/* ────────────────────────────────────────────────────────────────────
   SS FILE HOST · DESIGN SYSTEM
   palette: navy + light + coral
   type:    Inter (single family)
   icons:   Material Symbols Rounded
   ──────────────────────────────────────────────────────────────────── */

@import url('https://fonts.googleapis.com/css2?family=Inter:wght@400;500;600;700&family=Saira:wght@500;600;700;800;900&family=JetBrains+Mono:wght@400;500;600&display=swap');
@import url('https://fonts.googleapis.com/css2?family=Material+Symbols+Rounded:opsz,wght,FILL,GRAD@20..48,300..600,0..1,-25..0&display=swap');

:root {
  /* navy — structural / sidebar / hero (deepest tone in the system) */
  --navy:          #14171d;
  --navy-2:        #1d2129;
  --navy-3:        #272c36;
  --navy-deep:     #0e1015;
  --navy-text:     #d0d4dc;
  --navy-dim:      #8a909c;

  /* MAIN — charcoal dark grey */
  --bg:            #16181d;
  --bg-grad:       linear-gradient(180deg, #16181d 0%, #181b21 100%);
  --surface:       #1f232a;
  --surface-2:     #262b34;
  --surface-3:     #2e343f;
  --surface-glass: rgba(22, 24, 29, 0.86);

  /* lines */
  --border:        #353c48;
  --border-2:      #444c5a;
  --border-soft:   #2a2f3a;

  /* text */
  --text:          #ecedf2;
  --text-2:        #d2d6e0;
  --text-dim:      #a6acba;
  --muted:         #7a8090;
  --mute:          #515663;

  /* coral — primary accent */
  --coral:         #fa8a72;
  --coral-deep:    #e16a55;
  --coral-dark:    #b94e3b;
  --coral-soft:    #fde2da;
  --coral-soft-2:  #fbcebe;
  --coral-glow:    0 8px 24px rgba(250, 138, 114, 0.35);

  /* status colours (for stat-card top borders & dots) */
  --stat-coral:    #fa8a72;
  --stat-amber:    #f2b94c;
  --stat-blue:     #5ba4e6;
  --stat-purple:   #9c8cf2;
  --stat-green:    #7ec896;
  --stat-amber-bg: #fef6e0;
  --stat-amber-border: #f5d989;
  --stat-amber-ink: #8b6a1c;

  --warn:          #f2b94c;
  --danger:        #e25a5a;
  --success:       #7ec896;

  /* category dots (subtle) */
  --cat-photo:      #fa8a72;
  --cat-screenshot: #9c8cf2;
  --cat-document:   #5ba4e6;
  --cat-receipt:    #f2b94c;
  --cat-code:       #7ec896;
  --cat-audio:      #b8a6e6;
  --cat-video:      #f29d7e;
  --cat-archive:    #aeb4be;
  --cat-other:      #c8ccd4;
  --cat-starred:    #f2b94c;
  --cat-recent:     #5ba4e6;

  /* shape */
  --r-xs:  6px;
  --r-sm:  10px;
  --r-md:  14px;
  --r-lg:  18px;
  --r-xl:  24px;
  --r-2xl: 32px;
  --r-full: 999px;

  /* depth */
  --shadow-xs: 0 1px 2px rgba(0, 0, 0, 0.35);
  --shadow-sm: 0 1px 3px rgba(0, 0, 0, 0.4), 0 1px 2px rgba(0, 0, 0, 0.25);
  --shadow-md: 0 6px 18px rgba(0, 0, 0, 0.45);
  --shadow-lg: 0 16px 40px rgba(0, 0, 0, 0.55);
  --shadow-coral: 0 8px 22px rgba(250, 138, 114, 0.32);
  --shadow-nav:   0 4px 12px rgba(0, 0, 0, 0.45);

  /* type — engineering ISO drafting palette */
  --f-body:    'Inter', system-ui, -apple-system, 'Segoe UI', Roboto, sans-serif;
  --f-display: 'Saira', 'Inter', system-ui, sans-serif;
  --f-mono:    'JetBrains Mono', ui-monospace, 'SF Mono', Menlo, monospace;
  --vs-display: normal;
  --vs-display-bold: normal;

  /* motion */
  --ease:      cubic-bezier(.32, .72, .25, 1);
  --ease-soft: cubic-bezier(.4, 0, .2, 1);
  --t-fast:    .14s;
  --t-base:    .22s;
  --t-slow:    .38s;

  /* safe-area */
  --sa-t: env(safe-area-inset-top);
  --sa-b: env(safe-area-inset-bottom);
  --sa-l: env(safe-area-inset-left);
  --sa-r: env(safe-area-inset-right);

  /* layout — condensed for mobile-first symmetry */
  --header-h:  52px;
  --tabs-h:    60px;
  --sidebar-w: 220px;
  --gutter:    12px;
  --gap:       10px;
  --gap-sm:    6px;

  /* dark-theme tints (was in @media before) */
  --coral-soft:    rgba(250, 138, 114, 0.18);
  --coral-soft-2:  rgba(250, 138, 114, 0.34);
  --stat-amber-bg: rgba(242, 185, 76, 0.12);
  --stat-amber-border: rgba(242, 185, 76, 0.38);
  --stat-amber-ink: #f5c266;
}

* { box-sizing: border-box; min-width: 0; }
html, body {
  margin: 0; padding: 0;
  background: var(--bg);
  color: var(--text);
  font-family: var(--f-body);
  font-size: 14.5px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
  -webkit-tap-highlight-color: transparent;
  -webkit-text-size-adjust: 100%;
       text-size-adjust: 100%;
  text-rendering: optimizeLegibility;
  font-feature-settings: 'cv11', 'ss01', 'kern';
  /* Hard zoom-lock: allow vertical/horizontal scroll, no pinch-zoom */
  touch-action: pan-x pan-y;
}
body {
  min-height: 100dvh;
  background: var(--bg-grad);
  background-attachment: fixed;
  overscroll-behavior-y: none;
  touch-action: pan-x pan-y;
}
/* Disable double-tap zoom on every interactive element */
button, a, input, select, textarea, .chip, .file-card, .coll-card, .nav-item, .tab, .list-row, .preset, .ic, .star-btn, .select-mark, .fab-inner {
  touch-action: manipulation;
}

button, input, select, textarea { font: inherit; color: inherit; }
button { background: none; border: 0; cursor: pointer; padding: 0; }
input, textarea, select { background: none; border: 0; outline: 0; }
a { color: inherit; text-decoration: none; }
img { display: block; max-width: 100%; }

:focus-visible {
  outline: 2px solid var(--coral);
  outline-offset: 2px;
  border-radius: var(--r-xs);
}
::selection { background: var(--coral-soft); color: var(--coral-dark); }

.hidden { display: none !important; }
.muted  { color: var(--muted); }
.dim    { color: var(--text-dim); }

/* ── Material Symbols (rounded) ── */
.icon {
  font-family: 'Material Symbols Rounded';
  font-weight: normal;
  font-style: normal;
  font-size: 22px;
  line-height: 1;
  letter-spacing: normal;
  text-transform: none;
  display: inline-block;
  white-space: nowrap;
  word-wrap: normal;
  direction: ltr;
  -webkit-font-feature-settings: 'liga';
  -webkit-font-smoothing: antialiased;
  font-variation-settings: 'opsz' 24, 'wght' 400, 'GRAD' 0, 'FILL' 0;
}
.icon.filled { font-variation-settings: 'opsz' 24, 'wght' 450, 'GRAD' 0, 'FILL' 1; }
.icon.sm     { font-size: 17px; font-variation-settings: 'opsz' 20, 'wght' 400, 'GRAD' 0, 'FILL' 0; }
.icon.lg     { font-size: 28px; font-variation-settings: 'opsz' 40, 'wght' 350, 'GRAD' 0, 'FILL' 0; }
.icon.xl     { font-size: 44px; font-variation-settings: 'opsz' 48, 'wght' 300, 'GRAD' 0, 'FILL' 0; }

/* ─────────────────────────────────────────────
   AUTH PAGE
   ───────────────────────────────────────────── */
.auth-page {
  position: relative;
  z-index: 1;
  display: grid;
  place-items: center;
  min-height: 100dvh;
  padding: 24px;
  padding-top: max(24px, var(--sa-t));
  padding-bottom: max(24px, var(--sa-b));
  background: var(--bg);
}
.auth-card {
  width: 100%;
  max-width: 400px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--r-xl);
  padding: 36px 32px 28px;
  display: grid;
  gap: 18px;
  box-shadow: var(--shadow-md);
}
.brand {
  display: grid;
  gap: 14px;
  place-items: center;
  text-align: center;
  margin-bottom: 4px;
}
.brand .mark {
  width: 64px; height: 64px;
  background: var(--coral);
  border-radius: 16px;
  display: grid; place-items: center;
  color: #fff;
  box-shadow: var(--shadow-coral);
}
.brand .mark .icon { font-size: 32px; color: #fff; font-variation-settings: 'opsz' 40, 'wght' 500, 'GRAD' 0, 'FILL' 1; }
.brand h1 {
  margin: 0;
  font-family: var(--f-display);
  font-size: 28px;
  font-weight: 800;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  color: var(--text);
}
.brand .sub {
  font-family: var(--f-mono);
  font-size: 11px;
  color: var(--muted);
  font-weight: 500;
  letter-spacing: 0.12em;
  text-transform: uppercase;
}

.stack { display: grid; gap: 14px; }
.field { display: grid; gap: 6px; }
.field-label {
  font-size: 13px;
  font-weight: 500;
  color: var(--text-dim);
  padding-left: 2px;
}
.field input {
  background: var(--surface-2);
  border: 1.5px solid var(--border);
  border-radius: var(--r-sm);
  padding: 12px 14px;
  font-size: 14.5px;
  color: var(--text);
  font-family: var(--f-body);
  transition: border-color var(--t-base) var(--ease-soft), background var(--t-base) var(--ease-soft), box-shadow var(--t-base) var(--ease-soft);
}
.field input:focus {
  border-color: var(--coral);
  background: var(--surface);
  outline: none;
  box-shadow: 0 0 0 4px var(--coral-soft);
}

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 7px;
  padding: 10px 16px;
  background: var(--surface-2);
  border: 1.5px solid var(--border);
  border-radius: var(--r-sm);
  color: var(--text);
  font-family: var(--f-display);
  font-size: 12.5px;
  font-weight: 700;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  cursor: pointer;
  transition: transform var(--t-fast) var(--ease), background var(--t-fast) var(--ease-soft), box-shadow var(--t-fast) var(--ease-soft);
  user-select: none;
}
.btn:hover { background: var(--surface-3); }
.btn:active { transform: scale(.98); }
.btn.primary {
  background: var(--coral);
  border-color: var(--coral);
  color: #fff;
  box-shadow: var(--shadow-coral);
}
.btn.primary:hover { background: var(--coral-deep); border-color: var(--coral-deep); }
.btn.dark {
  background: var(--navy);
  border-color: var(--navy);
  color: #fff;
}
.btn.dark:hover { background: var(--navy-2); }
.btn.outline-dark {
  background: transparent;
  border-color: rgba(255, 255, 255, 0.22);
  color: #fff;
}
.btn.outline-dark:hover { background: rgba(255, 255, 255, 0.08); }
.btn.danger { color: var(--danger); background: rgba(226, 90, 90, 0.08); border-color: rgba(226, 90, 90, 0.18); }
.btn.danger:hover { background: rgba(226, 90, 90, 0.14); }
.btn.ghost { background: transparent; }
.btn.full { width: 100%; }
.btn:disabled { opacity: .55; cursor: not-allowed; box-shadow: none; }

