:root {
  --bg: #f3efe3;
  --ink: #1d2a2a;
  --muted: #536366;
  --panel: rgba(255, 255, 255, 0.82);
  --line: rgba(33, 63, 59, 0.2);
  --primary: #176a5b;
  --primary-2: #0f4f44;
  --accent: #c46f2c;
  --ok: #2f7c4a;
  --warn: #ab5b1d;
  --danger: #a33b2d;
  --shadow: 0 10px 30px rgba(24, 41, 44, 0.15);
}

*,
*::before,
*::after {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  color: var(--ink);
  background: radial-gradient(circle at 12% 8%, #d9efe8 0%, transparent 40%),
              radial-gradient(circle at 86% 12%, #ffe1c8 0%, transparent 34%),
              linear-gradient(145deg, #efe7d3 0%, #f6f2e8 44%, #efe9dd 100%);
  font-family: "Source Han Serif SC", "Noto Serif Tibetan", "STKaiti", serif;
  position: relative;
}

.bg-glow {
  position: fixed;
  pointer-events: none;
  z-index: 0;
  border-radius: 999px;
  filter: blur(45px);
  opacity: 0.5;
}

.bg-glow-a {
  width: 260px;
  height: 260px;
  top: 8%;
  right: 6%;
  background: #ffc288;
}

.bg-glow-b {
  width: 260px;
  height: 260px;
  bottom: 8%;
  left: 4%;
  background: #8dd6bf;
}

.app-shell {
  max-width: 1160px;
  margin: 0 auto;
  padding: 18px 16px 40px;
  position: relative;
  z-index: 1;
}

.app-header {
  border: 1px solid var(--line);
  border-radius: 18px;
  padding: 18px;
  background: var(--panel);
  box-shadow: var(--shadow);
  display: flex;
  flex-wrap: wrap;
  gap: 18px;
  justify-content: space-between;
  align-items: flex-start;
}

.kicker {
  margin: 0;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--primary);
  font-size: 0.78rem;
}

h1 {
  margin: 4px 0;
  font-size: clamp(1.36rem, 2.8vw, 2rem);
}

.subtitle {
  margin: 0;
  color: var(--muted);
}

.quick-stats {
  display: grid;
  grid-template-columns: repeat(2, minmax(90px, 1fr));
  gap: 8px;
  min-width: 230px;
}

.stat-box {
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 8px 10px;
  background: rgba(255, 255, 255, 0.66);
}

.stat-box .label {
  font-size: 0.8rem;
  color: var(--muted);
}

.stat-box .value {
  display: block;
  margin-top: 4px;
  font-size: 1.12rem;
  font-weight: 700;
}

.nav-tabs {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin: 14px 0;
}

.tab-btn {
  border: 1px solid var(--line);
  border-radius: 999px;
  padding: 8px 14px;
  background: rgba(255, 255, 255, 0.65);
  color: var(--ink);
  font-size: 0.96rem;
  cursor: pointer;
  transition: all 0.18s ease;
}

.tab-btn:hover {
  transform: translateY(-1px);
  border-color: rgba(23, 106, 91, 0.45);
}

.tab-btn.active {
  background: var(--primary);
  color: #fff;
  border-color: var(--primary-2);
}

.view {
  display: none;
  animation: fadeIn 0.24s ease;
}

.view.active {
  display: block;
}

@keyframes fadeIn {
  from {
    opacity: 0;
    transform: translateY(6px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

.panel-head h2 {
  margin: 6px 0;
}

.panel-head p {
  margin: 0 0 12px;
  color: var(--muted);
}

.lesson-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(250px, 1fr));
  gap: 12px;
}

.lesson-card {
  border: 1px solid var(--line);
  border-radius: 14px;
  padding: 12px;
  background: var(--panel);
  box-shadow: var(--shadow);
}

.lesson-card h3 {
  margin: 4px 0;
}

.lesson-card p {
  margin: 6px 0;
  color: var(--muted);
  line-height: 1.45;
}

.chip-row {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

.chip {
  font-size: 0.76rem;
  border: 1px solid rgba(23, 106, 91, 0.35);
  border-radius: 999px;
  padding: 3px 9px;
  background: rgba(23, 106, 91, 0.08);
}

.chip.warn {
  border-color: rgba(171, 91, 29, 0.45);
  background: rgba(196, 111, 44, 0.12);
}

.lesson-actions {
  margin-top: 10px;
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.small-btn,
.primary-btn {
  border: none;
  cursor: pointer;
  border-radius: 10px;
  padding: 8px 10px;
  font-family: inherit;
}

.small-btn {
  background: #ddeee7;
  color: var(--primary-2);
}

.small-btn:hover {
  background: #cbe7dd;
}

.primary-btn {
  background: linear-gradient(130deg, var(--primary), var(--primary-2));
  color: #fff;
}

.primary-btn:hover {
  filter: brightness(1.04);
}

.study-toolbar {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 10px;
}

select {
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 7px 10px;
  font-family: inherit;
  min-width: 220px;
}

.sentence-list {
  display: grid;
  gap: 12px;
}

.sentence-card {
  border: 1px solid var(--line);
  border-radius: 14px;
  background: var(--panel);
  padding: 12px;
  box-shadow: var(--shadow);
}

.sentence-head {
  display: flex;
  flex-wrap: wrap;
  justify-content: space-between;
  gap: 8px;
}

.sentence-head h3 {
  margin: 0;
  font-size: 1.06rem;
}

.sentence-source {
  font-size: 0.82rem;
  color: var(--muted);
}

.sentence-main {
  margin: 8px 0;
  padding: 8px 10px;
  border-radius: 10px;
  background: rgba(255, 255, 255, 0.75);
}

.sentence-main p {
  margin: 6px 0;
}

.tibetan-line {
  font-size: 1.1rem;
  letter-spacing: 0.02em;
}

.roman-line {
  color: var(--muted);
  font-size: 0.9rem;
}

.analysis-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(170px, 1fr));
  gap: 8px;
  margin: 8px 0;
}

.analysis-item {
  background: rgba(255, 255, 255, 0.75);
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 7px;
  font-size: 0.9rem;
}

.analysis-item strong {
  display: block;
  font-size: 0.82rem;
  color: var(--muted);
  margin-bottom: 3px;
}

.meta-points {
  display: grid;
  gap: 6px;
  margin-top: 10px;
}

.meta-points .point {
  background: rgba(250, 249, 244, 0.78);
  border-left: 3px solid var(--accent);
  border-radius: 4px;
  padding: 8px 9px;
}

.task-row {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 10px;
}

.task-btn {
  border: 1px solid var(--line);
  border-radius: 9px;
  background: rgba(255, 255, 255, 0.75);
  padding: 7px 9px;
  cursor: pointer;
}

.task-btn.done {
  border-color: rgba(47, 124, 74, 0.42);
  color: var(--ok);
  background: rgba(86, 180, 109, 0.16);
}

.task-btn:hover {
  transform: translateY(-1px);
}

.task-btn[disabled],
.small-btn[disabled] {
  opacity: 0.48;
  cursor: not-allowed;
  transform: none;
}

.speech-row {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  margin-top: 8px;
}

.speech-hint {
  font-size: 0.86rem;
  color: var(--muted);
}

.daily-layout {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(260px, 1fr));
  gap: 12px;
}

.card {
  border: 1px solid var(--line);
  border-radius: 14px;
  padding: 12px;
  background: var(--panel);
  box-shadow: var(--shadow);
}

.card h3 {
  margin-top: 0;
}

.progress-track {
  height: 12px;
  border-radius: 999px;
  background: rgba(32, 65, 60, 0.14);
  overflow: hidden;
}

.progress-bar {
  height: 100%;
  width: 0%;
  background: linear-gradient(90deg, #2a9e75, #1c6f5e);
  transition: width 0.2s ease;
}

.tip {
  margin-bottom: 0;
  font-size: 0.9rem;
}

.success {
  color: var(--ok);
}

.warning {
  color: var(--warn);
}

.report-cards {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(190px, 1fr));
  gap: 12px;
  margin-bottom: 12px;
}

.report-metric {
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 10px;
  background: var(--panel);
}

.report-metric .label {
  color: var(--muted);
  font-size: 0.85rem;
}

.report-metric .value {
  margin-top: 5px;
  font-size: 1.4rem;
  font-weight: 700;
}

.history-bars {
  display: grid;
  gap: 6px;
}

.history-row {
  display: grid;
  grid-template-columns: 90px 1fr 42px;
  align-items: center;
  gap: 8px;
  font-size: 0.88rem;
}

.history-track {
  height: 10px;
  border-radius: 999px;
  background: rgba(33, 63, 59, 0.16);
  overflow: hidden;
}

.history-fill {
  height: 100%;
  background: linear-gradient(90deg, #d48639, #ba6023);
}

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

.strong {
  color: var(--primary-2);
  font-weight: 700;
}

@media (max-width: 720px) {
  .app-shell {
    padding: 12px 10px 30px;
  }

  .app-header {
    padding: 14px;
  }

  .quick-stats {
    width: 100%;
    grid-template-columns: repeat(4, minmax(70px, 1fr));
  }

  .history-row {
    grid-template-columns: 72px 1fr 34px;
  }
}
