:root {
  --bg: #fff8f0;
  --card: #ffffff;
  --ink: #2b2420;
  --muted: #6b5f57;
  --line: #eadfd3;
  --accent: #f26b4a;
  --accent-ink: #ffffff;
  --accent-soft: #ffe3d8;
  --teal: #1f8a83;
  --teal-soft: #d9f1ee;
  --sun: #f6b73c;
  --sun-soft: #fff1cf;
  --bad: #c0392b;
  --bad-soft: #fde2df;
  --good: #23874a;
  --good-soft: #dcf3e3;
  --radius: 18px;
  --shadow: 0 2px 10px rgba(80, 50, 30, .08);
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #1d1916;
    --card: #2a2420;
    --ink: #f6eee7;
    --muted: #c5b7ab;
    --line: #42382f;
    --accent: #ff8a6b;
    --accent-ink: #1d1916;
    --accent-soft: #4a2a20;
    --teal: #4fc2b9;
    --teal-soft: #1c3b38;
    --sun: #f6c35c;
    --sun-soft: #43361a;
    --bad: #ff8a80;
    --bad-soft: #4a2220;
    --good: #6fd492;
    --good-soft: #1e3a27;
    --shadow: none;
  }
}
:root[data-theme="dark"] {
    --bg: #1d1916;
    --card: #2a2420;
    --ink: #f6eee7;
    --muted: #c5b7ab;
    --line: #42382f;
    --accent: #ff8a6b;
    --accent-ink: #1d1916;
    --accent-soft: #4a2a20;
    --teal: #4fc2b9;
    --teal-soft: #1c3b38;
    --sun: #f6c35c;
    --sun-soft: #43361a;
    --bad: #ff8a80;
    --bad-soft: #4a2220;
    --good: #6fd492;
    --good-soft: #1e3a27;
    --shadow: none;
  }

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font: 17px/1.5 -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  padding-bottom: calc(80px + env(safe-area-inset-bottom));
}
h1, h2, h3 { line-height: 1.25; margin: 0 0 .5em; }
h1 { font-size: 26px; }
h2 { font-size: 22px; }
h3 { font-size: 19px; }
p { margin: 0 0 .75em; }
a { color: var(--teal); }

/* Yläpalkki */
.top {
  position: sticky; top: 0; z-index: 5;
  display: flex; align-items: center; justify-content: space-between; gap: 8px;
  padding: calc(10px + env(safe-area-inset-top)) 16px 10px;
  background: var(--bg);
  border-bottom: 1px solid var(--line);
}
.brand { font-weight: 800; font-size: 19px; }
.top-stats { display: flex; gap: 10px; font-weight: 700; font-size: 16px; }

main { max-width: 640px; margin: 0 auto; padding: 16px; outline: none; }

/* Alavalikko */
.tabs {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 6;
  display: grid; grid-template-columns: repeat(5, 1fr);
  background: var(--card);
  border-top: 1px solid var(--line);
  padding-bottom: env(safe-area-inset-bottom);
}
.tabs a {
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  min-height: 60px; text-decoration: none; color: var(--muted);
  font-size: 16px;
}
.tabs a span { font-size: 22px; line-height: 1; }
.tabs a b { font-weight: 600; font-size: 16px; margin-top: 3px; letter-spacing: -.2px; }
.tabs a[aria-current="page"] { color: var(--accent); }
.tabs a[aria-current="page"] b { font-weight: 800; }

