/* Tomen Keep — a dashboard in the manner of Supabase (sidebar, slim top bar, tables, side panel), with Dropbox's warmth
   (plain words, a big friendly drop area), and Tomen's chartreuse as the one accent (AJ, 2026-11-19).
   Faces (AJ: "lets do mdio and uncut"): Uncut Sans for everything (OFL, free anywhere), MD IO for figures (Mass-Driver
   Commercial 2.2: any number of the organisation's websites, WOFF2 only, never the .otf). NOT Siche: its web license caps
   page views across tomen.app and every subdomain, and Keep would spend the reader's allowance. */
@font-face { font-family: 'Uncut Sans'; src: url('/fonts/UncutSans-Variable.woff2') format('woff2-variations'), url('/fonts/UncutSans-Variable.woff2') format('woff2'); font-weight: 300 700; font-style: normal; font-display: swap; }
@font-face { font-family: 'MD IO'; src: url('/fonts/MDIO-Regular.woff2') format('woff2'); font-weight: 400; font-style: normal; font-display: swap; }
@font-face { font-family: 'MD IO'; src: url('/fonts/MDIO-Bold.woff2') format('woff2'); font-weight: 700; font-style: normal; font-display: swap; }
:root {
  --bg: #fcfcfb; --panel: #ffffff; --side: #f7f7f5; --sunk: #f2f2ef;
  --border: #e5e5e1; --border-strong: #d4d4cf;
  --text: #171717; --muted: #6b6b66; --faint: #9a9a93;
  --hover: rgba(23, 23, 23, 0.045); --active: rgba(23, 23, 23, 0.07);
  --accent: #C8FF00; --accent-text: #1A2908; --accent-hover: #b8ec00;
  --accent-ink: #4f6a00;                       /* chartreuse as text or a line on a light ground */
  --accent-soft: color-mix(in srgb, #C8FF00 22%, transparent);
  --danger: #d93036; --danger-soft: color-mix(in srgb, #d93036 10%, transparent);
  --ok: #2f8a3e;
  --shadow: 0 1px 2px rgba(0,0,0,.04), 0 8px 24px rgba(0,0,0,.08);
  --radius: 8px; --radius-sm: 6px;
  --font: 'Uncut Sans', system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  --mono: 'MD IO', ui-monospace, "SF Mono", "Cascadia Mono", Menlo, Consolas, monospace;
  --side-w: 240px; --top-h: 56px; --gutter: 24px;
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #1c1c1c; --panel: #232323; --side: #171717; --sunk: #191919;
    --border: #2e2e2e; --border-strong: #3c3c3c;
    --text: #ededed; --muted: #a1a1a1; --faint: #707070;
    --hover: rgba(255,255,255,.05); --active: rgba(255,255,255,.08);
    --accent-ink: #C8FF00; --accent-soft: color-mix(in srgb, #C8FF00 14%, transparent);
    --danger: #ff6369; --danger-soft: color-mix(in srgb, #ff6369 14%, transparent); --ok: #4cc35e;
    --shadow: 0 1px 2px rgba(0,0,0,.3), 0 12px 32px rgba(0,0,0,.45);
    color-scheme: dark;
  }
}
* { box-sizing: border-box; margin: 0; }
html, body { height: 100%; }
body { background: var(--bg); color: var(--text); font: 14px/1.45 var(--font); -webkit-font-smoothing: antialiased; }
button, input { font: inherit; color: inherit; }
button { cursor: pointer; background: none; border: 0; }
[hidden] { display: none !important; }
.muted { color: var(--muted); }
.fine { color: var(--faint); font-size: 12px; }
.mono { font-family: var(--mono); font-size: 12px; }
.i { width: 16px; height: 16px; flex: none; display: block; }
[data-icon] { display: inline-flex; }
:focus-visible { outline: 2px solid var(--accent-ink); outline-offset: 2px; border-radius: 4px; }

/* Brand */
.brand { display: flex; align-items: center; gap: 10px; padding: 4px 8px; font-size: 15px; }
.brand-mark { width: 26px; height: 26px; border-radius: 7px; background: var(--accent); color: var(--accent-text); display: grid; place-items: center; }
.brand-mark svg { width: 18px; height: 18px; }
.brand-name b { font-weight: 650; }
.brand--big { padding: 0; margin-bottom: 20px; font-size: 17px; }
.brand--big .brand-mark { width: 32px; height: 32px; border-radius: 9px; }

