:root {
  --bg: #f4f1ea; --panel: #ffffff; --ink: #1c2733; --muted: #6b7280; --line: #e2ddd2;
  --brand: #1c2733; --accent: #b45309; --rep: #dbeafe; --seller: #ffffff; --coach: #fef3c7; --danger: #b91c1c;
  --radius: 14px;
}
@media (prefers-color-scheme: dark) {
  :root { --bg: #11161c; --panel: #1a222b; --ink: #e8e6e1; --muted: #9aa3ad; --line: #2b3540; --brand: #0b1117; --rep: #1e3a5f; --seller: #1f2933; --coach: #3b2f12; }
}
* { box-sizing: border-box; }
html, body { height: 100%; margin: 0; }
body { background: var(--bg); color: var(--ink); font: 16px/1.45 -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif; -webkit-text-size-adjust: 100%; }
button, input, select, textarea { font: inherit; color: inherit; }
button { cursor: pointer; border: 1px solid var(--line); background: var(--panel); border-radius: 10px; padding: 8px 12px; }
button.primary { background: var(--accent); border-color: var(--accent); color: #fff; font-weight: 600; }
button.ghost { background: transparent; }
button.danger { color: var(--danger); border-color: var(--danger); }
button.link { border: 0; background: none; color: var(--muted); text-decoration: underline; padding: 4px; }
button.icon { padding: 6px 9px; }
button:disabled { opacity: .5; cursor: default; }
input, select, textarea { background: var(--panel); border: 1px solid var(--line); border-radius: 10px; padding: 9px 10px; width: 100%; font-size: 16px; }
.muted { color: var(--muted); } .small { font-size: 13px; } .error { color: var(--danger); min-height: 1.4em; }
[hidden] { display: none !important; }

.login { min-height: 100%; display: grid; place-items: center; padding: 24px; }
.login form { width: min(360px, 100%); background: var(--panel); padding: 24px; border-radius: var(--radius); border: 1px solid var(--line); display: grid; gap: 12px; }
.login h1 { margin: 0; } .login label { display: grid; gap: 4px; font-size: 14px; }

.app { height: 100dvh; display: flex; flex-direction: column; max-width: 820px; margin: 0 auto; }
.top { display: flex; justify-content: space-between; align-items: center; gap: 8px; padding: calc(8px + env(safe-area-inset-top)) 12px 8px; background: var(--brand); color: #fff; }
.top button { background: transparent; color: #fff; border-color: rgba(255,255,255,.3); }
.top .link { color: #cbd5e1; }
.modes { display: flex; background: rgba(255,255,255,.1); border-radius: 12px; padding: 3px; }
.modes button { border: 0; border-radius: 9px; padding: 7px 14px; font-weight: 600; }
.modes button[aria-selected="true"] { background: #fff; color: var(--brand); }
.tools { display: flex; gap: 6px; align-items: center; }
.settings { padding: 10px 12px; background: var(--panel); border-bottom: 1px solid var(--line); }
.settings label { display: grid; gap: 4px; font-size: 14px; max-width: 320px; }

.pane { flex: 1; min-height: 0; display: flex; flex-direction: column; padding: 10px 12px 0; }
.start { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); padding: 12px 14px; margin-bottom: 10px; }
.start p { margin: 0 0 10px; }
.row { display: flex; gap: 10px; align-items: end; flex-wrap: wrap; }
.row label { display: grid; gap: 4px; font-size: 14px; }
.row.between { justify-content: space-between; align-items: center; margin: 6px 2px; }
.log { flex: 1; min-height: 0; overflow-y: auto; display: flex; flex-direction: column; gap: 8px; padding: 4px 0 12px; -webkit-overflow-scrolling: touch; }

.msg { max-width: 88%; padding: 9px 12px; border-radius: var(--radius); border: 1px solid var(--line); white-space: pre-wrap; word-wrap: break-word; }
.msg .who { display: block; font-size: 12px; color: var(--muted); margin-bottom: 2px; font-weight: 600; }
.msg.rep { align-self: flex-end; background: var(--rep); border-color: transparent; }
.msg.seller { align-self: flex-start; background: var(--seller); }
.msg.coach { align-self: stretch; max-width: 100%; background: var(--coach); border-color: #f59e0b; }
.msg.system { align-self: center; background: transparent; border: 0; color: var(--muted); font-size: 13px; text-align: center; }
.grade { align-self: stretch; max-width: 100%; background: var(--panel); border: 2px solid var(--accent); }
.grade a { color: var(--accent); font-weight: 600; }

.prop { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); padding: 8px 12px; }
.prop summary { cursor: pointer; font-weight: 600; }
.prop .grid { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; margin-top: 8px; }
.prop label { display: grid; gap: 3px; font-size: 13px; }
.card { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); padding: 12px 14px; }
.card .heard { font-size: 14px; color: var(--muted); margin-bottom: 8px; }
.card .say { font-size: 20px; line-height: 1.35; font-weight: 650; }
.card .label { display: block; font-size: 11px; letter-spacing: .06em; text-transform: uppercase; color: var(--accent); font-weight: 700; margin: 8px 0 2px; }
.card .ask { font-size: 17px; }
.card .another { font-size: 13px; padding: 4px 0 0; }
.card .tag { margin-top: 8px; font-size: 12px; color: var(--muted); }

.listen { flex: 1; min-height: 0; display: flex; flex-direction: column; gap: 8px; padding-bottom: 8px; }
.disclose { display: flex; gap: 10px; align-items: center; justify-content: space-between; background: var(--coach); border: 1px solid #f59e0b; border-radius: var(--radius); padding: 10px 12px; }
.lcCards { display: flex; flex-direction: column; gap: 8px; }
.lcCards .card:not(:first-child) { opacity: .75; }
.lcCards .card:not(:first-child) .say { font-size: 16px; }
.lcTranscript { flex: 1; min-height: 90px; overflow-y: auto; background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); padding: 8px 10px; font-size: 14px; }
.lcLine { margin: 3px 0; } .lcLine.seller b { color: var(--accent); } .lcLine.john b { color: var(--muted); }
button.small { padding: 5px 10px; font-size: 14px; }
button.stop { background: var(--danger); border-color: var(--danger); color: #fff; }
.composer { padding: 8px 12px calc(10px + env(safe-area-inset-bottom)); border-top: 1px solid var(--line); background: var(--bg); }
.actions { display: flex; gap: 8px; margin-bottom: 8px; }
.actions button { flex: 1; }
.inputRow { display: flex; gap: 8px; align-items: flex-end; }
.inputRow textarea { resize: none; max-height: 30vh; }
.mic { font-size: 22px; min-width: 52px; min-height: 46px; touch-action: none; user-select: none; -webkit-user-select: none; -webkit-touch-callout: none; }
.mic.live { background: var(--danger); border-color: var(--danger); color: #fff; animation: pulse 1s infinite; }
@keyframes pulse { 50% { transform: scale(1.06); } }
.status { min-height: 1.2em; margin: 4px 2px 0; }

@media (max-width: 480px) {
  .modes button { padding: 7px 10px; }
  .prop .grid { grid-template-columns: 1fr; }
  .card .say { font-size: 19px; }
  #settingsBtn { display: inline-block; }
}
