/**
 * Tools Folio — Component Classes
 * Reusable UI components for all tool pages.
 * Load order: 3rd (after tf-tokens.css)
 * All classes prefixed tf- to avoid collisions.
 * Tools override via inline <style> which always wins (loaded after).
 */

/* ─────────────────────────────────────────────────────────────────────────────
   1. BASE RESET
───────────────────────────────────────────────────────────────────────────── */

*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
html, body {
  height: 100%;
  font-family: var(--font-sans);
  font-size: 14px; color: var(--ink);
  background: var(--surface-3);
  overflow: hidden;   /* desktop: scroll happens in inner containers */
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}
body { display: flex; flex-direction: column; }
button { cursor: pointer; font: inherit; border: none; background: none; }
input, textarea, select { font: inherit; color: var(--ink); }
a { color: inherit; text-decoration: none; }

/* Mobile: unlock body scroll for overlay panel + full-page scroll */
@media (max-width: 768px) {
  html, body { overflow: auto; height: auto; }
  body { display: block; }
}

/* Accessibility: reduced motion */
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: 0.01ms !important;
    transition-duration: 0.01ms !important;
  }
}

/* ─────────────────────────────────────────────────────────────────────────────
   2. UTILITY CLASSES
───────────────────────────────────────────────────────────────────────────── */

.tf-sr-only {
  position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px;
  overflow: hidden; clip: rect(0,0,0,0); white-space: nowrap; border: 0;
}
.tf-spacer { flex: 1; }
.tf-no-print { /* marked for print suppression — see @media print block */ }

/* ─────────────────────────────────────────────────────────────────────────────
   3. ACCESSIBILITY: FOCUS STATES
───────────────────────────────────────────────────────────────────────────── */

/* Dark background context (topbar buttons) */
.tf-tb-btn:focus-visible,
.tf-tb-btn-primary:focus-visible,
.tf-tb-btn-secondary:focus-visible,
.tf-burger:focus-visible {
  outline: 2px solid rgba(255,255,255,.6);
  outline-offset: 2px;
}

/* Light background context (panel buttons, tabs, fields) */
.tf-btn:focus-visible,
.tf-tab:focus-visible,
.tf-tab-pill:focus-visible,
.tf-chip:focus-visible,
.tf-toggle-btn:focus-visible,
.tf-section-head:focus-visible,
.tf-add-btn:focus-visible,
.tf-swatch:focus-visible,
.tf-remove-btn:focus-visible {
  outline: 2px solid var(--accent, var(--tf-amber));
  outline-offset: 2px;
}

/* ─────────────────────────────────────────────────────────────────────────────
   4. TOPBAR BUTTONS (dark background context — inside <tf-topbar>)
───────────────────────────────────────────────────────────────────────────── */

