/* ============ Tokens ============
   Mirrors the Gemini app's design system (myapp-Gemini/app/globals.css + CLAUDE.md "UI rules"):
   one five-step surface ladder per theme, monochrome, flat, radius 10px.
     1 --background  page
     2 --card        anything raised (cards, panels)
     3 --muted       recessed: chips, wells
     4 --accent      hover / selected, one step off whatever it sits on
     5 --border       edges (form fields and seams only)                         */
:root {
  --radius: 10px;
  --radius-sm: 6px;   /* small controls, tags */
  --radius-md: 8px;   /* standard controls */
  --radius-lg: 10px;  /* containers */

  --background: #f9f8f7;
  --foreground: oklch(0.1 0 0);
  --card: oklch(1 0 0);
  --popover: oklch(1 0 0);
  --primary: oklch(0.1 0 0);
  --primary-foreground: oklch(0.985 0 0);
  --secondary: oklch(0.94 0 0);
  --secondary-foreground: oklch(0.1 0 0);
  --muted: oklch(0.94 0 0);
  --muted-foreground: oklch(0.45 0 0);
  --accent: oklch(0.91 0 0);
  --destructive: oklch(0.577 0.245 27.325);
  --border: oklch(0.85 0 0);
  --input: var(--border);
  --ring: oklch(0.707 0 0);

  --font-sans: ui-sans-serif, system-ui, -apple-system, "Segoe UI", Roboto, Helvetica, Arial, "Apple Color Emoji", "Segoe UI Emoji";
  --font-mono: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, "Liberation Mono", "Courier New", monospace;

  --safe-top: env(safe-area-inset-top, 0px);
  --safe-bottom: env(safe-area-inset-bottom, 0px);
  color-scheme: light;
}

@media (prefers-color-scheme: dark) {
  :root {
    --background: oklch(0.17 0 0);
    --foreground: oklch(0.92 0.016 95);
    --card: oklch(0.20 0 0);
    --popover: oklch(0.20 0 0);
    --primary: oklch(0.92 0.016 95);
    --primary-foreground: oklch(0.23 0 0);
    --secondary: oklch(0.24 0 0);
    --secondary-foreground: oklch(0.66 0.013 102);
    --muted: oklch(0.24 0 0);
    --muted-foreground: oklch(0.66 0.013 102);
    --accent: oklch(0.27 0 0);
    --destructive: oklch(0.704 0.191 22.216);
    --border: oklch(0.34 0 0);
    --ring: oklch(0.66 0.013 102);
    color-scheme: dark;
  }
}

/* ============ Base ============ */
* { box-sizing: border-box; }
/* Components below set display:flex/grid, which would otherwise override the hidden attribute. */
[hidden] { display: none !important; }
html, body { height: 100%; }
body {
  margin: 0;
  background: var(--background);
  color: var(--foreground);
  font-family: var(--font-sans);
  font-size: 16px;
  line-height: 1.5;
  font-weight: 500;
  -webkit-font-smoothing: antialiased;
  -webkit-tap-highlight-color: transparent;
  overflow-x: hidden;
}
button { font: inherit; color: inherit; }
a { color: var(--foreground); text-underline-offset: 4px; }
code {
  font: 12px/1.4 var(--font-mono);
  background: var(--muted);
  padding: 2px 6px;
  border-radius: var(--radius-sm);
}
:focus-visible { outline: none; box-shadow: 0 0 0 3px color-mix(in oklch, var(--ring) 50%, transparent); }

/* Lucide icons: 16px everywhere, stroke 2 → 1.33px visible, set here not per icon. */
.lucide {
  width: 16px; height: 16px; flex-shrink: 0;
  fill: none; stroke: currentColor; stroke-width: 2;
  stroke-linecap: round; stroke-linejoin: round;
}

#app { height: 100%; }
.screen { height: 100%; display: flex; flex-direction: column; }

