/* Photo Blender — one stylesheet, two themes.
 *
 * The theme is chosen by theme.js before first paint and lives on <html data-theme>, so every
 * colour below is a variable resolved once at the root. Nothing here depends on JavaScript
 * having run: the page is fully styled and readable with scripts blocked. */

:root {
  --ink: #241c33;
  --ink-soft: #574a6e;
  --ink-faint: #7d7292;
  --bg: #fbf7fd;
  --surface: #ffffff;
  --surface-2: #f4eef9;
  --line: #e2d8ee;
  --line-strong: #cfc0e3;
  --accent: #6d3ea8;
  --accent-ink: #ffffff;
  --accent-soft: #f0e6fb;
  --rose: #c2417a;
  --rose-soft: #fce7f0;
  --warn: #9a5b13;
  --warn-soft: #fdf0dc;
  --ok: #1f6f4a;
  --ok-soft: #e2f4ea;
  --danger: #a52a35;
  --danger-soft: #fce8ea;
  --radius: 12px;
  --radius-sm: 8px;
  --shadow: 0 1px 2px rgba(36, 28, 51, .06), 0 8px 24px rgba(36, 28, 51, .06);
  --mono: ui-monospace, SFMono-Regular, "SF Mono", Menlo, Consolas, monospace;
}

:root[data-theme="dark"] {
  --ink: #ece7f5;
  --ink-soft: #b6acc9;
  --ink-faint: #8e84a3;
  --bg: #16121f;
  --surface: #1e1930;
  --surface-2: #262038;
  --line: #322a48;
  --line-strong: #453a60;
  --accent: #b58cf0;
  --accent-ink: #1a1428;
  --accent-soft: #2a2141;
  --rose: #f0a0c4;
  --rose-soft: #3a2334;
  --warn: #e8b874;
  --warn-soft: #3a2c18;
  --ok: #7fd3a8;
  --ok-soft: #17301f;
  --danger: #f39aa4;
  --danger-soft: #3a1c20;
  --shadow: 0 1px 2px rgba(0, 0, 0, .3), 0 10px 28px rgba(0, 0, 0, .32);
}

* { box-sizing: border-box; }

body {
  margin: 0;
  padding: 0 20px 72px;
  background: var(--bg);
  color: var(--ink);
  font: 15px/1.55 -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  -webkit-font-smoothing: antialiased;
}

.hidden { display: none !important; }
.mono { font-family: var(--mono); font-size: 12.5px; }
.muted { color: var(--ink-faint); }
.small { font-size: 13px; }
.anchor { height: 1px; }

/* --- header ---------------------------------------------------------------------------- */

header {
  max-width: 1120px;
  margin: 0 auto;
  padding: 22px 0 14px;
  display: flex;
  gap: 18px;
  align-items: flex-start;
  justify-content: space-between;
  flex-wrap: wrap;
}

.brand { display: flex; gap: 12px; align-items: center; }
.brand .mark { width: 36px; height: 36px; color: var(--accent); flex: none; }
.brand h1 { margin: 0; font-size: 21px; letter-spacing: -.01em; }
.tagline { margin: 2px 0 0; color: var(--ink-faint); font-size: 13px; }

.session { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }

.home-link {
  display: inline-flex; align-items: center; gap: 5px;
  color: var(--ink-soft); text-decoration: none; font-size: 13px;
  padding: 6px 10px; border-radius: var(--radius-sm);
}
.home-link svg { width: 14px; height: 14px; }
.home-link:hover { background: var(--surface-2); color: var(--ink); }

button { font: inherit; }

.ghost {
  background: var(--surface);
  color: var(--ink-soft);
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  padding: 6px 12px;
  cursor: pointer;
}
.ghost:hover { border-color: var(--line-strong); color: var(--ink); }
.ghost:disabled { opacity: .5; cursor: not-allowed; }
.ghost.danger { color: var(--danger); }

.small-btn { padding: 4px 10px; font-size: 13px; }