/* .tf-tb-btn — Ghost/secondary topbar button */
.tf-tb-btn {
  display: inline-flex; align-items: center; gap: 5px;
  padding: 5px 11px; border-radius: 6px;
  border: 1px solid rgba(255,255,255,.1);
  background: rgba(255,255,255,.05); color: rgba(255,255,255,.8);
  font-family: var(--font-sans); font-size: 11.5px; font-weight: 500;
  cursor: pointer; transition: all var(--duration-fast); white-space: nowrap;
}
.tf-tb-btn:hover { background: rgba(255,255,255,.1); border-color: rgba(255,255,255,.18); color: #fff; }
.tf-tb-btn:disabled { opacity: .3; cursor: default; pointer-events: none; }
.tf-tb-btn.active { background: rgba(232,148,58,.2); border-color: rgba(232,148,58,.4); color: #F5A961; }
.tf-tb-btn svg {
  width: 13px; height: 13px; stroke: currentColor; fill: none;
  stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; flex-shrink: 0;
}

@media (max-width: 768px) {
  .tf-tb-btn { padding: 10px 14px; min-height: 44px; }
}

/* .tf-tb-btn-primary — Brand amber CTA (PDF / Download — always amber, never follows --accent) */
.tf-tb-btn-primary {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 6px 16px; border-radius: 6px; border: none;
  background: linear-gradient(135deg, #F5A961, var(--tf-amber));
  color: #fff;
  font-family: var(--font-sans); font-size: 13px; font-weight: 600;
  cursor: pointer; transition: all var(--duration-fast); white-space: nowrap;
  box-shadow: 0 2px 8px rgba(232,148,58,.45);
}
.tf-tb-btn-primary:hover:not(:disabled) {
  box-shadow: 0 4px 16px rgba(232,148,58,.55); transform: translateY(-1px);
}
.tf-tb-btn-primary:active { transform: none; }
.tf-tb-btn-primary:disabled { opacity: .45; cursor: not-allowed; transform: none; }
.tf-tb-btn-primary svg {
  width: 13px; height: 13px; stroke: #fff; fill: none;
  stroke-width: 2.5; stroke-linecap: round; stroke-linejoin: round;
}

@media (max-width: 768px) {
  .tf-tb-btn-primary { padding: 10px 16px; min-height: 44px; }
}

/* .tf-tb-btn-secondary — Filled accent button (topbar) */
.tf-tb-btn-secondary {
  display: inline-flex; align-items: center; gap: 5px;
  padding: 6px 14px; border-radius: 6px; border: none;
  background: var(--accent, var(--tf-amber)); color: #fff;
  font-family: var(--font-sans); font-size: 12px; font-weight: 600;
  cursor: pointer; transition: all var(--duration-fast); white-space: nowrap;
}
.tf-tb-btn-secondary:hover { background: var(--accent-dark, var(--tf-amber-dark)); }
.tf-tb-btn-secondary:disabled { opacity: .4; cursor: default; }
.tf-tb-btn-secondary svg {
  width: 13px; height: 13px; stroke: currentColor; fill: none;
  stroke-width: 2; stroke-linecap: round; stroke-linejoin: round;
}

/* .tf-tb-sep — Topbar vertical separator */
.tf-tb-sep {
  display: inline-block; width: 1px; height: 20px;
  background: rgba(255,255,255,.1); margin: 0 3px;
  flex-shrink: 0; align-self: center;
}

@media (max-width: 768px) {
  .tf-tb-sep { display: none; }
}

/* ─────────────────────────────────────────────────────────────────────────────
   5. PANEL / CONTENT AREA BUTTONS (light background context)
───────────────────────────────────────────────────────────────────────────── */

/* .tf-btn — Base button system */
.tf-btn {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 6px 14px; border-radius: var(--r); font-size: 13px; font-weight: 600;
  cursor: pointer; transition: var(--duration-fast); border: none; white-space: nowrap;
}
.tf-btn-primary  { background: var(--accent, var(--tf-amber)); color: #fff; }
.tf-btn-primary:hover  { background: var(--accent-dark, var(--tf-amber-dark)); }
.tf-btn-gold     { background: linear-gradient(135deg, #F5A961, var(--accent, var(--tf-amber))); color: #fff; }
.tf-btn-gold:hover { box-shadow: 0 2px 8px var(--accent-glow, var(--tf-amber-glow)); }
.tf-btn-outline  { background: transparent; color: var(--accent, var(--tf-amber)); border: 1.5px solid var(--accent, var(--tf-amber)); }
.tf-btn-outline:hover  { background: var(--accent-lite, var(--tf-amber-lite)); }
.tf-btn-ghost    { background: transparent; color: var(--ink-3); }
.tf-btn-ghost:hover    { background: var(--surface-3); }
.tf-btn-sm       { padding: 4px 10px; font-size: 12px; }
.tf-btn:disabled { opacity: .45; cursor: not-allowed; }
.tf-btn svg {
  width: 13px; height: 13px; stroke: currentColor; fill: none;
  stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; flex-shrink: 0;
}

@media (max-width: 768px) {
  .tf-btn    { min-height: 44px; padding: 0 16px; }
  .tf-btn-sm { min-height: 36px; padding: 0 12px; }
}

/* .tf-add-btn — Dashed "add entry" button */
.tf-add-btn {
  display: flex; align-items: center; justify-content: center; gap: 6px;
  padding: 7px; border-radius: 6px; border: 1.5px dashed var(--surface-4);
  font-size: 12px; font-weight: 600; color: var(--ink-4);
  transition: var(--duration-fast); width: 100%; background: transparent; cursor: pointer;
}
.tf-add-btn:hover { border-color: var(--accent, var(--tf-amber)); color: var(--accent, var(--tf-amber)); background: var(--accent-lite, var(--tf-amber-lite)); }

@media (max-width: 768px) {
  .tf-add-btn { min-height: 44px; font-size: 13px; }
}

/* Mobile touch targets for smaller interactive elements */
@media (max-width: 768px) {
  .tf-toggle-btn { min-height: 44px; padding: 0 10px; }
  .tf-chip       { min-height: 44px; padding: 0 14px; }
  .tf-tab-pill   { min-height: 44px; padding: 0 14px; }
}

/* .tf-chip — Selectable pill chip (templates, categories, filters) */
.tf-chip {
  display: inline-flex; align-items: center; gap: 4px;
  font-size: 11px; font-weight: 600; padding: 4px 10px; border-radius: 20px;
  background: var(--surface-3); border: 1.5px solid var(--surface-4); color: var(--ink-3);
  cursor: pointer; transition: var(--duration-fast); white-space: nowrap;
}
.tf-chip:hover:not(.active) { background: var(--accent-lite, var(--tf-amber-lite)); color: var(--accent, var(--tf-amber)); border-color: var(--accent, var(--tf-amber)); }
.tf-chip.active { background: var(--accent, var(--tf-amber)); color: #fff; border-color: var(--accent, var(--tf-amber)); }

/* .tf-toggle-group — Inline toggle button group (indent 2/4, flat/%, etc.) */
.tf-toggle-group {
  display: inline-flex; gap: 2px; background: var(--surface-3);
  border-radius: 6px; padding: 2px; border: 1px solid var(--surface-4);
}
.tf-toggle-btn {
  padding: 3px 8px; border-radius: 4px; font-size: 12px; font-weight: 600;
  border: none; background: transparent; color: var(--ink-3); cursor: pointer;
  transition: var(--duration-fast);
}
.tf-toggle-btn:hover:not(.active) { background: var(--surface-4); }
.tf-toggle-btn.active { background: var(--accent, var(--tf-amber)); color: #fff; }

/* ─────────────────────────────────────────────────────────────────────────────
   6. SECTION CARDS (ACCORDION)
───────────────────────────────────────────────────────────────────────────── */

/* .tf-section-card — Collapsible card in the panel */
.tf-section-card {
  background: var(--surface); border: 1px solid var(--surface-4);
  border-radius: var(--r); overflow: hidden;
}
.tf-section-head {
  display: flex; align-items: center; justify-content: space-between;
  padding: 10px 12px; cursor: pointer; user-select: none;
  background: var(--surface-2); transition: background var(--duration-fast);
}
.tf-section-head:hover { background: var(--surface-3); }
.tf-section-body {
  display: none; padding: 12px;
  border-top: 1px solid var(--surface-4);
  flex-direction: column; gap: 10px;
}
.tf-section-body.open { display: flex; }
.tf-chevron {
  font-size: 10px; color: var(--ink-4);
  transition: transform .2s var(--ease-standard);
}
.tf-section-head.open .tf-chevron { transform: rotate(180deg); }

@media (max-width: 768px) {
  .tf-section-head { padding: 14px 12px; min-height: 44px; }
}

/* .tf-icon-badge — Section header icon */
.tf-icon-badge {
  width: 28px; height: 28px; border-radius: 7px;
  background: linear-gradient(135deg, var(--surface-3), var(--surface-4));
  display: flex; align-items: center; justify-content: center;
  font-size: 14px; flex-shrink: 0;
  box-shadow: 0 1px 2px rgba(15,23,42,.07);
}
.tf-section-head.open .tf-icon-badge {
  background: var(--accent-lite, var(--tf-amber-lite));
}

/* .tf-entry-card — Repeating record within a section */
.tf-entry-card {
  background: var(--surface-2); border: 1px solid var(--surface-4);
  border-radius: 6px; padding: 10px 10px 10px 12px;
  position: relative; display: flex; flex-direction: column; gap: 8px;
}
.tf-remove-btn {
  position: absolute; top: 8px; right: 8px;
  width: 20px; height: 20px; border-radius: 50%;
  background: var(--surface-4); color: var(--ink-4);
  font-size: 10px; display: flex; align-items: center; justify-content: center;
  transition: var(--duration-fast); border: none; cursor: pointer;
}
.tf-remove-btn:hover { background: var(--color-error-bg); color: var(--color-error); }

@media (max-width: 768px) {
  .tf-remove-btn { width: 32px; height: 32px; font-size: 13px; }
}

/* .tf-entry-count — Badge showing item count on section header */
.tf-entry-count {
  font-size: 9px; font-weight: 700; padding: 1px 7px; border-radius: 10px;
  background: var(--accent, var(--tf-amber)); color: #fff;
}

/* ─────────────────────────────────────────────────────────────────────────────
   7. FORM FIELDS
───────────────────────────────────────────────────────────────────────────── */

/* .tf-field — Label + input/textarea/select group */
.tf-field { display: flex; flex-direction: column; gap: 4px; }
.tf-field label {
  font-size: 11px; font-weight: 600; color: var(--ink-3);
  text-transform: uppercase; letter-spacing: .5px;
}
.tf-field input,
.tf-field textarea,
.tf-field select {
  border: 1px solid var(--surface-4); border-radius: 6px;
  padding: 7px 10px; font-size: 13px; background: var(--surface);
  transition: border-color var(--duration-fast); width: 100%;
}
.tf-field input:focus,
.tf-field textarea:focus,
.tf-field select:focus {
  outline: none; border-color: var(--accent, var(--tf-amber)); box-shadow: 0 0 0 3px var(--accent-glow, var(--tf-amber-glow));
}
.tf-field input::placeholder,
.tf-field textarea::placeholder {
  color: var(--ink-5);
}

/* Two-column layout for paired fields (Start / End date, City / Country) */
.tf-field-row { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }

/* Mobile: 16px prevents iOS Safari auto-zoom on input focus */
@media (max-width: 768px) {
  .tf-field input,
  .tf-field textarea,
  .tf-field select { font-size: 16px; padding: 10px 12px; }
  .tf-field-row { grid-template-columns: 1fr; }
}

/* Small mobile: single column always */
@media (max-width: 600px) {
  .tf-field-row { grid-template-columns: 1fr; }
}

/* .tf-field-inline — Horizontal label + input for compact rows */
.tf-field-inline {
  display: flex; align-items: center; gap: 8px;
}
.tf-field-inline label {
  font-size: 11px; font-weight: 600; color: var(--ink-3);
  white-space: nowrap; min-width: 60px;
}
.tf-field-inline input,
.tf-field-inline select {
  flex: 1; border: 1px solid var(--surface-4); border-radius: 6px;
  padding: 5px 8px; font-size: 12px; background: var(--surface);
}

@media (max-width: 390px) {
  .tf-field-inline { flex-wrap: wrap; }
  .tf-field-inline label { white-space: normal; min-width: 0; width: 100%; }
  .tf-field-inline input, .tf-field-inline select { width: 100%; }
  .tf-list-item { flex-wrap: wrap; }
  .tf-list-item-actions { width: 100%; justify-content: flex-end; }
}

/* ─────────────────────────────────────────────────────────────────────────────
   8. BADGES & PILLS
───────────────────────────────────────────────────────────────────────────── */

.tf-badge {
  font-size: 11px; font-weight: 700; padding: 2px 8px; border-radius: 10px;
  display: inline-flex; align-items: center; gap: 4px;
}
.tf-badge-accent {
  background: var(--accent-lite, var(--tf-amber-lite)); color: var(--accent, var(--tf-amber));
  border: 1px solid color-mix(in srgb, var(--accent, var(--tf-amber)) 20%, transparent);
}
.tf-badge-success {
  background: var(--color-success-bg); color: var(--color-success);
  border: 1px solid var(--color-success-border);
}
.tf-badge-warning {
  background: var(--color-warning-bg); color: var(--color-warning);
  border: 1px solid var(--color-warning-border);
}
.tf-badge-error {
  background: var(--color-error-bg); color: var(--color-error);
  border: 1px solid var(--color-error-border);
}
.tf-badge-info {
  background: var(--color-info-bg); color: var(--color-info);
  border: 1px solid var(--color-info-border);
}

/* ─────────────────────────────────────────────────────────────────────────────
   9. PROGRESS BAR
───────────────────────────────────────────────────────────────────────────── */

.tf-progress-track {
  height: 6px; background: var(--surface-4); border-radius: 3px; overflow: hidden;
}
.tf-progress-fill {
  height: 100%; border-radius: 3px;
  transition: width .3s var(--ease-standard), background .3s;
  background: var(--accent, var(--tf-amber)); width: 0%;
}
.tf-progress-fill.gradient {
  background: linear-gradient(90deg, var(--accent, var(--tf-amber)), var(--accent-dark, var(--tf-amber-dark)));
}

/* ─────────────────────────────────────────────────────────────────────────────
   10. ALERT / BANNER
───────────────────────────────────────────────────────────────────────────── */

.tf-alert {
  display: none; align-items: flex-start; gap: 10px;
  padding: 12px 16px; border-radius: var(--r);
  font-size: 12.5px; line-height: 1.5;
}
.tf-alert.visible { display: flex; }
.tf-alert-success { background: var(--color-success-bg); border: 1.5px solid var(--color-success-border); color: var(--color-success); }
.tf-alert-warning { background: var(--color-warning-bg); border: 1.5px solid var(--color-warning-border); color: var(--color-warning); }
.tf-alert-error   { background: var(--color-error-bg); border: 1.5px solid var(--color-error-border); color: var(--color-error); }
.tf-alert-info    { background: var(--color-info-bg); border: 1.5px solid var(--color-info-border); color: var(--color-info); }

/* ─────────────────────────────────────────────────────────────────────────────
   11. STATUS VALIDATION PILL (inline in toolbars)
───────────────────────────────────────────────────────────────────────────── */

.tf-status-pill {
  font-size: 11px; font-weight: 600; padding: 2px 10px;
  border-radius: 10px; display: none; align-items: center; gap: 4px;
}
.tf-status-pill.visible { display: inline-flex; }
.tf-status-pill.ok   { background: var(--color-success-bg); color: var(--color-success); border: 1px solid var(--color-success-border); }
.tf-status-pill.err  { background: var(--color-error-bg); color: var(--color-error); border: 1px solid var(--color-error-border); }
.tf-status-pill.warn { background: var(--color-warning-bg); color: var(--color-warning); border: 1px solid var(--color-warning-border); }

/* ─────────────────────────────────────────────────────────────────────────────
   12. SEPARATORS
───────────────────────────────────────────────────────────────────────────── */

/* Light background context */
.tf-sep {
  display: inline-block; width: 1px; height: 16px;
  background: var(--surface-4); flex-shrink: 0; align-self: center;
}

/* Toolbar separator (slightly taller) */
.tf-toolbar-sep {
  display: inline-block; width: 1px; height: 20px;
  background: var(--surface-4); margin: 0 6px;
  flex-shrink: 0; align-self: center;
}

/* ─────────────────────────────────────────────────────────────────────────────
   13. TABS
───────────────────────────────────────────────────────────────────────────── */

/* .tf-tabs — Bottom-underline tab strip */
.tf-tabs { display: flex; border-bottom: 1px solid var(--surface-4); flex-shrink: 0; }
.tf-tab {
  flex: 1; padding: 10px; font-size: 13px; font-weight: 600;
  color: var(--ink-4); cursor: pointer; text-align: center;
  border: none; background: none;
  border-bottom: 2px solid transparent; transition: var(--duration-fast);
}
.tf-tab.active { color: var(--accent, var(--tf-amber)); border-bottom-color: var(--accent, var(--tf-amber)); }
.tf-tab:hover:not(.active) { color: var(--ink-2); }

@media (max-width: 768px) {
  .tf-tab { padding: 14px 10px; min-height: 44px; }
}

/* .tf-tabs-pill — Pill-style segmented control (alternative) */
.tf-tabs-pill {
  display: flex; gap: 0; padding: 3px;
  background: var(--surface-3); border-radius: 10px; flex-shrink: 0;
}
.tf-tab-pill {
  flex: 1; padding: 7px 12px; font-size: 12px; font-weight: 600;
  color: var(--ink-3); cursor: pointer; text-align: center;
  border: none; background: transparent; border-radius: 8px;
  transition: var(--duration-fast);
}
.tf-tab-pill.active {
  background: var(--surface); color: var(--ink);
  box-shadow: 0 1px 3px rgba(15,23,42,.08);
}

/* ─────────────────────────────────────────────────────────────────────────────
   14. COLOR SWATCHES
───────────────────────────────────────────────────────────────────────────── */

.tf-swatch {
  width: 20px; height: 20px; border-radius: 50%;
  border: 2px solid transparent; cursor: pointer;
  transition: transform var(--duration-fast), border-color var(--duration-fast);
}
.tf-swatch:hover { transform: scale(1.1); }
.tf-swatch.active { border-color: var(--ink-2); transform: scale(1.15); }

@media (max-width: 768px) {
  .tf-swatch { width: 28px; height: 28px; }
}

/* ─────────────────────────────────────────────────────────────────────────────
   15. CARDS (CONTENT)
───────────────────────────────────────────────────────────────────────────── */

.tf-card {
  background: var(--surface); border: 1px solid var(--surface-4);
  border-radius: var(--r); overflow: hidden;
  box-shadow: var(--shadow-card);
}
.tf-card-header {
  padding: 12px 16px; border-bottom: 1px solid var(--surface-3);
  display: flex; align-items: center; gap: 10px;
}
.tf-card-header-title { font-size: 13px; font-weight: 700; color: var(--ink-2); flex: 1; }
.tf-card-body { padding: 14px 16px; }

/* ─────────────────────────────────────────────────────────────────────────────
   16. GRID RULED (gap-as-border pattern)
───────────────────────────────────────────────────────────────────────────── */

.tf-grid-ruled {
  display: grid; gap: 1px; background: var(--surface-4);
  border-radius: var(--r); overflow: hidden; border: 1px solid var(--surface-4);
}
.tf-grid-ruled > * { background: var(--surface); }

/* ─────────────────────────────────────────────────────────────────────────────
   17. EMPTY STATE
───────────────────────────────────────────────────────────────────────────── */

.tf-empty {
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  height: 100%; padding: 32px; gap: 8px; text-align: center;
}
.tf-empty-icon { font-size: 32px; opacity: .4; }
.tf-empty-text { font-size: 13px; color: var(--ink-4); }

/* ─────────────────────────────────────────────────────────────────────────────
   18. SPINNER
───────────────────────────────────────────────────────────────────────────── */

.tf-spinner {
  width: 24px; height: 24px; border-radius: 50%;
  border: 3px solid var(--surface-4);
  border-top-color: var(--accent, var(--tf-amber));
  animation: tf-spin .7s linear infinite;
}
@keyframes tf-spin { to { transform: rotate(360deg); } }
.tf-spinner-sm { width: 16px; height: 16px; border-width: 2px; }

/* ─────────────────────────────────────────────────────────────────────────────
   19. ACCORDION (FAQ / Details)
───────────────────────────────────────────────────────────────────────────── */

.tf-accordion {
  background: var(--surface); border: 1px solid var(--surface-4);
  border-radius: var(--r); overflow: hidden;
}
.tf-accordion[open] { border-color: var(--accent, var(--tf-amber)); }
.tf-accordion summary {
  font-size: 13px; font-weight: 600; padding: 13px 16px; cursor: pointer;
  list-style: none; display: flex; justify-content: space-between; align-items: center;
}
.tf-accordion summary::after { content: '+'; font-size: 16px; color: var(--ink-4); }
.tf-accordion[open] summary::after { content: '-'; }
.tf-accordion .tf-accordion-body {
  font-size: 12.5px; color: var(--ink-3); line-height: 1.7; padding: 0 16px 14px;
}

@media (max-width: 768px) {
  .tf-accordion summary { min-height: 44px; padding: 12px 16px; }
}

/* ─────────────────────────────────────────────────────────────────────────────
   20. MODAL / DIALOG
───────────────────────────────────────────────────────────────────────────── */

/* .tf-modal-backdrop — For custom modal overlays (non-native <dialog>) */
.tf-modal-backdrop {
  display: none; position: fixed; inset: 0;
  z-index: var(--z-modal);
  background: rgba(0,0,0,.72);
  backdrop-filter: blur(4px); -webkit-backdrop-filter: blur(4px);
  align-items: center; justify-content: center;
}
.tf-modal-backdrop.visible { display: flex; }

.tf-modal {
  background: var(--surface); border-radius: 12px;
  box-shadow: var(--shadow-float);
  max-width: 480px; width: 90%; max-height: 85dvh;
  overflow-y: auto; padding: 24px;
  animation: tf-modal-in .2s var(--ease-decelerate);
}
@keyframes tf-modal-in {
  from { opacity: 0; transform: scale(.95) translateY(8px); }
  to   { opacity: 1; transform: scale(1) translateY(0); }
}
.tf-modal-title { font-size: 16px; font-weight: 700; color: var(--ink); margin-bottom: 12px; }
.tf-modal-actions { display: flex; gap: 8px; justify-content: flex-end; margin-top: 20px; }

/* Native <dialog> (preferred) */
dialog.tf-dialog {
  border: none; border-radius: 12px; padding: 24px;
  box-shadow: var(--shadow-float); max-width: 480px; width: 90%;
}
dialog.tf-dialog::backdrop {
  background: rgba(0,0,0,.72);
  backdrop-filter: blur(4px); -webkit-backdrop-filter: blur(4px);
}

/* ─────────────────────────────────────────────────────────────────────────────
   21. DROP ZONE (File Upload)
───────────────────────────────────────────────────────────────────────────── */

.tf-drop-zone {
  border: 2px dashed var(--surface-4); border-radius: var(--r);
  padding: 40px 24px; text-align: center;
  display: flex; flex-direction: column; align-items: center; gap: 12px;
  transition: border-color var(--duration-fast), background var(--duration-fast);
  cursor: pointer;
}
.tf-drop-zone:hover,
.tf-drop-zone.drag-over {
  border-color: var(--accent, var(--tf-amber)); background: var(--accent-lite, var(--tf-amber-lite));
}
.tf-drop-zone-icon { font-size: 32px; opacity: .6; }
.tf-drop-zone-text { font-size: 13px; color: var(--ink-3); font-weight: 500; }
.tf-drop-zone-hint { font-size: 11px; color: var(--ink-4); }

/* Processing state */
.tf-drop-zone.processing {
  pointer-events: none; opacity: .7;
  border-style: solid; border-color: var(--accent, var(--tf-amber));
}

/* Loaded state — compact with thumbnail */
.tf-drop-zone.loaded {
  padding: 16px; flex-direction: row; gap: 14px; text-align: left;
  border-style: solid; border-color: var(--surface-4); cursor: default;
}
.tf-drop-zone-thumb {
  width: 64px; height: 64px; object-fit: cover; border-radius: 6px; flex-shrink: 0;
}

@media (max-width: 768px) {
  .tf-drop-zone { padding: 32px 16px; }
}

/* ─────────────────────────────────────────────────────────────────────────────
   22. LIST ITEM (History / Records)
───────────────────────────────────────────────────────────────────────────── */

.tf-list-item {
  background: var(--surface-2); border: 1px solid var(--surface-4);
  border-radius: 6px; padding: 10px 12px;
  display: flex; align-items: center; justify-content: space-between; gap: 8px;
}
.tf-list-item:hover { background: var(--surface-3); }
.tf-list-item-meta { font-size: 11px; color: var(--ink-4); }
.tf-list-item-actions { display: flex; gap: 4px; }

/* ─────────────────────────────────────────────────────────────────────────────
   23. TOAST / NOTIFICATION
───────────────────────────────────────────────────────────────────────────── */

.tf-toast {
  position: fixed; bottom: 24px; left: 50%; transform: translateX(-50%);
  z-index: var(--z-toast);
  background: var(--ink); color: #fff; border-radius: 8px;
  padding: 10px 20px; font-size: 13px; font-weight: 500;
  box-shadow: var(--shadow-float);
  animation: tf-toast-in .25s var(--ease-decelerate);
  pointer-events: none;
}
@keyframes tf-toast-in {
  from { opacity: 0; transform: translateX(-50%) translateY(12px); }
  to   { opacity: 1; transform: translateX(-50%) translateY(0); }
}
.tf-toast.success { background: var(--color-success); }
.tf-toast.error   { background: var(--color-error); }

@media (max-width: 768px) {
  .tf-toast { bottom: calc(72px + env(safe-area-inset-bottom)); }
}

/* ─────────────────────────────────────────────────────────────────────────────
   24. CUSTOMISATION BAR (theme/template row)
───────────────────────────────────────────────────────────────────────────── */

.tf-custom-bar {
  background: var(--surface-3); border-radius: var(--r);
  padding: 10px 12px; display: flex; align-items: center; gap: 8px; flex-wrap: wrap;
}
.tf-custom-bar-label {
  font-size: 11px; font-weight: 600; color: var(--ink-4);
  text-transform: uppercase; letter-spacing: .6px; min-width: 60px;
}

/* ─────────────────────────────────────────────────────────────────────────────
   25. SCROLLBAR STYLING
───────────────────────────────────────────────────────────────────────────── */

/* Thin scrollbar for panels and scroll areas */
.tf-scroll::-webkit-scrollbar { width: 6px; height: 6px; }
.tf-scroll::-webkit-scrollbar-track { background: transparent; }
.tf-scroll::-webkit-scrollbar-thumb { background: var(--surface-4); border-radius: 3px; }
.tf-scroll::-webkit-scrollbar-thumb:hover { background: var(--ink-5); }

/* Firefox */
.tf-scroll { scrollbar-width: thin; scrollbar-color: var(--surface-4) transparent; }

/* ─────────────────────────────────────────────────────────────────────────────
   26. PRINT UTILITIES
───────────────────────────────────────────────────────────────────────────── */

@media print {
  .tf-no-print,
  .tf-tb-btn,
  .tf-tb-btn-primary,
  .tf-tb-btn-secondary,
  .tf-mob-toolbar,
  .tf-mob-overlay,
  .tf-bottom-sheet,
  .tf-resizer,
  .tf-preview-toolbar { display: none !important; }
}
