/* ==========================================================================
   On.board — design foundation
   Palette: deep petrol (structure) + brass (attention) + cool paper.
   Type: wide uppercase micro-labels, tight grotesque headings,
   monospace for identifiers and statuses.
   ========================================================================== */

:root {
  /* =====================================================================
     TEEMA - team.blue, tumma
     ---------------------------------------------------------------------
     Brandivarit tulevat team.blue -tyyliohjeesta:
         #1c3f6e  tumma sininen (paavari)
         #16ace2  syaani (aksentti, logon piste)

     Koko kayttoliittyman savy tulee tasta lohkosta. Vaaleaan teemaan
     palataan vaihtamalla pinta- ja tekstivarit takaisin vaaleiksi; muut
     saannot lukevat aina naita muuttujia.
     ===================================================================== */

  --brand-900:    #1c3f6e;   /* ylapalkki, tummat pinnat */
  --brand-700:    #21579A;   /* ensisijainen painike (valkoinen teksti) */
  --brand-500:    #16ace2;   /* aksentit, kaaviot, edistymispalkit */
  --brand-100:    #17324D;   /* tumma savytetty tausta (merkit, hoverit) */

  /* Tekstit: vaaleat, koska pohja on tumma. */
  --ink:          #E9EFF7;
  --ink-2:        #B7C6D8;
  --ink-3:        #8AA0B8;

  /* Pinnat tummasta vaaleampaan: sivu, kortti, korostettu alue. */
  --paper:        #0C1A2B;
  --surface:      #132741;
  --surface-2:    #1A3350;
  --line:         #26445F;
  --line-strong:  #37597C;

  /* Vanhat nimet osoittavat teemavareihin, jottei jokaista viittausta
     tarvitse muuttaa. --teal-700 on linkkivari, siksi vaaleampi. */
  --teal-900:     var(--brand-900);
  --teal-700:     #58C5F0;
  --teal-500:     var(--brand-500);
  --teal-100:     var(--brand-100);

  /* Aksentti: logon piste seuraa team.bluen syaania. */
  --brass:        #E0A458;
  --brass-dot:    #16ace2;
  --brass-100:    #33261A;

  /* Tilavarit tummalle pohjalle: vaalea etuala, tumma savytetty tausta. */
  --ok:           #4FC48D;
  --ok-100:       #12332A;
  --warn:         #E0A458;
  --warn-100:     #33261A;
  --danger:       #F0817E;
  --danger-100:   #3B2024;

  --sans: "Segoe UI", -apple-system, BlinkMacSystemFont, "Helvetica Neue", Arial, sans-serif;
  --mono: ui-monospace, "SFMono-Regular", "JetBrains Mono", "Cascadia Mono", Consolas, monospace;

  --radius:    4px;
  --radius-lg: 8px;
  --shadow:    0 1px 2px rgba(0, 0, 0, .30), 0 4px 14px rgba(0, 0, 0, .24);

  --space:     16px;
}

* { box-sizing: border-box; }

/* Elementti jolla on hidden-attribuutti pysyy piilossa, vaikka sen omassa
   saannossa olisi display-arvo. Ilman tata JavaScriptin asettama hidden ei
   tehoa esimerkiksi flex-elementteihin, jolloin piilotettu ilmoitus jaa
   nakyviin. */
[hidden] { display: none !important; }



html { -webkit-text-size-adjust: 100%; }

body {
  margin: 0;
  background: var(--paper);
  color: var(--ink);
  font-family: var(--sans);
  font-size: 15px;
  line-height: 1.55;
}

a { color: var(--teal-700); }
a:hover { color: var(--teal-500); }

:focus-visible {
  outline: 2px solid var(--teal-500);
  outline-offset: 2px;
}

h1, h2, h3 {
  margin: 0 0 .4em;
  letter-spacing: -.015em;
  font-weight: 650;
  line-height: 1.2;
}
h1 { font-size: 26px; }
h2 { font-size: 19px; }
h3 { font-size: 16px; }

p { margin: 0 0 1em; }

/* Small uppercase label — marks sections and form fields. */
.eyebrow {
  font-size: 11px;
  font-weight: 600;
  letter-spacing: .14em;
  text-transform: uppercase;
  color: var(--ink-3);
  margin: 0 0 10px;
}

.muted { color: var(--ink-3); }
.mono  { font-family: var(--mono); font-size: 13px; }

.skip-link {
  position: absolute;
  left: -999px;
  top: 8px;
  background: var(--teal-900);
  color: #fff;
  padding: 10px 16px;
  border-radius: var(--radius);
  z-index: 100;
}
.skip-link:focus { left: 8px; }

/* --------------------------------------------------------------------------
   Sign-in and setup — split view
   -------------------------------------------------------------------------- */

.split {
  display: grid;
  grid-template-columns: minmax(0, 4fr) minmax(0, 6fr);
  min-height: 100vh;
}

.split-brand {
  background: var(--teal-900);
  color: #E7EFF1;
  padding: 48px 44px;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  /* Hairline grid: echoes the structure of modules and sections. */
  background-image:
    linear-gradient(rgba(255,255,255,.045) 1px, transparent 1px),
    linear-gradient(90deg, rgba(255,255,255,.045) 1px, transparent 1px);
  background-size: 56px 56px;
}

.split-wordmark {
  font-size: 46px;
  font-weight: 680;
  letter-spacing: -.03em;
  line-height: 1;
  margin: 0;
  color: #FFFFFF;
}