.primary {
  background: var(--accent);
  color: var(--accent-ink);
  border: 1px solid var(--accent);
  border-radius: var(--radius-sm);
  padding: 9px 18px;
  font-weight: 600;
  cursor: pointer;
}
.primary:hover { filter: brightness(1.06); }
.primary:disabled { opacity: .45; cursor: not-allowed; filter: none; }

.credits {
  background: var(--surface-2);
  border: 1px solid var(--line);
  border-radius: 999px;
  padding: 4px 11px;
}
.topup { color: var(--accent); text-decoration: none; font-size: 13px; font-weight: 600; }
.topup:hover { text-decoration: underline; }



/* --- layout ---------------------------------------------------------------------------- */

main { max-width: 1120px; margin: 0 auto; }


form { display: block; }

section.doc-field, section.brief-field, .row, .run-row, .run-gate,
.progress, .result { margin-bottom: 18px; }

.label-row {
  display: flex; align-items: baseline; justify-content: space-between;
  gap: 12px; margin-bottom: 6px;
}
.klabel {
  font-size: 12px; font-weight: 700; letter-spacing: .06em;
  text-transform: uppercase; color: var(--ink-soft);
}
.prescan { color: var(--ink-faint); }

label { display: block; font-size: 13px; color: var(--ink-soft); margin-bottom: 4px; }

textarea, input[type="text"], input[type="search"], select {
  width: 100%;
  font: inherit;
  color: var(--ink);
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  padding: 9px 11px;
}
textarea { resize: vertical; min-height: 72px; line-height: 1.5; }
textarea:focus, input:focus, select:focus {
  outline: 2px solid var(--accent);
  outline-offset: 1px;
  border-color: var(--accent);
}

.card {
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--surface);
  padding: 10px;
  box-shadow: var(--shadow);
}
.card textarea { border: none; padding: 2px; box-shadow: none; background: transparent; }
.card textarea:focus { outline: none; }
.card.drop-on { border-color: var(--accent); background: var(--accent-soft); }
.doc-status { font-size: 12.5px; color: var(--ink-faint); min-height: 16px; padding: 0 2px; }

.row.three { display: grid; grid-template-columns: repeat(3, 1fr); gap: 14px; }
.hint { margin: 5px 0 0; font-size: 12.5px; color: var(--ink-faint); }

/* --- the guard panel -------------------------------------------------------------------- */

.guard {
  margin-top: 12px;
  border: 1px solid var(--danger);
  border-left-width: 4px;
  background: var(--danger-soft);
  border-radius: var(--radius);
  padding: 12px 14px;
}
.guard h3 { margin: 0 0 6px; font-size: 15px; color: var(--danger); }
.guard p { margin: 0 0 8px; }
.guard-list { margin: 0 0 8px; padding-left: 20px; }
.guard-list li { margin-bottom: 3px; font-size: 13.5px; }
.guard-foot { margin: 0; font-size: 12.5px; color: var(--ink-faint); }

/* --- the attribute form ------------------------------------------------------------------ */


/* --- shared chrome carried over: modal, history, status, footer --- */

/* --- history overlay ---------------------------------------------------------------------- */

