:root {
  --ink: #17211f;
  --muted: #68736f;
  --paper: #fbfaf6;
  --surface: #ffffff;
  --soft: #f1f3ed;
  --line: #dfe4dc;
  --green: #2f7d5c;
  --green-dark: #215d45;
  --blue: #376f9f;
  --red: #b94d40;
  --gold: #d6a73f;
  --shadow: 0 12px 34px rgba(32, 43, 40, 0.12);
}

* {
  box-sizing: border-box;
}

html {
  background: var(--paper);
}

body {
  margin: 0;
  min-height: 100vh;
  color: var(--ink);
  background: var(--paper);
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  letter-spacing: 0;
}

button,
input,
select {
  font: inherit;
}

button {
  min-height: 44px;
}

.app-frame {
  width: min(100%, 740px);
  min-height: 100vh;
  margin: 0 auto;
  padding: env(safe-area-inset-top) 14px calc(86px + env(safe-area-inset-bottom));
}

.app-header {
  position: sticky;
  top: 0;
  z-index: 20;
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
  padding: 14px 0 10px;
  background: color-mix(in srgb, var(--paper) 92%, transparent);
  backdrop-filter: blur(14px);
}

.brand {
  display: flex;
  align-items: center;
  gap: 10px;
  min-width: 0;
}

.brand img {
  border-radius: 10px;
}

.brand strong,
.brand span {
  display: block;
}

.brand strong {
  font-size: 1rem;
}

.brand span,
.small-label {
  color: var(--muted);
  font-size: 0.78rem;
}

.ghost-button,
.profile-button,
.tab-button,
.primary-button,
.secondary-button,
.chip-button,
.audio-button,
.icon-button {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
  color: var(--ink);
  cursor: pointer;
}

.ghost-button {
  padding: 0 12px;
}

.profile-bar {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 10px;
  align-items: center;
  margin-bottom: 16px;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
  box-shadow: var(--shadow);
}

.profile-bar strong {
  display: block;
}

.profile-buttons {
  display: flex;
  gap: 6px;
}

.profile-button {
  padding: 0 10px;
  font-weight: 700;
}

.profile-button.active {
  border-color: var(--green);
  color: white;
  background: var(--green);
}

#app {
  display: grid;
  gap: 14px;
  outline: none;
}

.screen {
  display: grid;
  gap: 14px;
}

.screen-title {
  margin: 0;
  font-size: clamp(1.8rem, 8vw, 3.4rem);
  line-height: 1.02;
}

.section-title {
  margin: 4px 0 0;
  font-size: 1.35rem;
}

.eyebrow {
  margin: 0 0 6px;
  color: var(--green);
  font-size: 0.76rem;
  font-weight: 850;
  text-transform: uppercase;
}

.muted {
  color: var(--muted);
}

.card,
.lesson-card,
.stat-card,
.notice {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
  box-shadow: var(--shadow);
}

.card,
.notice {
  padding: 16px;
}

.hero-card {
  display: grid;
  gap: 14px;
  padding: 18px;
  border-top: 6px solid var(--gold);
}

.hero-card p,
.card p,
.lesson-card p,
.notice p {
  line-height: 1.5;
}

.primary-button,
.secondary-button {
  display: inline-flex;
  justify-content: center;
  align-items: center;
  gap: 8px;
  padding: 0 14px;
  font-weight: 800;
  text-decoration: none;
}

.primary-button {
  border-color: var(--green);
  color: white;
  background: var(--green);
}

.primary-button:active {
  background: var(--green-dark);
}

.secondary-button {
  background: #f8f7f1;
}

.button-row,
.chip-row,
.audio-row {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.stats-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 8px;
}

.stat-card {
  padding: 12px;
}

.stat-card strong {
  display: block;
  font-size: 1.35rem;
}

.stat-card span {
  color: var(--muted);
  font-size: 0.78rem;
}

.lesson-card {
  display: grid;
  gap: 12px;
  padding: 16px;
}

.lesson-card.completed {
  border-color: #b7d9c5;
}

.lesson-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

.pill,
.chip-button {
  display: inline-flex;
  align-items: center;
  min-height: 32px;
  padding: 0 9px;
  border-radius: 8px;
  background: #edf5ef;
  color: #24543f;
  font-size: 0.82rem;
  font-weight: 750;
}

.chip-button {
  border: 1px solid #d8eadf;
}

.chip-button.selected,
.chip-button.known {
  border-color: var(--green);
  color: white;
  background: var(--green);
}

.chip-button.difficult {
  border-color: var(--red);
  color: white;
  background: var(--red);
}

.lesson-detail {
  display: grid;
  gap: 14px;
}

.detail-header {
  display: grid;
  gap: 10px;
}

.version-grid {
  display: grid;
  gap: 10px;
}

.version-card {
  padding: 14px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
}

.version-card strong {
  display: block;
  color: var(--red);
  font-size: 0.78rem;
  text-transform: uppercase;
  margin-bottom: 8px;
}

.pattern-list,
.word-list,
.review-list,
.scenario-list {
  display: grid;
  gap: 8px;
}

.list-item {
  display: grid;
  gap: 6px;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
}

.list-item header {
  display: flex;
  justify-content: space-between;
  gap: 12px;
}

.word-actions {
  display: flex;
  gap: 6px;
}

.audio-button {
  min-width: 86px;
  padding: 0 10px;
  background: #f8fbfd;
}

.audio-button.active {
  border-color: var(--blue);
  color: white;
  background: var(--blue);
}

.answer-panel {
  padding: 12px;
  border: 1px dashed #c8d4ce;
  border-radius: 8px;
  background: #fbfcf8;
}

.hidden {
  display: none !important;
}

.progress-bar {
  height: 10px;
  overflow: hidden;
  border-radius: 999px;
  background: #e8ece5;
}

.progress-bar span {
  display: block;
  height: 100%;
  border-radius: inherit;
  background: var(--green);
}

.empty-state {
  padding: 24px;
  text-align: center;
}

.bottom-nav {
  position: fixed;
  left: 50%;
  bottom: 0;
  z-index: 30;
  display: grid;
  grid-template-columns: repeat(5, 1fr);
  width: min(100%, 740px);
  transform: translateX(-50%);
  padding: 8px 10px calc(8px + env(safe-area-inset-bottom));
  border-top: 1px solid var(--line);
  background: color-mix(in srgb, var(--paper) 94%, transparent);
  backdrop-filter: blur(16px);
}

.tab-button {
  min-height: 52px;
  border-color: transparent;
  background: transparent;
  color: var(--muted);
  font-size: 0.78rem;
  font-weight: 800;
}

.tab-button.active {
  color: var(--green);
  background: #eaf4ee;
}

@media (min-width: 760px) {
  .app-frame {
    padding-left: 22px;
    padding-right: 22px;
  }

  .hero-card {
    grid-template-columns: 1fr auto;
    align-items: center;
  }

  .version-grid {
    grid-template-columns: repeat(3, 1fr);
  }

  .screen.two-column {
    grid-template-columns: 1.1fr 0.9fr;
    align-items: start;
  }
}