/* Buttons and fields */
.btn { display: inline-flex; align-items: center; gap: 8px; height: 34px; padding: 0 14px; border-radius: var(--radius-sm); border: 1px solid var(--border-strong); background: var(--panel); font-weight: 500; white-space: nowrap; }
.btn:hover { background: var(--hover); }
.btn--primary { background: var(--accent); color: var(--accent-text); border-color: transparent; }
.btn--primary:hover { background: var(--accent-hover); }
.btn--ghost { border-color: transparent; background: none; color: var(--muted); }
.btn--danger { color: var(--danger); }
.btn--danger:hover { background: var(--danger-soft); }
.btn[disabled] { opacity: .5; pointer-events: none; }
.icon-btn { width: 32px; height: 32px; display: grid; place-items: center; border-radius: var(--radius-sm); color: var(--muted); }
.icon-btn:hover { background: var(--hover); color: var(--text); }
.field { display: grid; gap: 6px; font-size: 13px; color: var(--muted); }
.field { min-width: 0; }
.field input { width: 100%; min-width: 0; height: 38px; padding: 0 12px; border-radius: var(--radius-sm); border: 1px solid var(--border-strong); background: var(--panel); color: var(--text); font-size: 14px; }
.field input:focus { outline: none; border-color: var(--accent-ink); box-shadow: 0 0 0 3px var(--accent-soft); }
.stack { display: grid; gap: 12px; }
.row { display: flex; gap: 8px; flex-wrap: wrap; justify-content: center; }

/* Sign-in */
.auth { min-height: 100%; display: grid; place-items: center; padding: 24px 16px; }
.auth-card { width: min(400px, 100%); }
.auth-card h1 { font-size: 22px; font-weight: 650; letter-spacing: -0.01em; margin-bottom: 6px; }
.auth-card > .muted { margin-bottom: 22px; }
.auth-err { color: var(--danger); font-size: 13px; min-height: 18px; margin: 10px 0 4px; }

/* The frame */
.app { display: grid; grid-template-columns: var(--side-w) 1fr; height: 100%; }
.side { background: var(--side); border-right: 1px solid var(--border); display: flex; flex-direction: column; padding: 14px 10px; gap: 14px; min-height: 0; }
.nav { display: grid; gap: 2px; }
.nav-item { display: flex; align-items: center; gap: 10px; height: 34px; padding: 0 10px; border-radius: var(--radius-sm); color: var(--muted); text-align: left; }
.nav-item:hover { background: var(--hover); color: var(--text); }
.nav-item.is-on { background: var(--accent-soft); color: var(--text); font-weight: 550; }
.nav-item.is-on .i { color: var(--accent-ink); }
.count { margin-left: auto; font-family: var(--mono); font-size: 11px; color: var(--faint); }
.side-foot { margin-top: auto; display: grid; gap: 12px; }
.meter { padding: 0 8px; display: grid; gap: 6px; font-size: 12px; color: var(--muted); }
.meter-row { display: flex; justify-content: space-between; }
.meter-bar { height: 6px; border-radius: 3px; background: var(--active); overflow: hidden; }
.meter-bar i { display: block; height: 100%; width: 0; background: var(--accent); border-radius: 3px; transition: width .4s; }
.meter.is-full .meter-bar i { background: var(--danger); }
.account { display: flex; align-items: center; gap: 8px; padding: 8px; border-top: 1px solid var(--border); }
.avatar { width: 26px; height: 26px; border-radius: 50%; background: var(--sunk); border: 1px solid var(--border); display: grid; place-items: center; font-size: 12px; font-weight: 600; flex: none; }
.account-email { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-size: 13px; }

