:root {
  --bg: #f7f6f2;
  --surface: #ffffff;
  --ink: #1b1b1f;
  --muted: #6b6b73;
  --line: #e4e2dc;
  --accent: #ff5a1f;
  --accent-ink: #ffffff;
  --user: #1b1b1f;
  --user-ink: #ffffff;
  --radius: 14px;
  --shadow: 0 1px 2px rgba(0,0,0,.05), 0 6px 20px rgba(0,0,0,.05);
  color-scheme: light;
}
* { box-sizing: border-box; }
html, body { height: 100%; }
body { margin: 0; background: var(--bg); color: var(--ink); font: 15px/1.45 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif; height: 100vh; height: 100dvh; display: flex; flex-direction: column; overflow: hidden; }
button, input, textarea { font: inherit; }

.top { flex: none; display: flex; align-items: center; justify-content: space-between; padding: 10px 16px; border-bottom: 1px solid var(--line); background: var(--surface); z-index: 5; }
.brand { font-weight: 800; letter-spacing: -.02em; font-size: 18px; font-style: italic; }
.brand span { color: var(--accent); }
.top-right { display: flex; gap: 10px; align-items: center; }
.status { font-size: 12px; color: var(--muted); }
.status.bad { color: #b3261e; }

/* The layout is pinned to the viewport so the messages pane is the scroller (not the page): auto-scroll needs one element to own the scroll. */
.layout { flex: 1; min-height: 0; width: 100%; display: grid; grid-template-columns: 1fr 360px; gap: 16px; padding: 16px; max-width: 1200px; margin: 0 auto; }
.chat { display: flex; flex-direction: column; min-width: 0; min-height: 0; height: 100%; }
.messages { flex: 1; min-height: 0; overflow-y: auto; overscroll-behavior: contain; padding: 8px 4px 16px; display: flex; flex-direction: column; gap: 12px; }

.empty { text-align: center; margin: auto; padding: 32px 8px; }
.empty h1 { font-size: 28px; margin: 0 0 6px; letter-spacing: -.02em; }
.muted { color: var(--muted); }
.entries { display: flex; flex-wrap: wrap; gap: 8px; justify-content: center; margin-top: 16px; }

.msg { max-width: 78%; display: flex; flex-direction: column; gap: 8px; }
.msg.user { align-self: flex-end; align-items: flex-end; }
.msg.assistant { align-self: flex-start; }
.bubble { padding: 10px 14px; border-radius: var(--radius); background: var(--surface); box-shadow: var(--shadow); white-space: pre-wrap; word-wrap: break-word; }
.msg.user .bubble { background: var(--user); color: var(--user-ink); }
.bubble p { margin: 0 0 8px; } .bubble p:last-child { margin: 0; }
.bubble ul { margin: 4px 0; padding-left: 18px; }
.bubble a { color: var(--accent); }
.thinking { font-size: 12px; color: var(--muted); display: none; }   /* the model's reasoning is noise for a customer; add ?debug=1 to the page to see it */
body.debug .thinking { display: block; }
.thinking summary { cursor: pointer; }

.chips { display: flex; flex-wrap: wrap; gap: 6px; }
.chip { display: inline-flex; align-items: center; gap: 6px; font-size: 12px; padding: 4px 10px; border-radius: 999px; background: #efede7; color: var(--muted); }
.chip .dot { width: 8px; height: 8px; border-radius: 50%; background: #c9c7bf; }
.chip.running .dot { background: var(--accent); animation: pulse 1s infinite; }
.chip.ok .dot { background: #2e7d32; }
.chip.err .dot { background: #b3261e; }
@keyframes pulse { 50% { opacity: .3; } }

.card { background: var(--surface); border-radius: var(--radius); box-shadow: var(--shadow); padding: 12px; }
.card h4 { margin: 0 0 8px; font-size: 14px; }
.design-previews { display: flex; gap: 8px; }
.design-previews img { width: 100%; max-width: 260px; aspect-ratio: 1; object-fit: contain; background: #f1f0ec; border-radius: 10px; }
.swatches { display: flex; gap: 6px; flex-wrap: wrap; margin-top: 8px; }
.swatch { display: inline-flex; align-items: center; gap: 6px; font-size: 12px; color: var(--muted); }
.swatch i { width: 18px; height: 18px; border-radius: 50%; border: 1px solid rgba(0,0,0,.1); display: inline-block; }
.slots { margin-top: 8px; display: grid; gap: 6px; }
.slots label { font-size: 12px; color: var(--muted); display: grid; gap: 2px; }
.slots input { padding: 6px 8px; border: 1px solid var(--line); border-radius: 8px; }

.options { display: grid; grid-template-columns: repeat(auto-fill, minmax(140px, 1fr)); gap: 8px; }
.option { background: var(--surface); border: 1px solid var(--line); border-radius: 12px; padding: 8px; cursor: pointer; text-align: left; }
.option:hover { border-color: var(--accent); }
.option img { width: 100%; aspect-ratio: 1; object-fit: contain; background: #f1f0ec; border-radius: 8px; }
.option .name { font-weight: 600; font-size: 13px; margin-top: 6px; }
.option .sub { font-size: 12px; color: var(--muted); }

table.price { width: 100%; border-collapse: collapse; font-size: 14px; }
table.price td { padding: 4px 0; border-bottom: 1px solid var(--line); }
table.price tr:last-child td { border: 0; font-weight: 700; }
table.price td:last-child { text-align: right; }

.replies { display: flex; flex-wrap: wrap; gap: 8px; padding: 8px 4px; }
.btn { border: 1px solid var(--line); background: var(--surface); color: var(--ink); padding: 8px 14px; border-radius: 999px; cursor: pointer; }
.btn:hover { border-color: #c8c6be; }
.btn.primary { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); font-weight: 600; }
.btn.danger { background: #b3261e; border-color: #b3261e; color: #fff; }
.btn.ghost { background: transparent; }
.btn.small { padding: 4px 10px; font-size: 12px; }
.btn.icon { width: 40px; height: 40px; padding: 0; display: inline-flex; align-items: center; justify-content: center; font-size: 20px; }
.btn.link { display: inline-block; text-decoration: none; }

.composer { flex: none; background: var(--bg); padding-top: 8px; padding-bottom: env(safe-area-inset-bottom, 0px); }
.composer .row { display: flex; gap: 8px; align-items: flex-end; }
.composer textarea { flex: 1; resize: none; padding: 10px 12px; border: 1px solid var(--line); border-radius: 12px; background: var(--surface); max-height: 160px; }
.attachments { display: flex; gap: 8px; padding-bottom: 6px; }
.attachments img { width: 48px; height: 48px; object-fit: cover; border-radius: 8px; border: 1px solid var(--line); }

.panel { align-self: start; background: var(--surface); border-radius: var(--radius); box-shadow: var(--shadow); max-height: 100%; overflow: auto; }
.panel-head { display: flex; align-items: center; justify-content: space-between; padding: 10px 12px; border-bottom: 1px solid var(--line); }
.panel-body { padding: 12px; }
.panel-toggle { position: fixed; right: 16px; bottom: 76px; z-index: 6; border: 0; background: var(--ink); color: #fff; padding: 10px 14px; border-radius: 999px; box-shadow: var(--shadow); }

.roster { display: grid; gap: 6px; margin-top: 8px; }
.roster .r { display: grid; grid-template-columns: 1fr 70px 80px auto; gap: 6px; }
.roster input, .roster select { padding: 6px 8px; border: 1px solid var(--line); border-radius: 8px; }
.error { background: #fdecea; color: #7a1c14; padding: 10px 14px; border-radius: 12px; }

@media (max-width: 860px) {
  .layout { grid-template-columns: 1fr; padding: 12px; }
  .msg { max-width: 92%; }
  .panel { position: fixed; left: 0; right: 0; bottom: 0; top: auto; max-height: 70vh; border-radius: 16px 16px 0 0; z-index: 7; }
  .panel-toggle { display: inline-block; }
}

.candidates .option img { aspect-ratio: 1; }
.swatches.big .swatch { font-size: 13px; }
.swatches.big .swatch i { width: 26px; height: 26px; }
.image-check img { width: 120px; height: 120px; object-fit: contain; background: #f1f0ec; border-radius: 8px; }
.crest img { width: 160px; height: 160px; object-fit: contain; }
.crest .variants { display: flex; flex-wrap: wrap; gap: 12px; }
.crest .variant { margin: 0; text-align: center; font-size: 12px; color: #555; }
.crest .variant img { display: block; margin: 0 auto 4px; }
.crest .variant.flawed img { outline: 2px dashed #c0392b; outline-offset: 2px; }
.crest .variant figcaption { font-weight: 600; }

/* ---- images open full size in a lightbox; every rendered image gets a zoom control ---- */
.zoomwrap { position: relative; display: inline-block; max-width: 100%; }
.zoomwrap > img { display: block; cursor: zoom-in; }
.zoom { position: absolute; top: 6px; right: 6px; width: 28px; height: 28px; border-radius: 999px; background: rgba(255,255,255,.92); border: 1px solid var(--line); box-shadow: var(--shadow); display: flex; align-items: center; justify-content: center; font-size: 14px; line-height: 1; color: var(--ink); cursor: zoom-in; opacity: 0; transition: opacity .15s; user-select: none; }
.zoomwrap:hover .zoom, .zoom:focus { opacity: 1; }
@media (hover: none) { .zoom { opacity: 1; } }
.option .zoomwrap { display: block; }
.option .zoomwrap > img { width: 100%; }
.lightbox { position: fixed; inset: 0; z-index: 100; background: rgba(20,20,24,.86); display: flex; align-items: center; justify-content: center; padding: 24px; }
.lightbox[hidden] { display: none; }
.lightbox img { max-width: min(96vw, 1400px); max-height: 92vh; object-fit: contain; background: #fff; border-radius: 12px; box-shadow: 0 20px 60px rgba(0,0,0,.4); cursor: zoom-out; }
.lightbox .lb-close { position: absolute; top: 14px; right: 16px; width: 40px; height: 40px; border-radius: 999px; border: 0; background: rgba(255,255,255,.92); color: var(--ink); font-size: 24px; line-height: 1; cursor: pointer; }
