:root {
  --bg: #09090b;
  --surface: #131316;
  --surface-2: #1a1a1e;
  --line: #27272a;
  --line-soft: #1f1f23;
  --text: #fafafa;
  --muted: #a1a1aa;
  --dim: #71717a;
  --accent: #b45309;
  --danger: #9f1239;
  --radius: 14px;
  --tap: 44px;
}

* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }

html, body {
  margin: 0;
  padding: 0;
  background: var(--bg);
  color: var(--text);
  font-family: -apple-system, BlinkMacSystemFont, "SF Pro Text", "Segoe UI", Roboto, system-ui, sans-serif;
  font-size: 17px;
  line-height: 1.45;
  letter-spacing: -0.011em;
  -webkit-font-smoothing: antialiased;
  overscroll-behavior-y: none;
}

body { min-height: 100dvh; }

button, input, textarea { font: inherit; color: inherit; }
button { background: none; border: none; cursor: pointer; }

.app {
  max-width: 640px;
  margin: 0 auto;
  min-height: 100dvh;
  display: flex;
  flex-direction: column;
  padding: max(14px, env(safe-area-inset-top)) 16px max(14px, env(safe-area-inset-bottom));
}

.screen { display: none; flex: 1; flex-direction: column; }
.screen.on { display: flex; }

/* ---------- typography ---------- */
.eyebrow {
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.09em;
  text-transform: uppercase;
  color: var(--dim);
}
h1 { font-size: 30px; font-weight: 700; letter-spacing: -0.025em; margin: 6px 0 4px; }
h2 { font-size: 20px; font-weight: 650; letter-spacing: -0.02em; margin: 0 0 2px; }
.sub { color: var(--muted); font-size: 15px; margin: 0; }
.section-label {
  font-size: 12px; font-weight: 600; letter-spacing: 0.06em; text-transform: uppercase;
  color: var(--dim); margin: 26px 0 10px;
}

/* ---------- setup ---------- */
.head { padding: 8px 2px 4px; }

.grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 8px;
}
.card {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 14px 14px 13px;
  text-align: left;
  min-height: 82px;
  display: flex;
  flex-direction: column;
  justify-content: center;
  gap: 3px;
  transition: border-color .14s, background .14s;
}
.card:active { background: var(--surface-2); }
.card[aria-pressed="true"] {
  border-color: #52525b;
  background: var(--surface-2);
  box-shadow: inset 0 0 0 1px #3f3f46;
}
.card .t { font-size: 16px; font-weight: 600; letter-spacing: -0.015em; }
.card .d { font-size: 12.5px; color: var(--dim); line-height: 1.3; }

/* ---------- slider ---------- */
.slab {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 16px;
}
.slider-top { display: flex; align-items: baseline; justify-content: space-between; margin-bottom: 2px; }
.level-num { font-size: 30px; font-weight: 700; letter-spacing: -0.03em; font-variant-numeric: tabular-nums; }
.level-name { font-size: 14px; font-weight: 600; color: var(--muted); }
.level-desc { font-size: 13.5px; color: var(--dim); line-height: 1.4; margin-top: 6px; min-height: 38px; }

