/* ===================================================================
   Breathing Coach — Sage green accent, dark breathing stage.
   =================================================================== */

:root {
  --bg:           #faf6f1;
  --bg-2:         #f3eee5;
  --surface:      #ffffff;
  --surface-2:    #faf6ed;
  --border:       #e8dfcc;
  --border-soft:  #f0e9da;
  --text:         #1f1a14;
  --text-2:       #5c5547;
  --text-3:       #6e6557;

  --accent:       #e85f4d;
  --accent-2:     #d44a39;
  --accent-soft:  rgba(232, 95, 77, 0.10);
  --accent-glow:  rgba(232, 95, 77, 0.30);

  --sage:         #5eb985;
  --sage-2:       #3a9d6f;
  --sage-soft:    rgba(94, 185, 133, 0.12);
  --sage-glow:    rgba(94, 185, 133, 0.35);

  --amber:        #d4a853;
  --lavender:     #7ba4d9;

  --r-sm:  8px;
  --r-md:  12px;
  --r-lg:  16px;
  --r-xl:  20px;
  --r-pill: 999px;

  --shadow-sm: 0 1px 2px rgba(0,0,0,0.04);
  --shadow-md: 0 4px 12px rgba(0,0,0,0.06);
  --shadow-lg: 0 24px 48px rgba(0,0,0,0.12);

  --font-ui: -apple-system, BlinkMacSystemFont, "Inter", "Segoe UI",
             "PingFang TC", "PingFang SC", "Hiragino Sans", "Noto Sans CJK", sans-serif;
  --font-mono: "SF Mono", Menlo, Consolas, monospace;

  --transition: 200ms cubic-bezier(0.4, 0, 0.2, 1);
}

* { box-sizing: border-box; margin: 0; padding: 0; }
html { font-size: 16px; }
html, body {
  font-family: var(--font-ui);
  background:
    radial-gradient(ellipse 80% 50% at 50% 0%, rgba(220, 245, 230, 0.35) 0%, transparent 70%),
    var(--bg);
  background-attachment: fixed;
  color: var(--text);
  min-height: 100vh;
  -webkit-font-smoothing: antialiased;
  line-height: 1.55;
  touch-action: manipulation;
}
button { font-family: inherit; cursor: pointer; border: none; background: none; color: inherit; }
input, select { font-family: inherit; color: inherit; }
a { color: var(--accent); text-decoration: none; transition: color var(--transition); }
a:hover { color: var(--accent-2); }
ul, ol { list-style: none; }

.skip-link {
  position: absolute;
  left: -9999px; top: 0;
  background: var(--accent);
  color: #fff;
  padding: 10px 16px;
  font-weight: 600;
  border-radius: 0 0 var(--r-sm) 0;
  z-index: 1000;
}
.skip-link:focus { left: 0; }

.app {
  max-width: 880px;
  margin: 0 auto;
  padding: clamp(12px, 3vw, 24px) clamp(12px, 3vw, 24px) 80px;
}

/* ============ Topbar ============ */
.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 8px 4px 28px;
}
.brand {
  font-weight: 600;
  font-size: 15px;
  color: var(--text-2);
}
.brand:hover { color: var(--accent); }

.topbar-right {
  display: flex;
  align-items: center;
  gap: 12px;
}
.nav-link {
  font-size: 13px;
  font-weight: 500;
  color: var(--text-3);
  padding: 6px 10px;
  border-radius: var(--r-sm);
  white-space: nowrap;
  transition: background var(--transition), color var(--transition);
}
.nav-link:hover {
  color: var(--accent);
  background: var(--surface-2);
}

.lang-switcher {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--r-sm);
  padding: 6px 28px 6px 10px;
  font-size: 13px;
  font-weight: 500;
  color: var(--text);
  cursor: pointer;
  appearance: none;
  -webkit-appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg viewBox='0 0 12 12' xmlns='http://www.w3.org/2000/svg'%3E%3Cpath d='M3 5l3 3 3-3' stroke='%237a7973' stroke-width='1.5' fill='none' stroke-linecap='round' stroke-linejoin='round'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 8px center;
  background-size: 12px;
  transition: border-color var(--transition);
}
.lang-switcher:hover { border-color: var(--text-3); }
.lang-switcher:focus { outline: 2px solid var(--accent); outline-offset: 2px; border-color: var(--accent); }

.page-title {
  font-size: clamp(22px, 4vw, 30px);
  font-weight: 700;
  letter-spacing: -0.02em;
  text-align: center;
  margin-bottom: 6px;
}
.page-sub {
  text-align: center;
  font-size: 14px;
  color: var(--text-3);
  margin-bottom: 28px;
}

/* ============ Breathing Stage (dark screen) ============ */
.breathing-stage {
  margin: 0 auto 28px;
  max-width: 560px;
}