/* The dot in the name, in brass — repeated in the top bar. */
.wordmark-dot { color: var(--brass-dot, #16ace2); }

.split-tagline {
  margin: 14px 0 0;
  font-size: 17px;
  color: #A9C3CA;
  max-width: 22ch;
}

.split-intro {
  font-size: 14px;
  color: #8FAAB2;
  max-width: 40ch;
  margin: 0;
}

.split-form {
  background: var(--surface);
  padding: 48px 44px;
  display: flex;
  align-items: center;
}

.split-form-inner {
  width: 100%;
  max-width: 380px;
  margin: 0 auto;
}

@media (max-width: 800px) {
  .split { grid-template-columns: 1fr; min-height: 0; }
  .split-brand { padding: 32px 24px; gap: 20px; }
  .split-wordmark { font-size: 34px; }
  .split-tagline { font-size: 15px; }
  .split-intro { display: none; }
  .split-form { padding: 32px 24px; }
}

/* --------------------------------------------------------------------------
   Application shell
   -------------------------------------------------------------------------- */

.topbar {
  background: var(--teal-900);
  color: #E7EFF1;
}

.topbar-inner {
  max-width: 1120px;
  margin: 0 auto;
  padding: 0 24px;
  display: flex;
  align-items: center;
  gap: 28px;
  min-height: 56px;
  flex-wrap: wrap;
}

.topbar-brand {
  font-weight: 680;
  font-size: 18px;
  letter-spacing: -.02em;
  color: #fff;
  text-decoration: none;
}
.topbar-brand:hover { color: #fff; }

.topbar-nav {
  display: flex;
  gap: 4px;
  margin-right: auto;
  flex-wrap: wrap;
}

.topbar-nav a {
  color: #A9C3CA;
  text-decoration: none;
  font-size: 14px;
  padding: 6px 10px;
  border-radius: var(--radius);
}
.topbar-nav a:hover { color: #fff; background: rgba(255,255,255,.07); }
.topbar-nav a.is-current { color: #fff; background: rgba(255,255,255,.12); }

.topbar-meta {
  display: flex;
  align-items: center;
  gap: 14px;
  font-size: 13px;
  color: #A9C3CA;
}
.topbar-meta a { color: #A9C3CA; text-decoration: none; }
.topbar-meta a:hover { color: #fff; }

.lang-switch { display: flex; gap: 2px; font-family: var(--mono); font-size: 12px; }
.lang-switch a { padding: 3px 6px; border-radius: 3px; text-transform: uppercase; }
.lang-switch a.is-current { background: rgba(255,255,255,.14); color: #fff; }

.linkbutton {
  background: none;
  border: 0;
  padding: 0;
  font: inherit;
  color: inherit;
  cursor: pointer;
  text-decoration: underline;
  text-underline-offset: 3px;
}

.page {
  max-width: 1120px;
  margin: 0 auto;
  padding: 32px 24px 64px;
}

.page-head {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 16px;
  flex-wrap: wrap;
  margin-bottom: 24px;
}
.page-head h1 { margin: 0; }

/* --------------------------------------------------------------------------
   Cards and grids
   -------------------------------------------------------------------------- */

.card {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius-lg);
  padding: 24px;
  box-shadow: var(--shadow);
}
.card + .card { margin-top: 20px; }

.grid-2 {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(260px, 1fr));
  gap: 20px;
}

.stat-value {
  font-size: 34px;
  font-weight: 680;
  letter-spacing: -.03em;
  line-height: 1;
  font-variant-numeric: tabular-nums;
}
.stat-label {
  font-size: 12px;
  letter-spacing: .1em;
  text-transform: uppercase;
  color: var(--ink-3);
  margin-top: 8px;
}

/* --------------------------------------------------------------------------
   Forms
   -------------------------------------------------------------------------- */

.field { margin-bottom: 18px; }

.field > label,
.fieldset > legend {
  display: block;
  font-size: 12px;
  font-weight: 600;
  letter-spacing: .08em;
  text-transform: uppercase;
  color: var(--ink-2);
  margin-bottom: 6px;
  padding: 0;
}

.input,
.select {
  width: 100%;
  padding: 10px 12px;
  font: inherit;
  color: var(--ink);
  /* Kenttien pohja on korttia tummempi, jotta ne erottuvat tummassa
     teemassa; vaaleassa teemassa ero syntyy toisin pain yhta hyvin. */
  background: var(--paper);
  border: 1px solid var(--line-strong);
  border-radius: var(--radius);
}
.input:focus,
.select:focus {
  border-color: var(--teal-500);
  outline: 2px solid var(--teal-100);
  outline-offset: 0;
}

.hint {
  font-size: 13px;
  color: var(--ink-3);
  margin: 6px 0 0;
}

.fieldset {
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 14px 16px;
  margin: 0 0 18px;
}

.check-list { display: grid; gap: 8px; }

.check {
  display: flex;
  align-items: flex-start;
  gap: 9px;
  font-size: 14px;
  cursor: pointer;
}
.check input { margin-top: 3px; flex: none; }
.check-note { display: block; font-size: 12px; color: var(--ink-3); }

.form-actions {
  display: flex;
  gap: 10px;
  align-items: center;
  margin-top: 24px;
  padding-top: 20px;
  border-top: 1px solid var(--line);
  flex-wrap: wrap;
}

/* --------------------------------------------------------------------------
   Buttons
   -------------------------------------------------------------------------- */

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 10px 18px;
  font: inherit;
  font-weight: 550;
  border-radius: var(--radius);
  border: 1px solid transparent;
  cursor: pointer;
  text-decoration: none;
  white-space: nowrap;
}

.btn-primary { background: var(--brand-700); color: #fff; }
.btn-primary:hover { background: var(--brand-500); color: var(--paper); }

.btn-secondary {
  background: var(--surface);
  color: var(--ink);
  border-color: var(--line-strong);
}
.btn-secondary:hover { background: var(--surface-2); color: var(--ink); }

.btn-danger { background: var(--surface); color: var(--danger); border-color: var(--danger); }
.btn-danger:hover { background: var(--danger); color: #fff; }

.btn-block { width: 100%; }
.btn-sm { padding: 6px 12px; font-size: 13px; }

/* --------------------------------------------------------------------------
   Tables
   -------------------------------------------------------------------------- */

.table-wrap {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius-lg);
  overflow-x: auto;
  box-shadow: var(--shadow);
}

.table { width: 100%; border-collapse: collapse; }

.table th {
  text-align: left;
  font-size: 11px;
  font-weight: 600;
  letter-spacing: .12em;
  text-transform: uppercase;
  color: var(--ink-3);
  padding: 12px 16px;
  border-bottom: 1px solid var(--line);
  white-space: nowrap;
}

.table td {
  padding: 13px 16px;
  border-bottom: 1px solid var(--line);
  vertical-align: middle;
}
.table tbody tr:last-child td { border-bottom: 0; }
.table tbody tr:hover { background: var(--surface-2); }

.table-name { font-weight: 550; }
.table-sub { font-size: 13px; color: var(--ink-3); }
.table-actions { text-align: right; white-space: nowrap; }

.toolbar {
  display: flex;
  gap: 10px;
  align-items: center;
  margin-bottom: 16px;
  flex-wrap: wrap;
}
.toolbar .input,
.toolbar .select { width: auto; min-width: 200px; }

/* --------------------------------------------------------------------------
   Chips and status pills
   -------------------------------------------------------------------------- */

.chip {
  display: inline-block;
  font-family: var(--mono);
  font-size: 11px;
  letter-spacing: .04em;
  padding: 3px 7px;
  border-radius: 3px;
  background: var(--teal-100);
  color: var(--teal-900);
  margin: 1px 3px 1px 0;
}
.chip-admin   { background: var(--brass-100); color: var(--brass); }
.chip-neutral { background: var(--surface-2); color: var(--ink-2); border: 1px solid var(--line); }

.pill {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: 12px;
  font-weight: 550;
  padding: 3px 9px;
  border-radius: 999px;
}
.pill::before {
  content: "";
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: currentColor;
}
.pill-active    { background: var(--ok-100);     color: var(--ok); }
.pill-invited   { background: var(--brass-100);  color: var(--brass); }
.pill-suspended { background: var(--danger-100); color: var(--danger); }

/* --------------------------------------------------------------------------
   Notices and empty states
   -------------------------------------------------------------------------- */

.notice {
  border: 1px solid var(--line);
  border-left: 3px solid var(--ink-3);
  border-radius: var(--radius);
  padding: 12px 16px;
  margin-bottom: 16px;
  background: var(--surface);
  font-size: 14px;
}
.notice-success { border-left-color: var(--ok);     background: var(--ok-100); }
.notice-error   { border-left-color: var(--danger); background: var(--danger-100); }
.notice-warning { border-left-color: var(--warn);   background: var(--warn-100); }
.notice-info    { border-left-color: var(--teal-500); background: var(--teal-100); }

.empty {
  text-align: center;
  padding: 56px 24px;
  color: var(--ink-3);
}
.empty h2 { color: var(--ink); }

.pager {
  display: flex;
  gap: 10px;
  align-items: center;
  justify-content: space-between;
  margin-top: 16px;
  font-size: 13px;
  color: var(--ink-3);
  flex-wrap: wrap;
}

.error-page {
  max-width: 520px;
  margin: 14vh auto;
  padding: 0 24px;
}
.error-code {
  font-family: var(--mono);
  font-size: 13px;
  letter-spacing: .16em;
  color: var(--brass);
  margin-bottom: 10px;
}

@media (prefers-reduced-motion: reduce) {
  * { animation: none !important; transition: none !important; }
}

/* --------------------------------------------------------------------------
   Content editor
   -------------------------------------------------------------------------- */

.head-actions { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }

.field-narrow { max-width: 200px; }

textarea.input { font: inherit; line-height: 1.5; resize: vertical; }

.check-columns { grid-template-columns: repeat(auto-fit, minmax(180px, 1fr)); }

.inline-form { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; }
.inline-form .input { flex: 1 1 280px; }

.select-inline { width: auto; min-width: 140px; }

/* Language rows on the module overview */
.lang-row {
  display: flex;
  gap: 16px;
  padding: 14px 0;
  border-bottom: 1px solid var(--line);
}
.lang-row:last-child { border-bottom: 0; }
.lang-row-label { flex: none; width: 44px; padding-top: 2px; }
.lang-row-body { flex: 1; min-width: 0; }

.version-line {
  display: flex;
  gap: 10px;
  align-items: baseline;
  flex-wrap: wrap;
  font-size: 14px;
  padding: 3px 0;
}

/* Section cards in the editor */
.section-card { padding: 0; overflow: hidden; }

.section-head {
  display: flex;
  gap: 12px;
  align-items: center;
  padding: 14px 20px;
  background: var(--surface-2);
  border-bottom: 1px solid var(--line);
}

.section-number {
  flex: none;
  width: 26px;
  height: 26px;
  border-radius: 50%;
  background: var(--teal-900);
  color: #fff;
  font-family: var(--mono);
  font-size: 12px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}

.section-title-form { display: flex; gap: 8px; flex: 1; min-width: 0; align-items: center; }
.section-title-static { margin: 0; flex: 1; }
.input-title { font-weight: 550; }

/* Jarjestys- ja poistonapit yhtenaisena ryhmana, jotta ne eivat nayta
   irrallisilta laatikoilta rivin lopussa. */
.section-tools, .block-tools {
  display: inline-flex;
  align-items: center;
  flex: none;
  border: 1px solid var(--line-strong);
  border-radius: var(--radius);
  overflow: hidden;
  background: var(--surface);
}
.section-tools form, .block-tools form { display: flex; }

.iconbtn {
  border: 0;
  border-left: 1px solid var(--line);
  background: transparent;
  color: var(--ink-3);
  width: 34px;
  height: 32px;
  padding: 0;
  font-size: 13px;
  line-height: 1;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  transition: background .12s ease, color .12s ease;
}
.section-tools form:first-child .iconbtn,
.block-tools form:first-child .iconbtn { border-left: 0; }

.iconbtn:hover { background: var(--teal-100); color: var(--ink); }
.iconbtn:active { background: var(--teal-500); color: var(--paper); }
.iconbtn:disabled { color: var(--line-strong); cursor: default; background: transparent; }
.iconbtn-danger:hover { background: var(--danger-100); color: var(--danger); }

/* Osion tyokalut nakyviin vasta kun osio on aktiivinen - vahentaa hälyä
   pitkassa moduulissa, mutta pysyy nakyvissa kosketuslaitteilla. */
@media (hover: hover) {
  .section-tools, .block-tools { opacity: .45; transition: opacity .12s ease; }
  .section-card:hover .section-tools,
  .section-card:focus-within .section-tools,
  .block:hover .block-tools,
  .block:focus-within .block-tools { opacity: 1; }
}

.block {
  padding: 16px 20px;
  border-bottom: 1px solid var(--line);
}
.block:last-of-type { border-bottom: 0; }

.block-bar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 10px;
  margin-bottom: 10px;
}

.block-type {
  font-size: 11px;
  font-weight: 600;
  letter-spacing: .12em;
  text-transform: uppercase;
  color: var(--ink-3);
}

.block-form { display: flex; flex-direction: column; gap: 8px; align-items: flex-start; }
.block-form .input { width: 100%; }
.block-form .btn { align-self: flex-start; }

.block-image {
  max-width: 100%;
  height: auto;
  border-radius: var(--radius);
  border: 1px solid var(--line);
  display: block;
  margin-bottom: 10px;
}
.block-caption { font-size: 13px; color: var(--ink-3); margin: 0; }
.block-empty { padding: 16px 20px; margin: 0; }

.block-callout { background: var(--surface-2); }

.adder { border-top: 1px solid var(--line); background: var(--surface-2); }
.adder > summary {
  padding: 12px 20px;
  cursor: pointer;
  font-size: 13px;
  font-weight: 550;
  color: var(--teal-700);
  list-style: none;
}
.adder > summary::before { content: "+ "; }
.adder[open] > summary { border-bottom: 1px solid var(--line); }

/* Lisayslomakkeet allekkain kayttojarjestyksessa: valiotsikko, teksti,
   huomiolaatikko, kuva. Sarakkeissa ne kilpailivat huomiosta eika
   jarjestys valittynyt. */
.adder-body {
  display: flex;
  flex-direction: column;
  gap: 12px;
  padding: 16px 20px;
}
/* Lisayslomake: editori taydella leveydella, sen alla nappi. Aiempi
   kolmisarakkeinen ruudukko oli tehty vanhalle asettelulle, jossa tyyppi
   oli omana sarakkeenaan - se latisti editorin tyokalupalkin. */
.adder-form {
  display: flex;
  flex-direction: column;
  align-items: stretch;
  gap: 10px;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 12px;
}
.adder-form .rte,
.adder-form textarea { width: 100%; }
.adder-form .select-inline { align-self: flex-start; }
.adder-form .hint { margin: 0; }
.adder-form .btn { align-self: flex-start; }

.add-section { border-style: dashed; }

/* --------------------------------------------------------------------------
   Reader view
   -------------------------------------------------------------------------- */

.reader { max-width: 100%; }
/* Teksti pysyy luettavan levyisena vaikka moduuli tayttaa koko sivun:
   kappaleet rajataan, mutta kuvat ja otsikot saavat levea. */
.reader-section .prose,
.reader-section > h2,
.reader-head { max-width: 74ch; }
.reader-figure { max-width: 100%; }

.reader-head { margin-bottom: 32px; padding-bottom: 20px; border-bottom: 2px solid var(--teal-900); }
.reader-head h1 { font-size: 32px; }
.reader-summary { font-size: 17px; color: var(--ink-2); margin: 0; }

.reader-section > h2 {
  display: flex;
  gap: 12px;
  align-items: baseline;
  font-size: 22px;
  margin-bottom: 16px;
}
.reader-section-number {
  font-family: var(--mono);
  font-size: 13px;
  color: var(--brass);
  flex: none;
}
.reader-section h3 { margin-top: 24px; font-size: 16px; }

.reader-figure { margin: 20px 0; }
.reader-figure img {
  max-width: 100%;
  height: auto;
  border-radius: var(--radius);
  border: 1px solid var(--line);
  display: block;
}
.reader-figure figcaption { font-size: 13px; color: var(--ink-3); margin-top: 8px; }

.prose p { margin: 0 0 1em; }
.prose ul, .prose ol { margin: 0 0 1em; padding-left: 1.4em; }
.prose li { margin-bottom: .3em; }
.prose code {
  font-family: var(--mono);
  font-size: .9em;
  background: var(--surface-2);
  border: 1px solid var(--line);
  border-radius: 3px;
  padding: 1px 5px;
}
.prose a { text-underline-offset: 3px; }
.prose > :last-child { margin-bottom: 0; }

.callout {
  border-left: 3px solid var(--teal-500);
  background: var(--teal-100);
  border-radius: var(--radius);
  padding: 14px 18px;
  margin: 20px 0;
}
.callout-label {
  font-size: 11px;
  font-weight: 600;
  letter-spacing: .12em;
  text-transform: uppercase;
  margin: 0 0 6px;
  color: var(--teal-900);
}
.callout-tip { border-left-color: var(--ok); background: var(--ok-100); }
.callout-tip .callout-label { color: var(--ok); }
.callout-warning { border-left-color: var(--warn); background: var(--warn-100); }
.callout-warning .callout-label { color: var(--warn); }

@media (max-width: 600px) {
  .section-head { flex-wrap: wrap; }
  .section-title-form { flex: 1 1 100%; }
  .reader-head h1 { font-size: 26px; }
}


/* --------------------------------------------------------------------------
   Rich text editor
   -------------------------------------------------------------------------- */

.rte {
  border: 1px solid var(--line-strong);
  border-radius: var(--radius);
  background: var(--paper);
  overflow: hidden;
}
.rte:focus-within { border-color: var(--teal-500); box-shadow: 0 0 0 2px var(--teal-100); }

.rte-toolbar {
  display: flex;
  gap: 2px;
  padding: 5px 6px;
  background: var(--surface-2);
  border-bottom: 1px solid var(--line);
  flex-wrap: wrap;
}

.rte-btn {
  border: 0;
  background: transparent;
  color: var(--ink-2);
  border-radius: 3px;
  min-width: 30px;
  height: 28px;
  padding: 0 7px;
  font-size: 13px;
  font-family: var(--mono);
  line-height: 1;
  cursor: pointer;
}
.rte-btn:hover { background: var(--teal-100); color: var(--ink); }
.rte-btn:active { background: var(--teal-500); color: var(--paper); }
.rte-btn.is-bold { font-weight: 700; font-family: var(--sans); }
.rte-btn.is-italic { font-style: italic; font-family: var(--sans); }

/* Muokkauspinta kayttaa samaa typografiaa kuin lukunakyma, jotta
   kirjoittaja nakee suunnilleen lopputuloksen. */
.rte-surface {
  border: 0;
  border-radius: 0;
  min-height: 96px;
  padding: 12px 14px;
  outline: none;
  overflow-wrap: break-word;
}
.rte-surface:focus { outline: none; box-shadow: none; border: 0; }
.rte-surface p { margin: 0 0 .8em; }
.rte-surface > :last-child { margin-bottom: 0; }
.rte-surface ul, .rte-surface ol { margin: 0 0 .8em; padding-left: 1.4em; }
.rte-surface li { margin-bottom: .25em; }
.rte-surface code {
  font-family: var(--mono);
  font-size: .9em;
  background: var(--surface-2);
  border: 1px solid var(--line);
  border-radius: 3px;
  padding: 1px 5px;
}
.rte-surface a { color: var(--teal-700); }

.rte-surface.is-empty::before {
  content: attr(data-placeholder);
  color: var(--ink-3);
  pointer-events: none;
  display: block;
}

/* Ilman JavaScriptia tekstialue jaa nakyviin normaalisti. */
.rte .rte-source { display: none; }

/* Kuvat tekstin seassa */
.inline-image {
  max-width: 100%;
  height: auto;
  display: block;
  margin: 12px 0;
  border-radius: var(--radius);
  border: 1px solid var(--line);
}
.rte-surface .inline-image { cursor: default; }
.rte-surface.is-dropping { background: var(--teal-100); }
.rte-surface.is-uploading { opacity: .6; }

/* --------------------------------------------------------------------------
   Settings: categories, brands, teams
   -------------------------------------------------------------------------- */

.taxonomy-row {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px 20px;
  border-bottom: 1px solid var(--line);
}
.taxonomy-row:hover { background: var(--surface-2); }

.taxonomy-form {
  display: flex;
  align-items: center;
  gap: 8px;
  flex: 1;
  min-width: 0;
  flex-wrap: wrap;
}
.taxonomy-form .input { flex: 1 1 160px; min-width: 0; }
.taxonomy-form .select { flex: 0 0 130px; }

.taxonomy-usage {
  flex: none;
  font-size: 12px;
  white-space: nowrap;
}

.taxonomy-group { padding: 14px 20px 4px; border-bottom: 1px solid var(--line); }
.taxonomy-group .taxonomy-row { padding-left: 0; padding-right: 0; border-bottom: 0; }
.taxonomy-group .taxonomy-row:hover { background: transparent; }
.taxonomy-group-label { margin-bottom: 8px; }

.taxonomy-add { padding: 16px 20px; background: var(--surface-2); }
.taxonomy-add .eyebrow { margin-bottom: 10px; }

@media (max-width: 700px) {
  .taxonomy-row { flex-wrap: wrap; align-items: flex-start; }
  .taxonomy-usage { order: 3; }
}

/* Otsikkovalikko editorin tyokalupalkissa */
.rte-select {
  border: 1px solid var(--line-strong);
  background: var(--surface);
  color: var(--ink);
  border-radius: 3px;
  height: 28px;
  font-size: 13px;
  padding: 0 6px;
  margin-right: 6px;
  cursor: pointer;
}
.rte-surface h3 { font-size: 18px; margin: .6em 0 .3em; }
.rte-surface h4 { font-size: 16px; margin: .6em 0 .3em; }
.rte-surface h5 { font-size: 14px; margin: .6em 0 .3em; font-weight: 650; }

/* "+ Add content" -tyyppivalinta */
.adder-choices {
  display: flex;
  gap: 6px;
  margin-bottom: 12px;
  flex-wrap: wrap;
}
.adder-choice {
  border: 1px solid var(--line-strong);
  background: var(--surface);
  color: var(--ink-2);
  border-radius: var(--radius);
  padding: 7px 16px;
  font: inherit;
  font-size: 14px;
  cursor: pointer;
}
.adder-choice:hover { background: var(--surface-2); }
.adder-choice[aria-selected="true"] {
  background: var(--teal-900);
  color: #fff;
  border-color: var(--teal-900);
}
.adder-panel[hidden] { display: none; }

/* Sisallon otsikot lukunakymassa */
.reader-section .prose h3 { font-size: 20px; margin: 1.1em 0 .4em; }
.reader-section .prose h4 { font-size: 17px; margin: 1em 0 .4em; }
.reader-section .prose h5 { font-size: 15px; margin: 1em 0 .3em; font-weight: 650; }
.reader-section .prose > :first-child { margin-top: 0; }

/* --------------------------------------------------------------------------
   Content tables
   -------------------------------------------------------------------------- */

/* Vaakavieritys kapealla naytolla ilman etta koko sivu venyy. */
.table-scroll { overflow-x: auto; margin: 1.1em 0; }

.content-table,
.rte-surface table {
  border-collapse: collapse;
  width: 100%;
  font-size: 15px;
}
.content-table th,
.content-table td,
.rte-surface th,
.rte-surface td {
  border: 1px solid var(--line-strong);
  padding: 8px 12px;
  text-align: left;
  vertical-align: top;
}
.content-table thead th,
.rte-surface thead th {
  background: var(--surface-2);
  font-weight: 650;
}
.content-table tbody tr:nth-child(even),
.rte-surface tbody tr:nth-child(even) { background: var(--surface-2); }

.content-table .ta-center, .rte-surface .ta-center { text-align: center; }
.content-table .ta-right,  .rte-surface .ta-right  { text-align: right; }

/* Editorin taulukko: solut nakyvat selvasti muokattavina. */
.rte-surface table { margin: 10px 0; }
.rte-surface td:focus,
.rte-surface th:focus { outline: 2px solid var(--teal-500); outline-offset: -2px; }

/* Tyokalupalkin erotin ja taulukkonapit */
.rte-sep {
  width: 1px;
  align-self: stretch;
  background: var(--line);
  margin: 2px 4px;
}
.rte-btn-table { font-size: 12px; }
.rte-btn:disabled { opacity: .35; cursor: default; }
.rte-btn:disabled:hover { background: transparent; color: var(--ink-2); }

/* --------------------------------------------------------------------------
   Reader sections as cards
   -------------------------------------------------------------------------- */

.reader-section {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius-lg, 12px);
  padding: 24px 28px;
  margin: 0 0 20px;
  box-shadow: 0 1px 2px rgba(16, 24, 40, .04);
}
.reader-section > h2 { margin-top: 0; }

/* --------------------------------------------------------------------------
   Unsaved-changes indicator and "Save all"
   -------------------------------------------------------------------------- */

.section-dirty {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: 13px;
  color: var(--brass);
  white-space: nowrap;
}
.section-dirty-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--brass);
  flex: none;
}

.js-save-all.is-saving { opacity: .7; cursor: default; }

/* A dirty block/title makes its own Save button stand out, so it is clear
   which parts still need saving even without using "Save all". */
.block-form.is-dirty .btn,
.section-title-form.is-dirty .btn {
  border-color: var(--brass);
  color: var(--brass-900, var(--brass));
  box-shadow: 0 0 0 2px var(--brass-100, rgba(180, 140, 60, .15));
}
.block-form.is-dirty,
.section-title-form.is-dirty { position: relative; }

/* A subtle marker on the whole section while it has unsaved edits. */
.section-card.has-unsaved { border-left: 3px solid var(--brass); }

/* ==========================================================================
   Phase 3: library, reader, assignments
   ========================================================================== */

.library-block { margin-bottom: 32px; }
.library-heading {
  font-size: 15px;
  text-transform: uppercase;
  letter-spacing: .04em;
  color: var(--ink-3);
  margin: 0 0 14px;
}

.library-filter {
  display: flex;
  gap: 8px;
  margin-bottom: 16px;
  flex-wrap: wrap;
}
.library-filter .input { flex: 1 1 220px; }
.library-filter .select { flex: 0 0 200px; }

.card-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(260px, 1fr));
  gap: 16px;
}