.divider {
  display: flex;
  align-items: center;
  gap: 12px;
  font-size: 12px;
  color: var(--muted);
}
.divider::before, .divider::after {
  content: '';
  flex: 1;
  height: 1px;
  background: var(--border);
}

.notice {
  background: var(--coral-soft);
  color: var(--coral-dark);
  padding: 12px 16px;
  border-radius: var(--r-sm);
  font-size: 13.5px;
  line-height: 1.5;
}
.error {
  color: var(--danger);
  background: rgba(226, 90, 90, 0.08);
  margin: 0;
  font-size: 13px;
  padding: 8px 12px;
  border-radius: var(--r-xs);
  min-height: 1.2em;
}
.error:empty { display: none; }

.tech-footer {
  display: flex;
  justify-content: center;
  gap: 14px;
  margin-top: 4px;
  padding-top: 14px;
  border-top: 1px solid var(--border-soft);
  font-size: 11.5px;
  color: var(--muted);
}

/* ─────────────────────────────────────────────
   APP SHELL — sidebar (desktop) + main
   ───────────────────────────────────────────── */
.app-page {
  position: relative;
  z-index: 1;
  display: flex;
  min-height: 100dvh;
  height: 100dvh;
  padding-bottom: calc(var(--tabs-h) + var(--sa-b));
}
@media (min-width: 900px) {
  .app-page { padding-bottom: 0; height: 100dvh; }
}
.main {
  flex: 1;
  min-width: 0;
  min-height: 0;
  display: flex;
  flex-direction: column;
  overflow-y: auto;
  overflow-x: hidden;
}

/* ── Sidebar ── */
.sidebar {
  display: none;
}
@media (min-width: 900px) {
  .sidebar {
    display: flex;
    flex-direction: column;
    position: sticky;
    top: 0;
    align-self: flex-start;
    width: var(--sidebar-w);
    height: 100dvh;
    background: var(--navy);
    color: var(--navy-text);
    padding: 14px 10px 10px;
    gap: 3px;
    box-shadow: var(--shadow-nav);
  }
}
.sidebar .brand-block {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 6px 8px 16px;
}
.sidebar .brand-mark {
  width: 34px; height: 34px;
  border-radius: 9px;
  background: var(--coral);
  display: grid; place-items: center;
  color: #fff;
  flex-shrink: 0;
}
.sidebar .brand-mark .icon { font-size: 20px; font-variation-settings: 'opsz' 24, 'wght' 600, 'GRAD' 0, 'FILL' 1; }
.sidebar .brand-text {
  flex: 1;
  font-family: var(--f-display);
  font-weight: 800;
  font-size: 17px;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  color: #fff;
}
.sidebar .brand-cog {
  width: 32px; height: 32px;
  border-radius: var(--r-full);
  display: grid; place-items: center;
  color: var(--navy-dim);
  background: var(--navy-2);
}
.sidebar .brand-cog:hover { color: #fff; }

.side-nav {
  display: grid;
  gap: 2px;
  margin-top: 6px;
}
.nav-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 11px;
  border-radius: var(--r-sm);
  color: var(--navy-text);
  font-family: var(--f-display);
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  width: 100%;
  text-align: left;
  transition: background var(--t-fast) var(--ease-soft), color var(--t-fast) var(--ease-soft);
  letter-spacing: 0.04em;
  text-transform: uppercase;
}
.nav-item:hover { background: var(--navy-2); color: #fff; }
.nav-item .icon { color: var(--navy-dim); font-size: 19px; }
.nav-item:hover .icon { color: #fff; }
.nav-item.active {
  background: var(--coral-soft);
  color: var(--coral-deep);
  font-weight: 600;
}
.nav-item.active .icon { color: var(--coral-deep); font-variation-settings: 'opsz' 24, 'wght' 500, 'GRAD' 0, 'FILL' 1; }

.side-foot {
  margin-top: auto;
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 12px 10px;
  border-top: 1px solid var(--navy-2);
}
.side-foot .ava {
  width: 32px; height: 32px;
  border-radius: var(--r-full);
  background: var(--coral);
  color: #fff;
  display: grid; place-items: center;
  font-weight: 600;
  font-size: 13px;
}
.side-foot .name {
  flex: 1;
  font-size: 13px;
  color: #fff;
  font-weight: 500;
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.side-foot .logout-btn {
  width: 32px; height: 32px;
  border-radius: var(--r-full);
  display: grid; place-items: center;
  color: var(--navy-dim);
}
.side-foot .logout-btn:hover { color: #fff; background: var(--navy-2); }

/* ── Main rules moved above ── */

/* Top app bar — visible on mobile; collapses on desktop */
.appbar {
  position: sticky;
  top: 0;
  z-index: 30;
  display: flex;
  align-items: center;
  gap: 4px;
  padding: 4px var(--gutter);
  padding-top: calc(4px + var(--sa-t));
  height: calc(var(--header-h) + var(--sa-t));
  background: var(--surface-glass);
  backdrop-filter: saturate(150%) blur(16px);
  -webkit-backdrop-filter: saturate(150%) blur(16px);
  border-bottom: 1px solid var(--border);
}
@media (min-width: 900px) {
  .appbar {
    background: var(--surface);
    border-bottom: 1px solid var(--border);
    padding: 8px 20px;
    height: var(--header-h);
    padding-top: 8px;
  }
}
.appbar .ic {
  display: inline-grid;
  place-items: center;
  width: 36px; height: 36px;
  border-radius: var(--r-full);
  color: var(--text-dim);
  transition: background var(--t-fast) var(--ease-soft), color var(--t-fast) var(--ease-soft);
}
.appbar .ic:hover { background: var(--surface-2); color: var(--text); }
.appbar .title {
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: 0;
  min-width: 0;
  padding: 0 4px;
}
.appbar .title .h {
  font-family: var(--f-display);
  font-size: 16px;
  font-weight: 800;
  letter-spacing: 0.02em;
  text-transform: uppercase;
  line-height: 1.05;
  color: var(--text);
}
.appbar .title .sub {
  font-family: var(--f-mono);
  font-size: 10.5px;
  color: var(--muted);
  font-weight: 500;
  letter-spacing: 0.04em;
  text-transform: uppercase;
}
.appbar .avatar-mini {
  width: 32px; height: 32px;
  border-radius: var(--r-full);
  background: var(--coral);
  color: #fff;
  display: grid; place-items: center;
  font-family: var(--f-display);
  font-weight: 800;
  font-size: 13px;
  letter-spacing: 0.02em;
  text-transform: uppercase;
}
@media (min-width: 900px) {
  .appbar .avatar-mini { display: none; }
}

/* Tab views container */
.views { flex: 1; position: relative; display: flex; flex-direction: column; min-height: 0; }
.view {
  display: none;
  padding: 8px var(--gutter) 20px;
  max-width: 1180px;
  margin: 0 auto;
  width: 100%;
  flex: 1;
  min-height: 0;
}
.view.active { display: block; animation: viewIn .2s var(--ease-soft); }
@keyframes viewIn {
  from { opacity: 0; transform: translateY(3px); }
  to   { opacity: 1; transform: translateY(0); }
}
@media (min-width: 900px) {
  .view { padding: 14px 20px 28px; }
}

/* Chat view fills the rest exactly — no inner scroll bleed */
.view[data-view="chat"] {
  display: none;
  padding: 0;
  max-width: 100%;
}
.view[data-view="chat"].active {
  display: flex;
  flex-direction: column;
  height: calc(100dvh - var(--header-h) - var(--tabs-h) - var(--sa-t) - var(--sa-b));
}
@media (min-width: 900px) {
  .view[data-view="chat"] { padding: 12px 16px 16px; max-width: 1180px; margin: 0 auto; }
  .view[data-view="chat"].active {
    height: calc(100dvh - var(--header-h) - 28px);
  }
}

/* ─────────────────────────────────────────────
   WELCOME HERO (Library top)
   ───────────────────────────────────────────── */
.hero-card {
  position: relative;
  background: var(--navy);
  color: #fff;
  border: 1px solid var(--border);
  border-radius: var(--r-md);
  padding: 14px 16px;
  margin-bottom: 12px;
  overflow: hidden;
}
.hero-card::after {
  content: '';
  position: absolute;
  right: -20px; top: -20px;
  width: 200px; height: 200px;
  border-radius: 50%;
  background: radial-gradient(circle, rgba(250, 138, 114, 0.16), transparent 70%);
  pointer-events: none;
}
.hero-card .date {
  font-family: var(--f-mono);
  font-size: 9.5px;
  font-weight: 500;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--navy-dim);
  margin-bottom: 4px;
  display: inline-block;
  padding: 3px 8px;
  background: rgba(255,255,255,0.06);
  border-radius: var(--r-full);
}
@media (min-width: 700px) {
  .hero-card .date { font-size: 10px; }
}
.hero-card h2 {
  margin: 0 0 10px;
  font-family: var(--f-display);
  font-size: 20px;
  font-weight: 800;
  letter-spacing: 0.005em;
  text-transform: uppercase;
  color: #fff;
  line-height: 1.05;
}
@media (min-width: 700px) {
  .hero-card { padding: 18px 22px; }
  .hero-card h2 { font-size: 26px; }
}
.hero-pills {
  display: flex;
  flex-wrap: wrap;
  gap: 5px;
  margin-bottom: 0;
}
@media (max-width: 700px) {
  .hero-pills { gap: 4px; }
  .hero-pill { padding: 3px 8px; font-size: 10px; }
}
.hero-pill {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 4px 10px;
  border-radius: var(--r-full);
  font-family: var(--f-mono);
  font-size: 10.5px;
  font-weight: 500;
  letter-spacing: 0.06em;
  text-transform: uppercase;
}
.hero-pill.coral {
  background: var(--coral-soft);
  color: var(--coral-deep);
}
.hero-pill.coral .dot { width: 7px; height: 7px; border-radius: 50%; background: var(--coral); }
.hero-pill.ghost {
  background: rgba(255, 255, 255, 0.08);
  color: #fff;
  border: 1px solid rgba(255, 255, 255, 0.16);
}
.hero-pill .icon { font-size: 14px; }

.hero-actions {
  position: absolute;
  right: 14px;
  top: 12px;
  display: flex;
  gap: 6px;
}
@media (max-width: 700px) {
  .hero-actions { right: 10px; top: 10px; }
  .hero-actions .btn { padding: 6px 8px; font-size: 11px; gap: 4px; min-width: 36px; }
  .hero-actions .btn .icon { font-size: 14px; }
  /* Hide the verbose label on small screens — keep just the icon for compactness */
  .hero-actions .btn .label-txt { display: none; }
}
.hero-actions .btn { padding: 7px 12px; font-size: 12px; }

/* Heavier separator between hero and rest */
.hero-card + .section-row { margin-top: 4px; }

/* ─────────────────────────────────────────────
   AT-A-GLANCE STAT CARDS
   ───────────────────────────────────────────── */
.glance {
  display: grid;
  gap: 8px;
  margin-bottom: 12px;
  /* Mobile-first: 2x2 grid with storage spanning full width on the third row */
  grid-template-columns: 1fr 1fr;
  grid-template-areas:
    "total   pending"
    "recent  starred"
    "storage storage";
}
.glance .stat[data-tone="coral"]  { grid-area: total; }
.glance .stat[data-tone="amber"]  { grid-area: pending; }
.glance .stat[data-tone="blue"]   { grid-area: recent; }
.glance .stat[data-tone="purple"] { grid-area: starred; }
.glance .stat[data-tone="green"]  { grid-area: storage; }

@media (min-width: 700px) {
  .glance {
    grid-template-columns: repeat(5, 1fr);
    grid-template-areas: "total pending recent starred storage";
    gap: 10px;
  }
}

.glance .stat {
  position: relative;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--r-md);
  padding: 9px 11px 10px;
  overflow: hidden;
  box-shadow: var(--shadow-sm);
}
/* The wide storage row gets number+label inline + a coral usage bar at the bottom */
@media (max-width: 700px) {
  .glance .stat[data-tone="green"] {
    display: flex;
    align-items: baseline;
    justify-content: space-between;
    gap: 12px;
    padding: 10px 14px;
  }
  .glance .stat[data-tone="green"] .n { font-size: 22px; }
  .glance .stat[data-tone="green"] .l { margin-top: 0; }
}
.glance .stat::before {
  content: '';
  position: absolute;
  inset: 0 0 auto 0;
  height: 2.5px;
  background: var(--mute);
  border-radius: var(--r-md) var(--r-md) 0 0;
}
.glance .stat .n {
  font-family: var(--f-mono);
  font-size: 20px;
  font-weight: 600;
  letter-spacing: -0.04em;
  line-height: 1;
  color: var(--text);
  font-feature-settings: 'tnum';
}
.glance .stat .l {
  margin-top: 5px;
  font-family: var(--f-mono);
  font-size: 9px;
  font-weight: 500;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--muted);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
@media (min-width: 700px) {
  .glance .stat .n { font-size: 24px; }
  .glance .stat .l { font-size: 10px; }
}
.glance .stat[data-tone="coral"]::before  { background: var(--stat-coral); }
.glance .stat[data-tone="coral"]  .n      { color: var(--stat-coral); }
.glance .stat[data-tone="amber"]::before  { background: var(--stat-amber); }
.glance .stat[data-tone="amber"]  .n      { color: var(--stat-amber); }
.glance .stat[data-tone="blue"]::before   { background: var(--stat-blue); }
.glance .stat[data-tone="blue"]   .n      { color: var(--stat-blue); }
.glance .stat[data-tone="purple"]::before { background: var(--stat-purple); }
.glance .stat[data-tone="purple"] .n      { color: var(--stat-purple); }
.glance .stat[data-tone="green"]::before  { background: var(--stat-green); }
.glance .stat[data-tone="green"]  .n      { color: var(--stat-green); }

/* Section title with coral tick + thin divider under it */
.section-title,
.section-row {
  position: relative;
  border-bottom: 1px solid var(--border);
  padding-bottom: 6px;
  margin: 14px 2px 10px;
}
.section-title::before,
.section-row::before {
  content: '';
  position: absolute;
  bottom: -1px; left: 0;
  width: 24px; height: 2px;
  background: var(--coral);
  border-radius: 2px;
  box-shadow: 0 0 8px var(--coral);
}
.section-row { display: flex; align-items: baseline; justify-content: space-between; }
.section-title,
.section-row .title {
  font-family: var(--f-display);
  font-size: 12.5px;
  font-weight: 700;
  letter-spacing: 0.08em;
  color: var(--text);
  text-transform: uppercase;
}
.section-row .more {
  font-family: var(--f-mono);
  font-size: 11px;
  color: var(--muted);
  cursor: pointer;
  font-weight: 500;
  letter-spacing: 0.04em;
  text-transform: uppercase;
}
.section-row .more:hover { color: var(--coral-deep); }

/* Full panel separator for visual rhythm between major groups */
.panel-divider {
  height: 1px;
  background: var(--border);
  margin: 16px 0;
  border: 0;
}

/* ─────────────────────────────────────────────
   Filter chips (Library)
   ───────────────────────────────────────────── */
.chips {
  display: flex;
  gap: 6px;
  overflow-x: auto;
  scrollbar-width: none;
  padding: 2px 0 12px;
  margin: 0 calc(-1 * var(--gutter)) 2px;
  padding-left: var(--gutter);
  padding-right: var(--gutter);
  scroll-snap-type: x mandatory;
  scroll-padding-inline: var(--gutter);
}
.chips::-webkit-scrollbar { display: none; }
.chips::after {
  /* trailing spacer so the last chip can scroll fully into view */
  content: '';
  flex: 0 0 calc(var(--gutter) - 2px);
}
@media (min-width: 900px) {
  .chips { margin-left: 0; margin-right: 0; padding-left: 2px; padding-right: 2px; }
  .chips::after { display: none; }
}
.chip {
  flex: 0 0 auto;
  display: inline-flex;
  align-items: center;
  gap: 5px;
  background: var(--surface);
  border: 1px solid var(--border);
  color: var(--text-dim);
  padding: 6px 12px;
  border-radius: var(--r-full);
  font-family: var(--f-display);
  font-weight: 600;
  font-size: 12px;
  cursor: pointer;
  scroll-snap-align: start;
  transition: all var(--t-fast) var(--ease-soft);
  white-space: nowrap;
  letter-spacing: 0.04em;
  text-transform: uppercase;
}
.chip:hover { background: var(--surface-2); border-color: var(--border-2); color: var(--text); }
.chip.active {
  background: var(--coral);
  border-color: var(--coral);
  color: #fff;
  box-shadow: var(--shadow-coral);
}
.chip .icon { font-size: 15px; }
.chip .count {
  font-family: var(--f-mono);
  font-size: 10px;
  color: var(--mute);
  padding-left: 4px;
  font-weight: 500;
  letter-spacing: 0;
}
.chip.active .count { color: rgba(255,255,255,0.86); }

/* ─────────────────────────────────────────────
   FILES GRID
   ───────────────────────────────────────────── */
.files-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);  /* mobile: always 2 columns, no orphans */
  gap: 8px;
}
@media (min-width: 480px) { .files-grid { grid-template-columns: repeat(3, 1fr); gap: 10px; } }
@media (min-width: 700px) { .files-grid { grid-template-columns: repeat(4, 1fr); gap: 12px; } }
@media (min-width: 1000px) { .files-grid { grid-template-columns: repeat(5, 1fr); gap: 12px; } }
@media (min-width: 1200px) { .files-grid { grid-template-columns: repeat(6, 1fr); gap: 14px; } }

