:root {
  --bg: #FFFFFF;
  --fg: #0A0A0A;
  --muted: #737373;
  --line: #F0F0F0;
  --line2: #F5F5F5;
  --accent: #EA580C;
  --late: #DC2626;
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #0A0A0A; --fg: #FAFAFA; --muted: #A3A3A3; --line: #262626; --line2: #1C1C1C;
    --accent: #F97316; --late: #F87171; color-scheme: dark;
  }
}
:root[data-theme="dark"] {
  --bg: #0A0A0A; --fg: #FAFAFA; --muted: #A3A3A3; --line: #262626; --line2: #1C1C1C;
  --accent: #F97316; --late: #F87171; color-scheme: dark;
}

* { box-sizing: border-box; }
html, body { margin: 0; background: var(--bg); color: var(--fg); }
body {
  font-family: Inter, -apple-system, BlinkMacSystemFont, "Segoe UI", system-ui, sans-serif;
  font-size: 15px;
  -webkit-font-smoothing: antialiased;
  -webkit-tap-highlight-color: transparent;
}
button, input, select { font: inherit; color: inherit; }
a { color: inherit; }
.sr { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }

#app {
  max-width: 480px;
  margin: 0 auto;
  min-height: 100dvh;
  padding: calc(env(safe-area-inset-top) + 8px) 24px calc(env(safe-area-inset-bottom) + 32px);
  display: flex;
  flex-direction: column;
  gap: 24px;
}

/* Header */
.top { display: flex; align-items: center; justify-content: space-between; min-height: 44px; gap: 8px; }
.top-actions { display: flex; margin-right: -12px; }
.brand { font-size: 17px; font-weight: 600; letter-spacing: -0.3px; }
.title { font-size: 28px; font-weight: 500; letter-spacing: -0.8px; flex: 1; }
.back { margin-left: -12px; }
.sub-top { margin-top: -16px; }
.icon-btn {
  width: 44px; height: 44px; border: 0; background: transparent; padding: 0;
  display: inline-flex; align-items: center; justify-content: center; color: var(--fg); text-decoration: none; cursor: pointer;
}
.pick {
  appearance: none; -webkit-appearance: none; border: 0; background: transparent; color: var(--muted);
  padding: 4px 18px 4px 0; font-size: 13px; cursor: pointer;
  background-image: linear-gradient(45deg, transparent 50%, var(--muted) 50%), linear-gradient(135deg, var(--muted) 50%, transparent 50%);
  background-position: right 6px center, right 2px center; background-size: 4px 4px; background-repeat: no-repeat;
}

/* Type */
.label { font-size: 13px; color: var(--muted); display: inline-flex; align-items: center; gap: 8px; }
.muted { color: var(--muted); }
.small { font-size: 13px; }
.body { margin: 0; color: var(--muted); line-height: 1.5; }
.big { font-size: 88px; font-weight: 300; line-height: 0.9; letter-spacing: -4px; font-variant-numeric: tabular-nums; }
.big.mid { font-size: 64px; letter-spacing: -3px; }
.sub { font-size: 15px; color: var(--muted); padding-top: 6px; line-height: 1.45; }
.headline { font-size: 32px; font-weight: 500; line-height: 1.1; letter-spacing: -1px; }

.hero { display: flex; flex-direction: column; gap: 8px; }

.sub-row { display: flex; align-items: center; justify-content: space-between; gap: 12px; }
.traffic { padding-top: 6px; white-space: nowrap; font-size: 13px; }
.field.place .input:not(.pname) { flex: 1; font-weight: 400; }
.field.place .pname { flex: none; width: 96px; text-align: left; color: var(--muted); font-weight: 400; }
.input::placeholder { color: var(--muted); }
.select { appearance: none; -webkit-appearance: none; cursor: pointer; text-align-last: right; flex: 1; }
.icon-btn.muted { color: var(--muted); margin-right: -12px; }

/* Now */
.now { display: flex; flex-direction: column; gap: 10px; }
.now-meta { display: flex; justify-content: space-between; align-items: center; }
.now-line { display: flex; justify-content: space-between; align-items: center; gap: 12px; }
.now-name { font-size: 28px; font-weight: 500; letter-spacing: -0.8px; }
.dot { width: 6px; height: 6px; border-radius: 3px; background: var(--accent); flex: none; }
.dot.late { background: var(--late); }
.bar { height: 2px; background: var(--line); }
.bar > div { height: 2px; background: var(--accent); transition: width .4s; }

