/* CMS admin screens. One action colour (teal), amber only marks where you are. System font: no requests
   to other servers. Scripts: only /_cms/admin.js (search, filters, drag-and-drop upload); all works without. */
:root {
  --canvas: #F4F6F5;
  --surface: #FFFFFF;
  --ink: #1C2422;
  --muted: #5D6865;
  --line: #DCE2DF;
  --side: #17322F;
  --side-ink: #CFE0DA;
  --side-muted: #8FAAA2;
  --side-hover: #21433F;
  --action: #0F7B6C;
  --action-ink: #FFFFFF;
  --action-soft: #E2F1EE;
  --here: #E9B44C;
  --err: #B3261E;
  --err-soft: #FBE9E7;
  --ok: #1E6B3A;
  --ok-soft: #E4F2E8;
  --radius: 10px;
  --font: system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", sans-serif;
  --mono: ui-monospace, "SF Mono", Menlo, Consolas, monospace;
}
@media (prefers-color-scheme: dark) {
  :root {
    --canvas: #111816; --surface: #19221F; --ink: #E6EEEB; --muted: #9AA8A4; --line: #2B3633;
    --side: #0C1513; --side-ink: #CFE0DA; --side-muted: #7F978F; --side-hover: #16241F;
    --action: #3DB39E; --action-ink: #0C1513; --action-soft: #173B34;
    --err: #FF8A80; --err-soft: #3A1D1B; --ok: #7BD88F; --ok-soft: #173123;
  }
}
* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body { margin: 0; background: var(--canvas); color: var(--ink); font: 15px/1.5 var(--font); }
a { color: var(--action); }
:focus-visible { outline: 3px solid var(--here); outline-offset: 2px; }
img, video { max-width: 100%; }
h1 { font-size: 26px; line-height: 1.2; font-weight: 700; letter-spacing: -0.01em; margin: 0; }
h2 { font-size: 17px; line-height: 1.3; font-weight: 650; margin: 0 0 12px; }
p { margin: 0 0 12px; }
.muted { color: var(--muted); }
.small { font-size: 13px; }
code { font-family: var(--mono); font-size: 0.9em; }