/* ============ Topbar ============ */
.topbar {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: calc(8px + var(--safe-top)) 8px 8px;
  background: var(--background);
  position: sticky;
  top: 0;
  z-index: 5;
}
.brand { display: flex; align-items: center; gap: 8px; padding: 0 8px; font-size: 14px; font-weight: 600; min-height: 32px; }
.topbar-title {
  font-size: 14px; font-weight: 600; min-width: 0;
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}

/* Main header, laid out like Eagle's: title left, slider centred, search right. */
.topbar-main { display: grid; grid-template-columns: minmax(0, 1fr) auto minmax(0, 1fr); gap: 12px; }
.topbar-start { display: flex; align-items: center; gap: 8px; min-width: 0; }
.topbar-start .topbar-title { padding-left: 8px; flex-shrink: 1; }
.topbar-start .icon-btn + .topbar-title { padding-left: 0; }
.topbar-end { display: flex; align-items: center; justify-content: flex-end; gap: 8px; min-width: 0; }

/* Search field — a form field, so it keeps the 1px edge. */
/* Collapsed to the search icon until opened; then it grows into a field. */
.header-search {
  display: flex; align-items: center; gap: 8px; overflow: hidden;
  width: 0; height: 32px; padding: 0; opacity: 0; pointer-events: none;
  border: none; border-radius: var(--radius-md);
  color: var(--muted-foreground); cursor: text;
  transition: width .2s ease, opacity .15s;
}
/* Open: a quiet fill, no outline or focus ring (user preference over the
   Gemini "fields keep an edge" rule — the fill marks it as a field instead). */
.topbar-main.searching .header-search {
  width: min(240px, 100%); padding: 0 10px; opacity: 1; pointer-events: auto;
  background: var(--muted);
}
.topbar-main.searching #btn-search-toggle { display: none; }

.header-search input {
  flex: 1; min-width: 0; height: 100%; padding: 0; border: none; outline: none; background: transparent;
  color: var(--foreground); font: inherit; font-size: 16px; /* no iOS zoom on focus */
}
.header-search input:focus-visible { box-shadow: none; }
.header-search input::-webkit-search-cancel-button { -webkit-appearance: none; appearance: none; }
@media (min-width: 768px) { .header-search input { font-size: 14px; } }

/* Phone: no room for a search field beside the title and slider — an icon
   instead, which swaps the header for a full-width field. */
@media (max-width: 767px) {
  .topbar-main { display: flex; gap: 8px; }
  .topbar-start { flex: 1; }
  .topbar-main .zoom .icon-btn-sm { display: none; }
  .topbar-main .zoom input[type="range"] { width: 72px; }
  .header-search { display: none; }
  .topbar-main.searching #btn-search-toggle { display: inline-flex; } /* stays as the close button */
  #sync-status-text { display: none; } /* the dots alone say "working" here */
  .topbar-main.searching .topbar-start,
  .topbar-main.searching .zoom { display: none; }
  .topbar-main.searching .topbar-end { flex: 1; }
  .topbar-main.searching .header-search { display: flex; flex: 1; width: auto; }
}

/* Icon button — ToolbarButton md: 32px, flat, muted at rest, accent on hover. */
.icon-btn {
  width: 32px; height: 32px; flex-shrink: 0;
  display: inline-flex; align-items: center; justify-content: center;
  border: none; background: transparent; padding: 0;
  color: var(--muted-foreground);
  border-radius: var(--radius-sm);
  cursor: pointer;
  transition: background-color .15s, color .15s;
}
.icon-btn:hover, .icon-btn:active { background: var(--accent); color: var(--foreground); }
.icon-btn.is-active { background: var(--accent); color: var(--foreground); }

/* ============ Buttons — fills, never outlines ============ */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  height: 36px; padding: 0 16px;
  border: none; border-radius: var(--radius-md);
  background: var(--muted); color: var(--foreground);
  font-size: 14px; font-weight: 500; white-space: nowrap;
  cursor: pointer;
  transition: background-color .15s;
}
.btn:hover { background: var(--accent); }
.btn:disabled { opacity: .5; pointer-events: none; }
.btn-primary { background: var(--primary); color: var(--primary-foreground); }
.btn-primary:hover { background: color-mix(in oklch, var(--primary) 90%, transparent); }
.btn-ghost { background: transparent; }
.btn-block { width: 100%; }
.btn-small { height: 32px; padding: 0 12px; }

