:root {
  color: #24302f;
  background: #f8f5ef;
  font-family:
    Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI",
    sans-serif;
  font-synthesis: none;
  text-rendering: optimizeLegibility;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-width: 320px;
  min-height: 100vh;
  background:
    linear-gradient(180deg, rgba(216, 229, 218, 0.7), rgba(248, 245, 239, 0) 280px),
    #f8f5ef;
}

button,
textarea,
input {
  font: inherit;
}

button {
  border: 0;
  cursor: pointer;
}

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

.app-shell {
  width: min(100%, 720px);
  min-height: 100vh;
  margin: 0 auto;
  padding: 18px 14px 92px;
}

.topbar,
.day-header,
.section-title,
.pattern-head,
.review-meta,
.modal-actions {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.topbar {
  padding: 4px 4px 18px;
}

.eyebrow {
  margin: 0 0 4px;
  color: #6a756d;
  font-size: 12px;
  font-weight: 800;
  letter-spacing: 0;
  text-transform: uppercase;
}

h1,
h2,
h3,
p {
  margin-top: 0;
}

h1 {
  margin-bottom: 0;
  font-size: 30px;
}

h2 {
  margin-bottom: 6px;
  font-size: 23px;
}

h3 {
  margin-bottom: 6px;
  font-size: 18px;
}

p {
  color: #5e6865;
  line-height: 1.55;
}

.panel {
  background: rgba(255, 255, 255, 0.76);
  border: 1px solid rgba(72, 87, 84, 0.14);
  border-radius: 8px;
  padding: 16px;
  box-shadow: 0 20px 60px rgba(40, 53, 50, 0.08);
}

.icon-button,
.done-button {
  display: inline-grid;
  width: 42px;
  height: 42px;
  min-width: 42px;
  place-items: center;
  border-radius: 8px;
  color: #24302f;
  background: #ece7df;
}

.done-button.is-done,
.primary-action {
  color: #fff;
  background: #d9594c;
}

.secondary-action {
  display: inline-flex;
  width: 100%;
  min-height: 44px;
  align-items: center;
  justify-content: center;
  gap: 8px;
  border-radius: 8px;
  color: #263238;
  background: #ece7df;
  font-weight: 800;
}

.primary-action {
  display: inline-flex;
  width: 100%;
  min-height: 48px;
  align-items: center;
  justify-content: center;
  gap: 10px;
  border-radius: 8px;
  font-weight: 800;
}

.day-header {
  align-items: flex-start;
}

.day-header > div {
  min-width: 0;
  flex: 1;
  text-align: center;
}

.today-header {
  display: grid;
  grid-template-columns: 32px minmax(0, 1fr) 32px;
  gap: 8px;
  align-items: stretch;
}

.today-stack {
  display: grid;
  gap: 10px;
}

.nav-arrow {
  display: grid;
  width: 32px;
  min-height: 100%;
  place-items: center;
  border-radius: 8px;
  color: #24302f;
  background: #ece7df;
}

.today-card {
  width: 100%;
  padding: 10px;
  border: 1px solid rgba(72, 87, 84, 0.13);
  border-radius: 8px;
  text-align: center;
}

.today-card span {
  display: block;
  margin-bottom: 4px;
  color: #6a756d;
  font-size: 12px;
  font-weight: 800;
  text-transform: uppercase;
}

.selector-card {
  background: #f7f2e9;
}

.selector-card strong {
  display: inline;
  margin-right: 10px;
  margin-bottom: 0;
  font-size: 15px;
}

.selector-card b {
  display: inline;
  margin-bottom: 0;
  color: #263238;
  font-size: 15px;
  line-height: 1.2;
}

.selector-card em {
  color: #6a756d;
  font-size: 12px;
  font-style: normal;
}

.focus-card {
  background: #fffdf9;
}

.focus-card h2 {
  margin-bottom: 5px;
  font-size: 20px;
  line-height: 1.18;
}

.focus-card p {
  max-width: 34ch;
  margin-right: auto;
  margin-bottom: 0;
  margin-left: auto;
  font-size: 14px;
  line-height: 1.45;
}

.today-actions {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
  padding: 8px;
  border: 1px solid rgba(72, 87, 84, 0.1);
  border-radius: 8px;
  background: #f3f7f0;
}

.today-actions button {
  min-height: 40px;
  padding: 8px;
  border-radius: 8px;
  color: #2f4a3d;
  background: #dce8d8;
  font-size: 13px;
  font-weight: 800;
}

.today-actions .study-toggle.is-logged {
  color: #fff;
  background: #2f4a3d;
}

.today-actions .calendar-button {
  color: #2f4a3d;
  background: #edf4ef;
  border: 1px solid rgba(47, 74, 61, 0.18);
}

.pattern-tabs,
.quick-prompts,
.reason-row,
.review-actions {
  display: flex;
  gap: 8px;
  overflow-x: auto;
  padding-bottom: 4px;
}

.pattern-tabs {
  margin: 14px -2px 12px;
  justify-content: center;
}

.pattern-tabs button,
.quick-prompts button,
.reason-row button,
.review-actions button,
.practice-mini button,
.modal-actions button {
  min-height: 38px;
  padding: 8px 12px;
  border-radius: 8px;
  white-space: nowrap;
  color: #2c3836;
  background: #ece7df;
  font-weight: 700;
  text-align: center;
}

.pattern-tabs button.active,
.reason-row button.active {
  color: #fff;
  background: #263238;
}

.jump-button {
  min-height: 36px;
  padding: 7px 12px;
  border-radius: 8px;
  color: #fff;
  background: #263238;
  font-size: 13px;
  font-weight: 800;
}

.pattern-card,
.review-item,
.practice-card,
.context-box,
.empty-state {
  border: 1px solid rgba(72, 87, 84, 0.13);
  border-radius: 8px;
  background: #fffdf9;
}

.pattern-card {
  padding: 14px;
}

.pattern-head span,
.context-box span,
.practice-card span,
.review-meta span,
.review-item small {
  color: #7b615c;
  font-size: 12px;
  font-weight: 800;
}

.explain-grid {
  display: grid;
  grid-template-columns: 1fr;
  gap: 10px;
  margin: 14px 0;
}

.explain-grid > div {
  padding: 12px;
  border-radius: 8px;
  background: #edf4ef;
}

.explain-grid strong {
  display: block;
  margin-bottom: 5px;
}

.explain-grid p {
  margin: 0;
}

.example-list,
.listen-list,
.review-list,
.drill-stack {
  display: grid;
  gap: 10px;
}

.example-row,
.listen-row {
  display: grid;
  grid-template-columns: 42px minmax(0, 1fr) 42px 42px;
  gap: 8px;
  align-items: center;
  padding: 10px;
  border-radius: 8px;
  background: #f7f2e9;
}

.listen-row {
  grid-template-columns: 42px minmax(0, 1fr);
}

.example-row strong,
.listen-row strong {
  display: block;
  margin-bottom: 4px;
  line-height: 1.35;
}

.example-row span,
.listen-row span {
  display: block;
  color: #67716e;
  line-height: 1.35;
}

.section-title {
  justify-content: flex-start;
  margin-bottom: 14px;
}

.section-title svg {
  color: #d9594c;
}

.section-title p {
  margin-bottom: 0;
}

.context-box {
  display: grid;
  gap: 7px;
  padding: 14px;
  margin-bottom: 12px;
}

.context-box em {
  color: #68716f;
  font-style: normal;
}

.question-box,
.modal textarea,
.practice-card textarea,
.review-composer input {
  width: 100%;
  border: 1px solid rgba(72, 87, 84, 0.18);
  border-radius: 8px;
  color: #24302f;
  background: #fffdf9;
  outline: 0;
}

.question-box,
.modal textarea,
.practice-card textarea {
  min-height: 112px;
  margin: 10px 0;
  padding: 12px;
  resize: vertical;
}

.answer-box {
  margin: 14px 0 0;
  padding: 14px;
  white-space: pre-wrap;
  line-height: 1.6;
  border-radius: 8px;
  color: #263238;
  background: #edf4ef;
}

.review-composer {
  display: grid;
  gap: 10px;
  margin-top: 14px;
  padding: 12px;
  border-radius: 8px;
  background: #f7f2e9;
}

.review-composer p {
  margin-bottom: 0;
  font-weight: 800;
}

.review-composer input {
  min-height: 42px;
  padding: 0 12px;
}

.review-composer > button {
  display: inline-flex;
  min-height: 42px;
  align-items: center;
  justify-content: center;
  gap: 8px;
  border-radius: 8px;
  color: #fff;
  background: #263238;
  font-weight: 800;
}

.empty-state {
  display: grid;
  min-height: 180px;
  place-items: center;
  padding: 24px;
  text-align: center;
}

.empty-state svg {
  color: #d9594c;
}

.review-item {
  display: grid;
  gap: 8px;
  padding: 14px;
}

.review-item p,
.review-item h3 {
  margin-bottom: 0;
}

.review-item em {
  padding: 10px;
  border-radius: 8px;
  color: #6f4f49;
  background: #f7ece9;
  font-style: normal;
}

.practice-card {
  display: grid;
  gap: 10px;
  padding: 14px;
}

.answer-line {
  padding: 12px;
  border-radius: 8px;
  background: #edf4ef;
}

.practice-mini {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding: 12px;
  border-radius: 8px;
  background: #f7f2e9;
}

.practice-mini span {
  min-width: 0;
  line-height: 1.4;
}

.listen-panel {
  background: #fffdf9;
}

.listen-summary {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 12px;
  margin-bottom: 12px;
  border: 1px solid rgba(72, 87, 84, 0.12);
  border-radius: 8px;
  background: #f7f2e9;
}

.listen-summary span {
  color: #6a756d;
  font-size: 13px;
  font-weight: 800;
  white-space: nowrap;
}

.listen-list {
  margin-top: 12px;
}

.settings-grid {
  display: grid;
  gap: 10px;
  margin-bottom: 14px;
}

.setting-box {
  display: grid;
  gap: 10px;
  padding: 12px;
  border: 1px solid rgba(72, 87, 84, 0.13);
  border-radius: 8px;
  background: #f9f7f2;
}

.setting-box strong {
  display: block;
}

.setting-box label {
  display: grid;
  gap: 6px;
  color: #5e6865;
  font-size: 14px;
  font-weight: 700;
}

.setting-box select {
  min-height: 40px;
  padding: 0 10px;
  border: 1px solid rgba(72, 87, 84, 0.18);
  border-radius: 8px;
  color: #24302f;
  background: #fffdf9;
}

.segmented-control {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 6px;
}

.segmented-control button {
  min-height: 38px;
  border-radius: 8px;
  color: #2c3836;
  background: #fffdf9;
  font-weight: 800;
}

.segmented-control button.active {
  color: #fff;
  background: #263238;
}

.setting-box p {
  margin: 0;
  font-size: 13px;
}

.zh-only {
  display: block;
  color: #24302f;
  font-weight: 800;
  line-height: 1.35;
}

.modal-backdrop {
  position: fixed;
  inset: 0;
  z-index: 20;
  display: grid;
  place-items: end center;
  padding: 14px;
  background: rgba(36, 48, 47, 0.38);
}

.modal {
  width: min(100%, 680px);
  padding: 16px;
  border-radius: 8px;
  background: #fffdf9;
}

.modal-actions {
  justify-content: flex-end;
}

.modal-actions .primary-action {
  width: auto;
  padding: 0 18px;
}

.bottom-nav {
  position: fixed;
  right: 0;
  bottom: 0;
  left: 0;
  z-index: 10;
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 4px;
  width: min(100%, 720px);
  margin: 0 auto;
  padding: 8px 10px 12px;
  border-top: 1px solid rgba(72, 87, 84, 0.12);
  background: rgba(255, 253, 249, 0.94);
  backdrop-filter: blur(14px);
}

.bottom-nav button {
  display: grid;
  min-height: 56px;
  place-items: center;
  border-radius: 8px;
  color: #67716e;
  background: transparent;
}

.bottom-nav button.active {
  color: #fff;
  background: #263238;
}

.bottom-nav span {
  font-size: 14px;
  font-weight: 800;
}

.tool-tabs {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 6px;
  margin-bottom: 10px;
}

.tool-tabs.compact {
  grid-template-columns: repeat(2, 1fr);
}

.tool-tabs button {
  min-height: 40px;
  border-radius: 8px;
  color: #2c3836;
  background: #ece7df;
  font-weight: 800;
}

.tool-tabs button.active {
  color: #fff;
  background: #263238;
}

.tool-body {
  display: grid;
  gap: 12px;
}

.tool-group-label {
  margin: 8px 0 6px;
  color: #6a756d;
  font-size: 12px;
  font-weight: 800;
  text-transform: uppercase;
}

.jump-modal {
  max-height: 86vh;
  overflow: hidden;
}

.jump-list {
  display: grid;
  gap: 14px;
  max-height: 65vh;
  overflow: auto;
  padding-right: 4px;
}

.jump-unit h3 {
  margin-bottom: 8px;
}

.jump-unit > div {
  display: grid;
  gap: 8px;
}

.jump-unit button {
  display: grid;
  gap: 4px;
  width: 100%;
  padding: 10px;
  border-radius: 8px;
  color: #24302f;
  background: #f7f2e9;
  text-align: left;
}

.jump-unit button.active {
  color: #fff;
  background: #263238;
}

.jump-unit span {
  font-size: 12px;
  font-weight: 800;
  opacity: 0.75;
}

.calendar-toolbar {
  margin-bottom: 12px;
}

.calendar-record-button {
  width: 100%;
  min-height: 42px;
  border-radius: 8px;
  color: #fff;
  background: #263238;
  font-weight: 800;
}

.calendar-grid {
  display: grid;
  grid-template-columns: repeat(7, 1fr);
  gap: 6px;
  margin-bottom: 14px;
}

.calendar-weekday {
  color: #6a756d;
  font-size: 12px;
  font-weight: 800;
  text-align: center;
}

.calendar-cell {
  display: grid;
  min-height: 48px;
  align-content: start;
  gap: 3px;
  padding: 6px;
  border: 1px solid rgba(72, 87, 84, 0.12);
  border-radius: 8px;
  background: #fffdf9;
}

.calendar-cell.empty {
  border-color: transparent;
  background: transparent;
}

.calendar-cell.today {
  border-color: #263238;
}

.calendar-cell.logged {
  background: #edf4ef;
}

.calendar-cell strong {
  font-size: 13px;
  text-align: center;
}

.calendar-cell em {
  overflow: hidden;
  color: #4f5d57;
  font-size: 10px;
  font-style: normal;
  line-height: 1.15;
  text-align: center;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
}

.calendar-list {
  display: grid;
  gap: 10px;
  max-height: 56vh;
  overflow: auto;
}

.calendar-item {
  display: grid;
  gap: 5px;
  padding: 12px;
  border-radius: 8px;
  background: #f7f2e9;
}

.calendar-item span {
  color: #6a756d;
  font-size: 12px;
  font-weight: 800;
}

.calendar-item h3,
.calendar-item p {
  margin-bottom: 0;
}

.vocab-strip {
  display: grid;
  gap: 8px;
  padding: 10px;
  border-radius: 8px;
  background: #edf4ef;
}

.vocab-strip > div {
  display: flex;
  gap: 8px;
  overflow-x: auto;
}

.vocab-strip button,
.vocab-save {
  min-height: 36px;
  padding: 7px 11px;
  border-radius: 8px;
  color: #fff;
  background: #263238;
  font-weight: 800;
}

.subhead {
  margin-top: 18px;
}

.vocab-list {
  display: grid;
  gap: 10px;
}

.vocab-item {
  display: grid;
  gap: 9px;
  padding: 14px;
  border: 1px solid rgba(72, 87, 84, 0.13);
  border-radius: 8px;
  background: #fffdf9;
}

.vocab-item.saved {
  background: #f7f2e9;
}

.vocab-item h3,
.vocab-item p {
  margin-bottom: 0;
}

.vocab-item em {
  color: #6f4f49;
  font-style: normal;
  line-height: 1.45;
}

.form-list,
.mini-examples {
  display: flex;
  flex-wrap: wrap;
  gap: 7px;
}

.form-list span,
.mini-examples span {
  padding: 6px 9px;
  border-radius: 8px;
  color: #24302f;
  background: #ece7df;
  font-size: 13px;
  font-weight: 800;
}

.mini-examples span {
  background: #edf4ef;
  font-weight: 700;
}

@media (min-width: 680px) {
  .app-shell {
    padding-top: 26px;
  }

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

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