:root {
  color-scheme: light;
  --bg: #f6f3ea;
  --ink: #143d3a;
  --text: #1e2623;
  --muted: #68746c;
  --panel: #fffdf6;
  --panel-2: #e9f3ee;
  --line: #d7d0bf;
  --accent: #df5b3f;
  --accent-2: #14796f;
  --accent-3: #f0bd37;
  --accent-4: #2f6fbd;
  --shadow: 0 18px 50px rgba(20, 61, 58, 0.12);
  --radius: 8px;
  --display: Optima, "Gill Sans", "PingFang SC", "Microsoft YaHei", sans-serif;
  --body: "Avenir Next", "PingFang SC", "Hiragino Sans GB", "Microsoft YaHei", sans-serif;
}

[data-theme="night"] {
  color-scheme: dark;
  --bg: #151a18;
  --ink: #e9f3ee;
  --text: #f4f0e6;
  --muted: #b0bbb4;
  --panel: #202822;
  --panel-2: #1b332e;
  --line: #3a493f;
  --accent: #ff765c;
  --accent-2: #69d0c4;
  --accent-3: #f2c64c;
  --accent-4: #8ab9ff;
  --shadow: 0 18px 50px rgba(0, 0, 0, 0.35);
}

* {
  box-sizing: border-box;
}

html {
  scroll-behavior: smooth;
}

body {
  margin: 0;
  min-height: 100vh;
  background:
    linear-gradient(135deg, rgba(20, 121, 111, 0.08) 0 24%, transparent 24% 100%),
    linear-gradient(315deg, rgba(223, 91, 63, 0.08) 0 18%, transparent 18% 100%),
    repeating-linear-gradient(90deg, rgba(20, 61, 58, 0.04) 0 1px, transparent 1px 54px),
    var(--bg);
  color: var(--text);
  font-family: var(--body);
  font-size: 16px;
  line-height: 1.6;
}

button,
input {
  font: inherit;
}

button {
  color: inherit;
}

img {
  display: block;
  max-width: 100%;
}

a {
  color: inherit;
  text-decoration: none;
}

::selection {
  background: var(--accent-3);
  color: #15211e;
}

.skip-link {
  position: fixed;
  top: 12px;
  left: 12px;
  z-index: 30;
  padding: 8px 12px;
  border-radius: 6px;
  background: var(--ink);
  color: var(--bg);
  transform: translateY(-150%);
  transition: transform 160ms ease;
}

.skip-link:focus {
  transform: translateY(0);
}

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

.app-shell {
  width: min(1180px, 100%);
  min-height: 100vh;
  margin: 0 auto;
  padding: 14px 16px calc(92px + env(safe-area-inset-bottom));
}

.topbar {
  position: sticky;
  top: 0;
  z-index: 20;
  display: flex;
  align-items: center;
  justify-content: space-between;
  min-height: 66px;
  padding: 8px 0 10px;
  backdrop-filter: blur(18px);
}

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

.brand img {
  width: 44px;
  height: 44px;
  border: 2px solid var(--ink);
  border-radius: 8px;
  box-shadow: 4px 4px 0 var(--accent-3);
}

.brand span {
  display: grid;
  line-height: 1.1;
}

.brand strong {
  color: var(--ink);
  font-family: var(--display);
  font-size: 1.15rem;
  letter-spacing: 0;
}

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

.topbar-actions {
  display: flex;
  gap: 8px;
}

.icon-action {
  display: grid;
  place-items: center;
  width: 42px;
  height: 42px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: color-mix(in srgb, var(--panel) 86%, transparent);
  cursor: pointer;
  transition:
    transform 160ms ease,
    border-color 160ms ease,
    background 160ms ease;
}

.icon-action:hover {
  border-color: var(--ink);
  background: var(--panel);
  transform: translateY(-1px);
}

.main-content {
  display: block;
}

.view {
  display: none;
  animation: lift-in 260ms ease both;
}

.view.is-active {
  display: block;
}