/* Rows */
.rows { display: flex; flex-direction: column; }
.row {
  display: flex; align-items: center; gap: 16px; min-height: 44px; width: 100%;
  border: 0; border-bottom: 1px solid var(--line2); background: transparent; padding: 0; text-align: left; cursor: pointer;
}
div.row { cursor: default; }
.row .time { width: 36px; font-size: 14px; color: var(--muted); font-variant-numeric: tabular-nums; flex: none; }
.row .name { flex: 1; display: flex; align-items: baseline; gap: 8px; min-width: 0; }
.row .name > span:first-child { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.row .dur { font-size: 13px; color: var(--muted); font-variant-numeric: tabular-nums; display: inline-flex; align-items: center; gap: 6px; }
.row .dur b { color: var(--fg); font-weight: 600; font-size: 15px; }
.row.done .name, .row.done .dur { color: var(--muted); }
.row.cur .name { font-weight: 600; }
.row.cur .time { color: var(--fg); }
.row.skipped .name > span:first-child { color: var(--muted); text-decoration: line-through; }
.opt { font-size: 12px; color: var(--muted); display: inline-flex; align-items: center; gap: 3px; white-space: nowrap; }

/* Buttons */
.btn-primary {
  display: flex; align-items: center; justify-content: center; height: 52px; border-radius: 26px; border: 0;
  background: var(--fg); color: var(--bg); font-size: 16px; font-weight: 500; text-decoration: none; cursor: pointer; width: 100%;
}
.btn-small {
  height: 36px; padding: 0 16px; border-radius: 18px; border: 1px solid var(--line); background: transparent;
  font-size: 14px; font-weight: 500; cursor: pointer; flex: none;
}
.btn-text {
  border: 0; background: transparent; color: var(--muted); font-size: 15px; min-height: 44px; padding: 0;
  text-decoration: none; display: inline-flex; align-items: center; justify-content: center; cursor: pointer;
}
.btn-text.left { justify-content: flex-start; }
.btn-text.strong { color: var(--fg); font-weight: 500; }
.btn-text.accent { color: var(--fg); font-weight: 600; justify-content: flex-start; text-decoration: underline; text-underline-offset: 4px; text-decoration-color: var(--accent); }
.btn-text.danger { color: var(--late); }
.actions { display: flex; flex-direction: column; gap: 4px; margin-top: auto; }

/* Setup */
.tabs { display: flex; gap: 20px; border-bottom: 1px solid var(--line); overflow-x: auto; margin-top: -8px; }
.tab {
  height: 40px; border: 0; background: transparent; padding: 0; color: var(--muted); cursor: pointer; white-space: nowrap;
  border-bottom: 2px solid transparent; margin-bottom: -1px;
}
.tab.on { color: var(--fg); font-weight: 500; border-bottom-color: var(--fg); }
.fields { display: flex; flex-direction: column; }
.field {
  display: flex; align-items: center; justify-content: space-between; gap: 12px; min-height: 48px;
  border-bottom: 1px solid var(--line2);
}
.field > label, .flabel { color: var(--muted); }
.input {
  border: 0; background: transparent; padding: 0; height: 40px; font-size: 15px; font-weight: 500; text-align: right;
  min-width: 0; border-radius: 0;
}
.input:focus { outline: none; box-shadow: inset 0 -1px 0 var(--fg); }
.input.num { width: 44px; font-variant-numeric: tabular-nums; }
.field .input:not(.num) { flex: 1; }
.stepper { display: flex; align-items: center; margin-right: -12px; }
.stepper span { width: 56px; text-align: center; font-weight: 500; }
.chips { display: flex; gap: 4px; flex-wrap: wrap; justify-content: flex-end; }
.chip {
  min-width: 32px; height: 32px; padding: 0 8px; border-radius: 16px; border: 1px solid var(--line); background: transparent;
  font-size: 13px; color: var(--muted); cursor: pointer;
}
.chip.on { background: var(--fg); color: var(--bg); border-color: var(--fg); }
.chip:disabled { opacity: .35; cursor: default; }
.chip.wide { padding: 0 14px; }
.chip.danger { color: var(--late); margin-left: auto; }
.edit-row { border-bottom: 1px solid var(--line2); background: var(--bg); position: relative; transition: transform .15s ease; }
.edit-row.dragging { transition: none; z-index: 2; box-shadow: 0 8px 24px rgba(0,0,0,.18); border-radius: 8px; }
.drag {
  width: 32px; height: 44px; margin-left: -8px; display: inline-flex; align-items: center; justify-content: center;
  color: var(--muted); touch-action: none; cursor: grab; flex: none;
}
.is-dragging, .is-dragging * { user-select: none; -webkit-user-select: none; cursor: grabbing; }
.edit-main { display: flex; align-items: center; gap: 6px; min-height: 44px; }
.edit-main .name-in { flex: 1; text-align: left; font-weight: 400; }
.edit-main .icon-btn { margin-right: -12px; color: var(--muted); }
.edit-more { display: flex; flex-direction: column; padding: 0 0 12px; }
.switch-row { display: flex; align-items: center; justify-content: space-between; min-height: 44px; }
.switch { width: 44px; height: 26px; border: 0; border-radius: 13px; padding: 3px; background: var(--line); display: flex; justify-content: flex-start; cursor: pointer; flex: none; }
.switch span { width: 20px; height: 20px; border-radius: 10px; background: var(--muted); }
.switch.on { background: var(--fg); justify-content: flex-end; }
.switch.on span { background: var(--bg); }
.edit-tools { display: flex; gap: 6px; padding-top: 6px; }
.hint { margin: -8px 0 0; font-size: 13px; color: var(--muted); line-height: 1.45; }
.wake-sum { display: flex; align-items: flex-end; justify-content: space-between; padding-top: 8px; }
.wake-sum > div { display: flex; flex-direction: column; gap: 4px; padding-bottom: 6px; }

/* Settings */
.group { display: flex; flex-direction: column; gap: 10px; }
.seg {
  display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 4px; padding: 4px;
  border: 1px solid var(--line); border-radius: 24px;
}
.seg button { height: 38px; border: 0; border-radius: 19px; background: transparent; color: var(--muted); font-weight: 500; cursor: pointer; }
.seg button.on { background: var(--fg); color: var(--bg); }

:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