.overlay {
  position: fixed; inset: 0; z-index: 40;
  background: rgba(20, 14, 30, .5);
  display: flex; align-items: flex-start; justify-content: center;
  padding: 40px 16px;
  overflow: auto;
}
.modal {
  width: min(760px, 100%);
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 16px 18px 18px;
}
.modal-head { display: flex; justify-content: space-between; gap: 12px; align-items: flex-start; }
.modal-head-acts { display: flex; gap: 8px; }
.hist-count { color: var(--ink-faint); margin-left: 8px; }
.hist-sync { font-size: 12.5px; color: var(--ink-faint); margin-top: 3px; }
.hist-search { display: flex; gap: 8px; margin: 12px 0; flex-wrap: wrap; }
.hist-search input { flex: 1 1 260px; }
.hist-list { display: grid; gap: 8px; max-height: 52vh; overflow: auto; }
.hist-row {
  display: flex; gap: 12px; justify-content: space-between; align-items: center;
  border: 1px solid var(--line); border-radius: var(--radius-sm);
  padding: 9px 11px; flex-wrap: wrap;
}
.hist-title { display: flex; gap: 8px; align-items: baseline; flex-wrap: wrap; }
.hist-sub { margin: 2px 0 0; font-size: 12.5px; color: var(--ink-faint); }
.hist-acts { display: flex; gap: 6px; flex-wrap: wrap; }
.modal-foot { margin: 12px 0 0; font-size: 12.5px; color: var(--ink-faint); }
kbd {
  font-family: var(--mono); font-size: 11.5px;
  border: 1px solid var(--line-strong); border-bottom-width: 2px;
  border-radius: 4px; padding: 0 4px;
}

/* --- toast --------------------------------------------------------------------------------- */

.toast {
  position: fixed; left: 50%; bottom: 22px; transform: translateX(-50%);
  z-index: 60;
  max-width: min(560px, calc(100vw - 32px));
  border-radius: var(--radius);
  padding: 10px 16px;
  font-size: 13.5px;
  box-shadow: var(--shadow);
  border: 1px solid var(--line);
  background: var(--surface);
}
.toast-ok { border-color: var(--ok); background: var(--ok-soft); color: var(--ok); }
.toast-err { border-color: var(--danger); background: var(--danger-soft); color: var(--danger); }

/* --- footer --------------------------------------------------------------------------------- */

footer {
  max-width: 1120px;
  margin: 34px auto 0;
  padding-top: 18px;
  border-top: 1px solid var(--line);
  color: var(--ink-faint);
  font-size: 13px;
}
footer p { margin: 0 0 8px; }
.foot-links { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }
.foot-links a { color: var(--accent); text-decoration: none; }
.foot-links a:hover { text-decoration: underline; }

/* --- Photo Blender's own surfaces ----------------------------------------------------------- */

.visually-hidden {
  position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px;
  overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; border: 0;
}

.consent {
  border: 1px solid var(--line-strong);
  background: var(--surface-2);
  border-radius: var(--radius);
  padding: 14px 16px;
  margin-bottom: 18px;
}
.consent h2 { margin: 0 0 6px; }
.consent p { margin: 0 0 8px; font-size: 14px; line-height: 1.55; }
.consent p:last-child { margin-bottom: 0; }
.consent-sub { color: var(--ink-soft); font-size: 13px !important; }

/* --- the two slots --- */

.slots {
  display: grid;
  grid-template-columns: 1fr auto 1fr;
  gap: 12px;
  align-items: start;
}
.slot { min-width: 0; }
.slot-head { display: flex; justify-content: space-between; align-items: center; gap: 8px; min-height: 26px; }
.slot-tag { font-size: 12.5px; font-weight: 650; color: var(--accent); }
.slot-mid { display: flex; align-items: center; justify-content: center; padding-top: 60px; }
.drop {
  margin-top: 6px;
  border: 1.5px dashed var(--line-strong);
  border-radius: var(--radius);
  background: var(--surface);
  aspect-ratio: 1 / 1;
  display: flex; align-items: center; justify-content: center;
  overflow: hidden;
  cursor: pointer;
  position: relative;
}
.drop:hover, .drop:focus-visible { border-color: var(--accent); background: var(--accent-soft); }
.drop.is-over { border-color: var(--accent); background: var(--accent-soft); }
.drop .preview { width: 100%; height: 100%; object-fit: cover; display: block; }
.drop-copy { text-align: center; padding: 16px; color: var(--ink-faint); }
.drop-copy strong { display: block; font-size: 14px; color: var(--ink-soft); margin-bottom: 3px; }
.drop-copy span { font-size: 12.5px; }
.slot-meta { margin: 6px 0 0; font-size: 12px; color: var(--ink-faint); min-height: 15px; }

