/* styles.css - Adrian's iPhone Archive GUI
   Mobile-first, original iOS-inspired styling. No remote fonts/assets.
   Theme via CSS custom properties: prefers-color-scheme + [data-theme] override. */

/* ----- Design tokens (light) ----- */
:root {
  --font: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  --radius-lg: 22px;
  --radius-md: 16px;
  --radius-sm: 10px;

  --bg: #f2f2f7;
  --bg-elevated: #ffffff;
  --panel: rgba(255, 255, 255, 0.72);
  --panel-solid: #ffffff;
  --panel-2: #f7f7fb;
  --text: #1c1c1e;
  --text-2: #6b6b70;
  --text-3: #9a9aa0;
  --separator: rgba(60, 60, 67, 0.14);
  --hairline: rgba(60, 60, 67, 0.10);
  --accent: #0a84ff;
  --accent-text: #ffffff;
  --bubble-in: #e9e9eb;
  --bubble-in-text: #1c1c1e;
  --bubble-out: #0a84ff;
  --bubble-out-text: #ffffff;
  --danger: #ff3b30;
  --warning-bg: rgba(255, 159, 10, 0.14);
  --warning-text: #9a5b00;
  --good: #34c759;
  --shadow: 0 1px 3px rgba(0,0,0,0.06), 0 8px 24px rgba(0,0,0,0.06);
  --blur: saturate(180%) blur(20px);
  --tab-h: 58px;
  --rail-w: 248px;
  --aside-w: 340px;
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #000000;
    --bg-elevated: #1c1c1e;
    --panel: rgba(28, 28, 30, 0.72);
    --panel-solid: #1c1c1e;
    --panel-2: #2c2c2e;
    --text: #f5f5f7;
    --text-2: #a1a1a6;
    --text-3: #6e6e73;
    --separator: rgba(84, 84, 88, 0.5);
    --hairline: rgba(84, 84, 88, 0.34);
    --accent: #0a84ff;
    --bubble-in: #26262a;
    --bubble-in-text: #f5f5f7;
    --shadow: 0 1px 3px rgba(0,0,0,0.5), 0 8px 28px rgba(0,0,0,0.45);
  }
}
/* Manual overrides win over prefers-color-scheme */
:root[data-theme="light"] {
  --bg: #f2f2f7; --bg-elevated:#fff; --panel: rgba(255,255,255,.72); --panel-solid:#fff; --panel-2:#f7f7fb;
  --text:#1c1c1e; --text-2:#6b6b70; --text-3:#9a9aa0; --separator:rgba(60,60,67,.14); --hairline:rgba(60,60,67,.10);
  --bubble-in:#e9e9eb; --bubble-in-text:#1c1c1e; --shadow:0 1px 3px rgba(0,0,0,.06),0 8px 24px rgba(0,0,0,.06);
}
:root[data-theme="dark"] {
  --bg:#000; --bg-elevated:#1c1c1e; --panel:rgba(28,28,30,.72); --panel-solid:#1c1c1e; --panel-2:#2c2c2e;
  --text:#f5f5f7; --text-2:#a1a1a6; --text-3:#6e6e73; --separator:rgba(84,84,88,.5); --hairline:rgba(84,84,88,.34);
  --bubble-in:#26262a; --bubble-in-text:#f5f5f7; --shadow:0 1px 3px rgba(0,0,0,.5),0 8px 28px rgba(0,0,0,.45);
}

* { box-sizing: border-box; }
[hidden] { display: none !important; } /* beat element display rules (e.g. .vault) */
html, body { height: 100%; }
body {
  margin: 0; font-family: var(--font); background: var(--bg); color: var(--text);
  -webkit-font-smoothing: antialiased; line-height: 1.4;
}
h1,h2,h3,h4 { margin: 0; font-weight: 600; }
button { font-family: inherit; cursor: pointer; }
a { color: var(--accent); }

.visually-hidden {
  position: absolute !important; width: 1px; height: 1px; padding: 0; margin: -1px;
  overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; border: 0;
}
.skip-link {
  position: fixed; left: 12px; top: -60px; z-index: 1000; background: var(--accent);
  color: var(--accent-text); padding: 10px 16px; border-radius: 10px; text-decoration: none;
  transition: top .15s ease;
}
.skip-link:focus { top: 12px; }

