:root {
  --bg: #f1f6ff;
  --surface: #ffffff;
  --text: #17202e;
  --muted: #5d6b82;
  --line: #d9e3f5;
  --primary: #2f6fed;
  --primary-text: #ffffff;
  --user-bubble: #2f6fed;
  --helper-bubble: #ffffff;
  --error: #b3261e;
  --radius: 20px;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #0f1624;
    --surface: #182236;
    --text: #e8eefb;
    --muted: #9aa8c2;
    --line: #2a3a58;
    --primary: #6b9bff;
    --primary-text: #0b1220;
    --user-bubble: #3b63c4;
    --helper-bubble: #1d2a43;
    --error: #ff8a80;
  }
}

* { box-sizing: border-box; }
html, body { height: 100%; margin: 0; }
:root { font-size: var(--text-scale, 90%); }
body {
  background: var(--bg);
  color: var(--text);
  font: 1.125rem/1.45 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  -webkit-text-size-adjust: 100%;
  overscroll-behavior: none;
}
button, input, textarea { font: inherit; color: inherit; }
button { cursor: pointer; -webkit-tap-highlight-color: transparent; }
[hidden] { display: none !important; }

#app {
  height: 100dvh;
  display: flex;
  flex-direction: column;
  max-width: 720px;
  margin: 0 auto;
}

.top {
  display: flex; align-items: center; justify-content: space-between;
  padding: calc(env(safe-area-inset-top) + 8px) 16px 8px;
  background: var(--bg);
}
.brand { display: flex; align-items: center; gap: 10px; }
.brand img { border-radius: 10px; }
.brand h1 { font-size: 1.15rem; margin: 0; }
/* Ylälaidan logo: Oivallin-lintu kääntyy katsomaan avointa välilehteä (issue #299). Välilehdet ovat linnun alapuolella
   vasemmalta oikealle, joten mitä vasemmammalla avoin välilehti on, sitä enemmän lintu kallistuu katsomaan alas.
   Pelkkää CSS:ää (:has ja aria-selected, jonka markTabs asettaa); animoidaan vain transform. Vähennetty liike: asento vaihtuu suoraan. */
