:root {
  --bg: #fffbf7;
  --panel: rgba(255,255,255,0.78);
  --card: #ffffff;
  --text: #1f2937;
  --muted: #64748b;
  --line: #e2e8f0;
  --emerald: #10b981;
  --emerald-dark: #047857;
  --emerald-soft: #ecfdf5;
  --blue-soft: #eff6ff;
  --blue-text: #1d4ed8;
  --amber-soft: #fff7ed;
  --amber-text: #b45309;
  --rose-soft: #fff1f2;
  --rose-text: #be123c;
  --shadow: 0 20px 50px rgba(15, 23, 42, 0.08);
  --radius-xl: 24px;
  --radius-2xl: 34px;
}

* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
body {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC", "Hiragino Sans GB", "Microsoft YaHei", sans-serif;
  background: radial-gradient(circle at top right, rgba(16,185,129,.09), transparent 28%),
              radial-gradient(circle at bottom left, rgba(59,130,246,.07), transparent 32%),
              var(--bg);
  color: var(--text);
}
button, input, textarea { font: inherit; }
a { color: inherit; text-decoration: none; }

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

.container {
  width: min(1120px, calc(100% - 32px));
  margin: 0 auto;
}

.topbar {
  position: sticky;
  top: 0;
  z-index: 40;
  backdrop-filter: blur(18px);
  background: rgba(255,255,255,0.78);
  border-bottom: 1px solid rgba(226,232,240,.8);
  border-radius: 0 0 22px 22px;
}

.topbar-inner {
  display: flex;
  align-items: center;
  justify-content: space-between;
  min-height: 68px;
  gap: 12px;
}

.brand {
  display: flex;
  align-items: center;
  gap: 12px;
  cursor: pointer;
  font-weight: 800;
  font-size: 1.05rem;
}

.brand-badge {
  width: 36px;
  height: 36px;
  border-radius: 12px;
  background: linear-gradient(135deg, #10b981, #34d399);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  color: white;
  box-shadow: 0 12px 25px rgba(16,185,129,.28);
  font-size: 18px;
}

.nav-links {
  display: flex;
  align-items: center;
  gap: 20px;
}

.nav-links button,
.lang-toggle,
.chip,
.link-btn,
.plain-btn,
.quick-exit,
.icon-btn,
.primary-btn,
.secondary-btn,
.card-button,
.option-btn,
.back-btn,
.pill-btn,
.text-link {
  border: 0;
  background: transparent;
  cursor: pointer;
}

.nav-links button {
  color: #64748b;
  font-weight: 600;
  padding: 10px 0;
}

.nav-links button.active {
  color: var(--emerald);
}

.lang-toggle {
  background: #f1f5f9;
  color: #334155;
  padding: 10px 14px;
  border-radius: 999px;
  font-size: 12px;
  font-weight: 800;
  display: inline-flex;
  align-items: center;
  gap: 8px;
}

.main {
  padding: 36px 0 84px;
}

.hero {
  display: grid;
  gap: 28px;
}

.hero h1 {
  font-size: clamp(2.8rem, 6vw, 4.8rem);
  line-height: 1.06;
  margin: 0;
  letter-spacing: -0.04em;
}

.hero-accent {
  color: var(--emerald);
  display: inline-block;
  transform: rotate(-8deg);
}

.hero p {
  margin: 0;
  color: #64748b;
  font-size: 1.1rem;
  line-height: 1.8;
  max-width: 760px;
}

.card-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 18px;
}

.card-button,
.tool-card,
.panel,
.stacked-card,
.result-card,
.study-highlight,
.textarea-wrap {
  background: var(--card);
  border: 1px solid rgba(226,232,240,.85);
  border-radius: var(--radius-2xl);
  box-shadow: var(--shadow);
}

.card-button {
  padding: 28px;
  text-align: left;
  transition: transform .18s ease, box-shadow .18s ease, border-color .18s ease;
}

.card-button:hover,
.tool-card:hover {
  transform: translateY(-3px);
  box-shadow: 0 24px 55px rgba(15, 23, 42, 0.12);
}