@keyframes lift-in {
  from {
    opacity: 0;
    transform: translateY(8px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

.section-kicker,
.eyebrow {
  margin: 0 0 10px;
  color: var(--accent-2);
  font-size: 0.78rem;
  font-weight: 900;
  letter-spacing: 0;
  text-transform: uppercase;
}

h1,
h2,
h3,
p {
  overflow-wrap: anywhere;
}

h1,
h2,
h3 {
  margin: 0;
  color: var(--ink);
  font-family: var(--display);
  font-weight: 900;
  letter-spacing: 0;
  line-height: 1.08;
}

h1 {
  max-width: 700px;
  font-size: 3.9rem;
}

h2 {
  font-size: 2.45rem;
}

h3 {
  font-size: 1.35rem;
}

.muted,
.today-copy p,
.lesson-head p,
.section-heading p,
.install-guide li,
.toggle-row small,
.status-line {
  color: var(--muted);
}

.today-layout {
  display: grid;
  grid-template-columns: minmax(0, 1.2fr) minmax(280px, 0.8fr);
  gap: 22px;
  align-items: stretch;
}

.today-copy {
  min-height: 320px;
  padding: 28px;
  border: 2px solid var(--ink);
  border-radius: var(--radius);
  background:
    linear-gradient(110deg, color-mix(in srgb, var(--accent-3) 34%, transparent), transparent 52%),
    var(--panel);
  box-shadow: 8px 8px 0 var(--ink);
}

.today-copy p {
  max-width: 580px;
  margin: 18px 0 0;
  font-size: 1.05rem;
}

.hero-actions,
.practice-actions,
.settings-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  margin-top: 22px;
}

.button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  min-height: 48px;
  padding: 10px 15px;
  border: 2px solid var(--ink);
  border-radius: 8px;
  font-weight: 900;
  line-height: 1.2;
  cursor: pointer;
  transition:
    transform 160ms ease,
    box-shadow 160ms ease,
    background 160ms ease;
}

.button:hover {
  transform: translate(-1px, -1px);
}

.button.primary {
  background: var(--accent);
  color: #fffdf6;
  box-shadow: 5px 5px 0 var(--ink);
}

.button.secondary {
  background: var(--panel);
  color: var(--ink);
  box-shadow: 5px 5px 0 var(--accent-3);
}

.button.ghost {
  background: transparent;
  color: var(--ink);
}

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

.daily-brief {
  display: grid;
  grid-template-columns: 1fr;
  gap: 12px;
}

.daily-brief div {
  display: grid;
  align-content: center;
  min-height: 96px;
  padding: 18px;
  border: 1px solid var(--line);
  border-left: 6px solid var(--accent-2);
  border-radius: var(--radius);
  background: color-mix(in srgb, var(--panel) 90%, transparent);
  box-shadow: var(--shadow);
}

.daily-brief span {
  color: var(--ink);
  font-family: var(--display);
  font-size: 2rem;
  font-weight: 900;
  line-height: 1;
}

.daily-brief small {
  color: var(--muted);
  font-weight: 800;
}

.lesson-head {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(240px, 0.6fr);
  gap: 18px;
  align-items: end;
  margin: 44px 0 18px;
}

.lesson-head p {
  margin: 0;
}

.phrase-board {
  display: grid;
  gap: 8px;
  margin-bottom: 14px;
  padding: 18px;
  border: 2px solid var(--ink);
  border-radius: var(--radius);
  background: var(--ink);
  color: var(--bg);
}

.phrase-board strong {
  font-family: var(--display);
  font-size: 1.65rem;
  line-height: 1.15;
}

.phrase-board span {
  color: color-mix(in srgb, var(--bg) 78%, transparent);
}

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

.word-card,
.scene-card {
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: color-mix(in srgb, var(--panel) 94%, transparent);
  box-shadow: 0 10px 26px rgba(20, 61, 58, 0.07);
}

.word-card {
  display: grid;
  grid-template-rows: auto 1fr auto;
  min-height: 180px;
  padding: 16px;
}

.word-card strong,
.scene-card strong {
  color: var(--ink);
  font-family: var(--display);
  font-size: 1.45rem;
  line-height: 1.1;
}

.word-card small,
.scene-card small {
  color: var(--accent-2);
  font-weight: 900;
}

.word-card p,
.scene-card p {
  margin: 10px 0 0;
  color: var(--muted);
}

.mini-action {
  justify-self: start;
  min-height: 34px;
  margin-top: 14px;
  padding: 5px 10px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: var(--panel-2);
  color: var(--ink);
  font-weight: 900;
  cursor: pointer;
}

.section-heading {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(260px, 0.55fr);
  gap: 18px;
  align-items: end;
  margin-bottom: 18px;
}

.section-heading.compact {
  align-items: start;
}

.section-heading p {
  margin: 0;
}

.search-box input,
.reminder-form input[type="time"] {
  width: 100%;
  min-height: 48px;
  border: 2px solid var(--line);
  border-radius: 8px;
  background: var(--panel);
  color: var(--text);
  outline: none;
}

.search-box input {
  padding: 0 14px;
}

.search-box input:focus,
.reminder-form input[type="time"]:focus {
  border-color: var(--accent-2);
  box-shadow: 0 0 0 3px color-mix(in srgb, var(--accent-2) 18%, transparent);
}

.scene-tabs {
  display: flex;
  gap: 8px;
  padding: 2px 0 16px;
  overflow-x: auto;
  scrollbar-width: thin;
}

.scene-tabs button {
  flex: 0 0 auto;
  min-height: 40px;
  padding: 8px 12px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: var(--panel);
  color: var(--muted);
  font-weight: 900;
  cursor: pointer;
}

.scene-tabs button.is-active {
  border-color: var(--ink);
  background: var(--ink);
  color: var(--bg);
}

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

.scene-card {
  display: grid;
  gap: 12px;
  min-height: 210px;
  padding: 16px;
}

.scene-card header {
  display: flex;
  align-items: start;
  justify-content: space-between;
  gap: 12px;
}

.scene-label {
  flex: 0 0 auto;
  padding: 3px 8px;
  border-radius: 999px;
  background: var(--panel-2);
  color: var(--accent-2);
  font-size: 0.78rem;
  font-weight: 900;
}

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

.phrase-list li {
  display: grid;
  gap: 2px;
  padding-top: 8px;
  border-top: 1px solid var(--line);
}

.phrase-list b {
  color: var(--ink);
}

.practice-layout {
  display: grid;
  grid-template-columns: minmax(0, 0.75fr) minmax(320px, 1fr);
  gap: 24px;
  align-items: stretch;
}

.practice-layout .muted {
  max-width: 520px;
  margin: 14px 0 0;
}

.flashcard {
  display: grid;
  align-content: space-between;
  min-height: 340px;
  padding: 24px;
  border: 2px solid var(--ink);
  border-radius: var(--radius);
  background:
    linear-gradient(135deg, color-mix(in srgb, var(--accent-2) 18%, transparent), transparent 58%),
    var(--panel);
  box-shadow: 10px 10px 0 var(--accent-3);
}

.flashcard strong {
  color: var(--ink);
  font-family: var(--display);
  font-size: 3.2rem;
  line-height: 1.04;
}

.flashcard span {
  align-self: end;
  color: var(--muted);
  font-size: 1.15rem;
  font-weight: 800;
}

.settings-grid {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(290px, 0.75fr);
  gap: 16px;
}

.reminder-form,
.install-guide {
  padding: 18px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: color-mix(in srgb, var(--panel) 94%, transparent);
  box-shadow: var(--shadow);
}

.reminder-form {
  display: grid;
  gap: 18px;
}

.reminder-form label {
  display: grid;
  gap: 8px;
  color: var(--ink);
  font-weight: 900;
}

.reminder-form input[type="time"] {
  padding: 0 12px;
}

.toggle-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 14px 0;
  border-top: 1px solid var(--line);
  border-bottom: 1px solid var(--line);
}

