:root {
  --bg: #EEF2F1;
  --surface: #FFFFFF;
  --surface-2: #F6F9F8;
  --ink: #12303D;
  --muted: #566B73;
  --line: #CFD9DA;
  --amber: #C9760A;
  --amber-ink: #3B2200;
  --amber-fill: #F2A33A;
  --amber-soft: #FBEBD0;
  --ok: #24704A;
  --ok-soft: #DDF0E5;
  --doing: #1F5F8B;
  --doing-soft: #DCEAF4;
  --danger: #A8261E;
  --focus: #1F5F8B;
  --display: "Karantina", "IBM Plex Sans Hebrew", system-ui, sans-serif;
  --body: "IBM Plex Sans Hebrew", "Segoe UI", Arial, sans-serif;
  --radius: 10px;
  --c1: #7C8F96; --c2: #1F5F8B; --c3: #3E8E6A; --c4: #E08A12; --c5: #B9C6C9;
  color-scheme: light;
}
:root[data-theme="red"] { --c1: #5A0F0A; --c2: #8A1A12; --c3: #B8352B; --c4: #FF5545; --c5: #3A0805; }
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]):not([data-theme="red"]) {
    --bg: #0A1A22; --surface: #10283A; --surface-2: #0D2230; --ink: #E6EEF0; --muted: #9AB0B8; --line: #22404F;
    --amber: #F2A33A; --amber-ink: #2A1800; --amber-fill: #F2A33A; --amber-soft: #3A2A10;
    --ok: #6FD39E; --ok-soft: #123A27; --doing: #7DB8E8; --doing-soft: #12324A; --danger: #FF8A80; --focus: #7DB8E8; --c2: #5FA3D6; --c3: #5CC096; --c5: #3A5562;
    color-scheme: dark;
  }
}
:root[data-theme="dark"] {
  --bg: #0A1A22; --surface: #10283A; --surface-2: #0D2230; --ink: #E6EEF0; --muted: #9AB0B8; --line: #22404F;
  --amber: #F2A33A; --amber-ink: #2A1800; --amber-fill: #F2A33A; --amber-soft: #3A2A10;
  --ok: #6FD39E; --ok-soft: #123A27; --doing: #7DB8E8; --doing-soft: #12324A; --danger: #FF8A80; --focus: #7DB8E8; --c2: #5FA3D6; --c3: #5CC096; --c5: #3A5562;
  color-scheme: dark;
}
:root[data-theme="red"] {
  --bg: #000000; --surface: #120000; --surface-2: #0A0000; --ink: #FF5545; --muted: #B8352B; --line: #4A0D08;
  --amber: #FF5545; --amber-ink: #000000; --amber-fill: #C8241A; --amber-soft: #2A0503;
  --ok: #FF5545; --ok-soft: #2A0503; --doing: #FF5545; --doing-soft: #2A0503; --danger: #FF8A80; --focus: #FF5545;
  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(--body); font-size: 16px; line-height: 1.6;
  padding-bottom: calc(72px + env(safe-area-inset-bottom));
}
:root[data-theme="red"] img { filter: grayscale(1) sepia(1) saturate(6) hue-rotate(-40deg) brightness(.7); }
a { color: inherit; }
button, input, select, textarea { font: inherit; color: inherit; }
:focus-visible { outline: 3px solid var(--focus); outline-offset: 2px; border-radius: 4px; }
.skip { position: absolute; inset-inline-start: -999px; top: 0; background: var(--surface); padding: 8px 12px; z-index: 20; }
.skip:focus { inset-inline-start: 8px; }

