/*
 * Kipinä theme: a warm campfire / scout look on top of Pico.css.
 * Light theme = canvas tent by day, dark theme = campfire at night.
 * Keep this file small and readable; no build step.
 */

:root {
  --kipina-forest: #2f5d3a;
  --kipina-forest-dark: #234a2d;
  --kipina-ember: #d9622b;
  --kipina-ember-soft: #f3d9c6;
  --kipina-gold: #f8c537;
  --kipina-bark: #6b4428;
  --kipina-canvas: #fbf6ec;
  --kipina-canvas-deep: #f2e8d5;
  --kipina-ink: #2b2a26;
}

:root:not([data-theme="dark"]),
[data-theme="light"] {
  --pico-font-family-sans-serif: ui-rounded, "Nunito", "Segoe UI", system-ui, -apple-system, "Helvetica Neue", Arial, sans-serif;
  --pico-border-radius: 0.75rem;
  --pico-background-color: var(--kipina-canvas);
  --pico-color: var(--kipina-ink);
  --pico-muted-color: #6f675b;
  --pico-muted-border-color: #e3d6bf;
  --pico-card-background-color: #fffdf8;
  --pico-card-sectioning-background-color: var(--kipina-canvas-deep);
  --pico-card-box-shadow: 0 1px 0 #e3d6bf, 0 6px 18px rgba(107, 68, 40, 0.08);
  --pico-primary: var(--kipina-forest);
  --pico-primary-background: var(--kipina-forest);
  --pico-primary-border: var(--kipina-forest);
  --pico-primary-underline: rgba(47, 93, 58, 0.5);
  --pico-primary-hover: var(--kipina-forest-dark);
  --pico-primary-hover-background: var(--kipina-forest-dark);
  --pico-primary-hover-border: var(--kipina-forest-dark);
  --pico-primary-focus: rgba(47, 93, 58, 0.3);
  --pico-primary-inverse: #fff;
  --pico-form-element-background-color: #fffdf8;
  --pico-form-element-border-color: #d8c8ab;
  --pico-form-element-focus-color: var(--kipina-ember);
  --pico-table-border-color: #e9dcc5;
  --kipina-header-bg: var(--kipina-forest);
  --kipina-header-fg: #fdf7ea;
}

@media only screen and (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --pico-background-color: #1b211d;
    --pico-color: #efe6d4;
    --pico-muted-color: #b2a68f;
    --pico-muted-border-color: #39433b;
    --pico-card-background-color: #232b25;
    --pico-card-sectioning-background-color: #2a332c;
    --pico-card-box-shadow: 0 6px 18px rgba(0, 0, 0, 0.35);
    --pico-primary: #e8894f;
    --pico-primary-background: #c7552a;
    --pico-primary-border: #c7552a;
    --pico-primary-underline: rgba(232, 137, 79, 0.5);
    --pico-primary-hover: #f0a374;
    --pico-primary-hover-background: #b04a22;
    --pico-primary-hover-border: #b04a22;
    --pico-primary-focus: rgba(232, 137, 79, 0.35);
    --pico-primary-inverse: #fff;
    --pico-form-element-background-color: #1f2621;
    --pico-form-element-border-color: #445046;
    --pico-table-border-color: #39433b;
    --kipina-header-bg: #141a16;
    --kipina-header-fg: #efe6d4;
  }
}

/* Dark theme chosen with the theme switch (overrides the system setting). */
:root[data-theme="dark"] {
  --pico-background-color: #1b211d;
  --pico-color: #efe6d4;
  --pico-muted-color: #b2a68f;
  --pico-muted-border-color: #39433b;
  --pico-card-background-color: #232b25;
  --pico-card-sectioning-background-color: #2a332c;
  --pico-card-box-shadow: 0 6px 18px rgba(0, 0, 0, 0.35);
  --pico-primary: #e8894f;
  --pico-primary-background: #c7552a;
  --pico-primary-border: #c7552a;
  --pico-primary-underline: rgba(232, 137, 79, 0.5);
  --pico-primary-hover: #f0a374;
  --pico-primary-hover-background: #b04a22;
  --pico-primary-hover-border: #b04a22;
  --pico-primary-focus: rgba(232, 137, 79, 0.35);
  --pico-primary-inverse: #fff;
  --pico-form-element-background-color: #1f2621;
  --pico-form-element-border-color: #445046;
  --pico-table-border-color: #39433b;
  --kipina-header-bg: #141a16;
  --kipina-header-fg: #efe6d4;
}