.file-card {
  position: relative;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--r-md);
  overflow: hidden;
  cursor: pointer;
  display: flex;
  flex-direction: column;
  transition: transform var(--t-fast) var(--ease), border-color var(--t-fast) var(--ease-soft), box-shadow var(--t-fast) var(--ease-soft);
  user-select: none;
  -webkit-user-select: none;
  box-shadow: var(--shadow-xs);
  will-change: transform;
}
.file-card:active { transform: scale(.97); }
/* clear divider between thumb and metadata */
.file-card .meta { border-top: 1px solid var(--border-soft); }
.file-card:hover { border-color: var(--border-2); box-shadow: var(--shadow-md); transform: translateY(-1px); }
.file-card:active { transform: translateY(0) scale(.99); }
.file-card.selected {
  border-color: var(--coral);
  box-shadow: 0 0 0 3px var(--coral-soft), var(--shadow-sm);
}
.file-card .thumb {
  position: relative;
  aspect-ratio: 1;
  background: var(--surface-3);
  display: grid;
  place-items: center;
  overflow: hidden;
}
.file-card .thumb img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  object-position: center;
  display: block;
}
/* Documents/scans tend to have important content centered — ensure object-position is right */
.file-card[data-cat="document"] .thumb img,
.file-card[data-cat="receipt"]  .thumb img,
.file-card[data-cat="screenshot"] .thumb img { object-position: center top; }

.file-card .thumb .placeholder {
  display: grid;
  place-items: center;
  gap: 6px;
  color: var(--mute);
}
.file-card .thumb .placeholder .icon { font-size: 38px; color: var(--mute); }
.file-card .thumb .placeholder .ext {
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  color: var(--muted);
}

.file-card .star-btn {
  position: absolute;
  top: 8px;
  right: 8px;
  width: 30px; height: 30px;
  background: rgba(255, 255, 255, 0.92);
  backdrop-filter: blur(6px);
  border-radius: var(--r-full);
  display: grid; place-items: center;
  color: var(--text-dim);
  opacity: 0;
  transition: opacity var(--t-fast) var(--ease), background var(--t-fast) var(--ease-soft);
  z-index: 2;
  box-shadow: var(--shadow-xs);
}
.file-card:hover .star-btn { opacity: 1; }
.file-card .star-btn.starred,
.file-card.starred .star-btn { opacity: 1; color: #fff; background: var(--coral); }
.file-card .star-btn.starred .icon { font-variation-settings: 'opsz' 24, 'wght' 500, 'GRAD' 0, 'FILL' 1; }

.file-card .select-mark {
  position: absolute;
  top: 8px; left: 8px;
  width: 26px; height: 26px;
  border-radius: var(--r-full);
  background: rgba(255, 255, 255, 0.92);
  border: 2px solid var(--border-2);
  display: grid; place-items: center;
  color: transparent;
  opacity: 0;
  transition: opacity var(--t-fast) var(--ease-soft);
  z-index: 2;
}
body.multiselect .file-card .select-mark { opacity: 1; }
.file-card.selected .select-mark {
  background: var(--coral);
  border-color: var(--coral);
  color: #fff;
}
.file-card.selected .select-mark .icon { font-variation-settings: 'opsz' 24, 'wght' 700, 'GRAD' 0, 'FILL' 1; }

.file-card .meta {
  padding: 7px 9px 9px;
  display: grid;
  gap: 2px;
}
.file-card .name {
  font-size: 12.5px;
  font-weight: 600;
  line-height: 1.25;
  color: var(--text);
  letter-spacing: -0.01em;
  display: -webkit-box;
  -webkit-line-clamp: 1;
  -webkit-box-orient: vertical;
  overflow: hidden;
  text-overflow: ellipsis;
  word-break: break-all;
  white-space: nowrap;
}
@media (min-width: 600px) {
  .file-card .name {
    -webkit-line-clamp: 2;
    white-space: normal;
    min-height: 2.5em;
  }
}
.file-card .sub {
  font-family: var(--f-mono);
  font-size: 10.5px;
  color: var(--muted);
  display: flex;
  align-items: center;
  gap: 5px;
  font-weight: 500;
  font-feature-settings: 'tnum';
  letter-spacing: 0.04em;
  text-transform: uppercase;
}
.file-card .sub .dot { color: var(--mute); }
.file-card .cat-dot {
  display: inline-block;
  width: 6px; height: 6px;
  border-radius: var(--r-full);
  background: var(--mute);
}
.file-card .tags {
  display: flex;
  flex-wrap: nowrap;
  gap: 3px;
  padding: 0 9px 8px;
  overflow: hidden;
}
.file-card .tag {
  font-family: var(--f-mono);
  font-size: 9.5px;
  color: var(--text-dim);
  padding: 1px 6px;
  border-radius: var(--r-full);
  background: var(--surface-2);
  border: 1px solid var(--border-soft);
  font-weight: 500;
  letter-spacing: 0.02em;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  max-width: 70%;
  flex-shrink: 1;
}
@media (max-width: 480px) {
  .file-card .tags { padding-bottom: 7px; }
  .file-card .tag { font-size: 9px; padding: 0 5px; }
}
/* Hide the back button on the home tabs — we'll show it later for sub-routes */
.appbar-back { display: none; }
.appbar-back[data-show] { display: inline-grid; }
.file-card .ai-status {
  position: absolute;
  bottom: 10px;
  right: 12px;
  font-size: 10.5px;
  color: var(--stat-amber-ink);
  font-weight: 600;
  letter-spacing: 0.02em;
}
.file-card .ai-status.pending::before {
  content: '';
  display: inline-block;
  width: 6px; height: 6px;
  border-radius: var(--r-full);
  background: var(--stat-amber);
  margin-right: 5px;
  animation: pulse 1.5s ease-in-out infinite;
  vertical-align: 1px;
}
@keyframes pulse { 0%, 100% { opacity: 1; transform: scale(1); } 50% { opacity: .35; transform: scale(.7); } }

/* ─────────────────────────────────────────────
   EMPTY STATES
   ───────────────────────────────────────────── */
.empty {
  display: grid;
  place-items: center;
  padding: 36px 18px 28px;
  text-align: center;
  gap: 10px;
  color: var(--muted);
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--r-md);
  box-shadow: var(--shadow-xs);
}
.empty .icon.xl { color: var(--mute); opacity: .8; }
.empty h3 {
  margin: 0;
  font-family: var(--f-display);
  font-size: 17px;
  font-weight: 800;
  letter-spacing: 0.02em;
  text-transform: uppercase;
  color: var(--text);
}
.empty p { margin: 0; font-size: 13px; max-width: 34ch; line-height: 1.5; }
.empty .icon.xl { font-size: 36px; }
.empty .suggest { display: flex; flex-wrap: wrap; gap: 8px; justify-content: center; margin-top: 8px; }

