:root {
  color-scheme: light dark;
  --bg: #ffffff; --ink: #141821; --mute: #5d6575; --line: #e3e6ee; --card: #f5f7fb; --field: #ffffff;
  --blue: #1f3fb0; --blue2: #1f3fb0; --red: #e2412f; --green: #1f9d55; --arrow: #1f6fd1;
  --good: #1f9d55; --bad: #d4442f;
  --navh: 58px; --timerh: 60px;
}
@media (prefers-color-scheme: dark) {
  :root { --bg: #0f1424; --ink: #eef1f8; --mute: #a3abbd; --line: #273050; --card: #161d33; --field: #0f1424;
    --blue2: #8ea6ff; --green: #3ccf7f; --arrow: #6aa8ff; --good: #3ccf7f; --bad: #ff7a69; }
}
* { box-sizing: border-box; min-width: 0; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0; background: var(--bg); color: var(--ink);
  font: 16px/1.55 -apple-system, BlinkMacSystemFont, "Apple SD Gothic Neo", "Noto Sans KR", system-ui, sans-serif;
  overflow-x: clip;
  padding-bottom: calc(var(--navh) + var(--timerh) + env(safe-area-inset-bottom) + 24px);
}
.top { background: var(--blue); color: #fff; padding: calc(14px + env(safe-area-inset-top)) max(4vw, 16px) 14px; }
.top h1 { margin: 0; font-size: 22px; font-weight: 800; }
.wrap { max-width: 720px; margin: 0 auto; padding: 0 max(4vw, 14px); }
h2 { font-size: 19px; margin: 24px 0 8px; font-weight: 800; }
h3 { font-size: 16px; margin: 0; }
.sub { margin: -4px 0 12px; color: var(--mute); font-size: 14px; }
.empty { color: var(--mute); padding: 24px 0; text-align: center; }
.err { color: var(--bad); font-size: 14px; min-height: 1em; margin: 6px 0; }
.card { background: var(--card); border: 1px solid var(--line); border-radius: 14px; padding: 14px; margin: 10px 0; }
.row { display: flex; flex-wrap: wrap; gap: 10px; align-items: flex-end; margin-top: 8px; }
.grid2 { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; margin-top: 8px; }
.f { display: flex; flex-direction: column; gap: 4px; flex: 1 1 120px; }
.f label, .lbl { font-size: 13px; color: var(--mute); }
.in { display: flex; align-items: center; gap: 6px; }
.u { font-size: 14px; color: var(--mute); white-space: nowrap; }
input, select, textarea {
  font-size: 16px; font-family: inherit; color: var(--ink); background: var(--field);
  border: 1px solid var(--line); border-radius: 10px; padding: 10px 12px; min-height: 44px; width: 100%;
}
textarea { min-height: 84px; resize: vertical; }
input:focus, select:focus, textarea:focus, button:focus-visible, a:focus-visible { outline: 3px solid #8ea6ff; outline-offset: 1px; }
.btn { min-height: 46px; border: 1px solid var(--line); border-radius: 12px; font-size: 15px; font-weight: 700; font-family: inherit;
  cursor: pointer; padding: 0 16px; background: var(--field); color: var(--ink); }
.btn.primary { background: var(--blue); border-color: var(--blue); color: #fff; }
.btn.danger { color: var(--bad); }
.btn.small { min-height: 40px; font-size: 14px; padding: 0 12px; }
.btn.wide { width: 100%; }
.chips { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 8px; }
.chips button { min-height: 42px; padding: 0 14px; border-radius: 999px; border: 1px solid var(--line); background: var(--field);
  color: var(--ink); font-size: 15px; font-weight: 500; font-family: inherit; cursor: pointer; }
.chips button[aria-pressed=true] { background: var(--blue); border-color: var(--blue); color: #fff; }
details summary { cursor: pointer; color: var(--blue2); font-size: 14px; min-height: 32px; display: flex; align-items: center; }
.how { margin: 6px 0 0; font-size: 14.5px; color: var(--mute); }

/* 그림 */
.fig { margin: 8px 0 2px; background: var(--field); border: 1px solid var(--line); border-radius: 12px; padding: 6px; }
.fig svg { display: block; width: 100%; max-width: 360px; height: auto; margin: 0 auto; }
.fig .b { fill: none; stroke: var(--ink); stroke-width: 7; stroke-linecap: round; stroke-linejoin: round; }
.fig .b.thin { stroke-width: 5; }
.fig .hd { fill: var(--ink); }
.fig .gd { stroke: var(--mute); stroke-width: 2; fill: none; }
.fig .dash { stroke-dasharray: 4 4; }
.fig .wall { fill: var(--line); stroke: var(--mute); stroke-width: 1.5; }
.fig .bench, .fig .deck { fill: var(--line); stroke: var(--mute); stroke-width: 1.5; }
.fig .ok { fill: none; stroke: var(--green); stroke-width: 3; }
.fig .ok-line { stroke: var(--green); stroke-width: 2.5; stroke-dasharray: 6 5; }
.fig .ar { stroke: var(--arrow); stroke-width: 3; }
.fig .ah { fill: var(--arrow); }
.fig .cable { stroke: var(--mute); stroke-width: 2; }
.fig .bar { fill: var(--mute); }
.fig .clk { fill: none; stroke: var(--arrow); stroke-width: 3; stroke-linecap: round; }
.fig .lb { fill: var(--ink); font-size: 12px; font-weight: 600; }
.fig .mute { fill: var(--mute); font-size: 11px; }

/* 일지 */
.ex { padding: 12px; }
.exh { display: flex; gap: 8px; align-items: center; }
.exh input { font-weight: 700; }
.last { font-size: 13px; color: var(--mute); margin: 6px 0 0; min-height: 1em; }
.sets { width: 100%; border-collapse: collapse; margin-top: 8px; }
.sets th { font-size: 12px; color: var(--mute); font-weight: 500; text-align: left; padding: 0 4px 4px; }
.sets td { padding: 3px 4px; }
.sets td:first-child { width: 2em; color: var(--mute); font-size: 14px; text-align: center; }
.sets td:last-child { width: 44px; }
.sets input { padding: 8px; text-align: right; }
.x { min-width: 40px; min-height: 40px; border: 0; background: transparent; color: var(--mute); font-size: 20px; cursor: pointer; border-radius: 8px; }
.state { font-size: 13px; color: var(--mute); }
.state.dirty { color: var(--red); font-weight: 700; }
.savebar.stick { position: sticky; bottom: calc(var(--navh) + var(--timerh) + env(safe-area-inset-bottom) + 8px); z-index: 3; }
.savebar .btn { box-shadow: 0 6px 20px rgba(0, 0, 0, .18); }

/* 목록 */
.item { display: block; width: 100%; text-align: left; font: inherit; color: inherit; cursor: pointer; }
.item b { font-variant-numeric: tabular-nums; }
.item .meta { display: block; font-size: 14px; color: var(--mute); margin-top: 2px; }
.cmp { width: 100%; border-collapse: collapse; font-size: 14.5px; }
.cmp td { padding: 7px 4px; border-top: 1px solid var(--line); }
.cmp td.v { text-align: right; white-space: nowrap; font-variant-numeric: tabular-nums; }
.up { color: var(--good); font-weight: 700; }
.down { color: var(--bad); font-weight: 700; }
.chart { position: relative; height: 200px; }
.chart svg { position: absolute; inset: 0; width: 100%; height: 100%; }
.chart .ln { fill: none; stroke: var(--blue2); stroke-width: 2.5; }
.chart .dot { fill: var(--blue2); }
.chart .ax { stroke: var(--line); }
.chart text { fill: var(--mute); font-size: 11px; }
.preview { font-size: 14px; color: var(--mute); margin: 6px 0 0; padding-left: 18px; }

/* 하단 타이머 + 탭 */
.timer { position: fixed; left: 0; right: 0; bottom: calc(var(--navh) + env(safe-area-inset-bottom)); height: var(--timerh);
  background: #141821; color: #fff; display: flex; align-items: center; gap: 10px; padding: 0 max(3vw, 10px); z-index: 5; }
.clock { font: 800 24px/1 ui-monospace, "SF Mono", Menlo, monospace; font-variant-numeric: tabular-nums; min-width: 4ch; }
.clock.run { color: #ff7a69; }
.tb { display: flex; gap: 6px; flex: 1; overflow-x: auto; scrollbar-width: none; }
.tb::-webkit-scrollbar { display: none; }
.tb button:first-child { margin-left: auto; }
.tb button { flex: none; min-height: 40px; padding: 0 8px; border-radius: 10px; border: 1px solid #3a4258; background: #1d2333;
  color: #fff; font-size: 13px; font-weight: 700; font-family: inherit; cursor: pointer; }
.tb .go { background: var(--red); border-color: var(--red); }
.tabs { position: fixed; left: 0; right: 0; bottom: 0; height: calc(var(--navh) + env(safe-area-inset-bottom));
  padding-bottom: env(safe-area-inset-bottom); background: var(--bg); border-top: 1px solid var(--line);
  display: grid; grid-template-columns: repeat(5, 1fr); z-index: 6; }
.tabs a { display: flex; align-items: center; justify-content: center; color: var(--mute); text-decoration: none; font-weight: 700; font-size: 15px; }
.tabs a[aria-current=page] { color: var(--blue2); box-shadow: inset 0 3px 0 var(--blue2); }

.overlay { position: fixed; inset: 0; background: rgba(10, 14, 28, .6); display: grid; place-items: center; z-index: 20; padding: 16px; }
.overlay[hidden] { display: none; }
.overlay .card { width: min(360px, 100%); background: var(--bg); }
#toast { position: fixed; left: 50%; bottom: calc(var(--navh) + var(--timerh) + env(safe-area-inset-bottom) + 16px);
  transform: translateX(-50%); background: var(--ink); color: var(--bg); padding: 10px 16px; border-radius: 999px;
  font-size: 14px; opacity: 0; pointer-events: none; transition: opacity .2s; z-index: 30; max-width: 90vw; }
#toast.on { opacity: 1; }
@media (prefers-reduced-motion: reduce) { #toast { transition: none; } }

input[type=number]::-webkit-inner-spin-button, input[type=number]::-webkit-outer-spin-button { -webkit-appearance: none; margin: 0; }
input[type=number] { -moz-appearance: textfield; appearance: textfield; }
.savebar { margin-top: 16px; }

/* 계정 */
.top { display: flex; align-items: center; justify-content: space-between; gap: 12px; }
.who { color: #dbe3ff; text-decoration: none; font-size: 14px; font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; max-width: 45%; }
.auth { display: grid; gap: 10px; }
.auth h2 { margin: 0 0 4px; }
.seg { display: grid; grid-template-columns: 1fr 1fr; border: 1px solid var(--line); border-radius: 12px; overflow: hidden; }
.seg button { min-height: 44px; border: 0; background: var(--field); color: var(--mute); font-size: 15px; font-weight: 700; font-family: inherit; cursor: pointer; }
.seg button[aria-pressed=true] { background: var(--blue); color: #fff; }
.auth:not(.signup) .only-signup { display: none; }
.hint { margin: 0; font-size: 13px; color: var(--mute); }
