/* ==========================================================================
   RookTrove
   "Google Drive usability, Edgar Allan Poe personality."

   The atmosphere lives in the frame -- brand, sidebar, dialogs, the signed-out
   pages. The file list itself stays plain, quiet and fast to scan.

   Palette (from the brand definition):
     Midnight Black #141419  primary background
     Antique Gold   #C4A46A  accents and branding
     Parchment      #EAE0CA  typography and lighter surfaces
     Raven Gray     #454650  secondary interface surfaces
     Deep Burgundy  #5C2636  occasional highlights
   ========================================================================== */

:root {
  --midnight: #141419;
  --gold: #C4A46A;
  --parchment: #EAE0CA;
  --raven: #454650;
  --burgundy: #5C2636;

  --bg: var(--midnight);
  --surface: #1b1b22;
  --surface-2: #23232c;
  --surface-3: #2c2c37;
  --line: #34343f;
  --line-strong: var(--raven);
  --text: var(--parchment);
  --text-muted: #a8a193;
  --accent: var(--gold);
  --accent-strong: #d8bd86;
  --accent-ink: #1a160e;
  --danger: #e28c9c;
  --danger-bg: var(--burgundy);
  --good: #9cc795;
  --focus: #e9cf94;

  --font-display: "Iowan Old Style", "Palatino Linotype", Palatino, "Book Antiqua", "URW Palladio L", Georgia, serif;
  --font-body: system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  --font-mono: ui-monospace, "Cascadia Code", "SF Mono", Menlo, Consolas, monospace;

  --radius: 10px;
  --radius-sm: 6px;
  --shadow: 0 12px 32px rgba(0, 0, 0, .45);
  --topbar-h: 60px;
  --sidebar-w: 252px;

  color-scheme: dark;
}

*, *::before, *::after { box-sizing: border-box; }

html { -webkit-text-size-adjust: 100%; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font: 15px/1.55 var(--font-body);
  min-height: 100vh;
}

h1, h2, h3 {
  font-family: var(--font-display);
  font-weight: 500;
  line-height: 1.2;
  margin: 0 0 .5em;
  letter-spacing: .01em;
}
h1 { font-size: 1.85rem; }
h2 { font-size: 1.3rem; }
h3 { font-size: 1.1rem; }

p { margin: 0 0 1em; }
a { color: var(--accent); text-decoration-thickness: 1px; text-underline-offset: 2px; }
a:hover { color: var(--accent-strong); }
code, .mono { font-family: var(--font-mono); font-size: .92em; }
img, svg, video { max-width: 100%; }

:focus-visible { outline: 2px solid var(--focus); outline-offset: 2px; border-radius: 3px; }

.muted { color: var(--text-muted); }
.small { font-size: .87rem; }
.optional { color: var(--text-muted); font-weight: normal; font-size: .9em; }

.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: absolute; left: 12px; top: -60px; z-index: 100;
  background: var(--accent); color: var(--accent-ink); padding: 8px 14px; border-radius: var(--radius-sm);
}
.skip-link:focus { top: 12px; }

.icon {
  width: 1.15em; height: 1.15em;
  fill: none; stroke: currentColor; stroke-width: 1.7; stroke-linecap: round; stroke-linejoin: round;
  vertical-align: -.2em; flex: none;
}

/* --- Buttons ------------------------------------------------------------- */

