[hidden] { display: none !important; }
:root {
  --bg: #faf8f6; --surface: #ffffff; --ink: #1f1b18; --muted: #6f655e; --line: #e8e2dc;
  --accent: #e6883b; --accent-ink: #ffffff; --accent-soft: #fdf0e4; --accent-dark: #b9651f;
  --ok: #1f7a4d; --ok-soft: #e4f4ea; --err: #b3261e; --err-soft: #fbe9e7; --warn-soft: #fff4d6;
  --radius: 10px; --shadow: 0 1px 2px rgba(31,27,24,.06), 0 4px 14px rgba(31,27,24,.05);
  --font: "Figtree", system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #161311; --surface: #201c19; --ink: #f3eee9; --muted: #a99d93; --line: #352f2a;
    --accent-soft: #3a2616; --accent-dark: #f0a05f; --ok: #5fd39b; --ok-soft: #173326; --err: #ff8a80; --err-soft: #3b1a17; --warn-soft: #3a3012;
    --shadow: 0 1px 2px rgba(0,0,0,.4), 0 4px 14px rgba(0,0,0,.3);
  }
}
* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body { margin: 0; background: var(--bg); color: var(--ink); font: 16px/1.5 var(--font); }
a { color: var(--accent-dark); }
h1, h2, h3 { line-height: 1.2; margin: 0 0 .5em; letter-spacing: -.01em; }
h1 { font-size: 1.75rem; } h2 { font-size: 1.2rem; } h3 { font-size: 1rem; }
p { margin: 0 0 1em; }
.muted { color: var(--muted); } .small { font-size: .875rem; }
.nowrap { white-space: nowrap; }

/* layout */
.topbar { background: var(--surface); border-bottom: 1px solid var(--line); position: sticky; top: 0; z-index: 10; }
.topbar-in { max-width: 1120px; margin: 0 auto; padding: 0 16px; display: flex; align-items: center; gap: 20px; min-height: 58px; flex-wrap: wrap; }
.brand { font-weight: 800; font-size: 1.15rem; text-decoration: none; color: var(--ink); display: flex; align-items: center; gap: 8px; }
.brand i { width: 26px; height: 26px; border-radius: 7px; background: var(--accent); display: inline-grid; place-items: center; }
.brand i::after { content: ""; border-left: 9px solid #fff; border-top: 6px solid transparent; border-bottom: 6px solid transparent; margin-left: 2px; }
.nav { display: flex; gap: 4px; flex: 1; flex-wrap: wrap; }
.nav a { text-decoration: none; color: var(--muted); padding: 8px 12px; border-radius: 8px; font-weight: 600; font-size: .95rem; }
.nav a:hover { background: var(--accent-soft); color: var(--ink); }
.nav a.on { background: var(--accent-soft); color: var(--accent-dark); }
.who { display: flex; align-items: center; gap: 10px; font-size: .9rem; color: var(--muted); }
main { max-width: 1120px; margin: 0 auto; padding: 28px 16px 64px; }
.page-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 16px; margin-bottom: 20px; flex-wrap: wrap; }
.page-head h1 { margin: 0; }
.grid { display: grid; gap: 16px; }
.cols-2 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.cols-3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
@media (max-width: 800px) { .cols-2, .cols-3 { grid-template-columns: 1fr; } }
.card { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 20px; box-shadow: var(--shadow); }
.card > :last-child { margin-bottom: 0; }
.banner { background: var(--ink); color: var(--bg); padding: 8px 16px; text-align: center; font-size: .9rem; }
.banner form { display: inline; }
.banner button { margin-left: 10px; }

/* forms */
label { display: block; font-weight: 600; font-size: .9rem; margin-bottom: 4px; }
input[type=text], input[type=email], input[type=password], input[type=number], input[type=search], select, textarea {
  width: 100%; padding: 10px 12px; border: 1px solid var(--line); border-radius: 8px; background: var(--surface); color: var(--ink); font: inherit;
}
input:focus-visible, select:focus-visible, textarea:focus-visible, button:focus-visible, a:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
textarea { min-height: 90px; resize: vertical; }
input[type=color] { width: 56px; height: 40px; padding: 2px; border: 1px solid var(--line); border-radius: 8px; background: var(--surface); }
.field { margin-bottom: 16px; }
.hint { color: var(--muted); font-size: .85rem; margin-top: 4px; }
.check { display: flex; gap: 8px; align-items: flex-start; font-weight: 500; }
.check input { margin-top: 5px; }
.row { display: flex; gap: 12px; align-items: center; flex-wrap: wrap; }
.row.end { justify-content: flex-end; }

.btn { display: inline-flex; align-items: center; justify-content: center; gap: 6px; padding: 10px 16px; border-radius: 8px; border: 1px solid transparent;
  background: var(--accent); color: var(--accent-ink); font: inherit; font-weight: 700; text-decoration: none; cursor: pointer; min-height: 42px; }
.btn:hover { filter: brightness(.95); }
.btn.secondary { background: var(--surface); color: var(--ink); border-color: var(--line); }
.btn.danger { background: var(--surface); color: var(--err); border-color: var(--err); }
.btn.small { padding: 6px 10px; min-height: 32px; font-size: .85rem; }
.btn[disabled] { opacity: .5; cursor: not-allowed; }

