/* ==========================================================================
   Lekce — design tokens & base
   Charakter: minimalistický, teplý, pastelový, lehce do růžova.
   Blíž papírovému zápisníku než "appce": hodně prostoru, žádné stíny navíc,
   žádné rámečky tam, kde stačí odsazení.
   ========================================================================== */

:root {
  /* --- světlý režim ------------------------------------------------------ */
  --bg: #FBF5F1;
  --surface: #FFFFFF;
  --surface-alt: #FDEDE7;
  --primary: #C97C6C;
  --primary-ink: #FFFFFF;
  --primary-soft: #F3D3CA;      /* podklad čipu "počáteční pozice" */
  --primary-soft-ink: #6E3B2E;
  --props-bg: #E4C9A8;          /* čipy pomůcek — teplá pískově-broskvová */
  --props-ink: #7A5C36;
  --text: #3A2E2A;
  --text-muted: #8E7C74;
  --separator: #EFE1DA;
  --danger: #B4453C;
  --warn-flag: #D9A521;

  /* pružiny — reálné barvy pružin reformeru */
  --spring-red: #D24B3E;
  --spring-blue: #3D7BC4;
  --spring-yellow: #E9C63C;
  --spring-green: #4FA46B;
  --spring-white: #FFFFFF;
  --spring-black: #342E2C;

  /* --- rozměry ----------------------------------------------------------- */
  --radius: 14px;
  --radius-sm: 9px;
  --radius-chip: 999px;
  --gap: 16px;
  --pad-screen: 20px;
  --sidebar-w: 250px;
  --list-w: 330px;
  --tap: 44px;                  /* minimální dotyková plocha */

  --font-round: ui-rounded, "SF Pro Rounded", -apple-system, BlinkMacSystemFont,
                "Segoe UI", system-ui, sans-serif;
  --font-body: -apple-system, BlinkMacSystemFont, "SF Pro Text", "Segoe UI",
               system-ui, sans-serif;

  --safe-t: env(safe-area-inset-top, 0px);
  --safe-b: env(safe-area-inset-bottom, 0px);
  --safe-l: env(safe-area-inset-left, 0px);
  --safe-r: env(safe-area-inset-right, 0px);

  color-scheme: light dark;
}

/* --- tmavý režim --------------------------------------------------------- */
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #1E1917;
    --surface: #272120;
    --surface-alt: #332A28;
    --primary: #E3A392;
    --primary-ink: #2A1D19;
    --primary-soft: #4A3630;
    --primary-soft-ink: #F6DCD4;
    --props-bg: #4A3D2C;
    --props-ink: #E8D3B4;
    --text: #F2E9E4;
    --text-muted: #A2908A;
    --separator: #3A302E;
    --danger: #E8877C;
    --spring-white: #F2ECEA;
    --spring-black: #1A1616;
  }
}
/* ruční přepnutí ze Nastavení má přednost před systémem */
:root[data-theme="dark"] {
  --bg: #1E1917;
  --surface: #272120;
  --surface-alt: #332A28;
  --primary: #E3A392;
  --primary-ink: #2A1D19;
  --primary-soft: #4A3630;
  --primary-soft-ink: #F6DCD4;
  --props-bg: #4A3D2C;
  --props-ink: #E8D3B4;
  --text: #F2E9E4;
  --text-muted: #A2908A;
  --separator: #3A302E;
  --danger: #E8877C;
  --spring-white: #F2ECEA;
  --spring-black: #1A1616;
}

/* ==========================================================================
   Reset
   ========================================================================== */

*, *::before, *::after { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  height: 100%;
  overscroll-behavior-y: none;
}

body {
  background: var(--bg);
  color: var(--text);
  font-family: var(--font-body);
  font-size: 17px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
  -webkit-text-size-adjust: 100%;
  /* v prezentaci nechceme modré výběry a callouty */
  -webkit-tap-highlight-color: transparent;
}

h1, h2, h3, h4 {
  font-family: var(--font-round);
  font-weight: 600;
  letter-spacing: -0.015em;
  margin: 0;
}

button, input, select, textarea { font: inherit; color: inherit; }

button {
  background: none;
  border: 0;
  padding: 0;
  cursor: pointer;
  color: inherit;
  font-family: var(--font-round);
}

