:root {
  --bg: #f6f6f4;
  --card: #ffffff;
  --ink: #16181d;
  --muted: #6b7280;
  --line: #e3e3df;
  --accent: #2f6f5e;
  --accent-soft: #e6f0ec;
  --warn: #9a5b2c;
  --radius: 14px;
  color-scheme: light dark;
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #101216;
    --card: #191c22;
    --ink: #e9eaec;
    --muted: #9aa1ad;
    --line: #272b33;
    --accent: #5fb89c;
    --accent-soft: #1d2b28;
    --warn: #d09a63;
  }
}

* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }

html, body {
  margin: 0;
  padding: 0;
  background: var(--bg);
  color: var(--ink);
  font: 16px/1.5 -apple-system, BlinkMacSystemFont, "SF Pro Text", system-ui, sans-serif;
  -webkit-font-smoothing: antialiased;
  overscroll-behavior-y: none;
}

body {
  padding:
    calc(env(safe-area-inset-top, 0px) + 12px)
    max(env(safe-area-inset-right, 0px), 16px)
    calc(env(safe-area-inset-bottom, 0px) + 28px)
    max(env(safe-area-inset-left, 0px), 16px);
  max-width: 560px;
  margin: 0 auto;
  touch-action: manipulation;
}

a { color: inherit; text-decoration: none; }
button { font: inherit; touch-action: manipulation; }

header.top {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 18px;
  min-height: 34px;
}

.back {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 34px;
  height: 34px;
  border-radius: 50%;
  background: var(--card);
  border: 1px solid var(--line);
  color: var(--muted);
  flex: none;
}

h1 { font-size: 20px; font-weight: 650; margin: 0; letter-spacing: -0.01em; }
h2 { font-size: 15px; font-weight: 650; margin: 26px 0 10px; letter-spacing: -0.01em; }

.sub { color: var(--muted); font-size: 13px; margin: 2px 0 0; }

.card {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 16px;
  margin-bottom: 12px;
}

.tile {
  display: flex;
  align-items: center;
  gap: 14px;
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 16px;
  margin-bottom: 10px;
  transition: transform 0.08s ease;
}
.tile:active { transform: scale(0.985); }
.tile.due { border-color: var(--accent); background: var(--accent-soft); }

.tile .glyph {
  width: 42px; height: 42px; flex: none;
  border-radius: 12px;
  display: grid; place-items: center;
  background: var(--accent-soft);
  color: var(--accent);
}
.tile.due .glyph { background: var(--accent); color: var(--card); }
.tile .body { flex: 1; min-width: 0; }
.tile .name { font-weight: 600; font-size: 16px; }
.tile .meta { color: var(--muted); font-size: 13px; margin-top: 1px; }
.tile .state { color: var(--muted); font-size: 13px; flex: none; font-variant-numeric: tabular-nums; }
.tile .state.ok { color: var(--accent); }

button.primary, .primary {
  display: block;
  width: 100%;
  padding: 15px;
  border: 0;
  border-radius: var(--radius);
  background: var(--accent);
  color: #fff;
  font-weight: 600;
  font-size: 16px;
  text-align: center;
  cursor: pointer;
}
button.primary:disabled { opacity: 0.4; }

button.ghost {
  display: block;
  width: 100%;
  padding: 13px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--card);
  color: var(--ink);
  font-weight: 550;
  cursor: pointer;
}

.row { display: flex; gap: 10px; }
.row > * { flex: 1; }

.stage {
  display: grid;
  place-items: center;
  min-height: 300px;
  margin: 8px 0 18px;
  position: relative;
}

.orb {
  width: 210px; height: 210px;
  border-radius: 50%;
  background: var(--accent-soft);
  border: 2px solid var(--accent);
  display: grid;
  place-items: center;
  transform: scale(0.55);
  transition: transform linear;
}
.orb .phase { font-size: 15px; font-weight: 600; color: var(--accent); }

.bigcount {
  font-size: 66px;
  font-weight: 250;
  font-variant-numeric: tabular-nums;
  letter-spacing: -0.03em;
  line-height: 1;
}

.cue { font-size: 19px; font-weight: 600; margin-top: 10px; text-align: center; }
.cuesub { color: var(--muted); font-size: 14px; margin-top: 6px; text-align: center; }

.bar { height: 4px; background: var(--line); border-radius: 2px; overflow: hidden; margin: 14px 0 6px; }
.bar > i { display: block; height: 100%; background: var(--accent); width: 0; transition: width 0.25s linear; }

ul.steps { margin: 8px 0 0; padding-left: 18px; color: var(--muted); font-size: 14px; }
ul.steps li { margin-bottom: 5px; }
ul.steps li.now { color: var(--ink); font-weight: 600; }

table.level { width: 100%; border-collapse: collapse; font-size: 14px; }
table.level td { padding: 7px 0; border-bottom: 1px solid var(--line); vertical-align: top; }
table.level td:first-child { color: var(--muted); width: 38%; }
table.level tr:last-child td { border-bottom: 0; }

.scale { font-size: 14px; }
.scale div { display: flex; gap: 12px; padding: 6px 0; border-bottom: 1px solid var(--line); }
.scale div:last-child { border-bottom: 0; }
.scale b { flex: none; width: 22px; font-variant-numeric: tabular-nums; }
.scale .hot { color: var(--warn); }

label.f { display: block; font-size: 13px; color: var(--muted); margin: 12px 0 5px; }
input, textarea, select {
  width: 100%;
  font: inherit;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: var(--bg);
  color: var(--ink);
  -webkit-appearance: none;
}
textarea { min-height: 64px; resize: vertical; }

.chart { width: 100%; height: 130px; display: block; }

.entry { display: flex; gap: 12px; padding: 11px 0; border-bottom: 1px solid var(--line); font-size: 14px; align-items: baseline; }
.entry:last-child { border-bottom: 0; }
.entry .d { color: var(--muted); flex: none; width: 54px; font-variant-numeric: tabular-nums; }
.entry .v { font-weight: 600; font-variant-numeric: tabular-nums; }
.entry .n { color: var(--muted); flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

.note { font-size: 13px; color: var(--muted); margin-top: 10px; }
.hint { background: var(--accent-soft); border-radius: 10px; padding: 11px 13px; font-size: 13.5px; color: var(--ink); margin-top: 12px; }

details.settings { margin-top: 26px; font-size: 14px; color: var(--muted); }
details.settings summary { cursor: pointer; padding: 8px 0; }

.toast {
  position: fixed;
  left: 50%;
  transform: translateX(-50%);
  bottom: calc(env(safe-area-inset-bottom, 0px) + 22px);
  background: var(--ink);
  color: var(--bg);
  padding: 11px 17px;
  border-radius: 999px;
  font-size: 14px;
  font-weight: 550;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.2s;
  z-index: 10;
}
.toast.show { opacity: 1; }

.orb { gap: 2px; }
.orb .secs {
  font-size: 46px;
  font-weight: 250;
  line-height: 1;
  letter-spacing: -0.03em;
  font-variant-numeric: tabular-nums;
  color: var(--ink);
}
.total {
  text-align: center;
  color: var(--muted);
  font-size: 13px;
  margin-top: 8px;
  font-variant-numeric: tabular-nums;
}
