/* Admin: cobalt header band, paper workspace, dense hairline tables. */
main.admin { min-height: 100vh; }
label { display: block; margin-bottom: 14px; font-weight: 600; font-size: .92rem; }
label.inline { display: inline-flex; gap: 8px; align-items: center; margin: 0; font-weight: 500; }

/* ---------- sign in ---------- */
.login-stage:has(> #login[hidden]) { display: none; }
.login-field { padding: 28px clamp(16px, 5vw, 64px) calc(7vw + 196px); }
.login-title { font-size: clamp(4rem, 13vw, 9rem); margin-top: clamp(24px, 6vh, 56px); color: var(--on-field); }
#login { max-width: 440px; margin: -170px auto 64px; width: calc(100% - 32px); padding: clamp(22px, 4vw, 34px); }
#login h1 { font-size: 2.6rem; margin-bottom: 20px; }
#login button { width: 100%; padding: 14px; margin-top: 4px; }

/* ---------- header band ---------- */
.topbar {
  display: flex; flex-wrap: wrap; align-items: center; gap: 10px 28px;
  padding: 14px clamp(16px, 3vw, 36px); background: var(--field); color: var(--on-field);
  position: sticky; top: 0; z-index: 5;
}
.topbar .wordmark { margin-right: 8px; }
.tabs { display: flex; flex-wrap: wrap; gap: 2px; flex: 1; }
.tab {
  background: transparent; color: var(--on-field-soft); padding: 9px 12px;
  font-family: var(--display); font-weight: 800; font-size: 1.12rem; letter-spacing: .06em; text-transform: uppercase;
}
.tab:hover { background: var(--field-deep); color: var(--on-field); }
.tab[aria-current="page"] { background: var(--active); color: var(--on-active); }
.who { color: var(--on-field-soft); font-size: .9rem; display: flex; gap: 12px; align-items: center; }
button.link { background: none; color: var(--on-field); padding: 0; text-decoration: underline; text-underline-offset: 3px; }
button.link:hover { background: none; color: var(--active); }

/* ---------- workspace ---------- */
.workspace { max-width: 1320px; margin: 0 auto; padding: 18px clamp(16px, 3vw, 36px) 64px; }
.status { min-height: 1.5em; margin: 0 0 12px; color: var(--muted); font-weight: 500; }
.status.bad { color: var(--danger); font-weight: 600; }
@media (prefers-color-scheme: dark) { .status.bad { color: #ff7a63; } }
.panel { animation: panel-in .5s var(--ease-out) both; }
@keyframes panel-in { from { clip-path: inset(0 100% 0 0); } to { clip-path: inset(0 0 0 0); } }
@media (prefers-reduced-motion: reduce) { .panel { animation: none; } }

.toolbar { display: flex; flex-wrap: wrap; gap: 12px; align-items: end; justify-content: space-between; margin-bottom: 14px; }
.toolbar label { margin: 0; }
.toolbar .hint { margin: 0; max-width: 60ch; }
.toolbar select { display: inline-block; width: auto; min-width: 160px; }
.toolbar input:not([type="checkbox"]) { display: inline-block; width: 280px; max-width: 100%; }
.actions { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; }
.toolbar .actions button, #new-code { padding: 9px 14px; }

.crumbs { display: flex; flex-wrap: wrap; gap: 2px; align-items: center; font-family: var(--display); font-weight: 800; font-size: 1.5rem; text-transform: uppercase; letter-spacing: .02em; }
.crumbs button { background: none; color: var(--ink); padding: 2px 4px; font: inherit; letter-spacing: inherit; }
.crumbs button:hover { background: var(--active); color: var(--on-active); }
.crumbs button:last-child { color: var(--field); }
@media (prefers-color-scheme: dark) { .crumbs button:last-child { color: #8fa2ff; } }
.crumbs span { color: var(--muted); padding: 0 2px; }

.view-toggle { display: inline-flex; box-shadow: inset 0 0 0 1.5px var(--line-strong); }
.view-toggle button { background: transparent; color: var(--ink); padding: 9px 14px; }
.view-toggle button:hover { background: var(--tint); color: var(--ink); }
.view-toggle button[aria-pressed="true"] { background: var(--ink); color: var(--paper); }

/* ---------- dense hairline tables ---------- */
.list { width: 100%; border-collapse: collapse; background: var(--sheet); box-shadow: 0 0 0 1px var(--line); font-variant-numeric: tabular-nums; }
.list th, .list td { padding: 7px 10px; text-align: left; border-bottom: 1px solid var(--line); vertical-align: middle; }
.list th {
  font-size: .72rem; font-weight: 700; letter-spacing: .1em; text-transform: uppercase; color: var(--muted);
  background: var(--paper); border-bottom: 1.5px solid var(--ink); position: sticky; top: 64px; z-index: 1;
}
.list tbody tr { transition: background-color .15s var(--ease-out); }
.list tbody tr:hover { background: var(--tint); }
.list tr:last-child td { border-bottom: 0; }
.list .num { text-align: right; white-space: nowrap; }
.list .check { width: 34px; }
.list td.name { overflow-wrap: anywhere; }
.list td.row-actions { text-align: right; white-space: nowrap; }
.list td.row-actions button { padding: 5px 10px; font-size: .8rem; margin-left: 4px; }
.list td.row-actions button.secondary { box-shadow: inset 0 0 0 1px var(--line-strong); }
.list td.row-actions button.secondary:hover { box-shadow: none; }
.list .empty { color: var(--muted); text-align: center; padding: 36px 12px; }
.open { display: inline-flex; gap: 8px; align-items: center; background: none; color: var(--ink); padding: 2px 0; text-align: left; font-weight: 600; }
.open:hover { background: none; color: var(--field); text-decoration: underline; text-underline-offset: 3px; }
@media (prefers-color-scheme: dark) { .open:hover { color: #8fa2ff; } }
.open svg, .ico { width: 18px; height: 18px; flex: none; color: var(--field); }
@media (prefers-color-scheme: dark) { .open svg { color: #8fa2ff; } }
.tag { display: inline-block; padding: 2px 8px; font-size: .74rem; font-weight: 700; letter-spacing: .06em; text-transform: uppercase; box-shadow: inset 0 0 0 1px var(--line-strong); white-space: nowrap; }
.tag.ok { background: var(--ink); color: var(--paper); box-shadow: none; }
.tag.bad { background: var(--danger); color: var(--on-danger); box-shadow: none; }
.small { font-size: .82rem; color: var(--muted); overflow-wrap: anywhere; }
#load-more { margin-top: 14px; }

/* ---------- gallery ---------- */
.gallery { display: grid; grid-template-columns: repeat(auto-fill, minmax(176px, 1fr)); gap: 12px; }
.tile {
  display: flex; flex-direction: column; gap: 8px; padding: 0 0 10px; text-align: left; cursor: pointer;
  background: var(--sheet); color: var(--ink); box-shadow: 0 0 0 1px var(--line);
  transition: transform .25s var(--ease-out), box-shadow .25s var(--ease-out);
}
.tile:hover { background: var(--sheet); color: var(--ink); transform: translateY(-3px); box-shadow: var(--lift); }
.tile img, .tile .folder { width: 100%; aspect-ratio: 1; object-fit: cover; display: block; background: var(--tint); }
.tile .folder { display: flex; align-items: center; justify-content: center; background: var(--field); color: var(--on-field); }
.tile .folder svg { width: 56px; height: 56px; }
.tile span { padding: 0 10px; font-size: .84rem; font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.tile img.broken { object-fit: contain; padding: 30%; }

/* ---------- dialogs ---------- */
dialog {
  border: 0; border-radius: 0; padding: 0; background: var(--sheet); color: var(--ink);
  width: min(540px, calc(100vw - 32px)); box-shadow: var(--lift);
}
dialog[open] { animation: dialog-in .4s var(--ease-out); }
@keyframes dialog-in { from { transform: translateY(16px); } }
@media (prefers-reduced-motion: reduce) { dialog[open] { animation: none; } }
dialog::backdrop { background: rgb(8 10 20 / .62); }
#dialog-form { padding: 0 24px 22px; }
dialog h2 {
  margin: 0 -24px 18px; padding: 18px 24px 14px; font-size: 1.9rem; overflow-wrap: anywhere;
  background: var(--field); color: var(--on-field);
}
.dialog-buttons { display: flex; gap: 8px; justify-content: flex-end; margin-top: 18px; }
.dialog-error { color: var(--danger); min-height: 1.2em; margin: 8px 0 0; font-weight: 600; }
.secret { display: flex; gap: 8px; align-items: stretch; margin: 6px 0 14px; }
.secret code { flex: 1; padding: 9px 10px; background: var(--paper); box-shadow: inset 0 0 0 1px var(--line); overflow-wrap: anywhere; font-size: .9rem; }
.secret button { padding: 6px 14px; font-size: .85rem; }
dialog textarea { resize: vertical; }
dialog.preview, dialog.lightbox { width: min(1400px, calc(100vw - 32px)); background: #0b0c10; color: #eceff6; padding: 16px; }
.preview-head { display: flex; flex-wrap: wrap; gap: 12px; justify-content: space-between; align-items: center; margin-bottom: 14px; }
.preview-head h2 { margin: 0; padding: 0; background: none; color: #eceff6; font-size: 1.7rem; }
.preview-head button.secondary { color: #eceff6; box-shadow: inset 0 0 0 1.5px rgb(236 239 246 / .35); }
.preview-head button.secondary:hover { background: #eceff6; color: #0b0c10; }
#preview-video { width: 100%; max-height: 75vh; background: #000; display: block; }
#lightbox-img { display: block; max-width: 100%; max-height: 78vh; margin: 0 auto; }

@media (max-width: 760px) {
  .topbar { position: static; }
  .list th { position: static; }
  .list thead { display: none; }
  .list tr { display: block; border-bottom: 1px solid var(--line); padding: 8px 0; }
  .list td { display: block; border: 0; padding: 3px 10px; }
  .list .num, .list td.row-actions { text-align: left; }
  .list td.row-actions { white-space: normal; }
  .list td.row-actions button { margin: 4px 4px 0 0; }
}

.card { background: var(--sheet); box-shadow: var(--lift); padding: clamp(22px, 4vw, 34px); }
.narrow { max-width: 480px; }
.card .hint { margin: 12px 0 0; }

#log-rows td:nth-child(1), #log-rows td:nth-child(3), #log-rows td:nth-child(4) { white-space: nowrap; }
#tab-log .toolbar { justify-content: flex-start; align-items: center; }
#log-refresh { margin-left: auto; }

@media (max-width: 760px) {
  .topbar { display: grid; grid-template-columns: 1fr auto; gap: 8px 12px; padding-bottom: 0; }
  .topbar .wordmark { grid-row: 1; }
  .who { grid-row: 1; grid-column: 2; }
  .tabs {
    grid-column: 1 / -1; padding-bottom: 10px;
  }
  .tab { white-space: nowrap; font-size: 1rem; padding: 7px 9px; }
  .gallery { grid-template-columns: repeat(auto-fill, minmax(140px, 1fr)); gap: 8px; }
  .list tr { display: grid; grid-template-columns: 34px 1fr; align-items: center; }
  .list td { grid-column: 1 / -1; }
  .list td.check { grid-column: 1; padding-right: 0; }
  .list td.check + td { grid-column: 2; }
}