@media (max-width: 640px) {
  .slots { grid-template-columns: 1fr; }
  .slot-mid { padding-top: 0; }
}

/* --- modes --- */

.modes { display: grid; grid-template-columns: repeat(auto-fit, minmax(210px, 1fr)); gap: 8px; }
.mode-btn {
  text-align: left; padding: 10px 12px;
  border: 1px solid var(--line); border-radius: var(--radius-sm);
  background: var(--surface); cursor: pointer;
}
.mode-btn:hover { border-color: var(--line-strong); }
.mode-btn.is-on { border-color: var(--accent); background: var(--accent-soft); }
.mode-btn.is-blocked { opacity: .45; }
.mode-name { display: block; font-weight: 650; font-size: 14px; }
.mode-sub { display: block; font-size: 12.5px; color: var(--ink-faint); margin-top: 2px; }

.strengths { display: flex; gap: 8px; flex-wrap: wrap; }
.strength-btn {
  padding: 7px 14px; border: 1px solid var(--line); border-radius: 999px;
  background: var(--surface); cursor: pointer; font-size: 13.5px;
}
.strength-btn.is-on { border-color: var(--accent); background: var(--accent-soft); font-weight: 650; }

/* --- run bars --- */

.runbar {
  display: flex; justify-content: space-between; align-items: center; gap: 14px;
  flex-wrap: wrap;
  border: 1px solid var(--line); border-radius: var(--radius);
  background: var(--surface-2); padding: 12px 14px; margin-top: 14px;
}
.runbar-acts { display: flex; gap: 8px; flex-wrap: wrap; }
.meter { display: flex; flex-direction: column; gap: 1px; }
.hold { font-size: 15px; font-weight: 650; }
.meter-sub { font-size: 12px; color: var(--ink-faint); }
.runbar-hint { margin-top: 6px; }

/* --- brief + result --- */

.brief-panel, .result-panel, .example-panel { margin-top: 22px; }
.reads { border-left: 3px solid var(--line-strong); padding-left: 12px; margin: 8px 0 14px; }
.reads p { margin: 0 0 5px; font-size: 14px; line-height: 1.5; }
.read-tag {
  display: inline-block; min-width: 66px; font-size: 12px; font-weight: 650;
  color: var(--accent); text-transform: uppercase; letter-spacing: .04em;
}
.read-people { font-size: 13px !important; color: var(--ink-soft); margin-top: 8px !important; }
.people-flag { color: var(--warn); font-weight: 650; }
.people-ok { color: var(--ok); font-weight: 650; }
.prescan.warn { color: var(--warn); }

.result-figure {
  border: 1px solid var(--line); border-radius: var(--radius);
  overflow: hidden; background: var(--surface-2);
}
.result-figure img { display: block; width: 100%; height: auto; }
.result-acts { display: flex; gap: 8px; flex-wrap: wrap; margin-top: 10px; }

/* --- progress --- */

.progress-head { display: flex; justify-content: space-between; align-items: baseline; }
.progress-steps { list-style: none; margin: 10px 0 0; padding: 0; display: grid; gap: 6px; }
.step { display: flex; align-items: center; gap: 8px; font-size: 13.5px; color: var(--ink-faint); }
.step-dot {
  width: 9px; height: 9px; border-radius: 50%;
  border: 1.5px solid var(--line-strong); flex: none;
}
.step.is-on { color: var(--ink); font-weight: 650; }
.step.is-on .step-dot { border-color: var(--accent); background: var(--accent-soft); }
.step.is-done { color: var(--ink-soft); }
.step.is-done .step-dot { background: var(--accent); border-color: var(--accent); }

/* --- example --- */

