:root {
  color-scheme: light dark;
  --bg: #f2f2f7;
  --card: #ffffff;
  --text: #111114;
  --muted: #6c6c72;
  --line: #d9d9de;
  --accent: #0a66e0;
  --accent-text: #ffffff;
  --soft: #e3e3e9;
  --warn: #c25e00;
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #000000;
    --card: #1c1c1e;
    --text: #f5f5f7;
    --muted: #9a9aa1;
    --line: #38383c;
    --accent: #2f86ff;
    --accent-text: #ffffff;
    --soft: #2a2a2e;
    --warn: #ff9f0a;
  }
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  height: 100%;
  background: var(--bg);
  color: var(--text);
  font-family: -apple-system, BlinkMacSystemFont, "Hiragino Sans", sans-serif;
  -webkit-text-size-adjust: 100%;
  -webkit-tap-highlight-color: transparent;
  overscroll-behavior: none;
}

body { touch-action: manipulation; }

#app {
  height: 100dvh;
  display: flex;
  flex-direction: column;
  padding: env(safe-area-inset-top) env(safe-area-inset-right) env(safe-area-inset-bottom) env(safe-area-inset-left);
}

button {
  font: inherit;
  color: inherit;
  border: 0;
  border-radius: 14px;
  background: var(--soft);
  cursor: pointer;
  -webkit-user-select: none;
  user-select: none;
}
button:active:not(:disabled) { filter: brightness(0.9); transform: scale(0.98); }
button:disabled { opacity: 0.35; }

.bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  min-height: 48px;
  padding: 4px 16px;
}
.bar h1 { margin: 0; font-size: 28px; }
.link { background: none; color: var(--accent); padding: 10px 4px; font-size: 17px; }

.scroll { flex: 1; overflow-y: auto; padding: 8px 16px 16px; }
.foot { padding: 12px 16px 16px; display: flex; gap: 12px; }

.section { margin: 16px 4px 8px; font-size: 13px; color: var(--muted); }
.card { background: var(--card); border-radius: 14px; overflow: hidden; }
.item { padding: 12px 16px; border-top: 1px solid var(--line); }
.item:first-child { border-top: 0; }
.item h2 { margin: 0 0 4px; font-size: 17px; }
.item .big { font-size: 20px; font-variant-numeric: tabular-nums; }
.item .sub { font-size: 14px; color: var(--muted); }
.note { color: var(--warn); font-weight: 600; }
.muted { color: var(--muted); }

.primary {
  flex: 1;
  min-height: 64px;
  background: var(--accent);
  color: var(--accent-text);
  font-size: 22px;
  font-weight: 700;
}

/* トレーニング中 */
.set { flex: 1; display: flex; flex-direction: column; gap: 12px; padding: 4px 16px 16px; min-height: 0; }
.head .title { display: flex; align-items: baseline; justify-content: space-between; gap: 12px; }
.head h1 { margin: 0; font-size: 32px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.head p { margin: 6px 0 0; font-size: 20px; font-variant-numeric: tabular-nums; }
.grow { flex: 1; min-height: 0; }
.setno { margin: 0; text-align: center; font-size: 22px; font-weight: 700; color: var(--muted); }

.values { display: flex; align-items: flex-start; gap: 8px; }
.values .times { font-size: 32px; color: var(--muted); padding-top: 18px; }
.col { flex: 1; display: flex; flex-direction: column; gap: 10px; align-items: stretch; }
.num { text-align: center; font-size: 64px; font-weight: 700; line-height: 1.1; font-variant-numeric: tabular-nums; white-space: nowrap; }
.num small { font-size: 20px; font-weight: 400; color: var(--muted); margin-left: 2px; }
.steps { display: flex; gap: 8px; }
.steps button { flex: 1; min-height: 52px; font-size: 20px; font-weight: 700; font-variant-numeric: tabular-nums; }
.steps.off { opacity: 0.3; }

.rest { display: flex; align-items: center; justify-content: space-between; min-height: 52px; }
.rest .time { font-size: 34px; font-weight: 700; font-variant-numeric: tabular-nums; }
.rest .time.over { font-size: 24px; color: var(--warn); }
.rest button { padding: 12px 16px; font-size: 16px; }

.done {
  min-height: 150px;
  border-radius: 28px;
  background: var(--accent);
  color: var(--accent-text);
  font-size: 44px;
  font-weight: 800;
}
.pair { display: flex; gap: 12px; }
.pair button { flex: 1; min-height: 52px; font-size: 17px; font-weight: 600; }

/* 休憩が終わったら画面全体を光らせる */
@keyframes flash {
  0%, 100% { background: var(--bg); }
  50% { background: var(--warn); }
}
body.flash { animation: flash 0.6s ease-in-out 4; }

/* メニューの編集 */
.row { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 10px 16px; border-top: 1px solid var(--line); min-height: 52px; }
.row:first-child { border-top: 0; }
.row.tap { cursor: pointer; }
.row .grow { min-width: 0; }
.row input[type="text"], .row input[type="url"] { flex: 1; min-width: 0; }
input {
  font: inherit;
  color: inherit;
  background: none;
  border: 0;
  padding: 8px 0;
  font-size: 17px;
}
input:focus { outline: none; }
input[type="number"] { width: 96px; text-align: right; font-variant-numeric: tabular-nums; }
input[type="checkbox"] { width: 24px; height: 24px; accent-color: var(--accent); }
.mini { padding: 8px 12px; font-size: 15px; border-radius: 10px; }
.danger { color: #d93025; }
.hint { margin: 8px 4px 0; font-size: 13px; color: var(--muted); }
.full { width: 100%; min-height: 52px; font-size: 17px; font-weight: 600; margin-top: 12px; }
