/* Card Studio. Same fog / fir / Sound palette as the cards; system UI font for forms. */

/* @font-face rules come from /fonts.css, generated from static/fonts/fonts.json */

:root {
  --bg: #EDF2EF;
  --surface: #FFFFFF;
  --sunken: #E2E9E5;
  --line: #CFDAD4;
  --ink: #1B342E;
  --muted: #55685F;
  --accent: #246784;
  --accent-hover: #1C5269;
  --on-accent: #FFFFFF;
  --live: #23663F;
  --live-bg: #D9EEE0;
  --warn: #7E4D00;
  --warn-bg: #FAEBCB;
  --danger: #A2271D;
  --danger-bg: #F7DEDA;
  --secret-bg: #E4EEF5;
  --shadow: 0 1px 2px rgb(27 52 46 / 0.08), 0 6px 20px -12px rgb(27 52 46 / 0.35);
  --display: "Lora", Georgia, serif;
  --ui: system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", sans-serif;
  --mono: ui-monospace, "SF Mono", Menlo, Consolas, monospace;
  --radius: 8px;
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #101A17; --surface: #17241F; --sunken: #0C1412; --line: #2B3D36; --ink: #E3ECE7; --muted: #9DB2A9;
    --accent: #7FBCD6; --accent-hover: #A4D2E6; --on-accent: #0D1A16; --live: #8CD3A6; --live-bg: #1C3A2A;
    --warn: #F0C46F; --warn-bg: #3A2C0F; --danger: #F1A097; --danger-bg: #43201C; --secret-bg: #1C2F3A;
    --shadow: 0 1px 2px rgb(0 0 0 / 0.4), 0 8px 24px -12px rgb(0 0 0 / 0.8);
    color-scheme: dark;
  }
}
:root[data-theme="dark"] {
  --bg: #101A17; --surface: #17241F; --sunken: #0C1412; --line: #2B3D36; --ink: #E3ECE7; --muted: #9DB2A9;
  --accent: #7FBCD6; --accent-hover: #A4D2E6; --on-accent: #0D1A16; --live: #8CD3A6; --live-bg: #1C3A2A;
  --warn: #F0C46F; --warn-bg: #3A2C0F; --danger: #F1A097; --danger-bg: #43201C; --secret-bg: #1C2F3A;
  --shadow: 0 1px 2px rgb(0 0 0 / 0.4), 0 8px 24px -12px rgb(0 0 0 / 0.8);
  color-scheme: dark;
}

* , *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body { margin: 0; background: var(--bg); color: var(--ink); font: 15px/1.5 var(--ui); }
img { max-width: 100%; height: auto; }
a { color: var(--accent); text-underline-offset: 0.15em; }
a:hover { color: var(--accent-hover); }
:focus-visible { outline: 3px solid var(--accent); outline-offset: 2px; border-radius: 3px; }
h1, h2, h3 { font-family: var(--display); font-weight: 500; line-height: 1.2; text-wrap: balance; margin: 0; }
h1 { font-size: 1.75rem; }
h2 { font-size: 1.25rem; }
h3 { font-size: 1.05rem; }
p { margin: 0; }
.muted { color: var(--muted); }
.small { font-size: 0.8125rem; }
.wrap { width: min(100% - 2rem, 72rem); margin-inline: auto; }

/* ---- top bar ---- */
.top { background: var(--surface); border-bottom: 1px solid var(--line); padding-top: env(safe-area-inset-top, 0px); }
.top .wrap { display: flex; align-items: center; gap: 1rem 1.5rem; flex-wrap: wrap; min-height: 3.5rem; padding-block: 0.4rem; }
.brand { font-family: var(--display); font-size: 1.15rem; color: var(--ink); text-decoration: none; margin-right: auto; }
.brand span { display: block; font-family: var(--ui); font-size: 0.75rem; color: var(--muted); margin-top: -0.1rem; }
.nav { display: flex; gap: 0.25rem 1rem; flex-wrap: wrap; align-items: center; }
.nav a { color: var(--ink); text-decoration: none; padding: 0.35rem 0.1rem; border-bottom: 2px solid transparent; }
.nav a[aria-current="page"] { border-bottom-color: var(--accent); }
.nav a:hover { color: var(--accent); }
.nav form { display: inline; }
.linkish { background: none; border: 0; padding: 0.35rem 0.1rem; color: var(--muted); font: inherit; cursor: pointer; }
.linkish:hover { color: var(--accent); text-decoration: underline; }

main.wrap { padding-block: 1.75rem 4rem; }
.page-head { display: flex; align-items: flex-end; justify-content: space-between; gap: 1rem; flex-wrap: wrap; margin-bottom: 1.25rem; }
.page-head p { margin-top: 0.25rem; }

