:root {
  --bg: #ffffff; --surface: rgba(255, 255, 255, .9); --surface-solid: #ffffff;
  --line: #e3e9cb; --line-strong: #b4d089;
  --ink: #20261a; --muted: #6a7462; --accent: #6f9f4a; --accent-ink: #305318;
  --tone1: #96cc76; --tone2: #6f9f4a; --tone3: #416b28;
  --btn: linear-gradient(135deg, #c7dd4a, #96cc76); --btn-hover: linear-gradient(135deg, #d3e66b, #a7d68a);
  --chip: #f4f9ef; --glow: rgba(111, 159, 74, .22); --danger: #b42318; --ok: #2f7a3f;
  --shadow: 0 14px 34px -22px rgba(50, 80, 31, .28);
  --serif: Outfit, Manrope, system-ui, -apple-system, "Segoe UI", sans-serif;
  --sans: Manrope, system-ui, -apple-system, "Segoe UI", sans-serif;
  --ease: cubic-bezier(.2, .8, .2, 1);
  color-scheme: light;
}
* { box-sizing: border-box; }
[hidden] { display: none !important; }
body { margin: 0; min-height: 100vh; background: var(--bg); color: var(--ink); font: 15px/1.55 var(--sans); overflow-x: hidden; }
body.lock { overflow: hidden; }
button, input, select, textarea { font: inherit; color: var(--ink); }
button { cursor: pointer; }
:focus-visible { outline: 2px solid var(--tone2); outline-offset: 3px; }

.topbar { position: sticky; top: 0; z-index: 30; display: flex; align-items: center; justify-content: space-between; gap: 12px;
  padding: 14px 24px; background: color-mix(in srgb, var(--bg) 80%, transparent); backdrop-filter: blur(16px) saturate(1.4);
  -webkit-backdrop-filter: blur(16px) saturate(1.4); border-bottom: 1px solid var(--line); }
.brand { display: flex; align-items: center; gap: 10px; text-decoration: none; color: var(--ink); min-width: 0; }
.brand svg { width: 40px; height: 40px; flex: none; }
.brand b { font: 500 17px/1 var(--serif); letter-spacing: .2em; text-transform: uppercase; white-space: nowrap; }
.brand small { display: block; font-size: 10px; letter-spacing: .32em; color: var(--muted); text-transform: uppercase; margin-top: 3px; }
.top-links { display: flex; gap: 8px; }
.ghost { display: inline-flex; align-items: center; justify-content: center; gap: 7px; border: 1px solid var(--line-strong); background: var(--surface); border-radius: 999px;
  padding: 8px 16px; font-size: 13px; font-weight: 600; color: var(--accent-ink); text-decoration: none; white-space: nowrap;
  transition: background .3s, transform .35s var(--ease); }
.ghost:hover:not(:disabled) { background: var(--btn-hover); transform: translateY(-2px); color: var(--btn-ink, #1d2f10); }
.ghost.small { padding: 5px 12px; font-size: 12px; }
.ghost:disabled { opacity: .45; cursor: not-allowed; }
.primary { display: inline-flex; align-items: center; justify-content: center; gap: 8px; min-height: 50px; padding: 0 26px; border-radius: 999px;
  border: 1px solid var(--tone2); background: var(--btn); color: var(--btn-ink, #1d2f10); font-weight: 700; letter-spacing: .02em;
  transition: transform .3s var(--ease), box-shadow .3s; white-space: nowrap; }
.primary:hover:not(:disabled) { transform: translateY(-2px); box-shadow: 0 12px 26px -14px var(--glow); }
.primary:disabled { opacity: .5; cursor: not-allowed; }

.wrap { max-width: 980px; margin: 0 auto; padding: 26px 28px 120px; }
.eyebrow { font-size: 11px; letter-spacing: .3em; text-transform: uppercase; color: var(--th-gold-text, #497929); font-weight: 700; }
h1 { font: 400 36px/1.1 var(--serif); letter-spacing: -.02em; margin: 6px 0 6px; }
.lead { color: var(--muted); margin: 0 0 18px; max-width: 760px; }
h2 { font: 500 20px/1.25 var(--serif); margin: 0 0 10px; }
.hint { font-size: 12.5px; color: var(--muted); margin: 6px 0 0; }
.err { color: var(--danger); font-size: 13.5px; font-weight: 600; margin: 10px 0 0; }
.err:empty { display: none; }
.card { border: 1px solid var(--line); border-radius: 22px; background: var(--surface-solid); padding: 20px 22px; box-shadow: var(--shadow); min-width: 0; }
.mode { display: flex; gap: 12px; align-items: flex-start; border: 1px solid var(--line-strong); background: var(--chip); border-radius: 16px;
  padding: 12px 16px; margin: 0 0 20px; font-size: 13.5px; }
.mode b { color: var(--accent-ink); }
.mode .dot { width: 9px; height: 9px; border-radius: 50%; background: var(--tone1); margin-top: 6px; flex: none; }
.mode.live .dot { background: var(--ok); }
/* 2026-11-04: the AI status as a plain line (dot + text), no box around it */
.mode.mode-plain { display: inline-flex; align-items: center; gap: 7px; border: 0; background: none; border-radius: 0; padding: 0; margin: 0 0 14px; font-size: 12.5px; }
.mode.mode-plain .dot { width: 7px; height: 7px; margin-top: 0; }
/* 2026-11-04: the AI status as a small tag (as on the Design Generator) instead of a full-width box */
.mode.mode-tag { display: inline-flex; align-items: center; gap: 6px; width: fit-content; padding: 3px 10px; border-radius: 999px;
  font-size: 12px; line-height: 1.4; margin: 0 0 16px; cursor: default; }
.mode.mode-tag .dot { width: 7px; height: 7px; margin-top: 0; }

/* source */
.drop { border: 1.5px dashed var(--line-strong); border-radius: 18px; background: var(--th-paper-2, #fbfef9); min-height: 210px; display: grid; place-items: center; text-align: center; padding: 24px; }
.drop.drag { border-color: var(--tone2); background: var(--chip); }
.drop .row { display: flex; gap: 10px; justify-content: center; flex-wrap: wrap; }
.camwrap { position: relative; border-radius: 18px; overflow: hidden; background: #111; aspect-ratio: 4 / 3; }
.camwrap video { width: 100%; height: 100%; object-fit: cover; display: block; }
.camwrap .bar { position: absolute; bottom: 14px; left: 0; right: 0; display: flex; justify-content: center; gap: 10px; }
.cropwrap { position: relative; margin: 0 auto; touch-action: none; user-select: none; background: #33382e; border-radius: 12px; overflow: hidden; width: fit-content; max-width: 100%; }
.cropwrap canvas { display: block; max-width: 100%; }
.cropbox { position: absolute; border: 2px solid #fff; box-shadow: 0 0 0 9999px rgba(23, 27, 19, .55); cursor: move; }
.cropbox::before, .cropbox::after { content: ""; position: absolute; inset: 0; pointer-events: none; }
.cropbox::before { border-left: 1px dashed rgba(255,255,255,.55); border-right: 1px dashed rgba(255,255,255,.55); left: 33.3%; right: 33.3%; }
.cropbox::after { border-top: 1px dashed rgba(255,255,255,.55); border-bottom: 1px dashed rgba(255,255,255,.55); top: 33.3%; bottom: 33.3%; }
.handle { position: absolute; width: 18px; height: 18px; margin: -9px 0 0 -9px; background: var(--th-paper, #fff); border: 2px solid var(--tone2); border-radius: 50%; z-index: 2; }
.crop-actions { display: flex; gap: 10px; margin-top: 12px; flex-wrap: wrap; }
.crop-actions .primary { flex: 1; }

.zoombox { position: relative; overflow: hidden; border-radius: 16px; border: 1px solid var(--line); background: var(--th-gold-tint, #ebf2e4); height: 420px; touch-action: none; cursor: grab; }
.zoombox.grabbing { cursor: grabbing; }
.zoomlayer { position: absolute; left: 0; top: 0; transform-origin: 0 0; }
.zoomlayer img { display: block; width: 100%; height: 100%; user-select: none; -webkit-user-drag: none; pointer-events: none; }
.zhead { display: flex; justify-content: space-between; align-items: center; gap: 8px; margin-bottom: 6px; font-size: 13px; font-weight: 700; }
.zhead span { font-weight: 500; font-size: 12px; color: var(--muted); }

label.f { display: block; font-size: 13px; font-weight: 700; margin: 16px 0 6px; }
select, textarea, input[type=text] { width: 100%; border: 1px solid var(--line-strong); border-radius: 12px; padding: 11px 14px; background: var(--th-paper, #fff); }
textarea { resize: vertical; min-height: 92px; line-height: 1.5; }
.chips { display: flex; gap: 8px; flex-wrap: wrap; }
.chip { border: 1px solid var(--line-strong); background: var(--th-paper, #fff); border-radius: 999px; padding: 8px 16px; font-weight: 600; font-size: 14px;
  display: inline-flex; align-items: center; gap: 7px; transition: background .25s, transform .3s var(--ease); }
.chip svg { width: 16px; height: 16px; }
.chip[aria-pressed="true"] { background: var(--btn); border-color: var(--tone2); color: var(--btn-ink, #1d2f10); }
.chip:hover { transform: translateY(-1px); }
.two { display: grid; grid-template-columns: 1fr 1fr; gap: 0 14px; }
.actions { display: flex; gap: 10px; flex-wrap: wrap; align-items: center; margin-top: 18px; }

.progress { margin-top: 16px; }
.pbar { height: 8px; border-radius: 999px; background: var(--chip); border: 1px solid var(--line); overflow: hidden; }
.pbar i { display: block; height: 100%; width: 0; background: linear-gradient(90deg, var(--tone1), var(--tone2)); transition: width .6s var(--ease); }
.progress p { font-size: 13px; color: var(--muted); margin: 8px 0 0; }

.result img.sheet { display: block; width: 100%; border-radius: 14px; border: 1px solid var(--line); cursor: zoom-in; background: var(--th-gold-tint, #f0f5eb); }

/* viewer */
.viewer { position: fixed; inset: 0; z-index: 100; background: rgba(21, 25, 17, .78); display: flex; flex-direction: column; align-items: center; justify-content: center; padding: 16px; gap: 10px; }
.viewer .zoombox { width: min(92vw, 860px); height: min(70vh, 860px); background: var(--th-gold-tint, #f0f5eb); border: 0; }
.viewer .close { position: absolute; top: 14px; right: 16px; width: 44px; height: 44px; border-radius: 50%; border: 0; background: var(--btn-fill, linear-gradient(135deg, #c7dd4a, #96cc76)); color: var(--btn-ink, #1d2f10); font-size: 22px; line-height: 1; }
.viewer .vhint { color: #e6ead5; font-size: 12.5px; text-align: center; }
.viewer .vbar { display: flex; flex-wrap: wrap; gap: 8px; justify-content: center; max-width: 860px; }
.viewer .vbar .ghost { background: rgba(var(--th-paper-rgb, 255, 255, 255), .94); }
.selbox { position: absolute; border: 3px solid var(--tone1); border-radius: 6px; box-shadow: 0 0 0 9999px rgba(21,25,17,.35); pointer-events: none; }
.refine { display: flex; gap: 8px; margin-top: 12px; }
.refine input { flex: 1; min-width: 0; }
.touch { display: flex; gap: 8px; width: min(92vw, 860px); }
.touch input { flex: 1; min-width: 0; }
.analysis { width: min(92vw, 860px); max-height: 32vh; overflow: auto; background: var(--th-paper, #fff); border-radius: 16px; padding: 14px 16px; font-size: 13.5px; }
.analysis .row { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; margin: 4px 0; }
.analysis .k { width: 96px; flex: none; font-size: 10.5px; letter-spacing: .14em; text-transform: uppercase; color: var(--muted); }
.trait { font-size: 12.5px; background: var(--chip); border: 1px solid var(--line-strong); border-radius: 999px; padding: 2px 10px; }
.cards { display: grid; grid-template-columns: repeat(auto-fill, minmax(130px, 1fr)); gap: 10px; margin-top: 10px; }
.mini { border: 1px solid var(--line); border-radius: 14px; overflow: hidden; background: var(--th-paper, #fff); text-decoration: none; color: var(--ink); position: relative;
  transition: transform .3s var(--ease), box-shadow .3s; }
.mini:hover { transform: translateY(-3px); box-shadow: var(--shadow); }
.mini img { display: block; width: 100%; aspect-ratio: 1 / 1; object-fit: contain; background: var(--th-paper-2, #f6f9f4); }
.mini .cap { padding: 6px 9px; font-size: 11.5px; color: var(--muted); display: flex; justify-content: space-between; gap: 6px; }
.mini button.x { position: absolute; top: 6px; right: 6px; width: 26px; height: 26px; border-radius: 50%; border: 1px solid var(--line-strong);
  background: rgba(var(--th-paper-rgb, 255, 255, 255), .92); font-size: 14px; line-height: 1; }
section.block { margin-top: 26px; }
.toast { position: fixed; left: 50%; bottom: 26px; transform: translateX(-50%); z-index: 200; background: var(--ink); color: var(--th-on-ink, #fff); padding: 10px 18px; border-radius: 999px; font-size: 13.5px; }

@media (max-width: 700px) {
  .wrap { padding: 18px 16px 100px; }
  h1 { font-size: 28px; }
  .topbar { padding: 10px 16px; }
  .brand small, .top-links .hide-sm { display: none; }
  .two { grid-template-columns: 1fr; }
  .zoombox { height: 320px; }
}
/* phones: headings scale with the screen (320px → 720px) instead of staying at one size;
   form fields at 16px so iPhones don't zoom the page when one is tapped */
@media (max-width: 720px) {
  body h1 { font-size: clamp(20px, 16.8px + 1vw, 24px) !important; }   /* body: outranks ai-theme.css's fixed h1 */
  h2 { font-size: clamp(17px, 14.6px + .75vw, 20px); }
  input, select, textarea { font-size: 16px; }
  html body :is(input, select, textarea, .input) { font-size: 16px; }   /* outranks ai-theme.css's field size */
}
/* phones: placeholders and the chosen value in drop-downs at 14px, closer to the small field names above them
   (they were 16px and looked oversized next to the labels), 2026-11-19. Typed text stays 16px. Phones only. */
@media (max-width: 720px) {
  html body :is(input, select, textarea) { font-family: inherit; }   /* fields in the page font, not the browser default */
  html body :is(input, textarea)::placeholder { font-size: min(14px, 1em); }
  html body select:not([multiple]) { font-size: 14px; }
}
