:root {
  --bg: #f7f4ee;
  --surface: #fffdf9;
  --surface-soft: #eef4f0;
  --ink: #203432;
  --muted: #6e7d79;
  --line: #e3e8e2;
  --accent: #2d7c74;
  --accent-dark: #225f59;
  --accent-soft: #dcece5;
  --gold: #f4c86a;
  --danger: #a24f42;
  --shadow: 0 18px 45px rgba(36, 68, 62, .10);
  font-family: "Segoe UI", "Microsoft YaHei", system-ui, sans-serif;
  color: var(--ink);
  background: var(--bg);
  font-synthesis: none;
}

* { box-sizing: border-box; }

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

body {
  margin: 0;
  min-width: 320px;
  min-height: 100vh;
  background: var(--bg);
}

button, input { font: inherit; }
button { cursor: pointer; }
button:focus-visible, input:focus-visible { outline: 3px solid rgba(45, 124, 116, .28); outline-offset: 3px; }
[hidden] { display: none !important; }

.app-shell { min-height: 100vh; }

.login-view {
  min-height: 100svh;
  display: grid;
  place-items: center;
  position: relative;
  overflow: hidden;
  padding: 32px 20px;
}

.login-view::before, .login-view::after {
  content: "";
  position: absolute;
  border-radius: 50%;
  filter: blur(1px);
  pointer-events: none;
}