/* ─────────────────────────────────────────────
   BOTTOM TABS (mobile only)
   ───────────────────────────────────────────── */
.tabs {
  position: fixed;
  left: 0; right: 0; bottom: 0;
  z-index: 40;
  display: grid;
  grid-template-columns: repeat(5, 1fr);
  background: color-mix(in oklab, var(--surface) 92%, transparent);
  backdrop-filter: saturate(180%) blur(22px);
  -webkit-backdrop-filter: saturate(180%) blur(22px);
  border-top: 1px solid var(--border);
  padding-bottom: var(--sa-b);
  height: calc(var(--tabs-h) + var(--sa-b));
}
@media (min-width: 900px) {
  .tabs { display: none; }
}
.tab {
  position: relative;
  display: grid;
  place-items: center;
  gap: 3px;
  padding: 10px 4px;
  color: var(--muted);
  cursor: pointer;
  transition: color var(--t-fast) var(--ease-soft);
}
.tab .icon { font-size: 20px; }
.tab .label {
  font-size: 11px;
  font-weight: 500;
  letter-spacing: 0;
}
.tab.active { color: var(--coral); }
.tab.active .icon { font-variation-settings: 'opsz' 24, 'wght' 500, 'GRAD' 0, 'FILL' 1; }
.tab.active::after {
  content: '';
  position: absolute;
  top: 0; left: 50%;
  transform: translateX(-50%);
  width: 24px; height: 2px;
  background: var(--coral);
  border-radius: 0 0 var(--r-full) var(--r-full);
  box-shadow: 0 0 12px var(--coral);
}
.tab.fab {
  align-items: center;
  justify-content: center;
}
.tab.fab .fab-inner {
  width: 46px; height: 46px;
  border-radius: var(--r-md);
  background: var(--coral);
  color: #fff;
  display: grid; place-items: center;
  box-shadow: var(--shadow-coral);
  margin-top: -16px;
  transition: transform var(--t-fast) var(--ease), background var(--t-fast) var(--ease-soft);
}
.tab.fab:hover .fab-inner { background: var(--coral-deep); }
.tab.fab:active .fab-inner { transform: scale(.94); }
.tab.fab .fab-inner .icon { font-size: 28px; font-variation-settings: 'opsz' 24, 'wght' 500, 'GRAD' 0, 'FILL' 0; }
.tab.fab .label { display: none; }

/* ─────────────────────────────────────────────
   COLLECTIONS GRID
   ───────────────────────────────────────────── */
.collections-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 10px;
}
@media (min-width: 600px) { .collections-grid { grid-template-columns: repeat(3, 1fr); gap: 12px; } }
@media (min-width: 1000px) { .collections-grid { grid-template-columns: repeat(4, 1fr); gap: 14px; } }

.coll-card {
  position: relative;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--r-md);
  overflow: hidden;
  padding: 14px;
  display: grid;
  gap: 10px;
  cursor: pointer;
  transition: all var(--t-fast) var(--ease-soft);
  box-shadow: var(--shadow-sm);
}
.coll-card:hover { border-color: var(--border-2); box-shadow: var(--shadow-md); transform: translateY(-2px); }
.coll-card .head { display: flex; align-items: center; gap: 10px; }
.coll-card .head .icon-tile {
  width: 36px; height: 36px;
  border-radius: var(--r-sm);
  display: grid; place-items: center;
  background: var(--surface-3);
  color: var(--text-dim);
}
.coll-card .head .icon-tile .icon { font-variation-settings: 'opsz' 24, 'wght' 450, 'GRAD' 0, 'FILL' 1; }
.coll-card .head .lbl {
  flex: 1;
  display: grid; gap: 2px;
}
.coll-card .head .lbl .name {
  font-family: var(--f-display);
  font-size: 15px;
  font-weight: 700;
  letter-spacing: 0.02em;
  text-transform: uppercase;
  color: var(--text);
}
.coll-card .head .lbl .count {
  font-family: var(--f-mono);
  font-size: 10.5px;
  color: var(--muted);
  font-weight: 500;
  font-feature-settings: 'tnum';
  letter-spacing: 0.04em;
  text-transform: uppercase;
}
.coll-card .preview {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 3px;
  height: 86px;
  border-radius: var(--r-sm);
  overflow: hidden;
}
.coll-card .preview > * {
  background: var(--surface-2);
  background-size: cover;
  background-position: center;
}
.coll-card .preview > .none {
  display: grid; place-items: center;
  color: var(--mute);
}
.coll-card[data-key="starred"] .icon-tile { background: var(--coral-soft); color: var(--coral-deep); }
.coll-card[data-key="recent"]  .icon-tile { background: rgba(91, 164, 230, 0.16); color: var(--stat-blue); }
.coll-card[data-key="photo"]   .icon-tile { background: rgba(250, 138, 114, 0.14); color: var(--stat-coral); }
.coll-card[data-key="screenshot"] .icon-tile { background: rgba(156, 140, 242, 0.16); color: var(--stat-purple); }
.coll-card[data-key="document"] .icon-tile { background: rgba(91, 164, 230, 0.16); color: var(--stat-blue); }
.coll-card[data-key="receipt"] .icon-tile { background: rgba(242, 185, 76, 0.18); color: var(--stat-amber-ink); }
.coll-card[data-key="code"]    .icon-tile { background: rgba(126, 200, 150, 0.18); color: var(--stat-green); }

/* ─────────────────────────────────────────────
   SEARCH
   ───────────────────────────────────────────── */
.search-hero {
  display: grid;
  gap: 14px;
  margin-bottom: 14px;
}
.search-input-wrap {
  position: relative;
  display: flex;
  align-items: center;
  gap: 6px;
  background: var(--surface);
  border: 1.5px solid var(--border);
  border-radius: var(--r-full);
  padding: 6px 6px 6px 18px;
  transition: border-color var(--t-base) var(--ease-soft), box-shadow var(--t-base) var(--ease-soft);
  box-shadow: var(--shadow-xs);
}
.search-input-wrap:focus-within {
  border-color: var(--coral);
  box-shadow: 0 0 0 4px var(--coral-soft);
}
.search-input-wrap .icon { color: var(--muted); }
.search-input-wrap input {
  flex: 1;
  background: none;
  border: 0;
  padding: 12px 6px;
  font-size: 14.5px;
  color: var(--text);
  outline: 0;
  min-width: 0;
}
.search-input-wrap input::placeholder { color: var(--mute); }
.search-input-wrap .mic-btn,
.search-input-wrap .ai-btn {
  width: 38px; height: 38px;
  border-radius: var(--r-full);
  display: grid; place-items: center;
  color: var(--muted);
  transition: background var(--t-fast) var(--ease-soft), color var(--t-fast) var(--ease-soft);
}
.search-input-wrap .mic-btn:hover,
.search-input-wrap .ai-btn:hover { background: var(--surface-2); color: var(--text); }
.search-input-wrap .ai-btn.on {
  background: var(--coral);
  color: #fff;
}
.search-input-wrap .mic-btn.listening { color: var(--danger); animation: pulse 1.2s ease-in-out infinite; }

.section-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 14px 4px 10px;
}
.section-head .h {
  font-size: 14px;
  font-weight: 600;
  color: var(--text-dim);
  letter-spacing: -0.01em;
}
.section-head .more {
  font-size: 12px;
  color: var(--muted);
  cursor: pointer;
}

.suggest-grid { display: grid; gap: 8px; }
.suggest-grid .suggest-row {
  display: flex; align-items: center; gap: 12px;
  padding: 13px 16px;
  background: var(--surface);
  border: 1px solid var(--border-soft);
  border-radius: var(--r-sm);
  font-size: 14px;
  color: var(--text-dim);
  cursor: pointer;
  transition: all var(--t-fast) var(--ease-soft);
  text-align: left;
  font-weight: 400;
}
.suggest-grid .suggest-row:hover { border-color: var(--coral); color: var(--text); background: var(--surface-2); }
.suggest-grid .suggest-row .icon { color: var(--coral-deep); flex-shrink: 0; }

.search-reasoning {
  background: var(--coral-soft);
  border: 1px solid var(--coral-soft-2);
  border-radius: var(--r-sm);
  padding: 12px 16px;
  margin-bottom: 14px;
  font-size: 13.5px;
  color: var(--coral-dark);
  display: flex; gap: 10px; align-items: flex-start;
}
.search-reasoning .icon { flex-shrink: 0; color: var(--coral-deep); }

/* ─────────────────────────────────────────────
   CHAT
   ───────────────────────────────────────────── */