.brand-mark { display: block; flex: 0 0 36px; width: 36px; height: 36px; }
.brand .brand-mark img { display: block; border-radius: 0; }
.brand-bird { transform-origin: 50% 85%; transition: transform .45s cubic-bezier(.3, 1.4, .5, 1); }
body:has(#modeTabs [data-mode="study"][aria-selected="true"]) .brand-bird { transform: rotate(38deg); }
body:has(#modeTabs [data-mode="task"][aria-selected="true"]) .brand-bird { transform: rotate(22deg); }
body:has(#modeTabs [data-mode="review"][aria-selected="true"]) .brand-bird { transform: rotate(12deg); }
body:has(#modeTabs [data-mode="exam"][aria-selected="true"]) .brand-bird { transform: rotate(4deg); }
@media (prefers-reduced-motion: reduce) {
  .brand-bird { transition: none; }
}
.icon-btn {
  width: 48px; height: 48px; border: 0; border-radius: 50%;
  background: transparent; display: grid; place-items: center;
}
.icon-btn svg, .round svg { fill: currentColor; }

#chat {
  flex: 1; overflow-y: auto; padding: 8px 16px 16px;
  display: flex; flex-direction: column; gap: 12px;
  scroll-behavior: smooth;
}
.row { display: flex; flex-direction: column; max-width: 88%; }
.row.user { align-self: flex-end; align-items: flex-end; }
.row.helper { align-self: flex-start; align-items: flex-start; }
.helper-body { display: flex; align-items: flex-start; gap: 8px; width: 100%; }
.helper-mascot {
  box-sizing: border-box; position: sticky; top: 8px; flex: 0 0 40px;
  width: 40px; height: 40px; margin-top: 22px;
}
.helper-mascot img { display: block; width: 100%; height: 100%; }
.helper-mascot::after {
  position: absolute; left: 31px; top: 18px; width: 5px; height: 2px;
  border-radius: 50%; background: #35434a; content: ""; opacity: 0;
}
.helper-message { flex: 1; min-width: 0; }
.helper-author { margin: 0 0 2px 4px; color: var(--muted); font-size: .85rem; font-weight: 600; }
.bubble {
  padding: 12px 16px; border-radius: var(--radius);
  white-space: pre-wrap; overflow-wrap: anywhere;
}
.user .bubble { background: var(--user-bubble); color: #fff; border-bottom-right-radius: 6px; }
.helper .bubble { background: var(--helper-bubble); border: 1px solid var(--line); border-bottom-left-radius: 6px; }
.bubble img { display: block; max-width: 100%; max-height: 220px; border-radius: 12px; margin-bottom: 8px; }
.listen {
  margin-top: 4px; min-height: 44px; padding: 0 12px;
  border: 0; background: transparent; color: var(--primary);
  display: inline-flex; align-items: center; gap: 6px; font-size: 0.95rem;
}
.feedback-actions { display: flex; flex-wrap: wrap; gap: 6px; margin: 2px 0 0 4px; align-items: center; }
.row.helper .feedback-actions { align-self: stretch; }
.row.user .feedback-actions { align-self: stretch; justify-content: flex-end; }
.feedback-btn { min-height: 38px; padding: 4px 10px; border: 1px solid var(--line); border-radius: 18px; background: var(--surface); color: var(--muted); font-size: .85rem; }
.feedback-btn:disabled { opacity: .6; cursor: wait; }
.exam-rating { display: flex; flex-wrap: wrap; gap: 6px 10px; align-items: center; margin: 6px 0 0 4px; align-self: stretch; }
.exam-rating-q { font-size: .92rem; font-weight: 600; }
.exam-rating-btns { display: flex; gap: 6px; }
.exam-rating-btn { min-width: 40px; min-height: 40px; border: 1px solid var(--line); border-radius: 20px; background: var(--surface); color: var(--text); font-weight: 700; }
.exam-rating-btn:disabled { opacity: .6; cursor: wait; }
.exam-rating-scale { font-size: .8rem; }
.sum-cell .exam-ratings-dist { font-size: .8rem; }
.listen svg { width: 22px; height: 22px; fill: currentColor; }

.row.helper.speaking .helper-mascot img { animation: mascot-talk .55s ease-in-out infinite; }
.row.helper.speaking .helper-mascot::after { opacity: 1; animation: mascot-beak .22s ease-in-out infinite alternate; }
@keyframes mascot-talk { 0%, 100% { transform: translateY(0); } 50% { transform: translateY(-2px); } }
@keyframes mascot-beak { to { transform: scaleY(2.5); } }

/* Ajattelutila (#365): pohtiva lintu (pää kallellaan, hidas keinunta) ja himmeä kipinä, joka tuikkii hiljaa. Vain transform ja opacity. */
.thinking { display: flex; align-items: center; gap: 10px; min-height: 52px; }
.thinking-bird { position: relative; display: block; flex: 0 0 40px; width: 40px; height: 40px; margin-top: 12px; }
.thinking-bird > img:first-child { display: block; width: 100%; height: 100%; transform: rotate(-8deg); transform-origin: 50% 90%; animation: thinking-sway 2.4s ease-in-out infinite; }
.thinking-spark { position: absolute; right: -4px; top: -12px; width: 12px; height: 12px; opacity: .55; animation: thinking-twinkle 1.8s ease-in-out infinite; }
.thinking-text { color: var(--muted); font-size: .95rem; }
.thinking-text:empty { display: none; }
@keyframes thinking-sway { 0%, 100% { transform: rotate(-8deg); } 50% { transform: rotate(-3deg); } }
@keyframes thinking-twinkle { 0%, 100% { opacity: .25; transform: scale(.8); } 50% { opacity: .75; transform: scale(1); } }
@media (prefers-reduced-motion: reduce) {
  .thinking-bird > img:first-child, .thinking-spark, .row.helper.speaking .helper-mascot img, .row.helper.speaking .helper-mascot::after { animation: none; }
  .row.helper.speaking .helper-mascot { outline: 2px solid var(--primary); outline-offset: 2px; border-radius: 50%; }
  .row.helper.speaking .helper-mascot::after { transform: scaleY(2.5); }
  #chat { scroll-behavior: auto; }
}

/* Tyhjä tila (#366, public/tyhja-tila.js): lintu alustalla, teksti ja yksi kehotus. Alusta on sama vaalea sininen kuin sovelluskuvakkeessa. */
.empty-state { display: flex; flex-direction: column; align-items: center; gap: 12px; text-align: center; padding: 24px 12px; animation: empty-in .4s ease-out both; }
.empty-bird { width: 96px; height: 96px; border-radius: 50%; background: #eaf1ff; display: grid; place-items: center; }
.empty-bird img { width: 64px; height: 64px; display: block; }
.empty-text { margin: 0; max-width: 32ch; color: var(--text); }
.empty-action { min-height: 48px; }
@keyframes empty-in { from { opacity: 0; transform: translateY(6px); } to { opacity: 1; transform: none; } }
@media (prefers-color-scheme: dark) { :root:not([data-theme="light"]) .empty-bird { background: #1d2a43; } }
@media (prefers-reduced-motion: reduce) { .empty-state { animation: none; } }

.notice { align-self: center; text-align: center; color: var(--muted); font-size: 0.95rem; max-width: 90%; }
.notice.error { color: var(--error); }
.notice.limit { color: var(--text); background: var(--surface); border: 1px solid var(--line); border-radius: 16px; padding: 6px 14px; }
.notice.cut .card-actions { justify-content: center; }

/* Aiemmat keskustelut */
.new-btn {
  display: inline-flex; align-items: center; gap: 4px; min-height: 40px; padding: 0 12px 0 10px; margin-left: 6px;
  border-radius: 20px; border: 1px solid var(--line); background: var(--surface); color: var(--primary); font-weight: 600;
}
.new-btn svg { fill: currentColor; }
.new-btn:disabled { opacity: .4; }
.mode-card { background: var(--surface); border: 1px solid var(--line); border-radius: 20px; padding: 14px 16px; }
.mode-card h3 { margin: 0 0 6px; font-size: 1.05rem; }
.mode-card ul { margin: 0; padding-left: 20px; display: flex; flex-direction: column; gap: 4px; }
.card-actions { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 12px; }
.card-actions .quick { align-self: auto; min-height: 42px; padding: 0 14px; font-size: 0.95rem; }
.card-switch { margin: 10px 0 0; color: var(--muted); font-size: 0.95rem; }
.card-switch .link-btn { min-height: 36px; padding: 0 6px; }
.quick.suggest { margin-top: 6px; }
.bubble .inline-new-conv { display: flex; margin-top: 10px; min-height: 42px; padding: 0 14px; font-size: 0.95rem; }
.move-bar { display: flex; flex-wrap: wrap; align-items: center; gap: 2px 4px; margin-top: 4px; color: var(--muted); font-size: 0.92rem; }
.move-bar .link-btn { min-height: 36px; padding: 0 6px; }
.move-bar.highlight { gap: 8px; margin-top: 8px; }
.move-bar.highlight .move-label { flex-basis: 100%; }
.move-bar.highlight .quick { min-height: 42px; padding: 0 14px; font-size: 0.95rem; }
.quick.secondary, .card-btn.secondary { border-color: var(--line); color: var(--text); font-weight: 500; }
.archive-box { max-width: 720px; margin: 8px auto 0; padding-bottom: calc(env(safe-area-inset-bottom) + 24px); }
.archive-item { display: flex; align-items: stretch; gap: 8px; margin-top: 10px; }
.archive-open {
  flex: 1; min-width: 0; text-align: left; display: flex; flex-direction: column; gap: 4px; padding: 12px 14px;
  border: 1px solid var(--line); border-radius: 16px; background: var(--surface);
}
.archive-open b { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.archive-open small { color: var(--muted); }
.archive-item .btn { align-self: center; }

/* Palkinnot */
.brand { margin-right: auto; }
.stars-btn {
  min-height: 40px; padding: 0 14px; border-radius: 20px; border: 1px solid var(--line);
  background: var(--surface); font-weight: 700; white-space: nowrap; display: inline-flex; align-items: center;
}
.goal-reminder-indicator { display: inline-flex; align-items: center; justify-content: center; width: 23px; height: 23px; margin-left: 6px; border-radius: 50%; background: #d85a30; color: #fff; font-size: 0.8rem; line-height: 1; }
.stars-btn.bump { animation: bump .6s ease; }
@keyframes bump { 0% { transform: scale(1); } 40% { transform: scale(1.25); } 100% { transform: scale(1); } }
.star-pop { margin-top: 4px; font-weight: 700; color: var(--primary); animation: pop .5s ease; }
@keyframes pop { 0% { transform: scale(.4); opacity: 0; } 70% { transform: scale(1.2); opacity: 1; } 100% { transform: scale(1); } }
.notice.reward {
  display: flex; align-items: center; gap: 10px; text-align: left; color: var(--text); font-weight: 600;
  background: var(--surface); border: 1px solid var(--primary); border-radius: 18px; padding: 10px 16px; animation: pop .5s ease;
}
.reward-icon { font-size: 1.8rem; line-height: 1; }
@media (prefers-reduced-motion: reduce) { .stars-btn.bump, .star-pop, .notice.reward { animation: none; } }
.reward-box { max-width: 720px; margin: 16px auto 0; display: flex; flex-direction: column; gap: 12px; padding-bottom: calc(env(safe-area-inset-bottom) + 24px); }
.rw-card { background: var(--surface); border: 1px solid var(--line); border-radius: 20px; padding: 16px; }
.rw-card h3 { margin: 0 0 6px; font-size: 1.05rem; }
.rw-card p { margin: 6px 0 0; }
.game-box { max-width: 720px; margin: 16px auto 0; padding: 16px; border: 1px solid var(--line); border-radius: 20px; background: var(--surface); }
.game-box h3 { margin: 0 0 10px; }
.game-box > p { margin: 8px 0; }
.game-time, .game-clock, .game-progress { color: var(--muted); font-variant-numeric: tabular-nums; }
.game-time { font-weight: 700; }
.game-description { font-weight: 600; }
.game-actions { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; margin-top: 16px; }
.game-actions .btn { min-height: 48px; }
.game-options { display: grid; gap: 8px; margin: 12px 0; }
.game-option { min-height: 50px; padding: 10px 14px; border: 1px solid var(--primary); border-radius: 14px; background: var(--bg); text-align: left; }
.game-option:focus-visible, .game-number-card:focus-visible, .game-answer-form button:focus-visible, .game-actions button:focus-visible { outline: 3px solid var(--primary); outline-offset: 2px; }
.game-option:disabled { opacity: .65; cursor: default; }
.game-number-cards { display: grid; grid-template-columns: repeat(4, minmax(56px, 1fr)); gap: 10px; margin: 16px 0; }
.game-number-card { min-height: 68px; border: 2px solid var(--primary); border-radius: 18px; background: var(--bg); color: var(--text); font-size: 1.5rem; font-weight: 700; }
.game-number-card.selected { background: var(--primary); color: var(--primary-text); transform: translateY(-3px); }
.game-number-card:disabled { opacity: .65; cursor: default; }
.game-answer-form { display: flex; flex-wrap: wrap; gap: 8px; margin: 12px 0; }
.game-answer { flex: 1; min-width: 120px; min-height: 48px; padding: 8px 12px; border: 1px solid var(--line); border-radius: 14px; background: var(--bg); }
.game-answer-form .btn { min-height: 48px; }
.game-feedback { min-height: 1.5em; font-weight: 600; }
.game-feedback.correct { color: #16784e; }
.game-feedback.incorrect, .game-error { color: var(--error); }
.game-hint, .game-notice { border-left: 3px solid var(--primary); padding: 8px 12px; background: var(--bg); }
.diagnostic-game { display: grid; gap: 8px; margin: 18px 0; padding: 16px; border: 1px solid var(--line); border-radius: 16px; background: var(--bg); }
.diagnostic-game h3, .diagnostic-game p { margin: 0; }
.diagnostic-topic-label { display: grid; gap: 6px; font-weight: 600; }
.diagnostic-topic { width: 100%; min-height: 48px; padding: 8px 12px; border: 1px solid var(--line); border-radius: 12px; background: var(--surface); color: var(--text); font: inherit; }
.diagnostic-form { display: grid; gap: 14px; margin: 14px 0; }
.diagnostic-form fieldset { display: grid; gap: 8px; min-width: 0; margin: 0; padding: 12px; border: 1px solid var(--line); border-radius: 14px; }
.diagnostic-form legend { padding: 0 4px; font-weight: 700; }
.diagnostic-choice { display: flex; align-items: flex-start; gap: 10px; padding: 9px; border-radius: 10px; background: var(--bg); }
.diagnostic-choice input { flex: 0 0 auto; width: 20px; height: 20px; margin: 2px 0 0; accent-color: var(--primary); }
.diagnostic-summary-line { padding: 8px 0; border-bottom: 1px solid var(--line); }
.rw-card.hero { text-align: center; }
.rw-figure { font-size: 4.5rem; line-height: 1.1; }
.rw-tree { position: relative; width: 100%; max-width: 440px; margin: 0 auto 6px; aspect-ratio: 4 / 3; border-radius: 16px; overflow: hidden; background: var(--bg); display: flex; align-items: center; justify-content: center; }
.rw-tree svg { display: block; width: 100%; height: 100%; }
.tree-fact { color: var(--muted); }
.tree-nav { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; }
.tree-chip { display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 2px; min-height: 64px; padding: 8px 6px; text-align: center; font: inherit; color: var(--text); background: var(--surface); border: 1px solid var(--line); border-radius: 16px; font-size: 0.85rem; }
button.tree-chip { cursor: pointer; }
.tree-chip small { color: var(--muted); font-size: 0.72rem; }
.tree-chip.locked { opacity: .7; }
.tree-path { list-style: none; margin: 8px 0 0; padding: 0; display: flex; flex-direction: column; gap: 4px; }
.tree-path li { display: flex; justify-content: space-between; align-items: center; gap: 8px; padding: 4px 2px; border-bottom: 1px solid var(--line); }
.tree-path li.locked { color: var(--muted); }
.tree-path small { color: var(--muted); white-space: nowrap; }
.rw-stars { font-size: 1.3rem; font-weight: 700; }
.bar { height: 12px; border-radius: 6px; background: var(--bg); border: 1px solid var(--line); overflow: hidden; margin-top: 10px; }
.bar-fill { height: 100%; background: var(--primary); border-radius: 6px; }
.rw-stats { display: grid; grid-template-columns: repeat(4, 1fr); gap: 8px; text-align: center; }
.rw-stats .sum-cell { display: flex; flex-direction: column; gap: 2px; }
.rw-stats .sum-cell span { color: var(--muted); font-size: 0.8rem; }
.badge-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(130px, 1fr)); gap: 8px; margin-top: 8px; }
.badge { display: flex; flex-direction: column; align-items: center; text-align: center; gap: 2px; padding: 10px 6px; border-radius: 14px; background: var(--bg); font-size: 0.9rem; }
.badge small { color: var(--muted); font-size: 0.78rem; }
.badge-icon { font-size: 1.8rem; line-height: 1.2; }
.badge.locked { opacity: .55; }
.use-line.reached { color: var(--primary); font-weight: 600; }
.rename.goal { flex-wrap: wrap; }
.rename.goal input[type="number"] { flex: 0 0 96px; }
.rename.goal select { flex: 1 1 220px; min-width: 0; min-height: 46px; border-radius: 23px; border: 1px solid var(--line); background: var(--bg); color: var(--text); padding: 0 12px; font: inherit; }
.rename.goal input[type="text"] { flex-basis: 100%; order: 1; }

.bottom { padding: 8px 12px calc(env(safe-area-inset-bottom) + 8px); background: var(--bg); }
.attach {
  display: flex; align-items: center; gap: 12px; margin-bottom: 8px;
  background: var(--surface); border: 1px solid var(--line); border-radius: 16px; padding: 8px;
}
.thumbs { display: flex; gap: 6px; }
.thumb { position: relative; width: 56px; height: 56px; padding: 0; border: 0; border-radius: 10px; overflow: hidden; background: var(--bg); }
.thumb img { width: 100%; height: 100%; object-fit: cover; display: block; }
.thumb span {
  position: absolute; top: 2px; right: 2px; width: 20px; height: 20px; border-radius: 50%;
  background: rgba(8, 14, 28, .7); color: #fff; font-size: 0.875rem; line-height: 1.25rem; text-align: center;
}
.attach .link-btn { margin-left: auto; white-space: nowrap; }
.bubble .imgs { display: grid; grid-template-columns: repeat(2, 1fr); gap: 6px; margin-bottom: 8px; }
.bubble .imgs img { width: 100%; height: 110px; max-height: none; object-fit: cover; margin: 0; }
.attach-label { flex: 1; font-size: 0.95rem; font-weight: 600; }
.file-attachment { margin-bottom: 6px; font-size: 0.9rem; font-weight: 600; overflow-wrap: anywhere; }
.page-source a { color: inherit; text-decoration: underline; }
.page-source .page-host { font-weight: 400; opacity: .8; }
.page-sheet { display: flex; flex-direction: column; gap: 10px; }
.page-sheet .page-hint { margin: 0 16px; color: var(--muted); font-size: 0.92rem; }
.page-sheet input[type="url"] { margin: 0 4px; min-height: 52px; padding: 0 14px; border: 1px solid var(--line); border-radius: 14px; font: inherit; background: var(--surface); color: inherit; }
.page-sheet .page-msg { margin: 0 16px; font-size: 0.92rem; }
.page-sheet .page-msg.error { color: var(--error); margin: 0 16px; }
.quick, .card-btn, .idea-open {
  align-self: flex-start; min-height: 48px; padding: 0 18px; border-radius: 24px;
  border: 1px solid var(--primary); background: var(--surface); color: var(--primary); font-weight: 600;
}
.choices { display: flex; flex-direction: column; gap: 8px; margin-top: 8px; align-self: stretch; }
.choice {
  display: flex; align-items: center; gap: 12px; min-height: 52px; padding: 8px 16px; text-align: left;
  border: 1px solid var(--primary); border-radius: 16px; background: var(--surface);
}
.choice:active { background: var(--bg); }
.link-btn { border: 0; background: transparent; color: var(--primary); min-height: 44px; padding: 0 8px; text-decoration: underline; }

#composer { display: flex; align-items: flex-end; gap: 8px; }
#input {
  flex: 1; resize: none; max-height: 140px; min-height: 52px;
  padding: 13px 16px; border-radius: 26px;
  border: 1px solid var(--line); background: var(--surface);
}
#input:focus, .screen input:focus { outline: 3px solid color-mix(in srgb, var(--primary) 45%, transparent); outline-offset: 1px; }
.round {
  width: 52px; height: 52px; flex: none; border-radius: 50%;
  border: 1px solid var(--line); background: var(--surface); color: var(--primary);
  display: grid; place-items: center;
}
.round.primary { background: var(--primary); color: var(--primary-text); border-color: transparent; }
.round.on { background: #e53935; color: #fff; border-color: transparent; }
.round:disabled { opacity: .5; }
/* Viestikenttä (#176): DOM-järjestys vastaa vaakarivin näkyvää järjestystä.
   Pystyssä olevalla puhelimella CSS-ruudukko sijoittaa napit kentän oikealle puolelle. */
@media (max-width: 600px) and (min-height: 560px) {
  #composer {
    display: grid; grid-template-columns: minmax(0, 1fr) 44px;
    grid-template-areas: "input attach" "input mic" "input send";
  }
  #input { grid-area: input; }
  #attachBtn { grid-area: attach; }
  #micBtn { grid-area: mic; }
  #sendBtn { grid-area: send; }
  #attachBtn, #micBtn, #sendBtn { width: 44px; height: 44px; }
  #input { min-height: 102px; max-height: 160px; }
  #composer:has(#micBtn:not([hidden])) #input { min-height: 152px; }
  /* Monivalinnan aikana (compact) napit ovat kentän vieressä samalla rivillä ja kenttä on matala. */
  #composer.compact { grid-template-columns: minmax(0, 1fr) repeat(3, 44px); grid-template-areas: "input attach mic send"; align-items: end; }
  #composer.compact:has(#micBtn[hidden]) { grid-template-columns: minmax(0, 1fr) repeat(2, 44px); grid-template-areas: "input attach send"; }
  #composer.compact #input, #composer.compact:has(#micBtn:not([hidden])) #input { min-height: 44px; padding-top: 10px; padding-bottom: 10px; }
}
.ai-note { margin: 6px 4px 0; font-size: 0.8rem; color: var(--muted); text-align: center; }

.screen {
  position: fixed; inset: 0; background: var(--bg); z-index: 20;
  display: flex; align-items: center; justify-content: center;
  padding: calc(env(safe-area-inset-top) + 16px) 16px calc(env(safe-area-inset-bottom) + 16px);
}
.screen.scroll { display: block; overflow-y: auto; }
.screen .card { max-height: 100%; overflow-y: auto; }
.card { background: var(--surface); border: 1px solid var(--line); border-radius: 28px; padding: 28px 24px; text-align: center; width: 100%; max-width: 420px; }
.card img { border-radius: 18px; }
.card h2 { margin: 12px 0 4px; }
.card p { color: var(--muted); margin: 0 0 16px; }
.screen input[type="password"], .screen input[type="text"] {
  width: 100%; padding: 14px 16px; border-radius: 16px; border: 1px solid var(--line);
  background: var(--bg); margin-bottom: 12px; text-align: center; font-size: 1.1rem;
}
.big { width: 100%; min-height: 52px; border-radius: 26px; border: 0; font-weight: 600; }
.big.primary { background: var(--primary); color: var(--primary-text); }
.error, .card p.error { color: var(--error); margin: 14px 0 0; }
.card .link-btn { margin-top: 10px; font-size: 0.95rem; color: var(--muted); }
.card a.link-btn { display: flex; align-items: center; justify-content: center; text-align: center; }

.sheet-wrap { position: fixed; inset: 0; background: rgba(8, 14, 28, .5); z-index: 30; display: flex; align-items: flex-end; justify-content: center; }
.menu-sheet-wrap { align-items: flex-start; justify-content: flex-end; padding: calc(env(safe-area-inset-top) + 60px) max(16px, calc((100vw - 720px) / 2 + 16px)) 12px; }
.sheet {
  width: 100%; max-width: 720px; background: var(--surface);
  max-height: 90dvh; overflow-y: auto;
  border-radius: 24px 24px 0 0; padding: 12px 12px calc(env(safe-area-inset-bottom) + 12px);
}
.menu-sheet-wrap .menu-sheet { width: min(380px, 100%); max-width: 380px; max-height: calc(100dvh - 88px); border-radius: 20px; padding: 8px; box-shadow: 0 12px 36px rgba(8, 14, 28, .2); }
.sheet-title { margin: 4px 16px 8px; font-weight: 600; }
.menu-group + .menu-group { border-top: 1px solid var(--line); }
.menu-section-title { margin: 10px 16px 2px; color: var(--muted); font-size: 0.82rem; font-weight: 700; }
.menu-item {
  width: 100%; min-height: 56px; border: 0; background: transparent; text-align: left;
  padding: 0 16px; border-radius: 14px; display: flex; align-items: center; justify-content: space-between; gap: 12px;
}
.menu-item:active { background: var(--bg); }
.menu-item:disabled { opacity: .65; cursor: not-allowed; }
.menu-item.subtle { color: var(--muted); }
.role-logout { margin-top: 16px; padding-top: 8px; border-top: 1px solid var(--line); }
.menu-item.info:active { background: transparent; }
.grade-row { color: inherit; }
.menu-item.toggle input { width: 26px; height: 26px; accent-color: var(--primary); flex: none; }
.text-size-setting { min-width: 0; margin: 8px 0 0; padding: 0; border: 0; }
.text-size-setting legend { margin-bottom: 8px; font-weight: 600; }
.text-size-control { display: flex; align-items: center; gap: 12px; }
.text-size-control input { flex: 1; min-width: 0; min-height: 44px; margin: 0; accent-color: var(--primary); cursor: pointer; }
.text-size-control output { min-width: 4.5em; font-variant-numeric: tabular-nums; font-weight: 600; text-align: right; }
.text-size-ticks { display: flex; justify-content: space-between; margin: -2px 4.5em 0 0; color: var(--muted); font-size: 0.8rem; }
.speech-rate-setting { min-width: 0; margin: 12px 0 0; padding: 0; border: 0; }
.speech-rate-setting legend { margin-bottom: 8px; font-weight: 600; }
.speech-rate-options { display: flex; gap: 8px; }
.speech-rate-option {
  display: flex; flex: 1; flex-direction: column; align-items: center; justify-content: center; gap: 2px;
  min-width: 0; min-height: 68px; padding: 6px; border: 1px solid var(--line); border-radius: 12px; text-align: center; cursor: pointer;
}
.speech-rate-option:has(input:checked) { border-color: var(--primary); background: var(--bg); }
.speech-rate-option input { width: 22px; height: 22px; margin: 0; accent-color: var(--primary); }
.speech-rate-option span { overflow-wrap: anywhere; }
.speech-rate-option:focus-within { outline: 3px solid var(--primary); outline-offset: 2px; }
.speech-rate-option:has(input:checked) { border-color: var(--primary); background: var(--bg); }
.settings-box { max-width: 720px; margin: 18px auto 0; padding-bottom: calc(env(safe-area-inset-bottom) + 24px); }
.settings-section { margin: 0 0 20px; padding: 12px 14px; border: 1px solid var(--line); border-radius: 16px; background: var(--surface); }
.settings-section h3 { margin: 0 0 8px; font-size: 1.05rem; }
.settings-section p { margin: 6px 0; }
.settings-section .menu-item { padding-right: 4px; padding-left: 4px; }
.settings-box > .menu-item { text-decoration: none; }
.rw-profile h3 { margin: 0 0 10px; }
.profile-list { display: grid; grid-template-columns: minmax(110px, 1fr) 2fr; gap: 8px 12px; margin: 0; }
.profile-list dt { color: var(--muted); }
.profile-list dd { margin: 0; font-weight: 600; }

.parent-head { display: flex; align-items: center; justify-content: space-between; max-width: 720px; margin: 0 auto; }
.parent-head h2 { margin: 0; }
.pin-form, #parentApp { max-width: 720px; margin: 16px auto 0; }
.pin-form p { color: var(--muted); }
/* Keskustelut: haku, päivänauha, päivän aikajana ja keskustelukortit */
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
.chat-search { width: 100%; min-height: 48px; margin-top: 8px; padding: 0 14px; border-radius: 14px; border: 1px solid var(--line); background: var(--surface); font-size: 1rem; }
.search-info { display: flex; flex-wrap: wrap; align-items: center; gap: 6px; margin-top: 8px; font-size: 0.9rem; color: var(--muted); }
.search-info .link-btn { min-height: 36px; font-size: 0.9rem; }
.hit-day { min-height: 34px; padding: 0 10px; border-radius: 17px; border: 1px solid var(--line); background: var(--surface); font-size: 0.85rem; }
.day-strip-wrap { margin-top: 12px; border-bottom: 1px solid var(--line); }
.day-strip { position: relative; display: flex; align-items: flex-end; gap: 2px; overflow-x: auto; padding-bottom: 6px; scrollbar-width: thin; }
.day-btn { flex: none; width: 38px; display: flex; flex-direction: column; align-items: center; gap: 2px; padding: 4px 0; border: 0; border-radius: 10px; background: transparent; color: var(--muted); font-size: 0.72rem; line-height: 1.2; }
.day-btn .day-n { min-height: 1.2em; }
.day-btn .day-bar { width: 14px; border-radius: 3px; background: color-mix(in srgb, var(--primary) 55%, transparent); }
.day-btn.empty .day-bar { background: var(--line); }
.day-btn.weekend .day-wd { opacity: 0.7; }
.day-btn .day-d { font-weight: 600; }
.day-btn[aria-pressed="true"] { background: var(--primary); color: var(--primary-text); }
.day-btn[aria-pressed="true"] .day-bar { background: var(--primary-text); }
.day-btn.hit .day-n::after { content: ""; display: inline-block; width: 6px; height: 6px; margin-left: 2px; border-radius: 50%; background: #e0a100; vertical-align: middle; }
.day-more { flex: none; align-self: stretch; padding: 0 8px; border: 0; background: transparent; color: var(--primary); font-size: 0.8rem; white-space: nowrap; }
.day-nav { display: flex; align-items: center; gap: 8px; margin: 12px 0 6px; }
.day-title { flex: 1; min-width: 0; text-align: center; }
.day-title h3 { margin: 0; font-size: 1.05rem; }
.day-title .muted { font-size: 0.85rem; }
.day-step { width: 44px; height: 44px; flex: none; border-radius: 50%; border: 1px solid var(--line); background: var(--surface); font-size: 1.4rem; line-height: 1; color: var(--primary); }
.day-step:disabled { opacity: 0.35; cursor: default; }
.timeline-box { margin-bottom: 12px; }
.timeline { position: relative; background: var(--surface); border: 1px solid var(--line); border-radius: 12px; }
.timeline .seg { position: absolute; height: 10px; min-width: 6px; padding: 0; border: 0; border-radius: 3px; }
.timeline .seg.dim { opacity: 0.2; }
.timeline .seg::before { content: ""; position: absolute; inset: -8px -2px; } /* isompi napautusalue */
.timeline.slots { height: 48px; }
.timeline .slot { position: absolute; bottom: 4px; padding: 0; border: 0; border-radius: 2px 2px 0 0; background: var(--primary); }
.timeline .slot.dim { opacity: 0.2; }
.mode-task { background: var(--primary); }
.mode-study { background: #1d9e75; }
.mode-exam { background: #d85a30; }
.timeline-axis { position: relative; height: 1.2em; margin: 2px 8px 0; font-size: 0.72rem; color: var(--muted); }
.timeline-axis span { position: absolute; transform: translateX(-50%); }
.timeline-legend { display: flex; flex-wrap: wrap; gap: 12px; margin-top: 2px; font-size: 0.75rem; color: var(--muted); }
.timeline-legend .swatch { display: inline-block; width: 10px; height: 10px; border-radius: 3px; margin-right: 4px; vertical-align: -1px; }
.convo { background: var(--surface); border: 1px solid var(--line); border-radius: 16px; margin-bottom: 10px; scroll-margin-top: 12px; }
.convo[open] { border-color: color-mix(in srgb, var(--primary) 45%, var(--line)); }
.convo summary { list-style: none; cursor: pointer; padding: 10px 14px; border-radius: 16px; }
.convo summary::-webkit-details-marker { display: none; }
.convo-head { display: flex; flex-wrap: wrap; justify-content: space-between; gap: 2px 10px; font-size: 0.92rem; }
.convo-who b { color: var(--text); }
.convo-when { color: var(--muted); font-size: 0.85rem; }
.convo-when::after { content: " ▾"; }
.convo[open] .convo-when::after { content: " ▴"; }
.convo-topic { margin-top: 2px; color: var(--muted); font-size: 0.88rem; overflow-wrap: anywhere; }
.convo-extra, .convo-hits { display: block; font-size: 0.8rem; }
.convo-hits { color: var(--text); font-weight: 600; }
.convo-body { padding: 0 14px 10px; border-top: 1px solid var(--line); }
.convo mark { background: #ffe58a; color: #17202e; border-radius: 3px; padding: 0 1px; }
.entry { margin-top: 10px; font-size: 0.95rem; }
.entry .time { color: var(--muted); font-size: 0.78rem; text-align: center; }
.entry .photo-note { display: block; color: var(--muted); font-size: 0.85rem; }
.entry .page-source { display: block; color: var(--muted); font-size: 0.85rem; }
.entry .photo-desc { margin: 0.35rem 0; color: var(--muted); font-size: 0.85rem; }
.entry .photo-desc summary { cursor: pointer; }
.entry .photo-desc pre { margin: 0.35rem 0 0; white-space: pre-wrap; word-break: break-word; font: inherit; }
/* Tekoälyn konteksti (#205): vain ylläpidon keskusteluhistoriassa */
.ctx-box, .ctx-status { margin: 0.35rem 0; color: var(--muted); font-size: 0.85rem; }
.ctx-box summary, .ctx-status summary, .ctx-section summary { cursor: pointer; }
.ctx-body { margin-top: 0.35rem; }
.ctx-section { margin: 0.25rem 0 0.25rem 0.5rem; }
.ctx-section pre, .ctx-msg { margin: 0.2rem 0 0.4rem; white-space: pre-wrap; word-break: break-word; font: inherit; max-height: 24rem; overflow: auto; }
.ctx-msg-head { margin: 0.4rem 0 0; font-weight: 600; }
.ctx-meta, .ctx-note { margin: 0.25rem 0; }
.ctx-recent { margin: 0.25rem 0; padding-left: 1.1rem; }
/* Muistikortit mallin kontekstissa (#167): vain ylläpidon keskusteluhistoriassa */
.entry .card-source { margin: 0.35rem 0; color: var(--muted); font-size: 0.85rem; }
.entry .card-source summary { cursor: pointer; }
.entry .card-source ul { margin: 0.25rem 0; padding-left: 1.1rem; }
.entry .card-source .card-used { font-weight: 600; }
.entry p { margin: 4px 0 0; white-space: pre-wrap; overflow-wrap: anywhere; }
.entry .said { max-width: 88%; padding: 8px 12px; border-radius: 14px; }
.entry .said.child { margin-left: auto; background: color-mix(in srgb, var(--primary) 14%, var(--surface)); border-bottom-right-radius: 4px; }
.entry .said.helper { background: var(--bg); border: 1px solid var(--line); border-bottom-left-radius: 4px; }
.entry .said.helper:has(.diagram) { max-width: 100%; }
.entry.hit .time { color: var(--text); font-weight: 600; }

.grade-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 12px; margin-top: 8px; }
.grade-grid button {
  min-height: 72px; border-radius: 20px; border: 1px solid var(--line);
  background: var(--bg); font-size: 1.6rem; font-weight: 700; color: var(--primary);
}
.grade-caption { grid-column: 1 / -1; margin: 6px 0 0; color: var(--muted); font-size: 0.95rem; text-align: left; }
.grade-grid button.group { grid-column: 1 / -1; min-height: 52px; font-size: 1.05rem; }
.grade-grid button:active, .grade-grid button.current { background: var(--primary); color: var(--primary-text); }
.muted { color: var(--muted); font-size: 0.95rem; }

.filter { display: flex; align-items: center; gap: 12px; color: var(--muted); margin-bottom: 4px; }
.filter select {
  flex: 1; min-height: 48px; padding: 0 12px; border-radius: 14px;
  border: 1px solid var(--line); background: var(--surface); color: inherit; font-size: 1rem;
}
.ms-btn { display: flex; align-items: center; justify-content: center; text-decoration: none; margin-top: 8px; }
.big.auth-provider-btn {
  gap: 12px; padding: 5px 12px; border: 1px solid; border-radius: 4px;
  background: #fff; color: #1f1f1f; font: 500 15px/20px Arial, sans-serif;
  text-align: center; text-decoration: none;
}
.auth-provider-btn .auth-provider-logo { display: block; flex: none; width: 20px; height: 20px; object-fit: contain; }
.auth-provider-btn.auth-google-btn { border-color: #747775; }
.auth-provider-btn.auth-microsoft-btn { border-color: #8c8c8c; }
.auth-provider-label { overflow-wrap: anywhere; }
.account-row .auth-provider-btn {
  display: flex; flex: 1 1 100%; width: 100%; min-height: 52px; justify-content: flex-start;
  gap: 12px; padding: 6px 14px; border-radius: 14px; background: var(--surface);
  color: var(--text); font: inherit; text-align: left;
}
.account-row .auth-provider-btn .auth-provider-logo { width: 24px; height: 24px; }
.account-row .auth-provider-label { flex: 0 1 auto; }
/* Apurin kaavio (Mermaid): täysi leveys kuplassa, leveä kaavio vierii sivusuunnassa. */
.diagram { display: block; margin: 10px 0; padding: 8px; border-radius: 12px; background: var(--surface); border: 1px solid var(--line); overflow-x: auto; text-align: center; }
.diagram svg { max-width: 100%; height: auto; }
.diagram.waiting, .diagram.failed { color: var(--muted); font-size: 0.9rem; font-style: italic; }
.row.helper .bubble:has(.diagram) { max-width: 100%; width: 100%; }
/* Molekyyli (SMILES): luonnollinen koko, pieni molekyyli ei veny koko kuplan levyiseksi. */
.diagram.molecule svg { max-height: 260px; width: auto; }
.sso-box { margin-top: 14px; }
.legal { margin: 18px 0 0; font-size: 0.85rem; color: var(--muted); }
.legal a { color: var(--muted); }
a.menu-item { text-decoration: none; }
.sso-box p { margin: 0 0 4px; font-size: 0.9rem; }
.secondary-btn { background: var(--surface); color: var(--text); border: 1px solid var(--line); }
.account-list { display: flex; flex-direction: column; gap: 10px; margin-top: 12px; }
.account-row { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; padding: 12px 14px; border: 1px solid var(--line); border-radius: 16px; background: var(--surface); }
.account-row span { flex: 1 1 200px; overflow-wrap: anywhere; }
.admin-who { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; max-width: 720px; margin: 8px auto 0; }
.admin-who .switch-msg { flex-basis: 100%; margin: 0; }
/* Järjestelmä-välilehden alivälilehdet ja osiot (#285) */
.tabs.subtabs { padding: 3px; border-radius: 14px; margin-bottom: 12px; }
.tabs.subtabs button { min-height: 40px; min-width: 0; padding: 0 6px; border-radius: 11px; font-size: 0.9rem; }
.tabs button[hidden] { display: none; }
.sys-section { margin: 0 0 20px; }
.sys-section h3 { margin: 0 0 2px; font-size: 1.05rem; }
.sys-section > p.muted { margin: 0 0 8px; }
.sys-section > select { width: 100%; min-height: 48px; padding: 0 12px; border-radius: 14px; border: 1px solid var(--line); background: var(--surface); color: inherit; font-size: 1rem; }
.sys-section .info { margin: 8px 4px; }
.saved-note { color: var(--primary); font-weight: 600; margin: -10px 0 16px; }
.admins-box h3 { margin: 0 0 2px; font-size: 1.05rem; }
.admin-row { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; padding: 8px 0; border-bottom: 1px solid var(--line); }
.admin-row b { flex: 1 1 12em; min-width: 0; overflow-wrap: anywhere; }
.admin-add { margin-top: 10px; flex-wrap: wrap; }
.admin-add select { min-height: 46px; border-radius: 23px; border: 1px solid var(--line); background: var(--bg); padding: 0 12px; }
/* Tapahtumaloki (#155, #285): pikavalinnat, aina näkyvät suodattimet, lisäsuodattimet; leveällä taulukko, kapealla kortit */
.audit-list { font-size: 0.9rem; }
.audit-list p { margin: 4px 0; }
.audit-filters { display: flex; flex-direction: column; gap: 8px; margin: 8px 0; }
.audit-presets { display: flex; flex-wrap: wrap; gap: 6px; }
.chip-btn { min-height: 36px; padding: 0 12px; border-radius: 18px; border: 1px solid var(--line); background: var(--surface); color: var(--text); font-size: 0.9rem; font-weight: 600; }
.chip-btn[aria-pressed="true"] { background: var(--primary); border-color: var(--primary); color: var(--primary-text); }
.audit-main, .audit-extra { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; }
.audit-extra[hidden] { display: none; }
.audit-filters input[type="search"], .audit-filters select, .audit-filters input[type="date"] { min-height: 42px; padding: 0 12px; border-radius: 12px; border: 1px solid var(--line); background: var(--surface); color: inherit; font: inherit; min-width: 0; }
.audit-filters input[type="search"] { flex: 1 1 180px; }
.audit-filters select { flex: 0 1 auto; max-width: 100%; }
.audit-filters .filter { margin: 0; gap: 6px; flex-wrap: wrap; }
.audit-more-filters { align-self: flex-start; }
.audit-empty { margin: 8px 0; display: flex; flex-wrap: wrap; gap: 8px; align-items: center; }
.audit-empty p { flex-basis: 100%; }
.audit-empty [hidden] { display: none; }
.audit-table { width: 100%; border-collapse: collapse; }
.audit-table[hidden] { display: none; }
.audit-table th, .audit-table td { text-align: left; vertical-align: top; padding: 6px 8px; border-bottom: 1px solid var(--line); }
.audit-table th { color: var(--muted); font-weight: 600; font-size: 0.85rem; }
.audit-table .audit-time { white-space: nowrap; }
.audit-table .audit-target, .audit-table .audit-who { overflow-wrap: anywhere; }
.audit-cat { display: inline-block; padding: 1px 8px; border-radius: 999px; font-size: 0.8rem; font-weight: 600; white-space: nowrap; background: color-mix(in srgb, var(--muted) 16%, var(--surface)); }
.audit-cat.cat-login { background: color-mix(in srgb, #2f80ed 18%, var(--surface)); }
.audit-cat.cat-access { background: color-mix(in srgb, #9b51e0 18%, var(--surface)); }
.audit-cat.cat-change { background: color-mix(in srgb, #27ae60 20%, var(--surface)); }
.audit-cat.cat-billing { background: color-mix(in srgb, #f5a524 26%, var(--surface)); }
.audit-cat.cat-denied { background: color-mix(in srgb, #b42318 18%, var(--surface)); color: var(--danger, #b42318); }
.audit-more { margin-top: 8px; }
@media (max-width: 640px) {
  .audit-table thead { display: none; }
  .audit-table, .audit-table tbody, .audit-table tr, .audit-table td { display: block; width: auto; }
  .audit-table tr { background: var(--surface); border: 1px solid var(--line); border-radius: 14px; padding: 8px 12px; margin-bottom: 8px; }
  .audit-table td { border: 0; padding: 2px 0; }
  .audit-table td.audit-time { display: inline-block; color: var(--muted); font-size: 0.85rem; margin-right: 8px; }
  .audit-table td.audit-catcell { display: inline-block; }
  .audit-table td.audit-action { font-weight: 600; }
  .audit-table td.audit-who::before, .audit-table td.audit-target:not(:empty)::before { content: attr(data-label) ": "; color: var(--muted); }
  .audit-table td.audit-target:empty { display: none; }
}
/* Ylläpidon näkymä: välilehdet, oppilaiden kortit, yhteenveto */
.tabs { display: flex; gap: 4px; padding: 4px; background: var(--surface); border: 1px solid var(--line); border-radius: 18px; margin-bottom: 16px; }
.tabs button { flex: 1; min-height: 46px; border: 0; border-radius: 14px; background: transparent; color: var(--muted); font-size: 0.98rem; font-weight: 600; }
.tabs button[aria-selected="true"] { background: var(--primary); color: var(--primary-text); }
.tabs.modes { margin: 0 12px 4px; }
.tabs.modes button { min-height: 42px; min-width: 0; padding: 0 4px; white-space: nowrap; }
/* Kertaus-välilehti (#153): välilehden merkki kertoo tänään kerrattavat */
.tab-badge { display: inline-block; min-width: 1.4em; margin-left: 4px; padding: 0 5px; border-radius: 10px; background: var(--primary); color: var(--primary-text); font-size: 0.78rem; line-height: 1.4em; text-align: center; }
.tabs.modes button[aria-selected="true"] .tab-badge { background: var(--primary-text); color: var(--primary); }
.banner { background: color-mix(in srgb, #f5a524 18%, var(--surface)); border: 1px solid color-mix(in srgb, #f5a524 55%, var(--line)); border-radius: 16px; padding: 10px 14px; margin-bottom: 16px; font-size: 0.95rem; }
.banner summary { cursor: pointer; font-weight: 600; min-height: 32px; display: flex; align-items: center; }
.banner ul { margin: 8px 0 0; padding-left: 20px; }
.problem-detail { color: var(--muted); font-size: 0.85rem; overflow-wrap: anywhere; }
.note { color: var(--muted); font-size: 0.95rem; margin: 8px 0; }
p.error.note { color: var(--error); }
.summary { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 6px; margin-bottom: 14px; }
.sum-cell { background: var(--surface); border: 1px solid var(--line); border-radius: 14px; padding: 8px 10px; display: flex; flex-direction: column; min-width: 0; }
.sum-cell b { font-size: 1.1rem; }
.sum-cell span { color: var(--muted); font-size: 0.75rem; line-height: 1.25; }
.add-form { background: var(--surface); border: 1px solid var(--line); border-radius: 20px; padding: 14px; margin-bottom: 20px; }
.add-form label { font-weight: 600; display: block; margin-bottom: 6px; }
.add-form textarea, .add-form input[type="email"] { width: 100%; padding: 12px 14px; border-radius: 14px; border: 1px solid var(--line); background: var(--bg); resize: vertical; margin-bottom: 10px; }
.add-form textarea:focus, .add-form input[type="email"]:focus, .rename input:focus { outline: 3px solid color-mix(in srgb, var(--primary) 45%, transparent); outline-offset: 1px; }
/* Oppilaslista: yksi tiivis rivi oppilasta kohden, avattava. */
.pupil-tools { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; margin: 16px 0 8px; }
.pupil-tools input { flex: 1 1 160px; min-width: 0; min-height: 40px; border-radius: 20px; border: 1px solid var(--line); background: var(--bg); color: var(--text); padding: 0 14px; font: inherit; }
.pager { display: flex; align-items: center; justify-content: center; gap: 12px; margin: 12px 0; }
.pager[hidden] { display: none; }
.pupil-list { border: 1px solid var(--line); border-radius: 16px; background: var(--surface); overflow: hidden; }
.pupil-list:empty { display: none; }
.pupil { border-bottom: 1px solid var(--line); }
.pupil:last-child { border-bottom: 0; }
.pupil.fresh { box-shadow: inset 4px 0 0 var(--primary); }
.pupil[open] { background: var(--bg); }
/* Rivit ja sarakeotsikot jakavat saman ruudukon. Puhelimella viimeksi paikalla ja viestit ovat toisella rivillä,
   viestit Keskustelut-painikkeen alla; leveällä näytöllä kaikki on yhdellä rivillä. Otsikkorivin näkymätön
   Keskustelut-painike tekee painikkeen sarakkeesta yhtä leveän kuin riveillä. */
.pupil-head, .pupil-cols { display: grid; grid-template-columns: 0.8em minmax(0, 1fr) 5.4em auto; align-items: center; column-gap: 8px; padding: 6px 10px 6px 12px; }
.pupil-head { grid-template-areas: "arrow name name btn" ". meta last msgs"; min-height: 44px; cursor: pointer; list-style: none; }
.pupil-cols { grid-template-areas: ". name last msgs"; padding-top: 4px; padding-bottom: 4px; border-bottom: 1px solid var(--line); }
.pupil-cols .cols-spacer { grid-area: msgs; visibility: hidden; }
.sort-btn { background: none; border: 0; padding: 4px 0; max-width: 100%; white-space: normal; min-height: 32px; font: inherit; font-size: 0.78rem; font-weight: 600; line-height: 1.2; color: var(--muted); cursor: pointer; text-align: left; }
.sort-btn.on { color: var(--primary); }
.sort-name { grid-area: name; justify-self: start; }
.sort-last { grid-area: last; text-align: right; justify-self: end; }
.sort-msgs { grid-area: msgs; text-align: right; justify-self: end; }
.pupil-last, .pupil-msgs { font-size: 0.82rem; text-align: right; white-space: nowrap; font-variant-numeric: tabular-nums; }
.pupil-last { grid-area: last; color: var(--muted); }
.pupil-msgs { grid-area: msgs; }
.pupil-head::-webkit-details-marker { display: none; }
.pupil-head::before { content: "›"; grid-area: arrow; color: var(--muted); transition: transform 0.15s; }
.pupil[open] > .pupil-head::before { transform: rotate(90deg); }
.pupil-name { grid-area: name; display: flex; align-items: center; gap: 6px; min-width: 0; }
.pupil-name b { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; min-width: 0; }
.pupil-meta { grid-area: meta; color: var(--muted); font-size: 0.82rem; line-height: 1.3; min-width: 0; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.pupil-head .btn.small { grid-area: btn; justify-self: end; }
.pupil-head .pupil-btns { grid-area: btn; justify-self: end; display: flex; gap: 6px; }
.pupil-head .pupil-btns .btn.small { grid-area: auto; }
@media (max-width: 359px) {
  .pupil-head, .pupil-cols { grid-template-columns: 0.8em minmax(0, 1fr) 5em auto; }
}
@media (min-width: 700px) {
  .pupil-head, .pupil-cols { grid-template-columns: 0.8em minmax(8em, 14em) minmax(0, 1fr) 7.5em 6.5em auto; }
  .pupil-head { grid-template-areas: "arrow name meta last msgs btn"; }
  .pupil-meta { white-space: normal; }
  .pupil-cols { grid-template-areas: ". name . last msgs btn"; }
  .pupil-cols .cols-spacer { grid-area: btn; }
}
.btn.small { min-height: 32px; padding: 0 12px; font-size: 0.85rem; }
.chip.quiet { background: var(--line); color: var(--text); }
.pupil-body { padding: 0 14px 14px 30px; }
.chip { background: var(--primary); color: var(--primary-text); border-radius: 999px; padding: 1px 10px; font-size: 0.78rem; font-weight: 600; }
.code-line, .use-line { margin: 6px 0 0; font-size: 0.95rem; overflow-wrap: anywhere; }
.use-line { color: var(--muted); font-size: 0.88rem; }
.use-line.warn { color: var(--error); }
code { font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; letter-spacing: .06em; font-size: 1.02em; }
.actions { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 12px; }
/* Liitä perhetiliin: QR-koodi on aina musta valkoisella pohjalla, myös tummassa teemassa */
.claim-qr { display: block; width: min(72vw, 260px); height: auto; margin: 12px auto 4px; border-radius: 8px; background: #fff; }
#guestClaimTimer { text-align: center; }
.claim-h { margin: 18px 0 6px; font-size: 1.05rem; }
.claim-steps { margin: 0 0 8px; padding-left: 22px; display: flex; flex-direction: column; gap: 6px; }
.claim-manual { margin-top: 16px; }
.claim-manual > summary { cursor: pointer; color: var(--primary); font-weight: 600; min-height: 44px; display: flex; align-items: center; }
.btn {
  min-height: 46px; padding: 0 16px; border-radius: 23px; border: 1px solid var(--line);
  background: var(--bg); color: var(--primary); font-weight: 600; font-size: 0.95rem;
  display: inline-flex; align-items: center; justify-content: center; text-decoration: none; text-align: center;
}
.btn.wa { background: #1fa855; border-color: transparent; color: #fff; }
.btn.danger { color: var(--error); }
.btn.here { background: var(--bg); color: var(--muted); }
.btn.armed { background: var(--error); border-color: transparent; color: #fff; white-space: normal; padding: 8px 16px; }
.btn:disabled { opacity: .5; }
.more-box { margin-top: 12px;  display: flex; flex-direction: column; align-items: stretch; gap: 8px; padding-bottom: 4px; }
.rename { display: flex; gap: 8px; }
.rename input { flex: 1; min-width: 0; padding: 0 14px; min-height: 46px; border-radius: 23px; border: 1px solid var(--line); background: var(--bg); }
.info { display: grid; grid-template-columns: 1fr auto; gap: 6px 12px; margin: 16px 4px; }
.info dt { color: var(--muted); }
.info dd { margin: 0; font-weight: 600; text-align: right; overflow-wrap: anywhere; }
#moreDays { display: block; margin: 12px auto 0; }
/* Kapea puhelin: yläpalkkiin mahtuvat tähdet, Uusi ja valikko, joten sovelluksen nimi jää pelkäksi kuvakkeeksi. */
@media (max-width: 420px) {
  .brand h1 { display: none; }
  .top { gap: 6px; flex-wrap: wrap; }
}

/* Ylläpito: julkaisuhistoria */
.release-list { list-style: none; padding: 0; margin: 8px 0 0; }
/* Julkaisut (#285): tilakortti, haku ja päiväryhmät */
.release-now { background: var(--surface); border: 2px solid var(--primary); border-radius: 16px; padding: 10px 14px; margin-bottom: 8px; }
.release-now[hidden] { display: none; }
.release-now .release-badge { display: inline-block; margin-bottom: 6px; }
.release-facts { display: grid; grid-template-columns: auto 1fr; gap: 2px 12px; margin: 0; font-size: 0.9rem; }
.release-facts dt { color: var(--muted); }
.release-facts dd { margin: 0; overflow-wrap: anywhere; }
.release-search { width: 100%; min-height: 44px; padding: 0 14px; border-radius: 14px; border: 1px solid var(--line); background: var(--surface); font-size: 1rem; margin: 4px 0; }
.release-day h4 { margin: 14px 0 6px; font-size: 0.95rem; color: var(--muted); }
.release-list > li[hidden] { display: none; }
.ref-link { color: var(--primary); }
.release { background: var(--surface); border: 1px solid var(--line); border-radius: 16px; padding: 10px 14px; margin-bottom: 10px; }
.release.current { border: 2px solid var(--primary); background: color-mix(in srgb, var(--primary) 8%, var(--surface)); }
.release-head { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 6px; font-size: 0.85rem; margin-bottom: 2px; }
.release-badge { background: var(--primary); color: var(--primary-text); border-radius: 999px; padding: 2px 10px; font-weight: 600; }
.release b { display: block; overflow-wrap: anywhere; }
.release ul { margin: 6px 0 0; padding-left: 18px; font-size: 0.9rem; color: var(--muted); }
.release ul li { margin: 3px 0; overflow-wrap: anywhere; }
.release-more summary { cursor: pointer; color: var(--primary); font-size: 0.9rem; margin-top: 4px; }
.release-more ul { margin-top: 2px; }

/* Kaavion tai molekyylin suurennus: koko näyttö, kuva sovitetaan ruutuun; .zoomed suurentaa ja vierittää. */
.diagram[role=button] { cursor: zoom-in; }
.diagram[role=button]:focus-visible { outline: 3px solid color-mix(in srgb, var(--primary) 45%, transparent); outline-offset: 2px; }
.zoom-screen { position: fixed; inset: 0; z-index: 40; background: var(--bg); }
.zoom-box {
  position: absolute; inset: 0; overflow: auto; display: grid; place-items: center;
  padding: calc(env(safe-area-inset-top) + 64px) 12px calc(env(safe-area-inset-bottom) + 16px);
}
.zoom-box svg { display: block; width: 100%; height: auto; max-width: none !important; max-height: 100%; cursor: zoom-in; }
.zoom-screen.molecule .zoom-box svg { background: var(--surface); border-radius: 16px; }
.zoom-screen.zoomed .zoom-box { place-items: start; }
.zoom-screen.zoomed .zoom-box svg { width: 250%; max-height: none; cursor: zoom-out; }
.zoom-close {
  position: absolute; z-index: 1; top: calc(env(safe-area-inset-top) + 10px); right: 12px;
  width: 44px; height: 44px; border-radius: 22px; border: 1px solid var(--line);
  background: var(--surface); color: inherit; display: grid; place-items: center;
}
.zoom-close svg { fill: currentColor; }

/* Tavoitteen muistutus ja saadut palkinnot */
.remind { margin-top: 10px; }
.remind button { width: 100%; }
.prize-list { margin: 6px 0 0; padding-left: 20px; }
.prize-list li { margin: 4px 0; }
/* "Näin saat tähtiä" (#80) ja kertaustähden ilmoitus muistikorttien kertauksessa */
.rw-how-list { margin: 6px 0 0; padding: 0; list-style: none; }
.rw-how-list li { margin: 6px 0; line-height: 1.4; }
.koe-ch-star { margin-left: 6px; }
.koe-stars { margin: 10px 0 0; font-weight: 600; }
.cards-stars { display: flex; flex-direction: column; gap: 6px; margin-bottom: 10px; }
.carry { display: flex; align-items: center; gap: 8px; font-size: 0.9rem; margin: 6px 0 0; flex-basis: 100%; }
/* Valintaruutu ei veny eikä kutistu: `.rename input` (flex: 1, min-width: 0) koskisi muuten sitäkin, ja kapealla ruudulla ruutu menisi nollaleveäksi. */
.carry input[type="checkbox"] { width: 20px; height: 20px; min-width: 20px; min-height: 0; flex: 0 0 auto; margin: 0; padding: 0; }
/* Ylläpidon Perheet: oppilaiden siirto perheeseen (valintalista, paikan laji, maksettu asti) */
.move-form { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; }
.move-list { flex-basis: 100%; display: grid; gap: 0 12px; grid-template-columns: repeat(auto-fill, minmax(160px, 1fr)); max-height: 220px; overflow: auto; padding: 6px 12px; border: 1px solid var(--line); border-radius: 14px; background: var(--bg); }
.move-list .carry { margin: 0; min-height: 40px; overflow-wrap: anywhere; }
.move-form > select { flex: 1 1 160px; min-width: 0; min-height: 46px; border-radius: 23px; border: 1px solid var(--line); background: var(--bg); color: var(--text); padding: 0 12px; font: inherit; }
.move-form > .carry { flex: 0 1 auto; margin: 0; }
.move-form .use-line { flex-basis: 100%; }
.move-one { flex-basis: 100%; display: flex; flex-wrap: wrap; gap: 8px; align-items: center; }
.btn.ack { margin: 6px 0 0; }

/* Koetehtävä (vanhemman antama koe, issue #42) */
.koe-banner { padding: 0 12px; }
.koe-banner-btn { display: flex; width: 100%; align-items: center; justify-content: space-between; gap: 10px; min-height: 48px; margin: 6px 0 0; padding: 8px 14px; border-radius: 16px; border: 1px solid var(--primary); background: color-mix(in srgb, var(--primary) 10%, var(--bg)); color: var(--text); font: inherit; text-align: left; cursor: pointer; }
.koe-banner-go { font-weight: 700; color: var(--primary); flex: none; }
.ain-banner-title { margin: 8px 0 0; font-size: .9em; color: var(--muted); }
.ain-chip { font-size: .8em; padding: 1px 8px; border-radius: 999px; border: 1px solid currentColor; }
.ain-chip.task { color: var(--primary); }
.ain-parts { margin: 2px 0 6px 12px; }
.ain-parts > summary { cursor: pointer; min-height: 40px; display: flex; align-items: center; font-size: .9em; color: var(--muted); }
.ain-part { font-size: .9em; text-align: left; }
.koe-bar-top { display: flex; align-items: center; gap: 10px; padding: 4px 12px; min-height: 44px; }
.koe-bar-top .link-btn { min-height: 44px; flex: none; }
.koe-bar-title { font-weight: 700; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.koe-box { display: grid; gap: 14px; padding: 0 16px 24px; }
.koe-card { padding: 14px 16px; border-radius: 18px; border: 1px solid var(--line); background: var(--surface); }
.koe-card h3 { margin: 0 0 4px; }
.koe-card.done { border-color: var(--primary); }
.koe-done { font-weight: 700; color: var(--primary); }
.koe-bar { height: 12px; border-radius: 6px; background: var(--line); overflow: hidden; margin: 8px 0; }
.koe-bar > span { display: block; height: 100%; border-radius: 6px; background: var(--primary); }
.koe-hint { margin: 4px 0 10px; font-weight: 600; }
.koe-chapters { list-style: none; margin: 0 0 12px; padding: 0; display: grid; gap: 8px; }
.koe-ch { display: flex; width: 100%; justify-content: space-between; align-items: center; gap: 10px; min-height: 48px; padding: 8px 14px; border-radius: 14px; border: 1px solid var(--line); background: var(--bg); color: var(--text); font: inherit; text-align: left; cursor: pointer; }
.koe-ch.done { border-color: var(--primary); }
.koe-ch.locked, .koe-ch:disabled { opacity: 0.55; cursor: default; }
.koe-ch-st { font-size: 0.9rem; color: var(--muted, var(--text)); }
.koe-finish { width: 100%; }
.koe-finish-note { margin: 8px 0 0; }
.koe-bar-top .koe-bar-finish { flex: none; margin-left: auto; min-height: 44px; padding: 0 16px; border-radius: 22px; border: 0; background: var(--accent, #4f6bed); color: #fff; font: inherit; font-weight: 600; cursor: pointer; }
.koe-bar-top .koe-bar-finish[hidden] { display: none; }

.vp-task-past { opacity: 0.9; }

/* Etusivun valinta (Olen vanhempi / Olen oppilas) */
.role-box { display: flex; flex-direction: column; gap: 10px; margin-bottom: 4px; }
.role-btn {
  display: flex; flex-direction: column; align-items: center; gap: 2px; width: 100%; min-height: 64px; padding: 12px 16px;
  border-radius: 20px; border: 1px solid var(--primary); background: var(--surface); color: var(--text); text-decoration: none; font: inherit; cursor: pointer;
}
.role-btn b { font-size: 1.05rem; }
.role-btn span { color: var(--muted); font-size: 0.9rem; }
.role-btn.primary-role { background: var(--primary); color: var(--primary-text); }
.role-btn.primary-role span { color: var(--primary-text); opacity: .9; }
.access-more { display: block; width: 100%; margin-top: 8px; }
.legal #accessParent {
  display: block; min-height: 44px; margin: 0 auto; padding: 0 8px; border: 0; background: transparent;
  color: var(--muted); font: inherit; font-size: 0.72rem; text-decoration: underline;
}

/* Ensimmäisen avauksen kortit */
.help-card .help-text { font-size: 1.1rem; line-height: 1.5; color: var(--text); margin: 8px 0 16px; }
.help-card .muted { margin: 0; font-size: 0.85rem; }
.help-listen {
  display: inline-flex; align-items: center; justify-content: center; min-height: 48px; padding: 0 18px; margin: 0 auto 12px; border-radius: 24px;
  border: 1px solid var(--line); background: var(--surface); color: var(--text); font-weight: 500;
}
/* Selain esti automaattisen luvun (sivua ei ole vielä kosketettu): Kuuntele-painike kiinnittää huomion. */
.help-listen.nudge { border-color: var(--primary); animation: nudge 1.4s ease-in-out 3; }
@keyframes nudge { 0%, 100% { transform: scale(1); } 50% { transform: scale(1.08); } }
@media (prefers-reduced-motion: reduce) { .help-listen.nudge { animation: none; box-shadow: 0 0 0 3px var(--primary); } }
.help-nav { display: flex; flex-direction: column; gap: 4px; align-items: stretch; }

/* Ehdotusnapit ensimmäisen keskustelun aloituskortissa */
.starters { display: flex; flex-direction: column; gap: 8px; margin-top: 12px; }
.starters .quick { align-self: stretch; min-height: 48px; text-align: left; }

/* Aiemmin lähetetty materiaali (issue #148) */
.material-link { display: flex; justify-content: flex-end; margin-top: 4px; }
.material-btn { display: inline-flex; align-items: center; gap: 8px; min-height: 44px; padding: 6px 12px 6px 6px; border: 1px solid var(--line); border-radius: 14px; background: var(--surface); color: var(--text); font: inherit; font-size: 0.9rem; cursor: pointer; }
.material-btn:focus-visible { outline: 3px solid var(--primary); outline-offset: 2px; }
.material-thumb { width: 40px; height: 40px; object-fit: cover; border-radius: 8px; }
.material-icon { font-size: 1.4rem; width: 40px; text-align: center; }
.material-label { font-weight: 600; }
.material-kind { color: var(--muted); }
.mat-viewer { width: min(100vw - 16px, 900px); max-width: none; height: min(100vh - 16px, 1000px); max-height: none; padding: 0; border: 0; border-radius: var(--radius); background: var(--surface); color: var(--text); display: none; flex-direction: column; }
.mat-viewer[open] { display: flex; }
.mat-viewer::backdrop { background: rgba(10, 16, 30, 0.6); }
.mat-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 12px 16px 0; }
.mat-head h2 { margin: 0; font-size: 1.15rem; }
.mat-from { margin: 4px 16px 8px; overflow-wrap: anywhere; }
.mat-tools { display: flex; gap: 8px; padding: 0 16px 8px; }
.mat-tools .btn { min-width: 48px; min-height: 44px; }
.mat-body { flex: 1; overflow: auto; padding: 0 16px 16px; touch-action: pan-x pan-y pinch-zoom; }
.mat-fig { margin: 0 0 12px; }
.mat-img { display: block; width: 100%; max-width: none; height: auto; border-radius: 8px; }
.mat-pdf { width: 100%; height: 70vh; border: 1px solid var(--line); border-radius: 8px; }
.mat-pdf-open, .mat-page .btn { display: inline-block; margin-top: 8px; }
.mat-missing p { margin: 0 0 8px; }

/* Huoltajan tehtävän opiskelusivu (issue #152) */
.koe-page { margin: 8px 0 12px; }
.koe-page-msg.error { color: var(--error); }
.koe-page-title { margin: 8px 0 4px; font-size: 1rem; }
.koe-page-text { max-height: 40vh; overflow: auto; white-space: pre-wrap; padding: 8px; border: 1px solid var(--line); border-radius: 8px; font-size: 0.9rem; }
.koe-page-use { margin-top: 8px; }

/* Kieliprofiili (issue #141) */
.lang-form { display: grid; gap: 12px; }
.lang-field { display: grid; gap: 6px; border: 0; padding: 0; margin: 0; }
.lang-field legend, .lang-field > label { font-weight: 600; margin-bottom: 4px; }
.lang-field select, .lang-field input[type="text"] { font: inherit; padding: 10px; border: 1px solid var(--line); border-radius: 10px; background: var(--surface); color: var(--text); }
.lang-checks { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 4px 12px; }
.lang-check { display: flex; align-items: center; gap: 6px; min-height: 36px; }
.lang-actions { display: grid; gap: 8px; }
.lang-msg.error { color: var(--error); }
.lang-card-form { margin-top: 8px; }
.lang-card { margin: 8px 0; padding: 12px 16px; border: 1px solid var(--line); border-radius: var(--radius); background: var(--surface); }
.lang-card h3 { margin: 0 0 4px; font-size: 1rem; }

/* Muistikortit (#153, public/muistikortit.js) */
.review-panel { flex: 1; overflow-y: auto; padding: 8px 16px 24px; }
.review-h { margin: 4px 0 10px; font-size: 1.3rem; }
.cards-suggested { padding: 12px 14px; margin-bottom: 14px; border: 1px solid var(--primary); border-radius: 16px; background: color-mix(in srgb, var(--primary) 8%, var(--bg)); display: grid; gap: 6px; justify-items: start; }
.cards-suggested p { margin: 0; }
.cards-suggested-label { font-size: 0.85rem; color: var(--muted); font-weight: 600; }
.cards-suggested-area { font-size: 1.15rem; font-weight: 700; }
.cards-areas { display: grid; gap: 8px; margin-bottom: 14px; }
.cards-area { display: grid; gap: 2px; text-align: left; min-height: 52px; padding: 8px 14px; border: 1px solid var(--line); border-radius: 14px; background: var(--surface); color: var(--text); font: inherit; cursor: pointer; }
.cards-area-name { font-weight: 700; }
.cards-area-meta { font-size: 0.85rem; }
.cards-area-actions { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; margin-bottom: 14px; }
.cards-back { padding-left: 0; }
.card-field input { font: inherit; font-weight: 400; min-height: 44px; padding: 0 12px; border-radius: 14px; border: 1px solid var(--line); background: var(--bg); color: var(--text); min-width: 0; width: 100%; box-sizing: border-box; }
.card-editor h3 { margin: 0; }
.feedback-actions .card-add-btn { margin-left: auto; min-height: 36px; padding: 0 12px; font-size: 0.88rem; }
.card-add { align-self: stretch; margin-top: 8px; padding: 10px 12px; border: 1px solid var(--line); border-radius: 16px; background: var(--surface); }
.flashcard-more { display: flex; flex-wrap: wrap; gap: 4px 12px; justify-content: center; }
.cards-deferred p:last-child { margin-bottom: 0; }
.cards-head { display: flex; flex-wrap: wrap; align-items: center; gap: 10px 14px; margin-bottom: 12px; }
.cards-head p { margin: 0; flex: 1 1 220px; }
.cards-done { padding: 10px 14px; border-radius: 14px; background: color-mix(in srgb, var(--primary) 10%, var(--bg)); font-weight: 600; }
.cards-add { margin: 8px 0 16px; }
.cards-manage { margin: 8px 0 16px; border-top: 1px solid var(--line); }
.cards-manage > summary { cursor: pointer; font-weight: 600; color: var(--primary); min-height: 44px; display: flex; align-items: center; }
.cards-add > summary { cursor: pointer; font-weight: 600; color: var(--primary); min-height: 44px; display: flex; align-items: center; }
.cards-list { list-style: none; margin: 0; padding: 0; }
.cards-item { border-bottom: 1px solid var(--line); }
.cards-item summary { display: flex; justify-content: space-between; gap: 10px; padding: 10px 0; cursor: pointer; min-height: 44px; align-items: center; }
.cards-front { font-weight: 600; overflow-wrap: anywhere; }
.cards-when { flex: none; font-size: 0.85rem; }
.cards-back, .cards-subject { margin: 4px 0 8px; white-space: pre-wrap; overflow-wrap: anywhere; }
.card-form { display: grid; gap: 10px; margin: 8px 0; }
.card-field { display: grid; gap: 4px; font-weight: 600; font-size: 0.92rem; }
.card-field textarea { font: inherit; font-weight: 400; padding: 10px 12px; border-radius: 14px; border: 1px solid var(--line); background: var(--bg); color: var(--text); resize: vertical; min-width: 0; width: 100%; box-sizing: border-box; }
.card-form-actions { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; }
.card-saved { margin: 4px 0 0; }
.card-drafts { display: flex; flex-direction: column; align-items: flex-start; gap: 6px; margin: 6px 0; }
.card-draft { text-align: left; }
.card-draft.saved { color: var(--muted, inherit); cursor: default; text-decoration: none; }
.card-drafts-title { margin: 0; }
.flashcard { margin: 8px 0 14px; padding: 22px 18px; min-height: 140px; border: 1px solid var(--line); border-radius: 20px; background: var(--surface, var(--bg)); text-align: center; box-shadow: 0 2px 10px rgb(0 0 0 / 0.06); }
.flashcard-front { font-size: 1.25rem; font-weight: 700; margin: 6px 0; overflow-wrap: anywhere; }
.flashcard-back { font-size: 1.1rem; margin: 6px 0; white-space: pre-wrap; overflow-wrap: anywhere; }
.flashcard hr { border: 0; border-top: 1px solid var(--line); margin: 14px 0; }
.flashcard-actions { display: grid; gap: 10px; justify-items: center; text-align: center; }
.flashcard-actions > p { margin: 0; }
.flashcard-grades { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 8px; width: 100%; }
.flashcard-grades .btn { min-width: 0; padding-left: 6px; padding-right: 6px; color: #fff; border-color: transparent; font-weight: 700; }
.flashcard-grades .grade-1 { background: color-mix(in srgb, #d92d20 85%, var(--bg)); }
.flashcard-grades .grade-2 { background: color-mix(in srgb, #dc6803 85%, var(--bg)); }
.flashcard-grades .grade-3 { background: color-mix(in srgb, #079455 85%, var(--bg)); }
.cards-progress { text-align: center; margin: 0; }

/* Pelikortti keskustelussa (#195, public/peli.js) */
.quiz-card { align-self: stretch; margin-top: 8px; padding: 12px 14px; border: 1px solid var(--line); border-radius: 18px; background: var(--surface); display: flex; flex-direction: column; gap: 8px; }
.quiz-progress { margin: 0; font-size: 0.85rem; }
.quiz-question { margin: 0; font-weight: 700; font-size: 1.05rem; overflow-wrap: anywhere; }
.quiz-options { display: flex; flex-direction: column; gap: 8px; }
.quiz-option { font: inherit; text-align: left; padding: 12px 14px; min-height: 48px; border-radius: 14px; border: 1px solid var(--line); background: var(--bg); color: var(--text); cursor: pointer; }
.quiz-option:disabled { cursor: default; opacity: 1; }
.quiz-option.right { border-color: #2e7d32; background: color-mix(in srgb, #2e7d32 14%, var(--bg)); font-weight: 600; }
.quiz-option.wrong { border-color: var(--error); background: color-mix(in srgb, var(--error) 12%, var(--bg)); }
.quiz-feedback { margin: 0; }
.quiz-feedback.right { color: #2e7d32; }
.quiz-feedback.wrong { color: var(--error); }
.quiz-feedback.unknown { color: var(--muted); }
.quiz-unknown { text-align: center; border-style: dashed; color: var(--muted); }
.quiz-unknown.picked { border-style: solid; font-weight: 600; }
.quiz-summary .unknown { color: var(--muted); }
.quiz-card-hint { margin: 0; font-size: 0.92rem; color: var(--muted); }
.feedback-actions .card-add-btn.card-add-nudge { border-color: var(--primary); color: var(--primary); font-weight: 700; }
.quiz-actions { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; }
.quiz-score { margin: 0; font-weight: 700; }
.quiz-summary { margin: 0; padding-left: 20px; display: flex; flex-direction: column; gap: 4px; }
.quiz-summary .muted { color: var(--muted); }

/* Aloitusidea (issue #164): nappi ja rivit tyhjän keskustelun kortin alla */
.idea-picker { margin-top: 12px; }
.idea-open { align-self: flex-start; min-height: 48px; padding: 0 18px; border-radius: 24px; border: 1px solid var(--primary); background: var(--surface); color: var(--primary); font-weight: 600; font: inherit; cursor: pointer; }
.idea-rows { display: flex; flex-direction: column; gap: 8px; margin-top: 10px; }
.idea-rows .quick { align-self: stretch; min-height: 48px; text-align: left; }
.idea-rows .idea-more { align-self: flex-start; min-height: 40px; }
.idea-hint { margin: 2px 0 0; font-size: 0.92rem; }

/* Etusivun huomautus ja luokan valinnan vahvistus (issue #247) */
.front-note { margin: 16px 0 0; padding: 12px 14px; border: 1px solid var(--line); border-radius: 18px; background: var(--bg); text-align: left; }
.front-note h3 { margin: 0 0 4px; font-size: 1rem; }
.front-note p { margin: 0 0 8px; font-size: 0.95rem; }
.front-note .faq-btn { width: 100%; min-height: 52px; border-radius: 26px; font-weight: 600; margin-top: 4px; }
.front-note .front-note-more { margin: 8px 0 0; text-align: center; }
.front-note-inline { font-size: 0.95rem; text-align: left; }
.grade-confirm { text-align: left; }
.grade-confirm h3 { margin: 0 0 12px; font-size: 1.5rem; line-height: 1.2; text-align: center; }
.grade-confirm ul { margin: 8px 0 16px; padding-left: 20px; }
.grade-confirm li { margin: 6px 0; }
.grade-confirm .big { width: 100%; margin-top: 8px; }
#gradeScreen.confirming .grade-intro { display: none; }
.front-note a:not(.big), .front-note-inline a, .grade-intro a { color: var(--primary); }


/* Jaa kaverille (#321): iso QR-koodi koko näytön levyisenä, jotta kaveri voi skannata sen suoraan puhelimesta. */
.friend-box { max-width: 520px; margin: 16px auto 0; display: flex; flex-direction: column; gap: 14px; padding: 0 16px calc(env(safe-area-inset-bottom) + 24px); }
.friend-lead { margin: 0; }
.friend-qr { width: min(88vw, 420px); height: auto; aspect-ratio: 1; align-self: center; background: #fff; border-radius: 12px; }
.friend-actions { display: flex; flex-direction: column; gap: 10px; }
.friend-open { display: block; margin: 12px auto 24px; }
.ref-invite { margin: 4px 0 12px; }
.ref-invite-line { margin: 0 0 8px; font-weight: 600; }
.ref-invite .role-box { display: flex; flex-direction: column; gap: 10px; }
.ref-stats { margin-top: 16px; }
.ref-table { border-collapse: collapse; width: 100%; margin: 6px 0 12px; font-size: .9rem; }
.ref-table th, .ref-table td { text-align: left; padding: 4px 6px; border-bottom: 1px solid var(--line); vertical-align: top; }

/* Sovelluksen oma varmistusikkuna (public/vahvistus.js, #405) */
.vahvistus { width: min(100vw - 32px, 420px); padding: 20px; border: 0; border-radius: var(--radius); background: var(--surface); color: var(--text); }
.vahvistus::backdrop { background: rgba(10, 16, 30, 0.6); }
.vahvistus p { margin: 0 0 16px; line-height: 1.45; }
.vahvistus-napit { display: flex; justify-content: flex-end; gap: 8px; flex-wrap: wrap; }
.vahvistus-napit button { min-height: 44px; padding: 0 16px; border-radius: 999px; font: inherit; cursor: pointer; }
.vahvistus-peruuta { border: 1px solid var(--line); background: transparent; color: var(--text); }
.vahvistus-ok { border: 0; background: var(--primary); color: var(--primary-text); }
