[hidden] { display: none !important; }

:root {
  color-scheme: light;
  --bg: #f4f0e8;
  --surface: #fffdf8;
  --ink: #243126;
  --muted: #6d756e;
  --line: rgba(36, 49, 38, 0.14);
  --accent: #58764a;
  --accent-strong: #3f5d37;
  --danger: #8d403b;
  --shadow: 0 20px 60px rgba(43, 52, 44, 0.10);
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

* { box-sizing: border-box; }

html, body { margin: 0; min-height: 100%; background: var(--bg); color: var(--ink); }
body { min-height: 100vh; }
button, select { font: inherit; }
button { -webkit-tap-highlight-color: transparent; }

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

.site-header {
  position: relative;
  z-index: 10;
  height: 72px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 clamp(20px, 5vw, 64px);
}

.brand {
  display: flex;
  align-items: center;
  gap: 10px;
  font-weight: 720;
  letter-spacing: -0.02em;
}

.brand-mark { color: var(--accent); font-size: 14px; }

.language-control select {
  appearance: none;
  border: 1px solid var(--line);
  background: rgba(255,255,255,0.45);
  color: var(--ink);
  border-radius: 999px;
  padding: 8px 30px 8px 12px;
  background-image: linear-gradient(45deg, transparent 50%, var(--muted) 50%), linear-gradient(135deg, var(--muted) 50%, transparent 50%);
  background-position: calc(100% - 14px) 13px, calc(100% - 10px) 13px;
  background-size: 4px 4px, 4px 4px;
  background-repeat: no-repeat;
}

.main-app {
  min-height: calc(100vh - 72px);
  display: grid;
  place-items: center;
  padding: 24px 20px 80px;
}

.companion-shell {
  width: min(560px, 100%);
  min-height: 550px;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  text-align: center;
}

.main-pet-stage {
  width: min(360px, 80vw);
  height: 260px;
  position: relative;
  display: grid;
  place-items: center;
  transition: width 280ms ease, height 280ms ease, opacity 280ms ease;
}

.main-pet {
  font-size: clamp(86px, 13vw, 132px);
  line-height: 1;
  transform-origin: 50% 100%;
  filter: drop-shadow(0 14px 12px rgba(45, 58, 46, 0.10));
  animation: breathe 3.8s ease-in-out infinite;
  transition: font-size 280ms ease, transform 280ms ease, filter 280ms ease;
}

.main-app[data-pip="open"] .main-pet-stage {
  width: min(300px, 72vw);
  height: 220px;
  opacity: 0.84;
}

.main-app[data-pip="open"] .main-pet {
  font-size: clamp(72px, 11vw, 108px);
  filter: drop-shadow(0 10px 9px rgba(45, 58, 46, 0.07));
}

.main-app[data-pip="closed"] .main-pet,
.main-app[data-pip="failed"] .main-pet,
.main-app[data-pip="unsupported"] .main-pet {
  filter: drop-shadow(0 16px 15px rgba(45, 58, 46, 0.13));
}

.main-app[data-phase="focus"] .main-pet,
.main-app[data-phase="paused"] .main-pet { animation-name: workBreathe; animation-duration: 1.8s; }
.main-app[data-phase="break"] .main-pet { animation-name: restBreathe; animation-duration: 4.8s; }

.main-copy { min-height: 104px; display: grid; justify-items: center; align-content: start; }
.phase-label { min-height: 24px; color: var(--muted); font-size: 14px; letter-spacing: 0.03em; }
.main-timer { font-size: clamp(48px, 8vw, 72px); line-height: 1; font-variant-numeric: tabular-nums; letter-spacing: -0.045em; margin-top: 8px; }

.break-progress-wrap { width: min(280px, 68vw); margin-top: 16px; }
.break-progress-track { width: 100%; height: 5px; border-radius: 999px; background: rgba(88,118,74,0.12); overflow: hidden; }
.break-progress-fill { height: 100%; width: 0%; background: var(--accent); border-radius: inherit; transition: width 220ms linear; }

.control-stack { width: min(280px, 100%); display: grid; gap: 10px; margin-top: 20px; }
.button { border: 0; border-radius: 999px; min-height: 48px; padding: 0 22px; cursor: pointer; transition: transform 120ms ease, background 120ms ease, opacity 120ms ease; }
.button:hover { transform: translateY(-1px); }
.button:active { transform: translateY(1px) scale(0.99); }
.button-primary { color: #fff; background: var(--accent); box-shadow: 0 8px 22px rgba(88,118,74,0.18); }
.button-primary:hover { background: var(--accent-strong); }
.button-large { min-height: 54px; font-weight: 720; }
.button-ghost { background: transparent; color: var(--muted); border: 1px solid var(--line); }
.button-danger { background: var(--danger); color: #fff; }
.text-button { border: 0; background: transparent; color: var(--accent-strong); cursor: pointer; padding: 8px; }

.pip-message { color: var(--muted); font-size: 13px; max-width: 420px; line-height: 1.6; margin: 16px 0 0; }
.test-badge { position: fixed; bottom: 18px; left: 18px; padding: 7px 10px; border: 1px dashed rgba(141,64,59,0.35); border-radius: 8px; color: var(--danger); background: rgba(255,253,248,0.72); font: 700 11px/1 ui-monospace, SFMono-Regular, Menlo, monospace; letter-spacing: .04em; }

.confirm-dialog { border: 0; padding: 0; border-radius: 22px; background: transparent; color: var(--ink); }
.confirm-dialog::backdrop { background: rgba(24,31,25,0.24); backdrop-filter: blur(4px); }
.dialog-card { width: min(440px, calc(100vw - 32px)); background: var(--surface); border: 1px solid var(--line); border-radius: 22px; padding: 28px; box-shadow: var(--shadow); text-align: left; }
.dialog-icon { width: 42px; height: 42px; display:grid; place-items:center; border-radius: 50%; background: rgba(141,64,59,.08); color: var(--danger); font-size: 22px; }
.dialog-card h2 { margin: 18px 0 8px; font-size: 22px; }
.dialog-card p { margin: 0; color: var(--muted); line-height: 1.7; }
.dialog-actions { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; margin-top: 24px; }

.pet-pop { animation: petPop 360ms cubic-bezier(.18,.9,.25,1.25) !important; }
.pet-celebrate { animation: celebrate 520ms ease-in-out infinite alternate !important; }

@keyframes breathe { 0%,100% { transform: translateY(0) scale(1); } 50% { transform: translateY(-4px) scale(1.015); } }
@keyframes workBreathe { 0%,100% { transform: translateY(0) rotate(-1deg); } 50% { transform: translateY(-3px) rotate(1deg); } }
@keyframes restBreathe { 0%,100% { transform: translateY(2px) scale(.98); } 50% { transform: translateY(-2px) scale(1); } }
@keyframes petPop { 0% { transform: scale(1); } 35% { transform: scale(1.12,.84); } 65% { transform: scale(.92,1.10); } 100% { transform: scale(1); } }
@keyframes celebrate { from { transform: translateY(0) rotate(-4deg) scale(1); } to { transform: translateY(-16px) rotate(4deg) scale(1.08); } }

@media (max-width: 640px) {
  .site-header { height: 64px; padding-inline: 18px; }
  .brand span:last-child { display: none; }
  .main-app { min-height: calc(100vh - 64px); padding-bottom: 56px; }
  .companion-shell { min-height: 500px; }
}

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