/* Archdrive web app. Tokens and components follow docs/mockups/archdrive.css; dark mode follows the system. */
:root {
  --bg-toolbar: #F6F6F7; --bg-sidebar: #EDEDEF; --bg-content: #FBFBFC; --bg-card: #FFFFFF; --bg-sunken: #F1F1F3;
  --border: rgba(0,0,0,0.09); --border-strong: rgba(0,0,0,0.16); --text-primary: #1D1D1F; --text-secondary: rgba(0,0,0,0.60);
  --text-tertiary: rgba(0,0,0,0.42); --accent: #0A6CDB; --accent-soft: rgba(10,108,219,0.11);
  --success: #1A8A44; --success-soft: rgba(26,138,68,0.12); --danger: #C92D22; --danger-soft: rgba(201,45,34,0.10);
  --warning: #A86408; --warning-soft: rgba(199,122,10,0.14); --ice: #1E7FA8; --ice-soft: rgba(30,127,168,0.12);
  --shadow: 0 12px 40px rgba(0,0,0,0.22);
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg-toolbar: #2A2A2D; --bg-sidebar: #202023; --bg-content: #232326; --bg-card: #2C2C30; --bg-sunken: #1B1B1E;
    --border: rgba(255,255,255,0.09); --border-strong: rgba(255,255,255,0.18); --text-primary: #F2F2F3; --text-secondary: rgba(255,255,255,0.64);
    --text-tertiary: rgba(255,255,255,0.42); --accent: #3E9AFF; --accent-soft: rgba(62,154,255,0.17);
    --success: #34C77B; --success-soft: rgba(52,199,123,0.16); --danger: #FF6259; --danger-soft: rgba(255,98,89,0.14);
    --warning: #E8A23A; --warning-soft: rgba(232,162,58,0.16); --ice: #5CC0E8; --ice-soft: rgba(92,192,232,0.16);
    --shadow: 0 12px 40px rgba(0,0,0,0.6);
  }
}
* { box-sizing: border-box; }
html, body { height: 100%; margin: 0; }
body { font-family: -apple-system, BlinkMacSystemFont, "SF Pro Text", "Helvetica Neue", Arial, sans-serif; -webkit-font-smoothing: antialiased; color: var(--text-primary); background: var(--bg-content); font-size: 13px; }
a { color: inherit; text-decoration: none; }
button, input, select { font: inherit; color: inherit; }
button { cursor: pointer; }
[hidden] { display: none !important; }

#app { height: 100%; display: flex; flex-direction: column; }
.webnav { height: 56px; flex: none; display: flex; align-items: center; gap: 22px; padding: 0 28px; border-bottom: 1px solid var(--border); background: var(--bg-card); position: relative; z-index: 30; }
.brand { display: flex; align-items: center; gap: 9px; font-weight: 700; font-size: 16px; letter-spacing: -0.01em; }
.brand i { width: 22px; height: 22px; border-radius: 6px; background: var(--accent); display: block; }
.webnav .lnk { font-size: 13px; color: var(--text-secondary); font-weight: 500; }
.webnav .lnk.on { color: var(--text-primary); font-weight: 600; }
.websearch { margin-left: auto; width: 340px; max-width: 40vw; position: relative; }
.websearch input { width: 100%; height: 32px; border-radius: 8px; background: var(--bg-sunken); border: 1px solid var(--border); padding: 0 10px 0 32px; outline: none; }
.websearch input:focus { border-color: var(--accent); }
.websearch svg { position: absolute; left: 10px; top: 9px; color: var(--text-tertiary); pointer-events: none; }
.suggest { position: absolute; top: 38px; left: 0; right: 0; background: var(--bg-card); border: 1px solid var(--border-strong); border-radius: 10px; box-shadow: var(--shadow); padding: 6px; max-height: 70vh; overflow: auto; }
.suggest .sec { font-size: 11px; font-weight: 700; letter-spacing: .06em; text-transform: uppercase; color: var(--text-tertiary); padding: 8px 8px 4px; }
.suggest a, .suggest button { display: flex; width: 100%; gap: 8px; align-items: center; padding: 7px 8px; border-radius: 6px; border: 0; background: transparent; text-align: left; }
.suggest a:hover, .suggest button:hover, .suggest .hot { background: var(--accent-soft); }
.suggest small { color: var(--text-tertiary); margin-left: auto; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; max-width: 55%; }
.signout { background: transparent; border: 0; color: var(--text-secondary); }