.main { display: flex; flex-direction: column; min-width: 0; min-height: 0; }
.top { height: var(--top-h); display: flex; align-items: center; gap: 12px; padding: 0 var(--gutter); border-bottom: 1px solid var(--border); background: var(--bg); }
.top-title { font-size: 15px; font-weight: 600; white-space: nowrap; }
.menu-btn { display: none; }
.search { flex: 1; max-width: 420px; margin-left: auto; display: flex; align-items: center; gap: 8px; height: 34px; padding: 0 10px; border-radius: var(--radius-sm); border: 1px solid var(--border); background: var(--panel); color: var(--faint); }
.search:focus-within { border-color: var(--accent-ink); box-shadow: 0 0 0 3px var(--accent-soft); }
.search input { flex: 1; min-width: 0; border: 0; background: none; outline: none; color: var(--text); }
.seg { display: flex; border: 1px solid var(--border); border-radius: var(--radius-sm); overflow: hidden; }
.seg-btn { width: 34px; height: 32px; display: grid; place-items: center; color: var(--muted); }
.seg-btn + .seg-btn { border-left: 1px solid var(--border); }
.seg-btn.is-on { background: var(--active); color: var(--text); }
.upload-group { position: relative; display: flex; }
.upload-group > .btn--primary:first-child { border-radius: var(--radius-sm) 0 0 var(--radius-sm); }
.btn--caret { padding: 0 8px; border-radius: 0 var(--radius-sm) var(--radius-sm) 0; border-left: 1px solid rgba(26, 41, 8, .18); }
.menu { position: absolute; right: 0; top: calc(100% + 6px); z-index: 30; min-width: 230px; padding: 4px; background: var(--panel); border: 1px solid var(--border); border-radius: var(--radius); box-shadow: var(--shadow); }
.menu button { width: 100%; display: flex; align-items: center; gap: 10px; padding: 8px 10px; border-radius: var(--radius-sm); text-align: left; }
.menu button:hover { background: var(--hover); }
.menu small { margin-left: auto; color: var(--faint); font-size: 11px; }

.content { flex: 1; overflow: auto; padding: var(--gutter); }

