:root {
  color-scheme: dark;
  --bg: #000;
  --ink: #f3eee8;
  --muted: #9a938b;
  --line: #2a2523;
  --panel: #161312;
  --pearl: #eee9e0;
  --celadon: #9ed1c4;
  --copper: #e0b085;
  --accent: var(--pearl);
}
body[data-phase="shortBreak"], body[data-phase="longBreak"] { --accent: var(--celadon); }
body[data-phase="life"] { --accent: var(--copper); }

* { box-sizing: border-box; }
html, body { height: 100%; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font: 15px/1.5 "Geist", "Noto Sans JP", system-ui, sans-serif;
  -webkit-font-smoothing: antialiased;
  overflow-x: hidden;
}
button, input { font: inherit; color: inherit; }
button { cursor: pointer; }
button:disabled { opacity: .35; cursor: default; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 3px; }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); }

.app {
  min-height: 100svh;
  display: flex;
  flex-direction: column;
  padding: max(12px, env(safe-area-inset-top)) 16px max(12px, env(safe-area-inset-bottom));
  background: radial-gradient(ellipse at 50% 45%, color-mix(in srgb, var(--accent) 14%, transparent), transparent 62%);
  transition: transform .55s cubic-bezier(.3, 1.3, .5, 1), background .8s;
}
/* Phones never rotate a page upside down, so the page turns itself. */
.app.upside-down { transform: rotate(180deg); }