/* Kortit ja painikkeet */
.card {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 16px;
  margin-bottom: 14px;
  box-shadow: var(--shadow);
}
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  min-height: 48px; min-width: 44px;
  padding: 10px 18px;
  border: 0; border-radius: 14px;
  background: var(--accent); color: var(--accent-ink);
  font: inherit; font-weight: 700; font-size: 17px;
  cursor: pointer; text-decoration: none;
  touch-action: manipulation;
}
.btn:active { transform: scale(.98); }
.btn.big { width: 100%; min-height: 64px; font-size: 20px; border-radius: 18px; }
.btn.ghost { background: transparent; color: var(--ink); border: 2px solid var(--line); }
.btn.teal { background: var(--teal); color: #fff; }
.btn.small { min-height: 44px; padding: 8px 14px; font-size: 16px; }
.btn:disabled { opacity: .5; }
.row { display: flex; gap: 10px; flex-wrap: wrap; }
.row > .btn { flex: 1 1 auto; }
.muted { color: var(--muted); }
.center { text-align: center; }

/* Etusivu */
.stats { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; margin-bottom: 14px; }
.stat {
  background: var(--card); border: 1px solid var(--line); border-radius: var(--radius);
  padding: 12px 8px; text-align: center; box-shadow: var(--shadow);
}
.stat .n { font-size: 28px; font-weight: 800; }
.stat .l { font-size: 16px; color: var(--muted); }
.badges { display: grid; grid-template-columns: repeat(4, 1fr); gap: 8px; }
.badge {
  min-height: 44px; border-radius: 14px; padding: 10px 4px; text-align: center;
  background: var(--sun-soft); border: 1px solid var(--line);
  font: inherit; color: var(--ink); cursor: pointer;
}
.badge .i { font-size: 26px; display: block; }
.badge.off { filter: grayscale(1); opacity: .4; background: var(--card); }
.progress { height: 12px; background: var(--line); border-radius: 99px; overflow: hidden; }
.progress > i { display: block; height: 100%; background: var(--teal); border-radius: 99px; }

/* Vihjeet */
.hint {
  font: inherit; color: inherit; background: none; border: 0; padding: 0;
  border-bottom: 2px dotted var(--teal);
  cursor: help; text-align: inherit;
}
.hint-pop {
  position: fixed; z-index: 20;
  max-width: min(90vw, 320px);
  background: var(--ink); color: var(--bg);
  padding: 10px 14px; border-radius: 12px;
  font-size: 16px; box-shadow: 0 6px 20px rgba(0,0,0,.25);
}

/* Haastattelu */
.chips { display: flex; flex-wrap: wrap; gap: 8px; padding-bottom: 6px; margin-bottom: 10px; }
.chip {
  flex: 0 0 auto; min-height: 44px; padding: 8px 14px; border-radius: 99px;
  border: 2px solid var(--line); background: var(--card); color: var(--ink);
  font: inherit; font-size: 16px; font-weight: 600; cursor: pointer;
}
.chip[aria-pressed="true"] { background: var(--teal); border-color: var(--teal); color: #fff; }
.qtag { display: inline-block; font-size: 16px; font-weight: 700; color: var(--teal); margin-bottom: 6px; }
.question { font-size: 21px; font-weight: 800; margin-bottom: 12px; }
textarea, input, select {
  width: 100%; font: inherit; font-size: 17px; color: var(--ink);
  background: var(--bg); border: 2px solid var(--line); border-radius: 12px;
  padding: 12px; min-height: 48px;
}
textarea { min-height: 120px; resize: vertical; }
textarea:focus, input:focus, select:focus { outline: none; border-color: var(--teal); }
.model { background: var(--teal-soft); border-radius: 14px; padding: 14px; margin: 12px 0; }
.kw { display: flex; flex-wrap: wrap; gap: 6px; margin: 8px 0; }
.kw span { background: var(--card); border: 1px solid var(--line); border-radius: 99px; padding: 4px 12px; font-size: 16px; }
.kw span.hit { background: var(--good-soft); border-color: var(--good); }
.tip { background: var(--sun-soft); border-radius: 14px; padding: 12px 14px; margin: 10px 0; }
.check { display: flex; align-items: center; gap: 12px; min-height: 48px; cursor: pointer; }
.check input { width: 26px; height: 26px; min-height: 0; flex: 0 0 26px; accent-color: var(--teal); }
.rate { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; margin-top: 10px; }
.rate .btn { flex-direction: column; gap: 2px; min-height: 64px; }
.rate .btn small { font-size: 16px; font-weight: 600; }
.dots { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 8px; }
.dot { width: 14px; height: 14px; border-radius: 50%; background: var(--line); }
.dot.r1 { background: var(--bad); } .dot.r2 { background: var(--sun); } .dot.r3 { background: var(--good); }

/* Sanakortit */
.flip {
  perspective: 1000px; height: 260px; margin-bottom: 12px; cursor: pointer;
  background: none; border: 0; padding: 0; width: 100%; font: inherit; color: inherit;
}
.flip-inner {
  position: relative; width: 100%; height: 100%;
  transition: transform .45s; transform-style: preserve-3d;
}
.flip.on .flip-inner { transform: rotateY(180deg); }
.face {
  position: absolute; inset: 0; backface-visibility: hidden; -webkit-backface-visibility: hidden;
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 10px;
  padding: 20px; border-radius: 22px; border: 1px solid var(--line);
  background: var(--card); box-shadow: var(--shadow); text-align: center;
}
.face .w { font-size: 28px; font-weight: 800; word-break: break-word; }
.face.back { transform: rotateY(180deg); background: var(--accent-soft); }
.face .en { font-size: 21px; font-weight: 700; }
.face .ex { font-size: 18px; }
.boxes { display: grid; grid-template-columns: repeat(5, 1fr); gap: 6px; text-align: center; font-size: 16px; }
.boxes div { background: var(--card); border: 1px solid var(--line); border-radius: 12px; padding: 8px 2px; }
.boxes b { display: block; font-size: 20px; }

/* Sopimus */
details.card { padding: 0; }
details.card > summary {
  list-style: none; cursor: pointer; padding: 16px; min-height: 56px;
  font-weight: 800; font-size: 18px; display: flex; justify-content: space-between; align-items: center; gap: 10px;
}
details.card > summary::-webkit-details-marker { display: none; }
details.card > summary::after { content: "＋"; font-size: 22px; color: var(--accent); }
details.card[open] > summary::after { content: "－"; }
details.card > .inner { padding: 0 16px 16px; }
.script { background: var(--bg); border-left: 5px solid var(--teal); border-radius: 10px; padding: 12px 14px; margin: 10px 0; }
.script p { margin: 0 0 .4em; }
ol.clean, ul.clean { padding-left: 1.3em; margin: 0; }
ol.clean li, ul.clean li { margin-bottom: .45em; }
.flag li::marker { content: "🚩 "; }
.note { background: var(--sun-soft); border-radius: 14px; padding: 12px 14px; font-size: 16px; }
.disclaimer { font-size: 16px; color: var(--muted); border-top: 1px solid var(--line); padding-top: 12px; margin-top: 18px; }

/* Laskuri */
.seg { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; margin-bottom: 12px; }
.seg .btn { background: var(--card); color: var(--ink); border: 2px solid var(--line); }
.seg .btn[aria-pressed="true"] { background: var(--teal); border-color: var(--teal); color: #fff; }
.field { margin-bottom: 12px; }
.field label { display: flex; justify-content: space-between; align-items: center; gap: 8px; font-weight: 700; margin-bottom: 4px; font-size: 16px; }
.tarkista {
  display: inline-flex; align-items: center; min-height: 32px;
  background: var(--sun); color: #2b2420; border-radius: 99px;
  padding: 2px 10px; font-size: 16px; font-weight: 800; text-decoration: none; white-space: nowrap;
}
.grid2 { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.result { display: grid; gap: 8px; }
.result div { display: flex; justify-content: space-between; gap: 10px; padding: 10px 12px; border-radius: 12px; background: var(--bg); }
.result div b { white-space: nowrap; }
.result .good { background: var(--good-soft); }
.result .bad { background: var(--bad-soft); }
.result .hl { background: var(--teal-soft); font-size: 18px; }
.jobs { list-style: none; margin: 0; padding: 0; }
.jobs li { display: flex; justify-content: space-between; align-items: center; gap: 8px; padding: 10px 0; border-bottom: 1px solid var(--line); }
.jobs li:last-child { border-bottom: 0; }
.jobs .x { background: var(--bad-soft); color: var(--bad); }

/* Kierros */
.timer { font-variant-numeric: tabular-nums; font-weight: 800; font-size: 20px; }
.round-head { display: flex; justify-content: space-between; align-items: center; margin-bottom: 10px; }
.done-emoji { font-size: 64px; text-align: center; }

#confetti { position: fixed; inset: 0; width: 100%; height: 100%; pointer-events: none; z-index: 30; }

.toast {
  position: fixed; left: 50%; top: calc(64px + env(safe-area-inset-top)); transform: translateX(-50%); max-width: calc(100vw - 32px); text-align: center; pointer-events: none;
  background: var(--ink); color: var(--bg); padding: 10px 18px; border-radius: 99px;
  font-weight: 700; z-index: 25; font-size: 16px;
}

@media (prefers-reduced-motion: reduce) {
  .flip-inner { transition: none; }
}
.grid2 > * { min-width: 0; }
.field label { flex-wrap: wrap; }
input[type="date"], input[type="month"] { -webkit-appearance: none; appearance: none; display: block; }
.seg .btn { padding: 10px 6px; }

/* Työtutka */
.radar-teaser { display: flex; align-items: center; gap: 12px; text-decoration: none; color: var(--ink); background: var(--teal-soft); border-color: var(--teal); }
.rt-icon { font-size: 34px; }
.rt-text { flex: 1; font-size: 18px; }
.rt-go { font-size: 34px; color: var(--teal); font-weight: 800; }
.status { font-weight: 700; }
.job { position: relative; }
.job h3 { padding-right: 84px; }
.job.is-new { border: 2px solid var(--accent); }
.job-meta { margin-bottom: 12px; }
.new-tag { position: absolute; top: 14px; right: 14px; background: var(--accent); color: var(--accent-ink); font-weight: 800; font-size: 16px; padding: 2px 10px; border-radius: 99px; }
.new-tag.pin { background: var(--teal); color: #fff; }
.card.warn { border: 2px solid var(--sun); background: var(--sun-soft); }
.linkgrid { display: grid; gap: 8px; }
.linkgrid .btn { justify-content: space-between; text-align: left; }

.job .apply { margin-top: 4px; }
.workitem { border: 1px solid var(--line); border-radius: 14px; padding: 12px; margin-bottom: 12px; background: var(--bg); }
.paper {
  background: #fff; color: #111; border: 1px solid var(--line); border-radius: 12px;
  padding: 20px 18px; font-family: Arial, Helvetica, sans-serif; box-shadow: var(--shadow);
}
.paper h1 { font-size: 24px; margin: 0 0 4px; }
.paper h2 { font-size: 18px; margin: 16px 0 4px; border-bottom: 1px solid #ccc; padding-bottom: 2px; }
.paper p { margin: 0 0 4px; font-size: 16px; }
#printArea { display: none; }
@media print {
  body { background: #fff; padding: 0; }
  body > *:not(#printArea) { display: none !important; }
  #printArea { display: block; color: #000; font-family: Arial, Helvetica, sans-serif; font-size: 11pt; }
  #printArea h1 { font-size: 20pt; margin: 0 0 4pt; }
  #printArea h2 { font-size: 13pt; margin: 12pt 0 3pt; border-bottom: 1px solid #999; }
  #printArea p { margin: 0 0 3pt; font-size: 11pt; }
  @page { margin: 18mm; }
}

/* Englanti ja työpaikan tiedot */
.en { color: var(--muted); font-size: 16px; font-style: italic; }
.question + .en { margin-top: -6px; }
.linkbtn { background: none; border: 0; padding: 0; font: inherit; color: inherit; text-align: left; cursor: pointer; text-decoration: underline; text-decoration-color: var(--line); text-underline-offset: 4px; }
.pay { color: var(--good); font-style: normal; }
.facts { display: grid; gap: 8px; margin: 12px 0; }
.fact { display: flex; justify-content: space-between; align-items: center; gap: 10px; background: var(--card); border: 1px solid var(--line); border-radius: 14px; padding: 12px 14px; }
.fact span { color: var(--muted); white-space: nowrap; }
.fact b { text-align: right; }
.fact.urgent { border: 2px solid var(--accent); background: var(--accent-soft); }
.qlink { width: 100%; justify-content: flex-start; text-align: left; margin-bottom: 8px; font-weight: 600; }

/* ===== Uudet osat ===== */
.small { font-size: 16px; }
.en.sub { margin: -6px 0 12px; }
.en.small { font-size: 16px; }
.card.soft { background: var(--bg); box-shadow: none; }
.card.today h2 { margin-bottom: 4px; }
.week { display: grid; grid-template-columns: repeat(7, 1fr); gap: 6px; margin: 12px 0; }
.wd { text-align: center; border: 1px solid var(--line); border-radius: 12px; padding: 6px 0; background: var(--card); }
.wd span { display: block; font-size: 16px; color: var(--muted); }
.wd b { display: block; min-height: 22px; color: var(--good); }
.wd.on { background: var(--good-soft); border-color: var(--good); }
.wd.today { outline: 2px solid var(--accent); outline-offset: 1px; }
.goal { font-size: 17px; margin: -4px 0 12px; }
.goals { display: grid; gap: 12px; }
.goalrow { display: flex; gap: 12px; align-items: center; }
.ring { width: 64px; height: 64px; flex: 0 0 64px; }
.ring .rbg { fill: none; stroke: var(--line); stroke-width: 7; }
.ring .rfg { fill: none; stroke: var(--teal); stroke-width: 7; stroke-linecap: round; transform: rotate(-90deg); transform-origin: 50% 50%; transition: stroke-dashoffset .6s; }
.ring text { font: 700 14px -apple-system, sans-serif; fill: var(--ink); }
.recap-grid { display: grid; grid-template-columns: repeat(4, 1fr); gap: 6px; text-align: center; }
.recap-grid b { display: block; font-size: 24px; }
.recap-grid span { font-size: 16px; color: var(--muted); }
.linkcard { display: flex; align-items: center; gap: 12px; text-decoration: none; color: var(--ink); }
.linkcard > span:first-child { font-size: 30px; }
.linkcard > span:nth-child(2) { flex: 1; }
.urgent-card { border: 2px solid var(--accent); background: var(--accent-soft); }
.badges .badge { display: flex; flex-direction: column; align-items: center; gap: 2px; min-height: 76px; }
.badge .bn { font-size: 16px; line-height: 1.15; font-weight: 600; }
.dot.big { width: 44px; height: 44px; border: 0; font: inherit; font-size: 16px; font-weight: 700; color: var(--ink); cursor: pointer; }
.dot.big.r1, .dot.big.r2, .dot.big.r3 { color: #fff; }
.dot.big.cur { outline: 3px solid var(--accent); outline-offset: 2px; }
.question.small { font-size: 18px; }
.storypick details { border: 1px solid var(--line); border-radius: 12px; padding: 8px 12px; margin-bottom: 6px; background: var(--card); }
.storypick summary { cursor: pointer; min-height: 32px; }
.face .w2 { font-size: 24px; font-weight: 800; }
.rtag { display: inline-block; font-size: 16px; font-weight: 700; padding: 2px 10px; border-radius: 99px; margin: 0 0 8px; }
.rtag.ok { background: var(--good-soft); color: var(--good); }
.rtag.ask { background: var(--sun-soft); color: var(--ink); }
.timer.low { color: var(--bad); }
.iv-avatar { font-size: 56px; }
.rate.two { grid-template-columns: 1fr 1fr; }
.ok { color: var(--good); font-weight: 700; }
.warnt { color: var(--bad); font-weight: 700; }
.note.ok { background: var(--good-soft); }
.card.done { border-color: var(--good); }
/* Aloitus */
.ob { padding-top: 8px; }
.ob-hero { font-size: 64px; text-align: center; }
.dots-step { display: flex; gap: 6px; justify-content: center; margin-bottom: 18px; }
.dots-step i { width: 28px; height: 6px; border-radius: 99px; background: var(--line); }
.dots-step i.on { background: var(--accent); }
.choice { display: grid; gap: 10px; }
.choice.row4 { grid-template-columns: repeat(4, 1fr); }
.choice .btn[aria-pressed="true"] { background: var(--teal); color: #fff; border-color: var(--teal); }
.big2 { min-height: 76px; flex-direction: column; text-align: center; line-height: 1.3; }
.big2 small { font-weight: 500; font-size: 16px; }
.seg .btn:not([aria-pressed]) { background: var(--card); color: var(--ink); border: 2px solid var(--line); }
/* Suomi */
.packs { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.pack { position: relative; display: flex; flex-direction: column; align-items: flex-start; gap: 2px; text-align: left; padding: 14px; min-height: 96px;
  background: var(--card); border: 1px solid var(--line); border-radius: 16px; font: inherit; color: var(--ink); cursor: pointer; box-shadow: var(--shadow); }
.pack .pi { font-size: 26px; }
.pack small { color: var(--muted); font-size: 16px; }
.pack.seen { border-color: var(--good); }
.pack .pk { position: absolute; top: 8px; right: 10px; color: var(--good); font-weight: 800; }
.phrase { display: flex; justify-content: space-between; gap: 10px; align-items: flex-start; padding: 12px 0; border-bottom: 1px solid var(--line); }
.phrase p { margin: 2px 0 0; }
.phrase.hear b { color: var(--teal); }
.pbtn { display: flex; gap: 6px; flex: 0 0 auto; }
.pill { display: inline-block; font-size: 16px; background: var(--teal-soft); color: var(--ink); border-radius: 99px; padding: 0 10px; font-weight: 600; }
/* Opas */
.glist { display: grid; gap: 8px; }
.gitem { display: flex; align-items: center; gap: 12px; background: var(--card); border: 1px solid var(--line); border-radius: 16px; padding: 12px 14px; min-height: 60px; text-decoration: none; color: var(--ink); box-shadow: var(--shadow); }
.gitem .gi { font-size: 26px; }
.gitem > span:nth-child(2) { flex: 1; }
.scr { margin-bottom: 16px; }
.scr h4 { margin: 0 0 4px; font-size: 18px; }
.paytable { display: grid; gap: 10px; }
.payrow { display: flex; flex-direction: column; gap: 2px; padding: 10px 12px; background: var(--bg); border-radius: 12px; }
.src { font-size: 16px; color: var(--muted); margin: 6px 0 0; }
.src a { color: var(--muted); }
ul.steps { margin: 6px 0 10px; }
ul.num { list-style: decimal; }

.badges { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.badge .bn { overflow-wrap: anywhere; hyphens: auto; }
.row > .btn, .row > a.btn { min-width: 0; }
main { overflow-wrap: break-word; }
.rate .btn { padding: 8px 4px; overflow-wrap: normal; }
.rate .btn small { overflow-wrap: normal; hyphens: none; }

[hidden] { display: none !important; }
.recap-grid { grid-template-columns: repeat(2, 1fr); row-gap: 10px; }
.shadow-box { background: var(--teal-soft); border-radius: 14px; padding: 12px 14px; margin: 10px 0; }
.shadow-box .line { font-size: 19px; font-weight: 700; margin: 6px 0 10px; }
.risk { border: 2px solid var(--sun); background: var(--sun-soft); }
details.more > summary { font-weight: 800; }
.tagmodel { display: inline-block; font-size: 16px; font-weight: 700; background: var(--sun-soft); border-radius: 99px; padding: 0 10px; margin-bottom: 6px; }