body {
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}
main { flex: 1; }

/* --- Header: a forest-green band with the campfire logo --- */
.site-header {
  background: var(--kipina-header-bg);
  color: var(--kipina-header-fg);
  padding-block: 0;
  box-shadow: 0 3px 0 var(--kipina-ember);
  margin-bottom: 2rem;
}
.site-header nav a,
.site-header nav summary,
.site-header nav .muted { color: var(--kipina-header-fg); }
.site-header nav a:hover { color: var(--kipina-gold); }
.site-header .brand {
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
  font-size: 1.35rem;
  font-weight: 800;
  letter-spacing: 0.02em;
  text-decoration: none;
}
.site-header .brand img { width: 2.2rem; height: 2.2rem; }
.site-header .crumb::before { content: "›"; margin-right: 0.75rem; opacity: 0.6; }
.site-header button.link {
  background: none; border: none; color: var(--kipina-header-fg);
  padding: 0; margin: 0; text-decoration: underline; cursor: pointer;
}
.site-header select { margin: 0; padding-block: 0.25rem; width: auto; font-size: 0.875rem; }

/* --- Footer: treeline silhouette --- */
.site-footer {
  margin-top: 3rem;
  padding: 3.5rem 0 1rem;
  color: var(--pico-muted-color);
  font-size: 0.85rem;
  background:
    url("../img/treeline.1b1f4b977f5e.svg") repeat-x top / auto 3rem;
}

/* --- Help: "?" button + side panel --- */
.help-button {
  display: inline-flex; align-items: center; gap: 0.35rem;
  text-decoration: none;
}
.help-button span {
  display: inline-grid; place-items: center;
  width: 1.6rem; height: 1.6rem; border-radius: 50%;
  background: var(--kipina-gold); color: var(--kipina-ink); font-weight: 800;
}
.help-panel {
  position: fixed; inset: 0 0 0 auto; z-index: 50;
  width: min(30rem, 100vw); overflow-y: auto;
  padding: 1.5rem; background: var(--pico-card-background-color);
  border-left: 4px solid var(--kipina-ember);
  box-shadow: -10px 0 30px rgba(0, 0, 0, 0.18);
}
.help-panel[hidden] { display: none; }
.help-panel .close { float: right; margin: 0; padding: 0.25rem 0.75rem; }
.help-body h2 { font-size: 1.3rem; }
.help-body h3 { font-size: 1.05rem; margin-top: 1.25rem; }
.help-topics { columns: 2 12rem; }
kbd { background: var(--kipina-canvas-deep); color: var(--kipina-ink); }

/* --- Bits and pieces --- */
.narrow { max-width: 34rem; }
.muted { color: var(--pico-muted-color); }
form.inline { display: inline; margin: 0; }
form.inline button, form.inline select { margin: 0; padding: 0.25rem 0.75rem; width: auto; display: inline-block; }