.chat-page {
  display: flex;
  flex-direction: column;
  height: 100%;
  flex: 1;
  min-height: 0;
  background: var(--surface);
  border-top: 1px solid var(--border);
  border-bottom: 1px solid var(--border);
  overflow: hidden;
}
@media (min-width: 900px) {
  .chat-page {
    border: 1px solid var(--border);
    border-radius: var(--r-md);
    box-shadow: var(--shadow-sm);
  }
}
.chat-head {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 14px;
  border-bottom: 1px solid var(--border);
  background: var(--surface-2);
  flex-shrink: 0;
}
.chat-head-titles { flex: 1; min-width: 0; display: grid; gap: 1px; }
.chat-current-title {
  font-family: var(--f-display);
  font-size: 14px;
  font-weight: 700;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  color: var(--text);
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.chat-current-sub {
  font-family: var(--f-mono);
  font-size: 10.5px;
  color: var(--muted);
  font-weight: 500;
  letter-spacing: 0.06em;
  text-transform: uppercase;
}
.chat-new-btn { padding: 6px 12px; font-size: 12.5px; }
.chat-sessions-bar {
  display: flex;
  gap: 6px;
  overflow-x: auto;
  scrollbar-width: none;
  padding: 8px 12px;
  flex-shrink: 0;
  background: var(--surface-2);
  border-bottom: 1px solid var(--border);
}
.chat-sessions-bar::-webkit-scrollbar { display: none; }
.chat-sessions-empty {
  font-size: 12px;
  color: var(--muted);
  padding: 6px 4px;
  font-style: italic;
}
.chat-body {
  flex: 1;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  padding: 0;
  scroll-behavior: smooth;
  background: var(--bg);
}
.chat-messages {
  display: flex;
  flex-direction: column;
  gap: 10px;
  padding: 12px;
}
.chat-skeleton { display: flex; flex-direction: column; gap: 12px; padding: 16px; }
.chat-skel-msg { height: 56px; width: 70%; border-radius: var(--r-md); }
.chat-skel-msg.right { align-self: flex-end; width: 50%; }
.msg {
  max-width: 86%;
  padding: 10px 14px;
  border-radius: var(--r-md);
  font-size: 14px;
  line-height: 1.5;
  white-space: pre-wrap;
  word-wrap: break-word;
  animation: msgIn .25s var(--ease-soft);
}
@media (min-width: 700px) {
  .msg { max-width: 75%; }
}
@keyframes msgIn {
  from { opacity: 0; transform: translateY(8px); }
  to   { opacity: 1; transform: translateY(0); }
}
.msg.user {
  background: var(--coral);
  color: #fff;
  align-self: flex-end;
  border-bottom-right-radius: 6px;
}
.msg.assistant {
  background: var(--surface-2);
  border: 1px solid var(--border);
  align-self: flex-start;
  border-bottom-left-radius: 6px;
  box-shadow: var(--shadow-xs);
  color: var(--text);
}
.msg.assistant.thinking {
  color: var(--muted);
  font-style: italic;
}
.msg.assistant.thinking::after {
  content: '';
  display: inline-block;
  width: 8px; height: 8px;
  border-radius: 50%;
  background: var(--muted);
  margin-left: 6px;
  animation: pulse 1.2s ease-in-out infinite;
  vertical-align: 1px;
}
.cited {
  margin-top: 10px;
  padding-top: 10px;
  border-top: 1px solid var(--border);
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}
.cited-label {
  width: 100%;
  font-family: var(--f-mono);
  font-size: 10.5px;
  font-weight: 500;
  text-transform: uppercase;
  letter-spacing: 0.14em;
  color: var(--muted);
  margin-bottom: 4px;
}
.cited a {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  background: var(--surface-2);
  border: 1px solid var(--border-soft);
  border-radius: var(--r-full);
  padding: 4px 12px;
  font-size: 12.5px;
  color: var(--text-dim);
}
.cited a:hover { border-color: var(--coral); color: var(--coral-deep); }
.cited a .icon { font-size: 14px; }

.chat-input-bar {
  display: flex;
  gap: 8px;
  align-items: center;
  padding: 10px 12px;
  padding-bottom: calc(10px + var(--sa-b));
  border-top: 1px solid var(--border);
  background: var(--surface-2);
  flex-shrink: 0;
}
.chat-input-bar input {
  flex: 1;
  background: var(--surface);
  border: 1.5px solid var(--border);
  border-radius: var(--r-full);
  padding: 11px 18px;
  font-size: 15px;
  color: var(--text);
  box-shadow: var(--shadow-xs);
}
.chat-input-bar input:focus { border-color: var(--coral); outline: none; box-shadow: 0 0 0 3px var(--coral-soft); }
.chat-input-bar .send {
  width: 44px; height: 44px;
  border-radius: var(--r-full);
  background: var(--coral);
  color: #fff;
  display: grid; place-items: center;
  box-shadow: var(--shadow-coral);
  transition: transform var(--t-fast) var(--ease);
}
.chat-input-bar .send:active { transform: scale(.94); }
.chat-input-bar .send:disabled { opacity: .4; background: var(--mute); box-shadow: none; }

/* ─────────────────────────────────────────────
   ACCOUNT
   ───────────────────────────────────────────── */
.account {
  display: grid;
  gap: 12px;
  max-width: 680px;
  margin: 0 auto;
}
.profile-card {
  display: flex;
  align-items: center;
  gap: 16px;
  background: var(--surface);
  border: 1px solid var(--border-soft);
  border-radius: var(--r-md);
  padding: 20px;
  box-shadow: var(--shadow-xs);
}
.profile-card .avatar {
  width: 56px; height: 56px;
  border-radius: var(--r-md);
  background: var(--coral);
  display: grid; place-items: center;
  color: #fff;
  font-weight: 700;
  font-size: 22px;
}
.profile-card .info { flex: 1; display: grid; gap: 3px; }
.profile-card .info .name {
  font-family: var(--f-display);
  font-size: 19px;
  font-weight: 800;
  letter-spacing: 0.02em;
  text-transform: uppercase;
  color: var(--text);
}
.profile-card .info .meta {
  font-size: 13px;
  color: var(--muted);
}

.storage-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--r-md);
  padding: 16px 18px;
  display: grid;
  gap: 14px;
  box-shadow: var(--shadow-sm);
}
.storage-card .row {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
}
.storage-card .row .lbl {
  font-family: var(--f-display);
  font-size: 14px;
  font-weight: 700;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--text);
}
.storage-card .row .v {
  font-family: var(--f-mono);
  font-size: 12px;
  font-weight: 500;
  letter-spacing: 0.02em;
  text-transform: uppercase;
  color: var(--muted);
  font-feature-settings: 'tnum';
}
.storage-cap-row {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  margin-bottom: -6px;
}
.storage-cap-row .pct {
  font-family: var(--f-mono);
  font-size: 22px;
  font-weight: 600;
  letter-spacing: -0.02em;
  color: var(--text);
  font-feature-settings: 'tnum';
}
.storage-cap-row .rem {
  font-family: var(--f-mono);
  font-size: 11.5px;
  color: var(--muted);
  font-weight: 500;
  letter-spacing: 0.04em;
  text-transform: uppercase;
}
.storage-bar.full > span:not([style*="transparent"]) {
  background: var(--coral) !important;
}
.storage-bar {
  display: flex;
  height: 10px;
  border-radius: var(--r-full);
  overflow: hidden;
  background: var(--surface-3);
}
.storage-bar > span {
  display: block;
  min-width: 2px;
  transition: width .4s var(--ease);
}
.storage-legend {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 8px;
}
@media (min-width: 500px) { .storage-legend { grid-template-columns: repeat(3, 1fr); } }
.storage-legend .row2 {
  display: flex; align-items: center; gap: 8px;
  font-size: 12.5px;
  color: var(--text-dim);
}
.storage-legend .row2 .swatch {
  width: 12px; height: 12px;
  border-radius: 3px;
  background: var(--mute);
}

.list-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--r-md);
  overflow: hidden;
  box-shadow: var(--shadow-sm);
}
.list-card h3 {
  margin: 0;
  padding: 12px 18px 10px;
  font-family: var(--f-display);
  font-size: 12.5px;
  font-weight: 700;
  color: var(--muted);
  letter-spacing: 0.1em;
  text-transform: uppercase;
  background: var(--surface-2);
  border-bottom: 1px solid var(--border);
}
.list-row {
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 14px 20px;
  border-top: 1px solid var(--border-soft);
  cursor: pointer;
  transition: background var(--t-fast) var(--ease-soft);
  width: 100%;
  text-align: left;
  font-weight: 400;
}
.list-row:hover { background: var(--surface-2); }
.list-row .icon { color: var(--coral-deep); flex-shrink: 0; }
.list-row .lbl { flex: 1; min-width: 0; }
.list-row .lbl .t { font-size: 14px; color: var(--text); font-weight: 600; letter-spacing: -0.01em; }
.list-row .lbl .s {
  font-family: var(--f-mono);
  font-size: 10.5px;
  color: var(--muted);
  font-weight: 500;
  letter-spacing: 0.06em;
  text-transform: uppercase;
}
.list-row.danger .icon { color: var(--danger); }
.list-row.danger .lbl .t { color: var(--danger); }

/* ─────────────────────────────────────────────
   FILE SHEET / DETAIL
   ───────────────────────────────────────────── */
.sheet {
  position: fixed;
  inset: 0;
  background: rgba(20, 27, 39, 0.55);
  backdrop-filter: blur(8px);
  z-index: 60;
  display: none;
  align-items: flex-end;
  justify-content: center;
}
.sheet[aria-hidden="false"] { display: flex; }
.sheet-card {
  width: 100%;
  max-width: 920px;
  background: var(--bg);
  border-top-left-radius: var(--r-2xl);
  border-top-right-radius: var(--r-2xl);
  max-height: 92dvh;
  display: flex;
  flex-direction: column;
  padding-bottom: var(--sa-b);
  animation: sheetIn .3s var(--ease);
  box-shadow: var(--shadow-lg);
}
@keyframes sheetIn { from { transform: translateY(12%); opacity: 0; } to { transform: translateY(0); opacity: 1; } }
@media (min-width: 800px) {
  .sheet { align-items: center; padding: 24px; }
  .sheet-card { border-radius: var(--r-xl); max-height: 88vh; border: 1px solid var(--border); }
  .sheet-card::before { display: none; }
}
.sheet-head { padding-top: 16px; }
@media (min-width: 800px) {
  .sheet-head { padding-top: 12px; }
}
.sheet-head {
  display: flex; align-items: center; gap: 8px;
  padding: 12px 14px;
  border-bottom: 1px solid var(--border-soft);
}
.sheet-head .ic {
  width: 40px; height: 40px;
  border-radius: var(--r-full);
  display: grid; place-items: center;
  color: var(--text-dim);
}
.sheet-head .ic:hover { background: var(--surface-2); color: var(--text); }
.sheet-head .ic.starred { color: var(--coral); }
.sheet-head .title {
  flex: 1;
  min-width: 0;
  display: grid; gap: 2px;
}
.sheet-head .title .h {
  font-family: var(--f-display);
  font-size: 15px;
  font-weight: 700;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
  color: var(--text);
}
.sheet-head .title .s {
  font-size: 12px;
  color: var(--muted);
}
.sheet-body {
  flex: 1;
  overflow: auto;
  padding: 16px;
  display: grid;
  gap: 16px;
}
.sheet-body img,
.sheet-body video,
.sheet-body audio {
  width: 100%; max-height: 60vh; object-fit: contain;
  border-radius: var(--r-sm);
  background: var(--surface-3);
}
.sheet-body iframe {
  width: 100%;
  height: 60vh;
  border: 0;
  border-radius: var(--r-sm);
  background: white;
}
.sheet-body pre {
  background: var(--surface);
  border: 1px solid var(--border-soft);
  border-radius: var(--r-sm);
  padding: 16px;
  overflow: auto;
  max-height: 60vh;
  white-space: pre-wrap;
  font-family: ui-monospace, 'SF Mono', 'JetBrains Mono', Menlo, monospace;
  font-size: 12.5px;
  line-height: 1.6;
}
.info-block {
  background: var(--surface);
  border: 1px solid var(--border-soft);
  border-radius: var(--r-sm);
  padding: 16px;
  display: grid;
  gap: 12px;
}
.info-block .summary {
  font-size: 14.5px;
  line-height: 1.55;
  color: var(--text-dim);
}
.info-block dl {
  margin: 0;
  display: grid;
  grid-template-columns: max-content 1fr;
  gap: 8px 16px;
}
.info-block dt {
  font-size: 12.5px;
  font-weight: 500;
  color: var(--muted);
}
.info-block dd {
  margin: 0;
  font-size: 13px;
  word-break: break-word;
  color: var(--text-2);
}
.info-tags { display: flex; flex-wrap: wrap; gap: 6px; }
.info-tags .tag {
  display: inline-flex; align-items: center; gap: 4px;
  background: var(--surface-2);
  border: 1px solid var(--border-soft);
  border-radius: var(--r-full);
  padding: 4px 10px;
  font-size: 11.5px;
  color: var(--text-dim);
}
.info-tags .tag .x { color: var(--mute); cursor: pointer; padding-left: 2px; font-size: 14px; line-height: 1; }
.info-tags .tag .x:hover { color: var(--danger); }
.info-tags .add-tag {
  padding: 4px 10px;
  background: transparent;
  border: 1px dashed var(--border-2);
  border-radius: var(--r-full);
  font-size: 11.5px;
  color: var(--muted);
}
.sheet-foot {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  padding: 14px;
  border-top: 1px solid var(--border-soft);
}
.sheet-foot .btn { flex: 1 1 auto; font-size: 13px; padding: 10px 14px; }
.sheet-foot .btn.icon-btn { flex: 0 0 44px; padding: 12px; }