.top { display: flex; align-items: center; justify-content: space-between; gap: 12px; max-width: 980px; width: 100%; margin: 0 auto; }
.modes, .segmented { display: inline-flex; background: #ffffff14; border-radius: 10px; padding: 2px; }
.modes button, .segmented button { border: 0; background: none; padding: 6px 14px; border-radius: 8px; font-size: 13px; font-weight: 500; color: #d8d2cb; }
.modes [aria-checked="true"], .segmented [aria-checked="true"] { background: #ffffff2b; color: #fff; }
.chip { border: 0; background: #ffffff14; border-radius: 99px; padding: 6px 14px; display: inline-flex; align-items: center; gap: 6px; font-size: 14px; }
.chip b { font-variant-numeric: tabular-nums; font-weight: 600; margin-right: 6px; }
.chip b:last-child { margin-right: 0; }
.dot { width: 9px; height: 9px; border-radius: 50%; background: var(--pearl); }

.stage {
  flex: 1;
  display: grid;
  grid-template-columns: minmax(0, 460px) minmax(300px, 380px);
  gap: 48px;
  align-items: center;
  justify-content: center;
  width: 100%;
  max-width: 980px;
  margin: 0 auto;
}

/* Frameless glass: photo, reservoirs, grains and reflection scale as one. */
.glass {
  position: relative;
  display: block;
  width: 100%;
  max-width: min(460px, calc((100svh - 140px) / 1.5));
  margin: 0 auto;
  aspect-ratio: 2 / 3;
  padding: 0;
  border: 0;
  background: #000;
  isolation: isolate;
  /* Black photo background melts into the tinted page instead of a plate. */
  mix-blend-mode: lighten;
  overflow: hidden;
  -webkit-tap-highlight-color: transparent;
  touch-action: manipulation;
}
.glass img, .glass svg, .glass canvas { position: absolute; inset: 0; width: 100%; height: 100%; pointer-events: none; user-select: none; -webkit-user-drag: none; }
.glass > img:first-child { mix-blend-mode: lighten; }
.glass svg { z-index: 1; }
.glass canvas { z-index: 2; }
.glass .reflection { z-index: 3; mix-blend-mode: screen; opacity: .48; }
.glass::after {
  content: ""; position: absolute; inset: 0; z-index: 4; pointer-events: none;
  box-shadow: inset 22px 0 20px -15px #000, inset -22px 0 20px -15px #000, inset 0 15px 20px -15px #000, inset 0 -25px 25px -15px #000;
}

.controls { text-align: center; }
.phase { margin: 0; display: flex; align-items: center; justify-content: center; gap: 8px; color: var(--accent); font-weight: 600; font-size: 14px; transition: color .6s; }
.dots { display: inline-flex; gap: 4px; }
.dots i { width: 6px; height: 6px; border-radius: 50%; background: #ffffff2e; }
.dots i.on { background: var(--pearl); }
.time { font-family: "Geist", system-ui, sans-serif; font-weight: 200; font-size: clamp(56px, 16vw, 84px); line-height: 1.05; font-variant-numeric: tabular-nums; letter-spacing: .01em; margin: 2px 0; }
.status { margin: 0 0 14px; min-height: 22px; color: var(--muted); font-size: 13px; }
.actions { display: flex; align-items: center; justify-content: center; gap: 12px; max-width: 380px; margin: 0 auto; }
.round { flex: none; width: 54px; height: 54px; border-radius: 50%; border: 0; background: #ffffff17; display: grid; place-items: center; }
.round svg { width: 21px; height: 21px; fill: none; stroke: currentColor; stroke-width: 2.2; stroke-linecap: round; stroke-linejoin: round; }
#skip svg path:first-child { fill: currentColor; }
.round.hidden { visibility: hidden; }
.primary { flex: 1; height: 54px; border: 0; border-radius: 99px; background: var(--accent); color: #140b08; font-weight: 700; font-size: 16px; display: inline-flex; align-items: center; justify-content: center; gap: 8px; transition: background .6s, transform .1s; }
.primary:active, .round:active { transform: scale(.97); }
.primary.wide { width: 100%; flex: none; margin-top: 14px; }
.motion-enable { margin-top: 14px; border: 1px solid #ffffff26; background: none; border-radius: 99px; padding: 8px 16px; font-size: 13px; color: #ddd; }
.tabs { display: flex; justify-content: space-around; margin-top: 18px; max-width: 380px; margin-inline: auto; }
.tabs button { border: 0; background: none; color: #ffffffbf; display: grid; justify-items: center; gap: 2px; font-size: 11px; min-width: 64px; padding: 6px; }
.tabs button span { font-size: 20px; line-height: 1; }
.keys { color: #6d6761; font-size: 11px; margin: 14px 0 0; }

/* Sheets */
dialog {
  width: min(560px, calc(100% - 24px));
  max-height: calc(100svh - 32px);
  border: 1px solid #ffffff1a;
  border-radius: 22px;
  padding: 18px 20px 24px;
  background: #1c1a19;
  color: var(--ink);
  box-shadow: 0 30px 90px #000c;
}
dialog::backdrop { background: #000a; backdrop-filter: blur(6px); }
.sheet-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 14px; }
.sheet-head h2 { font-size: 17px; margin: 0; }
.close { border: 0; background: #ffffff14; color: var(--pearl); border-radius: 99px; padding: 6px 14px; font-weight: 600; }
dialog h3 { font-size: 16px; margin: 22px 0 10px; }
.muted { color: var(--muted); font-size: 12px; margin: 8px 0; }
.center { text-align: center; }
.c-pearl { color: var(--pearl); } .c-orange { color: #ff9f0a; } .c-yellow { color: #ffd60a; } .c-copper { color: var(--copper); }

.tiles { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.tile { background: #ffffff0f; border-radius: 16px; padding: 12px 14px; display: grid; }
.tile small { font-size: 12px; font-weight: 600; }
.tile b { font-size: 32px; font-weight: 600; font-variant-numeric: tabular-nums; line-height: 1.2; }
.tile span { color: var(--muted); font-size: 12px; }

.grass-wrap { overflow-x: auto; scrollbar-width: none; direction: rtl; }
.grass-wrap::-webkit-scrollbar { display: none; }
.grass { direction: ltr; display: grid; grid-auto-flow: column; grid-template-rows: repeat(7, 13px); grid-auto-columns: 13px; gap: 3px; width: max-content; }
.grass button, .legend i { width: 13px; height: 13px; border-radius: 3px; border: 0; padding: 0; background: var(--g0); }
.grass button.future { visibility: hidden; }
.grass button[aria-selected="true"] { outline: 1.5px solid #fff; outline-offset: -1.5px; }
:root { --g0: #ffffff12; --g1: #eee9e03d; --g2: #eee9e073; --g3: #eee9e0b3; --g4: #eee9e0; }
[data-l="1"] { background: var(--g1) !important; } [data-l="2"] { background: var(--g2) !important; }
[data-l="3"] { background: var(--g3) !important; } [data-l="4"] { background: var(--g4) !important; }
.legend { display: flex; align-items: center; justify-content: flex-end; gap: 4px; color: var(--muted); font-size: 11px; margin: 4px 0 0; }
.legend i { display: inline-block; width: 11px; height: 11px; }
.recent { list-style: none; margin: 0; padding: 0; }
.recent li { display: flex; justify-content: space-between; padding: 8px 0; border-bottom: 1px solid #ffffff12; font-size: 14px; }
.recent li::before { content: "●"; color: var(--pearl); font-size: 9px; margin-right: 8px; align-self: center; }
.recent li span:first-of-type { flex: 1; }
.recent li span:last-child { color: var(--muted); }

#share .segmented { display: flex; }
#share .segmented button { flex: 1; }
.preview { margin: 16px auto 0; width: min(280px, 70%); aspect-ratio: 9 / 16; border-radius: 16px; overflow: hidden; background: repeating-conic-gradient(#3a3a3a 0 25%, #2c2c2c 0 50%) 0 0 / 22px 22px; box-shadow: 0 10px 30px #0009; }
.preview img { width: 100%; height: 100%; display: block; }

.rows { background: #ffffff0d; border-radius: 14px; overflow: hidden; }
.row { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 12px 14px; border: 0; border-bottom: 1px solid #ffffff10; background: none; width: 100%; text-align: left; font-size: 15px; }
.row:last-child { border-bottom: 0; }
.row input[type="number"] { width: 64px; text-align: right; background: #ffffff12; border: 0; border-radius: 8px; padding: 6px 8px; font-variant-numeric: tabular-nums; }
.row input[type="checkbox"] { width: 22px; height: 22px; accent-color: var(--pearl); }
.row.link { color: var(--pearl); cursor: pointer; }
.row.danger { color: #ff6b5e; }

@media (max-width: 760px) {
  .stage { grid-template-columns: 1fr; gap: 6px; align-content: center; }
  .glass { max-width: min(100%, calc((100svh - 330px) / 1.5)); min-width: 180px; }
  body:has(#motionEnable:not([hidden])) .glass { max-width: min(100%, calc((100svh - 385px) / 1.5)); }
  .keys { display: none; }
}
@media (prefers-reduced-motion: reduce) {
  .app { transition: none; }
}