.module-card {
  display: flex;
  flex-direction: column;
  gap: 10px;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius-lg);
  padding: 18px 20px;
  text-decoration: none;
  color: inherit;
  box-shadow: 0 1px 2px rgba(16, 24, 40, .04);
  transition: border-color .12s ease, box-shadow .12s ease, transform .12s ease;
}
.module-card:hover {
  border-color: var(--teal-500);
  box-shadow: 0 4px 14px rgba(16, 24, 40, .08);
  transform: translateY(-1px);
}
.module-card.is-complete { border-left: 3px solid var(--ok); }

.module-card-top { display: flex; flex-wrap: wrap; gap: 6px; }
.module-card-title { margin: 0; font-size: 17px; color: var(--ink); }
.module-card-summary {
  margin: 0;
  font-size: 14px;
  color: var(--ink-2);
  display: -webkit-box;
  -webkit-line-clamp: 3;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

.badge {
  display: inline-block;
  font-size: 12px;
  font-weight: 600;
  padding: 2px 9px;
  border-radius: 999px;
  white-space: nowrap;
}
.badge-required { background: var(--brand-500); color: var(--paper); }
.badge-muted    { background: var(--surface-2); color: var(--ink-3); border: 1px solid var(--line); }
.badge-due      { background: var(--brass-100); color: var(--brass); }
.badge-overdue  { background: var(--danger-100); color: var(--danger); }
.badge-done     { background: var(--ok-100); color: var(--ok); }
.badge-progress { background: var(--teal-100); color: var(--teal-700); }

.module-progress { margin-top: auto; display: flex; flex-direction: column; gap: 5px; }
.module-progress-bar {
  height: 6px;
  border-radius: 999px;
  background: var(--surface-2);
  overflow: hidden;
}
.module-progress-bar span { display: block; height: 100%; background: var(--teal-500); }
.module-card.is-complete .module-progress-bar span { background: var(--ok); }
.module-progress-label { font-size: 12px; color: var(--ink-3); }

/* Reader ------------------------------------------------------------------- */

.reader-shell { max-width: 760px; margin: 0 auto; }

.reader-topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 12px;
}
.reader-back { text-decoration: none; font-size: 14px; color: var(--teal-700); }
.reader-count { font-size: 13px; color: var(--ink-3); }