.toggle-row div {
  display: grid;
  gap: 2px;
}

.switch {
  position: relative;
  display: inline-block;
  width: 58px;
  height: 34px;
}

.switch input {
  opacity: 0;
}

.switch span {
  position: absolute;
  inset: 0;
  border: 2px solid var(--line);
  border-radius: 999px;
  background: var(--bg);
  cursor: pointer;
}

.switch span::before {
  position: absolute;
  top: 4px;
  left: 4px;
  width: 22px;
  height: 22px;
  border-radius: 50%;
  background: var(--muted);
  content: "";
  transition:
    transform 160ms ease,
    background 160ms ease;
}

.switch input:checked + span {
  border-color: var(--accent-2);
  background: color-mix(in srgb, var(--accent-2) 24%, var(--panel));
}

.switch input:checked + span::before {
  background: var(--accent-2);
  transform: translateX(24px);
}

.status-line {
  min-height: 24px;
  margin: 0;
  font-weight: 800;
}

.install-guide h3 {
  margin-bottom: 12px;
}

.install-guide ol {
  display: grid;
  gap: 10px;
  padding-left: 20px;
  margin: 0;
}

.bottom-nav {
  position: fixed;
  right: max(16px, calc((100vw - 1180px) / 2 + 16px));
  bottom: max(14px, env(safe-area-inset-bottom));
  left: max(16px, calc((100vw - 1180px) / 2 + 16px));
  z-index: 25;
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 6px;
  max-width: 560px;
  margin-inline: auto;
  padding: 8px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: color-mix(in srgb, var(--panel) 92%, transparent);
  box-shadow: 0 14px 40px rgba(20, 61, 58, 0.18);
  backdrop-filter: blur(18px);
}

