:root {
  --brand: #B4532A; --brand-ink: #ffffff; --bg: #FBF6EE; --surface: #ffffff; --text: #2B1D14; --muted: #6B5A4D;
  --line: #E6D9C8; --radius: 14px; --font: system-ui, -apple-system, "Segoe UI", Roboto, Arial, sans-serif; --serif: Georgia, "Times New Roman", serif;
}
* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body { margin: 0; font: 16px/1.55 var(--font); color: var(--text); background: var(--bg); overflow-x: hidden; }
h1, h2, h3 { font-family: var(--serif); line-height: 1.2; margin: 0 0 .5rem; }
a { color: var(--brand); }
:focus-visible { outline: 3px solid #1d4ed8; outline-offset: 2px; }
.wrap { max-width: 1040px; margin: 0 auto; padding: 0 16px; }
.skip { position: absolute; left: -999px; top: 0; background: #fff; padding: 8px 12px; z-index: 100; }
.skip:focus { left: 8px; top: 8px; }

.proto-note { background: #2B1D14; color: #FBF6EE; font-size: .875rem; padding: 8px 0; }
.proto-note .wrap { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }
.proto-note strong { background: var(--brand); color: #fff; padding: 1px 8px; border-radius: 99px; font-size: .75rem; letter-spacing: .04em; }

header.top { padding: 22px 0 8px; }
header.top h1 { font-size: clamp(1.5rem, 4.5vw, 2.25rem); }
.lede { color: var(--muted); margin: 0 0 14px; max-width: 70ch; }
nav.tabs { display: flex; gap: 6px; border-bottom: 1px solid var(--line); flex-wrap: wrap; }
nav.tabs button { font: inherit; background: none; border: 0; border-bottom: 3px solid transparent; padding: 10px 14px; cursor: pointer; color: var(--muted); border-radius: 8px 8px 0 0; }
nav.tabs button[aria-selected="true"] { color: var(--text); border-bottom-color: var(--brand); font-weight: 600; }

main { padding: 20px 0 110px; }
.btn { font: inherit; border: 1px solid var(--brand); background: var(--brand); color: var(--brand-ink); padding: 9px 16px; border-radius: 99px; cursor: pointer; text-decoration: none; display: inline-block; }
.btn:hover { filter: brightness(1.08); }
.btn.ghost { background: transparent; color: var(--brand); }
.btn.small { padding: 4px 12px; font-size: .875rem; }
.btn[disabled] { opacity: .5; cursor: not-allowed; }

.hero { background: linear-gradient(135deg, #F6E7D3, #EBCFAE); border-radius: 20px; padding: clamp(20px, 5vw, 44px); margin-bottom: 20px; }
.hero h2 { font-size: clamp(1.5rem, 5vw, 2.4rem); max-width: 18ch; }
.hero p { max-width: 52ch; }
.grid { display: grid; gap: 14px; grid-template-columns: repeat(auto-fit, minmax(230px, 1fr)); }
.card { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 16px; }
.card h3 { font-size: 1.1rem; }
.card .swatch-bag { height: 90px; border-radius: 10px; margin-bottom: 10px; }
.price { color: var(--muted); font-size: .9rem; margin: 0; }
.try { margin-top: 20px; }
.try ol { padding-left: 1.2rem; margin: .5rem 0 0; }
.try li { margin-bottom: 6px; }
.themer { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; margin-top: 14px; }
.sw { width: 34px; height: 34px; border-radius: 50%; border: 3px solid #fff; box-shadow: 0 0 0 1px var(--line); cursor: pointer; }
.sw[aria-pressed="true"] { box-shadow: 0 0 0 3px var(--text); }

/* admin */
.admin-grid { display: grid; gap: 16px; grid-template-columns: 1fr; }
@media (min-width: 860px) { .admin-grid { grid-template-columns: 1fr 1fr; } }
label { display: block; font-weight: 600; margin: 10px 0 4px; }
input[type=text], textarea { width: 100%; font: inherit; padding: 9px 11px; border: 1px solid #b9a894; border-radius: 10px; background: #fff; color: var(--text); }
textarea { min-height: 130px; resize: vertical; }
.err { color: #a11a1a; font-weight: 600; margin: 8px 0 0; min-height: 1.2em; }
.ok { color: #1c6b3a; font-weight: 600; margin: 8px 0 0; min-height: 1.2em; }
.kb-list { list-style: none; margin: 0; padding: 0; }
.kb-list li { display: flex; gap: 10px; justify-content: space-between; align-items: center; padding: 9px 0; border-top: 1px solid var(--line); flex-wrap: wrap; }
.kb-list li:first-child { border-top: 0; }
.kb-list .meta { color: var(--muted); font-size: .85rem; }
.kb-list .t { flex: 1 1 200px; min-width: 0; overflow-wrap: anywhere; }
pre.voice { white-space: pre-wrap; background: #FBF6EE; border: 1px solid var(--line); border-radius: 10px; padding: 12px; font-size: .875rem; overflow-wrap: anywhere; margin: 0; }
.meter { height: 10px; background: var(--line); border-radius: 99px; overflow: hidden; }
.meter > i { display: block; height: 100%; background: var(--brand); width: 0; }
footer { color: var(--muted); font-size: .85rem; border-top: 1px solid var(--line); padding: 16px 0 100px; }

/* chat widget */
#chat-toggle { position: fixed; right: 18px; bottom: 18px; z-index: 50; width: 60px; height: 60px; border-radius: 50%; border: 0; background: var(--brand); color: var(--brand-ink); font-size: 26px; cursor: pointer; box-shadow: 0 6px 20px rgba(0,0,0,.28); }
#chat-panel { position: fixed; right: 18px; bottom: 90px; z-index: 60; width: 380px; max-width: calc(100vw - 24px); height: 560px; max-height: calc(100vh - 110px); display: flex; flex-direction: column; background: var(--surface); border: 1px solid var(--line); border-radius: 18px; box-shadow: 0 14px 44px rgba(0,0,0,.28); overflow: hidden; }
#chat-panel[hidden] { display: none; }
.chat-head { background: var(--brand); color: var(--brand-ink); padding: 12px 14px; display: flex; align-items: center; gap: 8px; }
.chat-head h2 { font-size: 1rem; margin: 0; flex: 1; font-family: var(--font); }
.chat-head button { background: rgba(255,255,255,.18); color: inherit; border: 0; border-radius: 8px; padding: 6px 10px; cursor: pointer; font: inherit; font-size: .85rem; }
#chat-log { flex: 1; overflow-y: auto; padding: 14px; display: flex; flex-direction: column; gap: 10px; background: #FFFCF8; }
.msg { max-width: 92%; padding: 9px 12px; border-radius: 14px; font-size: .94rem; overflow-wrap: anywhere; white-space: pre-wrap; }
.msg.user { align-self: flex-end; background: var(--brand); color: var(--brand-ink); border-bottom-right-radius: 4px; }
.msg.bot { align-self: flex-start; background: #fff; border: 1px solid var(--line); border-bottom-left-radius: 4px; }
.msg.bot.warn { border-color: #d9a441; background: #FFF7E3; }
.msg sup.cite { color: var(--brand); font-weight: 700; }
.msg details { margin-top: 8px; font-size: .84rem; white-space: normal; }
.msg details summary { cursor: pointer; color: var(--brand); font-weight: 600; }
.msg details ol { margin: 6px 0 0; padding-left: 1.2rem; }
.msg details li { margin-bottom: 4px; color: var(--muted); }
.msg img { display: block; width: 100%; max-width: 300px; border-radius: 10px; margin: 8px 0; border: 1px solid var(--line); }
.msg .actions { display: flex; gap: 6px; flex-wrap: wrap; margin-top: 8px; white-space: normal; }
.typing { color: var(--muted); font-style: italic; }
.chips { display: flex; flex-wrap: wrap; gap: 6px; padding: 0 14px 8px; background: #FFFCF8; }
.chip { font: inherit; font-size: .82rem; background: #fff; border: 1px solid var(--brand); color: var(--brand); border-radius: 99px; padding: 4px 10px; cursor: pointer; text-align: left; }
.chip:hover { background: var(--brand); color: var(--brand-ink); }
#chat-form { display: flex; gap: 8px; padding: 10px; border-top: 1px solid var(--line); background: #fff; }
#chat-input { flex: 1; min-width: 0; font: inherit; padding: 9px 11px; border: 1px solid #b9a894; border-radius: 99px; }
#chat-send { flex: none; }
.hint { font-size: .75rem; color: var(--muted); padding: 0 12px 8px; background: #fff; }

@media (max-width: 520px) {
  #chat-panel { right: 0; left: 0; bottom: 0; top: 0; width: 100%; max-width: 100%; height: 100%; max-height: 100%; border-radius: 0; }
  #chat-toggle { right: 12px; bottom: 12px; }
}
@media (prefers-reduced-motion: no-preference) { #chat-panel { animation: pop .16s ease-out; } @keyframes pop { from { transform: translateY(8px); opacity: 0; } } }
