:root { --ink: #1b1b1b; --muted: #5f6b67; --bg: #f7f6f2; --card: #fff; --brand: #1f6f5f; --brand-ink: #fff; --line: #d9d7d0; --warn: #9a5b00; --bad: #a32020; --radius: 12px; }
* { box-sizing: border-box; }
[hidden] { display: none !important; }
html, body { margin: 0; background: var(--bg); color: var(--ink); font: 16px/1.45 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif; -webkit-text-size-adjust: 100%; }
body { padding-bottom: env(safe-area-inset-bottom); }
.top { position: sticky; top: 0; z-index: 2; display: flex; align-items: center; gap: 8px; padding: 10px 12px; background: var(--brand); color: var(--brand-ink); }
.top h1 { flex: 1; margin: 0; font-size: 18px; font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.top h1 input { width: 100%; font: inherit; font-weight: 600; padding: 6px 8px; border-radius: 8px; border: 0; background: rgba(255,255,255,.95); color: var(--ink); }
#rename { font-size: 18px; min-width: 40px; }
main { max-width: 720px; margin: 0 auto; padding: 12px; }
h2 { font-size: 20px; margin: 8px 0; }
.muted { color: var(--muted); }
.small { font-size: 14px; }
label { display: block; font-weight: 600; margin: 8px 0 4px; }
input, textarea, select { width: 100%; font: inherit; padding: 12px; border: 1px solid var(--line); border-radius: var(--radius); background: var(--card); color: inherit; }
textarea { resize: vertical; min-height: 52px; }
button, .btn { font: inherit; font-weight: 600; min-height: 48px; padding: 12px 16px; border-radius: var(--radius); border: 1px solid var(--line); background: var(--card); color: var(--ink); cursor: pointer; text-decoration: none; display: inline-flex; align-items: center; justify-content: center; }
button:disabled, .btn[aria-disabled="true"] { opacity: .5; pointer-events: none; }
.primary { background: var(--brand); border-color: var(--brand); color: var(--brand-ink); }
.secondary { background: var(--card); }
.icon-btn { min-width: 44px; min-height: 44px; padding: 0; font-size: 28px; line-height: 1; background: transparent; border: 0; color: inherit; }
.link-btn { background: transparent; border: 0; color: inherit; min-height: 44px; text-decoration: underline; font-weight: 500; }
form { display: grid; gap: 8px; }
#signin-form button { margin-top: 8px; }
.msg { min-height: 1.4em; }
.cards { list-style: none; padding: 0; margin: 12px 0; display: grid; gap: 10px; }
.cards li { display: flex; align-items: center; gap: 12px; padding: 10px; background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); min-height: 64px; cursor: pointer; }
.cards img, .cards .ph { width: 48px; height: 64px; object-fit: cover; border-radius: 6px; background: #eee; flex: none; }
.cards .t { flex: 1; min-width: 0; }
.cards .t b { display: block; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.tag { font-size: 12px; padding: 2px 8px; border-radius: 999px; background: #e7f1ee; color: var(--brand); font-weight: 600; }
#stage { position: relative; background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); min-height: 220px; display: flex; align-items: center; justify-content: center; overflow: hidden; }
#preview { width: 100%; max-height: 70vh; object-fit: contain; display: block; background: #fff; }
#stage-empty { padding: 24px; text-align: center; }
.banner { position: absolute; left: 8px; right: 8px; bottom: 8px; padding: 10px 12px; border-radius: 10px; background: rgba(31,111,95,.92); color: #fff; font-size: 14px; }
.banner.failed { background: rgba(163,32,32,.92); }
.versions { display: flex; gap: 8px; overflow-x: auto; padding: 10px 2px; scrollbar-width: thin; }
.versions button { flex: none; width: 64px; height: 84px; padding: 0; border-radius: 8px; overflow: hidden; position: relative; background: #fff; }
.versions img { width: 100%; height: 100%; object-fit: cover; display: block; }
.versions button[aria-selected="true"] { outline: 3px solid var(--brand); outline-offset: 1px; }
.versions .n { position: absolute; left: 4px; bottom: 4px; font-size: 11px; background: rgba(0,0,0,.65); color: #fff; padding: 1px 5px; border-radius: 6px; }
.versions .kept { position: absolute; right: 4px; top: 4px; font-size: 12px; background: var(--brand); color: #fff; padding: 1px 5px; border-radius: 6px; }
.row { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.row > * { flex: 1; }
.row label { flex: none; margin: 0; }
.panel { margin: 10px 0; padding: 12px; background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); display: grid; gap: 8px; }
.thread { list-style: none; padding: 0; margin: 12px 0; display: grid; gap: 8px; }
.thread li { max-width: 88%; padding: 10px 12px; border-radius: 14px; background: var(--card); border: 1px solid var(--line); white-space: pre-wrap; overflow-wrap: anywhere; }
.thread li.user { margin-left: auto; background: #e7f1ee; border-color: #cfe3dc; }
.thread li.system { margin: 0 auto; font-size: 13px; color: var(--muted); background: transparent; border: 0; text-align: center; }
.thread li .k { display: block; font-size: 12px; color: var(--muted); margin-bottom: 2px; }
.coach { margin-bottom: 8px; display: grid; gap: 6px; }
.checklist { display: flex; flex-wrap: wrap; gap: 6px; align-items: center; font-size: 13px; color: var(--muted); }
.checklist .chip { padding: 3px 10px; border-radius: 999px; border: 1px solid var(--line); background: var(--card); font-weight: 600; }
.checklist .chip.ok { background: #e7f1ee; border-color: #cfe3dc; color: var(--brand); }
.checklist .chip.missing { background: #fff7e6; border-color: #f0d9a8; color: var(--warn); }
.suggest { display: flex; gap: 8px; align-items: center; padding: 10px; background: #fff7e6; border: 1px solid #f0d9a8; border-radius: var(--radius); }
.suggest span { flex: 1; font-size: 14px; }
.suggest button { flex: none; }
#composer { position: sticky; bottom: 0; background: var(--bg); padding: 8px 0 max(8px, env(safe-area-inset-bottom)); grid-template-columns: 1fr auto; }
#send { min-width: 84px; }
.toast { position: fixed; left: 12px; right: 12px; bottom: 90px; padding: 12px 14px; background: #222; color: #fff; border-radius: 10px; font-size: 14px; z-index: 5; }
.warn { color: var(--warn); } .bad { color: var(--bad); }
@media (min-width: 600px) { #preview { max-height: 60vh; } }
.thread li:last-child { scroll-margin-bottom: 150px; }
.thread { padding-bottom: 8px; }