.body { flex: 1; display: flex; min-height: 0; }
.sidebar { width: 270px; flex: none; background: var(--bg-card); border-right: 1px solid var(--border); display: flex; flex-direction: column; padding: 14px 10px; overflow: auto; }
.no-side .sidebar { display: none; }
.main { flex: 1; min-width: 0; display: flex; flex-direction: column; background: var(--bg-content); overflow: auto; }
.tree { display: flex; flex-direction: column; gap: 1px; }
.tn { display: flex; align-items: center; gap: 6px; height: 28px; padding: 0 8px; border-radius: 6px; white-space: nowrap; }
.tn:hover { background: var(--bg-sunken); }
.tn.active { background: var(--accent-soft); color: var(--accent); font-weight: 600; }
.tn .chev { width: 14px; flex: none; color: var(--text-tertiary); background: transparent; border: 0; padding: 0; height: 20px; display: flex; align-items: center; justify-content: center; }
.tn .chev svg { transition: transform .1s; }
.tn .chev.open svg { transform: rotate(90deg); }
.tn .nm { overflow: hidden; text-overflow: ellipsis; }
.tn .c { margin-left: auto; font-size: 11px; color: var(--text-tertiary); font-variant-numeric: tabular-nums; padding-left: 8px; }
.tn svg.fi { flex: none; color: var(--text-secondary); }
.hint { font-size: 12px; color: var(--text-secondary); line-height: 1.45; }
.side-hint { margin-top: auto; padding: 14px 8px 0; }