.reader-progress { display: flex; align-items: center; gap: 12px; margin-bottom: 18px; }
.reader-progress-bar {
  flex: 1;
  height: 8px;
  border-radius: 999px;
  background: var(--surface-2);
  overflow: hidden;
}
.reader-progress-bar span { display: block; height: 100%; background: var(--teal-500); transition: width .2s ease; }
.reader-progress-label { font-size: 13px; color: var(--ink-3); white-space: nowrap; }

.reader-card {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius-lg);
  padding: 32px 36px;
  box-shadow: 0 1px 2px rgba(16, 24, 40, .04);
}
.reader-module {
  margin: 0 0 4px;
  font-size: 13px;
  text-transform: uppercase;
  letter-spacing: .04em;
  color: var(--brass);
}
.reader-section-title { margin: 0 0 20px; font-size: 26px; }
.reader-card .prose { max-width: 68ch; }
.reader-figure { margin: 16px 0; }
.reader-figure img { max-width: 100%; border-radius: var(--radius); border: 1px solid var(--line); }
.reader-figure figcaption { font-size: 13px; color: var(--ink-3); margin-top: 6px; }

.reader-nav {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-top: 20px;
}
.reader-nav form { margin: 0; }

/* Assignments panel -------------------------------------------------------- */

.assign-body { padding: 16px 20px; }
.assign-form {
  display: flex;
  gap: 8px;
  align-items: flex-end;
  flex-wrap: wrap;
}
.assign-form .select { flex: 1 1 240px; }
.assign-form .input { flex: 0 0 170px; }

