: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; }
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; }
.ghost { display: inline-flex; align-items: 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 { 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; transform: none; }
.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: 1240px; 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: 780px; }
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 small tag 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; }

.grid { display: grid; grid-template-columns: minmax(0, 1.05fr) minmax(0, .95fr); gap: 22px; align-items: start; }

.tabs { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; margin-bottom: 14px; }
.tab { border: 1px solid var(--line-strong); background: var(--th-paper, #fff); border-radius: 14px; padding: 11px 8px; font-weight: 600; font-size: 14px;
  display: flex; align-items: center; justify-content: center; gap: 8px; transition: background .25s, transform .3s var(--ease); }
.tab svg { width: 18px; height: 18px; }
.tab[aria-selected="true"] { background: var(--btn); border-color: var(--tone2); color: var(--btn-ink, #1d2f10); }
.tab:hover { transform: translateY(-1px); }

.stage { position: relative; border: 1.5px dashed var(--line-strong); border-radius: 18px; background: var(--th-paper-2, #fbfef9); aspect-ratio: 1 / 1;
  overflow: hidden; display: grid; place-items: center; }
.stage.drag { border-color: var(--tone2); background: var(--chip); }
.drop { text-align: center; padding: 20px; }
.drop .row { display: flex; gap: 10px; justify-content: center; flex-wrap: wrap; }
.picked { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: contain; background: var(--th-paper, #fff); }
.stage .remove { position: absolute; top: 10px; right: 10px; z-index: 3; }
video.cam { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; background: #111; }
.cam-bar { position: absolute; bottom: 14px; left: 0; right: 0; display: flex; justify-content: center; gap: 10px; z-index: 2; }

canvas.pad { position: absolute; inset: 0; width: 100%; height: 100%; touch-action: none; cursor: crosshair; background: var(--th-paper, #fff); }
.tools { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; margin-top: 10px; }
.tool { width: 38px; height: 38px; border-radius: 12px; border: 1px solid var(--line-strong); background: var(--th-paper, #fff); display: grid; place-items: center; }
.tool svg { width: 18px; height: 18px; }
.tool[aria-pressed="true"] { background: var(--btn); border-color: var(--tone2); color: var(--btn-ink, #1d2f10); }
.swatch { width: 26px; height: 26px; border-radius: 50%; border: 2px solid #fff; box-shadow: 0 0 0 1px var(--line-strong); }
.swatch[aria-pressed="true"] { box-shadow: 0 0 0 2px var(--tone2); }
.tools input[type=range] { width: 110px; accent-color: var(--tone2); }
.sep { width: 1px; height: 26px; background: var(--line); margin: 0 2px; }

label.f { display: block; font-size: 13px; font-weight: 700; margin: 14px 0 6px; }
label.f span { font-weight: 500; color: var(--muted); }
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: 84px; }
.check { display: flex; align-items: center; gap: 10px; margin: 14px 0 0; font-size: 14px; }
.check input { width: 18px; height: 18px; accent-color: var(--tone2); }
.actions { display: flex; gap: 10px; flex-wrap: wrap; align-items: center; margin-top: 16px; }

.result .frame { position: relative; border-radius: 18px; border: 1px solid var(--line); background: var(--th-paper-2, #f6f9f4); aspect-ratio: 1 / 1; overflow: hidden;
  display: grid; place-items: center; }
.result .frame img { width: 100%; height: 100%; object-fit: contain; }
.empty { color: var(--muted); text-align: center; padding: 30px; font-size: 14px; }
.making { display: grid; place-items: center; gap: 14px; color: var(--muted); font-size: 14px; }
.shine { width: 64px; height: 64px; border-radius: 50%; border: 3px solid var(--line); border-top-color: var(--tone2); animation: spin 1s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }
.meta { display: flex; justify-content: space-between; gap: 8px; flex-wrap: wrap; font-size: 12.5px; color: var(--muted); margin-top: 10px; }
.tag { font-size: 11px; font-weight: 700; color: var(--accent-ink); background: var(--chip); border: 1px solid var(--line-strong); padding: 2px 9px; border-radius: 999px; }
.refine { display: flex; gap: 8px; margin-top: 12px; }
.refine input { flex: 1; min-width: 0; }


.cards { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 12px; margin-top: 12px; }
.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: 7px 10px; font-size: 12px; 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; }

@media (max-width: 900px) {
  .grid { grid-template-columns: 1fr; }
  .wrap { padding: 18px 16px 100px; }
  h1 { font-size: 28px; }
  .topbar { padding: 10px 16px; }
  .brand small { display: none; }
  .tab { font-size: 13px; }
}
.wrap { max-width: 980px; }
.seg-card { display: flex; align-items: center; justify-content: space-between; gap: 14px; flex-wrap: wrap; border: 1px solid var(--line); border-radius: 18px;
  background: var(--chip); padding: 14px 18px; margin: 0 0 18px; }
.seg-card .k { font-size: 11px; letter-spacing: .24em; text-transform: uppercase; color: var(--muted); font-weight: 700; }
.seg-card .v { font-size: 13px; color: var(--muted); margin-top: 3px; }
.seg { display: inline-flex; background: var(--th-paper, #fff); border: 1px solid var(--line-strong); border-radius: 999px; padding: 4px; gap: 4px; }
.seg button { border: 0; background: transparent; border-radius: 999px; padding: 8px 18px; font-weight: 600; font-size: 13.5px; color: var(--muted); }
.seg button[aria-pressed="true"] { background: var(--btn); color: var(--btn-ink, #1d2f10); box-shadow: 0 4px 14px -8px var(--glow); }
.fold { border: 1px solid var(--line); border-radius: 22px; background: var(--surface-solid); box-shadow: var(--shadow); }
.fold > summary { list-style: none; display: flex; justify-content: space-between; align-items: center; gap: 10px; padding: 16px 22px; cursor: pointer; }
.fold > summary::-webkit-details-marker { display: none; }
.fold > summary b, .fold-title { font-size: 15px; font-weight: 700; margin: 0; font-family: inherit; line-height: 1.3; } .fold > summary small { display: block; color: var(--muted); font-size: 12.5px; }
.fold > summary svg { width: 18px; height: 18px; transition: transform .3s var(--ease); color: var(--muted); }
.fold:not([open]) > summary svg { transform: rotate(180deg); }
.fold .body { padding: 0 22px 22px; }
.sec { border: 1px solid var(--line); border-radius: 18px; padding: 16px 18px 18px; margin-top: 14px; background: var(--th-paper-2, #fbfef9); }
.sec-h { display: flex; justify-content: space-between; align-items: center; gap: 10px; }
.sec-h h3 { font: 600 15px/1.3 var(--sans); margin: 0; } .sec-h h3 span { font-weight: 500; color: var(--muted); font-size: 12px; }
.row3 { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 12px; }
.row2 { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 12px; }
.stone .row2.row-inv { grid-template-columns: minmax(0, 1fr) 96px; }
.fld label { display: block; font-size: 12.5px; font-weight: 700; margin: 12px 0 5px; }
.fld label .req { color: var(--danger); } .fld label span { font-weight: 500; color: var(--muted); }
input[type=number], input[type=url], input[type=search] { width: 100%; border: 1px solid var(--line-strong); border-radius: 12px; padding: 11px 14px; background: var(--th-paper, #fff); }
input:invalid:not(:placeholder-shown) { border-color: var(--danger); }
.stone { border: 1px solid var(--line); border-radius: 16px; padding: 12px 14px 14px; margin-top: 12px; background: var(--th-paper, #fff); }
.stone-h { display: flex; justify-content: space-between; align-items: center; font-weight: 700; font-size: 13.5px; }
.stone-h button { border: 0; background: none; color: var(--muted); font-size: 12.5px; text-decoration: underline; }
.inv-info { font-size: 12.5px; color: var(--muted); margin-top: 6px; }
.inv-info b { color: var(--ink); }
.adv-toggle { display: flex; align-items: center; gap: 12px; margin: 18px 0 4px; color: var(--muted); font-size: 13px; }
.adv-toggle::before, .adv-toggle::after { content: ""; flex: 1; height: 1px; background: var(--line); }
.adv-toggle button { border: 0; background: none; color: var(--accent-ink); font-weight: 600; display: inline-flex; gap: 6px; align-items: center; }
.counter { text-align: right; font-size: 11.5px; color: var(--muted); margin-top: 3px; }
.gen { width: 100%; margin-top: 18px; }
.why { font-size: 12.5px; color: var(--muted); text-align: center; margin-top: 8px; }
.q-empty { color: var(--muted); font-size: 13.5px; margin: 18px 2px; }
.qitem { border: 1px solid var(--line); border-radius: 18px; background: var(--th-paper, #fff); padding: 14px 16px; margin-top: 12px; box-shadow: var(--shadow); }
.qhead { display: flex; justify-content: space-between; gap: 10px; align-items: flex-start; }
.qhead .s { font-weight: 600; font-size: 14px; }
.qhead .m { font-size: 12px; color: var(--muted); margin-top: 2px; }
.badge { font-size: 11px; font-weight: 700; padding: 3px 10px; border-radius: 999px; border: 1px solid var(--line-strong); background: var(--chip); color: var(--accent-ink); white-space: nowrap; }
.badge.done { background: var(--th-paper-2, #eaf5ec); border-color: var(--th-ok-line, #b7dcbf); color: var(--ok); }
.badge.error { background: var(--th-danger-bg, #fdecea); border-color: var(--th-danger-line, #f3c0bb); color: var(--danger); }
.badge.cancelled { color: var(--muted); }
.qnotes { margin: 8px 0 0; padding-left: 18px; font-size: 12.5px; color: var(--muted); }
.qres { display: grid; grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)); gap: 12px; margin-top: 12px; }
.res { border: 1px solid var(--line); border-radius: 14px; overflow: hidden; background: var(--th-paper-2, #f6f9f4); }
.res img { display: block; width: 100%; aspect-ratio: 1 / 1; object-fit: contain; background: var(--th-paper, #fff); cursor: zoom-in; }
.res .chk { padding: 8px 10px 0; display: flex; flex-wrap: wrap; gap: 5px; }
.res .chk span { font-size: 11px; padding: 2px 8px; border-radius: 999px; border: 1px solid var(--line); background: var(--th-paper, #fff); }
.res .chk .y { color: var(--ok); border-color: var(--th-ok-line, #b7dcbf); } .res .chk .n { color: var(--danger); border-color: var(--th-danger-line, #f3c0bb); } .res .chk .u { color: var(--muted); }
.res .acts { display: flex; flex-wrap: wrap; gap: 6px; padding: 8px 10px 10px; }
.res .acts a, .res .acts button { font-size: 12px; padding: 5px 11px; }
.res .note { font-size: 11.5px; color: var(--muted); padding: 4px 10px 0; }
.res .edit { display: flex; gap: 6px; padding: 8px 10px 0; }
.res .edit input { flex: 1; min-width: 0; font-size: 12.5px; padding: 7px 10px; border-radius: 10px; }
.res .edit button { font-size: 12px; padding: 5px 11px; }
.res .ehint { font-size: 11.5px; color: var(--muted); padding: 4px 10px 0; }
.res .ehint.err { color: var(--danger); }
.qmaking { display: flex; align-items: center; gap: 10px; margin-top: 10px; color: var(--muted); font-size: 13px; }
.qmaking .shine { width: 22px; height: 22px; border-width: 2px; }
.inv table { width: 100%; border-collapse: collapse; font-size: 13px; margin-top: 10px; }
.inv th, .inv td { text-align: left; padding: 7px 6px; border-bottom: 1px solid var(--line); }
.inv th { font-size: 11.5px; color: var(--muted); font-weight: 700; }
.inv td button { font-size: 12px; border: 0; background: none; text-decoration: underline; color: var(--accent-ink); padding: 0 4px; }
/* 2026-11-04: Edit / Delete as small icon buttons, side by side */
.inv td.inv-act { white-space: nowrap; text-align: right; }
.inv td button.inv-ico { display: inline-flex; align-items: center; justify-content: center; width: 28px; height: 28px; padding: 0; border-radius: 8px; text-decoration: none; cursor: pointer; }
.inv td button.inv-ico + button.inv-ico { margin-left: 4px; }
.inv td button.inv-ico:hover { background: var(--line); }
.inv td button.inv-ico[data-del]:hover { color: var(--danger); }
.inv .tablewrap { overflow-x: auto; }
.inv form .row3 { margin-top: 4px; }
.zoom { position: fixed; inset: 0; z-index: 100; background: rgba(21, 25, 17, .82); display: grid; place-items: center; padding: 20px; cursor: zoom-out; }
.zoom img { max-width: 100%; max-height: 100%; border-radius: 12px; background: var(--th-paper, #fff); }
@media (max-width: 700px) { .row3, .row2, .stone .row2.row-inv { grid-template-columns: 1fr; } .seg-card { flex-direction: column; align-items: flex-start; } }
/* 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 */
}

/* 2026-11-04: Stone input mode as a compact inline row (label + small toggle), no card box */
.seg-card { justify-content: flex-start; gap: 10px; border: 0; border-radius: 0; background: none; padding: 0; margin: 0 0 12px; }
.seg-card .k { letter-spacing: .12em; }
.seg-card .seg { padding: 2px; gap: 2px; }
.seg-card .seg button { padding: 4px 12px; font-size: 12.5px; }
@media (max-width: 700px) { .seg-card { flex-direction: row; align-items: center; } }

/* 2026-11-04: Stone inventory tag button next to the mode switch */
.seg-card .inv-tag { display: inline-flex; align-items: center; gap: 6px; border: 1px solid var(--line-strong); background: none; border-radius: 999px;
  padding: 4px 11px; font-size: 12.5px; font-weight: 600; color: var(--muted); cursor: pointer; }
.seg-card .inv-tag[hidden] { display: none; }
.seg-card .inv-tag:hover, .seg-card .inv-tag[aria-expanded="true"] { color: var(--accent-ink); border-color: var(--accent-ink); }
.seg-card .inv-tag .inv-tag-n { font-weight: 500; opacity: .8; }
@media (max-width: 700px) { .seg-card { flex-wrap: wrap; } }

/* 2026-11-04: Stone input mode switch inside the New Design header */
.fold > summary > div:first-child { flex: 1 1 auto; min-width: 0; }
.fold > summary .seg-card { margin: 0; flex: none; cursor: default; }
.fold > summary .seg-card svg { width: 14px; height: 14px; transform: none; }
@media (max-width: 700px) {
  .fold > summary { flex-wrap: wrap; }
  .fold > summary .seg-card { order: 3; flex-basis: 100%; }
}
/* 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; }
}
