:root {
  color-scheme: light;
  --bg: #f7faf9;
  --panel: #ffffff;
  --panel-soft: #eef6f2;
  --ink: #18211f;
  --muted: #61706b;
  --line: #dce6e1;
  --teal: #0f766e;
  --teal-dark: #115e59;
  --teal-soft: #d9f0ec;
  --coral: #c2410c;
  --coral-soft: #ffedd5;
  --indigo: #4338ca;
  --indigo-soft: #e0e7ff;
  --amber: #b45309;
  --amber-soft: #fef3c7;
  --danger: #b91c1c;
  --shadow: 0 18px 40px rgba(20, 32, 29, 0.08);
  --radius: 8px;
  --sidebar: 312px;
}

* {
  box-sizing: border-box;
}

html {
  min-width: 320px;
  background: var(--bg);
}

body {
  margin: 0;
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  color: var(--ink);
  background:
    linear-gradient(180deg, rgba(15, 118, 110, 0.08), rgba(247, 250, 249, 0) 260px),
    var(--bg);
}

button,
input,
textarea,
select {
  font: inherit;
}

button {
  cursor: pointer;
}

button:disabled {
  cursor: not-allowed;
  opacity: 0.55;
}

.app-shell {
  min-height: 100vh;
  display: grid;
  grid-template-columns: var(--sidebar) minmax(0, 1fr);
}

.sidebar {
  position: sticky;
  top: 0;
  height: 100vh;
  padding: 24px 18px;
  border-right: 1px solid var(--line);
  background: rgba(255, 255, 255, 0.82);
  backdrop-filter: blur(14px);
  overflow: auto;
}

.brand {
  display: flex;
  gap: 12px;
  align-items: center;
  margin-bottom: 22px;
}

.brand-mark {
  width: 44px;
  height: 44px;
  display: grid;
  place-items: center;
  border-radius: var(--radius);
  color: white;
  background: var(--teal);
  box-shadow: 0 12px 24px rgba(15, 118, 110, 0.18);
}

.brand h1 {
  margin: 0;
  font-size: 18px;
  line-height: 1.1;
}

.brand p {
  margin: 3px 0 0;
  color: var(--muted);
  font-size: 13px;
}

.sidebar-section {
  margin-top: 22px;
}

.section-label {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  margin: 0 0 10px;
  color: var(--muted);
  font-size: 12px;
  font-weight: 800;
  letter-spacing: 0;
  text-transform: uppercase;
}

.day-grid {
  display: grid;
  grid-template-columns: repeat(5, minmax(0, 1fr));
  gap: 6px;
}

.day-button {
  height: 38px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  color: var(--ink);
  background: var(--panel);
}

.day-button:hover {
  border-color: var(--teal);
}

.day-button.active {
  color: #fff;
  border-color: var(--teal);
  background: var(--teal);
}

.day-button.done {
  border-color: #95d5ca;
  background: var(--teal-soft);
}

.day-button.active,
.day-button.active.done {
  color: #fff;
  border-color: var(--teal);
  background: var(--teal);
}

.main {
  min-width: 0;
  padding: 24px;
}

.topbar {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 18px;
  align-items: start;
  margin: 0 auto 18px;
  max-width: 1180px;
}

.headline {
  min-width: 0;
}

.kicker {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-bottom: 8px;
}

.pill {
  display: inline-flex;
  min-height: 28px;
  align-items: center;
  gap: 6px;
  padding: 5px 9px;
  border: 1px solid var(--line);
  border-radius: 999px;
  color: var(--muted);
  background: rgba(255, 255, 255, 0.76);
  font-size: 12px;
  font-weight: 750;
  white-space: nowrap;
}

.pill.teal {
  color: var(--teal-dark);
  border-color: #9ad6cc;
  background: var(--teal-soft);
}

.pill.coral {
  color: var(--coral);
  border-color: #fed7aa;
  background: var(--coral-soft);
}

.topic-title {
  margin: 0;
  font-size: clamp(28px, 4.4vw, 54px);
  line-height: 1.02;
  letter-spacing: 0;
}

.topic-subtitle {
  margin: 10px 0 0;
  max-width: 820px;
  color: var(--muted);
  font-size: 16px;
  line-height: 1.58;
}

.top-actions {
  display: flex;
  flex-wrap: wrap;
  justify-content: flex-end;
  gap: 8px;
}

.select-field {
  display: grid;
  gap: 5px;
}

.select-field span {
  color: var(--muted);
  font-size: 12px;
  font-weight: 750;
}

.select-field select {
  min-width: 118px;
  height: 40px;
  padding: 0 34px 0 10px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  color: var(--ink);
  background: var(--panel);
}

.workbench {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 336px;
  gap: 18px;
  max-width: 1180px;
  margin: 0 auto;
}

.stage {
  min-width: 0;
}

.stepper {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 8px;
  margin-bottom: 12px;
}

.step-button {
  min-height: 62px;
  padding: 11px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  text-align: left;
  color: var(--muted);
  background: var(--panel);
}

.step-button strong {
  display: block;
  margin-bottom: 2px;
  color: var(--ink);
  font-size: 14px;
}