/* ============ Form fields — the only thing a 1px line means ============ */
.input,
.field input[type="text"],
.add-row input {
  width: 100%; min-width: 0; height: 36px; padding: 4px 12px;
  border: 1px solid var(--input); border-radius: var(--radius-md);
  background: transparent; color: var(--foreground);
  font: inherit; font-size: 16px; /* 16px on phones so iOS doesn't zoom on focus */
  outline: none;
  transition: box-shadow .15s, border-color .15s;
}
.field input[type="text"]:focus-visible,
.add-row input:focus-visible {
  border-color: var(--ring);
  box-shadow: 0 0 0 3px color-mix(in oklch, var(--ring) 50%, transparent);
}
::placeholder { color: var(--muted-foreground); opacity: 1; }
@media (min-width: 768px) {
  .field input[type="text"], .add-row input { font-size: 14px; }
}

/* ============ Settings screen ============ */
.settings-body {
  flex: 1; overflow-y: auto;
  padding: 24px 16px calc(32px + var(--safe-bottom));
  max-width: 480px; margin: 0 auto; width: 100%;
}
.settings-title { font-size: 24px; font-weight: 600; line-height: 1.25; margin: 0 0 8px; text-wrap: balance; }
.lede { font-size: 16px; color: var(--muted-foreground); margin: 0 0 24px; }
.settings-card { background: var(--card); border-radius: var(--radius-lg); padding: 16px; }
.field { display: block; margin-bottom: 16px; }
.field-label { display: block; font-size: 14px; font-weight: 500; margin-bottom: 8px; }
.field-hint { display: block; font-size: 12px; color: var(--muted-foreground); margin-top: 8px; }
.checkbox-field { display: flex; align-items: flex-start; gap: 8px; font-size: 14px; }
.checkbox-field input { margin: 3px 0 0; width: 16px; height: 16px; accent-color: var(--primary); }

.advanced { margin-top: 24px; }
.advanced summary { cursor: pointer; font-size: 14px; color: var(--muted-foreground); }
.advanced summary:hover { color: var(--foreground); }
.advanced p { font-size: 14px; color: var(--muted-foreground); margin: 8px 0 0; }
.copy-row { display: flex; align-items: center; gap: 8px; margin-top: 8px; }
.copy-row code { flex: 1; overflow-x: auto; white-space: nowrap; padding: 8px; }

/* ============ Sync status (in the header, after the title) ============ */
.sync-status {
  display: flex; align-items: center; gap: 8px; min-width: 0;
  font-size: 12px; color: var(--muted-foreground);
}
#sync-status-text { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

/* Spinner — three dots, same as the Gemini app's <Spinner>. */
.spinner { display: inline-flex; align-items: center; gap: 5px; }
.spinner span {
  display: block; width: 5px; height: 5px; border-radius: 999px;
  background: var(--muted-foreground);
  animation: dot-bounce 1.2s ease-in-out infinite;
}
.spinner span:nth-child(2) { animation-delay: .2s; }
.spinner span:nth-child(3) { animation-delay: .4s; }
@keyframes dot-bounce {
  0%, 80%, 100% { transform: scale(.6); opacity: .4; }
  40% { transform: scale(1); opacity: 1; }
}

/* ============ Tile size slider (in the header) ============ */
.zoom { display: flex; align-items: center; gap: 2px; }
.icon-btn.icon-btn-sm { width: 24px; height: 24px; }
.zoom input[type="range"] {
  -webkit-appearance: none; appearance: none;
  width: 88px; height: 24px; margin: 0; background: transparent; cursor: pointer;
}
/* A track is a genuine capsule, so rounded-full is right here. */
.zoom input[type="range"]::-webkit-slider-runnable-track { height: 3px; border-radius: 999px; background: var(--accent); }
.zoom input[type="range"]::-moz-range-track { height: 3px; border-radius: 999px; background: var(--accent); }
.zoom input[type="range"]::-webkit-slider-thumb {
  -webkit-appearance: none; width: 12px; height: 12px; margin-top: -4.5px;
  border-radius: 999px; border: none; background: var(--foreground);
}
.zoom input[type="range"]::-moz-range-thumb { width: 12px; height: 12px; border-radius: 999px; border: none; background: var(--foreground); }

