/* ============================================================
   English Speaking Master — styles
   Palette: warm paper + coral (action) + teal (structure/feedback)
   + butter (reward). Display: Bricolage Grotesque. Mono: JetBrains Mono.
   ============================================================ */

:root {
  --bg: #f4f1ea;
  --paper: #fbf9f4;
  --card: #ffffff;
  --ink: #211d2e;
  --muted: #6b6480;
  --line: #e6e0d4;
  --coral: #ff5c49;
  --coral-ink: #c8341f;
  --teal: #0e7c7b;
  --teal-soft: #e0f0ef;
  --butter: #ffc24b;
  --shadow: 0 1px 0 rgba(33, 29, 46, 0.04), 0 14px 32px -18px rgba(33, 29, 46, 0.35);
  --radius: 18px;
  --rail-w: 268px;
  font-synthesis: none;
}

* { box-sizing: border-box; }

html, body { margin: 0; padding: 0; }

body {
  background:
    radial-gradient(circle at 1px 1px, rgba(33, 29, 46, 0.05) 1px, transparent 0) 0 0 / 22px 22px,
    var(--bg);
  color: var(--ink);
  font-family: "Inter", "Noto Sans SC", system-ui, sans-serif;
  -webkit-font-smoothing: antialiased;
  line-height: 1.5;
}

.mono { font-family: "JetBrains Mono", ui-monospace, monospace; }
.label { font-size: 11px; letter-spacing: 0.12em; color: var(--muted); text-transform: uppercase; }
.muted { color: var(--muted); }
h1, h2, h3, .brand strong { font-family: "Bricolage Grotesque", sans-serif; letter-spacing: -0.01em; }

/* ---------------- App layout ---------------- */
.app {
  display: grid;
  grid-template-columns: var(--rail-w) 1fr;
  min-height: 100vh;
}

/* ---------------- Sidebar ---------------- */
.rail {
  position: sticky;
  top: 0;
  align-self: start;
  height: 100vh;
  padding: 26px 22px;
  display: flex;
  flex-direction: column;
  gap: 22px;
  background: var(--paper);
  border-right: 1px solid var(--line);
}

.brand { display: flex; align-items: center; gap: 12px; }
.brand__mark {
  width: 42px; height: 42px; border-radius: 12px;
  background: var(--ink);
  display: flex; align-items: center; justify-content: center; gap: 3px;
  flex-shrink: 0;
}
.brand__mark .wave {
  width: 3px; border-radius: 3px; background: var(--coral);
  animation: eq 1.1s ease-in-out infinite;
}
.brand__mark .wave:nth-child(1) { height: 10px; animation-delay: 0s; }
.brand__mark .wave:nth-child(2) { height: 20px; background: var(--butter); animation-delay: 0.18s; }
.brand__mark .wave:nth-child(3) { height: 14px; background: var(--teal); animation-delay: 0.36s; }
.brand__mark .wave:nth-child(4) { height: 22px; background: var(--coral); animation-delay: 0.1s; }
@keyframes eq { 0%, 100% { transform: scaleY(0.5); } 50% { transform: scaleY(1); } }
.brand__text { display: flex; flex-direction: column; line-height: 1.2; }
.brand__text strong { font-size: 16px; font-weight: 800; }
.brand__text span { font-size: 11px; color: var(--muted); }

.today-card {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 14px 16px;
  box-shadow: var(--shadow);
}
.today-card__row { display: flex; justify-content: space-between; font-size: 11px; color: var(--muted); }
.today-card__theme {
  font-family: "Bricolage Grotesque", sans-serif;
  font-weight: 700; font-size: 19px; margin: 6px 0 10px;
}
.streak { display: flex; align-items: center; gap: 8px; font-size: 12px; }
.streak__flame { color: var(--coral); font-size: 10px; }
.streak b { color: var(--coral-ink); }

