:root {
  --bg: #f6f7f9; --panel: #ffffff; --text: #16181d; --muted: #5f6673; --line: #e3e6eb;
  --accent: #1d4ed8; --accent-soft: #e6edff; --hl: #fff3c4; --hl-line: #f2b705;
  --paid: #a15c00; --paid-bg: #fff1dd; --sum: #4b5563; --sum-bg: #eef0f3; --ok: #16a34a; --bad: #dc2626;
  --read: #8a909b; --shadow: 0 1px 2px rgba(0,0,0,.06), 0 4px 16px rgba(0,0,0,.05);
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #0f1115; --panel: #171a21; --text: #e7e9ee; --muted: #9aa3b2; --line: #272b35;
    --accent: #7aa2ff; --accent-soft: #1b2440; --hl: #3a3313; --hl-line: #d4a50a;
    --paid: #f0b35c; --paid-bg: #3a2a12; --sum: #b8c0cc; --sum-bg: #252a33; --read: #6b7280;
    --shadow: none; color-scheme: dark;
  }
}
:root[data-theme="dark"] {
  --bg: #0f1115; --panel: #171a21; --text: #e7e9ee; --muted: #9aa3b2; --line: #272b35;
  --accent: #7aa2ff; --accent-soft: #1b2440; --hl: #3a3313; --hl-line: #d4a50a;
  --paid: #f0b35c; --paid-bg: #3a2a12; --sum: #b8c0cc; --sum-bg: #252a33; --read: #6b7280;
  --shadow: none; color-scheme: dark;
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }
html, body { margin: 0; background: var(--bg); color: var(--text); }
body { font: 15px/1.5 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif; }
button, input, select { font: inherit; color: inherit; }
a { color: var(--accent); }
.visually-hidden { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }

/* ---------- top bar */
.topbar { position: sticky; top: 0; z-index: 20; display: flex; align-items: center; gap: 12px;
  padding: 10px 16px; background: var(--panel); border-bottom: 1px solid var(--line); }
.logo { margin: 0; font-size: 20px; font-weight: 800; letter-spacing: -.02em; }
.logo span { color: var(--accent); }
.live { display: inline-flex; align-items: center; gap: 6px; color: var(--muted); font-size: 13px; white-space: nowrap; }
.live .dot { width: 9px; height: 9px; border-radius: 50%; background: var(--muted); }
.live.on .dot { background: var(--ok); box-shadow: 0 0 0 3px color-mix(in srgb, var(--ok) 25%, transparent); }
.live.off .dot { background: var(--bad); }
.topbar { flex-wrap: wrap; row-gap: 8px; }
/* search opens as its own full-width row under the top bar */
.search { display: none; order: 99; flex: 1 1 100%; }
.search.open { display: block; }
.search input { font-size: 16px; padding: 9px 12px; }
#search-btn { margin-left: auto; }
#search-btn[aria-expanded="true"] { background: var(--accent-soft); border-color: var(--accent); color: var(--accent);
  box-shadow: 0 0 0 2px color-mix(in srgb, var(--accent) 25%, transparent); }
.search input { width: 100%; padding: 8px 12px; border: 1px solid var(--line); border-radius: 10px; background: var(--bg); }
.icon-btn { border: 1px solid var(--line); background: var(--panel); border-radius: 10px; min-width: 36px; height: 36px; cursor: pointer; }
.icon-btn:hover { border-color: var(--accent); }
.link-btn { border: 0; background: none; color: var(--accent); cursor: pointer; padding: 0; font-size: 13px; }
.only-mobile { display: none; }

/* ---------- tabs */
.tabs { display: flex; gap: 4px; padding: 8px 16px 0; overflow-x: auto; background: var(--panel); border-bottom: 1px solid var(--line); }
.tabs button { border: 0; background: none; padding: 8px 12px 10px; cursor: pointer; color: var(--muted); border-bottom: 3px solid transparent; white-space: nowrap; font-weight: 600; }
.tabs button.active { color: var(--text); border-bottom-color: var(--accent); }