/* ============ Grid — justified rows (see renderGrid in app.js) ============ */
.grid {
  flex: 1; overflow-y: auto; position: relative;
  scrollbar-gutter: stable; /* a scrollbar appearing mustn't change the row width */
  padding: 0 8px calc(24px + var(--safe-bottom));
}
.grid-row { display: flex; gap: 4px; margin-bottom: 4px; }

.cell {
  position: relative; overflow: hidden; flex: none; height: 100%;
  display: block; min-width: 0; padding: 0; border: none;
  background: var(--muted); border-radius: var(--radius-sm);
  cursor: pointer;
}
.cell.cell-fill { flex: 1 1 auto; }
/* Selected: a two-tone ring inside the tile, readable on any image. */
.cell.is-selected::after {
  content: ""; position: absolute; inset: 0; border-radius: inherit; pointer-events: none;
  border: 2px solid var(--foreground); box-shadow: inset 0 0 0 2px var(--background);
}
@media (pointer: fine) { .cell { cursor: default; } }
.grid-row.is-compact .cell.is-file .cell-name { display: none; }
/* Skeleton while the thumbnail loads: bg-accent, pulsing. */
.cell.is-loading { background: var(--accent); animation: pulse 2s cubic-bezier(.4, 0, .6, 1) infinite; }
@keyframes pulse { 50% { opacity: .5; } }
.cell img { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; display: block; }
.cell .cell-ext {
  position: absolute; inset: 0; display: flex; flex-direction: column;
  align-items: center; justify-content: center; gap: 4px; padding: 8px;
  color: var(--muted-foreground); font-size: 12px; font-weight: 600; letter-spacing: .04em;
}
/* Images speak for themselves; only non-image files show their name. */
.cell .cell-name { display: none; }
.cell.is-file .cell-name {
  display: block; position: absolute; left: 8px; right: 8px; bottom: 8px;
  font-size: 12px; color: var(--muted-foreground); text-align: center;
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}

.empty-state {
  flex: 1; display: grid; place-items: center;
  color: var(--muted-foreground); font-size: 16px; padding: 40px; text-align: center;
}
.empty-state p { margin: 0; transform: translateY(-3vh); }

/* ============ Overlays ============ */
.drawer-overlay { position: fixed; inset: 0; background: rgb(0 0 0 / .5); z-index: 20; }

/* Drawer floats over the page → shadow-lg, no border. */
.drawer {
  position: fixed; top: 0; left: 0; bottom: 0; width: min(300px, 84vw);
  background: var(--background); z-index: 21; display: flex; flex-direction: column;
  padding-top: var(--safe-top); padding-bottom: var(--safe-bottom);
  box-shadow: 0 10px 15px -3px rgb(0 0 0 / .1), 0 4px 6px -4px rgb(0 0 0 / .1);
}
.drawer-header, .sheet-header {
  display: flex; align-items: center; justify-content: space-between;
  padding: 8px 8px 8px 16px; font-size: 14px; font-weight: 600;
}
#btn-hide-sidebar { display: none; }
body.has-sidebar #btn-hide-sidebar { display: inline-flex; }
.drawer-footer { border-top: 1px solid var(--border); padding: 8px; display: grid; gap: 2px; }

