/* 駅の発車標のような、暗い盤面にオレンジの文字。ライト・ダークとも同じ見た目にしている。 */
:root {
  --bg: #111214; --panel: #1b1d21; --panel2: #24272c; --line: #33373e; --ink: #f2f0ea; --sub: #9aa0a8;
  --amber: #ffa630; --amber-dim: #6b4a1a; --green: #4cd68a; --red: #ff5c5c; --blue: #6fb8ff;
  --mono: "SF Mono", "Menlo", "Consolas", "Roboto Mono", monospace;
  --font: "Hiragino Sans", "Hiragino Kaku Gothic ProN", "Noto Sans JP", "Yu Gothic UI", "Meiryo", sans-serif;
  color-scheme: dark;
}
* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body { margin: 0; background: var(--bg); color: var(--ink); font-family: var(--font); line-height: 1.6; }
button, input, select { font: inherit; color: inherit; }
:focus-visible { outline: 3px solid var(--blue); outline-offset: 2px; }
[hidden] { display: none !important; }
.vh { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }

.board { max-width: 600px; margin: 0 auto; padding: calc(18px + env(safe-area-inset-top)) calc(16px + env(safe-area-inset-right)) calc(90px + env(safe-area-inset-bottom)) calc(16px + env(safe-area-inset-left)); }
.head h1 { margin: 0; font-size: 22px; letter-spacing: .04em; display: flex; align-items: center; gap: 8px; }
.head h1::before { content: ""; width: 12px; height: 12px; border-radius: 50%; background: var(--amber); box-shadow: 0 0 10px var(--amber); }
.lead { margin: 4px 0 14px; color: var(--sub); font-size: 14px; }
.sec { margin: 0 0 8px; font-size: 16px; }
.hint { margin: 8px 0; color: var(--sub); font-size: 13px; }
.ferr { margin: 6px 0 0; color: var(--red); font-size: 13px; }
.ferr:empty { display: none; }