/* ---------- layout */
.layout { display: grid; grid-template-columns: 260px minmax(0, 1fr); gap: 20px; max-width: 1200px; margin: 0 auto; padding: 16px; }
.filters { position: sticky; top: 118px; align-self: start; max-height: calc(100vh - 130px); overflow: auto; font-size: 14px; }
.filters section { margin-bottom: 18px; }
.filters h2 { font-size: 12px; text-transform: uppercase; letter-spacing: .06em; color: var(--muted); margin: 0 0 8px; }
.switch { display: flex; align-items: center; gap: 8px; padding: 3px 0; cursor: pointer; }
.seg { display: inline-flex; border: 1px solid var(--line); border-radius: 10px; overflow: hidden; }
.seg button { border: 0; background: var(--panel); padding: 5px 10px; cursor: pointer; }
.seg button.active { background: var(--accent-soft); color: var(--accent); font-weight: 600; }
.src-group h3 { font-size: 13px; margin: 10px 0 4px; }
.src-row { display: flex; align-items: center; gap: 6px; padding: 2px 0; }
.src-row .count { margin-left: auto; color: var(--muted); font-size: 12px; }
.src-row .sick { color: var(--bad); }
.legend { color: var(--muted); font-size: 12px; }

/* ---------- feed */
.toolbar { display: flex; gap: 16px; align-items: center; margin-bottom: 10px; color: var(--muted); font-size: 13px; }
.toolbar #read-all { margin-left: auto; }
.new-banner { position: sticky; top: 124px; z-index: 10; display: block; margin: 0 auto 12px; padding: 8px 18px;
  border: 0; border-radius: 999px; background: var(--accent); color: #fff; font-weight: 600; cursor: pointer; box-shadow: var(--shadow); }
.cards { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 10px; }
.card { background: var(--panel); border: 1px solid var(--line); border-radius: 14px; padding: 12px 14px; cursor: pointer; box-shadow: var(--shadow);
  transition: border-color .15s; }
.card:hover, .card.sel { border-color: var(--accent); }
.card.sel { outline: 2px solid var(--accent-soft); }
.card.hl { border-left: 4px solid var(--hl-line); }
.card.fresh { animation: flash 2.5s ease-out; }
@keyframes flash { from { background: var(--accent-soft); } to { background: var(--panel); } }
.card .meta { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; font-size: 12.5px; color: var(--muted); }
.card .src { font-weight: 700; color: var(--text); }
.card h3 { margin: 4px 0 2px; font-size: 17px; line-height: 1.3; }
.card.read h3 { color: var(--read); font-weight: 500; }
.card p.lead { margin: 2px 0 0; color: var(--muted); display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
.badge { display: inline-block; font-size: 11px; padding: 1px 7px; border-radius: 999px; font-weight: 600; }
.badge-paid { background: var(--paid-bg); color: var(--paid); }
.badge-summary { background: var(--sum-bg); color: var(--sum); }
.badge-cluster { background: var(--accent-soft); color: var(--accent); cursor: pointer; border: 0; }
mark { background: var(--hl); color: inherit; border-radius: 3px; padding: 0 1px; }
.sentinel { height: 40px; }
.empty { text-align: center; color: var(--muted); padding: 40px 0; }

/* ---------- reader + modals */
dialog { border: 1px solid var(--line); background: var(--panel); color: var(--text); border-radius: 16px; padding: 0; box-shadow: 0 20px 60px rgba(0,0,0,.3); }
dialog::backdrop { background: rgba(10, 12, 16, .45); }
.reader { width: min(760px, 100vw - 24px); max-height: calc(100vh - 40px); }
.reader-inner { padding: 18px 24px 24px; }
.reader-head { display: flex; align-items: center; gap: 10px; }
.r-meta { color: var(--muted); font-size: 13px; flex: 1; }
.reader h2 { font-size: 24px; line-height: 1.25; margin: 8px 0 12px; outline: none; }
.r-body p { margin: 0 0 1em; font-size: 16.5px; line-height: 1.65; }
.r-body p:first-child { font-weight: 600; }
.r-notice { background: var(--sum-bg); color: var(--sum); padding: 10px 12px; border-radius: 10px; font-size: 14px; margin-bottom: 12px; }
.r-link { font-weight: 700; }
#r-sib-list { padding-left: 18px; }
#r-sib-list li { margin: 4px 0; }
#r-sib-list button { border: 0; background: none; color: var(--accent); cursor: pointer; text-align: left; padding: 0; }
.modal { width: min(560px, 100vw - 24px); }
.modal.wide { width: min(1000px, 100vw - 24px); }
.modal > section, .modal > div:not(.modal-head) { padding: 0 20px 14px; }
.modal-head { display: flex; align-items: center; justify-content: space-between; padding: 14px 20px; border-bottom: 1px solid var(--line); margin-bottom: 12px; }
.modal-head h2 { margin: 0; font-size: 18px; }
.modal h3 { font-size: 14px; margin: 8px 0; }
.hint { color: var(--muted); font-size: 13px; margin: 0 0 8px; }
.word-form { display: flex; gap: 8px; }
.word-form input { flex: 1; padding: 6px 10px; border: 1px solid var(--line); border-radius: 8px; background: var(--bg); }
.word-form button, select { padding: 6px 12px; border: 1px solid var(--line); border-radius: 8px; background: var(--panel); cursor: pointer; }
.chips { list-style: none; padding: 0; display: flex; flex-wrap: wrap; gap: 6px; }
.chips li { background: var(--accent-soft); color: var(--accent); border-radius: 999px; padding: 2px 4px 2px 10px; display: inline-flex; align-items: center; gap: 4px; }
.chips button { border: 0; background: none; cursor: pointer; color: inherit; }
kbd { border: 1px solid var(--line); border-bottom-width: 2px; border-radius: 4px; padding: 0 4px; font-size: 12px; }
table.status { width: 100%; border-collapse: collapse; font-size: 13px; }
table.status th, table.status td { text-align: left; padding: 5px 6px; border-bottom: 1px solid var(--line); vertical-align: top; }
table.status td.err { color: var(--bad); }
table.status td.ok { color: var(--ok); }

/* ---------- mobile */
@media (max-width: 860px) {
  .only-mobile { display: inline-block; }
  .layout { grid-template-columns: 1fr; padding: 10px; }
  .filters { display: none; position: fixed; inset: 56px 0 0 0; top: 56px; max-height: none; z-index: 30; background: var(--panel); padding: 16px; }
  .filters.open { display: block; }
  .live .live-text { display: none; }
  .logo { font-size: 17px; }
  .new-banner { top: 110px; }
  .reader { width: 100vw; max-width: 100vw; height: 100vh; max-height: 100vh; border-radius: 0; margin: 0; }
}

/* ---------- markets */
.elec-chip { border: 0; border-radius: 999px; padding: 4px 10px; font-weight: 700; font-size: 13px; cursor: pointer; white-space: nowrap; }
.elec-chip.neg, .elec-chip.low { background: #dcfce7; color: #166534; }
.elec-chip.mid { background: #fef9c3; color: #854d0e; }
.elec-chip.high, .elec-chip.vhigh { background: #fee2e2; color: #991b1b; }
.markets { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 16px; max-width: 1200px; margin: 0 auto; padding: 16px; }
.markets[hidden], .layout[hidden] { display: none; }
.panel { background: var(--panel); border: 1px solid var(--line); border-radius: 14px; padding: 14px 16px; box-shadow: var(--shadow); min-width: 0; }
.wide-panel { grid-column: 1 / -1; }
.panel-head { display: flex; align-items: center; justify-content: space-between; gap: 10px; flex-wrap: wrap; }
.panel-head h2 { margin: 0; font-size: 17px; }
.kpi { display: flex; align-items: baseline; gap: 10px; flex-wrap: wrap; margin: 8px 0 4px; }
.kpi .big { font-size: 30px; font-weight: 800; letter-spacing: -.02em; }
.kpi .unit, .muted { color: var(--muted); font-size: 13px; }
.small { font-size: 13px; margin: 4px 0 8px; }
.kpi-line { font-weight: 600; margin: 8px 0; }
.source { color: var(--muted); font-size: 12px; margin: 6px 0 0; }
.change.up { color: var(--ok); font-weight: 700; }
.change.down { color: var(--bad); font-weight: 700; }
.idx-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 20px; margin-top: 10px; }
.idx-grid select { padding: 4px 8px; }
.legend-row { display: flex; gap: 10px; font-size: 12.5px; }
.legend-item::before { content: ""; display: inline-block; width: 12px; height: 3px; border-radius: 2px; margin-right: 5px; vertical-align: middle; background: currentColor; }
.chart-box { position: relative; min-height: 120px; }
.chart svg { display: block; overflow: visible; }
.chart .axis text { fill: var(--muted); font-size: 11px; }
.chart .grid { stroke: var(--line); stroke-width: 1; }
.chart .zero, .chart .baseline { stroke: var(--muted); stroke-dasharray: 4 4; stroke-width: 1; }
.chart .cross { stroke: var(--muted); stroke-width: 1; }
.chart .line { fill: none; stroke-width: 2; stroke-linejoin: round; }
.chart .area { stroke: none; opacity: .12; }
.c1 { color: #2563eb; stroke: #2563eb; fill: #2563eb; }
.c2 { color: #16a34a; stroke: #16a34a; fill: #16a34a; }
.c3 { color: #d97706; stroke: #d97706; fill: #d97706; }
.c4 { color: #9333ea; stroke: #9333ea; fill: #9333ea; }
.chart .up { stroke: #16a34a; fill: #16a34a; }
.chart .down { stroke: #dc2626; fill: #dc2626; }
.chart .bar.neg, .chart .bar.low { fill: #22c55e; }
.chart .bar.mid { fill: #eab308; }
.chart .bar.high { fill: #f97316; }
.chart .bar.vhigh { fill: #dc2626; }
.chart .bar.now { stroke: var(--text); stroke-width: 1.5; }
.chart .nowline { stroke: var(--text); stroke-width: 1; stroke-dasharray: 3 3; }
.chart-tip { position: absolute; top: 4px; min-width: 140px; pointer-events: none; background: var(--panel); border: 1px solid var(--line);
  border-radius: 8px; padding: 6px 8px; font-size: 12.5px; box-shadow: var(--shadow); }
@media (max-width: 860px) {
  .markets, .idx-grid { grid-template-columns: 1fr; padding: 10px; }
  .elec-chip { padding: 3px 8px; }
}
.elec-chip { display: inline-flex; align-items: center; gap: 6px; }
.elec-chip .spark { display: block; }
.spark rect { opacity: .5; }
.spark rect.now { opacity: 1; }
.spark rect.neg, .spark rect.low { fill: #16a34a; }
.spark rect.mid { fill: #ca8a04; }
.spark rect.high { fill: #ea580c; }
.spark rect.vhigh { fill: #dc2626; }
@media (max-width: 480px) { .elec-chip .spark { width: 44px; } }
.idx-chip { display: inline-flex; align-items: center; gap: 6px; border: 1px solid var(--line); background: var(--panel); border-radius: 999px;
  padding: 3px 10px; font-size: 13px; cursor: pointer; white-space: nowrap; }
.idx-chip .name { font-weight: 700; }
.idx-chip .chg.up { color: var(--ok); font-weight: 700; }
.idx-chip .chg.down { color: var(--bad); font-weight: 700; }
.spark-line { display: block; }
.spark-line path { fill: none; stroke-width: 1.6; stroke-linejoin: round; }
.spark-line path.up { stroke: #16a34a; }
.spark-line path.down { stroke: #dc2626; }
.spark-line .base { stroke: var(--muted); stroke-width: .8; stroke-dasharray: 2 2; }
@media (max-width: 1100px) { .idx-chip .spark-line { display: none; } }
@media (max-width: 860px) { .idx-chip { display: none !important; } }

/* ---------- public edition: ads, sponsors, attribution, footer */
.ad-slot { list-style: none; }
.ad-box { margin: 14px 0; }
.ad-unit, .sponsor { position: relative; background: var(--panel); border: 1px dashed var(--line); border-radius: 14px; padding: 18px 12px 10px; }
.ad-label { position: absolute; top: 4px; left: 10px; font-size: 10.5px; text-transform: uppercase; letter-spacing: .08em; color: var(--muted); }
.sponsor a { display: flex; flex-direction: column; gap: 3px; color: var(--text); text-decoration: none; }
.sponsor strong { font-size: 15.5px; }
.sponsor span { color: var(--muted); font-size: 14px; }
.sponsor .cta { color: var(--accent); font-weight: 700; }
.r-attrib { color: var(--muted); font-size: 13px; border-top: 1px solid var(--line); padding-top: 8px; }
.site-footer { max-width: 1200px; margin: 10px auto 30px; padding: 12px 16px; display: flex; flex-wrap: wrap; gap: 8px 18px;
  color: var(--muted); font-size: 13px; border-top: 1px solid var(--line); }
.legal { max-width: 820px; margin: 0 auto; padding: 20px 16px 40px; }
.legal h1 { font-size: 26px; } .legal h2 { font-size: 19px; margin-top: 28px; }
.legal table { width: 100%; border-collapse: collapse; font-size: 14px; }
.legal th, .legal td { text-align: left; border-bottom: 1px solid var(--line); padding: 6px; vertical-align: top; }
.logo-link { color: inherit; text-decoration: none; }

/* ---------- tabs: one scrollable row (keeps vertical space for headlines) + edge fades as a scroll hint */
.tabs-wrap { position: relative; }
.tabs { scrollbar-width: none; -webkit-overflow-scrolling: touch; }
.tabs::-webkit-scrollbar { display: none; }
.tabs-wrap::before, .tabs-wrap::after { content: ""; position: absolute; top: 0; bottom: 1px; width: 36px; pointer-events: none;
  opacity: 0; transition: opacity .2s; z-index: 1; }
.tabs-wrap::before { left: 0; background: linear-gradient(to right, var(--panel), transparent); }
.tabs-wrap::after { right: 0; background: linear-gradient(to left, var(--panel) 30%, transparent); }
.tabs-wrap.more-left::before, .tabs-wrap.more-right::after { opacity: 1; }
/* ---------- /porssisahko page */
.elec-page .kpi .big { font-size: 34px; }
.price-table { width: 100%; border-collapse: collapse; font-size: 14.5px; margin: 8px 0 16px; }
.price-table th, .price-table td { text-align: left; padding: 5px 8px; border-bottom: 1px solid var(--line); }
.price-table tr.now { background: var(--accent-soft); }
.price-table tr.cheapest td:first-child::after { content: " · halvin"; color: var(--ok); font-weight: 600; }
.price-table tr.priciest td:first-child::after { content: " · kallein"; color: var(--bad); font-weight: 600; }

/* ---------- /opeta: feelgood labelling */
.teach-card { background: var(--panel); border: 1px solid var(--line); border-radius: 16px; padding: 22px; margin: 16px 0; box-shadow: var(--shadow); }
.teach-card h2 { font-size: 22px; line-height: 1.3; margin: 8px 0 10px; min-height: 2.6em; }
.teach-meta, .teach-why { color: var(--muted); font-size: 13px; }
.teach-buttons { display: flex; gap: 10px; align-items: center; margin-top: 14px; flex-wrap: wrap; }
.teach-yes, .teach-no, .teach-train { border: 1px solid var(--line); border-radius: 12px; padding: 12px 20px; font-size: 16px; font-weight: 700; cursor: pointer; background: var(--panel); }
.teach-yes { background: #dcfce7; color: #166534; border-color: #86efac; }
.teach-no { background: var(--sum-bg); color: var(--sum); }
.teach-train { font-size: 14px; padding: 8px 14px; }