.step-button span {
  display: block;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  font-size: 12px;
}

.step-button.active {
  border-color: var(--teal);
  background: var(--teal-soft);
}

.step-button.done strong::after {
  content: " 완료";
  color: var(--teal);
  font-size: 11px;
  font-weight: 800;
}

.panel {
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: rgba(255, 255, 255, 0.94);
  box-shadow: var(--shadow);
}

.panel-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 14px;
  padding: 18px 18px 0;
}

.panel-title {
  margin: 0;
  font-size: 20px;
  line-height: 1.25;
}

.panel-copy {
  margin: 6px 0 0;
  color: var(--muted);
  line-height: 1.55;
}

.panel-body {
  padding: 18px;
}

.grid {
  display: grid;
  gap: 12px;
}

.expression-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 12px;
}

.expression-card,
.sentence-card,
.review-card,
.chat-message,
.tip-box {
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--panel);
}

.expression-card {
  display: grid;
  min-height: 184px;
  padding: 14px;
  gap: 11px;
}

.expression-card.learned {
  border-color: #9ad6cc;
  background: #f0fbf8;
}

.expression-top {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 10px;
}

.phrase {
  margin: 0;
  font-size: 21px;
  font-weight: 850;
  line-height: 1.1;
}

.meaning {
  margin: 5px 0 0;
  color: var(--teal-dark);
  font-size: 14px;
  font-weight: 750;
}

.example {
  margin: 0;
  color: var(--muted);
  line-height: 1.5;
}

.pattern {
  display: block;
  padding: 9px 10px;
  border-radius: var(--radius);
  color: #3f3a13;
  background: var(--amber-soft);
  font-size: 13px;
  line-height: 1.35;
}

.icon-button {
  flex: 0 0 auto;
  width: 38px;
  height: 38px;
  display: grid;
  place-items: center;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  color: var(--ink);
  background: var(--panel);
}

.icon-button:hover {
  border-color: var(--teal);
  color: var(--teal-dark);
}

.primary-button,
.secondary-button,
.quiet-button,
.danger-button {
  min-height: 40px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 0 13px;
  border-radius: var(--radius);
  font-weight: 800;
}

.primary-button {
  border: 1px solid var(--teal);
  color: white;
  background: var(--teal);
}

.primary-button:hover {
  background: var(--teal-dark);
}

.secondary-button {
  border: 1px solid var(--line);
  color: var(--ink);
  background: var(--panel);
}

.secondary-button:hover {
  border-color: var(--teal);
}

.quiet-button {
  border: 1px solid transparent;
  color: var(--teal-dark);
  background: transparent;
}

.quiet-button:hover {
  border-color: #9ad6cc;
  background: var(--teal-soft);
}

.danger-button {
  border: 1px solid #fecaca;
  color: var(--danger);
  background: #fff1f2;
}

.button-row {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  align-items: center;
}

.sentence-card {
  padding: 14px;
}

.sentence-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  margin-bottom: 10px;
}

.sentence-head strong {
  font-size: 15px;
}

.sentence-tools {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  align-items: center;
}

.sentence-tools select {
  min-width: 180px;
  height: 38px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--panel);
}

textarea,
input[type="text"] {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  color: var(--ink);
  background: #fff;
  outline: none;
}

textarea {
  min-height: 96px;
  padding: 12px;
  resize: vertical;
  line-height: 1.5;
}

textarea:focus,
input[type="text"]:focus,
select:focus {
  border-color: var(--teal);
  box-shadow: 0 0 0 3px rgba(15, 118, 110, 0.12);
}

.feedback {
  margin-top: 10px;
  padding: 10px 11px;
  border-radius: var(--radius);
  color: #373017;
  background: var(--amber-soft);
  line-height: 1.45;
}

.story-box {
  display: grid;
  gap: 12px;
}

.story-script {
  min-height: 154px;
  padding: 16px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: #fff;
  font-size: 18px;
  line-height: 1.55;
}

.timer-strip {
  display: grid;
  grid-template-columns: 80px minmax(0, 1fr);
  gap: 12px;
  align-items: center;
}

.timer {
  height: 64px;
  display: grid;
  place-items: center;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  color: var(--teal-dark);
  background: var(--teal-soft);
  font-size: 26px;
  font-weight: 900;
  transition: background 0.2s ease, color 0.2s ease;
}

.timer.running {
  color: #fff;
  background: var(--teal-dark);
  animation: timer-pulse 1s ease-in-out infinite;
}