/* ==========================================================================
   Phase 4: quizzes
   ========================================================================== */

/* Editor: quiz panel per section */
.quiz-editor {
  margin-top: 12px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--surface-2);
}
.quiz-editor > summary {
  cursor: pointer;
  padding: 10px 16px;
  font-weight: 600;
  font-size: 14px;
  list-style: none;
  display: flex;
  align-items: center;
  gap: 10px;
}
.quiz-editor > summary::-webkit-details-marker { display: none; }
.quiz-editor > summary::before { content: '▸'; color: var(--ink-3); }
.quiz-editor[open] > summary::before { content: '▾'; }
.quiz-editor-count { color: var(--ink-3); font-weight: 400; font-size: 13px; }

.quiz-editor-body { padding: 4px 16px 16px; }

.quiz-settings {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 0 14px;
  border-bottom: 1px solid var(--line);
  margin-bottom: 14px;
}
.quiz-threshold { display: flex; align-items: center; gap: 8px; font-size: 14px; }
.quiz-threshold .input { width: 72px; }
.quiz-settings-spacer { flex: 1; }

.quiz-q {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 12px 14px;
  margin-bottom: 12px;
}
.quiz-q-head {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 10px;
}
.quiz-q-head .input { flex: 1; min-width: 0; }
.quiz-q-head .select { flex: 0 0 190px; }
.quiz-q-num {
  flex: none;
  width: 26px;
  height: 26px;
  border-radius: 50%;
  background: var(--teal-900);
  color: #fff;
  font-size: 13px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}

