:root {
  --bg: #f6f7f8;
  --card: #ffffff;
  --text: #1c2024;
  --muted: #6b7480;
  --line: #e3e6ea;
  --accent: #0f766e;
  --accent-soft: #d9f2ee;
  --danger: #c0392b;
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #111416;
    --card: #1b1f23;
    --text: #e8eaed;
    --muted: #98a2ad;
    --line: #2b3137;
    --accent: #2dd4bf;
    --accent-soft: #12332f;
    --danger: #ff7b6b;
    color-scheme: dark;
  }
}
:root[data-theme="dark"] {
  --bg: #111416;
  --card: #1b1f23;
  --text: #e8eaed;
  --muted: #98a2ad;
  --line: #2b3137;
  --accent: #2dd4bf;
  --accent-soft: #12332f;
  --danger: #ff7b6b;
  color-scheme: dark;
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font: 16px/1.5 system-ui, -apple-system, "Hiragino Sans", "Noto Sans JP", sans-serif;
}
button, input { font: inherit; color: inherit; }
button { cursor: pointer; border: 0; background: none; padding: 0; }

nav, main { max-width: 640px; margin: 0 auto; padding-left: max(16px, env(safe-area-inset-left, 0px)); padding-right: max(16px, env(safe-area-inset-right, 0px)); }
nav { display: flex; gap: 4px; padding-top: max(10px, env(safe-area-inset-top)); }
nav button { padding: 6px 12px; border-radius: 999px; color: var(--muted); font-size: 14px; }
nav button.on { background: var(--accent-soft); color: var(--accent); font-weight: 600; }

main { padding-bottom: 110px; }

.datebar { display: flex; align-items: center; gap: 8px; margin: 14px 0 10px; min-height: 40px; }
.datebar h1 { font-size: 20px; margin: 0; flex: 1; }
#view-day .datebar h1 { flex: 0 1 auto; min-width: 8.5em; text-align: center; }
#prev, #next { width: 40px; height: 40px; border-radius: 50%; font-size: 24px; line-height: 1; color: var(--muted); }
#prev:hover, #next:hover { background: var(--line); }

.summary { display: flex; gap: 8px; margin-bottom: 12px; }
.summary div { flex: 1; background: var(--card); border: 1px solid var(--line); border-radius: 12px; padding: 8px 12px; min-width: 0; }
.summary span { display: block; font-size: 12px; color: var(--muted); }
.summary b { font-size: 18px; font-variant-numeric: tabular-nums; white-space: nowrap; }

.notice { display: flex; align-items: center; gap: 8px; background: var(--accent-soft); border-radius: 12px; padding: 10px 12px; margin-bottom: 10px; font-size: 14px; }
.notice button { margin-left: auto; flex: none; color: var(--accent); font-weight: 600; }

.list { list-style: none; margin: 0; padding: 0; background: var(--card); border: 1px solid var(--line); border-radius: 12px; overflow: hidden; }
.row { display: flex; align-items: center; gap: 4px; padding: 4px 8px; border-bottom: 1px solid var(--line); min-height: 60px; }
.row:last-child { border-bottom: 0; }
.row .main { flex: 1; min-width: 0; text-align: left; padding: 6px 4px; display: flex; flex-direction: column; }
.name { overflow-wrap: anywhere; }
.sub { font-size: 13px; color: var(--muted); font-variant-numeric: tabular-nums; }
.rt { font-style: normal; font-size: 11px; color: var(--muted); border: 1px solid var(--line); border-radius: 4px; padding: 0 4px; margin-left: 6px; vertical-align: 1px; white-space: nowrap; }

.act, .mark { flex: none; width: 40px; height: 40px; border-radius: 50%; display: grid; place-items: center; }
.act { border: 1.5px solid var(--accent); color: var(--accent); font-size: 13px; }
.act.stop { background: var(--accent); color: var(--card); }
.mark { color: var(--muted); }
.row.done .name { color: var(--muted); }
.row.running { background: var(--accent-soft); }
.row.running .name { font-weight: 600; }

.mini { flex: none; min-width: 36px; height: 36px; padding: 0 8px; border-radius: 8px; color: var(--muted); font-size: 14px; }
.mini:hover { background: var(--line); }
.empty { padding: 28px 16px; text-align: center; color: var(--muted); font-size: 14px; }
.hint { color: var(--muted); font-size: 14px; }

.addbar {
  position: fixed; left: 0; right: 0; bottom: 0;
  display: flex; gap: 8px; justify-content: center;
  padding-block: 10px calc(10px + env(safe-area-inset-bottom, 0px));
  padding-left: max(16px, env(safe-area-inset-left, 0px)); padding-right: max(16px, env(safe-area-inset-right, 0px));
  background: linear-gradient(transparent, var(--bg) 30%);
}
.addbar input { flex: 1; max-width: 552px; min-width: 0; height: 48px; padding: 0 16px; border: 1px solid var(--line); border-radius: 24px; background: var(--card); }
.addbar input:focus, dialog input:focus { outline: 2px solid var(--accent); outline-offset: -1px; }
.addbar button { flex: none; width: 48px; height: 48px; border-radius: 50%; background: var(--accent); color: var(--card); font-size: 26px; line-height: 1; }

.stack { display: flex; flex-direction: column; gap: 10px; }
.wide { display: block; width: 100%; text-align: center; padding: 12px; border: 1px solid var(--line); border-radius: 12px; background: var(--card); cursor: pointer; }

dialog { border: 0; border-radius: 16px; padding: 20px; width: min(420px, calc(100vw - 32px)); background: var(--card); color: var(--text); }
dialog::backdrop { background: rgba(0, 0, 0, 0.45); }
dialog form { display: flex; flex-direction: column; gap: 12px; }
dialog label { display: flex; flex-direction: column; gap: 4px; font-size: 13px; color: var(--muted); }
dialog input:not([type=checkbox]) { height: 44px; padding: 0 12px; border: 1px solid var(--line); border-radius: 10px; background: var(--bg); color: var(--text); font-size: 16px; width: 100%; }
.pair { display: flex; gap: 12px; }
.pair label { flex: 1; min-width: 0; }
.days { border: 0; padding: 0; margin: 0; display: flex; flex-wrap: wrap; gap: 6px; }
.days legend { font-size: 13px; color: var(--muted); margin-bottom: 4px; padding: 0; }
.days label { flex-direction: row; align-items: center; gap: 4px; font-size: 15px; color: var(--text); border: 1px solid var(--line); border-radius: 8px; padding: 6px 8px; }
.buttons { display: flex; align-items: center; gap: 6px; margin-top: 4px; }
.buttons button { padding: 9px 12px; border-radius: 10px; font-size: 15px; white-space: nowrap; }
.buttons .primary { background: var(--accent); color: var(--card); font-weight: 600; }
.buttons .danger { color: var(--danger); }
.grow { flex: 1; }