/* ikony se nesmí roztahovat podle tlačítka */
svg { width: 20px; height: 20px; flex-shrink: 0; }

a { color: var(--primary); text-decoration: none; }

:focus-visible {
  outline: 2px solid var(--primary);
  outline-offset: 2px;
  border-radius: 4px;
}

/* skryté jen vizuálně, čitelné pro VoiceOver */
.sr-only {
  position: absolute; width: 1px; height: 1px;
  padding: 0; margin: -1px; overflow: hidden;
  clip: rect(0 0 0 0); white-space: nowrap; border: 0;
}

/* ==========================================================================
   App shell — iPhone: jeden sloupec / iPad + Mac: split view
   ========================================================================== */

#app {
  height: 100%;
  display: flex;
  flex-direction: column;
}

.screen {
  flex: 1;
  min-height: 0;
  display: flex;
  flex-direction: column;
}

.split {
  flex: 1;
  min-height: 0;
  display: grid;
  grid-template-columns: 1fr;
}

@media (min-width: 900px) {
  .split.split--three {
    grid-template-columns: var(--sidebar-w) var(--list-w) 1fr;
  }
  .split.split--two { grid-template-columns: var(--list-w) 1fr; }
}

.pane {
  min-width: 0;
  min-height: 0;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}
.pane + .pane { border-left: 1px solid var(--separator); }
@media (max-width: 899px) { .pane + .pane { border-left: 0; } }

.pane__scroll {
  flex: 1;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
  padding-bottom: calc(var(--safe-b) + 24px);
}

/* ==========================================================================
   Toolbar
   ========================================================================== */

.toolbar {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px var(--pad-screen);
  padding-top: calc(10px + var(--safe-t));
  padding-left: calc(var(--pad-screen) + var(--safe-l));
  padding-right: calc(var(--pad-screen) + var(--safe-r));
  background: var(--bg);
  border-bottom: 1px solid var(--separator);
  min-height: calc(52px + var(--safe-t));
  flex-shrink: 0;
  position: sticky;
  top: 0;
  z-index: 20;
}
.pane .toolbar { padding-top: 10px; min-height: 52px; }
.pane:first-child .toolbar { padding-top: calc(10px + var(--safe-t)); }
@media (min-width: 900px) { .pane .toolbar { padding-top: calc(10px + var(--safe-t)); } }

.toolbar__title {
  font-family: var(--font-round);
  font-size: 19px;
  font-weight: 600;
  flex: 1;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.toolbar__spacer { flex: 1; }

.tbtn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  min-width: var(--tap);
  height: 38px;
  padding: 0 12px;
  border-radius: var(--radius-sm);
  color: var(--primary);
  font-size: 16px;
  font-weight: 500;
  white-space: nowrap;
}
.tbtn:hover { background: var(--surface-alt); }
.tbtn:active { opacity: .6; }
.tbtn--icon { padding: 0; width: var(--tap); }
.tbtn--plain { color: var(--text); }
.tbtn--danger { color: var(--danger); }
.tbtn[disabled] { opacity: .35; pointer-events: none; }
.tbtn svg { width: 21px; height: 21px; }

/* ==========================================================================
   Segmented control
   ========================================================================== */

.segmented {
  display: inline-flex;
  background: var(--surface-alt);
  border-radius: 10px;
  padding: 2px;
  gap: 2px;
}
.segmented button {
  padding: 6px 14px;
  border-radius: 8px;
  font-size: 14.5px;
  font-weight: 500;
  color: var(--text-muted);
  min-height: 32px;
}
.segmented button[aria-selected="true"] {
  background: var(--surface);
  color: var(--text);
}

/* ==========================================================================
   Čipy — pozice / pomůcky / pružiny mají vlastní odlišnou barvu
   Kontrast ≥ 4.5:1 → vždy tmavý text, nikdy bílý.
   ========================================================================== */

.chips { display: flex; flex-wrap: wrap; gap: 6px; align-items: center; }