/* ─────────────────────────────────────────────
   BATCH ACTION BAR
   ───────────────────────────────────────────── */
.batchbar {
  position: sticky;
  top: 0;
  z-index: 35;
  display: none;
  align-items: center;
  gap: 8px;
  padding: 10px 14px;
  padding-top: calc(10px + var(--sa-t));
  height: calc(var(--header-h) + var(--sa-t));
  background: var(--coral-soft);
  border-bottom: 1px solid var(--coral-soft-2);
}
body.multiselect .appbar { display: none; }
body.multiselect .batchbar { display: flex; }
.batchbar .ic {
  width: 40px; height: 40px;
  border-radius: var(--r-full);
  display: grid; place-items: center;
  color: var(--coral-deep);
}
.batchbar .ic:hover { background: rgba(255, 255, 255, 0.5); }
.batchbar .count {
  flex: 1;
  font-weight: 600;
  font-size: 14.5px;
  color: var(--coral-dark);
  display: flex; align-items: baseline; gap: 6px;
}
.batchbar .count .n {
  font-weight: 700;
  font-size: 16px;
}

/* ─────────────────────────────────────────────
   LIGHTBOX
   ───────────────────────────────────────────── */
.lightbox {
  position: fixed;
  inset: 0;
  background: var(--navy-deep);
  z-index: 70;
  display: none;
  flex-direction: column;
}
.lightbox.open { display: flex; }
.lightbox-head {
  position: absolute; top: 0; left: 0; right: 0;
  padding: 14px;
  padding-top: calc(14px + var(--sa-t));
  display: flex; align-items: center; gap: 8px;
  background: linear-gradient(to bottom, rgba(0,0,0,.5), transparent);
  z-index: 2;
  color: white;
}
.lightbox-head .ic {
  width: 42px; height: 42px;
  border-radius: var(--r-full);
  display: grid; place-items: center;
  background: rgba(255, 255, 255, 0.12);
  color: white;
}
.lightbox-head .ic:hover { background: rgba(255, 255, 255, 0.22); }
.lightbox-head .title { flex: 1; padding: 0 8px; min-width: 0; }
.lightbox-head .title .h {
  font-size: 14.5px;
  font-weight: 600;
  letter-spacing: -0.01em;
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.lightbox-head .title .s {
  font-size: 12px;
  color: rgba(255,255,255,.7);
}
.lightbox-body {
  flex: 1;
  position: relative;
  overflow: hidden;
  display: grid;
  place-items: center;
}
.lightbox-track {
  display: flex;
  width: 100%; height: 100%;
  transition: transform .28s var(--ease);
  touch-action: pan-y;
}
.lightbox-track > .slide {
  flex: 0 0 100%;
  display: grid;
  place-items: center;
  padding: 60px 16px;
}
.lightbox-track > .slide img,
.lightbox-track > .slide video {
  max-width: 100%; max-height: 100%;
  object-fit: contain;
  border-radius: var(--r-md);
}
.lightbox-nav {
  position: absolute;
  top: 50%;
  width: 46px; height: 46px;
  border-radius: var(--r-full);
  background: rgba(255, 255, 255, 0.12);
  color: white;
  display: grid; place-items: center;
  transform: translateY(-50%);
  z-index: 3;
}
.lightbox-nav.prev { left: 14px; }
.lightbox-nav.next { right: 14px; }
.lightbox-nav:hover { background: rgba(255, 255, 255, 0.22); }
@media (max-width: 700px) { .lightbox-nav { display: none; } }
.lightbox-foot {
  position: absolute; bottom: 0; left: 0; right: 0;
  padding: 18px;
  padding-bottom: calc(18px + var(--sa-b));
  background: linear-gradient(to top, rgba(0,0,0,.5), transparent);
  display: flex; gap: 10px; justify-content: center;
  z-index: 2;
}
.lightbox-foot .ic {
  width: 46px; height: 46px;
  border-radius: var(--r-full);
  background: rgba(255, 255, 255, 0.14);
  color: white;
  display: grid; place-items: center;
}
.lightbox-foot .ic:hover { background: rgba(255, 255, 255, 0.22); }
.lightbox-foot .ic.starred { color: var(--coral); background: rgba(250, 138, 114, 0.28); }
.lightbox-foot .ic.starred .icon { font-variation-settings: 'opsz' 24, 'wght' 500, 'GRAD' 0, 'FILL' 1; }

/* ─────────────────────────────────────────────
   SCANNER
   ───────────────────────────────────────────── */
.scanner {
  position: fixed;
  inset: 0;
  background: var(--navy-deep);
  z-index: 75;
  display: none;
  flex-direction: column;
}
.scanner.open { display: flex; }
.scanner-head {
  position: absolute; top: 0; left: 0; right: 0;
  padding: 16px;
  padding-top: calc(16px + var(--sa-t));
  display: flex; align-items: center; gap: 8px;
  background: linear-gradient(to bottom, rgba(0,0,0,.6), transparent);
  z-index: 2;
  color: white;
}
.scanner-head .ic {
  width: 40px; height: 40px;
  border-radius: var(--r-full);
  background: rgba(255, 255, 255, 0.12);
  color: white;
  display: grid; place-items: center;
}
.scanner-head .title {
  flex: 1;
  text-align: center;
  font-size: 15px;
  font-weight: 600;
  letter-spacing: -0.01em;
}
.scanner-head .count {
  font-size: 12px;
  font-weight: 500;
  background: rgba(255, 255, 255, 0.14);
  padding: 6px 12px;
  border-radius: var(--r-full);
}
.scanner-view {
  flex: 1;
  position: relative;
  background: #000;
  overflow: hidden;
}
.scanner-view video {
  position: absolute; inset: 0;
  width: 100%; height: 100%;
  object-fit: cover;
}
.scanner-frame {
  position: absolute;
  inset: 12% 8%;
  border: 2px dashed rgba(255, 255, 255, 0.55);
  border-radius: 12px;
  pointer-events: none;
}
.scanner-frame::before,
.scanner-frame::after,
.scanner-frame > .bl,
.scanner-frame > .br {
  content: '';
  position: absolute;
  width: 22px; height: 22px;
  border: 3px solid var(--coral);
  border-radius: 4px;
}
.scanner-frame::before { top: -3px; left: -3px; border-right: 0; border-bottom: 0; border-radius: 8px 0 0 0; }
.scanner-frame::after  { top: -3px; right: -3px; border-left: 0; border-bottom: 0; border-radius: 0 8px 0 0; }
.scanner-frame > .bl   { bottom: -3px; left: -3px; border-right: 0; border-top: 0; border-radius: 0 0 0 8px; }
.scanner-frame > .br   { bottom: -3px; right: -3px; border-left: 0; border-top: 0; border-radius: 0 0 8px 0; }

.scanner-foot {
  position: relative;
  background: var(--navy-deep);
  padding: 14px 16px;
  padding-bottom: calc(14px + var(--sa-b));
  display: grid;
  gap: 12px;
  z-index: 2;
}
.scan-thumbs {
  display: flex;
  gap: 8px;
  overflow-x: auto;
  scrollbar-width: none;
  min-height: 56px;
}
.scan-thumbs::-webkit-scrollbar { display: none; }
.scan-thumbs .t {
  flex: 0 0 50px;
  height: 56px;
  background-size: cover; background-position: center;
  border-radius: 8px;
  border: 1.5px solid rgba(255, 255, 255, 0.18);
  position: relative;
}
.scan-thumbs .t .x {
  position: absolute;
  top: -6px; right: -6px;
  width: 20px; height: 20px;
  border-radius: 50%;
  background: var(--danger);
  color: white;
  display: grid; place-items: center;
  font-size: 13px;
  cursor: pointer;
  font-weight: 600;
}
.scanner-controls {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
}
.scanner-controls .toggle {
  width: 48px; height: 48px;
  border-radius: var(--r-full);
  background: rgba(255, 255, 255, 0.12);
  color: white;
  display: grid; place-items: center;
}
.shutter {
  width: 74px; height: 74px;
  border-radius: 50%;
  background: white;
  border: 4px solid rgba(255, 255, 255, 0.55);
  display: grid; place-items: center;
  position: relative;
}
.shutter:active { transform: scale(.94); }
.shutter::after {
  content: '';
  width: 54px; height: 54px;
  border-radius: 50%;
  background: white;
  box-shadow: 0 0 0 4px var(--navy-deep) inset;
}
.finish-btn {
  padding: 12px 18px;
  background: var(--coral);
  color: #fff;
  border-radius: var(--r-full);
  font-size: 13px;
  font-weight: 600;
  display: inline-flex; align-items: center; gap: 6px;
  box-shadow: var(--shadow-coral);
}
.finish-btn:disabled { opacity: .5; background: rgba(255,255,255,0.2); box-shadow: none; }

/* ─────────────────────────────────────────────
   TOAST + DROPZONE
   ───────────────────────────────────────────── */
/* Old floating toast — kept hidden, replaced by .notice-bar */
.toast { display: none !important; }

/* Inline notice bar — pushes content down, never overlays */
.notice-bar {
  display: none;
  padding: 0;
}
.notice-bar.open {
  display: block;
  padding: 8px var(--gutter) 0;
}
@media (min-width: 900px) {
  .notice-bar.open { padding: 10px 20px 0; }
}
.notice {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 11px 12px 11px 16px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-left: 4px solid var(--coral);
  border-radius: var(--r-sm);
  box-shadow: var(--shadow-sm);
  animation: noticeIn .24s var(--ease);
  transform-origin: top center;
}
.notice.out { animation: noticeOut .22s var(--ease) forwards; }
@keyframes noticeIn {
  from { opacity: 0; transform: translateY(-6px) scaleY(.85); max-height: 0; padding-top: 0; padding-bottom: 0; }
  to   { opacity: 1; transform: translateY(0) scaleY(1); max-height: 100px; }
}
@keyframes noticeOut {
  from { opacity: 1; transform: translateY(0); max-height: 100px; }
  to   { opacity: 0; transform: translateY(-6px); max-height: 0; padding-top: 0; padding-bottom: 0; margin-top: 0; margin-bottom: 0; }
}
.notice .icon { color: var(--coral); flex-shrink: 0; }
.notice-msg {
  flex: 1;
  font-family: var(--f-display);
  font-size: 12.5px;
  font-weight: 700;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  color: var(--text);
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.notice-close {
  width: 28px; height: 28px;
  border-radius: var(--r-full);
  display: grid; place-items: center;
  color: var(--muted);
  flex-shrink: 0;
}
.notice-close:hover { background: var(--surface-2); color: var(--text); }

/* tones */
.notice-error { border-left-color: var(--danger); }
.notice-error .icon { color: var(--danger); }
.notice-success { border-left-color: var(--success); }
.notice-success .icon { color: var(--success); }
@media (min-width: 900px) { .toast { bottom: 24px; } }
.toast .icon { color: var(--coral); }
@keyframes toastIn {
  from { opacity: 0; transform: translate(-50%, 10px); }
  to   { opacity: 1; transform: translate(-50%, 0); }
}
body.dragover::after {
  content: 'Drop to upload';
  position: fixed; inset: 14px;
  background: var(--coral-soft);
  color: var(--coral-dark);
  display: grid; place-items: center;
  font-size: 22px;
  font-weight: 600;
  letter-spacing: -0.01em;
  border: 3px dashed var(--coral);
  border-radius: var(--r-xl);
  z-index: 90;
  pointer-events: none;
}

/* upload progress strip */
.uploads {
  position: fixed;
  top: calc(var(--header-h) + var(--sa-t) + 10px);
  left: 14px; right: 14px;
  z-index: 25;
  display: grid;
  gap: 6px;
  pointer-events: none;
}
@media (min-width: 900px) {
  .uploads { left: calc(var(--sidebar-w) + 28px); right: 28px; }
}
.uploads .row {
  pointer-events: auto;
  background: var(--surface);
  border: 1px solid var(--border-soft);
  border-radius: var(--r-sm);
  padding: 10px 14px;
  font-size: 13px;
  display: flex; gap: 10px; align-items: center;
  box-shadow: var(--shadow-sm);
}
.uploads .row .name { flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.uploads .row progress {
  width: 86px; height: 5px;
  border-radius: 999px;
  overflow: hidden;
  appearance: none;
}
.uploads .row progress::-webkit-progress-bar { background: var(--surface-3); border-radius: 999px; }
.uploads .row progress::-webkit-progress-value { background: var(--coral); border-radius: 999px; }
.uploads .row progress::-moz-progress-bar { background: var(--coral); border-radius: 999px; }

/* ─────────────────────────────────────────────
   RESIZE / OPTIMIZE DIALOG
   ───────────────────────────────────────────── */
.resize-card.sheet-card { max-width: 560px; }
.resize-card.mode-optimize .resize-only { display: none; }

/* Mode tabs */
.mode-tabs {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 6px;
  padding: 4px;
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: var(--r-md);
}
.mode-tab {
  display: grid;
  grid-template-columns: 22px 1fr;
  grid-template-rows: auto auto;
  align-items: center;
  text-align: left;
  gap: 2px 10px;
  padding: 10px 14px;
  border-radius: var(--r-sm);
  background: transparent;
  cursor: pointer;
  transition: all var(--t-fast) var(--ease-soft);
  color: var(--text-dim);
}
.mode-tab .icon { grid-row: 1 / span 2; align-self: center; color: var(--muted); font-size: 22px; }
.mode-tab .t {
  font-family: var(--f-display);
  font-size: 13px;
  font-weight: 700;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  color: var(--text);
}
.mode-tab .d {
  font-family: var(--f-mono);
  font-size: 10px;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--muted);
}
.mode-tab.active {
  background: var(--surface);
  box-shadow: var(--shadow-sm);
}
.mode-tab.active .icon { color: var(--coral); }
.mode-tab.active .t { color: var(--text); }
.mode-tab.active .d { color: var(--coral-deep); }
.mode-tab:hover:not(.active) { background: rgba(0,0,0,0.04); }
@media (prefers-color-scheme: dark) {
  .mode-tab:hover:not(.active) { background: rgba(255,255,255,0.04); }
}

/* Estimate panel */
.resize-estimate {
  background: var(--navy);
  color: #fff;
  border-radius: var(--r-md);
  padding: 14px 16px;
  display: grid;
  gap: 10px;
}
.est-headline {
  display: flex;
  align-items: center;
  gap: 8px;
}
.est-eyebrow {
  font-family: var(--f-mono);
  font-size: 10px;
  font-weight: 500;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--navy-dim);
  flex-shrink: 0;
}
.est-arrow { color: var(--navy-dim); flex-shrink: 0; line-height: 1; }
.est-arrow .icon { font-size: 14px; }
.est-value {
  font-family: var(--f-mono);
  font-size: 16px;
  font-weight: 600;
  letter-spacing: 0.02em;
  color: #fff;
  font-feature-settings: 'tnum';
  margin-left: auto;
}
.est-meter {
  position: relative;
  height: 10px;
  background: rgba(255, 255, 255, 0.08);
  border-radius: var(--r-full);
  overflow: hidden;
}
.est-bar-orig {
  position: absolute;
  top: 0; left: 0;
  height: 100%;
  background: rgba(255, 255, 255, 0.18);
  border-radius: var(--r-full);
  transition: width .25s var(--ease);
}
.est-bar {
  position: absolute;
  top: 0; left: 0;
  height: 100%;
  background: var(--coral);
  border-radius: var(--r-full);
  z-index: 1;
  transition: width .25s var(--ease);
}
.est-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
}
.est-now {
  font-family: var(--f-mono);
  font-size: 11px;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  color: var(--navy-dim);
  display: flex; gap: 6px; align-items: baseline;
}
.est-now .v { color: rgba(255, 255, 255, 0.85); font-weight: 500; }
.est-savings {
  font-family: var(--f-mono);
  font-size: 12px;
  font-weight: 600;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  padding: 4px 10px;
  border-radius: var(--r-full);
  white-space: nowrap;
}
.est-savings[data-tone="good"] { background: var(--coral); color: #fff; }
.est-savings[data-tone="bad"]  { background: rgba(226, 90, 90, 0.85); color: #fff; }
.est-savings[data-tone="neutral"] { background: rgba(255,255,255,0.14); color: var(--navy-dim); }

/* Save-as radio */
.saveas-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
}
.saveas-opt {
  position: relative;
  display: grid;
  grid-template-columns: 22px 1fr;
  grid-template-rows: auto auto;
  gap: 2px 10px;
  padding: 12px 14px;
  background: var(--surface);
  border: 1.5px solid var(--border);
  border-radius: var(--r-sm);
  cursor: pointer;
  transition: all var(--t-fast) var(--ease-soft);
}
.saveas-opt input { position: absolute; opacity: 0; pointer-events: none; }
.saveas-opt .icon {
  grid-row: 1 / span 2;
  align-self: center;
  font-size: 22px;
  color: var(--muted);
}
.saveas-opt .t {
  font-family: var(--f-display);
  font-size: 13px;
  font-weight: 700;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  color: var(--text);
}
.saveas-opt .d {
  font-family: var(--f-mono);
  font-size: 10px;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--muted);
}
.saveas-opt.active {
  border-color: var(--coral);
  background: var(--coral-soft);
}
.saveas-opt.active .icon { color: var(--coral-deep); }
.saveas-opt.active .t,
.saveas-opt.active .d { color: var(--coral-dark); }
.saveas-opt.warn.active {
  border-color: var(--warn);
  background: rgba(242, 185, 76, 0.14);
}
.saveas-opt.warn.active .icon,
.saveas-opt.warn.active .t,
.saveas-opt.warn.active .d { color: var(--stat-amber-ink); }