/* Folder tree — sidebar rows: 14px, 8px indent per level, accent on hover/active. */
.folder-tree { list-style: none; margin: 0; padding: 0 8px 8px; overflow-y: auto; flex: 1; }
.folder-tree ul { list-style: none; margin: 0; padding: 0; }
.folder-tree ul ul { padding-left: 8px; }
.folder-row {
  display: flex; align-items: center; min-height: 32px;
  border-radius: var(--radius-md); transition: background-color .15s;
}
.folder-row:hover, .folder-row.active { background: var(--accent); }
.folder-icon, .folder-toggle {
  width: 24px; height: 24px; margin-left: 4px; flex-shrink: 0;
  display: inline-flex; align-items: center; justify-content: center;
  padding: 0; border: none; background: transparent; border-radius: var(--radius-sm);
  color: var(--muted-foreground);
}
.folder-toggle { cursor: pointer; }
.folder-toggle:hover { color: var(--foreground); }
.folder-toggle-icon, .folder-toggle-chevron { display: inline-flex; }
.folder-toggle-chevron { display: none; transition: transform .15s; }
.folder-toggle[aria-expanded="true"] .folder-toggle-chevron { transform: rotate(90deg); }
.folder-row:hover .folder-toggle-icon, .folder-toggle:focus-visible .folder-toggle-icon { display: none; }
.folder-row:hover .folder-toggle-chevron, .folder-toggle:focus-visible .folder-toggle-chevron { display: inline-flex; }
.folder-main {
  flex: 1; min-width: 0; align-self: stretch;
  display: flex; align-items: center; gap: 8px;
  padding: 6px 8px 6px 4px; border: none; background: transparent;
  border-radius: var(--radius-md);
  color: var(--foreground); font-size: 14px; font-weight: 500; text-align: left; cursor: pointer;
}
.folder-row .folder-name { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.folder-row .folder-count {
  flex-shrink: 0; font-size: 12px; color: var(--muted-foreground);
  font-family: var(--font-mono); font-variant-numeric: tabular-nums;
}
.folder-row .folder-lock { display: inline-flex; color: var(--muted-foreground); }
.folder-relock {
  width: 24px; height: 24px; margin-right: 4px; flex-shrink: 0;
  display: inline-flex; align-items: center; justify-content: center;
  padding: 0; border: none; background: transparent; border-radius: var(--radius-sm);
  color: var(--muted-foreground); cursor: pointer;
}
.folder-relock:hover { color: var(--foreground); }
@media (pointer: coarse) { .folder-relock { width: 32px; height: 32px; } }
.folder-row .folder-check { display: inline-flex; color: var(--foreground); }

.menu-row {
  display: flex; align-items: center; gap: 8px; width: 100%;
  min-height: 32px; padding: 6px 8px;
  border: none; background: transparent; border-radius: var(--radius-md);
  color: var(--foreground); font-size: 14px; font-weight: 500; text-align: left;
  cursor: pointer; transition: background-color .15s;
}
.menu-row .lucide { color: var(--muted-foreground); }
/* Drop target while dragging images onto a folder. */
.folder-row.is-drop-target { background: var(--accent); box-shadow: inset 0 0 0 2px var(--foreground); }
.drag-chip {
  position: fixed; top: -100px; left: -100px; padding: 4px 8px; border-radius: var(--radius-sm);
  background: var(--primary); color: var(--primary-foreground); font-size: 12px; font-weight: 500;
}
.menu-row:hover { background: var(--accent); }
/* Quiet row (Disconnect): grey at rest, full colour on hover — present, not alarming. */
.menu-row.is-quiet { color: var(--muted-foreground); }
.menu-row.is-quiet:hover { color: var(--foreground); }

/* Desktop: docked sidebar. It is the page (step 1), separated from the grid by a
   full-height seam — not a floating panel, so no shadow and no backdrop. */
@media (min-width: 768px) {
  body.has-sidebar #app { display: flex; }
  body.has-sidebar #screen-main { flex: 1; min-width: 0; }
  body.has-sidebar .drawer {
    position: static; order: -1; flex: none; width: 256px; height: 100%; z-index: auto;
    box-shadow: none; border-right: 1px solid var(--border);
  }
  body.has-sidebar .drawer-header { min-height: 48px; }
  body.has-sidebar #btn-close-drawer { display: none; }
  /* Sidebar open: its own header holds the hide button, so ☰ steps aside. */
  body.has-sidebar.sidebar-open #btn-open-folders { display: none; }
}

/* ============ Viewer ============ */
.viewer {
  position: fixed; inset: 0; z-index: 30;
  background: var(--background); color: var(--foreground);
  display: flex; flex-direction: column;
}
.viewer-topbar {
  display: flex; align-items: center; gap: 8px;
  padding: calc(8px + var(--safe-top)) 8px 8px;
}
.viewer-title {
  flex: 1; text-align: center; font-size: 14px; font-weight: 600;
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.viewer-stage {
  flex: 1; display: grid; place-items: center; overflow: hidden; position: relative; min-height: 0;
  padding: 0 8px 8px;
}
.viewer-stage img { max-width: 100%; max-height: 100%; object-fit: contain; border-radius: var(--radius-sm); }
.viewer-fallback { text-align: center; color: var(--muted-foreground); font-size: 16px; }
.viewer-fallback p { margin: 0; }
.viewer-fallback span { font-size: 24px; font-weight: 600; letter-spacing: .04em; display: block; margin-bottom: 8px; color: var(--foreground); }
.viewer-loading { position: absolute; }

/* Details panel is in the layout (not floating) → a flat card. */
.viewer-panel {
  background: var(--card);
  border-radius: var(--radius-lg) var(--radius-lg) 0 0;
  padding: 16px 16px calc(16px + var(--safe-bottom));
  max-height: 46vh; overflow-y: auto;
}
.panel-section { margin-bottom: 16px; }
.panel-label { font-size: 12px; font-weight: 500; color: var(--muted-foreground); margin-bottom: 8px; }
.chip-row { display: flex; flex-wrap: wrap; gap: 6px; }

/* Tag chip — Badge secondary: rounded-sm, px-2 py-1, 12px medium. Never a pill. */
.chip {
  display: inline-flex; align-items: center; gap: 4px;
  padding: 4px 4px 4px 8px; border-radius: var(--radius-sm);
  background: var(--secondary); color: var(--secondary-foreground);
  font-size: 12px; font-weight: 500; line-height: 16px;
}
.chip-remove {
  display: inline-flex; align-items: center; justify-content: center;
  width: 16px; height: 16px; padding: 0; border: none; border-radius: 4px;
  background: transparent; color: var(--muted-foreground); cursor: pointer;
}
.chip-remove .lucide { width: 12px; height: 12px; stroke-width: 2.67; }
.chip-remove:hover { background: var(--accent); color: var(--foreground); }
.chip-empty { font-size: 14px; color: var(--muted-foreground); }
.add-row { display: flex; gap: 8px; margin-top: 8px; }
.panel-meta { font-size: 12px; color: var(--muted-foreground); display: grid; gap: 2px; }
.panel-meta:empty { display: none; }
.panel-actions { display: flex; align-items: center; gap: 12px; }
.save-status { font-size: 12px; color: var(--muted-foreground); flex-shrink: 0; }
.save-status:empty { display: none; }

/* ============ Sheet (folder picker) — floats → shadow-lg, no border ============ */
.sheet {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 31;
  background: var(--background);
  border-radius: var(--radius-lg) var(--radius-lg) 0 0;
  max-height: 70vh; display: flex; flex-direction: column;
  padding-bottom: var(--safe-bottom);
  box-shadow: 0 -10px 15px -3px rgb(0 0 0 / .1), 0 -4px 6px -4px rgb(0 0 0 / .1);
}
.sheet-footer { padding: 8px 16px 16px; }

/* ============ Splash — the Gemini app's SplashScreen ============ */
.splash {
  position: fixed; inset: 0; z-index: 100; background: var(--background);
  transition: opacity 150ms ease;
}
.splash.is-hiding { opacity: 0; pointer-events: none; }
/* Cover on inset-0; centre against the dynamic viewport (what you can see). */
.splash-center { height: 100vh; height: 100dvh; display: flex; align-items: center; justify-content: center; }
/* inline-flex so the bar is exactly as wide as the word; lifted 3% off the
   geometric centre, which otherwise reads as low. */
.splash-mark {
  position: relative; display: inline-flex; flex-direction: column; align-items: stretch;
  transform: translateY(-3vh); transform: translateY(-3dvh);
}
.splash-word {
  font-family: "Times New Roman", Times, serif; font-size: 36px; font-weight: 700;
  letter-spacing: -0.02em; line-height: 1.2; color: var(--foreground);
  animation: splash-pulse 1.6s ease-in-out 1.4s infinite;
}
.splash-bar { margin-top: 3px; height: 3px; overflow: hidden; }
.splash-bar > div {
  height: 100%; border-radius: 999px; background: var(--primary); transform-origin: left center;
  /* fills once, then pulses with the word */
  animation: underline-fill 1.4s cubic-bezier(0.4, 0, 0.2, 1) forwards,
             splash-pulse 1.6s ease-in-out 1.4s infinite;
}
/* Status hangs below the mark without widening it (the bar tracks the word). */
.splash-status {
  position: absolute; top: 100%; left: 50%; transform: translateX(-50%);
  margin: 16px 0 0; white-space: nowrap;
  font-size: 14px; color: var(--muted-foreground); font-variant-numeric: tabular-nums;
}
@keyframes underline-fill { 0% { transform: scaleX(0); } 100% { transform: scaleX(1); } }
@keyframes splash-pulse { 0%, 100% { opacity: 1; } 50% { opacity: .3; } }

/* ============ Dialog (unlock) — floats, so shadow-lg and no border ============ */
.dialog-overlay { z-index: 40; }
.dialog {
  position: fixed; left: 50%; top: 50%; transform: translate(-50%, -50%); z-index: 41;
  width: min(360px, calc(100vw - 32px)); padding: 24px;
  background: var(--popover); border-radius: var(--radius-lg);
  box-shadow: 0 10px 15px -3px rgb(0 0 0 / .1), 0 4px 6px -4px rgb(0 0 0 / .1);
  display: flex; flex-direction: column; gap: 12px;
}
.dialog-title { font-size: 18px; font-weight: 600; }
.dialog-text { margin: 0; font-size: 14px; color: var(--muted-foreground); }
.dialog-error { margin: 0; font-size: 14px; color: var(--destructive); }
.dialog-actions { display: flex; justify-content: flex-end; gap: 8px; margin-top: 4px; }
.dialog .input:focus-visible { border-color: var(--ring); box-shadow: 0 0 0 3px color-mix(in oklch, var(--ring) 50%, transparent); }
@media (pointer: coarse) { .dialog .input { height: 40px; } }

/* ============ Toast — a floating popover ============ */
.toast {
  position: fixed; left: 50%; bottom: calc(24px + var(--safe-bottom));
  transform: translateX(-50%);
  background: var(--popover); color: var(--foreground);
  padding: 12px 16px; border-radius: var(--radius-lg);
  font-size: 14px; z-index: 50; width: max-content; max-width: calc(100vw - 32px); text-align: center;
  box-shadow: 0 10px 15px -3px rgb(0 0 0 / .1), 0 4px 6px -4px rgb(0 0 0 / .1);
}

/* ============ Touch: same scale one step up (24→32, 32→40), rows grow to 40 ============ */
@media (pointer: coarse) {
  .icon-btn { width: 40px; height: 40px; }
  .topbar, .viewer-topbar { gap: 12px; }
  .btn { height: 40px; }
  .btn-small { height: 36px; }
  .folder-row, .menu-row { min-height: 40px; }
  /* No hover on touch: parents always show the arrow, in a 32px tap square. */
  .folder-icon, .folder-toggle { width: 32px; height: 32px; margin-left: 0; }
  .folder-toggle-icon { display: none !important; }
  .folder-toggle-chevron { display: inline-flex; }
  .field input[type="text"], .add-row input { height: 40px; }
  .header-search { height: 40px; }
  .chip-remove { width: 24px; height: 24px; }
  .icon-btn.icon-btn-sm { width: 32px; height: 32px; }
}

@media (prefers-reduced-motion: reduce) {
  * { transition: none !important; animation: none !important; }
}