.routines { display: flex; gap: 6px; overflow-x: auto; padding: 2px 2px 8px; margin: 0 -2px 6px; scrollbar-width: thin; }
.rt { flex: none; min-height: 44px; padding: 6px 14px; border: 1px solid var(--line); border-radius: 999px; background: var(--panel); color: var(--sub); cursor: pointer; white-space: nowrap; }
.rt[aria-current="true"] { background: var(--amber); border-color: var(--amber); color: #1a1205; font-weight: 700; }
.rt.plus { border-style: dashed; }
.templates { background: var(--panel); border: 1px solid var(--line); border-radius: 14px; padding: 14px; margin-bottom: 14px; }
.tpl-list { display: grid; gap: 8px; }
.tpl { display: grid; text-align: left; gap: 2px; padding: 10px 12px; border: 1px solid var(--line); border-radius: 10px; background: var(--panel2); cursor: pointer; min-height: 52px; }
.tpl small { color: var(--sub); font-size: 12px; }

.target { background: var(--panel); border: 1px solid var(--line); border-radius: 16px; padding: 14px; }
.mode { display: inline-flex; background: var(--bg); border-radius: 999px; padding: 3px; }
.mode button { min-height: 40px; padding: 4px 16px; border: 0; border-radius: 999px; background: none; color: var(--sub); cursor: pointer; font-weight: 700; }
.mode button[aria-checked="true"] { background: var(--panel2); color: var(--amber); }
.tgt { display: block; margin-top: 8px; }
.tgt input { width: 100%; font-family: var(--mono); font-size: 44px; font-weight: 700; color: var(--amber); background: #000; border: 1px solid var(--line); border-radius: 12px; padding: 4px 12px; text-shadow: 0 0 14px rgba(255, 166, 48, .45); min-height: 80px; }
.tgt input::-webkit-calendar-picker-indicator { filter: invert(.7); }
.startat { margin: 10px 0 0; font-size: 15px; font-weight: 700; }
.startat.late { color: var(--red); }

.steps { list-style: none; margin: 14px 0 0; padding: 0; position: relative; }
.step { display: grid; grid-template-columns: 52px 1fr auto; grid-template-areas: "at name name" "dur dur tools"; gap: 6px 8px; align-items: center; padding: 10px 0; border-bottom: 1px solid var(--line); }
.step .at { grid-area: at; font-family: var(--mono); font-weight: 700; color: var(--amber); font-size: 16px; }
.sn { grid-area: name; min-width: 0; min-height: 44px; padding: 6px 10px; border: 1px solid var(--line); border-radius: 10px; background: var(--panel); font-size: 16px; }
.dur { grid-area: dur; display: flex; align-items: center; gap: 4px; }
.st-b, .tb { width: 44px; height: 44px; border: 1px solid var(--line); border-radius: 10px; background: var(--panel); cursor: pointer; font-size: 18px; }
.tb:disabled { opacity: .3; cursor: default; }
.tb.rm { color: var(--sub); }
.dv { width: 52px; min-height: 44px; text-align: center; font-family: var(--mono); font-size: 17px; border: 1px solid var(--line); border-radius: 10px; background: #000; }
.u { color: var(--sub); font-size: 13px; }
.tools { grid-area: tools; display: flex; gap: 4px; justify-self: end; }
.step.end { grid-template-areas: "at name name"; border-bottom: 0; }
.step.end .at { font-size: 20px; }
.endw { grid-area: name; font-weight: 800; font-size: 18px; letter-spacing: .2em; }
.add { width: 100%; min-height: 48px; margin-top: 8px; border: 1px dashed var(--line); border-radius: 12px; background: none; color: var(--sub); cursor: pointer; }
.go { display: block; width: 100%; min-height: 60px; margin-top: 18px; border: 0; border-radius: 14px; background: var(--amber); color: #1a1205; font-size: 20px; font-weight: 800; letter-spacing: .1em; cursor: pointer; box-shadow: 0 4px 0 #a86412; }
.go:active { transform: translateY(2px); box-shadow: 0 2px 0 #a86412; }
.btn { min-height: 46px; padding: 8px 16px; border: 1px solid var(--line); border-radius: 12px; background: var(--panel); cursor: pointer; white-space: nowrap; }
.link { background: none; border: 0; min-height: 44px; padding: 8px 0; color: var(--blue); text-decoration: underline; text-underline-offset: 3px; cursor: pointer; }
.link.danger { color: var(--red); }
.more { margin-top: 18px; }
.more summary { cursor: pointer; min-height: 44px; display: flex; align-items: center; color: var(--sub); font-size: 14px; }
.fld { display: grid; gap: 2px; font-size: 13px; color: var(--sub); }
.fld input { min-height: 46px; padding: 6px 10px; border: 1px solid var(--line); border-radius: 10px; background: var(--panel); color: var(--ink); font-size: 16px; }
.move { margin-top: 26px; padding-top: 14px; border-top: 1px solid var(--line); }
.move .sec { font-size: 14px; }
.row { display: flex; flex-wrap: wrap; gap: 8px; }
.file { position: relative; display: inline-flex; align-items: center; }
.file input { position: absolute; inset: 0; opacity: 0; width: 100%; cursor: pointer; }
.file:focus-within { outline: 3px solid var(--blue); }

/* 実行中 */
.run-top { display: flex; justify-content: space-between; align-items: center; gap: 8px; flex-wrap: wrap; }
.dep { margin: 0; font-family: var(--mono); color: var(--amber); font-size: 15px; }
.chime { min-height: 40px; padding: 4px 12px; border: 1px solid var(--line); border-radius: 999px; background: var(--panel); color: var(--sub); cursor: pointer; font-size: 13px; }
.chime[aria-pressed="true"] { color: var(--amber); border-color: var(--amber); }
.now-label { margin: 22px 0 0; color: var(--sub); font-size: 14px; letter-spacing: .2em; }
.now { margin: 0; font-size: clamp(34px, 11vw, 60px); font-weight: 800; line-height: 1.25; overflow-wrap: anywhere; text-wrap: balance; }
.cd { margin: 14px 0 0; display: grid; gap: 0; background: #000; border: 1px solid var(--line); border-radius: 14px; padding: 10px 14px; }
.cd-l { color: var(--sub); font-size: 14px; overflow-wrap: anywhere; }
.cd-num { font-family: var(--mono); font-weight: 700; font-size: clamp(52px, 18vw, 96px); line-height: 1.1; color: var(--amber); text-shadow: 0 0 18px rgba(255, 166, 48, .45); font-variant-numeric: tabular-nums; }
.cd-num.over { color: var(--red); text-shadow: 0 0 18px rgba(255, 92, 92, .45); }
.status { display: inline-block; margin: 12px 0 0; padding: 4px 16px; border-radius: 999px; font-weight: 800; font-size: 20px; }
.status.late { background: var(--red); color: #1a0505; }
.status.ahead { background: var(--green); color: #04170c; }
.status.on { background: var(--panel2); color: var(--ink); }
.prog { position: relative; margin: 18px 0 6px; }
.segs { display: flex; gap: 3px; height: 14px; }
.seg { flex-basis: 0; background: var(--panel2); border-radius: 3px; }
.seg.done { background: var(--amber-dim); }
.seg.cur { background: var(--amber); }
.needle { position: absolute; top: -5px; bottom: -5px; width: 3px; margin-left: -1px; background: var(--ink); border-radius: 2px; }
.run-btns { display: grid; grid-template-columns: 1fr auto; gap: 8px; align-items: end; }
.run-btns .go { margin-top: 12px; font-size: 18px; letter-spacing: .02em; overflow-wrap: anywhere; padding: 8px 12px; }
.rows { list-style: none; margin: 18px 0 0; padding: 0; border-top: 1px solid var(--line); }
.rows li { display: grid; grid-template-columns: 56px 1fr auto; gap: 8px; padding: 10px 4px; border-bottom: 1px solid var(--line); align-items: center; }
.rows .rt-at { font-family: var(--mono); color: var(--amber); font-weight: 700; }
.rows .rt-m { color: var(--sub); font-size: 13px; font-family: var(--mono); }
.rows li.cur { background: var(--panel); }
.rows li.cur .rt-n { font-weight: 800; }
.rows li.fin .rt-n { letter-spacing: .2em; font-weight: 800; }
.flash { position: fixed; left: 50%; top: calc(12px + env(safe-area-inset-top)); transform: translateX(-50%); width: min(560px, calc(100% - 24px - env(safe-area-inset-left, 0px) - env(safe-area-inset-right, 0px))); margin: 0; padding: 12px 16px; border-radius: 12px; background: var(--amber); color: #1a1205; font-weight: 800; text-align: center; display: none; z-index: 5; }
.flash.on { display: block; }
@media (prefers-reduced-motion: no-preference) { .flash.on { animation: blink 1s ease-in-out 3; } @keyframes blink { 50% { opacity: .55; } } }

/* 完了 */
#done { text-align: center; padding-top: 60px; }
.done-mark { margin: 0; font-size: 60px; color: var(--green); text-shadow: 0 0 24px var(--green); line-height: 1; }
.done-h { margin: 10px 0 4px; font-size: 44px; letter-spacing: .2em; }
.done-sub { margin: 0 0 20px; color: var(--sub); }
@media (prefers-reduced-motion: no-preference) { .done-mark { animation: pop .5s cubic-bezier(.2, 1.6, .4, 1); } @keyframes pop { from { transform: scale(.3); opacity: 0; } } }

.foot { margin-top: 34px; text-align: center; font-size: 12px; color: var(--sub); }
.foot p { margin: 2px 0; }
.foot a { color: inherit; display: inline-block; padding: 8px; }
.v-run .foot { opacity: .6; }

.toast { position: fixed; left: 50%; bottom: calc(16px + env(safe-area-inset-bottom)); transform: translateX(-50%); width: min(560px, calc(100% - 24px - env(safe-area-inset-left, 0px) - env(safe-area-inset-right, 0px))); display: none; align-items: center; gap: 10px; padding: 12px 14px; background: var(--ink); color: var(--bg); border-radius: 12px; font-size: 14px; z-index: 10; }
.toast.on { display: flex; }
.toast span { flex: 1; }
.toast button { min-height: 40px; padding: 4px 12px; border: 1px solid currentColor; border-radius: 8px; background: none; color: inherit; font-weight: 700; cursor: pointer; white-space: nowrap; }

/* iPhone (WebKit) keeps a fieldset at least as wide as its content; let it shrink so nothing overflows narrow screens */
fieldset{min-width:0;min-inline-size:0}
input,select,textarea{max-width:100%}

/* Narrow phones and larger text: the time column grows with its text instead of overlapping the name */
.step { grid-template-columns: minmax(52px, auto) minmax(0, 1fr) auto; }
.tgt input { font-size: clamp(30px, 11vw, 44px); min-width: 0; }
.endw { min-width: 0; overflow-wrap: anywhere; }