.page-head { padding: 16px 28px 12px; display: flex; align-items: flex-end; gap: 16px; flex-wrap: wrap; }
.crumbs { display: flex; align-items: center; flex-wrap: wrap; gap: 7px; font-size: 13px; color: var(--text-secondary); }
.crumbs a:hover { color: var(--accent); }
.crumbs b { color: var(--text-primary); font-weight: 600; }
.page-sub { font-size: 13px; color: var(--text-secondary); margin-top: 6px; display: flex; gap: 8px; align-items: center; }
.page-actions { margin-left: auto; display: flex; gap: 8px; align-items: center; }
.btn { height: 30px; padding: 0 12px; border-radius: 7px; border: 1px solid var(--border-strong); background: var(--bg-card); font-weight: 500; display: inline-flex; align-items: center; gap: 6px; white-space: nowrap; }
.btn:hover:not(:disabled) { background: var(--bg-sunken); }
.btn:disabled { opacity: .5; cursor: default; }
.btn-primary { background: var(--accent); border-color: var(--accent); color: #fff; font-weight: 600; }
.btn-primary:hover:not(:disabled) { background: var(--accent); filter: brightness(1.08); }
.btn-sm { height: 24px; padding: 0 9px; font-size: 12px; border-radius: 6px; }
.seg { display: inline-flex; padding: 2px; border-radius: 8px; background: var(--bg-sunken); border: 1px solid var(--border); }
.seg button { border: 0; background: transparent; height: 24px; padding: 0 12px; font-size: 12px; font-weight: 500; color: var(--text-secondary); border-radius: 6px; }
.seg button.on { background: var(--bg-card); color: var(--text-primary); font-weight: 600; box-shadow: 0 1px 2px rgba(0,0,0,0.14); }
.pill { display: inline-flex; align-items: center; gap: 5px; height: 20px; padding: 0 8px; border-radius: 10px; font-size: 11px; font-weight: 600; white-space: nowrap; background: var(--bg-sunken); color: var(--text-secondary); }
.pill.run { background: var(--accent-soft); color: var(--accent); }
.pill.ice { background: var(--ice-soft); color: var(--ice); }
.pill.warn { background: var(--warning-soft); color: var(--warning); }
.muted { color: var(--text-secondary); } .faint { color: var(--text-tertiary); } .strong { font-weight: 600; }
.mono { font-family: ui-monospace, SFMono-Regular, Menlo, monospace; font-size: 12px; }

.filters { display: flex; align-items: center; gap: 8px; padding: 10px 28px; border-top: 1px solid var(--border); border-bottom: 1px solid var(--border); font-size: 12.5px; flex-wrap: wrap; }
.fpill { display: inline-flex; align-items: center; gap: 5px; height: 24px; padding: 0 10px; border-radius: 12px; border: 1px solid var(--border-strong); background: var(--bg-card); font-size: 12px; font-weight: 500; }
.fpill.on { background: var(--accent-soft); color: var(--accent); border-color: transparent; font-weight: 600; }
.filters .right { margin-left: auto; }
.popover { position: absolute; z-index: 40; min-width: 220px; max-width: 360px; max-height: 340px; overflow: auto; background: var(--bg-card); border: 1px solid var(--border-strong); border-radius: 10px; box-shadow: var(--shadow); padding: 6px; }
.popover button.opt { display: flex; width: 100%; align-items: center; gap: 8px; border: 0; background: transparent; padding: 6px 8px; border-radius: 6px; text-align: left; }
.popover button.opt:hover { background: var(--accent-soft); }
.popover button.opt.on { font-weight: 600; color: var(--accent); }
.popover button.opt small { margin-left: auto; color: var(--text-tertiary); }
.popover .row { display: flex; gap: 8px; align-items: center; padding: 6px 8px; }
.popover hr { border: 0; border-top: 1px solid var(--border); margin: 4px 0; }

.content { padding: 18px 28px 28px; flex: 1; }
.grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 12px; }
.tile { display: flex; flex-direction: column; gap: 4px; position: relative; min-width: 0; }
.tile .nm { font-size: 11px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; color: var(--text-tertiary); font-family: ui-monospace, SFMono-Regular, Menlo, monospace; }
.ph { position: relative; overflow: hidden; border-radius: 6px; background: linear-gradient(135deg, #8aa1b4, #5e7186); aspect-ratio: 4 / 3; }
.ph.t2 { background: linear-gradient(160deg, #c9a58a, #8f6b55); } .ph.t3 { background: linear-gradient(135deg, #9db38f, #62785a); }
.ph.t4 { background: linear-gradient(150deg, #b6a2c7, #76628a); } .ph.t5 { background: linear-gradient(135deg, #d6c28a, #9a8444); }
.ph.t6 { background: linear-gradient(145deg, #7fb4b0, #3f7b78); } .ph.t7 { background: linear-gradient(135deg, #c98f95, #8a4d56); }
.ph.t8 { background: linear-gradient(155deg, #a0a6b0, #596070); }
.ph img { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; }
.ph::after { content: ""; position: absolute; left: 0; right: 0; bottom: 0; height: 38%; background: linear-gradient(to top, rgba(0,0,0,0.28), transparent); pointer-events: none; }
.ph .tag { position: absolute; z-index: 1; left: 6px; bottom: 5px; font-size: 10px; font-weight: 700; color: #fff; letter-spacing: .04em; }
.ph .ts { position: absolute; z-index: 1; right: 6px; bottom: 5px; font-size: 10px; font-weight: 600; color: #fff; font-variant-numeric: tabular-nums; }
.ph .film { position: absolute; z-index: 1; left: 5px; right: 5px; top: 5px; height: 14px; display: flex; gap: 2px; }
.ph .film i { flex: 1; border-radius: 2px; background: rgba(255,255,255,0.38); display: block; }
.ph.doc { background: linear-gradient(160deg, #f4f4f6, #d9dbe2); display: flex; align-items: center; justify-content: center; color: #6a6f7d; font-weight: 800; font-size: 15px; letter-spacing: .06em; }
.ph.doc::after { display: none; }
@media (prefers-color-scheme: dark) { .ph.doc { background: linear-gradient(160deg, #3a3b42, #2a2b31); color: #a2a6b4; } }
.ph.dir { aspect-ratio: 4 / 3; background: var(--bg-sunken); border: 1px solid var(--border); display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 6px; color: var(--text-secondary); }
.ph.dir::after { display: none; }
.tile .check { position: absolute; top: 6px; left: 6px; z-index: 2; width: 20px; height: 20px; border-radius: 50%; border: 1.5px solid #fff; background: rgba(0,0,0,.35); color: #fff; padding: 0; display: none; align-items: center; justify-content: center; }
.tile:hover .check, .tile.sel .check, .selecting .tile .check { display: flex; }
.tile.sel .check { background: var(--accent); border-color: var(--accent); }
.tile.sel .ph { outline: 3px solid var(--accent); outline-offset: -2px; }
table.list { width: 100%; border-collapse: collapse; }
table.list th { text-align: left; font-size: 11px; font-weight: 700; letter-spacing: .05em; text-transform: uppercase; color: var(--text-tertiary); padding: 8px 12px; border-bottom: 1px solid var(--border); white-space: nowrap; }
table.list td { padding: 0 12px; height: 38px; border-bottom: 1px solid var(--border); white-space: nowrap; max-width: 360px; overflow: hidden; text-overflow: ellipsis; }
table.list tr.sel td { background: var(--accent-soft); }
table.list tr:hover td { background: var(--bg-sunken); }
table.list .num { text-align: right; font-variant-numeric: tabular-nums; }
.empty { padding: 60px 0; text-align: center; color: var(--text-secondary); }
.selbar { height: 60px; flex: none; position: sticky; bottom: 0; display: flex; align-items: center; gap: 14px; padding: 0 28px; background: var(--bg-card); border-top: 1px solid var(--border); }
.selbar .sp { margin-left: auto; display: flex; gap: 8px; }

.file { display: flex; gap: 32px; padding: 22px 40px; min-height: 0; flex: 1; }
.file .stage { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 14px; }
.file .stage .ph, .file .stage .ph[class] { flex: 1; min-height: 360px; border-radius: 10px; aspect-ratio: auto; background: #17171a; }
.file .stage .ph.doc { background: var(--bg-sunken); }
.file .stage .ph img { object-fit: contain; }
.file .side { width: 400px; flex: none; display: flex; flex-direction: column; gap: 14px; }
.file h1 { font-size: 22px; font-weight: 700; letter-spacing: -0.01em; margin: 0; word-break: break-all; }
.card { background: var(--bg-card); border: 1px solid var(--border); border-radius: 10px; }
.card-head { display: flex; align-items: center; gap: 10px; padding: 12px 16px; border-bottom: 1px solid var(--border); }
.card-title { font-size: 13px; font-weight: 700; } .card-sub { font-size: 12px; color: var(--text-secondary); }
.card-body { padding: 14px 16px; }
dl.kv { display: grid; grid-template-columns: 110px 1fr; gap: 9px 12px; margin: 0; }
dl.kv dt { color: var(--text-secondary); } dl.kv dd { margin: 0; min-width: 0; word-break: break-word; }
.nav-row { display: flex; gap: 8px; align-items: center; }
.nav-row .count { margin-left: auto; }
.reel-stage { position: relative; border-radius: 10px; overflow: hidden; background: #111; }
.reel-stage .frame { width: 100%; background-repeat: no-repeat; }
.reel-stage .cap { position: absolute; left: 14px; bottom: 12px; font-size: 12px; font-weight: 700; color: #fff; text-shadow: 0 1px 3px rgba(0,0,0,.6); }
.strip { display: grid; grid-template-columns: repeat(auto-fill, minmax(120px, 1fr)); gap: 8px; }
.strip .f { position: relative; border-radius: 6px; overflow: hidden; background-color: #111; background-repeat: no-repeat; border: 2px solid transparent; padding: 0; cursor: pointer; }
.strip .f.on { border-color: var(--accent); }
.strip .f span { position: absolute; right: 5px; bottom: 4px; font-size: 10px; font-weight: 600; color: #fff; text-shadow: 0 1px 2px rgba(0,0,0,.7); font-variant-numeric: tabular-nums; }
.video-top { display: flex; gap: 28px; flex-wrap: wrap; }
.video-top .l { width: min(760px, 100%); flex: none; }
.video-top .r { flex: 1; min-width: 300px; display: flex; flex-direction: column; gap: 14px; }

.overlay { position: fixed; inset: 0; background: rgba(0,0,0,0.34); display: flex; align-items: center; justify-content: center; z-index: 60; }
.sheet { width: 520px; max-width: calc(100vw - 32px); background: var(--bg-card); border: 1px solid var(--border); border-radius: 12px; box-shadow: var(--shadow); overflow: hidden; }
.sheet .hd { padding: 16px 20px; border-bottom: 1px solid var(--border); font-size: 15px; font-weight: 700; }
.sheet .bd { padding: 16px 20px; display: flex; flex-direction: column; gap: 12px; max-height: 60vh; overflow: auto; }
.sheet .ft { padding: 12px 20px; border-top: 1px solid var(--border); display: flex; gap: 8px; justify-content: flex-end; align-items: center; }
.sheet .err { color: var(--danger); margin-right: auto; }
input.txt, input[type=date] { height: 30px; border-radius: 7px; border: 1px solid var(--border-strong); background: var(--bg-card); padding: 0 10px; width: 100%; }
.pick { display: flex; flex-direction: column; border: 1px solid var(--border); border-radius: 8px; max-height: 280px; overflow: auto; }
.pick button { display: flex; align-items: center; gap: 8px; border: 0; background: transparent; text-align: left; padding: 6px 10px; }
.pick button:hover { background: var(--bg-sunken); } .pick button.on { background: var(--accent-soft); color: var(--accent); font-weight: 600; }
.toast { position: fixed; left: 50%; bottom: 24px; transform: translateX(-50%); background: var(--text-primary); color: var(--bg-card); padding: 9px 16px; border-radius: 8px; z-index: 80; box-shadow: var(--shadow); }
.login { margin: auto; width: 340px; max-width: calc(100vw - 32px); display: flex; flex-direction: column; gap: 14px; padding: 28px; }
.login .brand { font-size: 20px; } .login .err { color: var(--danger); min-height: 18px; }
.spin { color: var(--text-tertiary); padding: 24px; text-align: center; }
.callout { display: flex; gap: 10px; padding: 11px 14px; border-radius: 9px; font-size: 12.5px; line-height: 1.5; background: var(--accent-soft); }
.callout.warn { background: var(--warning-soft); }

/* Restore */
.sheet.wide { width: 720px; }
.rv-intro { color: var(--text-secondary); line-height: 1.5; }
.rv-files { border: 1px solid var(--border); border-radius: 8px; max-height: 190px; overflow: auto; }
.rv-files table { width: 100%; border-collapse: collapse; }
.rv-files td { padding: 5px 10px; border-bottom: 1px solid var(--border); white-space: nowrap; max-width: 320px; overflow: hidden; text-overflow: ellipsis; }
.rv-files tr:last-child td { border-bottom: 0; }
.tiers { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.tier { border: 1px solid var(--border-strong); border-radius: 10px; padding: 11px 14px; background: var(--bg-card); text-align: left; display: flex; flex-direction: column; gap: 2px; }
.tier.on { border-color: var(--accent); background: var(--accent-soft); }
.tier .t-name { font-weight: 700; } .tier .t-when { color: var(--text-secondary); font-size: 12px; }
.tier .t-total { font-size: 20px; font-weight: 700; font-variant-numeric: tabular-nums; margin-top: 4px; }
.lines { display: grid; grid-template-columns: 1fr auto; gap: 8px 16px; align-items: baseline; }
.lines .amt { text-align: right; font-variant-numeric: tabular-nums; }
.lines small { display: block; color: var(--text-secondary); }
.lines .total { font-weight: 700; border-top: 1px solid var(--border); padding-top: 8px; }
select.sel { height: 30px; border-radius: 7px; border: 1px solid var(--border-strong); background: var(--bg-card); padding: 0 8px; }
.stats { display: grid; grid-template-columns: repeat(3, 1fr); gap: 14px; padding: 0 28px 14px; }
.stat { padding: 14px 16px; } .stat .v { font-size: 22px; font-weight: 700; margin: 4px 0; font-variant-numeric: tabular-nums; }
.tabs { display: flex; gap: 6px; padding: 0 28px 10px; align-items: center; }
.tabs .right { margin-left: auto; display: flex; gap: 10px; align-items: center; }
.restores { padding: 0 28px 28px; }
.restores table.list td { white-space: normal; height: auto; padding: 10px 12px; vertical-align: top; max-width: none; }
.restores .acts { display: flex; gap: 6px; white-space: nowrap; }
.pill.ok { background: var(--success-soft); color: var(--success); } .pill.bad { background: var(--danger-soft); color: var(--danger); }
.dl-list a { color: var(--accent); }

@media (max-width: 900px) {
  .stats { grid-template-columns: 1fr; padding: 0 14px 14px; } .tabs, .restores { padding-left: 14px; padding-right: 14px; } .tiers { grid-template-columns: 1fr; }
  .sidebar { display: none; }
  .file { flex-direction: column; padding: 16px; } .file .side { width: 100%; }
  .webnav { padding: 0 14px; gap: 12px; } .page-head, .content, .filters, .selbar { padding-left: 14px; padding-right: 14px; }
  .websearch { width: auto; flex: 1; max-width: none; }
}
