/* Layout: kapea työpöytä — kuukausilista vasemmalla ylhäältä alas, treeni avautuu omaksi näkymäkseen (#t-id), jakonäkymä #jaa-id */
:root {
  --bg: #f3f4f6;
  --surface: #ffffff;
  --ink: #16181d;
  --muted: #646a76;
  --line: #dde0e6;
  --accent: #c2412b;      /* tartan */
  --accent-soft: #fbe9e5;
  --ok: #1d7a4a;
  --ok-soft: #e1f3e9;
  --no: #8b3b3b;
  --no-soft: #f4e4e4;
  --comp: #2f4fa8;
  --comp-soft: #e6ecfa;
  --display: "Barlow Condensed", "Arial Narrow", sans-serif;
  --body: "Barlow", system-ui, -apple-system, "Segoe UI", sans-serif;
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #121418; --surface: #1b1e24; --ink: #eceef2; --muted: #9aa1ad; --line: #2c3039;
    --accent: #ec6a50; --accent-soft: #3a211c; --ok: #5cc68c; --ok-soft: #173326;
    --no: #e08b8b; --no-soft: #3a2222; --comp: #8ea8f0; --comp-soft: #1d2643;
    color-scheme: dark;
  }
}
:root[data-theme="dark"] {
  --bg: #121418; --surface: #1b1e24; --ink: #eceef2; --muted: #9aa1ad; --line: #2c3039;
  --accent: #ec6a50; --accent-soft: #3a211c; --ok: #5cc68c; --ok-soft: #173326;
  --no: #e08b8b; --no-soft: #3a2222; --comp: #8ea8f0; --comp-soft: #1d2643;
  color-scheme: dark;
}
* { box-sizing: border-box; }
html, body { margin: 0; }
body { background: var(--bg); color: var(--ink); font: 16px/1.45 var(--body); }
button, input, textarea, select { font: inherit; color: inherit; }
button { cursor: pointer; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
.wrap { max-width: 1040px; margin: 0 auto; padding: 20px 16px 64px; }
h1, h2, h3 { font-family: var(--display); text-wrap: balance; margin: 0; letter-spacing: .01em; }
.top { display: flex; flex-wrap: wrap; align-items: end; justify-content: space-between; gap: 12px; margin-bottom: 18px; }
.top h1 { font-size: 34px; line-height: 1; }
.top .sub { color: var(--muted); font-size: 14px; margin-top: 4px; }
.btn { border: 1px solid var(--line); background: var(--surface); border-radius: 8px; padding: 8px 14px; font-weight: 600; font-size: 14px; display: inline-flex; gap: 6px; align-items: center; }
.btn:hover { border-color: var(--muted); }
.btn.primary { background: var(--accent); border-color: var(--accent); color: #fff; }
.btn.ghost { background: transparent; }
.btn.danger { color: var(--no); }
.row-actions { display: flex; flex-wrap: wrap; gap: 8px; }

/* Lista */
.month { margin-top: 26px; }
.month h2 { font-size: 22px; text-transform: uppercase; color: var(--muted); margin-bottom: 8px; display: flex; gap: 10px; align-items: baseline; }
.month h2 small { font-family: var(--body); text-transform: none; font-size: 13px; font-weight: 500; }
.list { background: var(--surface); border: 1px solid var(--line); border-radius: 12px; overflow: hidden; }
.ev { display: grid; grid-template-columns: 92px 108px 120px 1fr auto; gap: 12px; align-items: center; padding: 10px 14px; border-top: 1px solid var(--line); position: relative; }
.ev:first-child { border-top: 0; }
.ev:hover { background: color-mix(in srgb, var(--bg) 60%, var(--surface)); }
.ev.past { opacity: .55; }
.ev.today::before { content: ""; position: absolute; left: 0; top: 0; bottom: 0; width: 4px; background: var(--accent); }
.ev.kisa { background: var(--comp-soft); }
.ev .date { font-family: var(--display); font-size: 20px; font-weight: 600; font-variant-numeric: tabular-nums; white-space: nowrap; }
.ev .date span { color: var(--muted); font-weight: 500; margin-right: 6px; }
.ev .time { font-variant-numeric: tabular-nums; font-size: 14px; color: var(--muted); }
.ev .place { font-weight: 600; font-size: 14px; }
.ev .theme { min-width: 0; }
.ev .theme a { color: inherit; text-decoration: none; font-weight: 500; display: block; }
.ev .theme a:hover { text-decoration: underline; text-decoration-color: var(--accent); }
.ev .theme .empty { color: var(--muted); font-style: italic; }
.meta { display: flex; gap: 6px; margin-top: 3px; flex-wrap: wrap; }
.pill { font-size: 11px; font-weight: 600; letter-spacing: .04em; text-transform: uppercase; padding: 1px 7px; border-radius: 99px; border: 1px solid var(--line); color: var(--muted); }
.pill.kisa { background: var(--comp); border-color: var(--comp); color: #fff; }
.pill.done { background: var(--ok-soft); border-color: transparent; color: var(--ok); }
.pill.part { background: var(--accent-soft); border-color: transparent; color: var(--accent); }
.coaches { display: flex; gap: 4px; }
.cc { width: 30px; height: 30px; border-radius: 50%; border: 1.5px dashed var(--line); background: transparent; font-size: 12px; font-weight: 600; color: var(--muted); padding: 0; position: relative; }
.cc.paasen { background: var(--ok); border: 1.5px solid var(--ok); color: #fff; }
.cc.estynyt { background: var(--no-soft); border: 1.5px solid var(--no-soft); color: var(--no); text-decoration: line-through; }
.coachhead { display: flex; justify-content: flex-end; gap: 4px; padding: 0 14px 6px; }
.coachhead span { width: 30px; text-align: center; font-size: 11px; color: var(--muted); font-weight: 600; }
.legend { display: flex; gap: 14px; flex-wrap: wrap; font-size: 13px; color: var(--muted); align-items: center; }
.legend .cc { width: 18px; height: 18px; pointer-events: none; }
.legend span { display: inline-flex; gap: 6px; align-items: center; }

@media (max-width: 760px) {
  .ev { grid-template-columns: 1fr auto; grid-template-areas: "date time" "theme theme" "coaches coaches"; row-gap: 4px; }
  .ev .date { grid-area: date; }
  .ev .time { grid-area: time; text-align: right; }
  .ev .place { display: none; }
  .ev .theme { grid-area: theme; }
  .ev .coaches { grid-area: coaches; }
  .ev .time::after { content: attr(data-place); display: block; font-weight: 600; color: var(--ink); }
  .coachhead { display: none; }
  .cc { width: auto; min-width: 30px; border-radius: 99px; padding: 0 8px; }
  .cc .full { display: inline; }
  .cc .ini { display: none; }
}
.cc .full { display: none; }

/* Editori */
.back { color: var(--muted); text-decoration: none; font-size: 14px; font-weight: 600; }
.back:hover { color: var(--ink); }
.ed-head { background: var(--surface); border: 1px solid var(--line); border-radius: 12px; padding: 16px; margin-top: 10px; display: grid; gap: 12px; }
.ed-head.kisa { border-color: var(--comp); box-shadow: inset 4px 0 0 var(--comp); }
.fields { display: flex; flex-wrap: wrap; gap: 10px; }
.field { display: grid; gap: 3px; }
.field label { font-size: 12px; font-weight: 600; color: var(--muted); text-transform: uppercase; letter-spacing: .04em; }
.field input, .field select, .field textarea { border: 1px solid var(--line); background: var(--bg); border-radius: 8px; padding: 7px 10px; }
.theme-input { font-family: var(--display); font-size: 28px; font-weight: 600; border: 0; border-bottom: 2px solid var(--line); background: transparent; padding: 2px 0; width: 100%; }
.theme-input:focus { outline: none; border-bottom-color: var(--accent); }
.ed-coaches { display: flex; flex-wrap: wrap; gap: 6px; align-items: center; }
.ed-coaches .cc { width: auto; border-radius: 99px; padding: 0 10px; }
.ed-coaches .cc .full { display: inline; }
.ed-coaches .cc .ini { display: none; }
.sections { display: grid; gap: 12px; margin-top: 14px; }
.sec { background: var(--surface); border: 1px solid var(--line); border-radius: 12px; padding: 12px 14px 14px; }
.sec-top { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; margin-bottom: 8px; }
.sec-name { font-family: var(--display); font-size: 20px; font-weight: 600; border: 0; background: transparent; padding: 0; flex: 1 1 180px; min-width: 0; }
.sec-name:focus { outline: none; box-shadow: 0 2px 0 var(--accent); }
.mins { display: inline-flex; align-items: center; gap: 4px; font-size: 13px; color: var(--muted); }
.mins input { width: 56px; border: 1px solid var(--line); background: var(--bg); border-radius: 6px; padding: 3px 6px; text-align: right; font-variant-numeric: tabular-nums; }
.linkbtn { border: 0; background: none; color: var(--muted); font-size: 13px; font-weight: 600; padding: 4px 6px; border-radius: 6px; }
.linkbtn:hover { color: var(--ink); background: var(--bg); }
.groups { display: grid; gap: 10px; grid-template-columns: repeat(auto-fit, minmax(240px, 1fr)); }
.grp { display: grid; gap: 4px; }
.grp input { border: 0; border-bottom: 1px dashed var(--line); background: transparent; font-weight: 600; font-size: 14px; padding: 2px 0; color: var(--accent); }
textarea.txt { width: 100%; min-height: 110px; resize: vertical; border: 1px solid var(--line); background: var(--bg); border-radius: 8px; padding: 10px 12px; line-height: 1.5; }
.saved { font-size: 13px; color: var(--muted); }
.toolbar { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; justify-content: space-between; margin-top: 14px; }
.copyfrom { display: flex; gap: 6px; align-items: center; flex-wrap: wrap; font-size: 14px; }
.copyfrom select { border: 1px solid var(--line); background: var(--surface); border-radius: 8px; padding: 6px 8px; max-width: 280px; }

/* Jako */
.share { background: var(--surface); border: 1px solid var(--line); border-radius: 12px; padding: 28px clamp(16px, 4vw, 40px); margin-top: 10px; max-width: 760px; }
.share .when { font-family: var(--display); font-size: 18px; color: var(--muted); font-weight: 600; text-transform: uppercase; letter-spacing: .03em; }
.share h1 { font-size: 36px; margin: 2px 0 18px; }
.share h3 { font-size: 20px; margin: 18px 0 4px; display: flex; gap: 8px; align-items: baseline; }
.share h3 small { font-family: var(--body); font-size: 13px; color: var(--muted); font-weight: 500; }
.share .g { font-weight: 600; color: var(--accent); margin-top: 6px; font-size: 14px; }
.share p { margin: 2px 0; white-space: pre-wrap; max-width: 65ch; }
.share .cols { display: grid; gap: 14px; grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); }
.share .foot { margin-top: 26px; padding-top: 12px; border-top: 1px solid var(--line); font-size: 13px; color: var(--muted); }
.wa { margin-top: 16px; }
.wa pre { background: var(--bg); border: 1px solid var(--line); border-radius: 8px; padding: 12px; white-space: pre-wrap; font: 13px/1.5 ui-monospace, Menlo, monospace; max-height: 260px; overflow: auto; }

/* Dialogi + toast */
.modal { position: fixed; inset: 0; background: rgb(0 0 0 / .35); display: none; align-items: center; justify-content: center; padding: 16px; z-index: 10; }
.modal.open { display: flex; }
.dlg { background: var(--surface); border-radius: 14px; padding: 20px; width: min(520px, 100%); display: grid; gap: 14px; max-height: 90vh; overflow: auto; }
.dlg h2 { font-size: 24px; }
.slots { display: flex; flex-wrap: wrap; gap: 6px; }
.slot { border: 1px solid var(--line); background: var(--bg); border-radius: 8px; padding: 6px 10px; font-size: 13px; text-align: left; }
.slot b { display: block; font-size: 14px; }
.slot.on { border-color: var(--accent); background: var(--accent-soft); }
.toast { position: fixed; left: 50%; bottom: 20px; transform: translateX(-50%); background: var(--ink); color: var(--bg); padding: 10px 16px; border-radius: 10px; font-size: 14px; font-weight: 600; opacity: 0; transition: opacity .2s; pointer-events: none; z-index: 20; max-width: calc(100% - 32px); }
.toast.show { opacity: 1; }
.note { font-size: 13px; color: var(--muted); }
@media (prefers-reduced-motion: reduce) { .toast { transition: none; } }
@media print {
  body { background: #fff; }
  .noprint { display: none !important; }
  .share { border: 0; padding: 0; }
}

/* Palvelinversio */
.banner { background: var(--accent-soft); border: 1px solid var(--accent); border-radius: 10px; padding: 12px 14px; margin-top: 12px; display: flex; flex-wrap: wrap; gap: 10px; align-items: center; justify-content: space-between; }
.gate { max-width: 460px; margin: 12vh auto 0; background: var(--surface); border: 1px solid var(--line); border-radius: 14px; padding: 24px; display: grid; gap: 10px; }
.gate h1 { font-size: 30px; }
.empty-state { background: var(--surface); border: 1px dashed var(--line); border-radius: 12px; padding: 28px; margin-top: 20px; display: grid; gap: 12px; justify-items: start; }
.saved.err { color: var(--no); font-weight: 600; }