.card-button.amber { background: linear-gradient(180deg, #fffaf0 0%, #fff 100%); border-color: #fed7aa; color: #9a3412; }
.card-button.green { background: linear-gradient(180deg, #f0fdf4 0%, #fff 100%); border-color: #bbf7d0; color: #047857; }
.card-button.blue  { background: linear-gradient(180deg, #eff6ff 0%, #fff 100%); border-color: #bfdbfe; color: #1d4ed8; }

.card-icon,
.tool-icon,
.study-icon {
  width: 52px;
  height: 52px;
  border-radius: 18px;
  background: white;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: 24px;
  box-shadow: 0 10px 20px rgba(15, 23, 42, 0.07);
}

.card-title {
  margin: 20px 0 8px;
  font-size: 1.25rem;
  font-weight: 800;
}

.card-desc {
  color: rgba(15,23,42,.72);
  font-size: .98rem;
  line-height: 1.65;
  min-height: 50px;
}

.card-arrow {
  margin-top: 18px;
  display: flex;
  justify-content: flex-end;
  font-size: 20px;
}

.privacy-note,
.section-sub,
.small-muted,
.footer-note,
.list-text,
.panel p,
.about-copy {
  color: var(--muted);
  line-height: 1.75;
}

.section-head {
  margin-bottom: 22px;
}

.section-title {
  margin: 0 0 8px;
  font-size: clamp(2rem, 4vw, 3rem);
  letter-spacing: -0.04em;
}

.tool-grid,
.option-grid,
.checkin-actions,
.pill-row {
  display: grid;
  gap: 14px;
}

.tool-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.option-grid.two { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.option-grid.one, .checkin-actions, .pill-row { grid-template-columns: 1fr; }

.tool-card {
  padding: 22px;
  display: flex;
  gap: 16px;
  align-items: flex-start;
  transition: .18s ease;
}

.tool-card-title {
  margin: 0 0 6px;
  font-size: 1.1rem;
  font-weight: 800;
}

.tool-card p { margin: 0; color: var(--muted); line-height: 1.65; }
.tool-open { margin-top: 14px; color: var(--emerald); font-size: .9rem; font-weight: 800; }

.panel {
  padding: 28px;
}

.checkin-wrap,
.about-wrap,
.study-wrap {
  max-width: 860px;
  margin: 0 auto;
}

.back-btn {
  color: #94a3b8;
  font-size: .95rem;
  margin-bottom: 16px;
}

.option-btn,
.pill-btn,
.primary-btn,
.secondary-btn,
.icon-btn,
.link-btn {
  transition: .18s ease;
}

.option-btn {
  padding: 16px 18px;
  width: 100%;
  border-radius: 22px;
  border: 1px solid #e2e8f0;
  background: white;
  text-align: left;
  color: var(--text);
}

.option-btn:hover,
.option-btn.selected,
.pill-btn.selected {
  border-color: #6ee7b7;
  background: #f0fdf4;
}

.result-card {
  padding: 28px;
  border: 2px solid #d1fae5;
  max-width: 560px;
  margin: 0 auto;
}

.result-card .cta-box,
.info-box,
.crisis-box {
  border-radius: 22px;
  padding: 18px 20px;
}

.cta-box { background: #ecfdf5; color: #047857; font-weight: 800; display: flex; align-items: center; justify-content: space-between; }
.info-box { background: #f8fafc; border: 1px solid #e2e8f0; color: #475569; }
.public-box { background: #eff6ff; border: 1px solid #bfdbfe; color: #1d4ed8; }
.crisis-box { background: #fff1f2; border: 1px solid #fecdd3; color: #be123c; font-weight: 800; }

.quick-exit {
  position: fixed;
  right: 24px;
  bottom: 24px;
  z-index: 45;
  background: #0f172a;
  color: white;
  padding: 14px 20px;
  border-radius: 999px;
  box-shadow: 0 18px 35px rgba(15,23,42,.24);
  display: inline-flex;
  align-items: center;
  gap: 10px;
  font-weight: 800;
}

.about-cards {
  display: grid;
  gap: 18px;
}

.notice-card {
  display: flex;
  gap: 14px;
  padding: 22px;
  border-radius: 28px;
  border: 1px solid transparent;
}

.notice-card.amber { background: var(--amber-soft); border-color: #fde68a; color: #92400e; }
.notice-card.blue { background: var(--blue-soft); border-color: #bfdbfe; color: #1d4ed8; }

.study-page,
.breathing-page {
  min-height: 100vh;
  position: relative;
  background: #fdfcfb;
}

.study-header,
.breathing-header {
  position: sticky;
  top: 0;
  z-index: 50;
  backdrop-filter: blur(18px);
  background: rgba(255,255,255,.55);
  border-bottom: 1px solid rgba(226,232,240,.8);
}

.header-inner {
  min-height: 76px;
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.header-title { font-weight: 800; }

.study-main,
.breathing-main {
  padding: 52px 0 88px;
}

.study-intro {
  text-align: center;
  display: grid;
  gap: 28px;
  max-width: 860px;
  margin: 0 auto;
}

.study-icon {
  margin: 0 auto;
  width: 96px;
  height: 96px;
  border-radius: 32px;
  font-size: 40px;
}

.study-intro h1,
.breathing-done h2 {
  margin: 0;
  letter-spacing: -0.04em;
  font-size: clamp(2.2rem, 5vw, 4rem);
}

.study-intro p,
.breathing-done p {
  max-width: 760px;
  margin: 0 auto;
  color: var(--muted);
  line-height: 1.85;
  font-size: 1.05rem;
}

.action-row {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 14px;
}

.primary-btn,
.secondary-btn {
  padding: 15px 26px;
  border-radius: 20px;
  font-weight: 800;
}

.primary-btn { background: var(--emerald); color: white; box-shadow: 0 20px 35px rgba(16,185,129,.22); }
.primary-btn:hover { transform: translateY(-2px); }
.primary-btn.dark { background: #0f172a; box-shadow: none; }
.primary-btn:disabled { background: #e2e8f0; color: #94a3b8; cursor: not-allowed; box-shadow: none; }
.secondary-btn { background: white; border: 1px solid #e2e8f0; color: #475569; }

.study-form {
  max-width: 860px;
  margin: 0 auto;
  display: grid;
  gap: 24px;
}

.pill-row {
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
  justify-content: center;
}

.pill-btn {
  padding: 12px 18px;
  border-radius: 999px;
  background: white;
  border: 1px solid #e2e8f0;
  color: #64748b;
  font-weight: 700;
}

.pill-btn.selected {
  background: var(--emerald);
  color: white;
  border-color: var(--emerald);
}

.textarea-wrap {
  position: relative;
  padding: 22px;
}

.textarea-wrap textarea {
  width: 100%;
  min-height: 220px;
  border: 0;
  resize: vertical;
  outline: 0;
  background: transparent;
  font-size: 1.04rem;
  color: var(--text);
  line-height: 1.85;
}

.textarea-wrap textarea::placeholder { color: #cbd5e1; }

.loading-overlay {
  position: absolute;
  inset: 0;
  border-radius: inherit;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 14px;
  background: rgba(255,255,255,.78);
}

.spinner {
  width: 42px;
  height: 42px;
  border-radius: 50%;
  border: 4px solid #a7f3d0;
  border-top-color: var(--emerald);
  animation: spin 1s linear infinite;
}

@keyframes spin {
  to { transform: rotate(360deg); }
}

.study-result {
  max-width: 900px;
  margin: 0 auto;
  display: grid;
  gap: 26px;
}

.study-highlight {
  padding: 28px;
  background: linear-gradient(135deg, #064e3b, #065f46);
  color: white;
  display: flex;
  gap: 18px;
  align-items: flex-start;
}

.study-highlight small {
  color: rgba(167,243,208,.95);
  text-transform: uppercase;
  letter-spacing: .15em;
  font-weight: 800;
}

.study-highlight h3 {
  margin: 8px 0;
  font-size: 1.9rem;
}

.stacked-card {
  padding: 24px;
}

.stacked-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 16px;
}

.stacked-card h4 {
  margin: 0 0 14px;
  font-size: 1.05rem;
}

.stacked-card ul {
  margin: 0;
  padding-left: 20px;
  color: var(--muted);
  line-height: 1.8;
}

.end-note {
  text-align: center;
  color: #94a3b8;
  font-style: italic;
}

.text-link {
  color: #94a3b8;
  font-weight: 700;
  text-decoration: underline;
}

.breathing-page {
  display: flex;
  flex-direction: column;
}

.breathing-main {
  flex: 1;
  display: flex;
  align-items: center;
  justify-content: center;
}

.breathing-wrap {
  display: grid;
  gap: 36px;
  justify-items: center;
  text-align: center;
}

.breath-circle {
  width: min(64vw, 280px);
  height: min(64vw, 280px);
  border-radius: 50%;
  background: #f8fafc;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
  box-shadow: inset 0 0 0 14px rgba(255,255,255,.5), 0 30px 60px rgba(15,23,42,.08);
  transform: scale(1);
  transition: transform 4s linear, background .35s ease, color .35s ease;
}

.breath-circle.inhale {
  transform: scale(1.2);
  background: #d1fae5;
  color: #047857;
}

.breath-circle.exhale {
  transform: scale(1);
  background: #dbeafe;
  color: #1d4ed8;
}

.breath-circle.hold {
  background: #fef9c3;
  color: #854d0e;
}

.breath-phase {
  font-size: clamp(1.8rem, 4vw, 2.3rem);
  font-weight: 800;
}

.timer {
  color: #cbd5e1;
  font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, monospace;
  letter-spacing: .12em;
}

.controls {
  display: flex;
  gap: 14px;
  align-items: center;
}

.icon-btn {
  width: 68px;
  height: 68px;
  border-radius: 999px;
  background: white;
  color: var(--emerald-dark);
  box-shadow: var(--shadow);
  font-size: 22px;
}

.icon-btn.small {
  width: 52px;
  height: 52px;
  color: #64748b;
  background: rgba(255,255,255,.9);
}

.breathing-done {
  text-align: center;
  display: grid;
  gap: 18px;
  justify-items: center;
}

.center-heart {
  width: 82px;
  height: 82px;
  border-radius: 999px;
  background: #ecfdf5;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  color: var(--emerald);
  font-size: 38px;
}

.hidden-mobile { display: inline-flex; }
.mobile-only { display: none; }

@media (max-width: 900px) {
  .card-grid,
  .tool-grid,
  .stacked-grid,
  .option-grid.two {
    grid-template-columns: 1fr;
  }

  .hero p { font-size: 1rem; }
  .quick-exit { right: 16px; bottom: 16px; }
}

@media (max-width: 720px) {
  .hidden-mobile { display: none; }
  .mobile-only { display: inline-flex; }
  .topbar-inner { min-height: 62px; }
  .main { padding-top: 24px; }
  .card-button, .panel, .tool-card, .stacked-card, .study-highlight, .result-card { border-radius: 24px; }
  .hero h1 { font-size: 2.5rem; }
  .section-title { font-size: 2rem; }
  .header-inner { min-height: 70px; }
  .quick-exit { width: calc(100% - 32px); justify-content: center; }
}