.timer.done {
  color: #fff;
  background: var(--coral, #f97362);
}

@keyframes timer-pulse {
  0%, 100% { transform: scale(1); }
  50% { transform: scale(1.06); }
}

.meter {
  height: 12px;
  overflow: hidden;
  border-radius: 999px;
  background: #e7ecea;
}

.meter span {
  display: block;
  height: 100%;
  width: var(--value, 0%);
  border-radius: inherit;
  background: var(--teal);
  transition: width 200ms ease;
}

.chat-window {
  display: grid;
  gap: 10px;
  max-height: 360px;
  overflow: auto;
  padding-right: 4px;
}

.chat-message {
  padding: 12px;
}

.chat-message.coach {
  border-color: #c7d2fe;
  background: var(--indigo-soft);
}

.chat-message.user {
  border-color: #9ad6cc;
  background: #f0fbf8;
}

.chat-role {
  display: block;
  margin-bottom: 5px;
  color: var(--muted);
  font-size: 12px;
  font-weight: 850;
}

.chat-text {
  margin: 0;
  line-height: 1.48;
}

.side-panel {
  align-self: start;
  position: sticky;
  top: 24px;
  display: grid;
  gap: 12px;
}

.review-card {
  padding: 14px;
}

.review-card h3 {
  margin: 0 0 9px;
  font-size: 15px;
}

.review-card p {
  margin: 0;
  color: var(--muted);
  line-height: 1.48;
}

.check-list {
  display: grid;
  gap: 8px;
  margin: 0;
  padding: 0;
  list-style: none;
}

.check-list li {
  display: flex;
  align-items: center;
  gap: 8px;
  color: var(--muted);
  line-height: 1.35;
}

.check-dot {
  width: 18px;
  height: 18px;
  display: grid;
  place-items: center;
  border: 1px solid var(--line);
  border-radius: 50%;
  color: transparent;
  background: #fff;
  font-size: 12px;
  font-weight: 900;
}

.check-list li.done {
  color: var(--ink);
}

.check-list li.done .check-dot {
  color: white;
  border-color: var(--teal);
  background: var(--teal);
}

.tip-box {
  padding: 13px;
  color: var(--muted);
  line-height: 1.48;
  background: #fff;
}

.tip-box strong {
  display: block;
  margin-bottom: 5px;
  color: var(--ink);
}

.compact-list {
  display: grid;
  gap: 8px;
  margin: 0;
  padding: 0;
  list-style: none;
}

.compact-list li {
  padding: 9px 10px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: #fff;
  color: var(--muted);
  line-height: 1.35;
}

.empty-state {
  padding: 22px;
  border: 1px dashed #b8c7c2;
  border-radius: var(--radius);
  color: var(--muted);
  background: rgba(255, 255, 255, 0.72);
  line-height: 1.55;
}

.install-banner {
  display: none;
  margin-top: 12px;
  padding: 12px;
  border: 1px solid #fed7aa;
  border-radius: var(--radius);
  color: #7c2d12;
  background: var(--coral-soft);
}

.install-banner.ready {
  display: grid;
  gap: 10px;
}

.mobile-day-select {
  display: none;
}

.status-line {
  min-height: 24px;
  color: var(--muted);
  font-size: 13px;
}

.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

@media (max-width: 1060px) {
  .app-shell {
    grid-template-columns: 1fr;
  }

  .sidebar {
    position: static;
    height: auto;
    padding: 16px;
    border-right: 0;
    border-bottom: 1px solid var(--line);
  }

  .day-grid {
    display: none;
  }

  .mobile-day-select {
    display: block;
  }

  .mobile-day-select select {
    width: 100%;
    height: 42px;
    border: 1px solid var(--line);
    border-radius: var(--radius);
    background: var(--panel);
  }

  .workbench {
    grid-template-columns: 1fr;
  }

  .side-panel {
    position: static;
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
}

@media (max-width: 760px) {
  .main {
    padding: 16px;
  }

  .topbar {
    grid-template-columns: 1fr;
  }

  .top-actions {
    justify-content: flex-start;
  }

  .topic-title {
    font-size: 36px;
  }

  .expression-grid,
  .side-panel {
    grid-template-columns: 1fr;
  }

  .stepper {
    grid-template-columns: repeat(4, minmax(0, 1fr));
    gap: 6px;
  }

  .step-button {
    min-height: 0;
    padding: 9px 6px;
    text-align: center;
  }

  .step-button strong {
    margin-bottom: 0;
    font-size: 12px;
  }

  .step-button span {
    display: none;
  }

  .step-button.done strong::after {
    content: " ✓";
  }

  .panel-header {
    display: grid;
  }

  .timer-strip {
    grid-template-columns: 1fr;
  }

  .sentence-head {
    display: grid;
  }
}

@media (max-width: 440px) {
  .brand h1 {
    font-size: 16px;
  }

  .topic-title {
    font-size: 31px;
  }

  .top-actions,
  .button-row,
  .sentence-tools {
    align-items: stretch;
    flex-direction: column;
  }

  .primary-button,
  .secondary-button,
  .quiet-button,
  .danger-button,
  .select-field select,
  .sentence-tools select {
    width: 100%;
  }
}

.topic-search {
  margin: 4px 0 10px;
}

.topic-search input {
  width: 100%;
  box-sizing: border-box;
  padding: 9px 12px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--panel);
  color: var(--ink);
  font-size: 14px;
}

.topic-search input:focus {
  outline: 2px solid var(--teal-soft);
  border-color: var(--teal);
}

.day-button.filtered-out {
  display: none;
}

.prompt-status {
  margin: 10px 0 0;
  font-size: 13px;
  color: var(--teal-dark);
  min-height: 1em;
  line-height: 1.5;
}