.quiz-options { padding-left: 34px; display: flex; flex-direction: column; gap: 6px; }
.quiz-opt { display: flex; align-items: center; gap: 8px; }
.quiz-opt .input { flex: 1; min-width: 0; }
.quiz-opt-correct {
  flex: none;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 30px;
  height: 30px;
  border: 1px solid var(--line-strong);
  border-radius: var(--radius);
  background: var(--surface);
}
.quiz-opt-correct input:checked { accent-color: var(--ok); }
.quiz-opt-add { opacity: .85; }

.quiz-add-q { margin-top: 14px; padding-top: 14px; border-top: 1px solid var(--line); }
.quiz-add-q-row { display: flex; gap: 8px; }
.quiz-add-q-row .input { flex: 1; }
.quiz-add-q-row .select { flex: 0 0 190px; }

/* Reader: quiz taking */
.quiz {
  margin-top: 20px;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius-lg);
  padding: 24px 28px;
}
.quiz-title { margin: 0 0 4px; font-size: 20px; }
.quiz-intro { margin: 0 0 6px; color: var(--ink-2); font-size: 14px; }
.quiz-last-attempt { margin: 0 0 16px; color: var(--brass); font-size: 14px; }

.quiz-question {
  border: 0;
  border-top: 1px solid var(--line);
  padding: 16px 0 4px;
  margin: 0;
}
.quiz-question legend { font-weight: 600; padding: 0; margin-bottom: 8px; }
.quiz-hint-multi { font-size: 13px; color: var(--ink-3); margin: 0 0 8px; }
.quiz-option {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 10px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  margin-bottom: 6px;
  cursor: pointer;
}
.quiz-option:hover { background: var(--surface-2); }
.quiz-actions { margin-top: 18px; }

.reader-quiz-hint { font-size: 13px; color: var(--ink-3); }

.quiz-passed {
  margin-top: 20px;
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 16px 20px;
  background: var(--ok-100);
  color: var(--ok);
  border-radius: var(--radius-lg);
  font-weight: 600;
}
.quiz-passed-badge {
  width: 26px; height: 26px;
  border-radius: 50%;
  background: var(--ok);
  color: #fff;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}

/* ==========================================================================
   Exams (Koe)
   ========================================================================== */

.exam-create { margin-bottom: 20px; }
.exam-create-row { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; }
.exam-create-row .input[type="text"] { flex: 1 1 260px; }
.exam-threshold-inline, .exam-threshold-input { display: inline-flex; align-items: center; gap: 6px; font-size: 14px; }
.exam-threshold-inline .input, .exam-threshold-input .input { width: 72px; }

.page-head-actions { display: flex; align-items: center; gap: 10px; }
.page-head-actions form { margin: 0; }

.exam-not-ready {
  background: var(--brass-100);
  color: var(--brass);
  border-radius: var(--radius);
  padding: 10px 14px;
  margin-bottom: 16px;
}

.exam-settings .field { display: block; margin-bottom: 14px; }
.exam-settings .field > span { display: block; font-size: 13px; color: var(--ink-3); margin-bottom: 4px; }
.exam-threshold-field .exam-threshold-input { margin-top: 2px; }

/* Question head reuses quiz styles, plus a points box */
.exam-points { display: inline-flex; align-items: center; gap: 5px; flex: none; }
.exam-points .input { width: 62px; }
.exam-points span { font-size: 13px; color: var(--ink-3); }
.exam-add-q-row { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.exam-add-q-row .input[type="text"] { flex: 1 1 200px; }
.exam-add-q-row .select { flex: 0 0 180px; }

.exam-q-points { font-weight: 400; font-size: 13px; color: var(--brass); margin-left: 6px; }
.exam-take-desc { color: var(--ink-2); margin: 0 0 10px; }

/* Result screen */
.exam-result-card { text-align: left; }
.exam-result {
  display: flex;
  align-items: center;
  gap: 18px;
  padding: 24px;
  border-radius: var(--radius-lg);
  margin: 8px 0 20px;
}
.exam-result.is-pass { background: var(--ok-100); }
.exam-result.is-fail { background: var(--danger-100); }
.exam-result-badge {
  flex: none;
  width: 52px; height: 52px;
  border-radius: 50%;
  color: #fff;
  font-size: 26px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}
.exam-result.is-pass .exam-result-badge { background: var(--ok); }
.exam-result.is-fail .exam-result-badge { background: var(--danger); }
.exam-result-text h1 { margin: 0 0 4px; font-size: 22px; }
.exam-result-score { margin: 0 0 4px; font-size: 18px; font-weight: 600; }

/* Exam results: per-question training-need breakdown */
.exam-breakdown-intro { padding: 0 20px; margin: 0 0 8px; }
.exam-breakdown .table { margin-top: 4px; }
.exam-gap { background: var(--danger-100); }
.wrong-meter {
  display: inline-block;
  vertical-align: middle;
  width: 120px;
  height: 8px;
  border-radius: 999px;
  background: var(--surface-2);
  overflow: hidden;
  margin-right: 8px;
}
.wrong-meter span { display: block; height: 100%; background: var(--danger); }

/* ==========================================================================
   Drag ordering and the single save bar
   ========================================================================== */

/* One toolbar for the whole page, so saving is not hunted per section. */
.save-bar {
  position: sticky;
  top: 12px;
  z-index: 30;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 16px;
  padding: 10px 16px;
  background: var(--surface);
  border: 1px solid var(--brass);
  border-radius: var(--radius-lg);
  box-shadow: 0 4px 16px rgba(16, 24, 40, .10);
}
.save-bar-text {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  font-size: 14px;
  color: var(--ink-2);
}
.save-bar .btn.is-saving { opacity: .7; }

.drag-handle {
  flex: none;
  cursor: grab;
  user-select: none;
  color: var(--ink-3);
  font-size: 18px;
  line-height: 1;
  padding: 2px 6px;
  border-radius: var(--radius);
}
.drag-handle:hover { color: var(--ink); background: var(--surface-2); }
.drag-handle:active { cursor: grabbing; }

.section-card.is-dragging,
.block.is-dragging { opacity: .45; }

/* Where the dragged item will land. */
.section-card.drop-before,
.block.drop-before { box-shadow: 0 -3px 0 0 var(--brass); }
.section-card.drop-after,
.block.drop-after { box-shadow: 0 3px 0 0 var(--brass); }

.is-saving-order { opacity: .7; }

@media (max-width: 640px) {
  .save-bar { flex-direction: column; align-items: stretch; }
}

/* Version row actions on the module summary */
.version-actions { display: inline-flex; gap: 6px; margin-left: auto; }
.version-line { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }

/* Quiz readiness warning in the editor */
.quiz-not-live { margin: 10px 0 14px; }
.quiz-not-live ul { margin: 6px 0 0; padding-left: 20px; }
.quiz-not-live li { margin-bottom: 4px; }

/* ==========================================================================
   Manager reports
   ========================================================================== */

.stat-row {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  gap: 14px;
  margin-bottom: 20px;
}
.stat-card {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius-lg);
  padding: 16px 18px;
}
.stat-card.stat-alert { border-color: var(--danger); background: var(--danger-100); }
.stat-label {
  margin: 0 0 4px;
  font-size: 12px;
  text-transform: uppercase;
  letter-spacing: .04em;
  color: var(--ink-3);
}
.stat-value { margin: 0; font-size: 30px; font-weight: 600; line-height: 1.1; }
.stat-card.stat-alert .stat-value { color: var(--danger); }
.stat-card .hint { margin: 4px 0 0; }

.report-filter { display: flex; gap: 8px; margin-bottom: 16px; }

/* Small inline progress meter used in the report tables. */
.meter {
  width: 120px;
  height: 8px;
  border-radius: 999px;
  background: var(--surface-2);
  overflow: hidden;
  display: inline-block;
  vertical-align: middle;
  margin-right: 8px;
}
.meter span { display: block; height: 100%; background: var(--teal-500); }

tr.row-alert { background: var(--danger-100); }
tr.row-alert .table-name { color: var(--danger); }

@media (max-width: 640px) {
  .meter { width: 80px; }
}

/* ==========================================================================
   Dashboard and grouped navigation
   ========================================================================== */

/* Admin tools live behind one <details> menu, so no JavaScript is needed. */
.nav-menu { position: relative; display: inline-block; }
.nav-menu > summary {
  list-style: none;
  cursor: pointer;
  padding: 6px 10px;
  border-radius: var(--radius);
  color: inherit;
  white-space: nowrap;
}
.nav-menu > summary::-webkit-details-marker { display: none; }
.nav-menu > summary::after { content: ' ▾'; opacity: .6; font-size: 11px; }
.nav-menu > summary:hover { background: rgba(255, 255, 255, .12); }
.nav-menu[open] > summary { background: rgba(255, 255, 255, .12); }

.nav-menu-items {
  position: absolute;
  right: 0;
  top: calc(100% + 6px);
  min-width: 190px;
  z-index: 60;
  display: flex;
  flex-direction: column;
  padding: 6px;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius-lg);
  box-shadow: 0 8px 24px rgba(16, 24, 40, .16);
}
.nav-menu-items a {
  padding: 8px 10px;
  border-radius: var(--radius);
  color: var(--ink);
  text-decoration: none;
  white-space: nowrap;
}
.nav-menu-items a:hover { background: var(--surface-2); }
.nav-menu-items a.is-current { color: var(--teal-700); font-weight: 600; }