.resize-card .resize-preview {
  display: grid;
  place-items: center;
  background: var(--surface-2);
  border-radius: var(--r-sm);
  padding: 18px;
  min-height: 140px;
  border: 1px solid var(--border-soft);
}
.resize-card .resize-preview img {
  max-height: 160px;
  max-width: 100%;
  border-radius: var(--r-xs);
  box-shadow: var(--shadow-sm);
}

.resize-section { display: grid; gap: 10px; }
.resize-label {
  font-family: var(--f-display);
  font-size: 13px;
  font-weight: 700;
  letter-spacing: -0.01em;
  color: var(--text-2);
  padding-left: 2px;
}

.resize-presets {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 8px;
}
.resize-presets .preset {
  background: var(--surface);
  border: 1.5px solid var(--border);
  border-radius: var(--r-sm);
  padding: 12px 8px;
  cursor: pointer;
  display: grid;
  gap: 2px;
  text-align: center;
  transition: all var(--t-fast) var(--ease-soft);
}
.resize-presets .preset:hover { border-color: var(--border-2); }
.resize-presets .preset.active {
  border-color: var(--coral);
  background: var(--coral-soft);
  box-shadow: 0 0 0 3px var(--coral-soft);
}
.resize-presets .preset .t {
  font-family: var(--f-display);
  font-size: 13px;
  font-weight: 700;
  letter-spacing: -0.02em;
  color: var(--text);
}
.resize-presets .preset.active .t { color: var(--coral-dark); }
.resize-presets .preset .d {
  font-size: 11px;
  font-weight: 500;
  color: var(--muted);
}
.resize-presets .preset.active .d { color: var(--coral-deep); }

.resize-custom {
  display: grid;
  grid-template-columns: 1fr auto 1fr;
  gap: 10px;
  align-items: end;
}
.resize-custom .field { display: grid; gap: 4px; }
.resize-custom .field-label {
  font-size: 11px;
  font-weight: 500;
  color: var(--muted);
  padding-left: 2px;
}
.resize-custom input {
  background: var(--surface-2);
  border: 1.5px solid var(--border);
  border-radius: var(--r-sm);
  padding: 10px 12px;
  font-size: 14px;
  font-family: var(--f-display);
  font-feature-settings: 'tnum';
  color: var(--text);
  width: 100%;
  -moz-appearance: textfield;
}
.resize-custom input::-webkit-outer-spin-button,
.resize-custom input::-webkit-inner-spin-button { -webkit-appearance: none; margin: 0; }
.resize-custom input:focus { border-color: var(--coral); outline: none; box-shadow: 0 0 0 3px var(--coral-soft); }
.resize-custom .resize-x {
  font-family: var(--f-display);
  font-size: 18px;
  font-weight: 700;
  color: var(--mute);
  padding-bottom: 10px;
}

.resize-format {
  display: grid;
  grid-template-columns: 1fr 2fr;
  gap: 12px;
  align-items: end;
}
.resize-format .field { display: grid; gap: 4px; }
.resize-format .field-label {
  font-size: 11px;
  font-weight: 500;
  color: var(--muted);
  padding-left: 2px;
  display: flex;
  align-items: baseline;
  justify-content: space-between;
}
.resize-format .field-label b {
  font-family: var(--f-display);
  font-size: 13px;
  font-weight: 700;
  color: var(--text);
}
.resize-format select {
  background: var(--surface-2);
  border: 1.5px solid var(--border);
  border-radius: var(--r-sm);
  padding: 10px 12px;
  font-size: 14px;
  color: var(--text);
  cursor: pointer;
}
.resize-format select:focus { border-color: var(--coral); outline: none; }
.resize-format input[type="range"] {
  width: 100%;
  height: 36px;
  appearance: none;
  background: transparent;
}
.resize-format input[type="range"]::-webkit-slider-runnable-track {
  height: 4px;
  background: var(--surface-3);
  border-radius: 999px;
}
.resize-format input[type="range"]::-webkit-slider-thumb {
  appearance: none;
  width: 18px; height: 18px;
  border-radius: 50%;
  background: var(--coral);
  margin-top: -7px;
  box-shadow: var(--shadow-coral);
  cursor: pointer;
}
.resize-format input[type="range"]::-moz-range-track {
  height: 4px; background: var(--surface-3); border-radius: 999px;
}
.resize-format input[type="range"]::-moz-range-thumb {
  width: 18px; height: 18px;
  border: 0; border-radius: 50%;
  background: var(--coral);
  cursor: pointer;
}