.example-strip { display: grid; grid-template-columns: 1fr 1fr 1.4fr; gap: 10px; align-items: start; }
.example-strip figure { margin: 0; }
.example-strip img {
  width: 100%; height: auto; display: block;
  border: 1px solid var(--line); border-radius: var(--radius-sm);
}
.example-strip figcaption { font-size: 12px; color: var(--ink-faint); margin-top: 4px; }
.ex-brief {
  white-space: pre-wrap; font-size: 13px; line-height: 1.55;
  background: var(--surface-2); border: 1px solid var(--line);
  border-radius: var(--radius-sm); padding: 10px 12px; margin: 8px 0;
}
.ex-reads { font-size: 13px; color: var(--ink-soft); margin: 8px 0 0; }
.example-panel.is-stale { border-left: 3px solid var(--warn); padding-left: 12px; }
#exampleDetails summary { cursor: pointer; font-size: 13.5px; margin-top: 10px; }
#exampleLoad { margin-top: 10px; }

@media (max-width: 640px) {
  .example-strip { grid-template-columns: 1fr; }
}

/* --- guard box --- */

.guard-head { margin: 0 0 8px; font-weight: 650; color: var(--danger); }
.guard-item { margin-bottom: 10px; }
.guard-item:last-child { margin-bottom: 0; }
.guard-item strong { display: block; font-size: 14px; margin-bottom: 3px; }
.guard-item p { margin: 0 0 4px; font-size: 13.5px; line-height: 1.5; }
.guard-ev { font-size: 12px; color: var(--ink-faint); }

.hist-brief { font-size: 13px; color: var(--ink-soft); margin: 4px 0 8px; line-height: 1.5; }
.hist-mode { font-size: 12px; color: var(--ink-faint); margin-left: 8px; }
.hist-empty { color: var(--ink-faint); font-size: 13.5px; }
.foot-note { font-size: 12.5px; color: var(--ink-faint); max-width: 70ch; }

/* --- docs pages and token panel ----------------------------------------------------------- */

.theme-toggle { min-width: 34px; }
.theme-toggle::after { content: "◐"; }
.tabs { display: flex; gap: 6px; flex-wrap: wrap; margin: 10px 0 6px; }
.tabs button {
  font-size: 12.5px; padding: 3px 10px;
  border: 1px solid var(--line); border-radius: var(--radius-sm);
  background: var(--surface); cursor: pointer;
}
.tabs button.is-on { border-color: var(--accent); background: var(--accent-soft); color: var(--accent); }
.token-box {
  border: 1px solid var(--line); border-radius: var(--radius);
  background: var(--surface); padding: 13px 15px; margin-bottom: 14px;
}
.token-val {
  font-family: var(--mono); font-size: 12.5px; word-break: break-all;
  background: var(--surface-2); border-radius: var(--radius-sm);
  padding: 8px 10px; margin: 8px 0;
}
.code-group { margin: 10px 0 4px; }
.code-group pre, pre.contract {
  background: var(--surface-2); border: 1px solid var(--line);
  border-radius: var(--radius-sm); padding: 11px 13px; margin: 0;
  font-family: var(--mono); font-size: 12.5px; line-height: 1.5;
  overflow-x: auto; white-space: pre;
}
pre.contract { margin: 10px 0; }
.err-table { border-collapse: collapse; width: 100%; margin-top: 10px; font-size: 13px; }
.err-table th, .err-table td {
  text-align: left; padding: 6px 8px; border-bottom: 1px solid var(--line); vertical-align: top;
}
.callout { border-left: 3px solid var(--accent); padding-left: 12px; }
.brandlink { color: inherit; text-decoration: none; }
.ex-out img { border-color: var(--line-strong); }
code { font-family: var(--mono); font-size: 0.92em; }
ol.hint { padding-left: 20px; }
ol.hint li { margin-bottom: 4px; }

.status {
  border-radius: var(--radius-sm); padding: 10px 12px; margin-top: 16px; font-size: 13.5px;
  border: 1px solid var(--line); background: var(--surface-2);
}
.status.ok { border-color: var(--ok); background: var(--ok-soft); color: var(--ok); }
.status.warn { border-color: var(--warn); background: var(--warn-soft); color: var(--warn); }
.status.err { border-color: var(--danger); background: var(--danger-soft); color: var(--danger); }