/* ---- flash messages ---- */
.flashes { display: grid; gap: 0.5rem; margin-bottom: 1.25rem; }
.flash { padding: 0.7rem 0.9rem; border-radius: var(--radius); background: var(--sunken); }
.flash.ok { background: var(--live-bg); color: var(--live); }
.flash.error { background: var(--danger-bg); color: var(--danger); }
.flash.info { background: var(--warn-bg); color: var(--warn); }
.flash.secret { background: var(--secret-bg); color: var(--ink); font-weight: 600; user-select: all; }

/* ---- buttons ---- */
.btn { display: inline-flex; align-items: center; justify-content: center; gap: 0.4rem; min-height: 2.5rem;
  padding: 0.45rem 0.95rem; border-radius: var(--radius); border: 1px solid var(--line); background: var(--surface);
  color: var(--ink); font: 500 0.9375rem/1.2 var(--ui); text-decoration: none; cursor: pointer; white-space: nowrap; }
.btn:hover { border-color: var(--accent); color: var(--accent); }
.btn.primary { background: var(--accent); border-color: var(--accent); color: var(--on-accent); }
.btn.primary:hover { background: var(--accent-hover); border-color: var(--accent-hover); color: var(--on-accent); }
.btn.live { background: var(--live); border-color: var(--live); color: var(--surface); }
.btn.danger { color: var(--danger); }
.btn.danger:hover { border-color: var(--danger); color: var(--danger); }
.btn.quiet { border-color: transparent; background: none; }
.btn.small { min-height: 2rem; padding: 0.25rem 0.6rem; font-size: 0.8125rem; }
.btn[aria-busy="true"] { opacity: 0.6; pointer-events: none; }
.btn-row { display: flex; flex-wrap: wrap; gap: 0.5rem; align-items: center; }

/* ---- status chips ---- */
.chip { display: inline-flex; align-items: center; gap: 0.35rem; padding: 0.15rem 0.55rem; border-radius: 999px;
  font-size: 0.75rem; font-weight: 600; background: var(--sunken); color: var(--muted); white-space: nowrap; }
.chip::before { content: ""; width: 0.45rem; height: 0.45rem; border-radius: 50%; background: currentColor; }
.chip.live { background: var(--live-bg); color: var(--live); }
.chip.pending { background: var(--warn-bg); color: var(--warn); }
.chip.problem { background: var(--danger-bg); color: var(--danger); }

/* ---- panels ---- */
.panel { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 1.1rem 1.2rem; }
.panel + .panel { margin-top: 1rem; }
.panel > h2, .panel > h3 { margin-bottom: 0.75rem; }
.panel > form { margin-top: 0.75rem; }

/* ---- cards list ---- */
.layout { display: grid; gap: 1.5rem; grid-template-columns: minmax(0, 1fr); }
@media (min-width: 60rem) { .layout { grid-template-columns: minmax(0, 1fr) 19rem; align-items: start; } }
.month { margin-top: 1.5rem; }
.month:first-child { margin-top: 0; }
.month > h2 { font-size: 1rem; color: var(--muted); font-family: var(--ui); font-weight: 600; margin-bottom: 0.5rem; }
.rows { list-style: none; margin: 0; padding: 0; background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); }
.row { display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: 0.35rem 1rem; padding: 0.85rem 1rem; align-items: center; }
.row + .row { border-top: 1px solid var(--line); }
.row-name { font-family: var(--display); font-size: 1.05rem; color: var(--ink); text-decoration: none; }
.row-name:hover { color: var(--accent); text-decoration: underline; }
.row-meta { display: flex; flex-wrap: wrap; gap: 0.25rem 0.75rem; align-items: center; font-size: 0.8125rem; color: var(--muted); }
.row-actions { display: flex; gap: 0.35rem; flex-wrap: wrap; justify-content: flex-end; }
@media (max-width: 34rem) { .row { grid-template-columns: 1fr; } .row-actions { justify-content: flex-start; } }
.filters { display: flex; gap: 0.25rem; margin-bottom: 1rem; }
.filters a { padding: 0.3rem 0.7rem; border-radius: 999px; text-decoration: none; color: var(--muted); font-size: 0.875rem; }
.filters a[aria-current="true"] { background: var(--surface); color: var(--ink); box-shadow: var(--shadow); }
.empty { padding: 2.5rem 1.5rem; text-align: center; background: var(--surface); border: 1px dashed var(--line); border-radius: var(--radius); }
.empty p + p { margin-top: 0.5rem; }

.feed { list-style: none; margin: 0; padding: 0; display: grid; gap: 0.6rem; font-size: 0.8125rem; }
.feed li { line-height: 1.35; }
.feed .who { font-weight: 600; }