.messages { margin-bottom: 1.5rem; }
.message {
  padding: 0.75rem 1rem; margin-bottom: 0.5rem;
  border-radius: var(--pico-border-radius);
  background: var(--pico-card-background-color);
  border-left: 5px solid var(--pico-primary);
}
.message-error { border-left-color: #b91c1c; }
.message-success { border-left-color: #3f8f4f; }
.message-warning { border-left-color: var(--kipina-gold); }
small.message-error { color: #b91c1c; }

.secret {
  font-family: var(--pico-font-family-monospace);
  font-size: 1.75rem; letter-spacing: 0.12em;
  user-select: all;
}
.secret-url { font-family: var(--pico-font-family-monospace); word-break: break-all; user-select: all; }

/* "Badge" for roles, like a scout patch */
.badge {
  display: inline-block; padding: 0.1rem 0.6rem; border-radius: 999px;
  font-size: 0.8rem; font-weight: 700;
  background: var(--kipina-ember-soft); color: var(--kipina-bark);
  border: 1px dashed var(--kipina-bark);
}

.card-grid { display: grid; gap: 1rem; grid-template-columns: repeat(auto-fill, minmax(15rem, 1fr)); }
.card-grid article { margin: 0; }
.card-grid a.card { text-decoration: none; color: inherit; display: block; height: 100%; }
.card-grid a.card article { height: 100%; transition: transform 0.1s; }
.card-grid a.card:hover article { transform: translateY(-2px); border-color: var(--kipina-ember); }

.empty-state { text-align: center; padding: 2rem 1rem; }
.empty-state img { width: 4rem; opacity: 0.85; }

@media print {
  .site-header, .site-footer, .help-panel, form, .messages { display: none !important; }
  body { background: #fff; color: #000; }
}

/* --- Quick jump (Ctrl+K) --- */
.jump-dialog[open] {
  /* Undo Pico's full-screen modal layout */
  display: block; position: fixed; inset: 10vh auto auto 50%; transform: translateX(-50%);
  width: min(36rem, 94vw); min-width: 0; height: auto; min-height: 0; max-height: 80vh;
  padding: 1rem; margin: 0;
  border: 3px solid var(--kipina-ember); border-radius: var(--pico-border-radius);
  background: var(--pico-card-background-color); color: var(--pico-color);
  box-shadow: 0 20px 50px rgba(0, 0, 0, 0.3);
}
.jump-dialog input { margin-bottom: 0.5rem; }
.jump-dialog::backdrop { background: rgba(20, 26, 22, 0.45); }
.jump-dialog ul { list-style: none; padding: 0; margin: 0 0 0.5rem; max-height: 50vh; overflow-y: auto; }
.jump-dialog li { display: flex; justify-content: space-between; gap: 1rem; padding: 0.4rem 0.75rem; border-radius: 0.5rem; margin: 0; }
.jump-dialog li[aria-selected="true"] { background: var(--kipina-ember-soft); }
.jump-dialog li[aria-selected="true"] a { color: var(--kipina-bark); font-weight: 700; }
.jump-dialog li small { color: var(--pico-muted-color); white-space: nowrap; }
.jump-dialog li a { text-decoration: none; }
.site-header kbd { font-size: 0.7rem; padding: 0.1rem 0.35rem; }

/* --- Entry grids (table[data-grid]) --- */
table[data-grid] td { padding: 0; border: 1px solid var(--pico-table-border-color); }
table[data-grid] td > input, table[data-grid] td > select {
  margin: 0; border-radius: 0; border-color: transparent; background: transparent;
  height: auto; padding: 0.4rem 0.5rem; text-align: right; font-variant-numeric: tabular-nums;
}
table[data-grid] td > input:focus, table[data-grid] td > select:focus {
  outline: 2px solid var(--kipina-ember); outline-offset: -2px; box-shadow: none;
  background: var(--pico-form-element-background-color);
}
table[data-grid] td.grid-editing > input { outline-style: dashed; }
table[data-grid] tr.grid-row-active > *,
table[data-grid] .grid-col-active { background-color: rgba(248, 197, 55, 0.14); }
table[data-grid] thead th { position: sticky; top: 0; background: var(--pico-card-sectioning-background-color); z-index: 1; }

/* --- Results --- */
.series-tabs { display: flex; flex-wrap: wrap; justify-content: space-between; gap: 0.5rem; margin-bottom: 1rem; border-bottom: 2px solid var(--pico-muted-border-color); }
.series-tabs ul { margin: 0; padding: 0; flex-wrap: wrap; }
.series-tabs li { padding: 0.25rem 0.5rem; }
.series-tabs a[aria-current="page"] { font-weight: 800; color: var(--kipina-ember); text-decoration: underline 3px; text-underline-offset: 0.4rem; }
.table-scroll { overflow-x: auto; }
table.results { font-variant-numeric: tabular-nums; font-size: 0.92rem; }
table.results th, table.results td { padding: 0.35rem 0.5rem; white-space: nowrap; }
table.results thead th { position: sticky; top: 0; background: var(--pico-card-sectioning-background-color); vertical-align: bottom; }
table.results .num { text-align: right; }
table.results .total { font-weight: 800; }
table.results tbody th { font-weight: 600; }
table.results .patrol-number { display: inline-block; min-width: 2.5em; color: var(--pico-muted-color); }
table.results tr.group-heading th { background: var(--kipina-canvas-deep); color: var(--kipina-ink); font-weight: 700; }
.tie { color: var(--kipina-ember); font-weight: 800; margin-right: 0.15rem; }
.marker { color: var(--pico-muted-color); }
.cell-error { color: #b91c1c; font-weight: 700; }
.over-max { color: #b45309; }
details.task { border-bottom: 1px solid var(--pico-muted-border-color); padding: 0.5rem 0; }
code.formula { white-space: pre-wrap; word-break: break-all; font-size: 0.8rem; }
@media print {
  .series-tabs, .legend { display: none !important; }
  table.results { font-size: 9pt; }
  table.results thead th { position: static; }
}
/* Wide tables use the whole window width, not just the content column. */
.wide { width: calc(100vw - 2rem); max-width: none; position: relative; left: 50%; transform: translateX(-50%); }
table.results tbody th { position: sticky; left: 0; background: var(--pico-background-color); z-index: 1; }
table.results tbody th small { font-weight: 400; }
table.results td.total { border-right: 2px solid var(--pico-muted-border-color); }

/* --- Result entry --- */
.entry-tools { display: flex; flex-wrap: wrap; justify-content: space-between; border-bottom: 2px solid var(--pico-muted-border-color); margin-bottom: 1rem; }
.entry-tools ul { margin: 0; flex-wrap: wrap; }
.entry-grid { width: auto; }
.entry-grid td > input { min-width: 6.5rem; }
.entry-grid tbody th { white-space: nowrap; font-weight: 600; }
.entry-grid .score { font-weight: 800; min-width: 4rem; }
.entry-grid td.cell-invalid > input, .entry-grid td.cell-conflict > input { background: #fde2e1; color: #7f1d1d; }
.entry-grid td.cell-mismatch > input { background: #fff3c4; color: #5c4400; }
.entry-grid td.cell-saved > input { animation: kipina-saved 1.2s ease-out; }
@keyframes kipina-saved { from { background: rgba(63, 143, 79, 0.35); } to { background: transparent; } }
.entry-status { min-height: 1.5em; font-size: 0.9rem; color: var(--pico-muted-color); }
.entry-status-error { color: #b91c1c; font-weight: 600; }
.badge-ok { background: #d9f0dc; color: #1f5f2c; border-color: #1f5f2c; }
.badge-warn { background: #fff3c4; color: #5c4400; border-color: #8a6a00; }
table.entry-index progress { width: 6rem; margin: 0 0.5rem 0 0; vertical-align: middle; }
#id_tasks { max-height: 16rem; overflow-y: auto; border: 1px solid var(--pico-form-element-border-color); border-radius: var(--pico-border-radius); padding: 0.5rem 0.75rem; margin-bottom: 0.5rem; }
#id_tasks label { font-weight: 400; }

/* Links inside result tables look like the table, not like buttons. */
table.results thead th a, table.results tbody th a { color: inherit; text-decoration: none; }
table.results thead th a:hover, table.results tbody th a:hover,
table.results thead th a:focus-visible, table.results tbody th a:focus-visible { text-decoration: underline; color: var(--pico-primary); }
.screen-links { margin: -0.5rem 0 0.5rem; text-align: right; }
@media print { .screen-links { display: none; } }

/* Progress of result entry */
table.progress td { vertical-align: top; }
table.progress .task-status { display: block; padding: 0.3rem 0.5rem; border-radius: 0.4rem; text-decoration: none; color: var(--kipina-ink, inherit); border-left: 0.35rem solid transparent; }
table.progress .task-status small { display: block; opacity: 0.8; }
.status-not-started { background: var(--pico-card-sectioning-background-color); border-left-color: #b9b2a3 !important; }
.status-partial { background: #fdf0d2; border-left-color: #e0a526 !important; }
.status-entered { background: #dcebf7; border-left-color: #3d7fb8 !important; }
.status-checked { background: #dcefd9; border-left-color: #3e8a3a !important; }
.status-error { background: #f8d9d4; border-left-color: #c2412d !important; }
.progress-legend span { display: inline-block; padding: 0.1rem 0.5rem; margin: 0 0.3rem 0.3rem 0; border-radius: 0.3rem; border-left: 0.35rem solid transparent; color: #2b2a26; }
table.progress .task-status { color: #2b2a26; }
table.progress tfoot td { font-weight: 700; }
.input-value.mismatch { background: #fff3c4; color: #5c4400; padding: 0 0.2rem; border-radius: 0.2rem; }
.patrol-summary strong { font-size: 1.2em; }
table.results td.input-values { white-space: normal; min-width: 20rem; }

/* Task editor */
.visually-hidden { position: absolute !important; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; border: 0; padding: 0; }
.task-fields { display: grid; grid-template-columns: repeat(auto-fit, minmax(14rem, 1fr)); gap: 0 1rem; }
fieldset.subtask { border: 1px solid var(--pico-muted-border-color); border-left: 0.35rem solid var(--kipina-ember, #e07a1f); border-radius: 0.5rem; padding: 0.75rem 1rem; margin: 1rem 0; }
fieldset.subtask > legend { font-weight: 800; padding: 0 0.4rem; }
fieldset.subtask table.inputs td, fieldset.subtask table.inputs th { padding: 0.2rem 0.4rem; }
fieldset.subtask table.inputs input, fieldset.subtask table.inputs select { margin: 0; }
.points-rule { display: grid; grid-template-columns: repeat(auto-fit, minmax(16rem, 1fr)); gap: 0 1.5rem; }
.points-rule fieldset { margin-bottom: 0.4rem; }
.points-rule fieldset label { display: block; }
textarea.formula, pre.formula { font-family: ui-monospace, monospace; font-size: 0.9rem; }
pre.formula { white-space: pre-wrap; word-break: break-all; }
button.small { padding: 0.2rem 0.6rem; font-size: 0.85rem; width: auto; }
.task-editor .actions { display: flex; flex-wrap: wrap; gap: 0.75rem; align-items: center; }
.task-editor .actions button { width: auto; margin: 0; }
table.results tr.changed td { background: #fff3c4; color: #5c4400; }
[hidden] { display: none !important; }

/* Test patrols */
.badge-error { background: #f8d9d4; color: #7a1f12; border-color: #c2412d; }
button.link { background: none; border: none; padding: 0 0.3rem; color: var(--pico-primary); cursor: pointer; width: auto; margin: 0; }
button.link.danger { color: #b3361f; font-size: 1.2rem; line-height: 1; }
.trial-grid th[scope=row] input { min-width: 10rem; font-weight: 600; }
.trial-check { text-align: center; }
form.inline { display: flex; gap: 1rem; align-items: center; flex-wrap: wrap; }
form.inline button { width: auto; margin: 0; }
table.trial-matrix td.fail { background: #f8d9d4; }
table.trial-matrix td.pass { background: #dcefd9; }
.trials { margin-top: 2.5rem; }

/* Text size: Pico grows the root font up to 131% on wide screens, which is
   too big on laptops (the results office). Keep it at the browser default;
   users can still zoom. */
:root { --pico-font-size: 100%; }
@media (min-width: 576px) { :root { --pico-font-size: 100%; } }
@media (min-width: 768px) { :root { --pico-font-size: 100%; } }
@media (min-width: 1024px) { :root { --pico-font-size: 100%; } }
@media (min-width: 1280px) { :root { --pico-font-size: 100%; } }
@media (min-width: 1536px) { :root { --pico-font-size: 100%; } }

/* Theme switch */
.entry-grid td.num { text-align: right; padding: 0 0.6rem; }
.entry-grid td.cell-dropped > input { color: var(--pico-muted-color); font-style: italic; background: var(--pico-card-sectioning-background-color); }
.jury-grid td > input { min-width: 4.5rem; } .jury-grid td.jury-set > input { background: #fff3c4; color: #5c4400; font-weight: 700; }

/* Calculation trace */
.trace-form select { width: auto; margin: 0; }
.trace-result { font-size: 1.15rem; }
ol.trace-steps { list-style: none; padding: 0; font-size: 0.85rem; }
ol.trace-steps li { margin: 0.15rem 0 0.15rem calc(var(--depth, 0) * 1.25rem); padding: 0.2rem 0.5rem; border-left: 3px solid var(--pico-muted-border-color); word-break: break-word; }
ol.trace-steps li.trace-error { border-left-color: #c2412d; background: #f8d9d4; color: #7a1f12; }
ul.trace-params { font-size: 0.85rem; columns: 2 18rem; }

/* Formula highlighting (static/js/formula.js): bracket pairs by depth. */
:root {
  --f-d0: light-dark(#1c64c4, #79b0ff);
  --f-d1: light-dark(#a3168a, #f28bd3);
  --f-d2: light-dark(#23803a, #74d38e);
  --f-d3: light-dark(#c2410c, #ffa066);
  --f-d4: light-dark(#6d3fd6, #b9a1ff);
  --f-d5: light-dark(#0e7490, #5fd4e8);
  --f-bad: light-dark(#c92a2a, #ff8787);
  --f-match: light-dark(#f3d9c6, #4a3a2c);
}
.formula .f-d0, .formula-hl .f-d0 { color: var(--f-d0); }
.formula .f-d1, .formula-hl .f-d1 { color: var(--f-d1); }
.formula .f-d2, .formula-hl .f-d2 { color: var(--f-d2); }
.formula .f-d3, .formula-hl .f-d3 { color: var(--f-d3); }
.formula .f-d4, .formula-hl .f-d4 { color: var(--f-d4); }
.formula .f-d5, .formula-hl .f-d5 { color: var(--f-d5); }
.f-b { font-weight: 700; }
.f-var { font-weight: 700; }
.f-param { font-style: italic; }
.f-bad { color: var(--f-bad); font-weight: 700; text-decoration: underline wavy var(--f-bad); }
.f-match { background: var(--f-match); border-radius: 2px; outline: 1px solid currentColor; }
.formula-edit { position: relative; }
.formula-edit > .formula-hl {
  position: absolute; top: 0; left: 0; margin: 0; overflow: hidden; pointer-events: none;
  border-style: solid; border-color: transparent; box-sizing: border-box;
  background: var(--pico-form-element-background-color); color: var(--pico-color);
  white-space: pre-wrap; word-break: break-all;
}
.formula-edit.formula-single > .formula-hl { white-space: pre; word-break: normal; }
.formula-edit > .formula-field {
  position: relative; background: transparent; color: transparent;
  caret-color: var(--pico-color); word-break: break-all;
}
.formula-edit > .formula-field:focus { background: transparent; }
.formula-edit > .formula-field::placeholder { color: var(--pico-muted-color); }

/* --- Checkpoints and the route planner (checkpoint_views.py, plan.js) */
.cp-number {
  display: inline-flex; align-items: center; justify-content: center;
  min-width: 1.6em; height: 1.6em; padding: 0 0.3em; border-radius: 0.4em;
  background: var(--kipina-forest); color: #fff; font-weight: 700; font-size: 0.85em;
}
.task-status form.message { display: flex; flex-wrap: wrap; gap: 0.5rem; align-items: center; }
.task-status form.message button, .task-status form.message [role=button] { margin: 0; }
.plan-board { position: relative; }
/* the board uses the whole window width: many series side by side */
@media (min-width: 60rem) {
  .plan-board { width: calc(100vw - 3rem); margin-left: calc(50% - 50vw + 1.5rem); }
}
.plan-board.plan-saving { opacity: 0.7; pointer-events: none; }
.plan-grid {
  display: grid; grid-auto-flow: column; grid-auto-columns: minmax(12rem, 1fr);
  gap: 0.6rem; overflow-x: auto; padding-bottom: 0.75rem; align-items: start;
}
.plan-column {
  background: var(--pico-card-background-color); border: 1px solid var(--pico-muted-border-color);
  border-radius: var(--pico-border-radius); padding: 0.5rem; min-width: 0;
}
.plan-palette { background: var(--pico-card-sectioning-background-color); }
@media (min-width: 40rem) { .plan-palette { position: sticky; left: 0; z-index: 1; } }
.plan-column h2 { font-size: 1rem; margin: 0 0 0.5rem; }
.plan-list { list-style: none; margin: 0; padding: 0; min-height: 2.5rem; }
.plan-list:empty { border: 2px dashed var(--pico-muted-border-color); border-radius: var(--pico-border-radius); }
.plan-card {
  list-style: none; display: grid; grid-template-columns: auto minmax(0, 1fr) auto; gap: 0 0.35rem;
  position: relative;
  align-items: center; padding: 0.25rem 0.4rem; margin: 0 0 0.3rem;
  border-radius: var(--pico-border-radius); background: var(--pico-background-color);
  border: 1px solid var(--pico-muted-border-color); font-size: 0.9rem; line-height: 1.3;
}
.plan-draggable .plan-card { cursor: grab; }
.plan-card .plan-name { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.plan-card .task-number { font-weight: 700; min-width: 1.4em; }
.plan-marks { display: inline-flex; gap: 0.25rem; align-items: center; }
.plan-marks .badge { padding: 0 0.35rem; font-size: 0.7rem; font-weight: 600; }
.plan-card.plan-own { border-style: dashed; }
.plan-card-hidden { opacity: 0.6; border-style: dotted; }
.plan-results { color: var(--kipina-ember); font-size: 0.8rem; }
.plan-own-scoring { font-weight: 700; color: var(--kipina-ember); }
.plan-buttons { grid-column: 1 / -1; justify-self: end; display: inline-flex; margin: 0; gap: 0; }
.plan-buttons button.link { padding: 0 0.25rem; font-size: 1rem; line-height: 1.2; }
.plan-buttons button.link:disabled { opacity: 0.3; cursor: default; }
/* with a mouse the buttons appear on hover or keyboard focus; touch screens always show them */
@media (hover: hover) {
  [data-series] > .plan-card:not(:hover):not(:focus-within) .plan-buttons {
    position: absolute; width: 1px; height: 1px; overflow: hidden; clip-path: inset(50%);
  }
}
.plan-add { display: flex; gap: 0.3rem; margin: 0.5rem 0 0; }
.plan-add select { margin: 0; padding-block: 0.2rem; font-size: 0.85rem; height: auto; }
.plan-add button { margin: 0; }
.plan-hint { margin: 0.5rem 0 0; }
.plan-ghost { opacity: 0.4; border-style: dashed; border-color: var(--kipina-ember); }
.plan-chosen { box-shadow: 0 2px 8px rgb(0 0 0 / 0.25); }
.plan-usage { white-space: nowrap; }

/* --- Seasons (data-season on <html>, KIPINA_SEASON): header colours and
   decoration in both themes; the logo changes with them (img/kipina-*.svg). */
[data-season] .site-header { background-color: var(--kipina-header-bg); }
:root[data-season="summer"] {
  --kipina-header-bg: light-dark(#2f7a3a, #10261a);
  --kipina-season-accent: #f8c537;
}
[data-season="summer"] .site-header {
  background-image: radial-gradient(circle at 94% -30%, rgba(248, 197, 55, 0.6), rgba(248, 197, 55, 0.15) 5rem, transparent 9rem);
}
:root[data-season="winter"] {
  --kipina-header-bg: light-dark(#2d4f6a, #0f1a26);
  --kipina-season-accent: #9cc3e6;
}
[data-season="winter"] .site-header {
  background-image: url("../img/snow.3d12fe8e7e2f.svg");
  background-size: 240px 64px;
}
:root[data-season="autumn"] {
  --kipina-header-bg: light-dark(#7a3b1c, #24130b);
  --kipina-season-accent: #e0a020;
}
[data-season="autumn"] .site-header {
  background-image: linear-gradient(100deg, transparent 55%, rgba(224, 160, 32, 0.18) 75%, rgba(200, 64, 42, 0.25));
}
:root[data-season="spring"] {
  --kipina-header-bg: light-dark(#3f7d34, #132317);
  --kipina-season-accent: #f2a7c3;
}
[data-season="spring"] .site-header {
  background-image: url("../img/petals.9bcf93200393.svg");
  background-size: 300px 64px;
}
[data-season] .site-header { box-shadow: 0 3px 0 var(--kipina-season-accent); }
[data-season="winter"] .site-footer {
  background:
    linear-gradient(transparent 2.6rem, light-dark(#ffffff, #c9d8e6) 2.6rem, transparent 3.1rem) top / 100% 3rem no-repeat,
    url("../img/treeline.1b1f4b977f5e.svg") repeat-x top / auto 3rem;
}

/* --- Header icons (static/img/icons.svg, {% icon %}) --- */
.icon { width: 1.15em; height: 1.15em; flex: none; vertical-align: -0.2em; }
.site-header nav a, .site-header nav button.link { display: inline-flex; align-items: center; gap: 0.35rem; }
.site-header nav button.link { text-decoration: none; }
.site-header .help-button span { color: var(--kipina-ink); }
/* Narrow screens: icons only; labels stay for screen readers. */
@media (max-width: 60rem) {
  .site-header .nav-label {
    position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0);
    white-space: nowrap;
  }
  .site-header kbd { display: none; }
  .site-header .icon { width: 1.4em; height: 1.4em; }
}
.site-header form.inline button.link { padding: 0; line-height: inherit; }
.site-header .crumb a { white-space: nowrap; }

/* Light/dark toggle: the knob sits on the mode in use. Positioned by CSS
   (data-theme or the system setting), so it is right before JS runs. */
.theme-toggle {
  background: none; border: none; padding: 0; margin: 0; cursor: pointer;
  color: var(--kipina-header-fg); display: inline-flex;
}
.theme-track {
  position: relative; display: inline-flex; align-items: center; justify-content: space-between;
  width: 3.3rem; height: 1.7rem; padding: 0 0.3rem; border-radius: 1rem;
  background: rgba(0, 0, 0, 0.22); border: 1px solid rgba(255, 255, 255, 0.35);
}
.theme-track .icon { position: relative; z-index: 1; width: 1rem; height: 1rem; transition: color 0.2s; }
.theme-knob {
  position: absolute; top: 0.12rem; left: 0.12rem; width: 1.35rem; height: 1.35rem;
  border-radius: 50%; background: var(--kipina-gold); transition: transform 0.2s;
}
.theme-track .icon:first-child { color: var(--kipina-ink); }
:root[data-theme="dark"] .theme-knob { transform: translateX(1.6rem); }
:root[data-theme="dark"] .theme-track .icon:first-child { color: inherit; }
:root[data-theme="dark"] .theme-track .icon:nth-child(2) { color: var(--kipina-ink); }
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) .theme-knob { transform: translateX(1.6rem); }
  :root:not([data-theme="light"]) .theme-track .icon:first-child { color: inherit; }
  :root:not([data-theme="light"]) .theme-track .icon:nth-child(2) { color: var(--kipina-ink); }
}
.theme-toggle:focus-visible .theme-track { outline: 2px solid var(--kipina-gold); outline-offset: 2px; }
@media (prefers-reduced-motion: reduce) { .theme-knob, .theme-track .icon { transition: none; } }
@media (max-width: 60rem) {
  .site-header nav { flex-wrap: wrap; }
}
.site-header nav li { display: inline-flex; align-items: center; }
/* Action link rows (e.g. the competition page) wrap on narrow screens. */
nav.actions-bar, nav.actions-bar ul { flex-wrap: wrap; }