/* A full-width nudge for managers when something is overdue. */
.notice {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 12px 18px;
  margin-bottom: 18px;
  border-radius: var(--radius-lg);
  text-decoration: none;
  color: inherit;
}
.notice-alert { background: var(--danger-100); border: 1px solid var(--danger); color: var(--danger); }
.notice-alert:hover { filter: brightness(.98); }

.continue-card { margin-bottom: 18px; border-left: 3px solid var(--brass); }
.continue-title { margin: 2px 0 6px; font-size: 22px; }
.continue-summary { margin: 0 0 14px; }
.continue-foot {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 20px;
  flex-wrap: wrap;
}
.continue-progress { flex: 1 1 260px; display: flex; flex-direction: column; gap: 6px; }

.dash-count { font-size: 15px; margin: 4px 0 10px; }
.dash-count strong { font-size: 24px; }
.dash-empty-title { margin: 4px 0 6px; font-size: 18px; }
.dash-none { margin: 6px 0 0; }

.dash-list { list-style: none; margin: 8px 0 0; padding: 0; }
.dash-list li {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding: 8px 0;
  border-top: 1px solid var(--line);
}
.dash-list li:first-child { border-top: 0; }

.dash-roles { margin-top: 14px; }
.dash-manager { margin-top: 20px; }
.dash-manager-stats {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(120px, 1fr));
  gap: 16px;
  padding: 16px 20px;
}
.dash-manager-stats .stat-value { font-size: 26px; margin: 0; }
.text-alert { color: var(--danger); }

@media (max-width: 640px) {
  .nav-menu-items { right: auto; left: 0; }
  .continue-foot { flex-direction: column; align-items: stretch; }
}

/* Impersonation banner: always visible while viewing as someone else. */
.impersonation-bar {
  position: sticky;
  top: 0;
  z-index: 100;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 8px 20px;
  background: var(--brand-500);
  color: var(--paper);
  font-weight: 600;
  font-size: 14px;
}
.impersonation-bar form { margin: 0; }

/* ==========================================================================
   Charts (inline SVG, no libraries)
   ========================================================================== */

.chart-panel { margin-bottom: 20px; padding: 20px 22px; }
.chart-grid {
  display: grid;
  grid-template-columns: auto 1fr 1fr;
  gap: 28px;
  align-items: center;
}
.chart-cell { min-width: 0; }
.chart-cell-donut { text-align: center; }

.chart-title {
  margin: 0 0 10px;
  font-size: 12px;
  text-transform: uppercase;
  letter-spacing: .04em;
  color: var(--ink-3);
}
.chart-caption { margin: 8px 0 0; font-size: 12px; color: var(--ink-3); }

.chart-donut-value {
  font-family: var(--sans);
  font-size: 22px;
  font-weight: 600;
  fill: var(--ink);
}
.chart-bar { border-radius: 999px; overflow: hidden; display: block; }
.chart-columns { display: block; }

.chart-legend {
  list-style: none;
  margin: 10px 0 0;
  padding: 0;
  display: flex;
  flex-wrap: wrap;
  gap: 4px 16px;
  font-size: 13px;
  color: var(--ink-2);
}
.chart-legend li { display: inline-flex; align-items: center; gap: 6px; }
.chart-legend .swatch {
  width: 10px;
  height: 10px;
  border-radius: 2px;
  display: inline-block;
}

@media (max-width: 900px) {
  .chart-grid { grid-template-columns: 1fr; gap: 22px; }
  .chart-cell-donut { text-align: left; }
}

/* ==========================================================================
   Reader sidebar: course outline and progress
   ========================================================================== */

.reader-layout {
  display: grid;
  grid-template-columns: 260px minmax(0, 1fr);
  gap: 28px;
  align-items: start;
}

.reader-outline {
  position: sticky;
  top: 16px;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius-lg);
  padding: 4px 0;
  max-height: calc(100vh - 32px);
  overflow-y: auto;
}
.reader-outline-summary {
  list-style: none;
  cursor: default;
  padding: 12px 16px 8px;
  display: flex;
  flex-direction: column;
  gap: 2px;
}
.reader-outline-summary::-webkit-details-marker { display: none; }
.reader-outline-title {
  font-size: 12px;
  text-transform: uppercase;
  letter-spacing: .06em;
  color: var(--ink-3);
}
.reader-outline-count { font-size: 13px; color: var(--ink-2); }
.reader-outline-body { padding: 0 12px 12px; }
.reader-outline-body .reader-progress { margin: 0 4px 12px; }

.outline-list {
  list-style: none;
  margin: 0;
  padding: 0;
  counter-reset: none;
}
.outline-item a {
  display: flex;
  align-items: flex-start;
  gap: 9px;
  padding: 8px 10px;
  border-radius: var(--radius);
  color: var(--ink-2);
  text-decoration: none;
  font-size: 14px;
  line-height: 1.35;
}
.outline-item a:hover { background: var(--surface-2); color: var(--ink); }

