@import url('/theme.css');

*, *::before, *::after { box-sizing: border-box; }
body { margin: 0; min-height: 100vh; background: var(--ink); color: var(--paper); font: 14px/1.55 var(--sans); -webkit-font-smoothing: antialiased; }
a { color: var(--gold); }
button, input, select, textarea { font: inherit; }
button { cursor: pointer; }
button:disabled { opacity: .5; cursor: not-allowed; }
:focus-visible { outline: 2px solid var(--mint); outline-offset: 2px; }
[hidden] { display: none !important; }
h1, h2, h3 { font-family: var(--serif); font-weight: 400; margin: 0; letter-spacing: -.4px; }
h1 { font-size: 30px; line-height: 1.15; }
h2 { font-size: 21px; margin-bottom: 14px; }
h3 { font-size: 17px; margin: 18px 0 8px; }
code { font-family: Consolas, 'Courier New', monospace; font-size: 12px; color: #d9c999; overflow-wrap: anywhere; }
.skip { position: fixed; top: -80px; left: 16px; z-index: 100; padding: 10px 14px; background: var(--gold); color: var(--ink); font-weight: 700; }
.skip:focus { top: 12px; }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
.eyebrow { margin: 0 0 6px; font-size: 10px; letter-spacing: 2.2px; color: var(--gold); font-weight: 700; }
.muted { color: var(--muted); }
.small { font-size: 12px; }
.boot { padding: 40px; color: var(--muted); }
.empty { padding: 14px 0; color: var(--muted); }

/* buttons */
.button { display: inline-flex; align-items: center; justify-content: center; gap: 8px; padding: 9px 15px; border: 1px solid #bca37188; background: none; color: var(--paper);
  font-size: 13px; font-weight: 700; text-decoration: none; white-space: nowrap; }
.button:hover:not(:disabled) { border-color: var(--gold); background: #c8af7714; }
.button.primary { background: var(--gold); border-color: var(--gold); color: #172128; }
.button.primary:hover:not(:disabled) { background: var(--gold-strong); }
.button.danger { background: #8f3b33; border-color: #b9574d; color: #fff3ee; }
.button.danger-ghost { border-color: #b9574d99; color: #f2b3a7; }
.button.small { padding: 5px 10px; font-size: 12px; }
.button.wide { width: 100%; }
.text-link { border: 0; padding: 0; background: none; color: var(--gold); font-size: 12px; text-decoration: underline; text-underline-offset: 3px; }
.icon-button { width: 32px; height: 32px; flex: none; border: 1px solid var(--line-strong); background: none; color: var(--paper); }
.icon-button:hover:not(:disabled) { border-color: var(--gold); }
.icon-button.danger { color: #f2b3a7; }
.actions { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; }

/* login */
.center { display: grid; place-items: center; min-height: 100vh; padding: 20px; }
.login-card { display: flex; flex-direction: column; gap: 12px; width: min(420px, 100%); padding: 34px; border: 1px solid var(--line-strong); background: #16252c; }
.login-card h1 { margin-bottom: 4px; }

/* shell */
.shell { display: grid; grid-template-columns: 236px minmax(0, 1fr); min-height: 100vh; }
.sidebar { position: sticky; top: 0; display: flex; flex-direction: column; gap: 18px; height: 100vh; padding: 22px 16px; border-right: 1px solid var(--line); background: #0d181d; }
.brand { display: block; color: var(--paper); text-decoration: none; font: 16px var(--serif); letter-spacing: 2px; }
.brand span, .brand strong { color: var(--gold); font-weight: 400; }
.brand small { display: block; margin-top: 4px; font: 11px var(--sans); letter-spacing: 1px; color: var(--muted); }
.nav-toggle { display: none; padding: 8px 12px; border: 1px solid var(--line-strong); background: none; color: var(--paper); }
.admin-nav { display: flex; flex-direction: column; gap: 2px; }
.admin-nav a { display: flex; align-items: center; gap: 10px; padding: 9px 10px; color: #cdd5d1; text-decoration: none; border-left: 2px solid transparent; }
.admin-nav a:hover { background: #ffffff08; color: var(--gold); }
.admin-nav a[aria-current="page"] { border-color: var(--gold); background: #d7bc7f14; color: var(--gold); }
.nav-icon { width: 18px; text-align: center; color: var(--gold); }
.account { margin-top: auto; padding-top: 14px; border-top: 1px solid var(--line); }
.account p { margin: 0 0 4px; overflow-wrap: anywhere; }
.account-email { font-size: 13px; }
.account-actions { display: flex; gap: 16px; margin-top: 8px; }
.view { min-width: 0; padding: 28px 34px 60px; }
.view:focus { outline: none; }
.view-header { display: flex; flex-wrap: wrap; align-items: flex-end; justify-content: space-between; gap: 14px; margin-bottom: 18px; }
.view-header .badges { margin-top: 8px; }
.breadcrumb { margin-bottom: 10px; font-size: 12px; color: var(--muted); }
.intro { max-width: 820px; margin: -6px 0 18px; }
.toolbar { display: flex; flex-wrap: wrap; gap: 10px; margin-bottom: 14px; }
.toolbar input[type="search"] { flex: 1 1 260px; }
.segmented { display: inline-flex; border: 1px solid var(--line-strong); }
.segmented button { padding: 8px 14px; border: 0; background: none; color: #cdd5d1; }
.segmented button[aria-pressed="true"] { background: var(--gold); color: var(--ink); }

/* inputs */
input, select, textarea { width: 100%; padding: 8px 10px; border: 1px solid #65716b88; border-radius: 0; background: #0b161b; color: var(--paper); }
input[type="checkbox"] { width: 16px; height: 16px; accent-color: var(--gold); }
input:read-only:not([type="checkbox"]) { color: var(--muted); }
textarea { resize: vertical; }
textarea.code { font-family: Consolas, 'Courier New', monospace; font-size: 12px; line-height: 1.45; tab-size: 2; }
textarea.code.tall { min-height: 460px; }
textarea.invalid, input:user-invalid { border-color: var(--danger); }
.field { display: flex; flex-direction: column; gap: 5px; margin-bottom: 12px; min-width: 0; }
.field > label, .field > .label, p.label { font-size: 12px; color: #c0c9c4; font-weight: 700; margin: 0; }
.hint { margin: 0; font-size: 11px; color: var(--muted); }
.field-error, .form-error { margin: 4px 0 0; min-height: 0; color: var(--danger); font-size: 12px; }
.check { display: inline-flex; align-items: center; gap: 8px; margin: 4px 14px 8px 0; font-size: 13px; color: #d7ddd9; }
.grid { display: grid; gap: 0 16px; }
.grid.two { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.grid.three { grid-template-columns: repeat(3, minmax(0, 1fr)); align-items: end; }
.grid.five { grid-template-columns: repeat(5, minmax(0, 1fr)); }
.grid.announce { grid-template-columns: minmax(0, 2fr) minmax(0, 1fr); }
/* A fieldset is as wide as its content by default: a wide table would push
   the page sideways instead of scrolling inside .table-wrap. */
fieldset { min-width: 0; }
.form-section { margin: 0 0 18px; padding: 16px 18px 6px; border: 1px solid var(--line); background: #0e1a20; }
.form-section > legend { padding: 0 8px; font: 17px var(--serif); color: var(--gold); }
.form-subsection { margin: 10px 0 14px; padding: 12px 14px 4px; border: 1px dashed var(--line-strong); }
.form-subsection > legend { padding: 0 6px; font-size: 12px; font-weight: 700; color: #d7ddd9; }
.rows { display: flex; flex-direction: column; gap: 6px; margin-bottom: 8px; }
.row { display: flex; align-items: center; gap: 8px; }
.row.talk { align-items: flex-start; }
.row.talk select { width: 130px; flex: none; }
.row input[type="time"], .row input[type="date"] { width: auto; }
input.count { width: 96px; flex: none; }
.lookup-wrap { display: flex; flex: 1; flex-direction: column; min-width: 0; }
.lookup-name { min-height: 15px; font-size: 11px; color: var(--mint); }
.weekdays { display: flex; flex-wrap: wrap; }
details.advanced { margin: 6px 0 12px; }
details.advanced summary { cursor: pointer; margin-bottom: 8px; color: var(--gold); font-size: 12px; }

/* cards, stats, tables */
.card { margin-bottom: 18px; padding: 18px 20px; border: 1px solid var(--line); background: #0e1a20; }
.columns { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 18px; }
.stats { display: grid; grid-template-columns: repeat(6, minmax(0, 1fr)); gap: 12px; margin: 0 0 12px; }
.stats.compact { grid-template-columns: repeat(4, minmax(0, 1fr)); margin-bottom: 18px; }
.stat { padding: 14px 16px; border: 1px solid var(--line); background: #0e1a20; }
.stat dt { font-size: 11px; color: var(--gold); letter-spacing: .6px; }
.stat dd { margin: 6px 0 0; font: 26px var(--serif); }
.stat p { margin: 4px 0 0; }
.timeline { margin: 0; padding-left: 18px; }
.timeline li { margin-bottom: 8px; }
.table-wrap { width: 100%; overflow-x: auto; border: 1px solid var(--line); }
table { width: 100%; border-collapse: collapse; font-size: 13px; }
th { position: sticky; top: 0; padding: 9px 10px; background: #13232a; color: var(--gold); font-size: 11px; letter-spacing: .5px; text-align: left; white-space: nowrap; }
td { padding: 8px 10px; border-top: 1px solid var(--line); vertical-align: top; }
tr.clickable { cursor: pointer; }
tr.clickable:hover td, tr.clickable:focus-visible td { background: #d7bc7f0d; }
.row-actions { display: flex; flex-wrap: wrap; gap: 6px; }
.pager { display: flex; align-items: center; justify-content: center; gap: 14px; margin-top: 14px; }
.more-row { display: flex; justify-content: center; margin-top: 14px; }
.facts { display: grid; grid-template-columns: max-content 1fr; gap: 6px 18px; margin: 0 0 14px; }
.facts dt { color: var(--muted); }
.facts dd { margin: 0; }
.item-list { margin: 0; padding: 0; list-style: none; }
.item-list li + li { margin-top: 2px; }
.nowrap { white-space: nowrap; }
.goods-table td { min-width: 90px; }
.goods-table td:nth-child(2) { min-width: 190px; }
.goods-table td:nth-child(5), .goods-table td:nth-child(6) { min-width: 150px; }
.goods-table td:nth-child(8) { min-width: 130px; }
.goods-table input[type="number"] { min-width: 80px; }
.goods-table select { min-width: 130px; }
.goods-table .check { margin-right: 0; white-space: nowrap; }

/* badges and callouts */
.badges { display: inline-flex; flex-wrap: wrap; gap: 5px; }
.badge { display: inline-block; padding: 2px 7px; border: 1px solid currentColor; font-size: 10px; font-weight: 700; letter-spacing: .6px; text-transform: uppercase; white-space: nowrap; }
.badge.original, .badge.muted { color: #9aa8a6; }
.badge.edited, .badge.version { color: var(--gold); }
.badge.created, .badge.ok { color: var(--mint); }
.badge.draft, .badge.draft-only { color: #a9c3e6; }
.badge.warning { color: #f0c27b; }
.badge.danger { color: var(--danger); }
.badge.admin { color: var(--gold); }
.badge.gm { color: var(--mint); }
.badge.support { color: #a9c3e6; }
.callout { margin: 0 0 16px; padding: 10px 14px; border-left: 3px solid var(--gold); background: #d7bc7f10; }
.callout.error { border-color: var(--danger); background: #ef8f7f14; }

/* editor */
.editor { display: grid; grid-template-columns: minmax(0, 1fr) 320px; gap: 20px; align-items: start; }
.editor-side { position: sticky; top: 16px; max-height: calc(100vh - 32px); overflow: auto; padding: 16px; border: 1px solid var(--line); background: #0e1a20; }
.tabs { display: flex; flex-wrap: wrap; gap: 2px; margin-bottom: 14px; border-bottom: 1px solid var(--line); }
.tabs [role="tab"] { padding: 9px 14px; border: 0; border-bottom: 2px solid transparent; background: none; color: #b8c1bc; }
.tabs [role="tab"][aria-selected="true"] { color: var(--gold); border-color: var(--gold); }
.tab-panel:focus { outline: none; }
.issue-title { font: 700 12px var(--sans); margin: 12px 0 6px; }
.issue-title.error, .error-line { color: var(--danger); }
.issue-title.warning { color: #f0c27b; }
.issues { margin: 0; padding-left: 16px; font-size: 12px; }
.issues li { margin-bottom: 6px; }
.ok-line { color: var(--mint); }
.preview-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 14px; }
.preview-grid .card { margin: 0; }
.talk-preview { list-style: none; margin: 10px 0 0; padding: 0; }
.talk-preview li { margin-bottom: 6px; padding: 6px 10px; background: #ffffff07; }
.speaker { font-weight: 700; color: var(--gold); }

/* dialogs and toasts */
dialog.modal { width: min(560px, calc(100vw - 24px)); max-height: 90vh; padding: 24px; border: 1px solid var(--line-strong); background: #16252c; color: var(--paper); }
dialog.modal.wide { width: min(980px, calc(100vw - 24px)); }
dialog.modal::backdrop { background: #050e15cc; }
dialog.modal h2 { margin-bottom: 14px; }
.modal-actions { display: flex; justify-content: flex-end; gap: 10px; margin-top: 16px; }
.json-view { max-height: 60vh; overflow: auto; margin: 0; padding: 12px; background: #0b161b; border: 1px solid var(--line); font: 12px/1.45 Consolas, 'Courier New', monospace; white-space: pre-wrap; overflow-wrap: anywhere; }
.compare { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 12px; }
.toasts { position: fixed; right: 16px; bottom: 16px; z-index: 200; display: flex; flex-direction: column; gap: 8px; max-width: min(380px, calc(100vw - 32px)); }
.toast { padding: 10px 14px; border-left: 3px solid var(--gold); background: #1d313a; box-shadow: 0 10px 30px #0008; transition: opacity .4s, transform .4s; }
.toast.success { border-color: var(--mint); }
.toast.warning { border-color: #f0c27b; }
.toast.error { border-color: var(--danger); }
.toast.leaving { opacity: 0; transform: translateY(8px); }

/* responsive */
@media (max-width: 1200px) {
  .stats { grid-template-columns: repeat(3, minmax(0, 1fr)); }
  .stats.compact { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .editor { grid-template-columns: minmax(0, 1fr); }
  .editor-side { position: static; max-height: none; }
  .grid.five { grid-template-columns: repeat(3, minmax(0, 1fr)); }
}
@media (max-width: 960px) {
  .shell { grid-template-columns: minmax(0, 1fr); }
  .sidebar { position: sticky; z-index: 10; flex-flow: row wrap; align-items: center; height: auto; padding: 12px 16px; border-right: 0; border-bottom: 1px solid var(--line); }
  .nav-toggle { display: block; margin-left: auto; }
  .admin-nav { display: none; flex-basis: 100%; }
  .admin-nav.open { display: flex; }
  .account { display: none; }
  .admin-nav.open ~ .account { display: block; flex-basis: 100%; margin-top: 0; }
  .view { padding: 20px 16px 50px; }
  .columns, .preview-grid, .compare { grid-template-columns: minmax(0, 1fr); }
}
@media (max-width: 640px) {
  h1 { font-size: 24px; }
  .stats, .stats.compact, .grid.two, .grid.three, .grid.five, .grid.announce { grid-template-columns: minmax(0, 1fr); }
  .row.talk { flex-wrap: wrap; }
  .row.talk select { width: 100%; }
  .view-header .actions { width: 100%; }
}
@media (prefers-reduced-motion: reduce) {
  * { transition: none !important; }
}
