/* ── Design tokens (dataviz reference palette) ─────────────────────────── */
:root {
  --page:      #f9f9f7;
  --surface:   #fcfcfb;
  --ink:       #0b0b0b;
  --ink-2:     #52514e;
  --muted:     #898781;
  --grid:      #e1e0d9;
  --baseline:  #c3c2b7;
  --border:    rgba(11,11,11,.10);
  --accent:    #2a78d6;
  --weekend:   rgba(11,11,11,.030);
  --wash:      rgba(11,11,11,.035);
  --danger:    #d03b3b;
  --s1: #2a78d6; --s2: #1baf7a; --s3: #eda100; --s4: #008300;
  --s5: #4a3aa7; --s6: #e34948; --s7: #e87ba4; --s8: #eb6834;
  --shadow: 0 8px 30px rgba(11,11,11,.10);
}
@media (prefers-color-scheme: dark) {
  :root {
    --page:      #0d0d0d;
    --surface:   #1a1a19;
    --ink:       #ffffff;
    --ink-2:     #c3c2b7;
    --muted:     #898781;
    --grid:      #2c2c2a;
    --baseline:  #383835;
    --border:    rgba(255,255,255,.10);
    --accent:    #3987e5;
    --weekend:   rgba(255,255,255,.035);
    --wash:      rgba(255,255,255,.045);
    --danger:    #e66767;
    --s1: #3987e5; --s2: #199e70; --s3: #c98500; --s4: #008300;
    --s5: #9085e9; --s6: #e66767; --s7: #d55181; --s8: #d95926;
    --shadow: 0 8px 30px rgba(0,0,0,.45);
  }
}

/* ── Base ───────────────────────────────────────────────────────────────── */
* { box-sizing: border-box; margin: 0; padding: 0; }
html, body { height: 100%; }
body {
  display: flex; flex-direction: column;
  background: var(--page); color: var(--ink);
  font: 13px/1.45 system-ui, -apple-system, "Segoe UI", sans-serif;
  overflow: hidden;
}
button { font: inherit; color: inherit; cursor: pointer; }
.spacer { flex: 1; }
.hint { color: var(--muted); font-size: 11.5px; }

/* ── Top bar ────────────────────────────────────────────────────────────── */
#topbar {
  display: flex; align-items: center; gap: 10px;
  min-height: 50px; padding: 8px 16px; flex-wrap: wrap;
  border-bottom: 1px solid var(--border); background: var(--page);
}
.brand { font-size: 14px; color: var(--ink-2); white-space: nowrap; }
.brand b { color: var(--ink); font-weight: 700; }
.viz-controls { display: flex; align-items: center; gap: 10px; flex: 1; flex-wrap: wrap; }
body.mode-input .viz-controls { display: none; }

#search {
  width: 210px; height: 30px; padding: 0 10px;
  border: 1px solid var(--border); border-radius: 8px;
  background: var(--surface); color: var(--ink); font: inherit;
  outline: none;
}
#search:focus { border-color: var(--accent); }
#search::placeholder { color: var(--muted); }

.segmented {
  display: flex; border: 1px solid var(--border); border-radius: 8px;
  background: var(--surface); overflow: hidden;
}
.segmented button {
  border: 0; background: transparent; height: 28px; padding: 0 12px;
  color: var(--ink-2); font-size: 12.5px;
}
.segmented button + button { border-left: 1px solid var(--border); }
.segmented button:hover { background: var(--wash); }
.segmented button.active {
  background: color-mix(in srgb, var(--accent) 14%, transparent);
  color: var(--accent); font-weight: 600;
}

.btn {
  height: 30px; padding: 0 12px;
  border: 1px solid var(--border); border-radius: 8px;
  background: var(--surface); color: var(--ink); font-size: 12.5px;
}
.btn:hover { background: var(--wash); }
.btn.primary {
  background: var(--accent); border-color: transparent; color: #fff; font-weight: 600;
}
.btn.primary:hover { filter: brightness(1.07); }
.btn.link { border: none; background: none; color: var(--accent); }
.btn.link:hover { text-decoration: underline; background: none; }

.iconbtn {
  width: 30px; height: 30px; border: 1px solid var(--border); border-radius: 8px;
  background: var(--surface); color: var(--ink-2); font-size: 14px; line-height: 1;
}
.iconbtn:hover { background: var(--wash); }

.clock {
  font-size: 12px; color: var(--ink-2); white-space: nowrap;
  font-variant-numeric: tabular-nums;
}
.clock .loc { color: var(--muted); }

/* ── Popovers ───────────────────────────────────────────────────────────── */
.pop {
  position: absolute; z-index: 60;
  background: var(--surface); border: 1px solid var(--border); border-radius: 10px;
  box-shadow: var(--shadow); padding: 12px 14px;
}
.pop.settings { top: 54px; right: 96px; width: 280px; }
.pop.settings label { display: block; font-size: 12px; font-weight: 600; margin: 10px 0 6px; }
.pop.settings label:first-child { margin-top: 0; }
.pop.settings select {
  width: 100%; height: 30px; border: 1px solid var(--border); border-radius: 8px;
  background: var(--surface); color: var(--ink); font: inherit; padding: 0 6px;
}
.pop.settings .hint { margin-top: 8px; }