.login-view::before { width: 480px; height: 480px; background: #e5f0e9; top: -220px; right: -170px; }
.login-view::after { width: 360px; height: 360px; background: #f5e7c9; bottom: -180px; left: -160px; }

.login-content {
  position: relative;
  z-index: 1;
  width: min(100%, 430px);
  padding: 42px 34px 36px;
  background: rgba(255, 253, 249, .86);
  border: 1px solid rgba(255,255,255,.8);
  border-radius: 30px;
  box-shadow: var(--shadow);
  backdrop-filter: blur(10px);
}

.brand-mark {
  width: 58px;
  height: 58px;
  display: grid;
  place-items: center;
  border-radius: 19px;
  color: #fffdf9;
  background: var(--accent);
  font-size: 29px;
  font-weight: 800;
  letter-spacing: -.06em;
  box-shadow: 0 10px 24px rgba(45, 124, 116, .22);
}

.eyebrow {
  margin: 0 0 6px;
  color: var(--accent);
  font-size: 13px;
  font-weight: 800;
  letter-spacing: .13em;
  text-transform: uppercase;
}

h1, h2, h3, p { margin-top: 0; }
h1 { margin-bottom: 8px; font-size: clamp(28px, 7vw, 40px); line-height: 1.12; letter-spacing: -.04em; }
h2 { margin-bottom: 10px; font-size: clamp(24px, 6vw, 34px); line-height: 1.16; letter-spacing: -.035em; }
h3 { margin-bottom: 6px; font-size: 18px; line-height: 1.3; }

.login-content h1 { margin-top: 24px; }
.login-copy { color: var(--muted); line-height: 1.7; font-size: 16px; }
.login-form { margin-top: 28px; }
.login-form label { display: block; margin-bottom: 8px; font-weight: 700; }
.login-form input {
  width: 100%;
  height: 54px;
  border: 1px solid var(--line);
  border-radius: 15px;
  padding: 0 16px;
  color: var(--ink);
  background: #fff;
}

.primary-button, .secondary-button, .quiet-button, .text-button {
  min-height: 48px;
  border-radius: 14px;
  padding: 0 18px;
  font-weight: 800;
  transition: transform .18s ease, background .18s ease, color .18s ease, border-color .18s ease, box-shadow .18s ease;
}

.primary-button { width: 100%; margin-top: 15px; border: 1px solid var(--accent); color: #fff; background: var(--accent); box-shadow: 0 10px 20px rgba(45, 124, 116, .18); }
.primary-button:hover, .secondary-button:hover, .quiet-button:hover { transform: translateY(-1px); }
.primary-button:hover { border-color: var(--accent-dark); background: var(--accent-dark); box-shadow: 0 12px 24px rgba(45, 124, 116, .22); }
.primary-button:active, .secondary-button:active, .quiet-button:active, .track-action:active, .loop-toggle:active, .book-controls button:active { transform: translateY(1px); }
.secondary-button { border: 1px solid #b9d8ce; color: var(--accent-dark); background: var(--accent-soft); box-shadow: 0 4px 10px rgba(45,124,116,.07); }
.secondary-button:hover { border-color: #8fc3b5; background: #e5f4ed; box-shadow: 0 6px 14px rgba(45,124,116,.12); }
.quiet-button { display: inline-flex; align-items: center; justify-content: center; gap: 7px; min-height: 44px; padding: 0 14px; border: 1px solid #a9cec1; border-radius: 13px; color: var(--accent-dark); background: #f3faf6; box-shadow: 0 4px 11px rgba(45,124,116,.09); white-space: nowrap; }
.quiet-button:hover { border-color: #7fb8a8; background: #e6f4ed; box-shadow: 0 7px 16px rgba(45,124,116,.14); }
.text-button { min-height: 40px; padding: 0 10px; border: 1px solid transparent; color: var(--accent-dark); background: transparent; }
.text-button:hover { border-color: #c5ddd4; border-radius: 10px; background: #f1f8f4; }
.install-icon { display: inline-grid; place-items: center; width: 20px; height: 20px; border: 1.5px solid currentColor; border-radius: 6px; font-size: 16px; line-height: 1; }
.form-error { margin: 12px 0 0; color: var(--danger); font-size: 14px; }

.login-art { position: absolute; inset: 0; pointer-events: none; }
.sun { position: absolute; top: 12%; right: 13%; width: 88px; height: 88px; border-radius: 50%; background: var(--gold); opacity: .78; }
.leaf { position: absolute; width: 120px; height: 44px; border-radius: 100% 0 100% 0; background: #c4ddd0; transform: rotate(-25deg); opacity: .7; }
.leaf-a { left: 9%; top: 20%; }
.leaf-b { right: 8%; bottom: 21%; transform: rotate(28deg); background: #d8e8d6; }

#main-view { width: min(100%, 1120px); min-height: 100vh; margin: 0 auto; padding: 24px 20px 110px; }
.topbar { display: flex; align-items: center; justify-content: space-between; gap: 16px; margin: 0 auto 28px; }
.topbar h1 { margin: 0; font-size: 28px; }
.topbar .eyebrow { margin-bottom: 3px; }
.content { min-height: 60vh; }

.page-heading { display: flex; align-items: end; justify-content: space-between; gap: 16px; margin-bottom: 22px; }
.page-heading p { margin: 0; color: var(--muted); line-height: 1.55; }
.section { margin-top: 30px; }
.section-heading { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-bottom: 12px; }
.section-heading h2, .section-heading h3 { margin: 0; }
.section-heading h2 { font-size: 21px; }
.section-heading h3 { font-size: 17px; }
.muted { color: var(--muted); }
.small { color: var(--muted); font-size: 14px; line-height: 1.55; }

.continue-panel {
  display: grid;
  grid-template-columns: minmax(140px, 210px) 1fr;
  gap: 22px;
  align-items: stretch;
  overflow: hidden;
  border-radius: 26px;
  background: var(--accent-dark);
  color: #fff;
  box-shadow: var(--shadow);
}
.continue-image { position: relative; display: grid; place-items: center; height: 170px; min-height: 0; overflow: hidden; border-radius: 26px 0 0 26px; background: #426f68; }
.continue-image img { display: block; width: 100%; height: 170px; object-fit: cover; object-position: center top; background: #426f68; border-radius: 0; -webkit-mask-image: linear-gradient(to bottom, #000 0%, #000 68%, rgba(0,0,0,.75) 84%, transparent 100%); mask-image: linear-gradient(to bottom, #000 0%, #000 68%, rgba(0,0,0,.75) 84%, transparent 100%); }
.continue-image::after { position: absolute; z-index: 1; right: 0; bottom: -1px; left: 0; height: 42px; content: ''; background: transparent; -webkit-backdrop-filter: blur(3px); backdrop-filter: blur(3px); -webkit-mask-image: linear-gradient(to bottom, transparent 0%, transparent 35%, #000 100%); mask-image: linear-gradient(to bottom, transparent 0%, transparent 35%, #000 100%); pointer-events: none; }
.continue-copy { padding: 27px 26px 25px 0; }
.continue-copy .eyebrow { color: #cfe9df; }
.continue-copy h2 { margin-bottom: 8px; font-size: clamp(24px, 5vw, 34px); }
.continue-copy p { color: rgba(255,255,255,.76); line-height: 1.6; }
.continue-copy .primary-button { width: auto; min-width: 144px; margin-top: 7px; color: var(--accent-dark); background: #fffdf9; box-shadow: none; }

.next-row, .record-row, .track-row, .course-row {
  display: flex;
  align-items: center;
  gap: 14px;
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 18px;
  padding: 13px;
  color: inherit;
  text-align: left;
  background: rgba(255, 253, 249, .78);
}
.next-row, .record-row, .track-row { border-radius: 15px; }
.next-row:hover, .record-row:hover, .track-row:hover, .course-row:hover { border-color: #b7d5cb; background: #fff; }
.row-thumb { width: 70px; height: 58px; flex: 0 0 auto; display: grid; place-items: center; overflow: hidden; border-radius: 12px; color: var(--accent-dark); background: var(--surface-soft); font-weight: 800; }
.row-thumb img { width: 100%; height: 100%; object-fit: contain; }
.row-main { min-width: 0; flex: 1; }
.row-main strong, .row-main span { display: block; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.row-main strong { font-size: 16px; }
.row-main span { margin-top: 4px; color: var(--muted); font-size: 14px; }
.row-arrow { color: var(--accent); font-size: 25px; }

.link-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 12px; }
.link-tile { display: flex; flex-direction: column; align-items: flex-start; gap: 7px; min-height: 112px; padding: 18px; border: 1px solid var(--line); border-radius: 18px; color: var(--ink); background: var(--surface); text-align: left; }
.link-tile:hover { border-color: #b7d5cb; }
.link-tile .tile-icon { color: var(--accent); font-size: 28px; }
.link-tile strong { font-size: 16px; }
.link-tile span:last-child { color: var(--muted); font-size: 14px; }

.course-list, .track-list, .record-list { display: grid; gap: 10px; }
.course-row { align-items: stretch; padding: 10px; }
.course-row .row-thumb { width: 112px; height: 88px; }
.course-row .row-main { align-self: center; }
.status-line { display: flex; flex-wrap: wrap; gap: 7px; margin-top: 8px; }
.status-badge { display: inline-flex; align-items: center; gap: 5px; padding: 5px 9px; border-radius: 999px; color: var(--accent-dark); background: var(--accent-soft); font-size: 12px; font-weight: 800; }
.status-badge.neutral { color: var(--muted); background: #eef1ef; }
.status-badge.done { color: #54723e; background: #e7f0d9; }

.back-button { display: inline-flex; align-items: center; gap: 8px; min-height: 44px; margin-bottom: 16px; padding: 0 14px; border: 1px solid #b9d7ce; border-radius: 12px; color: var(--accent-dark); background: #f4faf6; box-shadow: 0 4px 10px rgba(45,124,116,.08); font-weight: 800; cursor: pointer; transition: background .18s ease, border-color .18s ease, box-shadow .18s ease, transform .18s ease; }
.back-button:hover { border-color: #8fc3b5; background: #eaf6f0; box-shadow: 0 6px 14px rgba(45,124,116,.13); }
.back-button:active { transform: translateY(1px); box-shadow: 0 2px 5px rgba(45,124,116,.08); }
.detail-hero { display: grid; grid-template-columns: 210px 1fr; gap: 22px; align-items: center; padding-bottom: 24px; border-bottom: 1px solid var(--line); }
.detail-cover { width: 100%; aspect-ratio: 1.25; display: grid; place-items: center; overflow: hidden; border-radius: 22px; background: var(--surface-soft); }
.detail-cover img { width: 100%; height: 100%; object-fit: contain; }
.detail-hero h2 { margin-bottom: 7px; }
.detail-note { margin: 0; color: var(--muted); line-height: 1.55; }
.detail-progress { margin-top: 14px; }
.progress-line { height: 8px; overflow: hidden; border-radius: 99px; background: #e2e9e4; }
.progress-line span { display: block; height: 100%; border-radius: inherit; background: var(--accent); }
.content-group { margin-top: 27px; }
.content-group h3 { margin-bottom: 10px; }
.track-row { align-items: flex-start; }
.track-row .row-main strong { white-space: normal; line-height: 1.35; }
.track-row .row-main span { white-space: normal; line-height: 1.35; }
.track-action { flex: 0 0 auto; min-height: 42px; padding: 0 13px; border: 1px solid #c5ddd4; border-radius: 12px; color: var(--accent-dark); background: #f4faf6; font-weight: 800; }

.player-shell { max-width: 760px; margin: 0 auto; }
.player-top { display: flex; align-items: center; justify-content: space-between; gap: 14px; }
.player-top .back-button { margin-bottom: 0; }
.player-art { display: grid; place-items: center; width: min(100%, 520px); margin: 12px auto 22px; border-radius: 28px; background: var(--surface-soft); }
.player-art img { display: block; width: 100%; height: auto; max-height: 66svh; object-fit: contain; border-radius: 28px; }
.player-title { text-align: center; }
.player-title .eyebrow { margin-bottom: 7px; }
.player-title h2 { margin-bottom: 5px; font-size: clamp(22px, 5.5vw, 31px); }
.player-title p { margin-bottom: 20px; color: var(--muted); line-height: 1.55; }
.audio-progress { width: 100%; accent-color: var(--accent); }
.time-row { display: flex; justify-content: space-between; margin-top: 5px; color: var(--muted); font-size: 13px; }
.player-controls { display: flex; align-items: center; justify-content: center; gap: 20px; margin: 23px 0 18px; }
.icon-button { width: 54px; height: 54px; display: grid; place-items: center; border: 1px solid var(--line); border-radius: 50%; color: var(--accent-dark); background: var(--surface); font-size: 22px; }
.play-button { width: 70px; height: 70px; border: 0; border-radius: 50%; color: #fff; background: var(--accent); font-size: 28px; box-shadow: 0 10px 22px rgba(45,124,116,.25); }
.play-button:hover { background: var(--accent-dark); }
.player-options { display: flex; justify-content: center; gap: 12px; flex-wrap: wrap; }
.loop-toggle { min-height: 42px; padding: 0 14px; border: 1px solid var(--line); border-radius: 12px; color: var(--muted); background: var(--surface); }
.loop-toggle.active { color: var(--accent-dark); border-color: #acd1c3; background: var(--accent-soft); font-weight: 800; }
.sync-status { min-height: 24px; margin: 14px 0 0; color: var(--muted); text-align: center; font-size: 13px; }
.book-panel { margin: 12px 0 24px; padding: 14px; border: 1px solid var(--line); border-radius: 20px; background: var(--surface); touch-action: pan-y; }
.book-panel img { width: 100%; max-height: 62svh; display: block; object-fit: contain; border-radius: 12px; background: #f0eee8; }
.book-controls { display: flex; align-items: center; justify-content: space-between; gap: 10px; margin-top: 12px; }
.book-controls button { min-height: 44px; padding: 0 13px; border: 1px solid var(--line); border-radius: 12px; color: var(--accent-dark); background: #fff; font-weight: 700; }
.book-controls button:disabled { cursor: default; color: #a4afab; background: #f3f4f1; }
.book-page-count { color: var(--muted); font-size: 14px; }
.next-track { display: flex; align-items: center; justify-content: space-between; gap: 14px; margin-top: 18px; padding: 14px 16px; border-radius: 16px; color: var(--ink); background: var(--surface-soft); }
.next-track p { margin: 0; color: var(--muted); font-size: 13px; }

.empty-state { padding: 40px 22px; border: 1px dashed #cfd9d2; border-radius: 20px; text-align: center; background: rgba(255,253,249,.55); }
.empty-state p { color: var(--muted); line-height: 1.65; }
.empty-state .secondary-button { margin-top: 4px; }
.record-date { margin: 26px 0 9px; color: var(--accent-dark); font-size: 14px; font-weight: 800; }
.record-row { padding: 15px; }
.record-row .row-main strong { white-space: normal; }

.bottom-nav { position: fixed; z-index: 20; right: 50%; bottom: max(12px, env(safe-area-inset-bottom)); display: flex; width: min(calc(100% - 28px), 420px); transform: translateX(50%); padding: 6px; border: 1px solid rgba(211,225,218,.95); border-radius: 22px; background: rgba(255,253,249,.97); box-shadow: 0 16px 40px rgba(36,68,62,.18), 0 2px 8px rgba(36,68,62,.07); backdrop-filter: blur(16px) saturate(115%); }
.bottom-nav button { flex: 1; min-height: 56px; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 3px; border: 1px solid transparent; border-radius: 16px; color: var(--muted); background: transparent; font-size: 12px; font-weight: 800; transition: color .18s ease, background .18s ease, border-color .18s ease, transform .18s ease; }
.bottom-nav button:hover { color: var(--accent-dark); background: #f2f8f5; }
.bottom-nav button:active { transform: translateY(1px); }
.bottom-nav button.active { border-color: #c8e2d8; color: var(--accent-dark); background: #e4f3ed; box-shadow: inset 0 1px 0 rgba(255,255,255,.8), 0 3px 9px rgba(45,124,116,.10); }
.nav-icon { font-size: 22px; line-height: 1; }
.toast { position: fixed; z-index: 50; right: 50%; bottom: 88px; max-width: calc(100% - 36px); transform: translateX(50%); padding: 12px 16px; border-radius: 12px; color: #fff; background: #263d39; box-shadow: var(--shadow); font-size: 14px; }

@media (min-width: 760px) {
  #main-view { padding: 36px 34px 110px; }
  .home-grid { display: grid; grid-template-columns: minmax(0, 1.45fr) minmax(280px, .75fr); gap: 28px; align-items: start; }
  .home-grid > .section:first-child { margin-top: 0; }
  .home-side { display: grid; gap: 22px; }
  .link-grid { grid-template-columns: 1fr; }
  .course-list { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}

@media (max-width: 560px) {
  .login-content { padding: 34px 24px 28px; }
  #main-view { padding-left: 15px; padding-right: 15px; }
  .topbar { margin-bottom: 22px; }
  .topbar h1 { font-size: 25px; }
  .quiet-button { padding: 0 12px; font-size: 13px; }
  .continue-panel { grid-template-columns: 1fr; gap: 0; }
  .continue-image { height: 300px; }
  .continue-image { border-radius: 26px 26px 0 0; }
  .continue-image img { height: 300px; }
  .continue-copy { padding: 21px 20px 22px; }
  .detail-hero { grid-template-columns: 116px 1fr; gap: 15px; }
  .detail-cover { border-radius: 16px; }
  .course-row .row-thumb { width: 88px; height: 78px; }
  .track-row { gap: 9px; }
  .track-action { padding: 0 10px; font-size: 13px; }
  .player-art { margin-top: 8px; border-radius: 21px; }
  .player-art img { max-height: 52svh; border-radius: 21px; }
  .player-controls { gap: 14px; }
  .icon-button { width: 50px; height: 50px; }
  .play-button { width: 64px; height: 64px; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { scroll-behavior: auto !important; transition: none !important; animation: none !important; }
}