/* skeleton */
.skel {
  background: linear-gradient(90deg, var(--surface) 0%, var(--surface-2) 50%, var(--surface) 100%);
  background-size: 200% 100%;
  animation: shimmer 1.4s linear infinite;
  border-radius: var(--r-sm);
}
@keyframes shimmer { from { background-position: 100% 0; } to { background-position: -100% 0; } }

/* skeleton file card */
.skel-card {
  display: flex;
  flex-direction: column;
  background: var(--surface);
  border: 1px solid var(--border-soft);
  border-radius: var(--r-md);
  overflow: hidden;
}
.skel-card .skel-thumb { aspect-ratio: 1; background: var(--surface-2); animation: shimmer 1.6s linear infinite; background-size: 200% 100%; background-image: linear-gradient(90deg, var(--surface-2) 0%, var(--surface-3) 50%, var(--surface-2) 100%); }
.skel-card .skel-line { height: 9px; margin: 8px 10px 4px; }
.skel-card .skel-line.short { width: 50%; margin-bottom: 10px; }

/* skeleton stat */
.skel-stat {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--r-md);
  padding: 12px;
  position: relative;
  overflow: hidden;
}
.skel-stat::before {
  content: '';
  position: absolute; inset: 0 0 auto 0;
  height: 2.5px; background: var(--border-2);
}
.skel-stat .l1 { height: 22px; width: 60%; margin-bottom: 8px; }
.skel-stat .l2 { height: 8px; width: 80%; }

/* utility */
.row-flex { display: flex; align-items: center; gap: 10px; }
.spacer { flex: 1; }
.sr { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0,0,0,0); }

/* ─────────────────────────────────────────────
   Inline upload card (mobile + Library tab)
   Expands inline between strip and chips — no overlay.
   ───────────────────────────────────────────── */
.upload-inline {
  display: none;
  background: var(--surface);
  border: 1.5px solid var(--coral);
  border-radius: var(--r-md);
  padding: 10px 12px 12px;
  margin: 0 0 10px;
  box-shadow: var(--shadow-md), 0 0 0 4px rgba(250, 138, 114, 0.12);
  overflow: hidden;
}
.upload-inline[aria-hidden="false"] {
  display: block;
  animation: uploadIn .28s var(--ease);
}
@keyframes uploadIn {
  from { opacity: 0; transform: translateY(-6px); max-height: 0; padding-top: 0; padding-bottom: 0; }
  to   { opacity: 1; transform: translateY(0); max-height: 400px; padding-top: 10px; padding-bottom: 12px; }
}
.upload-inline-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 10px;
}
.upload-inline-title {
  font-family: var(--f-display);
  font-size: 13px;
  font-weight: 700;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--text);
}
.upload-inline .ic {
  width: 32px; height: 32px;
  border-radius: var(--r-full);
  display: grid; place-items: center;
  color: var(--text-dim);
}
.upload-inline-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 6px;
}
.upload-tile {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 3px;
  padding: 12px 4px 10px;
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: var(--r-sm);
  cursor: pointer;
  transition: all var(--t-fast) var(--ease-soft);
  min-height: 80px;
}
.upload-tile:hover, .upload-tile:active {
  background: var(--coral-soft);
  border-color: var(--coral);
  transform: scale(.98);
}
.upload-tile .icon {
  font-size: 24px;
  color: var(--coral);
  margin-bottom: 2px;
}
.upload-tile .t {
  font-family: var(--f-display);
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  color: var(--text);
}
.upload-tile .d {
  font-family: var(--f-mono);
  font-size: 8.5px;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  color: var(--muted);
  text-align: center;
}
@media (min-width: 900px) {
  .upload-inline { display: none !important; }
}

/* ─────────────────────────────────────────────
   Responsive visibility helpers
   ───────────────────────────────────────────── */
.desktop-only { display: none !important; }
.mobile-only  { display: inline-flex; }
@media (min-width: 900px) {
  .desktop-only  { display: block !important; }
  .desktop-only.section-row { display: flex !important; }
  .desktop-only.glance      { display: grid !important; }
  .mobile-only   { display: none !important; }
  .mobile-hidden { display: flex !important; }
}
@media (max-width: 899px) {
  .mobile-hidden { display: none !important; }
}

/* ─────────────────────────────────────────────
   Library strip (mobile-only welcome + stat pills)
   ───────────────────────────────────────────── */
.lib-strip { display: none; }
@media (max-width: 899px) {
  .lib-strip {
    display: flex;
    flex-direction: column;
    gap: 10px;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--r-md);
    padding: 12px 12px 10px;
    margin-bottom: 10px;
    box-shadow: var(--shadow-xs);
  }
  .lib-strip-greet {
    display: flex;
    align-items: center;
    gap: 10px;
    min-width: 0;
  }
  .lib-strip-date {
    font-family: var(--f-mono);
    font-size: 9.5px;
    font-weight: 500;
    letter-spacing: 0.14em;
    text-transform: uppercase;
    color: var(--muted);
    flex-shrink: 0;
    padding: 3px 8px;
    background: var(--surface-2);
    border: 1px solid var(--border-soft);
    border-radius: var(--r-full);
  }
  .lib-strip-name {
    flex: 1;
    min-width: 0;
    font-size: 14px;
    color: var(--text-dim);
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
  }
  .lib-strip-name b {
    font-family: var(--f-display);
    font-weight: 800;
    letter-spacing: 0.03em;
    text-transform: uppercase;
    font-size: 16px;
    color: var(--text);
    margin-left: 4px;
  }
  .lib-strip-pills {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 6px;
  }
  .lib-pill {
    min-width: 0;
    display: grid;
    grid-template-rows: auto auto;
    grid-template-columns: 14px 1fr;
    gap: 1px 6px;
    align-items: center;
    padding: 7px 9px;
    background: var(--surface-2);
    border: 1px solid var(--border-soft);
    border-radius: var(--r-sm);
    border-top: 2px solid var(--mute);
  }
  .lib-pill .icon { grid-row: 1 / span 2; grid-column: 1; font-size: 16px; color: var(--text-dim); }
  .lib-pill .v {
    grid-column: 2;
    font-family: var(--f-mono);
    font-size: 13px;
    font-weight: 600;
    letter-spacing: -0.01em;
    color: var(--text);
    line-height: 1;
  }
  .lib-pill .k {
    grid-column: 2;
    font-family: var(--f-mono);
    font-size: 8.5px;
    font-weight: 500;
    letter-spacing: 0.08em;
    text-transform: uppercase;
    color: var(--muted);
    line-height: 1.1;
  }
  .lib-pill[data-tone="coral"]  { border-top-color: var(--stat-coral); }
  .lib-pill[data-tone="coral"]  .icon { color: var(--stat-coral); }
  .lib-pill[data-tone="blue"]   { border-top-color: var(--stat-blue); }
  .lib-pill[data-tone="blue"]   .icon { color: var(--stat-blue); }
  .lib-pill[data-tone="amber"]  { border-top-color: var(--stat-amber); }
  .lib-pill[data-tone="amber"]  .icon { color: var(--cat-starred); }
  .lib-pill[data-tone="green"]  { border-top-color: var(--stat-green); }
  .lib-pill[data-tone="green"]  .icon { color: var(--stat-green); }
}

/* ─────────────────────────────────────────────
   MOBILE-SPECIFIC POLISH
   ───────────────────────────────────────────── */
@media (max-width: 700px) {
  /* Hero — compact, two-row layout: [date | actions] above title */
  .hero-card {
    padding: 12px 14px 10px;
    margin-bottom: 10px;
  }
  .hero-card h2 {
    font-size: 17px;
    margin-bottom: 8px;
    line-height: 1.1;
  }
  .hero-card .date {
    margin-bottom: 6px;
    font-size: 9px;
    padding: 2px 7px;
  }

  /* Stat numbers stay readable but compact */
  .glance { gap: 6px; }
  .glance .stat { padding: 8px 10px 9px; }
  .glance .stat .n { font-size: 18px; }
  .glance .stat .l { font-size: 8px; letter-spacing: 0.08em; }

  /* Tighter section row spacing on mobile */
  .section-row, .section-title { margin: 10px 2px 8px; padding-bottom: 5px; }

  /* Bottom bar adjustments for thumb-zone */
  .tabs { height: calc(var(--tabs-h) + var(--sa-b)); }
  .tab .label { font-size: 9px; }

  /* Lightbox controls bigger touch targets on mobile */
  .lightbox-foot .ic { width: 48px; height: 48px; }

  /* Sheet footer buttons */
  .sheet-foot .btn { font-size: 11.5px; padding: 9px 8px; gap: 5px; }
  .sheet-foot .btn .icon.sm { font-size: 15px; }

  /* Compact appbar on mobile */
  .appbar .title .h { font-size: 15px; }
  .appbar .title .sub { font-size: 11px; }

  /* The big "+" FAB in the bottom tab — pop it more on mobile */
  .tab.fab .fab-inner { width: 50px; height: 50px; margin-top: -16px; }
}

/* Press feedback for touch */
.btn:active,
.list-row:active,
.chip:active,
.coll-card:active,
.tab:active { transition: transform .08s ease; }
.btn:active        { transform: scale(.97); }
.list-row:active   { background: var(--surface-3); }
.chip:active       { transform: scale(.95); }
.coll-card:active  { transform: scale(.98); }
.tab:active .icon  { transform: scale(.9); transition: transform .1s ease; }

/* Smoother focus ring (not as harsh) */
:focus-visible {
  outline: 2px solid var(--coral);
  outline-offset: 3px;
  border-radius: var(--r-xs);
}

/* Inputs feel chunkier on touch */
.field input,
.chat-input-bar input,
.resize-custom input,
.resize-format select,
.search-input-wrap input {
  min-height: 44px;  /* iOS recommended minimum touch target */
}

/* Better placeholder styling */
input::placeholder, textarea::placeholder {
  color: var(--mute);
  opacity: 0.9;
}

/* Smooth FAB pulse on tap */
.tab.fab .fab-inner:active {
  transform: scale(.9);
  transition: transform .1s ease;
}

/* Native-feeling sheet anim */
.sheet[aria-hidden="false"] .sheet-card {
  animation: sheetIn .32s var(--ease);
}

/* Subtle pulse for active tab indicator */
@keyframes tabPulse {
  0%, 100% { opacity: 1; }
  50%      { opacity: 0.7; }
}
.tab.active::after {
  animation: tabPulse 2.4s ease-in-out infinite;
}

/* Refined toast with icon glow */
.toast .icon {
  color: var(--coral);
  filter: drop-shadow(0 0 6px rgba(250, 138, 114, 0.6));
}