/* ---- forms ---- */
.form-grid { display: grid; gap: 1rem; }
@media (min-width: 40rem) { .form-grid.two { grid-template-columns: 1fr 1fr; } }
.field { display: grid; gap: 0.3rem; min-width: 0; }
.field > label, .field > .label { font-weight: 600; font-size: 0.875rem; }
.hint { font-size: 0.8125rem; color: var(--muted); }
input[type=text], input[type=email], input[type=tel], input[type=password], input[type=number], input[type=month], select, textarea {
  width: 100%; min-height: 2.5rem; padding: 0.5rem 0.65rem; border: 1px solid var(--line); border-radius: 6px;
  background: var(--surface); color: var(--ink); font: 0.9375rem/1.4 var(--ui); }
textarea { min-height: 6rem; resize: vertical; }
input:focus, select:focus, textarea:focus { outline: 2px solid var(--accent); outline-offset: 0; border-color: var(--accent); }
input[type=range] { width: 100%; accent-color: var(--accent); }
input[type=file] { font: inherit; max-width: 100%; }
.check { display: flex; gap: 0.5rem; align-items: flex-start; font-size: 0.9rem; }
.check input { margin-top: 0.2rem; accent-color: var(--accent); }
fieldset { border: 0; padding: 0; margin: 0; min-width: 0; }
legend { padding: 0; }
.radios { display: flex; gap: 0.5rem 1.25rem; flex-wrap: wrap; }
.req::after { content: " *"; color: var(--danger); }

/* ---- editor ---- */
.editor { display: grid; gap: 1.25rem; grid-template-columns: minmax(0, 1fr); }
@media (min-width: 64rem) { .editor { grid-template-columns: minmax(0, 1fr) 20rem; align-items: start; }
  .side { position: sticky; top: 1rem; } }
.section { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 1.2rem; }
.section + .section { margin-top: 1.25rem; }
.section > h2 { margin-bottom: 0.35rem; }
.section > .hint:first-of-type { margin-bottom: 1rem; }
.problems { background: var(--danger-bg); color: var(--danger); border-radius: var(--radius); padding: 0.8rem 1rem; margin-bottom: 1.25rem; }
.problems ul { margin: 0.35rem 0 0; padding-left: 1.2rem; }

.notes-list { display: grid; gap: 0.75rem; }
.note-row { display: grid; gap: 0.5rem; padding: 0.8rem; border: 1px solid var(--line); border-radius: var(--radius); background: var(--bg); }
.note-row .note-top { display: flex; gap: 0.5rem; flex-wrap: wrap; align-items: center; }
.note-row .note-top select { width: auto; flex: 1 1 12rem; }
.note-row .note-top .color { flex: 0 1 9rem; }
.note-row .tools { display: flex; gap: 0.25rem; margin-left: auto; }
.swatch { display: inline-block; width: 0.8rem; height: 0.8rem; border-radius: 3px; vertical-align: -1px; }

.image-box { display: grid; gap: 1rem; }
@media (min-width: 40rem) { .image-box { grid-template-columns: 12rem minmax(0, 1fr); } }
.thumb { background: var(--sunken); border-radius: 6px; aspect-ratio: 3 / 2; display: grid; place-items: center;
  overflow: hidden; color: var(--muted); font-size: 0.8125rem; text-align: center; padding: 0.5rem; }
.thumb img { width: 100%; height: 100%; object-fit: cover; }
.sliders { display: grid; gap: 0.9rem; margin-top: 1rem; }
@media (min-width: 40rem) { .sliders { grid-template-columns: repeat(3, 1fr); } }
.slider-head { display: flex; justify-content: space-between; font-size: 0.875rem; font-weight: 600; }
.slider-head output { font-weight: 400; color: var(--muted); font-variant-numeric: tabular-nums; }
.seed-row { display: flex; gap: 0.5rem; align-items: end; flex-wrap: wrap; margin-top: 0.9rem; }
.seed-row .field { flex: 0 1 9rem; }

.side .panel h3 { margin-bottom: 0.5rem; }
.side .btn { width: 100%; }
.side .stack { display: grid; gap: 0.5rem; }
.link-box { display: flex; gap: 0.35rem; align-items: center; margin-top: 0.5rem; }
.link-box code { flex: 1; min-width: 0; overflow-wrap: anywhere; font: 0.8125rem/1.35 var(--mono); background: var(--sunken);
  padding: 0.4rem 0.5rem; border-radius: 6px; }
.painting-thumb { margin-top: 0.75rem; border-radius: 6px; overflow: hidden; background: var(--sunken); }
.painting-thumb img { display: block; }
.history { list-style: none; margin: 0; padding: 0; display: grid; gap: 0.4rem; font-size: 0.8125rem; }
.danger-zone { margin-top: 1rem; display: grid; gap: 0.5rem; }