.breathing-screen {
  position: relative;
  border-radius: var(--r-lg);
  overflow: hidden;
  background:
    radial-gradient(ellipse 60% 50% at 50% 40%, #2a2d35 0%, #1a1d24 100%);
  border: 1px solid rgba(255, 255, 255, 0.06);
  box-shadow:
    inset 0 1px 0 rgba(255, 255, 255, 0.04),
    0 8px 32px rgba(0, 0, 0, 0.25),
    0 2px 8px rgba(0, 0, 0, 0.15);
  aspect-ratio: 4 / 3;
  min-height: 300px;
}

.breathing-screen canvas {
  display: block;
  width: 100%;
  height: 100%;
}

.phase-label {
  position: absolute;
  top: clamp(16px, 4vw, 24px);
  left: 50%;
  transform: translateX(-50%);
  font-size: clamp(11px, 2.5vw, 13px);
  font-weight: 700;
  letter-spacing: 0.18em;
  text-transform: uppercase;
  color: rgba(255, 255, 255, 0.85);
  text-shadow: 0 1px 4px rgba(0, 0, 0, 0.4);
}
.phase-label.inhale  { color: rgba(255, 255, 255, 0.88); }
.phase-label.hold    { color: rgba(237, 193, 98, 0.92); }
.phase-label.exhale  { color: rgba(255, 255, 255, 0.88); }
.phase-label.holdEmpty { color: rgba(168, 196, 235, 0.92); }
.breath-timer {
  position: absolute;
  bottom: clamp(48px, 8vw, 64px);
  left: 50%;
  transform: translateX(-50%);
  font-family: var(--font-mono);
  font-variant-numeric: tabular-nums;
  font-size: clamp(36px, 10vw, 64px);
  font-weight: 600;
  letter-spacing: 0.02em;
  color: rgba(255, 255, 255, 0.9);
  text-shadow: 0 2px 8px rgba(0, 0, 0, 0.5);
  line-height: 1;
}

.cycle-display {
  position: absolute;
  bottom: clamp(16px, 2.5vw, 20px);
  left: 50%;
  transform: translateX(-50%);
  font-size: clamp(10px, 2vw, 11px);
  font-weight: 500;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: rgba(255, 255, 255, 0.45);
}

/* ============ Technique chips ============ */
.techniques {
  text-align: center;
  margin: 0 auto 24px;
  max-width: 640px;
}
.techniques-label {
  display: block;
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.18em;
  color: var(--text-3);
  font-weight: 700;
  margin-bottom: 10px;
}
.technique-chips {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 6px;
}
.chip {
  padding: 8px 16px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--r-pill);
  color: var(--text-2);
  font-size: 13px;
  font-weight: 600;
  transition: border-color var(--transition), color var(--transition), background var(--transition);
}
.chip:hover { border-color: var(--accent); color: var(--accent); }
.chip-active {
  background: var(--accent);
  border-color: var(--accent);
  color: #fff;
}
.chip-active:hover { color: #fff; background: var(--accent-2); }

/* ============ Controls ============ */
.controls {
  display: flex;
  justify-content: center;
  gap: 10px;
  margin: 0 auto 32px;
  flex-wrap: wrap;
}

.ctrl-btn {
  min-width: 120px;
  padding: 14px 28px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--r-pill);
  color: var(--text);
  font-weight: 600;
  font-size: clamp(14px, 2.5vw, 16px);
  letter-spacing: 0.01em;
  box-shadow: var(--shadow-sm);
  transition: background var(--transition), border-color var(--transition), transform 80ms ease-out;
}
.ctrl-btn:hover {
  border-color: var(--accent);
  color: var(--accent);
}
.ctrl-btn:active {
  transform: scale(0.97);
}

.ctrl-btn-primary {
  background: var(--accent);
  border-color: var(--accent);
  color: #fff;
  box-shadow: 0 2px 8px rgba(232, 95, 77, 0.30);
}
.ctrl-btn-primary:hover {
  background: var(--accent-2);
  border-color: var(--accent-2);
  color: #fff;
}

/* ============ Info ============ */
.info {
  max-width: 720px;
  margin: 40px auto 0;
  padding: 0 4px;
}
.info h2 {
  font-size: clamp(18px, 4vw, 22px);
  font-weight: 600;
  letter-spacing: -0.015em;
  margin: 26px 0 10px;
  color: var(--text);
}
.info p {
  font-size: 15px;
  color: var(--text-2);
  margin-bottom: 10px;
}

/* ============ Footer ============ */
.site-footer {
  max-width: 720px;
  margin: 56px auto 0;
  padding-top: 24px;
  border-top: 1px solid var(--border-soft);
  text-align: center;
}
.site-footer-row {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 16px;
  font-size: 13px;
  color: var(--text-3);
}
.site-footer a { color: var(--text-2); }
.site-footer a:hover { color: var(--accent); }
.site-footer .sub {
  margin-top: 8px;
  font-size: 11px;
  color: var(--text-3);
}

@media (max-width: 480px) {
  .breathing-screen {
    border-radius: var(--r-md);
  }
  .chip { padding: 7px 13px; font-size: 12px; }
  .ctrl-btn { min-width: 100px; padding: 12px 22px; }
}

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

/* ============ Focus visible ============ */
:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}
button:focus:not(:focus-visible),
select:focus:not(:focus-visible),
input:focus:not(:focus-visible),
a:focus:not(:focus-visible) { outline: none; }
