:root { --warn: #8a5a00; --warn-bg: #fdf4dc; --err-bg: #fbe9e7; --mono: ui-monospace, 'SF Mono', Menlo, Consolas, monospace; }
* { box-sizing: border-box; }
body { margin: 0; background: var(--canvas); color: var(--ink); font: 15px/1.5 var(--font); -webkit-font-smoothing: antialiased; }
button, input, textarea { font: inherit; color: inherit; }
a { color: var(--brand-text); }
[hidden] { display: none !important; }

.top { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 12px 24px; background: var(--nav); color: #fff; }
.brand { color: #fff; text-decoration: none; display: flex; align-items: baseline; gap: 8px; }
.brand b { font-size: 18px; letter-spacing: -.01em; }
.brand span { color: #f0b48f; }
.top nav { display: flex; align-items: center; gap: 18px; font-size: 14px; min-width: 0; }
.top nav a { color: #d6dadd; text-decoration: none; }
.top nav a:hover { color: #fff; }
.account { min-width: 32px; display: inline-flex; }

.intro { max-width: 1180px; margin: 22px auto 0; padding: 0 20px; }
.intro h1 { font-size: 28px; line-height: 1.15; margin: 0 0 6px; letter-spacing: -.015em; }
.intro p { margin: 0; color: var(--muted); max-width: 720px; }

.layout { max-width: 1180px; margin: 18px auto; padding: 0 20px; display: grid; grid-template-columns: minmax(0, 1fr) 400px; gap: 18px; align-items: start; }
.block { background: var(--surface); border: 1px solid var(--line); border-radius: 12px; padding: 16px 18px; margin-bottom: 14px; }
.block-head { display: flex; align-items: center; justify-content: space-between; gap: 10px; margin-bottom: 10px; flex-wrap: wrap; }
.block h2 { font-size: 17px; margin: 0; letter-spacing: -.005em; }
.tools { display: flex; gap: 6px; flex-wrap: wrap; }
.hint { color: var(--muted); font-size: 13px; margin: 8px 0 0; }
.side { position: sticky; top: 14px; }

.choices { display: flex; flex-wrap: wrap; gap: 6px; }
.choices button { padding: 8px 12px; border: 1px solid var(--line); background: #fff; border-radius: 8px; cursor: pointer; font-variant-numeric: tabular-nums; transition: border-color .12s, background-color .12s; }
.choices button:hover { border-color: #b8bec4; }
.choices button[aria-pressed="true"] { border-color: var(--brand); background: var(--brand-soft); color: var(--brand-text); font-weight: 600; }

.table-wrap { overflow-x: auto; margin: 0 -4px; }
.schedule { width: 100%; border-collapse: collapse; font-size: 14px; font-variant-numeric: tabular-nums; }
.schedule th { text-align: left; font-weight: 600; color: var(--muted); font-size: 12px; padding: 6px 8px; border-bottom: 1px solid var(--line); white-space: nowrap; }
.schedule td { padding: 9px 8px; border-bottom: 1px solid var(--line); white-space: nowrap; }
.schedule .num { text-align: right; }
.schedule tbody tr { cursor: pointer; }
.schedule tbody tr:hover { background: #fafafa; }
.schedule tr.sel { background: var(--brand-soft) !important; box-shadow: inset 3px 0 0 var(--brand); }
.schedule tr.bad td:first-child b { color: var(--danger); }
.schedule tr.warn td:first-child b { color: var(--warn); }
.add { margin-top: 10px; width: 100%; }

.editor label, .dlg label { display: flex; flex-direction: column; gap: 4px; font-size: 13px; color: var(--muted); font-weight: 500; }
.editor label.inline { flex-direction: row; align-items: center; gap: 8px; margin-top: 8px; }
.editor label.inline input { width: 90px; }
.grid2 { display: grid; grid-template-columns: 1fr 1fr; gap: 10px 14px; margin: 10px 0; }
.span2 { grid-column: 1 / -1; }
.field { margin: 14px 0; }
.label { display: block; font-weight: 600; font-size: 13px; margin-bottom: 6px; }
input, textarea { padding: 8px 10px; border: 1px solid var(--line); border-radius: 8px; background: #fff; width: 100%; }
input:not([type]), input[inputmode] { font-family: var(--mono); font-variant-numeric: tabular-nums; }
input:focus, textarea:focus, button:focus-visible { outline: 2px solid var(--brand-soft); outline-offset: 1px; border-color: var(--brand); }
.stepper { display: grid; grid-template-columns: 40px 1fr 40px; border: 1px solid var(--line); border-radius: 8px; overflow: hidden; }
.stepper button { border: 0; background: var(--canvas); font-size: 18px; cursor: pointer; }
.stepper input { border: 0; border-radius: 0; text-align: center; min-width: 0; }
.run { font-size: 14px; margin: 4px 0; }
.run summary { cursor: pointer; color: var(--brand-text); }
.run-row { display: flex; flex-wrap: wrap; align-items: end; gap: 10px; margin-top: 8px; }
.run-row label { flex-direction: row !important; align-items: center; }
.run-row input { width: 80px; }

.primary, .ghost { display: inline-flex; align-items: center; justify-content: center; padding: 10px 16px; border-radius: 8px; cursor: pointer; text-decoration: none; font-weight: 600; font-size: 14px; transition: transform .1s, background-color .12s, border-color .12s; }
.primary { background: var(--brand); color: #fff; border: 1px solid var(--brand); }
.primary:hover { background: #c95d27; }
.ghost { background: #fff; border: 1px solid var(--line); color: var(--ink); }
.ghost:hover { border-color: #b8bec4; }
.small { padding: 6px 10px; font-size: 13px; }
.danger { color: var(--danger); }
button:active:not(:disabled) { transform: scale(.98); }
button:disabled { opacity: .5; cursor: not-allowed; }

.preview { padding: 12px; }
#card { width: 100%; height: auto; max-height: 300px; display: block; background: #f7f6f2; border-radius: 8px; }
#card .board { fill: #e3ddd0; stroke: #3b3b3b; }
#card .conduit { fill: #f7f6f2; stroke: var(--brand); }
#card .tie { fill: #f7f6f2; stroke: #3b3b3b; }
#card .dim { stroke: #8a9096; }
#card text { fill: var(--muted); font-family: var(--mono); }
#card .engrave { fill: #8c7f66; font-weight: 700; }
.caption { font-size: 13px; color: var(--muted); margin: 8px 2px 0; }

.total { display: flex; flex-direction: column; }
.total b { font: 700 30px/1.1 var(--mono); font-variant-numeric: tabular-nums; letter-spacing: -.02em; transition: opacity .15s; }
.total b.busy { opacity: .45; }
.total span { color: var(--muted); font-size: 13px; margin-top: 4px; }
.facts { display: grid; grid-template-columns: repeat(4, 1fr); gap: 6px; margin: 12px 0 0; }
.facts div { border: 1px solid var(--line); border-radius: 8px; padding: 7px 9px; min-width: 0; }
.facts dt { font-size: 11px; color: var(--muted); }
.facts dd { margin: 0; font: 600 14px/1.3 var(--mono); font-variant-numeric: tabular-nums; }
.messages p { margin: 8px 0 0; padding: 8px 10px; border-radius: 8px; font-size: 13px; }
.err { background: var(--err-bg); color: var(--danger); }
.warn { background: var(--warn-bg); color: var(--warn); }
.actions { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; margin-top: 14px; }
.actions .primary { grid-column: 1 / -1; padding: 12px; font-size: 15px; }
.fine { font-size: 12px; color: var(--muted); margin: 12px 0 0; }
.error { color: var(--danger); font-size: 13px; margin: 8px 0 0; min-height: 0; }
.error:empty { display: none; }

.how { max-width: 1180px; margin: 10px auto 0; padding: 0 20px; }
.how h2 { font-size: 20px; margin: 18px 0 8px; }
.how ol { padding-left: 20px; max-width: 760px; }
.how li { margin: 6px 0; }
.how .hint { max-width: 760px; font-size: 14px; }
.foot { text-align: center; color: var(--muted); font-size: 13px; padding: 26px 0 36px; }

.dlg { border: 1px solid var(--line); border-radius: 14px; padding: 20px 22px; max-width: 620px; width: calc(100% - 24px); color: var(--ink); }
.dlg::backdrop { background: rgba(20, 22, 24, .45); }
.dlg h2 { margin: 0 0 6px; font-size: 19px; }
.dlg textarea { font-family: var(--mono); font-size: 13px; }
.dlg form > label { margin: 10px 0; }
.dlg-actions { display: flex; justify-content: flex-end; gap: 8px; margin-top: 14px; flex-wrap: wrap; }

@media (max-width: 900px) {
  .layout { grid-template-columns: minmax(0, 1fr); }
  .side { position: static; order: -1; }
  .preview #card { max-height: 200px; }
  .top nav a:not(:last-of-type) { display: none; }
}
@media (max-width: 520px) {
  .grid2 { grid-template-columns: 1fr; }
  .facts { grid-template-columns: repeat(2, 1fr); }
  .intro h1 { font-size: 24px; }
  .top { padding: 12px 16px; }
}