.bottom-nav button {
  display: grid;
  gap: 2px;
  place-items: center;
  min-height: 50px;
  border: 0;
  border-radius: 6px;
  background: transparent;
  color: var(--muted);
  font-size: 0.84rem;
  font-weight: 900;
  cursor: pointer;
}

.bottom-nav button span {
  font-size: 0.82rem;
}

.bottom-nav button.is-active {
  background: var(--ink);
  color: var(--bg);
}

.toast {
  position: fixed;
  right: 18px;
  bottom: 96px;
  z-index: 40;
  max-width: min(360px, calc(100vw - 36px));
  padding: 12px 14px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--ink);
  color: var(--bg);
  font-weight: 900;
  box-shadow: var(--shadow);
  opacity: 0;
  pointer-events: none;
  transform: translateY(12px);
  transition:
    opacity 180ms ease,
    transform 180ms ease;
}

.toast.is-visible {
  opacity: 1;
  transform: translateY(0);
}

@media (max-width: 920px) {
  h1 {
    font-size: 3rem;
  }

  h2 {
    font-size: 2rem;
  }

  .today-layout,
  .lesson-head,
  .section-heading,
  .practice-layout,
  .settings-grid {
    grid-template-columns: 1fr;
  }

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

  .word-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
}

@media (max-width: 640px) {
  body {
    font-size: 15px;
  }

  .app-shell {
    padding-inline: 12px;
  }

  .topbar {
    min-height: 60px;
  }

  .brand small {
    display: none;
  }

  h1 {
    font-size: 2.35rem;
  }

  h2 {
    font-size: 1.65rem;
  }

  .today-copy {
    min-height: auto;
    padding: 20px;
    box-shadow: 5px 5px 0 var(--ink);
  }

  .daily-brief,
  .word-grid,
  .scene-list {
    grid-template-columns: 1fr;
  }

  .daily-brief div {
    min-height: 82px;
  }

  .phrase-board strong {
    font-size: 1.35rem;
  }

  .flashcard {
    min-height: 280px;
    padding: 20px;
  }

  .flashcard strong {
    font-size: 2.35rem;
  }

  .button {
    width: 100%;
  }

  .bottom-nav {
    left: 10px;
    right: 10px;
    max-width: none;
  }

  .toast {
    right: 12px;
    bottom: 88px;
  }
}

@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    scroll-behavior: auto !important;
    transition-duration: 0.01ms !important;
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
  }
}