.button {
  display: inline-flex; align-items: center; justify-content: center; gap: .45em;
  min-height: 40px; padding: 0 16px;
  border: 1px solid var(--accent); border-radius: var(--radius-sm);
  background: var(--accent); color: var(--accent-ink);
  font: 600 .95rem/1 var(--font-body); text-decoration: none; cursor: pointer;
  transition: background-color .15s, border-color .15s, color .15s;
  white-space: nowrap;
}
.button:hover { background: var(--accent-strong); border-color: var(--accent-strong); color: var(--accent-ink); }
.button--ghost { background: transparent; color: var(--text); border-color: var(--line-strong); }
.button--ghost:hover { background: var(--surface-3); color: var(--text); border-color: var(--accent); }
.button--danger { background: var(--burgundy); border-color: #8c4559; color: #fff; }
.button--danger:hover { background: #74304a; border-color: var(--danger); color: #fff; }
.button--danger-ghost { background: transparent; border-color: #6b3646; color: var(--danger); }
.button--danger-ghost:hover { background: rgba(92, 38, 54, .35); color: #f2b3be; border-color: var(--danger); }
.button--small { min-height: 32px; padding: 0 11px; font-size: .85rem; }
.button--large { min-height: 50px; padding: 0 24px; font-size: 1.05rem; }
.button--block { width: 100%; }
summary.button { list-style: none; }
summary.button::-webkit-details-marker { display: none; }

.icon-button {
  display: inline-flex; align-items: center; justify-content: center;
  width: 36px; height: 36px; padding: 0;
  border: 1px solid transparent; border-radius: 50%;
  background: transparent; color: var(--text-muted); cursor: pointer;
  list-style: none; text-decoration: none;
}
.icon-button::-webkit-details-marker { display: none; }
.icon-button:hover { background: var(--surface-3); color: var(--text); }
.icon-button .icon { width: 20px; height: 20px; }

.linkish { background: none; border: 0; color: var(--accent); cursor: pointer; font: inherit; padding: 0; text-decoration: underline; }

.star.is-on { color: var(--accent); }
.star.is-on .icon { fill: var(--accent); }

form.inline { display: inline; margin: 0; }

/* --- Forms --------------------------------------------------------------- */

.stack > * + * { margin-top: 14px; }
.stack-tight > * + * { margin-top: 6px; }

.field { display: flex; flex-direction: column; gap: 5px; }
.field > label, .label { font-weight: 600; font-size: .93rem; }

input[type=text], input[type=email], input[type=password], input[type=search], input[type=number],
input[type=date], select, textarea {
  width: 100%; min-height: 42px; padding: 8px 12px;
  background: var(--surface-2); color: var(--text);
  border: 1px solid var(--line-strong); border-radius: var(--radius-sm);
  font: inherit;
}
textarea { min-height: 110px; resize: vertical; }
input:focus, select:focus, textarea:focus { border-color: var(--accent); outline: none; box-shadow: 0 0 0 3px rgba(196, 164, 106, .25); }
input[aria-invalid=true] { border-color: var(--danger); }
::placeholder { color: #807a6e; }

.hint { margin: 0; font-size: .85rem; color: var(--text-muted); }
.field-error { margin: 0; color: var(--danger); font-size: .88rem; }

.check { display: flex; gap: 10px; align-items: flex-start; cursor: pointer; }
.check input { margin-top: 4px; accent-color: var(--gold); width: 16px; height: 16px; flex: none; }
.check--block { padding: 10px 12px; border: 1px solid var(--line); border-radius: var(--radius-sm); }

.choice { border: 0; padding: 0; margin: 0; display: flex; flex-direction: column; gap: 8px; }
.choice legend { font-weight: 600; margin-bottom: 8px; }

.row-form { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }
.row-form > input, .row-form > select { flex: 1 1 180px; width: auto; }
.row-form--tight { gap: 6px; }
.row-form--tight > input { flex: 0 1 110px; min-height: 32px; padding: 4px 8px; }
.row-form--tight label { font-size: .85rem; }

.input-prefix { display: flex; align-items: stretch; }
.input-prefix > span {
  display: flex; align-items: center; padding: 0 10px;
  background: var(--surface-3); border: 1px solid var(--line-strong); border-right: 0;
  border-radius: var(--radius-sm) 0 0 var(--radius-sm); color: var(--text-muted);
}
.input-prefix > input { border-radius: 0 var(--radius-sm) var(--radius-sm) 0; }

.code-input { font-family: var(--font-mono); font-size: 1.3rem; letter-spacing: .25em; text-align: center; max-width: 220px; }

.hp-field { position: absolute; left: -10000px; top: auto; width: 1px; height: 1px; overflow: hidden; }

.copyfield { display: flex; gap: 6px; margin: 6px 0; }
.copyfield input { font-family: var(--font-mono); font-size: .85rem; min-height: 34px; }
.copyfield--compact input { min-height: 30px; padding: 4px 8px; font-size: .78rem; }

/* --- Cards, notices, flashes ------------------------------------------- */

.card {
  background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius);
  padding: 22px 24px; margin-bottom: 20px;
}
.card h2 .icon { color: var(--accent); }
.card--accent { border-color: var(--accent); box-shadow: inset 3px 0 0 var(--accent); }
.card--danger { border-color: #5e2c3a; }
.card--centered { text-align: center; max-width: 520px; margin: 0 auto; }
.card__more { margin-top: 14px; }
.card__more > summary { list-style: none; display: inline-flex; }
.card__more > summary::-webkit-details-marker { display: none; }
.card__more[open] > summary { margin-bottom: 14px; }

.notice {
  display: block; padding: 10px 14px; border-radius: var(--radius-sm);
  background: var(--surface-2); border: 1px solid var(--line-strong); font-size: .92rem;
}
.notice--gold { border-color: var(--accent); background: rgba(196, 164, 106, .09); }
.notice--danger { border-color: var(--danger); background: rgba(92, 38, 54, .35); }

.flashes { display: flex; flex-direction: column; gap: 8px; margin-bottom: 18px; }
.flashes--tight { width: 100%; max-width: 440px; }
.flash {
  display: flex; align-items: flex-start; gap: 10px; padding: 11px 14px;
  border-radius: var(--radius-sm); border: 1px solid var(--line-strong); background: var(--surface-2);
}
.flash p { margin: 0; flex: 1; }
.flash .icon { margin-top: 2px; }
.flash--success { border-color: #4b6a47; } .flash--success > .icon { color: var(--good); }
.flash--error { border-color: #7a3a4c; background: rgba(92, 38, 54, .3); } .flash--error > .icon { color: var(--danger); }
.flash--info { border-color: #6d5d3b; } .flash--info > .icon { color: var(--accent); }
.flash__close { background: none; border: 0; color: var(--text-muted); cursor: pointer; padding: 2px; }

.tag {
  display: inline-flex; align-items: center; gap: 4px;
  padding: 1px 8px; border-radius: 999px; font-size: .74rem; line-height: 1.6;
  background: var(--surface-3); color: var(--text-muted); border: 1px solid var(--line);
}
.tag .icon { width: 12px; height: 12px; }
.tag--danger { color: var(--danger); border-color: #6b3646; background: rgba(92, 38, 54, .35); }
.tag--good { color: var(--good); border-color: #3f5a3c; }

.badge {
  display: inline-block; min-width: 20px; padding: 0 6px; margin-left: auto;
  border-radius: 999px; background: var(--burgundy); color: #fff; font-size: .74rem; line-height: 20px; text-align: center;
}

/* --- Top bar ------------------------------------------------------------- */

.topbar {
  position: sticky; top: 0; z-index: 30;
  display: flex; align-items: center; gap: 14px;
  height: var(--topbar-h); padding: 0 16px;
  background: rgba(20, 20, 25, .96); border-bottom: 1px solid var(--line);
  backdrop-filter: blur(6px);
}
.topbar__menu { display: none; }

.brand { display: inline-flex; align-items: center; gap: 10px; color: var(--accent); text-decoration: none; flex: none; }
.brand:hover { color: var(--accent-strong); }
.brand__mark { width: 34px; height: 34px; }
.brand__text { font-family: var(--font-display); font-size: 1.45rem; letter-spacing: .04em; }

.search { position: relative; flex: 1; max-width: 640px; margin: 0 auto; }
.search__icon { position: absolute; left: 13px; top: 50%; transform: translateY(-50%); color: var(--text-muted); }
.search input { padding-left: 40px; border-radius: 999px; background: var(--surface-2); border-color: var(--line); }

.avatar {
  display: inline-flex; align-items: center; justify-content: center; flex: none;
  width: 34px; height: 34px; border-radius: 50%;
  background: var(--burgundy); color: var(--parchment); border: 1px solid var(--accent);
  font-family: var(--font-display); font-size: 1rem;
}
.avatar--ghost { background: var(--surface-3); border-color: var(--line-strong); }
.usermenu__button { list-style: none; cursor: pointer; display: flex; }
.usermenu__button::-webkit-details-marker { display: none; }

/* --- Menus (details/summary dropdowns) ---------------------------------- */

.menu { position: relative; display: inline-block; }
.menu > summary { list-style: none; }
.menu > summary::-webkit-details-marker { display: none; }
.menu__panel {
  position: absolute; z-index: 40; top: calc(100% + 6px); left: 0;
  min-width: 210px; padding: 6px;
  background: var(--surface-2); border: 1px solid var(--line-strong); border-radius: var(--radius);
  box-shadow: var(--shadow);
}
.menu__panel--right { left: auto; right: 0; }
.menu__panel form { margin: 0; }
.menu__header { padding: 8px 10px 10px; margin: 0 0 4px; border-bottom: 1px solid var(--line); display: flex; flex-direction: column; }
.menu__item {
  display: flex; align-items: center; gap: 10px; width: 100%;
  padding: 8px 10px; border: 0; border-radius: var(--radius-sm);
  background: none; color: var(--text); font: inherit; text-align: left; text-decoration: none; cursor: pointer;
}
.menu__item:hover, .menu__item:focus-visible { background: var(--surface-3); color: var(--text); }
.menu__item .icon { color: var(--text-muted); }
.menu__item[aria-current] { color: var(--accent); }
.menu__item--danger, .menu__item--danger .icon { color: var(--danger); }
.filepick { margin: 0; }

/* --- Shell and sidebar --------------------------------------------------- */

.shell { display: grid; grid-template-columns: var(--sidebar-w) minmax(0, 1fr); min-height: calc(100vh - var(--topbar-h)); }

.sidebar {
  position: sticky; top: var(--topbar-h); height: calc(100vh - var(--topbar-h));
  display: flex; flex-direction: column; gap: 18px; padding: 18px 12px;
  border-right: 1px solid var(--line); overflow-y: auto;
  background:
    radial-gradient(120% 50% at 0% 100%, rgba(92, 38, 54, .16), transparent 70%),
    var(--bg);
}
.sidenav { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 2px; }
.sidenav a {
  display: flex; align-items: center; gap: 12px; padding: 9px 14px;
  border-radius: 999px; color: var(--text); text-decoration: none; font-size: .95rem;
}
.sidenav a .icon { color: var(--text-muted); width: 20px; height: 20px; }
.sidenav a:hover { background: var(--surface-2); }
.sidenav a[aria-current=page] { background: rgba(196, 164, 106, .14); color: var(--accent-strong); }
.sidenav a[aria-current=page] .icon { color: var(--accent); }

.nest-meter {
  display: flex; flex-direction: column; gap: 7px; padding: 14px;
  border: 1px solid var(--line); border-radius: var(--radius);
  color: var(--text); text-decoration: none; margin-top: auto;
}
.nest-meter:hover, .nest-meter[aria-current=page] { border-color: var(--accent); color: var(--text); }
.nest-meter__label { font-weight: 600; display: flex; gap: 8px; align-items: center; }
.nest-meter__label .icon { color: var(--accent); }
.nest-meter__text { font-size: .82rem; color: var(--text-muted); }
.nest-meter--warn .meter__fill { background: #d39a52; }
.nest-meter--full .meter__fill { background: var(--danger); }

.meter { display: block; height: 6px; border-radius: 999px; background: var(--surface-3); overflow: hidden; }
.meter--small { width: 90px; height: 4px; margin-top: 4px; }
.meter__fill { display: block; height: 100%; width: 0; background: var(--accent); border-radius: inherit; transition: width .4s; }

.sidebar__motto {
  margin: 0; padding: 0 14px; text-align: center;
  font-family: var(--font-display); font-style: italic; font-size: .85rem; color: #8a8475;
}
.sidebar-scrim { display: none; }

.main { padding: 22px 28px 40px; min-width: 0; }
.app-footer { margin-top: 48px; font-size: .82rem; color: var(--text-muted); text-align: center; }
.app-footer a { color: var(--text-muted); }

/* --- Page head, crumbs, toolbar ----------------------------------------- */

.page { position: relative; }
.page--narrow { max-width: 760px; }
.backlink { margin-bottom: 8px; }
.backlink a { color: var(--text-muted); text-decoration: none; }

.crumbs ol { list-style: none; margin: 0 0 8px; padding: 0; display: flex; flex-wrap: wrap; align-items: center; font-size: .9rem; }
.crumbs li + li::before { content: "\203A"; margin: 0 8px; color: var(--text-muted); }
.crumbs a { color: var(--text-muted); text-decoration: none; }
.crumbs a:hover { color: var(--text); }
.crumbs [aria-current] { color: var(--text); }

.page-head { display: flex; flex-wrap: wrap; align-items: flex-start; justify-content: space-between; gap: 12px 20px; margin-bottom: 16px; }
.page-head__title { min-width: 0; }
.page-head__title h1 { overflow-wrap: anywhere; margin-bottom: .2em; }
.page-head__title h1 .icon { color: var(--accent); }
.page-head__title p { margin: 0; }
.toolbar { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }

.filters { display: flex; flex-wrap: wrap; gap: 10px 16px; align-items: flex-end; margin-bottom: 16px; }
.filters label { display: flex; flex-direction: column; gap: 4px; font-size: .82rem; color: var(--text-muted); }
.filters select, .filters input { width: auto; min-width: 150px; min-height: 36px; }

.selection {
  position: sticky; top: calc(var(--topbar-h) + 8px); z-index: 20;
  display: flex; align-items: center; gap: 8px; flex-wrap: wrap;
  padding: 8px 12px; margin-bottom: 12px;
  background: var(--surface-3); border: 1px solid var(--accent); border-radius: var(--radius);
  box-shadow: var(--shadow);
}
.selection[hidden] { display: none; }
.selection__count { font-weight: 600; margin-right: auto; }

/* --- Item list ----------------------------------------------------------- */

.items { list-style: none; margin: 0; padding: 0; }
.items__head, .item { display: flex; align-items: center; gap: 12px; padding: 0 10px; }
.items__head {
  height: 38px; font-size: .8rem; color: var(--text-muted); text-transform: uppercase; letter-spacing: .06em;
  border-bottom: 1px solid var(--line);
}
.item { min-height: 58px; border-bottom: 1px solid var(--line); border-radius: 0; }
.item:hover { background: var(--surface); }
.item.is-selected { background: rgba(196, 164, 106, .1); }

.col-check { width: 22px; flex: none; display: flex; }
.col-check input { width: 16px; height: 16px; accent-color: var(--gold); margin: 0; }
.col-name { flex: 1; min-width: 0; }
.col-location { width: 190px; flex: none; font-size: .88rem; min-width: 0; }
.location { display: flex; align-items: center; gap: 6px; color: var(--text-muted); text-decoration: none; }
.location span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.location .icon { color: var(--accent); }
.location:hover { color: var(--accent-strong); }
.col-owner { width: 140px; flex: none; font-size: .88rem; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.col-date { width: 130px; flex: none; font-size: .88rem; }
.col-size { width: 84px; flex: none; font-size: .88rem; text-align: right; }
.col-actions { width: 84px; flex: none; display: flex; justify-content: flex-end; align-items: center; gap: 2px; }
.col-actions--wide { width: auto; gap: 6px; }

.item__name { display: flex; align-items: center; gap: 12px; color: var(--text); text-decoration: none; padding: 6px 0; }
.item__name:hover .item__title { color: var(--accent-strong); }
.item__thumb {
  width: 40px; height: 40px; flex: none; display: flex; align-items: center; justify-content: center;
  border-radius: var(--radius-sm); background: var(--surface-2); color: var(--text-muted); overflow: hidden;
}
.item__thumb img { width: 100%; height: 100%; object-fit: cover; }
.item__thumb .icon { width: 22px; height: 22px; }
.item__thumb--folder { color: var(--accent); background: rgba(196, 164, 106, .1); }
.item__thumb--image { color: #9ec0d8; }
.item__thumb--video { color: #c99be0; }
.item__thumb--audio { color: #e0b27a; }
.item__thumb--pdf { color: #e8897f; }
.item__thumb--document, .item__thumb--text { color: #a9c3ea; }
.item__thumb--spreadsheet { color: #8fcf9d; }
.item__thumb--presentation { color: #eda36c; }
.item__thumb--archive { color: #c9b38a; }
.item__label { min-width: 0; display: flex; flex-direction: column; }
.item__title { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.item__badges { display: flex; gap: 4px; flex-wrap: wrap; }
.item__badges:empty { display: none; }

/* Grid view */
.items.is-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(168px, 1fr)); gap: 14px; }
.items.is-grid .items__head { display: none; }
.items.is-grid .item {
  position: relative; flex-direction: column; align-items: stretch; gap: 0; padding: 0;
  border: 1px solid var(--line); border-radius: var(--radius); background: var(--surface); overflow: visible;
}
.items.is-grid .item:hover { border-color: var(--line-strong); }
.items.is-grid .item.is-selected { border-color: var(--accent); }
.items.is-grid .col-check { position: absolute; top: 8px; left: 8px; z-index: 2; }
.items.is-grid .item__name { flex-direction: column; align-items: stretch; gap: 8px; padding: 0 0 4px; }
.items.is-grid .item__thumb { width: 100%; height: auto; aspect-ratio: 4 / 3; border-radius: var(--radius) var(--radius) 0 0; }
.items.is-grid .item__thumb .icon { width: 44px; height: 44px; }
.items.is-grid .item__label { padding: 0 10px; }
.items.is-grid .col-owner, .items.is-grid .col-date { display: none; }
.items.is-grid .col-location { width: auto; padding: 0 10px 2px; font-size: .8rem; }
.items.is-grid .col-size { width: auto; text-align: left; padding: 0 10px 10px; font-size: .8rem; }
.items.is-grid .col-actions { position: absolute; right: 4px; bottom: 2px; width: auto; }

.icon-button .when-grid, .is-grid-view .icon-button .when-list { display: none; }
.is-grid-view .icon-button .when-grid { display: inline; }

.empty { text-align: center; padding: 60px 20px; color: var(--text-muted); }
.empty__raven, .error-raven { opacity: .85; margin-bottom: 12px; }
.empty p { max-width: 440px; margin: 0 auto; }

/* Drag-and-drop */
.dropzone-overlay {
  position: fixed; inset: 0; z-index: 60; display: flex; align-items: center; justify-content: center;
  background: rgba(20, 20, 25, .82); pointer-events: none;
}
.dropzone-overlay[hidden] { display: none; }
.dropzone-overlay__inner {
  padding: 40px 60px; text-align: center; font-size: 1.2rem;
  border: 2px dashed var(--accent); border-radius: 20px; background: var(--surface);
}

/* Upload progress panel */
.uploads {
  position: fixed; right: 18px; bottom: 18px; z-index: 50;
  width: min(380px, calc(100vw - 36px)); max-height: 50vh; display: flex; flex-direction: column;
  background: var(--surface-2); border: 1px solid var(--line-strong); border-radius: var(--radius); box-shadow: var(--shadow);
}
.uploads[hidden] { display: none; }
.uploads__head { display: flex; justify-content: space-between; align-items: center; padding: 8px 8px 8px 14px; border-bottom: 1px solid var(--line); }
.uploads__list { list-style: none; margin: 0; padding: 6px 0; overflow-y: auto; }
.upload { padding: 7px 14px; font-size: .88rem; }
.upload__row { display: flex; gap: 8px; align-items: center; }
.upload__name { flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.upload__state { color: var(--text-muted); font-size: .8rem; white-space: nowrap; }
.upload .meter { margin-top: 5px; }
.upload--done .upload__state { color: var(--good); }
.upload--error .upload__state { color: var(--danger); white-space: normal; }
.upload--error .meter__fill { background: var(--danger); }

/* --- File page ------------------------------------------------------------- */

.file-view { display: grid; grid-template-columns: minmax(0, 1fr) 320px; gap: 24px; align-items: start; }
.preview {
  min-height: 360px; display: flex; align-items: center; justify-content: center;
  background: #0d0d11; border: 1px solid var(--line); border-radius: var(--radius); overflow: hidden;
}
.preview__image { max-height: 78vh; object-fit: contain; display: block; }
.preview__media { width: 100%; max-height: 78vh; background: #000; display: block; }
.preview__frame { width: 100%; height: 78vh; border: 0; background: #fff; display: block; }
.preview__audio { display: flex; flex-direction: column; align-items: center; gap: 24px; padding: 40px; width: 100%; }
.preview__audio audio { width: 100%; max-width: 520px; }
.preview__bigicon { width: 96px !important; height: 96px !important; color: var(--accent); stroke-width: 1.2; }
.preview__none { text-align: center; padding: 40px; color: var(--text-muted); display: flex; flex-direction: column; align-items: center; gap: 10px; }
.preview__text { align-self: stretch; width: 100%; max-height: 78vh; overflow: auto; padding: 0; }
.preview__text .muted { padding: 20px; }

.code {
  margin: 0; padding: 18px 20px; font: .86rem/1.6 var(--font-mono); color: #e3dccb;
  white-space: pre; tab-size: 4; counter-reset: line;
}
.code .tok-com { color: #8b8578; font-style: italic; }
.code .tok-str { color: #b6cf8e; }
.code .tok-num { color: #e5a96b; }
.code .tok-kw { color: var(--gold); }
.code .tok-tag { color: #d8899a; }
.preview__truncated { padding: 10px 20px; border-top: 1px solid var(--line); color: var(--text-muted); font-size: .85rem; }
.preview__toggle { display: flex; gap: 6px; padding: 10px 14px; border-bottom: 1px solid var(--line); position: sticky; top: 0; background: #0d0d11; }

.markdown { padding: 24px 28px; max-width: 760px; line-height: 1.7; }
.markdown h1, .markdown h2, .markdown h3 { margin-top: 1.2em; }
.markdown pre { background: var(--surface-2); padding: 12px; border-radius: var(--radius-sm); overflow-x: auto; }
.markdown code { background: var(--surface-2); padding: 1px 5px; border-radius: 4px; }
.markdown pre code { background: none; padding: 0; }
.markdown blockquote { margin: 0; padding-left: 14px; border-left: 3px solid var(--accent); color: var(--text-muted); }

.details { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 18px; }
.details__name { font-size: 1.3rem; overflow-wrap: anywhere; }
.details__actions { display: flex; gap: 6px; align-items: center; flex-wrap: wrap; margin-bottom: 16px; }
.details__h { font-size: 1.05rem; margin-top: 20px; color: var(--accent); }
.facts { display: grid; grid-template-columns: auto 1fr; gap: 6px 14px; margin: 0; font-size: .9rem; }
.facts dt { color: var(--text-muted); }
.facts dd { margin: 0; overflow-wrap: anywhere; }

.versions { list-style: none; margin: 0; padding: 0; }
.version { display: flex; justify-content: space-between; align-items: center; gap: 10px; padding: 9px 0; border-bottom: 1px solid var(--line); font-size: .9rem; }
.version__actions { display: flex; }
.version--current strong { color: var(--accent); }

.plain-list { list-style: none; padding: 0; margin: 0 0 12px; }
.plain-list li { padding: 4px 0; }
.plain-list--rows li { display: flex; justify-content: space-between; gap: 12px; border-bottom: 1px solid var(--line); padding: 8px 0; }
.plain-list--rows a { color: var(--text); text-decoration: none; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

/* --- Sharing, Rookery ------------------------------------------------------ */

.people { list-style: none; margin: 0 0 14px; padding: 0; }
.person { display: flex; align-items: center; gap: 12px; padding: 10px 0; border-bottom: 1px solid var(--line); flex-wrap: wrap; }
.person__name { flex: 1; min-width: 160px; }
.person select { width: auto; min-height: 32px; padding: 2px 8px; }

.linkbox { padding: 14px; border: 1px solid var(--line); border-radius: var(--radius-sm); margin-bottom: 12px; }
.linkbox--new { border-color: var(--accent); box-shadow: 0 0 0 3px rgba(196, 164, 106, .15); }
.linkbox__head { display: flex; gap: 6px; flex-wrap: wrap; }
.linkbox__edit { margin: 6px 0 10px; }
.linkbox__edit summary { cursor: pointer; color: var(--accent); font-size: .9rem; }
.linkbox__edit[open] summary { margin-bottom: 10px; }

/* --- Security / Nest ------------------------------------------------------- */

.steps { padding-left: 1.3em; }
.steps > li { margin-bottom: 18px; }
.steps--status { list-style: none; padding: 0; counter-reset: step; }
.steps--status > li { position: relative; padding: 0 0 18px 44px; border-left: 1px dashed var(--line-strong); margin-left: 14px; }
.steps--status > li:last-child { border-left-color: transparent; }
.steps--status > li::before {
  counter-increment: step; content: counter(step);
  position: absolute; left: -15px; top: -2px; width: 30px; height: 30px; border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  background: var(--surface-3); border: 1px solid var(--line-strong); color: var(--text-muted); font-weight: 600;
}
.steps--status > li.is-current::before { border-color: var(--accent); color: var(--accent); }
.steps--status > li.is-done::before { content: "\2713"; background: #2d4029; border-color: var(--good); color: var(--good); }
.steps--status > li > strong { display: block; margin-bottom: 4px; }

.backup-codes { display: grid; grid-template-columns: repeat(auto-fill, minmax(120px, 1fr)); gap: 6px; list-style: none; padding: 0; margin: 10px 0 0; }
.backup-codes code { display: block; padding: 6px; text-align: center; background: var(--surface); border-radius: 4px; font-size: 1rem; }

.sessions { list-style: none; padding: 0; margin: 0 0 14px; }
.session { display: flex; align-items: center; gap: 12px; padding: 10px 0; border-bottom: 1px solid var(--line); }
.session > .icon { width: 24px; height: 24px; color: var(--text-muted); }
.session__info { flex: 1; min-width: 0; }

.nest__big { font-family: var(--font-display); font-size: 2rem; margin-bottom: 10px; }
.stackbar { display: flex; height: 14px; border-radius: 999px; background: var(--surface-3); overflow: hidden; margin-bottom: 12px; }
.stackbar__seg { display: block; height: 100%; width: 0; }
.stackbar__seg--live, .legend__swatch--live { background: var(--gold); }
.stackbar__seg--versions, .legend__swatch--versions { background: #8a7a9e; }
.stackbar__seg--droppings, .legend__swatch--droppings { background: #8c4559; }
.legend__swatch--free { background: var(--surface-3); border: 1px solid var(--line-strong); }
.legend { list-style: none; padding: 0; margin: 0 0 12px; display: flex; flex-wrap: wrap; gap: 6px 18px; font-size: .9rem; }
.legend__swatch { display: inline-block; width: 11px; height: 11px; border-radius: 3px; vertical-align: -1px; margin-right: 4px; }

/* --- Tables (admin, links) ------------------------------------------------- */

.table-wrap { overflow-x: auto; }
.table { width: 100%; border-collapse: collapse; font-size: .9rem; }
.table th { text-align: left; font-weight: 600; color: var(--text-muted); font-size: .78rem; text-transform: uppercase; letter-spacing: .05em; padding: 8px 10px; border-bottom: 1px solid var(--line-strong); }
.table td { padding: 10px; border-bottom: 1px solid var(--line); vertical-align: top; }

.manage summary { list-style: none; }
.manage summary::-webkit-details-marker { display: none; }
.manage__panel { padding: 12px; margin-top: 8px; background: var(--surface-2); border: 1px solid var(--line); border-radius: var(--radius-sm); min-width: 280px; }

.stats { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 12px; margin-bottom: 20px; }
.stat { padding: 14px; border: 1px solid var(--line); border-radius: var(--radius); background: var(--surface); display: flex; flex-direction: column; }
.stat__value { font-family: var(--font-display); font-size: 1.5rem; color: var(--accent); }
.stat__label { font-size: .8rem; color: var(--text-muted); }
.stat--warn .stat__value { color: var(--danger); }

/* --- Dialogs ----------------------------------------------------------------- */

.dialog {
  width: min(440px, calc(100vw - 32px)); padding: 0;
  background: var(--surface-2); color: var(--text);
  border: 1px solid var(--line-strong); border-radius: 14px; box-shadow: var(--shadow);
}
.dialog--wide { width: min(560px, calc(100vw - 32px)); }
.dialog::backdrop { background: rgba(8, 8, 12, .72); }
.dialog__body { padding: 22px 24px; display: flex; flex-direction: column; gap: 14px; }
.dialog__body h2 { margin: 0; }
.dialog__actions { display: flex; justify-content: flex-end; gap: 8px; margin-top: 6px; }

.dialog--nevermore { border-color: #6b3646; text-align: center; }
.dialog--nevermore .dialog__body {
  align-items: center;
  background: radial-gradient(90% 60% at 50% 0%, rgba(92, 38, 54, .45), transparent 70%);
}
.dialog--nevermore .dialog__actions { justify-content: center; }
.nevermore__raven { filter: drop-shadow(0 4px 10px rgba(0, 0, 0, .6)); }
.nevermore__word { font-size: 2rem; font-style: italic; color: var(--parchment); letter-spacing: .04em; }
.nevermore-card { text-align: left; }
.nevermore-card .nevermore__raven { display: block; margin: 0 auto 10px; }

.picker { list-style: none; margin: 0; padding: 4px; max-height: 300px; overflow-y: auto; border: 1px solid var(--line); border-radius: var(--radius-sm); background: var(--surface); min-height: 120px; }
.picker li button {
  display: flex; width: 100%; align-items: center; gap: 10px; padding: 8px 10px;
  background: none; border: 0; border-radius: var(--radius-sm); color: var(--text); font: inherit; text-align: left; cursor: pointer;
}
.picker li button:hover { background: var(--surface-3); }
.picker li button .icon { color: var(--accent); }
.picker__empty { padding: 12px; color: var(--text-muted); font-size: .9rem; }
.picker__trail { display: flex; flex-wrap: wrap; gap: 4px; font-size: .88rem; align-items: center; }
.picker__trail button { background: none; border: 0; color: var(--accent); cursor: pointer; padding: 2px 4px; font: inherit; }
.picker__trail span { color: var(--text-muted); }
.picker__hint { margin: 0; font-size: .88rem; }

/* --- Signed-out pages -------------------------------------------------------- */

.page-auth {
  background:
    radial-gradient(70% 45% at 50% 0%, rgba(92, 38, 54, .35), transparent 70%),
    radial-gradient(60% 40% at 50% 100%, rgba(69, 70, 80, .25), transparent 70%),
    var(--bg);
}
.auth-shell { min-height: calc(100vh - 60px); display: flex; flex-direction: column; align-items: center; padding: 36px 16px 20px; gap: 20px; }
.auth-brand { display: flex; flex-direction: column; align-items: center; text-decoration: none; color: var(--accent); text-align: center; }
.auth-brand__mark { width: 150px; height: 150px; filter: drop-shadow(0 8px 24px rgba(0, 0, 0, .6)); }
.auth-brand__title { font-family: var(--font-display); font-size: 2.4rem; letter-spacing: .08em; margin-top: 6px; }
.auth-brand__motto { font-family: var(--font-display); font-style: italic; color: var(--parchment); opacity: .85; }
.auth-card { width: 100%; max-width: 440px; margin: 0; padding: 28px; border-color: #3b3542; background: rgba(27, 27, 34, .94); }
.auth-card--wide { max-width: 540px; }
.auth-card h1 { font-size: 1.6rem; }
.auth-card__alt { margin: 16px 0 0; text-align: center; font-size: .92rem; }
.auth-card__note { margin: 14px 0 0; font-size: .85rem; color: var(--text-muted); }
.verify-mark { text-align: center; font-size: 2.2rem; color: var(--accent); margin: 0 0 6px; }
.verify-mark .icon { width: 44px; height: 44px; }
.verify-mark--ok { color: var(--good); }
.verify-mark--bad { color: var(--danger); }

.site-footer {
  display: flex; flex-wrap: wrap; gap: 6px 18px; justify-content: center;
  padding: 18px 16px 26px; font-size: .82rem; color: var(--text-muted);
}
.site-footer a { color: var(--text-muted); }
.site-footer__motto { font-family: var(--font-display); font-style: italic; }

/* --- Public pages ------------------------------------------------------------- */

.public-bar { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 14px 24px; border-bottom: 1px solid var(--line); }
.public-bar__nav { display: flex; gap: 16px; align-items: center; }
.public-bar__nav > a:not(.button) { color: var(--text); text-decoration: none; }
.public-main { max-width: 1120px; margin: 0 auto; padding: 28px 24px 40px; }
.shared-by { color: var(--text-muted); margin-bottom: 10px; }
.shared-by .icon { color: var(--accent); }
.report-link { margin-top: 30px; text-align: center; font-size: .84rem; }
.report-link a { color: var(--text-muted); }
.public-file__head { display: flex; flex-wrap: wrap; align-items: center; gap: 6px 18px; margin-bottom: 16px; }
.public-file__head h1 { margin: 0; overflow-wrap: anywhere; }
.public-file__head p { margin: 0; flex: 1; }

.drop-page { text-align: center; padding: 10px 0; }
.drop-page__art { filter: drop-shadow(0 8px 24px rgba(0, 0, 0, .6)); }
.drop-target {
  display: flex; flex-direction: column; align-items: center; gap: 6px; margin: 24px 0;
  padding: 44px 20px; border: 2px dashed var(--line-strong); border-radius: 16px; cursor: pointer;
  background: var(--surface); transition: border-color .15s, background .15s;
}
.drop-target:hover, .drop-target:focus-visible, .drop-target.is-over { border-color: var(--accent); background: var(--surface-2); }
.drop-target .icon { width: 40px; height: 40px; color: var(--accent); }

/* Landing */
.page-home .public-main { max-width: 1180px; }
.hero { display: grid; grid-template-columns: minmax(0, 5fr) minmax(0, 6fr); gap: 40px; align-items: center; padding: 30px 0 50px; }
.hero__art { display: flex; justify-content: center; }
.hero__art img {
  width: 100%; max-width: 380px; height: auto;
  filter: drop-shadow(0 18px 40px rgba(0, 0, 0, .7));
}
.hero__eyebrow { font-family: var(--font-display); font-style: italic; color: var(--text-muted); margin-bottom: 4px; }
.hero__title { font-size: clamp(2.8rem, 6vw, 4.4rem); color: var(--accent); letter-spacing: .06em; margin-bottom: 4px; }
.hero__motto { font-family: var(--font-display); font-size: 1.4rem; font-style: italic; margin-bottom: 18px; }
.hero__lede { font-size: 1.08rem; max-width: 560px; color: #d7cdb6; }
.hero__actions { display: flex; flex-wrap: wrap; gap: 12px; margin-top: 22px; }

.features { display: grid; grid-template-columns: repeat(auto-fit, minmax(260px, 1fr)); gap: 18px; margin-bottom: 40px; }
.feature {
  padding: 22px; border: 1px solid var(--line); border-radius: var(--radius);
  background: linear-gradient(180deg, var(--surface), rgba(27, 27, 34, .4));
}
.feature__icon { width: 34px; height: 34px; color: var(--accent); stroke-width: 1.3; margin-bottom: 8px; }
.feature p { color: #cfc6b1; margin: 0; }

.quote { max-width: 680px; margin: 0 auto 30px; text-align: center; font-family: var(--font-display); }
.quote p { font-size: 1.3rem; font-style: italic; }
.quote footer { font-size: .9rem; color: var(--text-muted); }

/* Legal pages */
.prose { max-width: 720px; margin: 0 auto; }
.prose h2 { margin-top: 1.6em; color: var(--accent); }
.prose li { margin-bottom: .4em; }

/* Error page */
.page-error { background: radial-gradient(60% 40% at 50% 0%, rgba(92, 38, 54, .3), transparent 70%), var(--bg); }
.page-error .card { margin-top: 60px; }
.error-status { font-family: var(--font-display); font-size: 1rem; color: var(--text-muted); letter-spacing: .3em; margin: 0; }
.error-hint { color: var(--accent); }
.error-detail { text-align: left; white-space: pre-wrap; font-size: .75rem; max-height: 300px; overflow: auto; background: #0d0d11; padding: 10px; border-radius: 6px; }

/* --- Responsive ------------------------------------------------------------- */

@media (max-width: 1100px) {
  .file-view { grid-template-columns: 1fr; }
  .col-owner { display: none; }
}

@media (max-width: 900px) {
  .topbar__menu { display: inline-flex; }
  .brand__text { display: none; }
  .shell { grid-template-columns: 1fr; }
  .sidebar {
    position: fixed; top: var(--topbar-h); left: 0; bottom: 0; height: auto; z-index: 35;
    width: min(290px, 85vw); transform: translateX(-102%); transition: transform .2s ease;
    box-shadow: var(--shadow); background: var(--bg);
  }
  .sidebar.is-open { transform: none; }
  .sidebar-scrim:not([hidden]) { display: block; position: fixed; inset: var(--topbar-h) 0 0 0; z-index: 34; background: rgba(0, 0, 0, .5); }
  .main { padding: 16px 16px 32px; }
  .hero { grid-template-columns: 1fr; text-align: center; gap: 10px; }
  .hero__art img { max-width: 240px; }
  .hero__lede { margin: 0 auto; }
  .hero__actions { justify-content: center; }
}

@media (max-width: 640px) {
  h1 { font-size: 1.5rem; }
  .col-date { display: none; }
  .col-location { width: 110px; font-size: .8rem; }
  .col-size { width: 64px; font-size: .8rem; }
  .items__head { display: none; }
  .card { padding: 18px 16px; }
  .public-bar { padding: 12px 16px; }
  .public-main { padding: 20px 16px 32px; }
  .table thead { display: none; }
  .table tr { display: block; border-bottom: 1px solid var(--line-strong); padding: 6px 0; }
  .table td { display: block; border: 0; padding: 4px 0; }
  .table td[data-label]::before { content: attr(data-label); display: block; font-size: .72rem; text-transform: uppercase; letter-spacing: .05em; color: var(--text-muted); }
  .items.is-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; }
  .toolbar .button { padding: 0 12px; }
  .search input { font-size: 16px; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { transition: none !important; animation: none !important; }
}

@media print {
  .topbar, .sidebar, .toolbar, .col-actions, .col-check { display: none !important; }
  body { background: #fff; color: #000; }
}