/* Visible focus everywhere */
:focus-visible { outline: 3px solid var(--accent); outline-offset: 2px; border-radius: 8px; }

/* ---------------- Vault ---------------- */
.vault {
  min-height: 100dvh; display: grid; place-items: center; padding: 24px;
  background: radial-gradient(120% 90% at 50% -10%, rgba(10,132,255,.18), transparent 60%), var(--bg);
}
.vault__card {
  width: min(420px, 100%); background: var(--panel-solid); border-radius: var(--radius-lg);
  padding: 32px 26px; box-shadow: var(--shadow); border: 1px solid var(--hairline); text-align: center;
}
.vault__badge {
  width: 64px; height: 64px; border-radius: 18px; margin: 0 auto 16px;
  display: grid; place-items: center; background: linear-gradient(160deg, #0a84ff, #5e5ce6); color: #fff;
}
.vault__badge svg { width: 32px; height: 32px; }
.vault h1 { font-size: 22px; }
.vault__device { color: var(--text-2); font-size: 14px; margin-top: 4px; }
.vault__access {
  display: inline-flex; align-items: center; gap: 7px; margin: 16px 0; padding: 6px 12px;
  background: var(--panel-2); border-radius: 999px; font-size: 12.5px; color: var(--text-2);
}
.vault__access .dot { width: 8px; height: 8px; border-radius: 50%; background: var(--text-3); }
.vault__access[data-state="verified"] .dot { background: var(--good); }
.vault__form { display: grid; gap: 12px; margin-top: 8px; text-align: left; }
.field label { display: block; font-size: 12.5px; color: var(--text-2); margin-bottom: 6px; }
.field input {
  width: 100%; padding: 13px 14px; border-radius: var(--radius-sm); border: 1px solid var(--hairline);
  background: var(--bg-elevated); color: var(--text); font-size: 16px;
}
.btn {
  border: none; border-radius: var(--radius-sm); padding: 13px 16px; font-size: 16px; font-weight: 600;
  background: var(--panel-2); color: var(--text); display: inline-flex; align-items: center; justify-content: center; gap: 8px;
}
.btn--primary { background: var(--accent); color: var(--accent-text); }
.btn--block { width: 100%; }
.btn--ghost { background: transparent; color: var(--accent); }
.btn:disabled { opacity: .5; cursor: progress; }
.btn svg { width: 18px; height: 18px; }
.vault__warning {
  display: flex; gap: 10px; align-items: flex-start; text-align: left; margin-top: 18px; padding: 12px 14px;
  background: var(--warning-bg); color: var(--warning-text); border-radius: var(--radius-sm); font-size: 12.5px;
}
.vault__warning svg { width: 18px; height: 18px; flex: none; margin-top: 1px; }
.form-error {
  color: var(--danger); font-size: 13px; min-height: 18px; display: flex; align-items: center; gap: 6px;
}

/* ---------------- App shell ---------------- */
.app-header {
  position: sticky; top: 0; z-index: 60; display: flex; align-items: center; gap: 12px;
  padding: 10px 16px; background: var(--panel); -webkit-backdrop-filter: var(--blur); backdrop-filter: var(--blur);
  border-bottom: 1px solid var(--hairline);
}
.app-header h1 { font-size: 17px; white-space: nowrap; }
.header__title { display: flex; align-items: center; gap: 10px; }
.header__spacer { flex: 1; }
.icon-btn {
  width: 38px; height: 38px; border-radius: 50%; border: none; background: var(--panel-2);
  color: var(--text); display: grid; place-items: center; flex: none;
}
.icon-btn svg { width: 20px; height: 20px; }
.icon-btn--accent { color: var(--accent); }
.menu-btn { display: inline-grid; }

.search {
  position: relative; display: flex; align-items: center; flex: 1; max-width: 420px;
}
.search svg.search__icon { position: absolute; left: 12px; width: 18px; height: 18px; color: var(--text-3); pointer-events: none; }
.search input {
  width: 100%; padding: 9px 12px 9px 38px; border-radius: 999px; border: 1px solid var(--hairline);
  background: var(--bg-elevated); color: var(--text); font-size: 15px;
}
.search__results {
  position: absolute; top: calc(100% + 8px); left: 0; right: 0; background: var(--panel-solid);
  border: 1px solid var(--hairline); border-radius: var(--radius-md); box-shadow: var(--shadow);
  max-height: 60vh; overflow: auto; padding: 6px; z-index: 80;
}
.search__result { display: block; width: 100%; text-align: left; background: none; border: none; color: var(--text);
  padding: 9px 10px; border-radius: 10px; }
.search__result:hover, .search__result:focus-visible { background: var(--panel-2); }
.search__result .r-type { font-size: 11px; color: var(--accent); text-transform: uppercase; letter-spacing: .04em; }
.search__result .r-title { font-weight: 600; font-size: 14px; }
.search__result .r-sub { color: var(--text-2); font-size: 12.5px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.search__empty { padding: 14px; color: var(--text-2); font-size: 14px; text-align: center; }

.app-body { display: block; }

/* Navigation rail (desktop) */
.nav-rail { display: none; }
.nav-rail__list { list-style: none; margin: 0; padding: 8px; display: grid; gap: 2px; }
.nav-item {
  display: flex; align-items: center; gap: 12px; width: 100%; padding: 10px 12px; border-radius: 12px;
  border: none; background: none; color: var(--text); font-size: 15px; text-align: left;
}
.nav-item svg { width: 22px; height: 22px; color: var(--text-2); }
.nav-item:hover { background: var(--panel-2); }
.nav-item[aria-current="page"] { background: var(--accent); color: var(--accent-text); }
.nav-item[aria-current="page"] svg { color: var(--accent-text); }
.nav-item .nav-count { margin-left: auto; font-size: 12px; color: var(--text-3); }
.nav-item[aria-current="page"] .nav-count { color: rgba(255,255,255,.85); }

/* Content + detail */
.content { padding: 16px; max-width: 760px; margin: 0 auto; }
.detail-pane { display: none; }

/* Tab bar (mobile) */
.tab-bar {
  position: fixed; bottom: 0; left: 0; right: 0; z-index: 70; display: flex; justify-content: space-around;
  padding: 6px 6px calc(6px + env(safe-area-inset-bottom)); background: var(--panel);
  -webkit-backdrop-filter: var(--blur); backdrop-filter: var(--blur); border-top: 1px solid var(--hairline);
}
.tab {
  border: none; background: none; color: var(--text-3); display: grid; justify-items: center; gap: 3px;
  font-size: 10.5px; padding: 4px 10px; border-radius: 12px; flex: 1; max-width: 96px;
}
.tab svg { width: 24px; height: 24px; }
.tab[aria-current="page"] { color: var(--accent); }
.has-tabbar .content { padding-bottom: calc(var(--tab-h) + 20px); }

/* ---------------- Cards & lists ---------------- */
.section-title { font-size: 13px; color: var(--text-2); text-transform: uppercase; letter-spacing: .04em; margin: 22px 4px 8px; }
.section-title:first-child { margin-top: 4px; }

.card {
  background: var(--panel-solid); border: 1px solid var(--hairline); border-radius: var(--radius-md);
  box-shadow: var(--shadow); overflow: hidden;
}
.card + .card { margin-top: 14px; }
.card__pad { padding: 16px; }

.list { list-style: none; margin: 0; padding: 0; }
.row {
  display: flex; align-items: center; gap: 12px; width: 100%; text-align: left; border: none; background: none;
  color: var(--text); padding: 12px 16px; border-bottom: 1px solid var(--hairline);
}
.row:last-child { border-bottom: none; }
.row:hover { background: var(--panel-2); }
.row[aria-current="true"] { background: color-mix(in srgb, var(--accent) 14%, transparent); }
.row__main { flex: 1; min-width: 0; }
.row__title { font-weight: 600; font-size: 15px; display: flex; align-items: center; gap: 8px; }
.row__sub { color: var(--text-2); font-size: 13.5px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.row__meta { color: var(--text-3); font-size: 12px; text-align: right; flex: none; display: grid; gap: 4px; justify-items: end; }
.chevron { color: var(--text-3); flex: none; }
.chevron svg { width: 18px; height: 18px; transform: scaleX(-1); }

.avatar {
  width: 42px; height: 42px; border-radius: 50%; flex: none; display: grid; place-items: center;
  color: #fff; font-weight: 600; font-size: 15px; background: var(--accent);
}
.avatar--sm { width: 34px; height: 34px; font-size: 13px; }
.avatar--lg { width: 72px; height: 72px; font-size: 26px; }

.badge {
  font-size: 11px; padding: 2px 8px; border-radius: 999px; background: var(--panel-2); color: var(--text-2);
  font-weight: 600; white-space: nowrap;
}
.badge--local { background: rgba(10,132,255,.16); color: var(--accent); }
.badge--enc { background: rgba(52,199,89,.16); color: var(--good); }
.badge--unread { background: var(--accent); color: #fff; min-width: 20px; text-align: center; }
.dot-unread { width: 10px; height: 10px; border-radius: 50%; background: var(--accent); flex: none; }

.pill-row { display: flex; flex-wrap: wrap; gap: 8px; }

/* Home */
.device-hero {
  display: flex; gap: 16px; align-items: center;
}
.device-hero__icon { width: 56px; height: 56px; border-radius: 16px; background: linear-gradient(160deg,#0a84ff,#5e5ce6); color:#fff; display:grid; place-items:center; flex:none; }
.device-hero__icon svg { width: 28px; height: 28px; }
.grid-cats { display: grid; grid-template-columns: repeat(2, 1fr); gap: 12px; }
.cat-tile {
  display: flex; align-items: center; gap: 12px; padding: 14px; border-radius: var(--radius-md);
  border: 1px solid var(--hairline); background: var(--panel-solid); color: var(--text); box-shadow: var(--shadow);
}
.cat-tile__icon { width: 40px; height: 40px; border-radius: 11px; display: grid; place-items: center; color: #fff; flex: none; }
.cat-tile__icon svg { width: 22px; height: 22px; }
.cat-tile__label { font-weight: 600; font-size: 15px; }
.cat-tile__count { font-size: 12.5px; color: var(--text-2); }
.notice {
  display: flex; gap: 10px; align-items: flex-start; padding: 12px 14px; border-radius: var(--radius-sm);
  background: var(--panel-2); color: var(--text-2); font-size: 13px; margin-top: 12px;
}
.notice svg { width: 18px; height: 18px; flex: none; margin-top: 1px; color: var(--text-3); }
.notice--warn { background: var(--warning-bg); color: var(--warning-text); }
.notice--warn svg { color: var(--warning-text); }

.storage-bar { height: 12px; border-radius: 999px; background: var(--panel-2); overflow: hidden; display: flex; margin: 10px 0; }
.storage-seg { height: 100%; }
.legend { display: flex; flex-wrap: wrap; gap: 12px; }
.legend span { display: inline-flex; align-items: center; gap: 6px; font-size: 12.5px; color: var(--text-2); }
.legend i { width: 10px; height: 10px; border-radius: 3px; display: inline-block; }

/* Messages transcript */
.transcript { display: grid; gap: 4px; padding: 8px 12px; }
.date-sep { text-align: center; color: var(--text-3); font-size: 12px; margin: 12px 0 6px; }
.bubble { max-width: 78%; padding: 9px 13px; border-radius: 18px; font-size: 15px; line-height: 1.35; word-wrap: break-word; }
.bubble--in { background: var(--bubble-in); color: var(--bubble-in-text); border-bottom-left-radius: 5px; align-self: flex-start; }
.bubble--out { background: var(--bubble-out); color: var(--bubble-out-text); border-bottom-right-radius: 5px; align-self: flex-end; }
.bubble-time { font-size: 11px; color: var(--text-3); margin: 0 6px 6px; }
.bubble-time--out { text-align: right; }
.attach {
  display: flex; align-items: center; gap: 10px; margin-top: 4px; padding: 10px; border-radius: 12px;
  background: var(--panel-solid); border: 1px solid var(--hairline); max-width: 78%;
}
.attach--out { align-self: flex-end; }
.attach--in { align-self: flex-start; }
.attach__thumb { width: 44px; height: 44px; border-radius: 9px; display: grid; place-items: center; color: #fff; flex: none; }
.attach__thumb svg { width: 22px; height: 22px; }
.attach__main { flex: 1; min-width: 0; }
.attach__name { font-size: 13.5px; font-weight: 600; color: var(--text); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.attach__meta { font-size: 12px; color: var(--text-2); }

/* Calendar */
.cal-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 6px; }
.cal-head h2 { font-size: 20px; }
.event-card { display: flex; gap: 12px; padding: 14px 16px; border-bottom: 1px solid var(--hairline); }
.event-card:last-child { border-bottom: none; }
.event-card__bar { width: 4px; border-radius: 4px; flex: none; }
.event-card__time { font-size: 12.5px; color: var(--text-2); min-width: 64px; flex: none; }

/* Notes / reminders / segmented */
.segmented {
  display: inline-flex; background: var(--panel-2); border-radius: 10px; padding: 3px; gap: 3px; margin-bottom: 14px;
}
.segmented button {
  border: none; background: none; color: var(--text); padding: 7px 16px; border-radius: 8px; font-size: 14px; font-weight: 500;
}
.segmented button[aria-selected="true"] { background: var(--panel-solid); box-shadow: var(--shadow); font-weight: 600; }
.note-body { white-space: pre-wrap; font-size: 15px; color: var(--text); }
.reminder-row { display: flex; align-items: flex-start; gap: 12px; padding: 12px 16px; border-bottom: 1px solid var(--hairline); }
.reminder-row:last-child { border-bottom: none; }
.reminder-check { width: 22px; height: 22px; border-radius: 50%; border: 2px solid var(--text-3); flex: none; display: grid; place-items: center; }
.reminder-check.done { background: var(--good); border-color: var(--good); color: #fff; }
.reminder-check svg { width: 14px; height: 14px; }
.reminder-row.done .reminder-title { color: var(--text-3); text-decoration: line-through; }

/* Media grid */
.media-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 6px; }
.media-cell {
  position: relative; aspect-ratio: 1; border-radius: 12px; overflow: hidden; border: none; padding: 0;
  background: var(--panel-2); display: block;
}
.media-cell .ph {
  position: absolute; inset: 0; display: grid; place-items: center; color: rgba(255,255,255,.92); font-size: 11px;
  background-image: linear-gradient(135deg, rgba(255,255,255,.18), rgba(0,0,0,.18));
}
.media-cell .ph svg { width: 26px; height: 26px; opacity: .9; }
.media-cell.loaded .skeleton-shimmer { display: none; }
.media-badge { position: absolute; top: 6px; left: 6px; }
.media-vid-dur { position: absolute; bottom: 6px; right: 6px; background: rgba(0,0,0,.55); color: #fff; font-size: 11px; padding: 1px 6px; border-radius: 6px; }

/* Files */
.filter-row { display: flex; gap: 8px; flex-wrap: wrap; margin-bottom: 12px; }
.chip { border: 1px solid var(--hairline); background: var(--panel-solid); color: var(--text); padding: 6px 13px; border-radius: 999px; font-size: 13px; }
.chip[aria-pressed="true"] { background: var(--accent); color: #fff; border-color: var(--accent); }
.file-icon { width: 40px; height: 40px; border-radius: 10px; display: grid; place-items: center; background: var(--panel-2); color: var(--accent); flex: none; }
.file-icon svg { width: 20px; height: 20px; }
.mono { font-family: ui-monospace, "SF Mono", Menlo, Consolas, monospace; font-size: 12px; color: var(--text-2); }

/* Upload */
.dropzone {
  border: 2px dashed var(--hairline); border-radius: var(--radius-md); padding: 26px; text-align: center;
  background: var(--panel-2); color: var(--text-2); transition: border-color .15s, background .15s;
}
.dropzone.dragover { border-color: var(--accent); background: color-mix(in srgb, var(--accent) 10%, transparent); color: var(--text); }
.dropzone svg { width: 30px; height: 30px; color: var(--accent); }
.upload-row { display: flex; align-items: center; gap: 12px; padding: 12px 0; border-bottom: 1px solid var(--hairline); }
.upload-row:last-child { border-bottom: none; }
.progress { height: 8px; border-radius: 999px; background: var(--panel-2); overflow: hidden; margin-top: 6px; }
.progress > i { display: block; height: 100%; background: var(--accent); transition: width .2s; }
.upload-row.done .progress > i { background: var(--good); }
.upload-row.failed .progress > i { background: var(--danger); }
.status-text { font-size: 12px; color: var(--text-2); }
.status-text.failed { color: var(--danger); }
.status-text.done { color: var(--good); }

/* Apps */
.app-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(130px,1fr)); gap: 12px; }
.app-tile { display: grid; justify-items: center; gap: 8px; padding: 16px 10px; text-align: center; border-radius: var(--radius-md); border: 1px solid var(--hairline); background: var(--panel-solid); color: var(--text); box-shadow: var(--shadow); }
.app-tile__icon { width: 52px; height: 52px; border-radius: 14px; display: grid; place-items: center; color: #fff; }
.app-tile__icon svg { width: 26px; height: 26px; }
.app-tile__name { font-weight: 600; font-size: 14px; }
.app-tile__bundle { font-size: 11px; color: var(--text-3); word-break: break-all; }

/* Device detail rows */
.kv { display: flex; justify-content: space-between; gap: 16px; padding: 11px 16px; border-bottom: 1px solid var(--hairline); }
.kv:last-child { border-bottom: none; }
.kv dt { color: var(--text-2); font-size: 14px; }
.kv dd { margin: 0; font-weight: 600; font-size: 14px; text-align: right; }

/* Waveform decoration */
.waveform { display: flex; align-items: center; gap: 2px; height: 28px; }
.waveform i { width: 3px; border-radius: 2px; background: var(--accent); opacity: .65; }

/* ---------------- States ---------------- */
.banner {
  position: sticky; top: 0; z-index: 90; display: flex; align-items: center; gap: 10px; padding: 10px 16px;
  font-size: 13.5px; color: #fff; background: var(--danger);
}
.banner--offline { background: #8e8e93; }
.banner button { margin-left: auto; }
.banner .btn--ghost { color: #fff; text-decoration: underline; padding: 4px 8px; }

.skeleton { padding: 16px; }
.sk-line, .sk-block, .sk-circle { background: var(--panel-2); border-radius: 8px; position: relative; overflow: hidden; }
.sk-line { height: 14px; margin: 8px 0; }
.sk-circle { width: 42px; height: 42px; border-radius: 50%; }
.sk-block { height: 76px; margin-bottom: 12px; border-radius: var(--radius-md); }
.skeleton-shimmer, .sk-line::after, .sk-block::after, .sk-circle::after {
  content: ""; position: absolute; inset: 0;
  background: linear-gradient(90deg, transparent, rgba(127,127,127,.18), transparent);
  transform: translateX(-100%); animation: shimmer 1.3s infinite;
}
@keyframes shimmer { 100% { transform: translateX(100%); } }
.sk-row { display: flex; gap: 12px; align-items: center; padding: 8px 0; }
.sk-row .grow { flex: 1; }

.empty-state, .error-state {
  text-align: center; padding: 48px 24px; color: var(--text-2); display: grid; gap: 8px; justify-items: center;
}
.empty-state .bubble-icon, .error-state .bubble-icon {
  width: 60px; height: 60px; border-radius: 50%; background: var(--panel-2); display: grid; place-items: center; color: var(--text-3);
}
.empty-state .bubble-icon svg, .error-state .bubble-icon svg { width: 28px; height: 28px; }
.error-state .bubble-icon { background: rgba(255,59,48,.14); color: var(--danger); }
.empty-state h3, .error-state h3 { font-size: 17px; color: var(--text); }

.unavailable {
  display: flex; gap: 10px; align-items: center; padding: 14px 16px; border-radius: var(--radius-sm);
  background: var(--panel-2); color: var(--text-2); font-size: 13.5px;
}
.unavailable svg { width: 20px; height: 20px; color: var(--text-3); flex: none; }

/* ---------------- Modal ---------------- */
.modal-overlay {
  position: fixed; inset: 0; z-index: 200; background: rgba(0,0,0,.45); display: grid; place-items: center; padding: 20px;
  -webkit-backdrop-filter: blur(4px); backdrop-filter: blur(4px);
}
.modal {
  width: min(560px, 100%); max-height: 86vh; overflow: auto; background: var(--panel-solid);
  border-radius: var(--radius-lg); box-shadow: var(--shadow); border: 1px solid var(--hairline);
}
.modal__head { display: flex; align-items: center; gap: 12px; padding: 16px; border-bottom: 1px solid var(--hairline); position: sticky; top: 0; background: var(--panel-solid); }
.modal__head h2 { font-size: 17px; flex: 1; }
.modal__body { padding: 16px; }
.modal__preview {
  aspect-ratio: 4/3; border-radius: var(--radius-md); display: grid; place-items: center; color: rgba(255,255,255,.9);
  margin-bottom: 14px; background-image: linear-gradient(135deg, rgba(255,255,255,.18), rgba(0,0,0,.2));
}
.modal__preview svg { width: 46px; height: 46px; }

.detail-header { display: none; }
.detail-back { display: none; }

/* Page enter animation */
.fade-in { animation: fade .22s ease; }
@keyframes fade { from { opacity: 0; transform: translateY(6px);} to { opacity: 1; transform: none; } }

/* ---------------- Responsive ---------------- */
@media (min-width: 600px) {
  .grid-cats { grid-template-columns: repeat(3, 1fr); }
  .media-grid { grid-template-columns: repeat(4, 1fr); }
}

/* Tablet+: hide bottom tab bar, show nav rail, two-pane */
@media (min-width: 900px) {
  .tab-bar { display: none; }
  .menu-btn { display: none; }
  .has-tabbar .content { padding-bottom: 16px; }
  .app-body {
    display: grid; grid-template-columns: var(--rail-w) 1fr; align-items: start;
    max-width: 1400px; margin: 0 auto; min-height: calc(100dvh - 60px);
  }
  .app-body.has-detail { grid-template-columns: var(--rail-w) 1fr var(--aside-w); }
  .nav-rail {
    display: block; position: sticky; top: 60px; align-self: start; height: calc(100dvh - 60px);
    overflow: auto; border-right: 1px solid var(--hairline); padding-top: 8px;
  }
  .content { max-width: none; }
  .detail-pane {
    display: block; position: sticky; top: 60px; height: calc(100dvh - 60px); overflow: auto;
    border-left: 1px solid var(--hairline); padding: 16px;
  }
  .detail-pane:empty::after {
    content: "Select an item to see details"; display: grid; place-items: center; height: 60%;
    color: var(--text-3); font-size: 14px; text-align: center;
  }
  .grid-cats { grid-template-columns: repeat(2, 1fr); }
  .media-grid { grid-template-columns: repeat(3, 1fr); }
}

@media (min-width: 1180px) {
  .grid-cats { grid-template-columns: repeat(3, 1fr); }
  .media-grid { grid-template-columns: repeat(4, 1fr); }
}

/* Mobile full-screen detail view */
@media (max-width: 899px) {
  .detail-view-active .content { display: none; }
  .detail-pane.mobile-active {
    display: block; position: fixed; inset: 0; top: 0; z-index: 75; background: var(--bg); overflow: auto;
    padding: 0 16px calc(var(--tab-h) + 20px);
  }
  .detail-header { display: flex; align-items: center; gap: 6px; padding: 12px 0; position: sticky; top: 0; background: var(--bg); z-index: 2; }
  .detail-back { display: inline-flex; align-items: center; gap: 4px; background: none; border: none; color: var(--accent); font-size: 16px; padding: 6px 4px; }
  .detail-back svg { width: 22px; height: 22px; }
}

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