input[type=range] {
  -webkit-appearance: none; appearance: none;
  width: 100%; height: var(--tap); background: transparent; margin: 8px 0 0; display: block;
}
input[type=range]::-webkit-slider-runnable-track {
  height: 4px; border-radius: 2px; background: #3f3f46;
}
input[type=range]::-moz-range-track { height: 4px; border-radius: 2px; background: #3f3f46; }
input[type=range]::-webkit-slider-thumb {
  -webkit-appearance: none; appearance: none;
  width: 28px; height: 28px; border-radius: 50%;
  background: #fafafa; border: none; margin-top: -12px;
  box-shadow: 0 1px 3px rgba(0,0,0,.6);
}
input[type=range]::-moz-range-thumb {
  width: 28px; height: 28px; border-radius: 50%; background: #fafafa; border: none;
  box-shadow: 0 1px 3px rgba(0,0,0,.6);
}
.ticks { display: flex; justify-content: space-between; font-size: 11px; color: var(--dim); padding: 0 2px; font-variant-numeric: tabular-nums; }

/* ---------- buttons ---------- */
.btn {
  display: flex; align-items: center; justify-content: center; gap: 8px;
  min-height: 52px; width: 100%;
  border-radius: var(--radius);
  font-size: 17px; font-weight: 600; letter-spacing: -0.01em;
  transition: opacity .14s, background .14s;
}
.btn:active { opacity: .82; }
.btn-primary { background: #fafafa; color: #09090b; }
.btn-primary:disabled { opacity: .35; }
.btn-ghost { background: var(--surface); border: 1px solid var(--line); color: var(--text); }
.btn-quiet { background: none; color: var(--muted); min-height: var(--tap); font-size: 15px; font-weight: 500; }
.btn-row { display: flex; gap: 8px; }
.btn-row .btn { flex: 1; }

.foot { margin-top: auto; padding-top: 22px; display: grid; gap: 8px; }

/* ---------- session ---------- */
.bar {
  display: flex; align-items: center; gap: 12px;
  padding: 6px 2px 12px;
  border-bottom: 1px solid var(--line-soft);
}
.avatar {
  width: 42px; height: 42px; border-radius: 50%;
  background: var(--surface-2); border: 1px solid var(--line);
  display: grid; place-items: center;
  font-size: 15px; font-weight: 600; color: var(--muted);
  flex-shrink: 0;
}
.who { flex: 1; min-width: 0; }
.who .n { font-size: 16px; font-weight: 650; letter-spacing: -0.015em; }
.who .c { font-size: 12.5px; color: var(--dim); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.pill {
  font-size: 11px; font-weight: 600; letter-spacing: .04em;
  border: 1px solid var(--line); border-radius: 999px;
  padding: 4px 9px; color: var(--muted); white-space: nowrap;
}

.meter-wrap { padding: 12px 2px 10px; }
.meter-top {
  display: flex; justify-content: space-between; align-items: baseline;
  font-size: 11px; letter-spacing: .07em; text-transform: uppercase; color: var(--dim);
  font-weight: 600; margin-bottom: 7px;
}
.meter-top .read { color: var(--muted); letter-spacing: 0; text-transform: none; font-size: 12.5px; font-weight: 500; }
.meter { height: 5px; border-radius: 3px; background: #232327; overflow: hidden; }
.meter > i { display: block; height: 100%; width: 45%; background: #52525b; transition: width .5s cubic-bezier(.22,.61,.36,1), background-color .5s; }
.delta {
  font-size: 12px; font-variant-numeric: tabular-nums; font-weight: 600;
  opacity: 0; transition: opacity .3s; margin-left: 8px;
}
.delta.up { color: #84cc16; opacity: 1; }
.delta.down { color: #fb7185; opacity: 1; }

/* ---------- transcript ---------- */
.log {
  flex: 1; overflow-y: auto; -webkit-overflow-scrolling: touch;
  display: flex; flex-direction: column; gap: 10px;
  padding: 14px 0 8px; min-height: 0;
}
.msg { max-width: 84%; font-size: 16px; line-height: 1.4; }
.msg .b { padding: 10px 13px; border-radius: 17px; display: inline-block; }
.msg.her { align-self: flex-start; }
.msg.her .b { background: var(--surface-2); border: 1px solid var(--line); border-bottom-left-radius: 5px; }
.msg.me { align-self: flex-end; }
.msg.me .b { background: #fafafa; color: #09090b; border-bottom-right-radius: 5px; }
.msg.sys { align-self: center; max-width: 100%; text-align: center; }
.msg.sys .b {
  background: none; border: none; color: var(--dim); font-size: 13px; padding: 4px 0;
}
.thinking { display: inline-flex; gap: 4px; align-items: center; padding: 12px 14px; }
.thinking i { width: 6px; height: 6px; border-radius: 50%; background: var(--dim); animation: bob 1.1s infinite; }
.thinking i:nth-child(2) { animation-delay: .16s; }
.thinking i:nth-child(3) { animation-delay: .32s; }
@keyframes bob { 0%,60%,100% { opacity: .25; transform: translateY(0); } 30% { opacity: .9; transform: translateY(-3px); } }

/* ---------- input dock ---------- */
.dock { padding-top: 10px; border-top: 1px solid var(--line-soft); }
.dock-row { display: flex; align-items: flex-end; gap: 9px; }
.mic {
  width: 56px; height: 56px; border-radius: 50%; flex-shrink: 0;
  background: #fafafa; color: #09090b;
  display: grid; place-items: center;
  transition: transform .12s, background .18s;
}
.mic:active { transform: scale(.94); }
.mic.live { background: var(--danger); color: #fff; animation: pulse 1.6s ease-in-out infinite; }
.mic:disabled { opacity: .35; }
@keyframes pulse { 0%,100% { box-shadow: 0 0 0 0 rgba(159,18,57,.5); } 50% { box-shadow: 0 0 0 11px rgba(159,18,57,0); } }
.mic svg { width: 24px; height: 24px; }

.field {
  flex: 1; min-height: 56px; max-height: 128px;
  background: var(--surface); border: 1px solid var(--line);
  border-radius: 26px; padding: 16px 17px; resize: none; outline: none;
  font-size: 16px; line-height: 1.35;
}
.field:focus { border-color: #3f3f46; }
.field::placeholder { color: var(--dim); }
.send {
  width: 56px; height: 56px; border-radius: 50%; flex-shrink: 0;
  background: var(--surface); border: 1px solid var(--line); color: var(--text);
  display: grid; place-items: center;
}
.send:disabled { opacity: .3; }
.send svg { width: 21px; height: 21px; }

.dock-foot { display: flex; justify-content: space-between; align-items: center; padding-top: 9px; }
.hint { font-size: 12px; color: var(--dim); }

/* ---------- report ---------- */
.big-score { text-align: center; padding: 20px 0 8px; }
.big-score .n { font-size: 68px; font-weight: 700; letter-spacing: -0.045em; line-height: 1; font-variant-numeric: tabular-nums; }
.big-score .l { font-size: 12px; letter-spacing: .09em; text-transform: uppercase; color: var(--dim); font-weight: 600; margin-top: 6px; }
.headline { text-align: center; color: var(--muted); font-size: 15.5px; padding: 10px 4px 4px; line-height: 1.45; }

.metric { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 14px; margin-bottom: 8px; }
.metric-top { display: flex; justify-content: space-between; align-items: baseline; gap: 10px; }
.metric-top .k { font-size: 12px; letter-spacing: .07em; text-transform: uppercase; color: var(--dim); font-weight: 600; }
.metric-top .v { font-size: 22px; font-weight: 700; font-variant-numeric: tabular-nums; letter-spacing: -0.02em; }
.metric .verdict { font-size: 15px; font-weight: 600; margin-top: 3px; }
.metric .note { font-size: 14.5px; color: var(--muted); margin-top: 5px; line-height: 1.45; }
.metric .rewrite {
  margin-top: 10px; padding: 10px 12px; border-left: 2px solid var(--accent);
  background: #17171a; border-radius: 0 8px 8px 0; font-size: 14.5px; color: #d4d4d8;
}
.metric .rewrite b { display: block; font-size: 11px; letter-spacing: .07em; text-transform: uppercase; color: var(--dim); margin-bottom: 3px; font-weight: 600; }

ul.list { list-style: none; padding: 0; margin: 0; display: grid; gap: 7px; }
ul.list li {
  font-size: 14.5px; color: var(--muted); line-height: 1.45;
  padding-left: 18px; position: relative;
}
ul.list li::before { content: ""; position: absolute; left: 4px; top: 9px; width: 5px; height: 5px; border-radius: 50%; background: var(--dim); }
ul.list.good li::before { background: #65a30d; }
ul.list.bad li::before { background: #be123c; }

.takeaway { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 15px; margin-bottom: 8px; }
.takeaway .num { font-size: 11px; font-weight: 700; letter-spacing: .09em; color: var(--accent); }
.takeaway .t { font-size: 16.5px; font-weight: 650; letter-spacing: -0.015em; margin-top: 3px; }
.takeaway .w { font-size: 14.5px; color: var(--muted); margin-top: 5px; line-height: 1.45; }
.takeaway .drill { margin-top: 10px; padding-top: 10px; border-top: 1px solid var(--line-soft); font-size: 14.5px; line-height: 1.45; }
.takeaway .drill b { display: block; font-size: 11px; letter-spacing: .07em; text-transform: uppercase; color: var(--dim); margin-bottom: 3px; font-weight: 600; }

/* ---------- sheet ---------- */
.sheet-bg {
  position: fixed; inset: 0; background: rgba(0,0,0,.6); z-index: 40;
  display: none; align-items: flex-end;
}
.sheet-bg.on { display: flex; }
.sheet {
  width: 100%; max-width: 640px; margin: 0 auto;
  background: #141417; border-top: 1px solid var(--line);
  border-radius: 18px 18px 0 0;
  padding: 8px 16px max(20px, env(safe-area-inset-bottom));
  max-height: 82dvh; overflow-y: auto;
  animation: rise .24s cubic-bezier(.22,.61,.36,1);
}
@keyframes rise { from { transform: translateY(18px); opacity: .6; } to { transform: translateY(0); opacity: 1; } }
.grabber { width: 36px; height: 4px; border-radius: 2px; background: #3f3f46; margin: 6px auto 12px; }

.opt {
  display: flex; align-items: center; justify-content: space-between; gap: 12px;
  width: 100%; min-height: var(--tap); padding: 11px 2px;
  border-bottom: 1px solid var(--line-soft); text-align: left;
}
.opt:last-of-type { border-bottom: none; }
.opt .on-name { font-size: 15.5px; }
.opt .on-sub { font-size: 12.5px; color: var(--dim); }
.opt .tick { color: var(--text); opacity: 0; font-size: 17px; }
.opt[aria-pressed="true"] .tick { opacity: 1; }

.toggle-row { display: flex; align-items: center; justify-content: space-between; gap: 14px; padding: 13px 2px; border-bottom: 1px solid var(--line-soft); }
.toggle-row .tl { font-size: 15.5px; }
.toggle-row .ts { font-size: 12.5px; color: var(--dim); margin-top: 1px; }
.switch { width: 50px; height: 30px; border-radius: 15px; background: #3f3f46; position: relative; flex-shrink: 0; transition: background .18s; }
.switch::after { content: ""; position: absolute; top: 3px; left: 3px; width: 24px; height: 24px; border-radius: 50%; background: #fff; transition: transform .18s; }
.switch[aria-pressed="true"] { background: #4d7c0f; }
.switch[aria-pressed="true"]::after { transform: translateX(20px); }

.banner {
  background: #201510; border: 1px solid #3a2415; color: #e7b08a;
  border-radius: 11px; padding: 11px 13px; font-size: 13.5px; line-height: 1.4; margin-bottom: 10px;
}
.banner b { color: #f5c9a8; }

.scroll { flex: 1; overflow-y: auto; -webkit-overflow-scrolling: touch; min-height: 0; }