.pop.skipped {
  left: 16px; bottom: 42px; max-width: min(720px, calc(100vw - 32px));
  max-height: 40vh; overflow: auto;
}
.pop.skipped .sk-line { display: flex; gap: 8px; align-items: baseline; padding: 3px 0; font-size: 12px; }
.pop.skipped .sk-no { color: var(--muted); min-width: 34px; font-variant-numeric: tabular-nums; }
.pop.skipped .sk-reason { color: var(--danger); white-space: nowrap; }
.pop.skipped code {
  font: 11.5px ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  color: var(--ink-2); overflow-wrap: anywhere;
}

/* ── Main / input panel ─────────────────────────────────────────────────── */
#main { flex: 1; display: flex; flex-direction: column; min-height: 0; position: relative; }

#inputPanel { display: flex; justify-content: center; align-items: flex-start; overflow: auto; }
body.mode-input #inputPanel { flex: 1; padding: 7vh 20px 40px; }
body.mode-viz #inputPanel {
  position: absolute; inset: 0; z-index: 50; padding: 6vh 20px 40px;
  background: color-mix(in srgb, var(--page) 60%, transparent);
  backdrop-filter: blur(3px);
}
body.mode-viz:not(.editing) #inputPanel { display: none; }
body.mode-input #closeInput { display: none; }

#inputPanel .card {
  width: min(760px, 100%);
  background: var(--surface); border: 1px solid var(--border); border-radius: 14px;
  box-shadow: var(--shadow); padding: 26px 28px;
}
.card-head { display: flex; align-items: center; justify-content: space-between; }
#inputPanel h1 { font-size: 19px; font-weight: 700; }
#inputPanel .sub { color: var(--ink-2); font-size: 12.5px; margin: 6px 0 14px; }
#cronInput {
  width: 100%; height: min(46vh, 380px); resize: vertical;
  border: 1px solid var(--border); border-radius: 10px;
  background: var(--page); color: var(--ink);
  font: 12px/1.55 ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  padding: 12px; outline: none; white-space: pre; overflow-wrap: normal; overflow-x: auto;
}
#cronInput:focus { border-color: var(--accent); }
#cronInput::placeholder { color: var(--muted); }
.input-error { color: var(--danger); font-size: 12.5px; margin-top: 10px; }
#inputPanel .row { display: flex; align-items: center; gap: 12px; margin-top: 14px; }

/* ── SEO content (cheat sheet + FAQ, shown under the input card) ────────── */
.info-card {
  width: min(760px, 100%); margin: 22px auto 0; color: var(--ink-2);
}
.info-card h2 {
  font-size: 14px; font-weight: 700; color: var(--ink); margin: 22px 0 10px;
}
.info-card h2:first-child { margin-top: 0; }
.info-card > p { font-size: 12.5px; margin-bottom: 10px; }
#cheatTable {
  width: 100%; border-collapse: collapse; font-size: 12.5px;
  border: 1px solid var(--border); border-radius: 10px; overflow: hidden;
}
#cheatTable th, #cheatTable td {
  text-align: left; padding: 7px 10px; border-bottom: 1px solid var(--border);
}
#cheatTable th { color: var(--muted); font-weight: 600; background: var(--wash); }
#cheatTable tr:last-child td { border-bottom: 0; }
#cheatTable code {
  font: 11.5px ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; color: var(--accent);
}
.faq details {
  border: 1px solid var(--border); border-radius: 10px;
  padding: 10px 12px; margin-top: 8px; background: var(--surface);
}
.faq summary {
  font-size: 12.5px; font-weight: 600; color: var(--ink); cursor: pointer;
}
.faq p { font-size: 12.5px; margin-top: 8px; }
.faq code {
  font: 11.5px ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; color: var(--ink-2);
}

/* ── Timeline ───────────────────────────────────────────────────────────── */
#tl { flex: 1; position: relative; min-height: 0; background: var(--surface); }
body.mode-input #tl, body.mode-input #statusbar { display: none; }
#cv { display: block; width: 100%; height: 100%; touch-action: none; }

.tooltip {
  position: absolute; z-index: 40; pointer-events: none;
  max-width: 400px;
  background: var(--surface); border: 1px solid var(--border); border-radius: 9px;
  box-shadow: var(--shadow); padding: 8px 11px; font-size: 12px;
}
.tooltip .tt-time { font-weight: 700; font-variant-numeric: tabular-nums; }
.tooltip .tt-cmd {
  font: 11.5px ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  color: var(--ink-2); margin-top: 4px; overflow-wrap: anywhere;
}
.tooltip .tt-meta { color: var(--muted); margin-top: 4px; font-size: 11.5px; }

/* ── Status bar ─────────────────────────────────────────────────────────── */
#statusbar {
  display: flex; align-items: center; justify-content: space-between; gap: 16px;
  min-height: 30px; padding: 4px 16px;
  border-top: 1px solid var(--border); background: var(--page);
  font-size: 11.5px; color: var(--muted);
}
#stats { display: flex; gap: 6px; align-items: center; white-space: nowrap; }
#stats .sk-toggle { border: 0; background: none; color: var(--danger); font-size: 11.5px; padding: 0; }
#stats .sk-toggle:hover { text-decoration: underline; }
@media (max-width: 760px) { #statusbar .hint { display: none; } }