/* Covers */
.grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(148px, 1fr)); gap: 24px 20px; }
.card { display: grid; gap: 8px; text-align: left; min-width: 0; }
.cover { aspect-ratio: 2 / 3; border-radius: var(--radius-sm); overflow: hidden; background: var(--sunk); border: 1px solid var(--border); position: relative; transition: transform .15s, box-shadow .15s; }
.card:hover .cover { transform: translateY(-2px); box-shadow: var(--shadow); }
.cover img { width: 100%; height: 100%; object-fit: cover; display: block; }
.cover-blank { position: absolute; inset: 0; display: flex; flex-direction: column; justify-content: space-between; padding: 12px; font-size: 13px; font-weight: 600; line-height: 1.25; color: var(--text); background: linear-gradient(160deg, var(--sunk), var(--active)); }
.cover-blank small { font-weight: 400; color: var(--muted); }
.badge { position: absolute; left: 6px; bottom: 6px; padding: 1px 6px; border-radius: 4px; font: 600 10px/16px var(--mono); letter-spacing: .03em; text-transform: uppercase; background: rgba(23,23,23,.72); color: #fff; }
.card-title { font-weight: 550; line-height: 1.3; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
.card-sub { color: var(--muted); font-size: 12.5px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; margin-top: -4px; }

/* List */
.table-wrap { border: 1px solid var(--border); border-radius: var(--radius); overflow: auto; background: var(--panel); }
.table { width: 100%; border-collapse: collapse; font-size: 13.5px; }
.table th { text-align: left; font-weight: 500; color: var(--muted); font-size: 12px; padding: 9px 14px; border-bottom: 1px solid var(--border); background: var(--side); white-space: nowrap; }
.table td { padding: 10px 14px; border-bottom: 1px solid var(--border); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; max-width: 360px; }
.table tr:last-child td { border-bottom: 0; }
.table tbody tr { cursor: pointer; }
.table tbody tr:hover { background: var(--hover); }
.table .num { text-align: right; font-family: var(--mono); font-size: 12px; }
.t-title { display: flex; align-items: center; gap: 10px; font-weight: 500; }
.t-thumb { width: 22px; height: 33px; border-radius: 3px; background: var(--sunk); border: 1px solid var(--border); overflow: hidden; flex: none; }
.t-thumb img { width: 100%; height: 100%; object-fit: cover; }
.pill { display: inline-block; padding: 1px 7px; border-radius: 999px; font: 500 11px/18px var(--mono); text-transform: uppercase; background: var(--active); color: var(--muted); }

/* Empty, friendly */
.empty { min-height: 100%; display: grid; place-items: center; }
.empty-drop { max-width: 520px; text-align: center; padding: 48px 32px; border: 2px dashed var(--border-strong); border-radius: 16px; display: grid; gap: 12px; justify-items: center; }
.empty-icon svg { width: 44px; height: 44px; color: var(--accent-ink); }
.empty h3 { font-size: 18px; font-weight: 650; }
.noresults { padding: 48px 0; text-align: center; }

/* Details panel */
.scrim { position: fixed; inset: 0; background: rgba(0,0,0,.25); z-index: 40; }
.panel { position: fixed; top: 0; right: 0; bottom: 0; width: min(440px, 100%); z-index: 41; background: var(--panel); border-left: 1px solid var(--border); box-shadow: var(--shadow); display: flex; flex-direction: column; animation: slide .18s ease-out; }
@keyframes slide { from { transform: translateX(24px); opacity: 0; } }
.panel-head { height: var(--top-h); display: flex; align-items: center; justify-content: space-between; padding: 0 12px 0 20px; border-bottom: 1px solid var(--border); }
.panel-head h3 { font-size: 15px; font-weight: 600; }
.panel-body { flex: 1; overflow: auto; padding: 20px; display: grid; grid-template-columns: minmax(0, 1fr); gap: 22px; align-content: start; }
.panel-body > *, .stack > * { min-width: 0; }   /* a long file name must not widen the panel */
.p-top { display: grid; grid-template-columns: 110px minmax(0, 1fr); gap: 16px; align-items: start; }
.p-top .cover { width: 110px; }
.p-cover-actions { display: grid; gap: 6px; }
.section-label { font-size: 12px; font-weight: 600; color: var(--muted); text-transform: uppercase; letter-spacing: .04em; margin-bottom: 8px; }
.files { border: 1px solid var(--border); border-radius: var(--radius); }
.file-row { display: flex; align-items: center; gap: 12px; padding: 10px 12px; }
.file-row + .file-row { border-top: 1px solid var(--border); }
.file-name { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.file-meta { color: var(--faint); font: 12px var(--mono); white-space: normal; }
.danger-zone { border-top: 1px solid var(--border); padding-top: 18px; display: flex; justify-content: space-between; align-items: center; gap: 12px; }

/* Uploads tray */
.tray { position: fixed; right: 20px; bottom: 20px; z-index: 35; width: min(380px, calc(100% - 32px)); max-height: 50vh; display: flex; flex-direction: column; background: var(--panel); border: 1px solid var(--border); border-radius: var(--radius); box-shadow: var(--shadow); }
.tray-head { display: flex; align-items: center; justify-content: space-between; padding: 8px 8px 8px 14px; border-bottom: 1px solid var(--border); font-weight: 600; }
.tray-list { list-style: none; padding: 4px 0; overflow: auto; }
.tray-item { display: grid; grid-template-columns: 18px 1fr; gap: 2px 10px; padding: 8px 14px; font-size: 13px; }
.tray-item .i { margin-top: 2px; color: var(--faint); }
.tray-item.is-ok .i { color: var(--ok); }
.tray-item.is-bad .i { color: var(--danger); }
.tray-name { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.tray-note { grid-column: 2; color: var(--muted); font-size: 12px; }
.tray-item.is-bad .tray-note { color: var(--danger); }
.tray-bar { grid-column: 2; height: 3px; border-radius: 2px; background: var(--active); overflow: hidden; }
.tray-bar i { display: block; height: 100%; background: var(--accent); width: 0; transition: width .2s; }

.dropzone { position: fixed; inset: 0; z-index: 50; background: color-mix(in srgb, var(--bg) 70%, transparent); backdrop-filter: blur(2px); display: grid; place-items: center; padding: 16px; pointer-events: none; }
.dropzone-card { display: grid; justify-items: center; gap: 6px; padding: 40px 56px; border: 2px dashed var(--accent-ink); border-radius: 16px; background: var(--panel); box-shadow: var(--shadow); font-size: 16px; text-align: center; }
.dropzone-card svg { width: 40px; height: 40px; color: var(--accent-ink); }
.toast { position: fixed; left: 50%; bottom: 24px; transform: translateX(-50%); z-index: 60; padding: 10px 16px; border-radius: var(--radius); background: var(--text); color: var(--bg); box-shadow: var(--shadow); font-size: 13px; max-width: calc(100% - 32px); }

/* Narrow screens: the sidebar becomes a drawer */
@media (max-width: 1000px) { .hide-md { display: none; } }
@media (max-width: 760px) {
  :root { --gutter: 16px; }
  .app { grid-template-columns: 1fr; }
  .side { position: fixed; inset: 0 auto 0 0; width: min(280px, 85%); z-index: 45; transform: translateX(-100%); transition: transform .2s; box-shadow: var(--shadow); }
  .side.is-open { transform: none; }
  .menu-btn { display: grid; }
  .top { gap: 8px; }
  .top-title { display: none; }
  .search { margin-left: 0; }
  .hide-sm { display: none; }
  .grid { grid-template-columns: repeat(auto-fill, minmax(104px, 1fr)); gap: 18px 12px; }
  .seg { display: none; }
}
