:root {
  color-scheme: light;
  --porcelain: #f8f9f6;
  --porcelain-deep: #eef4f5;
  --paper: #ffffff;
  --ink: #25313a;
  --muted: #7b8992;
  --line: #dbe5e8;
  --blue: #a8cfe0;
  --blue-deep: #6f9fb6;
  --blue-ink: #3f6f8d;
  --lamp: #f4ddb0;
  --lamp-core: #ffe7a8;
  --shadow: rgba(80, 105, 116, 0.14);
}

* {
  box-sizing: border-box;
}

html {
  min-height: 100%;
  background: var(--porcelain);
}

body {
  min-height: 100vh;
  margin: 0;
  font-family: "Hiragino Sans", "Yu Gothic", "Yu Gothic UI", system-ui, sans-serif;
  color: var(--ink);
  background:
    radial-gradient(circle at 50% 34%, rgba(244, 221, 176, 0.42), transparent 21rem),
    linear-gradient(135deg, #fbfbf8 0%, #f5f8f7 48%, #edf5f7 100%);
  background-attachment: fixed;
}

button,
input {
  font: inherit;
}

.app {
  min-height: 100vh;
  padding: clamp(18px, 3vw, 44px);
}

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  max-width: 1160px;
  margin: 0 auto;
}

.brand {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  color: #33434d;
  text-decoration: none;
  font-family: "Yu Mincho", "Hiragino Mincho ProN", serif;
  font-size: 18px;
  letter-spacing: 0;
}

.brand-mark,
.icon-button {
  display: grid;
  place-items: center;
}

.brand-mark {
  width: 34px;
  height: 34px;
  color: var(--blue-deep);
  border: 1px solid var(--line);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.64);
}