/* Numero, tai valintamerkki kun osio on suoritettu. */
.outline-mark {
  flex: none;
  width: 20px;
  height: 20px;
  margin-top: 1px;
  border-radius: 50%;
  border: 1px solid var(--line-strong);
  font-size: 11px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  color: var(--ink-3);
}
.outline-item.is-done .outline-mark {
  background: var(--ok);
  border-color: var(--ok);
  color: var(--paper);
}
.outline-item.is-current > a {
  background: var(--brand-100);
  color: var(--ink);
  font-weight: 600;
}
.outline-item.is-current .outline-mark {
  border-color: var(--brand-500);
  color: var(--brand-500);
}
.outline-item.is-current.is-done .outline-mark { color: var(--paper); }

.outline-text { flex: 1; min-width: 0; }

/* Merkki osiosta jossa on kysely. */
.outline-quiz {
  flex: none;
  width: 18px;
  height: 18px;
  margin-top: 2px;
  border-radius: 50%;
  background: var(--surface-2);
  border: 1px solid var(--line-strong);
  color: var(--ink-3);
  font-size: 11px;
  font-weight: 700;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}
.outline-quiz.is-passed {
  background: var(--ok-100);
  border-color: var(--ok);
  color: var(--ok);
}

.outline-back {
  display: inline-block;
  margin: 10px 10px 2px;
  font-size: 13px;
  color: var(--teal-700);
  text-decoration: none;
}

.reader-module-name {
  font-size: 13px;
  text-transform: uppercase;
  letter-spacing: .04em;
  color: var(--brass-dot);
}

/* Kapea naytto: sisallys avattavaksi sisallon ylapuolelle. */
@media (max-width: 900px) {
  .reader-layout { grid-template-columns: 1fr; gap: 16px; }
  .reader-outline {
    position: static;
    max-height: none;
  }
  .reader-outline-summary { cursor: pointer; flex-direction: row; justify-content: space-between; align-items: center; }
  .reader-outline-summary::after { content: '▾'; color: var(--ink-3); }
  .reader-outline:not([open]) .reader-outline-summary::after { content: '▸'; }
}

/* Yksittainen valintaruutu kentassa (esim. ilmoitusasetus). */
.checkbox {
  display: flex;
  align-items: center;
  gap: 10px;
  cursor: pointer;
  font-size: 14px;
  color: var(--ink-2);
}
.checkbox input { flex: none; }

/* Kyselyn kysymyslomake: koko kysymys vaihtoehtoineen yhtena kokonaisuutena */
.quiz-options-head {
  display: flex;
  gap: 8px;
  margin: 0 0 6px;
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: .06em;
  color: var(--ink-3);
}
.quiz-correct-head { flex: none; width: 30px; text-align: center; }

.quiz-opt-remove {
  flex: none;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 4px;
  width: 30px;
  height: 30px;
  border-radius: var(--radius);
  color: var(--ink-3);
  cursor: pointer;
}
.quiz-opt-remove:hover { color: var(--danger); background: var(--danger-100); }
/* Rastitettu poisto nakyy heti, jottei se yllata tallennettaessa. */
.quiz-opt-remove input { position: absolute; opacity: 0; width: 0; height: 0; }
.quiz-opt-remove:has(input:checked) { color: var(--danger); background: var(--danger-100); }
.quiz-opt:has(.quiz-opt-remove input:checked) .input {
  text-decoration: line-through;
  opacity: .55;
}

.quiz-q-actions {
  display: flex;
  gap: 8px;
  margin-top: 12px;
  padding-top: 10px;
  border-top: 1px solid var(--line);
}
.quiz-add-q .quiz-options { padding-left: 0; margin-top: 10px; }
.quiz-add-q .hint { margin: 6px 0 12px; }

/* ==========================================================================
   Kurssin aloitussivu
   ========================================================================== */

.overview { max-width: 760px; margin: 0 auto; }
.overview-head { margin: 12px 0 20px; }
.overview-title { margin: 6px 0 8px; font-size: 30px; line-height: 1.2; }
.overview-summary {
  margin: 0 0 10px;
  font-size: 17px;
  line-height: 1.55;
  color: var(--ink-2);
  max-width: 62ch;
}
.overview-facts {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin: 0;
  font-size: 14px;
  color: var(--ink-3);
}

.overview-h2 {
  margin: 0 0 12px;
  font-size: 13px;
  text-transform: uppercase;
  letter-spacing: .06em;
  color: var(--ink-3);
}

.overview-objectives { padding: 20px 24px; margin-bottom: 16px; }
.overview-objectives .prose { max-width: 62ch; }
.overview-objectives .prose ul { margin-bottom: 0; }

/* Aloituskortti erottuu, koska se on sivun ainoa toiminto. */
.overview-start {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 24px;
  padding: 20px 24px;
  margin-bottom: 16px;
  border-left: 3px solid var(--brand-500);
}
.overview-start-text { flex: 1; min-width: 0; }
.overview-state { margin: 0 0 4px; font-weight: 600; color: var(--ok); }
.overview-progress-label { margin: 6px 0 0; font-size: 13px; }

.overview-contents { padding: 20px 24px; }
.overview-list { margin: 0; }
.overview-list .outline-item a { font-size: 15px; padding: 10px; }

@media (max-width: 640px) {
  .overview-start { flex-direction: column; align-items: stretch; }
  .overview-title { font-size: 24px; }
}

/* ==========================================================================
   Minimoitavat osiot editorissa
   ========================================================================== */

.section-details > summary.section-head {
  list-style: none;
  cursor: pointer;
  user-select: none;
}
.section-details > summary::-webkit-details-marker { display: none; }

/* Kolmio kertoo tilan; se on ainoa lisays otsikkoriville. */
.section-details > summary.section-head::after {
  content: '▸';
  margin-left: auto;
  color: var(--ink-3);
  font-size: 12px;
  flex: none;
}
.section-details[open] > summary.section-head::after { content: '▾'; }
.section-details > summary.section-head:hover { background: var(--surface-2); }

.section-summary-title {
  font-weight: 600;
  font-size: 15px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.section-meta {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  font-size: 13px;
  color: var(--ink-3);
  white-space: nowrap;
}
.section-meta-quiz {
  width: 18px;
  height: 18px;
  border-radius: 50%;
  background: var(--surface-2);
  border: 1px solid var(--line-strong);
  font-size: 11px;
  font-weight: 700;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}

/* Suljetunkin osion voi nahda muuttuneeksi. */
.section-card.has-unsaved > .section-details > summary.section-head {
  border-left: 3px solid var(--brass);
}

.section-titlebar {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
  padding: 14px 20px 4px;
}
.section-titlebar .section-title-form { flex: 1; min-width: 220px; }

/* ==========================================================================
   Videolohko
   ========================================================================== */

.video-block { margin: 16px 0; }

/* Upotus skaalautuu leveyden mukaan 16:9-suhteessa, jotta se ei hypi
   latautuessaan eika vaadi kiinteita mittoja. */
.video-frame {
  position: relative;
  width: 100%;
  aspect-ratio: 16 / 9;
  background: #000;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  overflow: hidden;
}
.video-frame iframe {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  border: 0;
}

.video-player {
  width: 100%;
  max-height: 70vh;
  background: #000;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  display: block;
}

.video-fallback { margin: 6px 0 0; font-size: 13px; }
.video-block figcaption { font-size: 13px; color: var(--ink-3); margin-top: 6px; }

/* Radiovalinta videon lahteelle */
.radio-row {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 14px;
  color: var(--ink-2);
  margin-top: 4px;
}
.radio-row input { flex: none; }
