:root {
    --bg: #f6f7f9;      --panel: #ffffff;   --ink: #14181f;
    --muted: #5f6b7a;   --line: #e2e6ec;    --accent: #1f6feb;
    --ok: #12805c;      --warn: #a05e03;    --bad: #b42318;
    --chip: #eef1f5;    --shadow: 0 1px 2px rgba(20,24,31,.06), 0 4px 12px rgba(20,24,31,.05);
  }
  @media (prefers-color-scheme: dark) {
    :root:not([data-theme="light"]) {
      --bg: #0f1216;    --panel: #161b22;   --ink: #e6edf3;
      --muted: #94a3b5;  --line: #262d38;   --accent: #4f9dff;
      --ok: #3fb98c;    --warn: #d99b3a;    --bad: #f2705c;
      --chip: #1e242d;  --shadow: 0 1px 2px rgba(0,0,0,.4), 0 4px 14px rgba(0,0,0,.3);
    }
  }
  * { box-sizing: border-box; }
  body {
    margin: 0; background: var(--bg); color: var(--ink);
    font: 15px/1.5 ui-sans-serif, -apple-system, "Segoe UI", Roboto, sans-serif;
  }
  .wrap { max-width: 1180px; margin: 0 auto; padding: 28px 20px 64px; }
  header { display: flex; align-items: baseline; gap: 14px; flex-wrap: wrap; margin-bottom: 6px; }
  h1 { font-size: 21px; margin: 0; letter-spacing: -.01em; }
  .sub { color: var(--muted); font-size: 13px; }
  .grid { display: grid; grid-template-columns: 380px 1fr; gap: 20px; margin-top: 22px; }
  @media (max-width: 900px) { .grid { grid-template-columns: 1fr; } }
  .card {
    background: var(--panel); border: 1px solid var(--line);
    border-radius: 12px; padding: 18px; box-shadow: var(--shadow); margin-bottom: 20px;
  }
  .card h2 {
    font-size: 12px; text-transform: uppercase; letter-spacing: .07em;
    color: var(--muted); margin: 0 0 14px; font-weight: 600;
  }
  label { display: block; font-size: 12px; color: var(--muted); margin: 12px 0 5px; font-weight: 500; }
  input, select {
    width: 100%; padding: 9px 11px; font: inherit; font-size: 14px;
    background: var(--bg); color: var(--ink);
    border: 1px solid var(--line); border-radius: 8px;
  }
  input:focus, select:focus { outline: 2px solid var(--accent); outline-offset: -1px; border-color: transparent; }
  .row { display: flex; gap: 10px; }
  .row > * { flex: 1; min-width: 0; }
  button {
    font: inherit; font-size: 14px; font-weight: 550; cursor: pointer;
    padding: 9px 14px; border-radius: 8px; border: 1px solid var(--line);
    background: var(--panel); color: var(--ink); transition: .12s;
  }
  button:hover { border-color: var(--accent); color: var(--accent); }
  button.primary { background: var(--accent); border-color: var(--accent); color: #fff; }
  button.primary:hover { filter: brightness(1.08); color: #fff; }
  button.ghost { padding: 5px 9px; font-size: 12px; font-weight: 500; }
  .btnrow { display: flex; gap: 9px; margin-top: 18px; }
  #map { height: 260px; border-radius: 9px; border: 1px solid var(--line); margin-top: 10px; background: var(--chip); }
  .hint { font-size: 12px; color: var(--muted); margin-top: 8px; }
  .banner {
    display: flex; gap: 12px; align-items: flex-start; padding: 13px 15px;
    border-radius: 10px; font-size: 13.5px; margin-bottom: 18px; border: 1px solid;
  }
  .banner.ok   { background: color-mix(in srgb, var(--ok) 10%, transparent);   border-color: color-mix(in srgb, var(--ok) 32%, transparent); }
  .banner.warn { background: color-mix(in srgb, var(--warn) 12%, transparent); border-color: color-mix(in srgb, var(--warn) 36%, transparent); }
  .banner.bad  { background: color-mix(in srgb, var(--bad) 10%, transparent);  border-color: color-mix(in srgb, var(--bad) 32%, transparent); }
  .banner > div { flex: 1; min-width: 0; }
  .banner b:first-child { display: block; margin-bottom: 2px; }   /* headline only */
  .banner code { background: var(--chip); padding: 1px 6px; border-radius: 5px; font-size: 12.5px; }
  ul.rules, ul.log { list-style: none; margin: 0; padding: 0; }
  ul.rules li {
    display: flex; align-items: center; gap: 11px; padding: 11px 0;
    border-bottom: 1px solid var(--line);
  }
  ul.rules li:last-child { border-bottom: 0; }
  /* Each line carries its own hue in --lh (see lineHue() in common.js); the
     theme only decides how light the fill is. */
  .line-badge {
    display: inline-block; flex: none; min-width: 42px; text-align: center;
    font-weight: 700; font-size: 13px; padding: 4px 7px; border-radius: 7px;
    background: hsl(var(--lh, 214) 60% 42%); color: #fff;
  }
  ul.rules .line-badge { cursor: pointer; }
  .line-badge.sm { min-width: 34px; font-size: 12px; padding: 2px 6px; }
  @media (prefers-color-scheme: dark) {
    :root:not([data-theme="light"]) .line-badge { background: hsl(var(--lh, 214) 60% 52%); }
  }
  .rule-main { flex: 1; min-width: 0; }
  .rule-main .nm { font-weight: 550; }
  .rule-main .meta { font-size: 12px; color: var(--muted); font-variant-numeric: tabular-nums; }
  .off { opacity: .45; }
  table { width: 100%; border-collapse: collapse; font-size: 13.5px; }
  th {
    text-align: left; font-size: 11px; text-transform: uppercase; letter-spacing: .06em;
    color: var(--muted); font-weight: 600; padding: 0 10px 9px 0; border-bottom: 1px solid var(--line);
  }
  td { padding: 9px 10px 9px 0; border-bottom: 1px solid var(--line); font-variant-numeric: tabular-nums; }
  tr:last-child td { border-bottom: 0; }
  .near { color: var(--ok); font-weight: 650; }
  .dot { display: inline-block; width: 7px; height: 7px; border-radius: 50%; margin-right: 7px; }
  .dot.g { background: var(--ok); } .dot.r { background: var(--bad); } .dot.y { background: var(--warn); }
  .empty { color: var(--muted); font-size: 13.5px; padding: 18px 0; text-align: center; }
  ul.log li { padding: 9px 0; border-bottom: 1px solid var(--line); font-size: 13px; }
  ul.log li:last-child { border-bottom: 0; }
  .log .t { color: var(--muted); font-variant-numeric: tabular-nums; margin-right: 8px; }
  .chips { display: flex; flex-wrap: wrap; gap: 5px; margin-top: 9px; max-height: 92px; overflow-y: auto; }
  .chip {
    font-size: 11.5px; padding: 3px 8px; border-radius: 20px; cursor: pointer;
    color: hsl(var(--lh, 214) 60% 34%);
    background: color-mix(in srgb, hsl(var(--lh, 214) 60% 45%) 14%, transparent);
    border: 1px solid color-mix(in srgb, hsl(var(--lh, 214) 60% 45%) 26%, transparent);
  }
  .chip:hover { border-color: hsl(var(--lh, 214) 60% 45%); }
  @media (prefers-color-scheme: dark) {
    :root:not([data-theme="light"]) .chip { color: hsl(var(--lh, 214) 65% 70%); }
  }
  .foot { margin-top: 26px; font-size: 12px; color: var(--muted); }

/* ---- auth pages ---- */
.auth-wrap { max-width: 380px; margin: 0 auto; padding: 76px 20px; }
.auth-card { background: var(--panel); border: 1px solid var(--line); border-radius: 12px; padding: 26px; box-shadow: var(--shadow); }
.auth-card h1 { font-size: 19px; margin: 0 0 4px; }
.auth-card .sub { margin-bottom: 18px; }
.auth-card button { width: 100%; margin-top: 20px; }
.err { background: color-mix(in srgb, var(--bad) 12%, transparent); border: 1px solid color-mix(in srgb, var(--bad) 34%, transparent); color: var(--bad); padding: 10px 12px; border-radius: 8px; font-size: 13px; margin-bottom: 4px; }
.topbar { display: flex; align-items: center; gap: 12px; margin-left: auto; font-size: 13px; color: var(--muted); }
.topbar form { display: inline; }
.topbar button { padding: 5px 10px; font-size: 12px; }
.topbar a { color: var(--accent); text-decoration: none; }
.topbar a:hover { text-decoration: underline; }

/* ---- profile ---- */
.wrap.narrow { max-width: 620px; }
.wrap.narrow .card { margin-top: 20px; }
.ok-text { color: var(--ok); }
ul.windows { list-style: none; margin: 4px 0 18px; padding: 0; }
ul.windows li {
  display: flex; align-items: center; gap: 11px; padding: 11px 0;
  border-bottom: 1px solid var(--line);
}
ul.windows li:last-child { border-bottom: 0; }
.win-main { flex: 1; min-width: 0; }
.win-main .nm { font-weight: 550; font-variant-numeric: tabular-nums; }
.win-main .meta { font-size: 12px; color: var(--muted); }
.days { display: flex; flex-wrap: wrap; gap: 6px; }
.days .day {
  flex: 1; min-width: 46px; padding: 7px 0; font-size: 12.5px; font-weight: 550;
  background: var(--bg); color: var(--muted);
}
.days .day.on { background: var(--accent); border-color: var(--accent); color: #fff; }
.days .day.on:hover { color: #fff; filter: brightness(1.08); }