.nav { display: flex; flex-direction: column; gap: 2px; }
.nav__item {
  display: flex; align-items: baseline; gap: 10px;
  border: 0; background: none; cursor: pointer;
  padding: 11px 14px; border-radius: 12px; text-align: left;
  color: var(--ink); font-size: 15px; font-weight: 500;
  transition: background 0.15s;
}
.nav__item em { font-style: normal; font-size: 11px; color: var(--muted); font-family: "JetBrains Mono", monospace; }
.nav__item:hover { background: rgba(33, 29, 46, 0.04); }
.nav__item.is-active { background: var(--ink); color: #fff; }
.nav__item.is-active em { color: rgba(255, 255, 255, 0.55); }

.rail__foot { margin-top: auto; display: flex; flex-direction: column; gap: 8px; }
.level-select, .topic-select {
  width: 100%; padding: 9px 12px; border-radius: 10px;
  border: 1px solid var(--line); background: var(--card); color: var(--ink);
  font-family: inherit; font-size: 14px; cursor: pointer;
}

/* ---------------- Main ---------------- */
.main { padding: 40px clamp(20px, 5vw, 64px) 96px; max-width: 920px; }
.view { display: none; }
.view.is-active { display: block; animation: fade 0.35s ease; }
@keyframes fade { from { opacity: 0; transform: translateY(6px); } to { opacity: 1; transform: none; } }

.view__head { margin-bottom: 26px; }
.eyebrow { font-size: 11px; letter-spacing: 0.18em; color: var(--coral-ink); margin: 0 0 8px; }
.view__head h1 { font-size: clamp(28px, 4.5vw, 40px); font-weight: 800; margin: 0 0 8px; line-height: 1.05; }
.view__head .sub { color: var(--muted); margin: 0; max-width: 52ch; }
.view__head b { color: var(--ink); }

/* ---------------- Step progress strip ---------------- */
.steps { list-style: none; display: flex; gap: 8px; padding: 0; margin: 0 0 22px; }
.steps li {
  flex: 1; height: 6px; border-radius: 4px; background: var(--line);
  position: relative; cursor: pointer; transition: background 0.2s;
}
.steps li.done { background: var(--teal); }
.steps li.active { background: var(--coral); }

/* ---------------- Step cards ---------------- */
.step-card {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 22px 24px;
  margin-bottom: 16px;
  box-shadow: var(--shadow);
}
.step-card__head { display: flex; align-items: center; gap: 12px; margin-bottom: 6px; }
.step-card__head h2 { font-size: 18px; font-weight: 700; margin: 0; flex: 1; }
.step-no { font-size: 11px; color: #fff; background: var(--ink); padding: 4px 8px; border-radius: 7px; letter-spacing: 0.04em; }
.step-card__min { font-size: 11px; color: var(--muted); }
.step-card__desc { color: var(--muted); margin: 4px 0 16px; font-size: 14px; }
.step-card__desc b { color: var(--coral-ink); }
.step-card--hero { border-color: rgba(255, 92, 73, 0.4); background: linear-gradient(180deg, #fff, #fff6f4); }

/* ---------------- Buttons ---------------- */
.btn {
  font-family: inherit; font-size: 14px; font-weight: 600; cursor: pointer;
  border-radius: 11px; padding: 10px 16px; border: 1px solid var(--line);
  background: var(--card); color: var(--ink); transition: transform 0.08s, background 0.15s, border-color 0.15s;
  display: inline-flex; align-items: center; gap: 7px;
}
.btn:active { transform: translateY(1px); }
.btn--solid { background: var(--ink); color: #fff; border-color: var(--ink); }
.btn--ghost:hover { border-color: var(--ink); }
.btn--mic { border-color: var(--coral); color: var(--coral-ink); background: #fff; }
.btn--mic.is-rec { background: var(--coral); color: #fff; }
.btn--mic .dot { width: 9px; height: 9px; border-radius: 50%; background: currentColor; }
.btn--mic.is-rec .dot { animation: blink 1s infinite; }
@keyframes blink { 50% { opacity: 0.25; } }
.btn--mini { padding: 8px 12px; border-color: var(--teal); color: var(--teal); font-weight: 700; }
.btn[disabled] { opacity: 0.5; cursor: not-allowed; }

/* ---------------- Shadowing ---------------- */
.shadow__target { font-size: 22px; font-weight: 600; font-family: "Bricolage Grotesque", sans-serif; margin: 0 0 16px; }
.shadow__controls { display: flex; flex-wrap: wrap; gap: 10px; }
.shadow__result { margin-top: 16px; padding: 14px 16px; background: var(--paper); border-radius: 12px; border: 1px solid var(--line); }
.shadow__score { font-family: "JetBrains Mono", monospace; font-size: 13px; margin-bottom: 8px; }
.shadow__score b { font-size: 22px; color: var(--teal); }
.w-hit { color: var(--teal); font-weight: 600; }
.w-miss { color: var(--muted); text-decoration: line-through; }
.heard { color: var(--ink); }

/* ---------------- Expressions ---------------- */
.exprs { display: flex; flex-direction: column; gap: 8px; }
.expr {
  display: flex; align-items: center; gap: 12px; padding: 12px 14px;
  border: 1px solid var(--line); border-radius: 12px; cursor: pointer; background: var(--paper);
  transition: border-color 0.15s, background 0.15s;
}
.expr:hover { border-color: var(--coral); }
.expr.said { background: var(--teal-soft); border-color: var(--teal); }
.expr__text { flex: 1; font-size: 16px; }
.expr__play { font-size: 16px; opacity: 0.6; }
.expr__check { width: 22px; height: 22px; border-radius: 50%; border: 2px solid var(--line); flex-shrink: 0; display: grid; place-items: center; color: #fff; font-size: 12px; }
.expr.said .expr__check { background: var(--teal); border-color: var(--teal); }
.exprs__foot { display: flex; justify-content: space-between; align-items: center; margin-top: 14px; font-size: 12px; color: var(--muted); }

/* ---------------- Speak dial (signature) ---------------- */
.dial-wrap { display: grid; place-items: center; padding: 20px 0 8px; }
.dial {
  position: relative; width: 220px; height: 220px; border: 0; background: none; cursor: pointer;
  display: grid; place-items: center;
}
.dial__ring { position: absolute; inset: 0; transform: rotate(-90deg); }
.dial__track { fill: none; stroke: var(--line); stroke-width: 8; }
.dial__pulse {
  fill: none; stroke: var(--coral); stroke-width: 8; stroke-linecap: round;
  stroke-dasharray: 578; stroke-dashoffset: 578; transition: stroke-dashoffset 0.3s linear;
}
.dial__face {
  width: 168px; height: 168px; border-radius: 50%; background: #fff;
  box-shadow: var(--shadow); display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 2px;
  transition: transform 0.15s;
}
.dial.is-rec .dial__face { background: var(--coral); color: #fff; }
.dial__icon { font-size: 30px; }
.dial__time { font-size: 28px; font-weight: 700; }
.dial__hint { font-size: 12px; color: var(--muted); }
.dial.is-rec .dial__hint { color: rgba(255, 255, 255, 0.8); }
.dial.is-rec .dial__face { animation: live 1.2s ease-in-out infinite; }
@keyframes live { 0%, 100% { transform: scale(1); } 50% { transform: scale(1.015); } }

.topic-row { display: flex; align-items: center; gap: 12px; margin-bottom: 8px; }
.topic-select { width: auto; flex: 1; max-width: 320px; }
.topic-result { margin-top: 12px; }

/* feedback card */
.fb { background: var(--paper); border: 1px solid var(--line); border-radius: 14px; padding: 16px 18px; }
.fb__top { display: flex; align-items: center; gap: 14px; margin-bottom: 12px; }
.fb__score { width: 56px; height: 56px; border-radius: 50%; background: var(--teal); color: #fff; display: grid; place-items: center; font-family: "JetBrains Mono", monospace; font-weight: 700; font-size: 20px; flex-shrink: 0; }
.fb__transcript { flex: 1; font-size: 14px; color: var(--ink); font-style: italic; }
.fb h4 { font-size: 12px; letter-spacing: 0.08em; text-transform: uppercase; color: var(--muted); margin: 12px 0 6px; font-family: "JetBrains Mono", monospace; }
.fb ul { margin: 0; padding-left: 18px; }
.fb li { margin: 3px 0; font-size: 14px; }
.fb .wrong { color: var(--coral-ink); text-decoration: line-through; }
.fb .better { color: var(--teal); font-weight: 600; }
.fb__tip { margin-top: 10px; padding: 10px 12px; background: #fff; border-left: 3px solid var(--butter); border-radius: 8px; font-size: 14px; }

/* ---------------- Chat ---------------- */
.chat__log { display: flex; flex-direction: column; gap: 10px; min-height: 120px; max-height: 360px; overflow-y: auto; padding: 4px; }
.bubble { max-width: 78%; padding: 10px 14px; border-radius: 14px; font-size: 15px; line-height: 1.45; }
.bubble--ai { background: var(--paper); border: 1px solid var(--line); align-self: flex-start; border-bottom-left-radius: 4px; }
.bubble--me { background: var(--ink); color: #fff; align-self: flex-end; border-bottom-right-radius: 4px; }
.bubble__fix { display: block; margin-bottom: 6px; padding: 6px 10px; background: #fff4e6; border: 1px solid var(--butter); border-radius: 8px; font-size: 13px; color: var(--coral-ink); }
.bubble__fix b { color: var(--teal); }
.chat__bar { display: flex; gap: 8px; margin-top: 14px; align-items: center; }
.chat__mic { width: 44px; height: 44px; border-radius: 12px; border: 1px solid var(--coral); background: #fff; cursor: pointer; display: grid; place-items: center; flex-shrink: 0; }
.chat__mic .dot { width: 12px; height: 12px; border-radius: 50%; background: var(--coral); }
.chat__mic.is-rec { background: var(--coral); }
.chat__mic.is-rec .dot { background: #fff; animation: blink 1s infinite; }
.chat__bar input { flex: 1; padding: 11px 14px; border-radius: 12px; border: 1px solid var(--line); font-family: inherit; font-size: 15px; }
.chat__bar input:focus { outline: 2px solid var(--coral); outline-offset: -1px; }
.chat__count { margin-top: 8px; font-size: 12px; color: var(--muted); text-align: right; }
.typing span { display: inline-block; width: 6px; height: 6px; margin: 0 1px; border-radius: 50%; background: var(--muted); animation: blink 1.2s infinite; }
.typing span:nth-child(2) { animation-delay: 0.2s; } .typing span:nth-child(3) { animation-delay: 0.4s; }

/* ---------------- Logbook / add rows ---------------- */
.logbook { display: grid; grid-template-columns: repeat(3, 1fr); gap: 14px; }
.logbook__col { display: flex; flex-direction: column; gap: 6px; }
.add-row { display: flex; gap: 6px; }
.add-row input { flex: 1; padding: 9px 12px; border-radius: 10px; border: 1px solid var(--line); font-family: inherit; font-size: 14px; }
.add-row--lg input { padding: 12px 16px; font-size: 15px; }

/* ---------------- Checklist ---------------- */
.check { list-style: none; padding: 0; margin: 0; display: grid; grid-template-columns: repeat(2, 1fr); gap: 8px; }
.check li { display: flex; align-items: center; gap: 10px; padding: 11px 14px; border: 1px solid var(--line); border-radius: 11px; cursor: pointer; font-size: 14px; transition: background 0.15s; }
.check li:hover { background: var(--paper); }
.check li.on { background: var(--teal-soft); border-color: var(--teal); }
.check__box { width: 20px; height: 20px; border-radius: 6px; border: 2px solid var(--line); display: grid; place-items: center; color: #fff; font-size: 12px; flex-shrink: 0; }
.check li.on .check__box { background: var(--teal); border-color: var(--teal); }
.check__note { margin-top: 14px; font-size: 12px; color: var(--muted); }
.checklist-card { border-color: rgba(14, 124, 123, 0.35); }

/* ---------------- Patterns ---------------- */
.pattern-groups { display: flex; flex-direction: column; gap: 16px; }
.pgroup { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); padding: 18px 22px; box-shadow: var(--shadow); }
.pgroup h3 { margin: 0 0 12px; font-size: 16px; }
.pgroup__list { display: flex; flex-wrap: wrap; gap: 8px; }
.pat {
  padding: 9px 14px; border-radius: 999px; border: 1px solid var(--line); background: var(--paper);
  font-size: 15px; cursor: pointer; transition: border-color 0.15s, background 0.15s;
}
.pat:hover { border-color: var(--coral); background: #fff; }
.pat:active { background: var(--coral); color: #fff; }

/* ---------------- Words ---------------- */
.explain { margin-bottom: 28px; }
.explain__out { margin-top: 14px; background: var(--paper); border: 1px solid var(--line); border-left: 3px solid var(--teal); border-radius: 12px; padding: 14px 16px; }
.explain__out .said-line { font-size: 17px; font-weight: 600; }
.block-title { font-size: 16px; margin: 26px 0 12px; display: flex; align-items: baseline; gap: 10px; }
.block-title .mono { font-size: 11px; color: var(--muted); font-weight: 500; }
.chips { display: flex; flex-wrap: wrap; gap: 8px; }
.chip { padding: 8px 14px; border-radius: 10px; border: 1px solid var(--line); background: var(--card); font-size: 14px; cursor: pointer; font-family: "JetBrains Mono", monospace; }
.chip:hover { border-color: var(--teal); color: var(--teal); }
.saved { display: grid; grid-template-columns: repeat(3, 1fr); gap: 14px; margin-top: 26px; }
.saved__group { background: var(--card); border: 1px solid var(--line); border-radius: 14px; padding: 14px 16px; }
.saved__group h4 { margin: 0 0 10px; font-size: 13px; }
.saved__group ul { list-style: none; padding: 0; margin: 0; display: flex; flex-direction: column; gap: 5px; }
.saved__group li { font-size: 14px; display: flex; justify-content: space-between; gap: 8px; align-items: center; }
.saved__group li button { border: 0; background: none; color: var(--muted); cursor: pointer; font-size: 15px; line-height: 1; }
.saved__empty { color: var(--muted); font-size: 13px; }

/* ---------------- Review / panels ---------------- */
.panel { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); padding: 22px 24px; margin-bottom: 16px; box-shadow: var(--shadow); }
.panel textarea, .panel input { width: 100%; padding: 11px 14px; border-radius: 11px; border: 1px solid var(--line); font-family: inherit; font-size: 15px; margin-top: 4px; }
.panel textarea { resize: vertical; }
.stars-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 12px; margin-bottom: 16px; }
.star-row { background: var(--paper); border: 1px solid var(--line); border-radius: 12px; padding: 12px; text-align: center; }
.star-row .stars { font-size: 22px; letter-spacing: 2px; cursor: pointer; margin-top: 6px; }
.star-row .s { color: var(--line); }
.star-row .s.on { color: var(--butter); }
.two-col { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; margin: 12px 0 16px; }
.saved__history { margin-top: 16px; display: flex; flex-direction: column; gap: 8px; }
.rev-item { background: var(--paper); border: 1px solid var(--line); border-radius: 10px; padding: 10px 14px; font-size: 13px; }
.rev-item .mono { color: var(--muted); }
.goals { display: grid; grid-template-columns: repeat(3, 1fr); gap: 12px; }
.goal-mo { background: var(--paper); border: 1px solid var(--line); border-radius: 12px; padding: 14px; }
.goal-mo h4 { margin: 0 0 8px; font-size: 14px; color: var(--coral-ink); }
.goal-mo ul { margin: 0; padding-left: 16px; font-size: 14px; }
.goal-mo li { margin: 4px 0; }

/* ---------------- Plan ---------------- */
.week-table { width: 100%; border-collapse: collapse; }
.week-table td { padding: 11px 12px; border-bottom: 1px solid var(--line); font-size: 15px; }
.week-table td:first-child { font-family: "JetBrains Mono", monospace; color: var(--muted); width: 110px; }
.week-table tr.is-today td { background: var(--teal-soft); }
.week-table tr.is-today td:first-child { color: var(--teal); font-weight: 700; }
.principles { display: flex; flex-direction: column; gap: 14px; }
.principle { display: grid; grid-template-columns: 36px 1fr; gap: 12px; align-items: start; }
.principle .mono { color: var(--coral); font-size: 18px; font-weight: 700; }
.principle b { font-size: 16px; }
.principle p { margin: 4px 0 0; color: var(--muted); font-size: 14px; }
.explain-examples { list-style: none; padding: 0; margin: 12px 0 0; display: flex; flex-direction: column; gap: 8px; }
.explain-examples li { font-size: 15px; }
.explain-examples span { font-family: "JetBrains Mono", monospace; color: var(--coral-ink); }

/* ---------------- Toast ---------------- */
.toast {
  position: fixed; bottom: 28px; left: 50%; transform: translateX(-50%) translateY(20px);
  background: var(--ink); color: #fff; padding: 12px 20px; border-radius: 12px;
  font-size: 14px; opacity: 0; pointer-events: none; transition: opacity 0.25s, transform 0.25s; z-index: 50;
}
.toast.show { opacity: 1; transform: translateX(-50%) translateY(0); }

/* ---------------- Mobile tab bar ---------------- */
.tabbar { display: none; }

/* ---------------- Responsive ---------------- */
@media (max-width: 820px) {
  .app { grid-template-columns: 1fr; }
  .rail {
    position: static; height: auto; flex-direction: row; flex-wrap: wrap; align-items: center;
    gap: 14px; padding: 16px 18px;
  }
  .rail .nav, .rail__foot .label { display: none; }
  .today-card { flex: 1; min-width: 180px; }
  .rail__foot { margin: 0; flex-direction: row; align-items: center; }
  .main { padding: 24px 18px 110px; }
  .logbook, .saved, .stars-grid, .goals { grid-template-columns: 1fr; }
  .check { grid-template-columns: 1fr; }
  .two-col { grid-template-columns: 1fr; }
  .tabbar {
    display: grid; grid-template-columns: repeat(5, 1fr);
    position: fixed; bottom: 0; left: 0; right: 0; z-index: 40;
    background: var(--paper); border-top: 1px solid var(--line);
  }
  .tabbar__item {
    border: 0; background: none; cursor: pointer; padding: 9px 4px 12px;
    display: flex; flex-direction: column; align-items: center; gap: 3px;
    font-size: 11px; color: var(--muted); font-family: inherit;
  }
  .tabbar__item span { font-size: 17px; }
  .tabbar__item.is-active { color: var(--coral-ink); }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation: none !important; transition: none !important; }
}

:focus-visible { outline: 2px solid var(--coral); outline-offset: 2px; }