.top {
  position: sticky; top: 0; z-index: 10;
  display: flex; align-items: center; justify-content: space-between; gap: 12px;
  padding: 10px 16px; background: var(--bg); border-bottom: 1px solid var(--line);
}
.brand { display: flex; align-items: center; gap: 10px; text-decoration: none; min-width: 0; }
.brand-mark { width: 30px; height: 30px; flex: none; }
.brand-mark .horizon { stroke: var(--ink); stroke-width: 3; }
.brand-mark .shell { fill: var(--amber-fill); }
.brand-text { font-family: var(--display); font-weight: 700; font-size: 26px; line-height: 1; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.top-meta { display: flex; align-items: center; gap: 10px; }
.progress-label { font-size: 14px; color: var(--muted); font-variant-numeric: tabular-nums; white-space: nowrap; }
.icon-btn { border: 1px solid var(--line); background: var(--surface); border-radius: 999px; padding: 6px 12px; font-size: 14px; cursor: pointer; white-space: nowrap; }
.icon-btn[aria-pressed="true"] { background: var(--amber-fill); color: var(--amber-ink); border-color: var(--amber-fill); }

.nav {
  position: fixed; bottom: 0; inset-inline: 0; z-index: 10;
  display: grid; grid-template-columns: repeat(6, 1fr);
  background: var(--surface); border-top: 1px solid var(--line);
  padding-bottom: env(safe-area-inset-bottom);
}
.nav a { text-decoration: none; text-align: center; padding: 12px 2px 14px; font-size: 13px; color: var(--muted); border-top: 3px solid transparent; }
.nav a[aria-current="page"] { color: var(--ink); border-top-color: var(--amber-fill); font-weight: 600; }

main { max-width: 760px; margin: 0 auto; padding: 20px 16px 32px; outline: none; }
.loading { color: var(--muted); }
h1, h2, h3 { font-family: var(--display); font-weight: 700; line-height: 1.05; margin: 0; letter-spacing: .2px; }
h1 { font-size: 44px; margin-bottom: 6px; }
h2 { font-size: 32px; margin: 28px 0 10px; }
h3 { font-size: 24px; margin: 0 0 4px; }
.lede { color: var(--muted); margin: 0 0 18px; max-width: 62ch; }
p { margin: 0 0 12px; max-width: 70ch; }
.muted { color: var(--muted); }
.small { font-size: 14px; }

@media (min-width: 900px) {
  body { padding-bottom: 0; }
  .nav { position: sticky; top: 51px; bottom: auto; display: flex; justify-content: center; gap: 4px; border-top: 0; border-bottom: 1px solid var(--line); background: var(--bg); }
  .nav a { padding: 10px 16px 12px; font-size: 15px; border-top: 0; border-bottom: 3px solid transparent; }
  .nav a[aria-current="page"] { border-bottom-color: var(--amber-fill); }
  h1 { font-size: 56px; }
}

/* next step hero */
.now { background: var(--surface); border: 1px solid var(--line); border-radius: 14px; padding: 18px 18px 16px; margin: 6px 0 20px; display: grid; grid-template-columns: auto 1fr; gap: 4px 16px; align-items: start; }
.now-num { font-family: var(--display); font-weight: 700; font-size: 84px; line-height: .85; color: var(--amber); grid-row: span 3; font-variant-numeric: tabular-nums; }
.now-label { font-size: 14px; color: var(--muted); }
.now h2 { margin: 0; font-size: 34px; }
.now .meta { font-size: 14px; color: var(--muted); }
.now .how { grid-column: 1 / -1; margin-top: 10px; }
.now .actions { grid-column: 1 / -1; }

.bar { height: 10px; background: var(--surface-2); border: 1px solid var(--line); border-radius: 999px; overflow: hidden; margin: 6px 0 4px; }
.bar > span { display: block; height: 100%; background: var(--amber-fill); }

.stats { display: grid; grid-template-columns: repeat(auto-fit, minmax(140px, 1fr)); gap: 10px; margin: 12px 0 8px; }
.stat { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 10px 12px; text-decoration: none; display: block; }
.stat b { display: block; font-family: var(--display); font-size: 36px; line-height: 1; font-variant-numeric: tabular-nums; }
.stat span { font-size: 14px; color: var(--muted); }

/* phases + steps */
.phase { margin-top: 26px; }
.phase-head { display: flex; align-items: baseline; justify-content: space-between; gap: 12px; border-bottom: 2px solid var(--ink); padding-bottom: 4px; margin-bottom: 4px; }
.phase-head h2 { margin: 0; font-size: 30px; }
.phase-head span { font-size: 14px; color: var(--muted); font-variant-numeric: tabular-nums; white-space: nowrap; }
.steps { list-style: none; margin: 0; padding: 0; }
.step-row { border-bottom: 1px solid var(--line); }
.step-row a { display: grid; grid-template-columns: 44px 1fr auto; gap: 10px; align-items: center; padding: 12px 2px; text-decoration: none; }
.step-row .n { font-family: var(--display); font-weight: 700; font-size: 32px; line-height: 1; color: var(--muted); font-variant-numeric: tabular-nums; text-align: center; }
.step-row.done .n { color: var(--ok); }
.step-row.doing .n { color: var(--amber); }
.step-row .t { font-weight: 500; }
.step-row.done .t { color: var(--muted); }
.step-row .sub { display: block; font-size: 13px; color: var(--muted); font-weight: 400; }
.pill { font-size: 13px; padding: 2px 10px; border-radius: 999px; white-space: nowrap; border: 1px solid var(--line); color: var(--muted); }
.pill.done { background: var(--ok-soft); color: var(--ok); border-color: transparent; }
.pill.doing { background: var(--amber-soft); color: var(--amber); border-color: transparent; }
.pill.skipped { text-decoration: line-through; }
.pill.late { color: var(--danger); border-color: var(--danger); }

.step-detail { background: var(--surface); border: 1px solid var(--line); border-radius: 14px; padding: 18px; }
.step-detail .num { font-family: var(--display); font-size: 64px; line-height: .9; color: var(--amber); font-weight: 700; }
.block { margin: 14px 0; }
.block h3 { font-size: 22px; }
.record { background: var(--amber-soft); border-radius: var(--radius); padding: 10px 12px; }
.result-text { white-space: pre-wrap; background: var(--surface-2); border: 1px solid var(--line); border-radius: var(--radius); padding: 10px 12px; }

/* forms */
form.card, .card { background: var(--surface); border: 1px solid var(--line); border-radius: 14px; padding: 16px; margin: 12px 0; }
.grid2 { display: grid; grid-template-columns: 1fr 1fr; gap: 10px 12px; }
.grid2 .full { grid-column: 1 / -1; }
@media (max-width: 520px) { .grid2 { grid-template-columns: 1fr; } }
label { display: block; font-size: 14px; font-weight: 500; margin-bottom: 4px; }
.hint { display: block; font-size: 13px; color: var(--muted); font-weight: 400; }
input[type=text], input[type=number], input[type=date], input[type=time], input[type=password], select, textarea {
  width: 100%; min-height: 44px; padding: 9px 11px; border: 1px solid var(--line); border-radius: 8px; background: var(--surface-2);
}
textarea { min-height: 96px; resize: vertical; }
input:focus, select:focus, textarea:focus { border-color: var(--focus); outline: none; box-shadow: 0 0 0 3px color-mix(in srgb, var(--focus) 30%, transparent); }
.row { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; }
.btn { min-height: 44px; padding: 9px 16px; border-radius: 8px; border: 1px solid var(--line); background: var(--surface); cursor: pointer; font-weight: 500; text-decoration: none; display: inline-flex; align-items: center; justify-content: center; gap: 6px; }
.btn.primary { background: var(--ink); color: var(--bg); border-color: var(--ink); }
:root[data-theme="red"] .btn.primary { background: var(--amber-fill); color: #000; border-color: var(--amber-fill); }
.btn.amber { background: var(--amber-fill); color: var(--amber-ink); border-color: var(--amber-fill); }
.btn.danger { color: var(--danger); border-color: var(--danger); background: transparent; }
.btn.quiet { border-color: transparent; background: transparent; text-decoration: underline; padding-inline: 4px; }
.btn[disabled] { opacity: .6; cursor: progress; }
.err { color: var(--danger); font-size: 14px; margin-top: 6px; }
.locked { background: var(--surface-2); border: 1px dashed var(--line); border-radius: var(--radius); padding: 12px; color: var(--muted); }

/* entries */
.entries { list-style: none; padding: 0; margin: 0; }
.entry { background: var(--surface); border: 1px solid var(--line); border-radius: 12px; padding: 12px 14px; margin: 10px 0; }
.entry-head { display: flex; justify-content: space-between; gap: 10px; align-items: baseline; }
.entry-head b { font-weight: 600; }
.entry dl { display: grid; grid-template-columns: max-content 1fr; gap: 2px 12px; margin: 8px 0 0; font-size: 14px; }
.entry dt { color: var(--muted); }
.entry dd { margin: 0; white-space: pre-wrap; overflow-wrap: anywhere; }
.prio { font-family: var(--display); font-size: 26px; line-height: 1; font-weight: 700; color: var(--amber); }
.thumbs { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 10px; }
.thumbs a { display: block; width: 88px; height: 88px; border-radius: 8px; overflow: hidden; border: 1px solid var(--line); background: var(--surface-2); }
.thumbs img { width: 100%; height: 100%; object-fit: cover; display: block; }
.empty { border: 1px dashed var(--line); border-radius: 12px; padding: 16px; color: var(--muted); }

/* tables + charts */
.table-wrap { overflow-x: auto; border: 1px solid var(--line); border-radius: 12px; background: var(--surface); }
table { border-collapse: collapse; width: 100%; font-size: 14px; }
th, td { text-align: start; padding: 8px 10px; border-bottom: 1px solid var(--line); white-space: nowrap; font-variant-numeric: tabular-nums; }
th { font-weight: 600; background: var(--surface-2); }
tr:last-child td { border-bottom: 0; }
.chart { background: var(--surface); border: 1px solid var(--line); border-radius: 12px; padding: 12px; margin: 10px 0; }
.chart svg { width: 100%; height: auto; display: block; }
.chart text { fill: var(--ink); font-family: var(--body); }
.chart .axis { stroke: var(--line); }
.chart .lbl { fill: var(--muted); }
.legend { display: flex; flex-wrap: wrap; gap: 12px; font-size: 13px; color: var(--muted); margin-bottom: 6px; }
.legend i { display: inline-block; width: 12px; height: 12px; border-radius: 3px; margin-inline-end: 5px; vertical-align: -1px; }

#map { height: 360px; border-radius: 12px; border: 1px solid var(--line); margin: 10px 0; background: var(--surface-2); }
:root[data-theme="red"] #map { filter: grayscale(1) sepia(1) saturate(5) hue-rotate(-40deg) brightness(.6); }

.menu { list-style: none; padding: 0; margin: 0; }
.menu a { display: flex; justify-content: space-between; align-items: center; padding: 14px 4px; border-bottom: 1px solid var(--line); text-decoration: none; font-weight: 500; }
.menu a span { color: var(--muted); font-weight: 400; font-size: 14px; }
.check { list-style: none; padding: 0; margin: 0; }
.check li { padding: 6px 0; }
.check .yes { color: var(--ok); font-weight: 600; }
.check .no { color: var(--danger); font-weight: 600; }
pre.export { white-space: pre-wrap; background: var(--surface); border: 1px solid var(--line); border-radius: 12px; padding: 12px; font-size: 13px; max-height: 420px; overflow: auto; direction: ltr; text-align: left; }

#toast { position: fixed; inset-inline: 16px; bottom: calc(84px + env(safe-area-inset-bottom)); z-index: 30; display: flex; justify-content: center; pointer-events: none; }
#toast .t { background: var(--ink); color: var(--bg); padding: 10px 16px; border-radius: 10px; font-size: 15px; max-width: 520px; }
#toast .t.bad { background: var(--danger); color: #fff; }
@media (min-width: 900px) { #toast { bottom: 24px; } }
@media (prefers-reduced-motion: no-preference) {
  #toast .t { animation: rise .18s ease-out; }
  @keyframes rise { from { transform: translateY(8px); opacity: 0; } to { transform: none; opacity: 1; } }
}