/* ── Frame: sidebar + content ── */
.frame { display: grid; grid-template-columns: 232px minmax(0, 1fr); min-height: 100vh; }
.side { background: var(--side); color: var(--side-ink); display: flex; flex-direction: column; padding: 20px 12px; position: sticky; top: 0; height: 100vh; }
.side .site { padding: 4px 10px 18px; }
.side .site b { display: block; font-size: 16px; line-height: 1.3; color: #fff; }
.side .site a { color: var(--side-muted); font-size: 13px; text-decoration: none; }
.side .site a:hover { color: var(--side-ink); text-decoration: underline; }
.side nav { display: flex; flex-direction: column; gap: 2px; }
.side nav a { display: flex; align-items: center; gap: 10px; padding: 9px 10px; border-radius: 8px; color: var(--side-ink); text-decoration: none; font-weight: 500; border-left: 3px solid transparent; }
.side nav a:hover { background: var(--side-hover); }
.side nav a[aria-current="page"] { background: var(--side-hover); border-left-color: var(--here); color: #fff; }
.side nav svg { width: 18px; height: 18px; flex: none; opacity: .85; }
.side .me { margin-top: auto; padding: 14px 10px 0; border-top: 1px solid var(--side-hover); font-size: 13px; color: var(--side-muted); }
.side .me b { color: var(--side-ink); font-weight: 600; }
.side .me button { all: unset; cursor: pointer; color: var(--side-ink); text-decoration: underline; margin-left: 6px; }
.side .me button:focus-visible { outline: 3px solid var(--here); }
main { padding: 32px clamp(16px, 4vw, 48px) 64px; max-width: 1180px; width: 100%; }
.head { display: flex; align-items: flex-end; justify-content: space-between; gap: 16px; flex-wrap: wrap; margin-bottom: 24px; }
.head p { margin: 6px 0 0; color: var(--muted); max-width: 62ch; }

@media (max-width: 820px) {
  .frame { grid-template-columns: minmax(0, 1fr); }
  .side { position: static; height: auto; padding: 12px 16px; flex-direction: row; flex-wrap: wrap; align-items: center; gap: 8px 16px; }
  .side .site { padding: 0; flex: 1; }
  .side nav { flex-direction: row; overflow-x: auto; width: 100%; min-width: 0; order: 3; }
  .side nav a { border-left: 0; border-bottom: 3px solid transparent; white-space: nowrap; padding: 8px 10px; }
  .side nav a[aria-current="page"] { border-bottom-color: var(--here); }
  .side nav svg { display: none; }
  .side .me { margin: 0; padding: 0; border: 0; }
  main { padding-top: 20px; }
}

/* ── Building blocks ── */
.panel { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 20px; }
.panel + .panel, .panel + .grid2, .grid2 + .panel { margin-top: 20px; }
.grid2 { display: grid; grid-template-columns: minmax(0, 3fr) minmax(0, 2fr); gap: 20px; align-items: start; }
@media (max-width: 960px) { .grid2 { grid-template-columns: 1fr; } }
.button { display: inline-flex; align-items: center; gap: 8px; border: 1px solid transparent; border-radius: 8px; padding: 9px 16px; background: var(--action); color: var(--action-ink); font: inherit; font-weight: 600; cursor: pointer; text-decoration: none; line-height: 1.3; }
.button:hover { filter: brightness(1.08); }
.button.quiet { background: var(--surface); color: var(--ink); border-color: var(--line); }
.button.quiet:hover { border-color: var(--muted); filter: none; }
.button.danger { background: var(--surface); color: var(--err); border-color: var(--err); }
.button[disabled] { opacity: .5; cursor: not-allowed; }
.msg { padding: 12px 16px; border-radius: 8px; margin-bottom: 20px; }
.msg.err { background: var(--err-soft); color: var(--err); }
.msg.ok { background: var(--ok-soft); color: var(--ok); }
label { display: block; font-weight: 600; margin: 14px 0 6px; }
input[type=text], input[type=password], input[type=search] { width: 100%; padding: 10px 12px; border: 1px solid var(--line); border-radius: 8px; background: var(--surface); color: var(--ink); font: inherit; }
input:focus-visible { outline: 3px solid var(--here); outline-offset: 0; border-color: transparent; }
.search { max-width: 360px; }
.actions { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; margin-top: 16px; }
form.inline { display: inline; margin: 0; }
.empty { padding: 28px; text-align: center; color: var(--muted); }

/* ── Pages: visual list ── */
.pages { list-style: none; margin: 0; padding: 0; background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); overflow: hidden; }
.pages li { display: grid; grid-template-columns: 96px minmax(0, 1fr) auto; gap: 16px; align-items: center; padding: 12px 16px; border-top: 1px solid var(--line); }
.pages li:first-child { border-top: 0; }
.pages li.d1 { padding-left: 44px; }
.pages li.d2 { padding-left: 72px; }
.pages li.d3, .pages li.d4, .pages li.d5 { padding-left: 100px; }
.pages li:hover { background: color-mix(in srgb, var(--action-soft) 45%, transparent); }
.thumb { width: 96px; aspect-ratio: 3 / 2; border-radius: 6px; background: var(--canvas) center / cover no-repeat; border: 1px solid var(--line); display: grid; place-items: center; color: var(--muted); font-size: 12px; overflow: hidden; }
.thumb img { width: 100%; height: 100%; object-fit: cover; display: block; }
.thumb-link { text-decoration: none; }
.pages .title { font-weight: 650; font-size: 16px; color: var(--ink); text-decoration: none; }
.pages .title:hover { color: var(--action); text-decoration: underline; }
.pages .addr { font-family: var(--mono); font-size: 13px; color: var(--muted); overflow-wrap: anywhere; }
.pages .when { font-size: 13px; color: var(--muted); }
.pages .row-actions { display: flex; gap: 8px; }
.pages .folder { grid-template-columns: 1fr; padding-top: 16px; padding-bottom: 6px; color: var(--muted); font-size: 13px; font-weight: 600; background: var(--canvas); }
@media (max-width: 640px) {
  .pages li { grid-template-columns: 72px minmax(0, 1fr); }
  .thumb { width: 72px; }
  .pages .row-actions { grid-column: 1 / -1; }
  .pages li.child { padding-left: 16px; }
}

/* ── Overview ── */
.recent-pages { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 14px; }
.recent-pages a { text-decoration: none; color: var(--ink); }
.recent-pages .thumb { width: 100%; margin-bottom: 8px; }
.recent-pages b { display: block; font-weight: 600; line-height: 1.3; }
.recent-pages span { font-size: 13px; color: var(--muted); }
.changes { list-style: none; margin: 0; padding: 0; }
.changes li { padding: 10px 0; border-top: 1px solid var(--line); }
.changes li:first-child { border-top: 0; padding-top: 0; }
.changes .who { font-size: 13px; color: var(--muted); }
.facts { display: flex; gap: 28px; flex-wrap: wrap; margin-top: 4px; }
.facts a { text-decoration: none; color: var(--ink); }
.facts b { font-size: 22px; display: block; }
.facts span { color: var(--muted); font-size: 13px; }

/* ── Media library ── */
.toolbar { display: flex; gap: 12px; flex-wrap: wrap; align-items: center; margin-bottom: 16px; }
.filters { display: inline-flex; border: 1px solid var(--line); border-radius: 8px; overflow: hidden; background: var(--surface); }
.filters a, .filters button { all: unset; cursor: pointer; padding: 8px 14px; font-weight: 500; color: var(--muted); }
.filters [aria-current="true"] { background: var(--action-soft); color: var(--ink); }
.filters a:focus-visible, .filters button:focus-visible { outline: 3px solid var(--here); outline-offset: -3px; }
.dropzone { border: 2px dashed var(--line); border-radius: var(--radius); padding: 18px; display: flex; gap: 14px; align-items: center; flex-wrap: wrap; background: var(--surface); margin-bottom: 20px; }
.dropzone.over { border-color: var(--action); background: var(--action-soft); }
.dropzone p { margin: 0; color: var(--muted); flex: 1 1 280px; }
.mgrid { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 12px; list-style: none; margin: 0; padding: 0; }
.mgrid a { display: block; text-decoration: none; color: var(--ink); background: var(--surface); border: 1px solid var(--line); border-radius: 8px; overflow: hidden; }
.mgrid a:hover { border-color: var(--action); }
.mgrid .tile { aspect-ratio: 1; background: var(--canvas); display: grid; place-items: center; overflow: hidden; }
.mgrid .tile img, .mgrid .tile video { width: 100%; height: 100%; object-fit: cover; }
.mgrid .tile .kind { font-weight: 700; color: var(--muted); }
.mgrid .name { padding: 6px 8px; font-size: 12px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.mgrid .unused { font-size: 11px; color: var(--muted); padding: 0 8px 6px; }
.detail { display: grid; grid-template-columns: minmax(0, 3fr) minmax(260px, 2fr); gap: 20px; align-items: start; }
@media (max-width: 860px) { .detail { grid-template-columns: 1fr; } }
.detail .preview { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 12px; display: grid; place-items: center; }
.detail .preview img, .detail .preview video { max-height: 70vh; border-radius: 6px; }
dl.props { display: grid; grid-template-columns: auto 1fr; gap: 6px 16px; margin: 0; }
dl.props dt { color: var(--muted); }
dl.props dd { margin: 0; overflow-wrap: anywhere; }
.used { list-style: none; padding: 0; margin: 0; }
.used li { padding: 6px 0; border-top: 1px solid var(--line); }
.used li:first-child { border-top: 0; }

/* ── Lists and tables ── */
.history { list-style: none; margin: 0; padding: 0; }
.history li { display: flex; justify-content: space-between; align-items: center; gap: 12px; flex-wrap: wrap; padding: 14px 0; border-top: 1px solid var(--line); }
.history li:first-child { border-top: 0; padding-top: 0; }
.history .actions { margin: 0; }
table.values, table.users { width: 100%; border-collapse: collapse; }
table.values th, table.users th { text-align: left; font-size: 13px; color: var(--muted); font-weight: 600; padding: 0 8px 8px; }
table.values td, table.users td { padding: 10px 8px; border-top: 1px solid var(--line); vertical-align: middle; }
table.values td.key { font-family: var(--mono); font-size: 13px; overflow-wrap: anywhere; }
table.values input { max-width: 160px; }
@media (max-width: 640px) {
  table.values tr { display: grid; grid-template-columns: 1fr auto; }
  table.values td.key { grid-column: 1 / -1; border-top: 1px solid var(--line); padding-bottom: 0; }
  table.values td:not(.key) { border-top: 0; }
  table.values thead { display: none; }
}

/* ── Login ── */
body.login { min-height: 100vh; display: grid; place-items: center; padding: 16px; background: var(--side); }
.login-card { width: min(400px, 100%); background: var(--surface); border-radius: 14px; padding: 32px 28px; }
.login-card h1 { font-size: 22px; }
.login-card .muted { margin: 4px 0 8px; }
.login-card .button { width: 100%; justify-content: center; margin-top: 20px; }

@media (prefers-reduced-motion: no-preference) {
  .dropzone { transition: background-color .15s, border-color .15s; }
}
select { width: 100%; padding: 10px 12px; border: 1px solid var(--line); border-radius: 8px; background: var(--surface); color: var(--ink); font: inherit; }
.setting { padding: 14px 0; border-top: 1px solid var(--line); }
.setting:first-of-type { border-top: 0; }
.setting label { margin: 0 0 8px; font-weight: 500; }
.setting .num { display: flex; align-items: center; gap: 10px; }
.setting .num input[type=range] { flex: 1; accent-color: var(--action); }
.setting .num input[type=number] { width: 110px; padding: 8px; border: 1px solid var(--line); border-radius: 8px; background: var(--surface); color: var(--ink); font: inherit; }
.setting .num input[type=color] { width: 52px; height: 40px; padding: 3px; border: 1px solid var(--line); border-radius: 8px; background: var(--surface); }
.setting .num input[type=text] { width: 120px; font-family: var(--mono); }
ul.blocks { list-style: none; margin: 0; padding: 0; display: grid; gap: 16px; }
ul.blocks li { display: grid; grid-template-columns: minmax(0, 2fr) minmax(0, 3fr); gap: 20px; align-items: start; }
ul.blocks iframe { width: 100%; aspect-ratio: 16 / 10; border: 1px solid var(--line); border-radius: 8px; background: var(--canvas); }
ul.blocks details { margin-top: 12px; }
ul.blocks summary { cursor: pointer; color: var(--muted); }
@media (max-width: 760px) { ul.blocks li { grid-template-columns: 1fr; } }

/* Second login step */
.login-card h2 { font-size: 17px; margin: 0 0 6px; }
.setup-choice { border-top: 1px solid var(--line); padding-top: 18px; margin-top: 18px; }
.passkey-box { margin: 12px 0 20px; }
.qr-box { background: #fff; border-radius: 8px; padding: 8px; width: 200px; margin: 12px 0; }
.qr-box .qr { display: block; width: 100%; height: auto; }
.secret { word-break: break-all; font-size: 15px; letter-spacing: .04em; }
.codes { columns: 2; padding-left: 1.4em; font-size: 16px; line-height: 1.9; }
.factor-list { list-style: none; padding: 0; margin: 0 0 8px; }
.factor-list li { display: flex; justify-content: space-between; align-items: center; gap: 12px; padding: 8px 0; border-bottom: 1px solid var(--line); }
.me a { color: inherit; }
@media print { .side, .actions, .msg { display: none !important; } body.login { background: #fff; } .login-card { box-shadow: none; } }
.login-card .passkey-box .button { margin-top: 12px; }
.login-card .or { margin: 18px 0 0; }