.chip {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 3px 10px;
  border-radius: var(--radius-chip);
  font-size: 13.5px;
  font-weight: 500;
  line-height: 1.45;
  white-space: nowrap;
  max-width: 100%;
  overflow: hidden;
  text-overflow: ellipsis;
}
.chip--position { background: var(--primary-soft); color: var(--primary-soft-ink); }
.chip--prop     { background: var(--props-bg);    color: var(--props-ink); }
.chip--category { background: var(--surface-alt); color: var(--text-muted); }
.chip--tag      { background: var(--surface-alt); color: var(--text-muted); }
.chip__x { opacity: .55; font-size: 15px; line-height: 1; padding: 2px 0 2px 2px; }
.chip__x:hover { opacity: 1; }

/* barevná kolečka pružin — ne text */
.springs { display: inline-flex; align-items: center; gap: 5px; flex-wrap: wrap; }
.spring-group { display: inline-flex; align-items: center; gap: 3px; }
.spring-dot {
  width: 16px; height: 16px;
  border-radius: 50%;
  flex-shrink: 0;
  box-shadow: inset 0 0 0 1px rgba(0,0,0,.16);
}
.spring-dot--red    { background: var(--spring-red); }
.spring-dot--blue   { background: var(--spring-blue); }
.spring-dot--yellow { background: var(--spring-yellow); }
.spring-dot--green  { background: var(--spring-green); }
.spring-dot--white  { background: var(--spring-white); }
.spring-dot--black  { background: var(--spring-black); }
.spring-or {
  font-size: 12.5px;
  color: var(--text-muted);
  padding: 0 2px;
  font-family: var(--font-round);
}

/* ==========================================================================
   Seznam lekcí
   ========================================================================== */

.list { padding: 4px var(--pad-screen) 0; }
.list__section-head {
  font-family: var(--font-round);
  font-size: 13px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: .05em;
  color: var(--text-muted);
  padding: 18px 4px 7px;
  position: sticky;
  top: 0;
  background: var(--bg);
  z-index: 5;
}

.row {
  display: flex;
  align-items: center;
  gap: 12px;
  width: 100%;
  padding: 12px 14px;
  border-radius: var(--radius);
  text-align: left;
  min-height: var(--tap);
  position: relative;
}
.row:hover { background: var(--surface); }
.row[aria-current="true"] { background: var(--surface); }
.row + .row::before {
  content: "";
  position: absolute;
  left: 14px; right: 14px; top: 0;
  border-top: 1px solid var(--separator);
}
.row:hover::before, .row[aria-current="true"]::before,
.row:hover + .row::before, .row[aria-current="true"] + .row::before { border-color: transparent; }