svg {
  width: 20px;
  height: 20px;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.7;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.icon-button {
  position: relative;
  width: 42px;
  height: 42px;
  padding: 0;
  color: var(--muted);
  background: rgba(255, 255, 255, 0.54);
  border: 1px solid rgba(219, 229, 232, 0.86);
  border-radius: 8px;
  cursor: pointer;
  transition: color 180ms ease, border-color 180ms ease, background 180ms ease;
}

.icon-button::after {
  content: "";
  position: absolute;
  right: 8px;
  bottom: 8px;
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: transparent;
  transition: background 180ms ease, box-shadow 180ms ease;
}

.icon-button:hover,
.icon-button[aria-pressed="true"] {
  color: var(--blue-deep);
  background: rgba(255, 255, 255, 0.86);
  border-color: rgba(168, 207, 224, 0.92);
}

.icon-button[aria-pressed="true"]::after {
  background: var(--lamp);
  box-shadow: 0 0 0 3px rgba(244, 221, 176, 0.24);
}

.booster {
  width: min(1050px, 100%);
  margin: clamp(30px, 5vw, 74px) auto 0;
  display: grid;
  justify-items: center;
  gap: clamp(22px, 3vw, 36px);
}

.lamp-ring {
  --progress: 0deg;
  position: relative;
  display: grid;
  place-items: center;
  align-content: center;
  width: min(460px, calc(100vw - 44px));
  aspect-ratio: 1;
  padding: 40px;
  text-align: center;
  border-radius: 50%;
  border: 1px solid rgba(206, 222, 227, 0.82);
  background:
    radial-gradient(circle, rgba(255, 255, 255, 0.92) 0 42%, rgba(248, 251, 250, 0.66) 62%, rgba(239, 246, 247, 0.44) 100%),
    conic-gradient(from 180deg, rgba(168, 207, 224, 0.08), rgba(244, 221, 176, 0.2), rgba(168, 207, 224, 0.08));
  box-shadow:
    0 34px 78px var(--shadow),
    inset 0 0 0 18px rgba(255, 255, 255, 0.36);
  overflow: hidden;
  transition: box-shadow 320ms ease, border-color 320ms ease, transform 320ms ease;
}

.lamp-ring::before {
  content: "";
  position: absolute;
  inset: 44px;
  border-radius: 50%;
  background: radial-gradient(circle, rgba(244, 221, 176, 0.36), transparent 68%);
  opacity: 0.46;
  transition: opacity 260ms ease, transform 260ms ease;
}

.lamp-ring::after {
  content: "";
  position: absolute;
  inset: 21%;
  border-radius: 50%;
  background: radial-gradient(circle, rgba(255, 231, 168, 0.32), transparent 68%);
  opacity: 0;
  transform: scale(0.82);
  transition: opacity 320ms ease, transform 320ms ease;
}

.lamp-ring[data-state="running"]::before {
  opacity: 0.92;
  transform: scale(1.12);
  animation: quietGlow 4s ease-in-out infinite;
}

.lamp-ring[data-state="running"] {
  border-color: rgba(168, 207, 224, 0.9);
  box-shadow:
    0 42px 92px rgba(80, 105, 116, 0.18),
    0 0 90px rgba(244, 221, 176, 0.34),
    inset 0 0 0 18px rgba(255, 255, 255, 0.36);
}

.lamp-ring[data-state="running"]::after {
  opacity: 1;
  transform: scale(1);
  animation: ember 7s ease-in-out infinite;
}

.progress-ring {
  position: absolute;
  inset: 8px;
  border-radius: 50%;
  background: conic-gradient(var(--blue-ink) var(--progress), transparent 0);
  opacity: 0.74;
  mask: radial-gradient(circle, transparent 0 78%, #000 78.6% 100%);
  transition: background 280ms linear, opacity 240ms ease;
}

.ticks {
  position: absolute;
  inset: 18px;
  border-radius: 50%;
  background: repeating-conic-gradient(from 0deg, rgba(111, 159, 182, 0.22) 0 1deg, transparent 1deg 12deg);
  mask: radial-gradient(circle, transparent 0 72%, #000 72.5% 100%);
  opacity: 0.42;
}

.session-label,
.timer,
.session-note {
  position: relative;
  margin: 0;
}

.session-label {
  color: var(--muted);
  font-size: 15px;
  line-height: 1.7;
}

.timer {
  margin-top: 10px;
  font-family: "Yu Mincho", "Hiragino Mincho ProN", serif;
  font-size: clamp(58px, 10vw, 104px);
  line-height: 1;
  font-variant-numeric: tabular-nums;
}

.session-note {
  margin-top: 14px;
  color: #83949d;
  font-size: 14px;
}

.breath-dots {
  position: relative;
  display: inline-flex;
  gap: 8px;
  margin-top: 20px;
  opacity: 0;
  pointer-events: none;
  transform: translateY(3px);
  transition: opacity 240ms ease, transform 240ms ease;
}

.breath-dots span {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: var(--blue-deep);
  transform: scale(0.72);
}

.lamp-ring[data-state="running"] .breath-dots {
  opacity: 0.78;
  transform: translateY(0);
}

.lamp-ring[data-state="running"] .breath-dots span {
  animation: breatheDot 3.6s ease-in-out infinite;
}

.lamp-ring[data-state="running"] .breath-dots span:nth-child(2) {
  animation-delay: 0.35s;
}

.lamp-ring[data-state="running"] .breath-dots span:nth-child(3) {
  animation-delay: 0.7s;
}

.controls {
  display: grid;
  width: min(720px, 100%);
  gap: 16px;
}

.modes {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 12px;
  min-width: 0;
  margin: 0;
  padding: 0;
  border: 0;
}

.modes legend {
  position: absolute;
  width: 1px;
  height: 1px;
  overflow: hidden;
  clip: rect(0 0 0 0);
}

.mode {
  position: relative;
  display: grid;
  grid-template-columns: 30px 1fr;
  align-items: center;
  gap: 12px;
  min-height: 70px;
  padding: 12px 14px;
  border: 1px solid rgba(219, 229, 232, 0.92);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.46);
  cursor: pointer;
  overflow: hidden;
  transition: border-color 180ms ease, background 180ms ease, box-shadow 180ms ease;
}

.mode::before {
  content: "";
  position: absolute;
  inset: 0 auto 0 0;
  width: 4px;
  background: transparent;
  transition: background 180ms ease, box-shadow 180ms ease;
}

.mode input {
  position: absolute;
  opacity: 0;
  pointer-events: none;
}

.mode:has(input:checked) {
  border-color: rgba(111, 159, 182, 0.66);
  background: linear-gradient(90deg, rgba(168, 207, 224, 0.24), rgba(255, 255, 255, 0.78));
  box-shadow: 0 14px 36px rgba(111, 159, 182, 0.13);
}

.mode:has(input:checked)::before {
  background: var(--blue-deep);
  box-shadow: 0 0 18px rgba(111, 159, 182, 0.4);
}

.mode:hover {
  border-color: rgba(111, 159, 182, 0.48);
  background: rgba(255, 255, 255, 0.66);
}

.mode-icon {
  display: grid;
  place-items: center;
  width: 30px;
  height: 30px;
  color: var(--blue-ink);
}

.moon,
.sun,
.rings {
  display: block;
}

.moon {
  width: 21px;
  height: 21px;
  border-radius: 50%;
  box-shadow: inset 7px -2px 0 0 rgba(111, 159, 182, 0.85);
  border: 1px solid rgba(111, 159, 182, 0.22);
}

.sun {
  width: 20px;
  height: 20px;
  border: 1px solid #cfb77d;
  border-radius: 50%;
  background: radial-gradient(circle, rgba(244, 221, 176, 0.8) 0 36%, transparent 39%);
  box-shadow:
    0 -9px 0 -8px #cfb77d,
    0 9px 0 -8px #cfb77d,
    9px 0 0 -8px #cfb77d,
    -9px 0 0 -8px #cfb77d,
    6px 6px 0 -8px #cfb77d,
    -6px -6px 0 -8px #cfb77d,
    -6px 6px 0 -8px #cfb77d,
    6px -6px 0 -8px #cfb77d;
}

.rings {
  width: 23px;
  height: 23px;
  border: 1px solid var(--blue-deep);
  border-radius: 50%;
  box-shadow: inset 0 0 0 5px rgba(168, 207, 224, 0.28);
  background:
    radial-gradient(circle, transparent 0 28%, rgba(111, 159, 182, 0.32) 30% 34%, transparent 36%);
}

.mode-copy {
  display: grid;
  gap: 1px;
  min-width: 0;
}

.mode-copy span {
  font-family: "Yu Mincho", "Hiragino Mincho ProN", serif;
  font-size: 26px;
  line-height: 1;
  font-variant-numeric: tabular-nums;
}

.mode-copy small {
  color: var(--muted);
  font-size: 11px;
  line-height: 1.2;
  text-transform: uppercase;
}

.actions {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 10px;
}

.primary,
.secondary {
  min-width: 118px;
  height: 44px;
  padding: 0 22px;
  border-radius: 8px;
  cursor: pointer;
  transition: transform 180ms ease, box-shadow 180ms ease, background 180ms ease, color 180ms ease;
}

.primary {
  color: #263742;
  border: 1px solid rgba(111, 159, 182, 0.52);
  background: linear-gradient(180deg, #d8eaf1 0%, #bddce8 100%);
  box-shadow: 0 14px 34px rgba(111, 159, 182, 0.16);
}

.secondary {
  color: #667983;
  border: 1px solid rgba(219, 229, 232, 0.96);
  background: rgba(255, 255, 255, 0.44);
}

.share-button {
  min-width: 54px;
  padding: 0 16px;
}

.share-button[hidden] {
  display: none;
}

.primary:hover,
.secondary:hover {
  transform: translateY(-1px);
}

.primary:active,
.secondary:active {
  transform: translateY(0);
}

@keyframes quietGlow {
  0%,
  100% {
    filter: blur(0);
  }
  50% {
    filter: blur(8px);
  }
}

@keyframes ember {
  0%,
  100% {
    transform: scale(0.92);
  }
  50% {
    transform: scale(1.12);
  }
}

@keyframes breatheDot {
  0%,
  100% {
    transform: translateY(0) scale(0.72);
  }
  45% {
    transform: translateY(-4px) scale(1);
  }
}

@media (max-width: 760px) {
  .app {
    padding: 16px;
  }

  .booster {
    margin-top: 24px;
    gap: 16px;
  }

  .lamp-ring {
    width: min(326px, calc(100vw - 36px));
    padding: 22px;
  }

  .lamp-ring::before {
    inset: 34px;
  }

  .modes {
    grid-template-columns: 1fr;
  }

  .mode {
    min-height: 58px;
    padding: 12px 14px;
  }

  .controls {
    gap: 12px;
  }

  .actions {
    width: 100%;
  }

  .primary,
  .secondary {
    flex: 1;
    min-width: 0;
  }
}

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