/* NJM Call Assistant. One screen, no scrolling: the line, a tip, six buttons. */
:root {
  --bg: #121315;
  --panel: #1b1c20;
  --btn: #25272c;
  --btn-press: #33363d;
  --edge: #34363d;
  --text: #f5f5f6;
  --silver: #a9acb3;
  --dim: #7d8088;
  --accent: #e2b45c;
  --gap: 8px;
  --side: 16px;
  --tap: 48px;
  color-scheme: dark;
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }
html, body { margin: 0; height: 100%; background: var(--bg); color: var(--text); }
body {
  font: 16px/1.4 -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  -webkit-font-smoothing: antialiased;
  -webkit-tap-highlight-color: transparent;
  overflow: hidden;
  overscroll-behavior: none;
}
button { font: inherit; color: inherit; cursor: pointer; touch-action: manipulation; }
button:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }

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

/* ---------- top bar: stage indicator, undo, restart ---------- */
.bar {
  flex: none;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--gap);
  padding: 4px var(--side) 0;
  min-height: 56px;
}
.stage {
  min-height: var(--tap);
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 0 12px 0 10px;
  background: none;
  border: 1px solid var(--edge);
  border-radius: 999px;
  color: var(--silver);
  font-size: 14px;
  font-weight: 600;
  white-space: nowrap;
  max-width: 58%;
  overflow: hidden;
}
#stageLabel { overflow: hidden; text-overflow: ellipsis; }
.stage-dot { width: 8px; height: 8px; border-radius: 50%; background: var(--accent); flex: none; }
.caret { font-size: 11px; color: var(--dim); }
.bar-actions { display: flex; gap: 4px; }
.ghost {
  min-height: var(--tap);
  min-width: var(--tap);
  padding: 0 12px;
  background: none;
  border: 0;
  border-radius: 10px;
  color: var(--silver);
  font-size: 15px;
  font-weight: 600;
}
.ghost:active { background: var(--btn); }
.ghost:disabled { color: #4b4e55; cursor: default; }

/* ---------- main ---------- */
.main {
  flex: 1;
  min-height: 0;
  display: flex;
  flex-direction: column;
  padding: 0 var(--side) 12px;
}

.say {
  flex: 1;
  min-height: 0;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  padding: 4px 0 8px;
}
/* Centred with auto margins rather than justify-content, so a too-long line overflows downwards
   (where fitLine can see it and shrink the text), never off the top. */
.say > :first-child { margin-top: auto; }
.say > :last-child { margin-bottom: auto; }
.say-label {
  font-size: 12px;
  font-weight: 700;
  letter-spacing: .12em;
  text-transform: uppercase;
  color: var(--accent);
  margin-bottom: 8px;
}
.line {
  margin: 0;
  font-size: clamp(21px, 6.1vw, 30px);
  line-height: 1.3;
  font-weight: 600;
  letter-spacing: -.005em;
  text-wrap: pretty;
}
.line.enter { animation: fade .14s ease-out; }
@keyframes fade { from { opacity: .35; } to { opacity: 1; } }

/* ---------- coaching tip (quieter than the script) ---------- */
.coach {
  flex: none;
  display: grid;
  grid-template-columns: 1fr auto;
  align-items: center;
  column-gap: 8px;
  border-top: 1px solid var(--edge);
  padding: 4px 0 10px;
  min-height: 56px;
}
.tip { margin: 0; font-size: 14px; line-height: 1.35; color: var(--silver); }
.why-btn {
  min-height: var(--tap);
  padding: 0 10px;
  background: none;
  border: 0;
  color: var(--dim);
  font-size: 13px;
  text-decoration: underline;
  text-underline-offset: 3px;
  white-space: nowrap;
}
.why { grid-column: 1 / -1; margin: 2px 0 0; font-size: 13px; line-height: 1.4; color: var(--dim); }

/* ---------- the six buttons ---------- */
.replies {
  flex: none;
  display: grid;
  grid-template-columns: 1fr 1fr;
  grid-auto-rows: minmax(56px, auto);
  gap: var(--gap);
}
.reply {
  min-height: 56px;
  padding: 6px 12px;
  background: var(--btn);
  border: 1px solid transparent;
  border-radius: 12px;
  font-size: 17px;
  font-weight: 600;
  line-height: 1.2;
  text-align: left;
  display: flex;
  align-items: center;
}
.reply:active { background: var(--btn-press); }
.reply.neg { color: #d9dadd; border-color: #3b3d44; background: #1f2024; }
.reply.other { background: none; border: 1px dashed #4a4d55; color: var(--silver); justify-content: center; flex-direction: column; gap: 1px; }
.reply.other small { font-size: 11px; font-weight: 500; color: var(--dim); }
.reply { -webkit-touch-callout: none; user-select: none; }

/* ---------- practice mode ---------- */
.said { flex: none; display: grid; grid-template-rows: minmax(184px, auto); align-items: end; }
.said .big { min-height: 64px; }
.line.quote { color: var(--silver); font-style: italic; }
.app.is-practice .stage { border-color: var(--accent); }
.toast {
  position: fixed; left: 50%; top: 64px; transform: translateX(-50%); z-index: 20;
  max-width: calc(100% - 32px); padding: 10px 16px; border-radius: 999px;
  background: var(--text); color: var(--bg); font-size: 15px; font-weight: 700; text-align: center;
}

/* ---------- end of call ---------- */
.ended { flex: none; display: grid; grid-template-columns: 1fr 1fr; gap: var(--gap); }
.big {
  min-height: 64px;
  border-radius: 12px;
  border: 0;
  background: var(--text);
  color: var(--bg);
  font-size: 18px;
  font-weight: 700;
}
.big.secondary { background: var(--btn); color: var(--text); }
.app.is-ended .bar { visibility: hidden; }
.app.is-ended .why-btn { display: none; }
.app.is-ended .say-label { color: var(--silver); }

/* ---------- stage drawer (bottom sheet) ---------- */
.scrim { position: fixed; inset: 0; background: rgba(0, 0, 0, .55); z-index: 10; }
.drawer {
  position: fixed;
  left: 0; right: 0; bottom: 0;
  max-width: 560px;
  margin: 0 auto;
  max-height: 92dvh;
  overflow-y: auto;
  z-index: 11;
  background: var(--panel);
  border-radius: 16px 16px 0 0;
  border-top: 1px solid var(--edge);
  padding: 8px var(--side) calc(16px + env(safe-area-inset-bottom));
}
.drawer-head { display: flex; justify-content: space-between; align-items: center; }
.drawer h2 { font-size: 15px; margin: 0; color: var(--text); }
.drawer-sub { margin-top: 16px !important; margin-bottom: 8px !important; }
.drawer-note { margin: 0 0 8px; font-size: 13px; color: var(--dim); }
.stages, .end-row, .styles, .ask-row, .trades, .levels, .scenarios, .more-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 6px; }
.end-row { grid-template-columns: 1fr 1fr 1fr; }
.styles { grid-template-columns: 1fr 1fr 1fr; }
.trades { grid-template-columns: 1fr 1fr 1fr; }
.levels { grid-template-columns: 1fr 1fr 1fr 1fr; }
.scenarios { grid-template-columns: 1fr 1fr; }
.review { grid-column: 1 / -1; margin: 6px 0 0; padding-left: 18px; font-size: 14px; line-height: 1.35; color: var(--text); }
.review li + li { margin-top: 4px; }
.tip.warn { color: var(--accent); font-weight: 600; }
.more-grid .reply { min-height: 52px; font-size: 16px; }
.wide-btn { width: 100%; margin-top: 8px; min-height: var(--tap); border-radius: 10px; border: 1px solid var(--edge); background: none; color: var(--silver); font-size: 14px; font-weight: 600; }
.wide-btn:disabled { opacity: .4; }
.stages button, .end-btn, .ask-btn, .styles button, .trades button, .levels button, .scenarios button {
  min-height: var(--tap);
  padding: 4px 10px;
  border-radius: 10px;
  border: 1px solid transparent;
  background: var(--btn);
  font-size: 14px;
  font-weight: 600;
  text-align: left;
}
.stages button[aria-current="true"] { border-color: var(--accent); }
.stages button:disabled { opacity: .4; cursor: default; }
.end-btn { text-align: center; color: var(--silver); }
.ask-btn { color: var(--text); }
.styles button, .trades button, .levels button { text-align: center; }
.styles button[aria-checked="true"], .trades button[aria-checked="true"], .levels button[aria-checked="true"], .scenarios button[aria-checked="true"] { background: var(--text); color: var(--bg); }

/* Short phones: tighten everything so the six buttons never leave the screen. */
@media (max-height: 680px) {
  .bar { min-height: 52px; }
  .replies { grid-auto-rows: minmax(52px, auto); }
  .reply { min-height: 52px; font-size: 16px; }
  .coach { min-height: 52px; padding-bottom: 8px; }
  .tip { font-size: 13px; }
}

@media (prefers-reduced-motion: reduce) {
  .line.enter { animation: none; }
}