.row__main { flex: 1; min-width: 0; }
.row__title {
  font-family: var(--font-round);
  font-size: 16.5px;
  font-weight: 600;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.row__meta {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
  font-size: 13px;
  color: var(--text-muted);
  margin-top: 3px;
}
.row__star { color: var(--primary); flex-shrink: 0; }
.row__star svg { width: 17px; height: 17px; }
.row__flag { color: var(--warn-flag); flex-shrink: 0; }

.cat-dot {
  width: 9px; height: 9px;
  border-radius: 50%;
  flex-shrink: 0;
  background: var(--primary);
}

/* ==========================================================================
   Editor
   ========================================================================== */

.doc {
  max-width: 760px;
  margin: 0 auto;
  padding: 8px var(--pad-screen) 140px;
}
.doc--wide { max-width: 900px; }

.lesson-title {
  font-family: var(--font-round);
  font-size: 28px;
  font-weight: 700;
  letter-spacing: -0.02em;
  width: 100%;
  border: 0;
  background: none;
  padding: 14px 0 4px;
  outline: none;
}
.lesson-title::placeholder { color: var(--text-muted); opacity: .5; }

.lesson-sub {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
  font-size: 13.5px;
  color: var(--text-muted);
  padding-bottom: 14px;
  border-bottom: 1px solid var(--separator);
  margin-bottom: 6px;
}

/* sekce = karta s jemným oddělením, ne rámeček */
.section-card {
  padding: 14px 16px 16px;
  border-radius: var(--radius);
  margin: 2px 0;
  position: relative;
}
.section-card:hover { background: var(--surface); }
.section-card--focus { background: var(--surface); }
.section-card + .section-card::before {
  content: "";
  position: absolute;
  left: 16px; right: 16px; top: -1px;
  border-top: 1px solid var(--separator);
}
.section-card:hover::before, .section-card--focus::before,
.section-card:hover + .section-card::before,
.section-card--focus + .section-card::before { border-color: transparent; }
.section-card--dragging { opacity: .4; }
.section-card--over { box-shadow: 0 -2px 0 var(--primary); }

.section-head { display: flex; align-items: center; gap: 8px; }
.section-title {
  flex: 1;
  min-width: 0;
  font-family: var(--font-round);
  font-size: 19px;
  font-weight: 600;
  border: 0;
  background: none;
  padding: 2px 0;
  outline: none;
}
.section-title::placeholder { color: var(--text-muted); opacity: .45; font-weight: 500; }

.section-grip {
  color: var(--text-muted);
  opacity: 0;
  cursor: grab;
  width: 26px; height: 30px;
  display: flex; align-items: center; justify-content: center;
  flex-shrink: 0;
  touch-action: none;
}
.section-card:hover .section-grip, .section-card--focus .section-grip { opacity: .5; }
.section-grip:active { cursor: grabbing; }
@media (pointer: coarse) { .section-grip { opacity: .4; } }

.section-meta { margin: 7px 0 2px; }
.section-body { margin-top: 6px; }
.section-note {
  margin-top: 8px;
  padding: 8px 11px;
  background: var(--surface-alt);
  border-radius: var(--radius-sm);
  font-size: 14.5px;
  color: var(--text-muted);
  font-style: italic;
}

.section-add {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 7px;
  width: 100%;
  padding: 13px;
  margin-top: 10px;
  border-radius: var(--radius);
  border: 1px dashed var(--separator);
  color: var(--text-muted);
  font-size: 15px;
  font-weight: 500;
  min-height: var(--tap);
}
.section-add:hover { color: var(--primary); border-color: var(--primary); }

/* --- rich text ----------------------------------------------------------- */

.rt {
  outline: none;
  min-height: 1.6em;
  font-size: 16.5px;
  line-height: 1.62;
  word-wrap: break-word;
}
.rt:empty::before {
  content: attr(data-placeholder);
  color: var(--text-muted);
  opacity: .45;
  pointer-events: none;
}
.rt h1 { font-size: 23px; margin: 14px 0 5px; }
.rt h2 { font-size: 19.5px; margin: 12px 0 4px; }
.rt h1:first-child, .rt h2:first-child, .rt p:first-child { margin-top: 0; }
.rt p { margin: 0 0 7px; }
.rt ul, .rt ol { margin: 5px 0 8px; padding-left: 1.35em; }
.rt li { margin: 2px 0; }
.rt s { opacity: .6; }
.rt a { text-decoration: underline; }

/* formátovací lišta */
.fmtbar {
  display: flex;
  align-items: center;
  gap: 3px;
  padding: 6px 8px;
  background: var(--surface);
  border-top: 1px solid var(--separator);
  overflow-x: auto;
  scrollbar-width: none;
  flex-shrink: 0;
  padding-bottom: calc(6px + var(--safe-b));
}
.fmtbar::-webkit-scrollbar { display: none; }
.fmtbar button {
  min-width: 40px;
  height: 38px;
  padding: 0 9px;
  border-radius: 8px;
  font-size: 15px;
  font-weight: 600;
  color: var(--text);
  flex-shrink: 0;
}
.fmtbar button:hover { background: var(--surface-alt); }
.fmtbar button[aria-pressed="true"] { background: var(--primary-soft); color: var(--primary-soft-ink); }
.fmtbar .sep { width: 1px; height: 22px; background: var(--separator); margin: 0 4px; flex-shrink: 0; }

/* ==========================================================================
   Combobox (pozice / pomůcky)
   ========================================================================== */

.meta-add {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 3px 9px;
  border-radius: var(--radius-chip);
  border: 1px dashed var(--separator);
  color: var(--text-muted);
  font-size: 13px;
  min-height: 28px;
}
.meta-add:hover { color: var(--primary); border-color: var(--primary); }

.combo { position: relative; display: inline-block; }
.combo__input {
  border: 1px solid var(--primary);
  background: var(--surface);
  border-radius: var(--radius-chip);
  padding: 3px 11px;
  font-size: 13.5px;
  outline: none;
  min-width: 150px;
  min-height: 28px;
}
.combo__menu {
  position: absolute;
  top: calc(100% + 5px);
  left: 0;
  min-width: 230px;
  max-width: 320px;
  max-height: 280px;
  overflow-y: auto;
  background: var(--surface);
  border: 1px solid var(--separator);
  border-radius: var(--radius);
  box-shadow: 0 8px 28px rgba(58,46,42,.13);
  padding: 5px;
  z-index: 60;
}
.combo__opt {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  width: 100%;
  padding: 8px 11px;
  border-radius: var(--radius-sm);
  font-size: 15px;
  text-align: left;
  min-height: 38px;
}
.combo__opt:hover, .combo__opt[aria-selected="true"] { background: var(--surface-alt); }
.combo__opt em { font-style: normal; color: var(--text-muted); font-size: 13px; }
.combo__opt--new { color: var(--primary); font-weight: 500; }

/* ==========================================================================
   Přílohy — obrázky a kresba
   ========================================================================== */

.media-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(108px, 1fr));
  gap: 8px;
  margin-top: 10px;
}
.media-tile {
  position: relative;
  aspect-ratio: 4 / 3;
  border-radius: var(--radius-sm);
  overflow: hidden;
  background: var(--surface-alt);
}
.media-tile img, .media-tile canvas {
  width: 100%; height: 100%;
  object-fit: cover;
  display: block;
}
.media-tile__del {
  position: absolute;
  top: 5px; right: 5px;
  width: 26px; height: 26px;
  border-radius: 50%;
  background: rgba(0,0,0,.5);
  color: #fff;
  display: flex; align-items: center; justify-content: center;
  font-size: 15px;
  line-height: 1;
}
.media-tile__cap {
  position: absolute;
  left: 0; right: 0; bottom: 0;
  padding: 4px 7px;
  background: linear-gradient(transparent, rgba(0,0,0,.6));
  color: #fff;
  font-size: 11.5px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

/* ==========================================================================
   Prezentační režim
   ========================================================================== */

.present {
  position: fixed;
  inset: 0;
  background: var(--bg);
  display: flex;
  flex-direction: column;
  z-index: 100;
  /* tap do těla textu nedělá nic — ochrana proti omylu */
  -webkit-user-select: none;
  user-select: none;
}
.present--studio { --bg: #16110F; --surface: #1D1715; --text: #D8CCC6; --text-muted: #7C6C66; }

.present__bar {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px 18px;
  padding-top: calc(10px + var(--safe-t));
  padding-left: calc(18px + var(--safe-l));
  padding-right: calc(18px + var(--safe-r));
  flex-shrink: 0;
}

.progress {
  flex: 1;
  display: flex;
  gap: 3px;
  height: 6px;
  min-width: 0;
}
.progress span {
  flex: 1;
  background: var(--separator);
  border-radius: 3px;
  transition: background .18s;
}
.progress span.done { background: var(--primary); }
.progress span.current { background: var(--primary); opacity: 1; }

.present__count {
  font-family: var(--font-round);
  font-size: 15px;
  font-weight: 600;
  color: var(--text-muted);
  font-variant-numeric: tabular-nums;
  flex-shrink: 0;
}

.present__body {
  flex: 1;
  min-height: 0;
  overflow-y: auto;
  padding: 6px calc(28px + var(--safe-l)) 10px calc(28px + var(--safe-r));
}
.present__inner { max-width: 1100px; margin: 0 auto; }

.present__title {
  font-family: var(--font-round);
  font-weight: 700;
  font-size: calc(var(--p-scale) * 1.55);
  line-height: 1.15;
  letter-spacing: -0.02em;
  margin-bottom: 8px;
  display: flex;
  align-items: center;
  gap: 14px;
  flex-wrap: wrap;
}
.present__meta { margin-bottom: 16px; }
.present__meta .chip { font-size: calc(var(--p-scale) * .52); padding: 4px 13px; }
.present__meta .spring-dot { width: calc(var(--p-scale) * .62); height: calc(var(--p-scale) * .62); }
.present__text {
  font-size: var(--p-scale);
  line-height: 1.45;
}
.present__text ul, .present__text ol { padding-left: 1.1em; margin: .2em 0; }
.present__text li { margin: .28em 0; }
.present__text p { margin: 0 0 .35em; }
.present__text h1 { font-size: calc(var(--p-scale) * 1.2); margin: .4em 0 .2em; }
.present__text h2 { font-size: calc(var(--p-scale) * 1.08); margin: .35em 0 .2em; }
.present__media { display: flex; gap: 12px; flex-wrap: wrap; margin-top: 16px; }
.present__media img, .present__media canvas {
  max-height: 30vh;
  max-width: 100%;
  border-radius: var(--radius);
  object-fit: contain;
}
.present__note {
  margin-top: 14px;
  padding: 10px 14px;
  background: var(--surface-alt);
  border-radius: var(--radius-sm);
  font-size: calc(var(--p-scale) * .55);
  color: var(--text-muted);
  font-style: italic;
}

.present__next {
  flex-shrink: 0;
  padding: 12px calc(28px + var(--safe-l)) 12px calc(28px + var(--safe-r));
  border-top: 1px solid var(--separator);
  color: var(--text-muted);
  font-size: calc(var(--p-scale) * .46);
  line-height: 1.5;
  max-height: 26vh;
  overflow: hidden;
}
.present__next div { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

.present__nav {
  display: flex;
  gap: 10px;
  padding: 10px calc(16px + var(--safe-l)) calc(10px + var(--safe-b)) calc(16px + var(--safe-r));
  flex-shrink: 0;
}
.present__nav button {
  flex: 1;
  min-height: 88px;
  border-radius: var(--radius);
  background: var(--surface);
  color: var(--text);
  font-family: var(--font-round);
  font-size: 21px;
  font-weight: 600;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  -webkit-user-select: none;
  user-select: none;
}
.present__nav button:active { background: var(--primary-soft); }
.present__nav button[disabled] { opacity: .3; pointer-events: none; }
.present__nav .next { flex: 1.6; background: var(--primary); color: var(--primary-ink); }
.present__nav .next:active { filter: brightness(.93); }

@media (orientation: landscape) and (max-height: 500px) {
  .present__nav button { min-height: 62px; font-size: 18px; }
}

.timer {
  font-variant-numeric: tabular-nums;
  font-family: var(--font-round);
  font-size: 14px;
  color: var(--text-muted);
  flex-shrink: 0;
}

/* ==========================================================================
   Reading view
   ========================================================================== */

.read h2.read__sec {
  font-size: 22px;
  margin: 26px 0 6px;
}
.read__intro { color: var(--text-muted); margin-bottom: 8px; }
.read img, .read canvas {
  max-width: 100%;
  border-radius: var(--radius);
  margin: 10px 0;
  display: block;
}

/* ==========================================================================
   Formuláře, sheet, dialog
   ========================================================================== */

.field { margin-bottom: 15px; }
.field label {
  display: block;
  font-size: 13px;
  font-weight: 600;
  color: var(--text-muted);
  margin-bottom: 5px;
  font-family: var(--font-round);
}
.input, .field input[type="text"], .field input[type="number"],
.field input[type="password"], .field select, .field textarea {
  width: 100%;
  padding: 10px 13px;
  border: 1px solid var(--separator);
  border-radius: var(--radius-sm);
  background: var(--surface);
  outline: none;
  min-height: var(--tap);
}
.input:focus, .field input:focus, .field select:focus, .field textarea:focus {
  border-color: var(--primary);
}

.search {
  display: flex;
  align-items: center;
  gap: 8px;
  background: var(--surface-alt);
  border-radius: 10px;
  padding: 0 12px;
  margin: 4px var(--pad-screen) 8px;
  min-height: 38px;
}
.search input {
  flex: 1;
  border: 0;
  background: none;
  outline: none;
  padding: 8px 0;
  min-width: 0;
}
.search svg { width: 17px; height: 17px; color: var(--text-muted); flex-shrink: 0; }

.scrim {
  position: fixed;
  inset: 0;
  background: rgba(40,30,26,.34);
  z-index: 200;
  display: flex;
  align-items: flex-end;
  justify-content: center;
  animation: fade .16s ease;
}
@media (min-width: 700px) { .scrim { align-items: center; } }
@keyframes fade { from { opacity: 0 } }

.sheet {
  background: var(--bg);
  width: 100%;
  max-width: 560px;
  max-height: 88vh;
  border-radius: 18px 18px 0 0;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  animation: rise .22s cubic-bezier(.2,.8,.3,1);
  padding-bottom: var(--safe-b);
}
@media (min-width: 700px) { .sheet { border-radius: 18px; max-height: 82vh; } }
@keyframes rise { from { transform: translateY(18px); opacity: .6 } }

.sheet__head {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 14px 18px;
  border-bottom: 1px solid var(--separator);
  flex-shrink: 0;
}
.sheet__head h2 { font-size: 18px; flex: 1; }
.sheet__body { padding: 18px; overflow-y: auto; flex: 1; }
.sheet__foot {
  display: flex;
  gap: 10px;
  padding: 14px 18px;
  border-top: 1px solid var(--separator);
  flex-shrink: 0;
}
.sheet__foot .tbtn { flex: 1; justify-content: center; height: 46px; }
.btn-primary {
  background: var(--primary);
  color: var(--primary-ink);
  border-radius: var(--radius-sm);
  font-weight: 600;
}
.btn-primary:hover { background: var(--primary); filter: brightness(1.05); }

/* kontextové menu */
.menu {
  position: fixed;
  background: var(--surface);
  border: 1px solid var(--separator);
  border-radius: var(--radius);
  box-shadow: 0 10px 34px rgba(58,46,42,.17);
  padding: 5px;
  min-width: 210px;
  z-index: 300;
}
.menu button {
  display: flex;
  align-items: center;
  gap: 10px;
  width: 100%;
  padding: 9px 12px;
  border-radius: var(--radius-sm);
  text-align: left;
  font-size: 15.5px;
  font-weight: 400;
  font-family: var(--font-body);
  min-height: 40px;
}
.menu button:hover { background: var(--surface-alt); }
.menu button.danger { color: var(--danger); }
.menu hr { border: 0; border-top: 1px solid var(--separator); margin: 4px 8px; }
.menu svg { width: 17px; height: 17px; opacity: .65; flex-shrink: 0; }

/* toast */
.toast {
  position: fixed;
  left: 50%;
  bottom: calc(24px + var(--safe-b));
  transform: translateX(-50%);
  background: var(--text);
  color: var(--bg);
  padding: 11px 18px;
  border-radius: var(--radius-chip);
  font-size: 14.5px;
  font-family: var(--font-round);
  font-weight: 500;
  z-index: 400;
  display: flex;
  align-items: center;
  gap: 12px;
  max-width: calc(100vw - 40px);
  animation: rise .2s ease;
}
.toast button { color: var(--primary); font-weight: 600; }

/* prázdný stav */
.empty {
  padding: 60px 30px;
  text-align: center;
  color: var(--text-muted);
}
.empty h3 { font-size: 18px; margin-bottom: 6px; color: var(--text); }
.empty p { font-size: 15px; margin: 0 0 18px; }

.spinner {
  width: 15px; height: 15px;
  border: 2px solid var(--separator);
  border-top-color: var(--primary);
  border-radius: 50%;
  animation: spin .7s linear infinite;
  flex-shrink: 0;
}
@keyframes spin { to { transform: rotate(360deg) } }

.sync-state {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: 12.5px;
  color: var(--text-muted);
}

/* ==========================================================================
   Tisk / export do PDF
   ========================================================================== */

@media print {
  :root { --bg: #fff; --surface: #fff; --text: #000; --text-muted: #444; --separator: #ccc; }
  .toolbar, .fmtbar, .present, .section-add, .tbtn, .scrim, .toast { display: none !important; }
  .pane + .pane { border: 0; }
  .pane__scroll { overflow: visible; }
  .doc { max-width: none; padding: 0; }
  .read__sec { break-after: avoid; page-break-after: avoid; }
  .read img, .read canvas { max-height: 8cm; }
  body { font-size: 11.5pt; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: .01ms !important; transition-duration: .01ms !important; }
}