/* ---- job log ---- */
.job-status { display: flex; align-items: center; gap: 0.6rem; margin: 0.5rem 0 1rem; font-weight: 600; }
.spinner { width: 1rem; height: 1rem; border-radius: 50%; border: 2px solid var(--line); border-top-color: var(--accent);
  animation: spin 0.8s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }
@media (prefers-reduced-motion: reduce) { .spinner { animation: none; border-top-color: var(--line); } }
.log { background: #0E1916; color: #D6E3DD; font: 0.8125rem/1.55 var(--mono); padding: 1rem; border-radius: var(--radius);
  max-height: 60vh; overflow: auto; white-space: pre-wrap; overflow-wrap: anywhere; margin: 0; }
.log .t-FAIL, .log .t-STOP { color: #FF9C8F; }
.log .t-WARN, .log .t-WAIT { color: #F2C66D; }
.log .t-OK, .log .t-LIVE, .log .t-DONE { color: #8FDDA9; }
.log .t-PAINT { color: #9CCBE8; }
.log .t-JOB { color: #8DA39A; }
.next-steps { margin-top: 1.25rem; }

/* ---- preview ---- */
.preview-bar { display: flex; flex-wrap: wrap; gap: 0.75rem; align-items: center; justify-content: space-between; margin-bottom: 1rem; }
.seg { display: inline-flex; border: 1px solid var(--line); border-radius: var(--radius); overflow: hidden; }
.seg button { border: 0; background: var(--surface); padding: 0.45rem 0.9rem; font: inherit; color: var(--ink); cursor: pointer; }
.seg button[aria-pressed="true"] { background: var(--accent); color: var(--on-accent); }
.frame-wrap { display: flex; justify-content: center; background: var(--sunken); border-radius: var(--radius); padding: 1rem 0; }
.frame-wrap iframe { width: 100%; height: 80vh; border: 0; background: #E4EBE7; border-radius: 4px; box-shadow: var(--shadow); }
.frame-wrap.phone iframe { width: 390px; max-width: 100%; height: 780px; border-radius: 22px; }

/* ---- signers & photos ---- */
.grid-list { display: grid; gap: 1rem; grid-template-columns: repeat(auto-fill, minmax(15rem, 1fr)); }
.signer { display: grid; gap: 0.4rem; }
.signer .sample { font-size: 1.5rem; line-height: 1.2; padding: 0.5rem 0.7rem; background: #F2E7A8; color: #23302C; border-radius: 3px; }
.hand-kalam { font-family: "Kalam", cursive; }
.hand-patrick { font-family: "Patrick Hand", cursive; }
.hand-caveat { font-family: "Caveat", cursive; font-size: 1.15em; }
.hand-nanum { font-family: "Nanum Pen Script", cursive; font-size: 1.25em; }
.photo-row { display: grid; gap: 0.75rem; padding: 0.9rem; border: 1px solid var(--line); border-radius: var(--radius); background: var(--surface); }
@media (min-width: 44rem) { .photo-row { grid-template-columns: 10rem minmax(0, 1fr) auto; align-items: start; } }
.photo-row .tools { display: flex; gap: 0.25rem; flex-wrap: wrap; }
.photo-list { display: grid; gap: 0.75rem; }

table.users { width: 100%; border-collapse: collapse; background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); overflow: hidden; }
.users th, .users td { text-align: left; padding: 0.65rem 0.8rem; border-bottom: 1px solid var(--line); vertical-align: middle; }
.users th { font-size: 0.8125rem; color: var(--muted); font-weight: 600; }
.table-wrap { overflow-x: auto; position: relative; }   /* keeps .sr-only labels inside the scroll box */

.login { min-height: 100vh; display: grid; place-items: center; padding: 1.5rem 1rem; }
.login .panel { width: min(100%, 24rem); padding: 1.75rem; box-shadow: var(--shadow); }
.login h1 { margin-bottom: 0.25rem; }

.narrow { max-width: 32rem; }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
.mt { margin-top: 1rem; }
.sample { display: block; font-size: 1.35rem; line-height: 1.2; padding: 0.5rem 0.7rem; background: #F2E7A8; color: #23302C; border-radius: 3px; }
.avatar-lg { width: 5rem; height: 5rem; border-radius: 50%; object-fit: cover; }
.form-grid + .form-grid { margin-top: 1rem; }
details.field { margin-top: 1rem; }
details.field > summary { cursor: pointer; }
.side .link-box { flex-direction: column; align-items: stretch; }
.side .link-box .btn { width: 100%; }
.side textarea { min-height: 9rem; font-size: 0.875rem; }