.flash { padding: 12px 16px; border-radius: 8px; margin-bottom: 16px; font-weight: 500; word-break: break-word; }
.flash.ok { background: var(--ok-soft); color: var(--ok); }
.flash.err { background: var(--err-soft); color: var(--err); }

/* tables & chips */
table { width: 100%; border-collapse: collapse; }
th, td { text-align: left; padding: 10px 12px; border-bottom: 1px solid var(--line); vertical-align: middle; font-size: .95rem; }
th { font-size: .8rem; text-transform: uppercase; letter-spacing: .04em; color: var(--muted); font-weight: 700; }
.table-wrap { overflow-x: auto; }
.chip { display: inline-block; padding: 2px 10px; border-radius: 99px; font-size: .78rem; font-weight: 700; background: var(--line); color: var(--muted); }
.chip.ready, .chip.active, .chip.done { background: var(--ok-soft); color: var(--ok); }
.chip.failed, .chip.suspended { background: var(--err-soft); color: var(--err); }
.chip.processing, .chip.queued, .chip.uploading, .chip.running { background: var(--warn-soft); color: #8a6200; }
@media (prefers-color-scheme: dark) { .chip.processing, .chip.queued, .chip.uploading, .chip.running { color: #f2cf6b; } }

.meter { height: 8px; background: var(--line); border-radius: 99px; overflow: hidden; }
.meter > span { display: block; height: 100%; background: var(--accent); border-radius: 99px; }
.meter.hot > span { background: var(--err); }
.usage { display: grid; gap: 14px; }

/* video library */
.vgrid { display: grid; grid-template-columns: repeat(auto-fill, minmax(250px, 1fr)); gap: 16px; }
.vcard { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); overflow: hidden; box-shadow: var(--shadow); display: flex; flex-direction: column; text-decoration: none; color: inherit; }
.vcard:hover { border-color: var(--accent); }
.thumb { aspect-ratio: 16 / 9; background: #2a2420 center / cover no-repeat; position: relative; display: grid; place-items: center; color: #d9cfc6; font-size: .9rem; }
.thumb .dur { position: absolute; right: 8px; bottom: 8px; background: rgba(0,0,0,.75); color: #fff; padding: 1px 7px; border-radius: 5px; font-size: .78rem; font-weight: 700; }
.thumb .prog { position: absolute; left: 0; bottom: 0; height: 4px; background: var(--accent); }
.vbody { padding: 12px 14px 14px; }
.vtitle { font-weight: 700; margin-bottom: 4px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.vmeta { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; color: var(--muted); font-size: .85rem; }
.empty { text-align: center; padding: 56px 16px; }
.empty h2 { margin-bottom: 8px; }

/* upload */
.drop { border: 2px dashed var(--line); border-radius: var(--radius); padding: 48px 16px; text-align: center; background: var(--surface); transition: border-color .15s, background .15s; }
.drop.over { border-color: var(--accent); background: var(--accent-soft); }
.uplist { margin-top: 16px; display: grid; gap: 10px; }
.upitem { background: var(--surface); border: 1px solid var(--line); border-radius: 8px; padding: 12px 14px; }
.upitem .top { display: flex; justify-content: space-between; gap: 12px; margin-bottom: 8px; font-size: .92rem; }
.upitem .name { font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

/* video detail */
.player-frame { position: relative; padding-top: 56.25%; background: #000; border-radius: var(--radius); overflow: hidden; }
.player-frame iframe { position: absolute; inset: 0; width: 100%; height: 100%; border: 0; }
.code { font: 13px/1.45 ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; background: var(--bg); border: 1px solid var(--line); border-radius: 8px; padding: 12px; word-break: break-all; white-space: pre-wrap; margin: 0 0 10px; }
.bars { display: flex; align-items: flex-end; gap: 3px; height: 120px; }
.bars span { flex: 1; background: var(--accent); border-radius: 3px 3px 0 0; min-height: 2px; opacity: .9; }
.bars span.z { background: var(--line); }
.stat { font-size: 1.6rem; font-weight: 800; letter-spacing: -.02em; }
.stat-label { color: var(--muted); font-size: .85rem; }
.tabs { display: flex; gap: 4px; margin-bottom: 16px; border-bottom: 1px solid var(--line); }

/* plain (auth) layout */
.plain { min-height: 100vh; display: grid; place-items: center; padding: 24px 16px; }
.plain .card { width: 100%; max-width: 420px; }
.plain .brand { justify-content: center; margin-bottom: 20px; font-size: 1.3rem; }
.plain-wide .card { max-width: 640px; }

/* phones: logo + account on the first row, nav as one scrollable row underneath */
@media (max-width: 720px) {
  .topbar-in { gap: 6px 12px; padding-top: 10px; padding-bottom: 4px; }
  .who { margin-left: auto; }
  .who > span { display: none; }
  .nav { order: 3; flex: 0 0 100%; flex-wrap: nowrap; overflow-x: auto; padding-bottom: 6px; scrollbar-width: none; }
  .nav a { white-space: nowrap; }
  main { padding-top: 20px; }
}
