/* ==========================================================================
   © LessonHelpers — Silben- & Leseteppich-Generator (Swiss Atelier UI + A4 Print)
   100 % lokal im Browser · Eigene LessonHelpers Schulschriften · Zero CDN
   ========================================================================== */

@font-face {
  font-family: 'LessonHelpers Schulschrift';
  src: url('../assets/fonts/LessonHelpersSchulschrift-Regular.woff2') format('woff2');
  font-weight: 400;
  font-style: normal;
  font-display: swap;
}
@font-face {
  font-family: 'LessonHelpers Schulschrift';
  src: url('../assets/fonts/LessonHelpersSchulschrift-Bold.woff2') format('woff2');
  font-weight: 700;
  font-style: normal;
  font-display: swap;
}
@font-face {
  font-family: 'LessonHelpers Basisschrift';
  src: url('../assets/fonts/LessonHelpersBasisschrift-Regular.woff2') format('woff2');
  font-weight: 400;
  font-style: normal;
  font-display: swap;
}
@font-face {
  font-family: 'LessonHelpers Basisschrift';
  src: url('../assets/fonts/LessonHelpersBasisschrift-Bold.woff2') format('woff2');
  font-weight: 700;
  font-style: normal;
  font-display: swap;
}
@font-face {
  font-family: 'LessonHelpers Handschrift';
  src: url('../assets/fonts/LessonHelpersHandschrift-Regular.woff2') format('woff2');
  font-weight: 400;
  font-style: normal;
  font-display: swap;
}
@font-face {
  font-family: 'LessonHelpers Handschrift';
  src: url('../assets/fonts/LessonHelpersHandschrift-Bold.woff2') format('woff2');
  font-weight: 700;
  font-style: normal;
  font-display: swap;
}

:root {
  --brand: #123D32;
  --brand-deep: #0D2D24;
  --brand-soft: #EBF5EF;
  --brand-line: #B5D7C6;
  --ink: #14181A;
  --ink-2: #3A4246;
  --ink-muted: #5F6A70;
  --paper: #FFFFFF;
  --desk: #ECE9E1;
  --panel: #FAF9F6;
  --rule: #E0DDD4;
  --rule-strong: #C9C4B8;
  --syl-blue: #164C9E;
  --syl-red: #C62828;
  --syl-gray: #6B7280;
  --syl-green: #146B46;
  --font-ui: -apple-system, BlinkMacSystemFont, 'SF Pro Text', 'Segoe UI', Roboto, Helvetica, Arial, sans-serif;
  --font-mono: ui-monospace, 'SF Mono', Menlo, Monaco, Consolas, monospace;
}

*, *::before, *::after { box-sizing: border-box; }
[hidden] { display: none !important; }

html, body {
  margin: 0;
  padding: 0;
  background: var(--desk);
  color: var(--ink);
  font-family: var(--font-ui);
  -webkit-font-smoothing: antialiased;
  -webkit-text-size-adjust: 100%;
  overscroll-behavior: contain;
  min-height: 100%;
}

/* ==========================================================================
   Top Swiss Studio Bar
   ========================================================================== */
.sg-header {
  position: sticky;
  top: 0;
  z-index: 40;
  background: var(--paper);
  border-bottom: 1px solid var(--rule);
  padding: max(0.55rem, env(safe-area-inset-top)) max(1.15rem, env(safe-area-inset-right)) 0.55rem max(1.15rem, env(safe-area-inset-left));
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.65rem;
  flex-wrap: wrap;
}

.sg-brand-group {
  display: flex;
  align-items: center;
  gap: 0.7rem;
  min-width: 0;
}

.sg-home-link {
  display: inline-flex;
  align-items: center;
  gap: 0.45rem;
  text-decoration: none;
  color: var(--ink);
  font-weight: 700;
  font-size: 0.92rem;
  letter-spacing: -0.01em;
}
.sg-home-link:hover { color: var(--brand); }

.sg-logo-mark {
  width: 26px;
  height: 26px;
  background: var(--brand);
  color: #fff;
  display: grid;
  place-items: center;
  border-radius: 3px;
  flex-shrink: 0;
}

.sg-sep {
  width: 1px;
  height: 18px;
  background: var(--rule-strong);
}

.sg-app-title {
  margin: 0;
  font-size: 0.94rem;
  font-weight: 700;
  color: var(--ink);
  letter-spacing: -0.01em;
}

.sg-badge-free {
  font-family: var(--font-mono);
  font-size: 0.68rem;
  font-weight: 600;
  color: var(--brand);
  background: var(--brand-soft);
  border: 1px solid var(--brand-line);
  padding: 0.16rem 0.46rem;
  white-space: nowrap;
}

.sg-usage-pill {
  display: inline-flex;
  align-items: center;
  gap: 0.3rem;
  font-family: var(--font-mono);
  font-size: 0.68rem;
  font-weight: 600;
  color: var(--ink-2);
  background: var(--panel);
  border: 1px solid var(--rule-strong);
  padding: 0.16rem 0.48rem;
  white-space: nowrap;
  font-variant-numeric: tabular-nums;
}
.sg-usage-pill strong {
  color: var(--brand-deep);
  font-weight: 700;
}
.sg-usage-dot {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: var(--brand);
  flex-shrink: 0;
}

.sg-actions {
  display: flex;
  align-items: center;
  gap: 0.45rem;
  flex-wrap: wrap;
}

/* Embedded mode inside lessonhelpers.com window */
.sg-embed-only { display: none; }
body.is-embed .sg-embed-only { display: inline-flex; }
body.is-embed .sg-header {
  padding: 0.45rem 0.9rem;
  flex-wrap: nowrap;
}
body.is-embed .sg-home-link,
body.is-embed .sg-sep,
body.is-embed .sg-app-title,
body.is-embed .sg-badge-free {
  display: none;
}
@media (max-width: 820px) {
  body.is-embed .sg-header { flex-wrap: wrap; }
}

/* Buttons */
.sg-btn {
  appearance: none;
  border: 1px solid var(--rule-strong);
  background: var(--paper);
  color: var(--ink);
  font-family: var(--font-ui);
  font-size: 0.8rem;
  font-weight: 600;
  padding: 0.44rem 0.78rem;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  gap: 0.38rem;
  text-decoration: none;
  line-height: 1.1;
  white-space: nowrap;
  touch-action: manipulation;
  -webkit-tap-highlight-color: transparent;
  user-select: none;
  -webkit-user-select: none;
  transition: background 0.14s ease, border-color 0.14s ease, color 0.14s ease;
}
.sg-btn:hover {
  border-color: var(--brand);
  color: var(--brand);
  background: var(--brand-soft);
}
.sg-btn-primary {
  background: var(--brand);
  border-color: var(--brand);
  color: #fff;
}
.sg-btn-primary:hover {
  background: var(--brand-deep);
  border-color: var(--brand-deep);
  color: #fff;
}
.sg-btn-quiet {
  background: transparent;
  border-color: var(--rule);
  color: var(--ink-2);
}
.sg-btn-sm {
  font-size: 0.75rem;
  padding: 0.34rem 0.6rem;
}

/* ==========================================================================
   Main Split Studio Workspace
   ========================================================================== */
.sg-workspace {
  display: grid;
  grid-template-columns: 392px minmax(0, 1fr);
  min-height: calc(100vh - 52px);
  min-height: calc(100dvh - 52px);
  align-items: start;
  padding-left: env(safe-area-inset-left);
  padding-right: env(safe-area-inset-right);
  padding-bottom: env(safe-area-inset-bottom);
}

/* Left Control Panel */
.sg-sidebar {
  background: var(--panel);
  border-right: 1px solid var(--rule);
  padding: 1rem 1.05rem 1.4rem;
  display: flex;
  flex-direction: column;
  gap: 0.95rem;
  position: sticky;
  top: 50px;
  max-height: calc(100vh - 50px);
  max-height: calc(100dvh - 50px);
  overflow-y: auto;
  overscroll-behavior: contain;
}

.sg-block {
  background: var(--paper);
  border: 1px solid var(--rule);
  padding: 0.82rem 0.88rem;
  display: flex;
  flex-direction: column;
  gap: 0.62rem;
}

.sg-block-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.5rem;
}

.sg-label {
  font-size: 0.72rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.055em;
  color: var(--ink-muted);
  margin: 0;
}

/* Mode Segmented Switch */
.sg-mode-tabs {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 0.32rem;
}

.sg-mode-btn {
  appearance: none;
  border: 1px solid var(--rule);
  background: var(--panel);
  color: var(--ink-2);
  font-family: var(--font-ui);
  font-size: 0.76rem;
  font-weight: 700;
  padding: 0.56rem 0.35rem;
  cursor: pointer;
  text-align: center;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.2rem;
  transition: all 0.14s ease;
}
.sg-mode-btn span.sg-mode-sub {
  font-size: 0.65rem;
  font-weight: 500;
  color: var(--ink-muted);
}
.sg-mode-btn:hover {
  border-color: var(--brand);
  color: var(--brand);
}
.sg-mode-btn.is-active {
  background: var(--brand);
  border-color: var(--brand);
  color: #fff;
}
.sg-mode-btn.is-active span.sg-mode-sub {
  color: rgba(255, 255, 255, 0.82);
}

/* Presets row */
.sg-presets {
  display: flex;
  flex-wrap: wrap;
  gap: 0.3rem;
}
.sg-chip {
  appearance: none;
  border: 1px solid var(--rule);
  background: var(--panel);
  color: var(--ink-2);
  font-family: var(--font-ui);
  font-size: 0.72rem;
  font-weight: 600;
  padding: 0.28rem 0.54rem;
  cursor: pointer;
  transition: all 0.12s ease;
}
.sg-chip:hover {
  border-color: var(--brand);
  color: var(--brand);
  background: var(--brand-soft);
}
.sg-chip.is-active {
  background: var(--brand-soft);
  border-color: var(--brand);
  color: var(--brand-deep);
}

/* Text inputs */
.sg-field {
  display: flex;
  flex-direction: column;
  gap: 0.24rem;
}
.sg-field-label {
  font-size: 0.74rem;
  font-weight: 600;
  color: var(--ink-2);
}
.sg-input,
.sg-textarea,
.sg-select {
  width: 100%;
  border: 1px solid var(--rule-strong);
  background: var(--paper);
  color: var(--ink);
  font-family: var(--font-ui);
  font-size: 0.84rem;
  padding: 0.45rem 0.58rem;
  outline: none;
  transition: border-color 0.14s ease;
}
.sg-input:focus,
.sg-textarea:focus,
.sg-select:focus {
  border-color: var(--brand);
  box-shadow: 0 0 0 2px rgba(18, 61, 50, 0.14);
}
.sg-textarea {
  resize: vertical;
  min-height: 112px;
  line-height: 1.48;
}

.sg-hint {
  margin: 0;
  font-size: 0.73rem;
  line-height: 1.42;
  color: var(--ink-muted);
}

.sg-stats-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.5rem;
  flex-wrap: wrap;
  font-family: var(--font-mono);
  font-size: 0.7rem;
  color: var(--ink-2);
  background: var(--panel);
  border: 1px solid var(--rule);
  padding: 0.34rem 0.55rem;
}

/* Visual Syllable Style Picker */
.sg-style-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 0.35rem;
}
.sg-style-opt {
  appearance: none;
  border: 1px solid var(--rule);
  background: var(--paper);
  padding: 0.46rem 0.54rem;
  cursor: pointer;
  text-align: left;
  display: flex;
  flex-direction: column;
  gap: 0.18rem;
  transition: all 0.12s ease;
}
.sg-style-opt:hover {
  border-color: var(--brand);
}
.sg-style-opt.is-active {
  border-color: var(--brand);
  background: var(--brand-soft);
  box-shadow: inset 0 0 0 1px var(--brand);
}
.sg-style-sample {
  font-family: 'LessonHelpers Schulschrift', var(--font-ui);
  font-size: 0.95rem;
  font-weight: 700;
  line-height: 1.38;
  color: var(--ink);
  padding-bottom: 0.14rem;
}
.sg-mini-arc {
  position: relative;
  display: inline-block;
}
.sg-mini-arc::after {
  content: '';
  position: absolute;
  left: 1px;
  right: 1px;
  bottom: -2px;
  height: 5px;
  border-bottom: 1.5px solid currentColor;
  border-radius: 0 0 50% 50%;
}
.sg-style-name {
  font-size: 0.69rem;
  font-weight: 600;
  color: var(--ink-muted);
}
.sg-style-opt.is-active .sg-style-name {
  color: var(--brand-deep);
}

/* Font picker */
.sg-font-row {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 0.3rem;
}
.sg-font-btn {
  appearance: none;
  border: 1px solid var(--rule);
  background: var(--paper);
  padding: 0.4rem 0.35rem;
  cursor: pointer;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.12rem;
}
.sg-font-btn:hover { border-color: var(--brand); }
.sg-font-btn.is-active {
  border-color: var(--brand);
  background: var(--brand-soft);
  box-shadow: inset 0 0 0 1px var(--brand);
}
.sg-font-btn .fp-demo {
  font-size: 0.94rem;
  color: var(--ink);
  line-height: 1.25;
}
.sg-font-btn .fp-name {
  font-size: 0.66rem;
  font-weight: 600;
  color: var(--ink-muted);
}

/* Sliders & Toggles */
.sg-range-row {
  display: grid;
  grid-template-columns: 1fr auto;
  align-items: center;
  gap: 0.5rem;
}
.sg-range-val {
  font-family: var(--font-mono);
  font-size: 0.72rem;
  color: var(--brand-deep);
  font-weight: 700;
  min-width: 44px;
  text-align: right;
}
.sg-range {
  width: 100%;
  accent-color: var(--brand);
}

.sg-grid-2 {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 0.5rem;
}

.sg-checks {
  display: flex;
  flex-direction: column;
  gap: 0.4rem;
}
.sg-check {
  display: flex;
  align-items: center;
  gap: 0.48rem;
  font-size: 0.79rem;
  color: var(--ink-2);
  cursor: pointer;
  user-select: none;
}
.sg-check input {
  width: 15px;
  height: 15px;
  accent-color: var(--brand);
  margin: 0;
  cursor: pointer;
}

/* Cross-promo subtle card to free fonts */
.sg-fonts-promo {
  background: var(--brand);
  color: #fff;
  padding: 0.75rem 0.85rem;
  display: flex;
  flex-direction: column;
  gap: 0.35rem;
}
.sg-fonts-promo strong {
  font-size: 0.8rem;
}
.sg-fonts-promo p {
  margin: 0;
  font-size: 0.72rem;
  line-height: 1.4;
  color: rgba(255, 255, 255, 0.86);
}
.sg-fonts-promo a {
  color: #fff;
  font-size: 0.75rem;
  font-weight: 700;
  text-decoration: underline;
  text-underline-offset: 2px;
  align-self: flex-start;
  margin-top: 0.15rem;
}

/* ==========================================================================
   Right Desk Stage & Real A4 Sheet Preview (210mm x 297mm)
   ========================================================================== */
.sg-stage {
  padding: 1.35rem 1.5rem 2.5rem;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.85rem;
  min-width: 0;
}

.sg-stage-bar {
  width: 100%;
  max-width: 210mm;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.6rem;
  flex-wrap: wrap;
  font-size: 0.76rem;
  color: var(--ink-2);
}

.sg-stage-tip {
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  background: var(--paper);
  border: 1px solid var(--rule);
  padding: 0.3rem 0.65rem;
  font-size: 0.74rem;
}
.sg-stage-tip .tip-dot {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: var(--brand);
  flex-shrink: 0;
}

.sg-sheet-wrap {
  width: 100%;
  display: flex;
  justify-content: center;
}

/* Real A4 Paper Sheet */
.a4-sheet {
  width: 210mm;
  max-width: 100%;
  min-height: 297mm;
  background: #FFFFFF;
  color: #14181A;
  border: 1px solid #D8D4C9;
  box-shadow: 0 18px 42px -22px rgba(20, 24, 26, 0.34), 0 2px 6px rgba(20, 24, 26, 0.06);
  padding: 17mm 18mm 14mm 18mm;
  display: flex;
  flex-direction: column;
  position: relative;
  --sheet-font: 'LessonHelpers Schulschrift', sans-serif;
  --sheet-features: "kern" 1;
  --sheet-size: 19pt;
  --sheet-lh: 2.05;
  font-family: var(--sheet-font);
  font-feature-settings: var(--sheet-features);
}

/* Worksheet Header (Name / Date) */
.ws-meta-row {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 12mm;
  margin-bottom: 5.5mm;
  padding-bottom: 3mm;
  border-bottom: 0.5pt solid #D4D7DC;
  font-size: 10.5pt;
  color: #4B5563;
}
.ws-meta-field {
  display: flex;
  align-items: baseline;
  gap: 2.5mm;
  flex: 1;
}
.ws-meta-field.is-date {
  flex: 0 0 48mm;
}
.ws-meta-line {
  flex: 1;
  border-bottom: 0.75pt solid #9CA3AF;
  height: 4.5mm;
}

.ws-title-block {
  margin-bottom: 6mm;
}
.ws-title {
  margin: 0 0 1.8mm 0;
  font-size: 20pt;
  font-weight: 700;
  line-height: 1.18;
  color: #111827;
  letter-spacing: -0.01em;
}
.ws-instruction {
  margin: 0;
  font-size: 11.5pt;
  line-height: 1.45;
  color: #4B5563;
}

.ws-body {
  flex: 1 1 auto;
}

/* ==========================================================================
   Syllable Rendering Engine (All 7 Styles + Interactive Hover)
   ========================================================================== */
.ws-word-wrap {
  display: inline;
  white-space: nowrap;
}
.ws-word {
  display: inline-block;
  white-space: nowrap;
  cursor: pointer;
  border-radius: 2px;
  transition: background 0.1s ease;
}
.ws-word:hover {
  background: rgba(19, 78, 74, 0.1);
}
.ws-word.is-edited {
  text-decoration: underline dotted rgba(19, 78, 74, 0.45);
  text-underline-offset: 0.28em;
}

.syl {
  position: relative;
  display: inline-block;
  line-height: 1.18;
}

/* Style: Blau / Rot (Klassische Silbenmethode) */
.a4-sheet[data-style="bluered"] .syl.is-even,
.a4-sheet[data-style="bluered-arcs"] .syl.is-even {
  color: var(--syl-blue);
}
.a4-sheet[data-style="bluered"] .syl.is-odd,
.a4-sheet[data-style="bluered-arcs"] .syl.is-odd {
  color: var(--syl-red);
}

/* Style: Blau / Grau (Farbsehfreundlich & ruhig) */
.a4-sheet[data-style="bluegray"] .syl.is-even {
  color: var(--syl-blue);
}
.a4-sheet[data-style="bluegray"] .syl.is-odd {
  color: #525965;
}

/* Style: S/W Kontrast (Schwarz-Weiss-Kopierer) */
.a4-sheet[data-style="bw"] .syl.is-even {
  color: #111827;
  font-weight: 700;
}
.a4-sheet[data-style="bw"] .syl.is-odd {
  color: #6B7280;
  font-weight: 400;
}

/* Style: Silbenbögen (S/W) */
.a4-sheet[data-style="arcs"] .syl {
  color: #14181A;
}

/* Style: Silbenpunkte */
.a4-sheet[data-style="middot"] .syl {
  color: #14181A;
}
.syl-dot {
  color: #164C9E;
  font-weight: 700;
  padding: 0 0.04em;
  user-select: none;
}

/* Style: Plain (Ohne Hilfe) */
.a4-sheet[data-style="plain"] .syl {
  color: #14181A;
}

/* SVG Silbenbogen exakt unter jeder Silbe */
.syl-arc {
  position: absolute;
  left: 0.04em;
  right: 0.04em;
  bottom: -0.34em;
  width: calc(100% - 0.08em);
  height: 0.28em;
  overflow: visible;
  pointer-events: none;
}
.syl.is-narrow .syl-arc {
  left: -0.05em;
  right: -0.05em;
  width: calc(100% + 0.1em);
}
.syl-arc path {
  fill: none;
  stroke: #1B4F9C;
  stroke-width: 1.5;
  stroke-linecap: round;
  vector-effect: non-scaling-stroke;
}
.a4-sheet[data-style="bluered-arcs"] .syl.is-odd .syl-arc path {
  stroke: var(--syl-red);
}
.a4-sheet[data-style="arcs"] .syl-arc path {
  stroke: #263238;
}

/* ==========================================================================
   Mode 1: Silben-Lesetext
   ========================================================================== */
.ws-text-lines {
  display: flex;
  flex-direction: column;
  gap: 0.42em;
  font-size: var(--sheet-size);
  line-height: var(--sheet-lh);
}

.ws-text-para {
  display: flex;
  align-items: baseline;
  gap: 4mm;
}
.ws-line-num {
  flex: 0 0 6.5mm;
  font-family: var(--font-mono);
  font-size: 9pt;
  color: #9CA3AF;
  text-align: right;
  user-select: none;
}
.ws-para-content {
  flex: 1;
  min-width: 0;
  word-wrap: break-word;
}
.ws-para-empty {
  height: 0.55em;
}

/* ==========================================================================
   Mode 2: Leseteppich (Schnelllese-Raster)
   ========================================================================== */
.ws-carpet-table {
  width: 100%;
  border-collapse: collapse;
  table-layout: fixed;
  font-size: var(--sheet-size);
  margin-top: 2mm;
}

.ws-carpet-table td {
  border: 0.8pt solid #C8CDD4;
  text-align: center;
  vertical-align: middle;
  padding: 3.8mm 2mm 4.6mm;
  line-height: 1.35;
  word-break: break-word;
}
.ws-carpet-table td.is-row-num {
  width: 8mm;
  border-left: none;
  border-top: none;
  border-bottom: none;
  font-family: var(--font-mono);
  font-size: 9.5pt;
  color: #6B7280;
  text-align: right;
  padding: 2mm 2.5mm 2mm 0;
}
.ws-carpet-table.has-zebra tr:nth-child(even) td:not(.is-row-num) {
  background: #F6F7F9;
}

/* Abhak-Boxen für Leseteppich (5x lesen) */
.ws-carpet-tracker {
  margin-top: 7mm;
  padding: 3.5mm 4.5mm;
  border: 0.8pt solid #D0D5DC;
  background: #FAFBFD;
  break-inside: avoid;
}
.ws-tracker-title {
  margin: 0 0 2.8mm 0;
  font-size: 10.5pt;
  font-weight: 700;
  color: #1F2937;
}
.ws-tracker-grid {
  display: grid;
  grid-template-columns: repeat(5, minmax(0, 1fr));
  gap: 3mm;
}
.ws-tracker-box {
  border: 0.75pt solid #B8C0CC;
  background: #fff;
  padding: 2.2mm 2mm;
  text-align: center;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 1.2mm;
}
.ws-tracker-box .tr-num {
  font-size: 9pt;
  font-weight: 700;
  color: #4B5563;
}
.ws-tracker-box .tr-star {
  font-size: 15pt;
  line-height: 1;
  color: #9CA3AF;
}
.ws-tracker-box .tr-time {
  font-size: 8pt;
  color: #6B7280;
}

/* ==========================================================================
   Mode 3: Lesepyramide
   ========================================================================== */
.ws-pyramids {
  display: flex;
  flex-direction: column;
  gap: 7mm;
  font-size: var(--sheet-size);
}

.ws-pyramid-card {
  border: 0.8pt solid #D4D8DF;
  padding: 4.5mm 5.5mm 5mm;
  break-inside: avoid;
  background: #FFFFFF;
}

.ws-pyramid-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 4mm;
  margin-bottom: 3mm;
  padding-bottom: 2mm;
  border-bottom: 0.5pt dashed #D4D8DF;
  font-size: 10pt;
  color: #4B5563;
}

.ws-pyramid-checks {
  display: inline-flex;
  align-items: center;
  gap: 3.5mm;
  font-size: 10pt;
}
.ws-box-check {
  display: inline-flex;
  align-items: center;
  gap: 1.2mm;
}
.ws-box-sq {
  display: inline-block;
  width: 3.6mm;
  height: 3.6mm;
  border: 0.85pt solid #6B7280;
  vertical-align: middle;
}

.ws-pyramid-lines {
  display: flex;
  flex-direction: column;
  gap: 0.34em;
  line-height: 1.65;
}
.ws-pyramid-lines.is-center {
  text-align: center;
}
.ws-pyramid-lines.is-left {
  text-align: left;
}
.ws-pyr-new {
  font-weight: 700;
  background: #EAF4F1;
  padding: 0.02em 0.16em;
  border-radius: 3px;
}

/* Lesesterne unten für Lesetext */
.ws-stars-foot {
  margin-top: 7mm;
  padding: 3mm 4.5mm;
  border: 0.8pt solid #D0D5DC;
  background: #FAFBFD;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 4mm;
  font-size: 10.5pt;
  color: #374151;
  break-inside: avoid;
}
.ws-stars-icons {
  display: inline-flex;
  align-items: center;
  gap: 4mm;
  font-size: 16pt;
  color: #9CA3AF;
  letter-spacing: 0.08em;
}

/* Dezente Copyright-Fusszeile auf dem A4-Blatt */
.ws-footer {
  margin-top: auto;
  padding-top: 5mm;
  border-top: 0.5pt solid #E5E7EB;
  display: flex;
  align-items: center;
  justify-content: space-between;
  font-size: 8.5pt;
  color: #6B7280;
  font-family: var(--font-ui);
}

/* ==========================================================================
   1-Click Syllable Editor Popover
   ========================================================================== */
.syl-popover {
  position: fixed;
  z-index: 120;
  background: var(--paper);
  border: 1.5px solid var(--brand);
  box-shadow: 0 18px 40px -14px rgba(14, 61, 58, 0.38);
  padding: 0.78rem 0.9rem;
  min-width: 260px;
  max-width: 92vw;
  display: flex;
  flex-direction: column;
  gap: 0.55rem;
}
.syl-popover[hidden] { display: none; }

.syl-pop-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.5rem;
}
.syl-pop-title {
  font-size: 0.74rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--brand);
}
.syl-pop-close {
  appearance: none;
  border: none;
  background: transparent;
  font-size: 1.1rem;
  line-height: 1;
  color: var(--ink-muted);
  cursor: pointer;
  padding: 0.1rem 0.3rem;
}
.syl-pop-close:hover { color: var(--ink); }

.syl-pop-hint {
  margin: 0;
  font-size: 0.72rem;
  color: var(--ink-muted);
}

.syl-pop-letters {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 0;
  padding: 0.45rem 0.55rem;
  background: var(--panel);
  border: 1px solid var(--rule);
  font-family: 'LessonHelpers Schulschrift', var(--font-ui);
  font-size: 1.45rem;
  font-weight: 700;
}
.syl-pop-char {
  padding: 0.05rem 0.04rem;
  line-height: 1.2;
}
.syl-pop-char.is-even { color: var(--syl-blue); }
.syl-pop-char.is-odd { color: var(--syl-red); }

.syl-pop-gap {
  appearance: none;
  border: none;
  background: transparent;
  width: 14px;
  height: 30px;
  padding: 0;
  margin: 0 -2px;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  position: relative;
}
.syl-pop-gap::after {
  content: '';
  width: 2px;
  height: 14px;
  border-radius: 2px;
  background: transparent;
  transition: all 0.1s ease;
}
.syl-pop-gap:hover::after {
  background: rgba(19, 78, 74, 0.38);
  height: 20px;
}
.syl-pop-gap.is-split::after {
  background: var(--brand);
  width: 3px;
  height: 24px;
}

.syl-pop-foot {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.45rem;
}

/* Toast */
.sg-toast {
  position: fixed;
  bottom: 1.1rem;
  right: 1.1rem;
  z-index: 150;
  background: var(--brand-deep);
  color: #fff;
  font-size: 0.8rem;
  font-weight: 600;
  padding: 0.55rem 0.9rem;
  box-shadow: 0 10px 26px -10px rgba(0, 0, 0, 0.45);
  opacity: 0;
  transform: translateY(8px);
  pointer-events: none;
  transition: opacity 0.18s ease, transform 0.18s ease;
}
.sg-toast.is-show {
  opacity: 1;
  transform: translateY(0);
}

/* ==========================================================================
   Responsive (Tablet & Mobile)
   ========================================================================== */
@media (max-width: 1080px) {
  .sg-workspace {
    grid-template-columns: 1fr;
  }
  .sg-sidebar {
    position: static;
    max-height: none;
    border-right: none;
    border-bottom: 1px solid var(--rule);
  }
  .sg-stage {
    padding: 1rem 0.75rem 2rem;
  }
  .a4-sheet {
    width: 100%;
    min-height: auto;
    padding: 1.4rem 1.25rem 1.2rem;
  }
}

@media (max-width: 600px) {
  .sg-header {
    padding: max(0.5rem, env(safe-area-inset-top)) max(0.75rem, env(safe-area-inset-right)) 0.5rem max(0.75rem, env(safe-area-inset-left));
  }
  .sg-badge-free { display: none; }
  .sg-style-grid {
    grid-template-columns: 1fr;
  }
  .ws-tracker-grid {
    grid-template-columns: repeat(5, minmax(0, 1fr));
    gap: 1.5mm;
  }
}

/* iPad, Touch & Reduced-Motion Optimizations (Apple HIG >= 44px, zero iOS auto-zoom) */
.sg-mode-btn, .sg-chip, .sg-style-opt, .sg-font-btn, .syl-pop-gap, .syl-pop-close, .sg-check {
  touch-action: manipulation;
  -webkit-tap-highlight-color: transparent;
}
@media (pointer: coarse), (max-width: 1024px) {
  .sg-input, .sg-textarea, .sg-select {
    font-size: 16px;
    min-height: 44px;
  }
  .sg-btn, .sg-mode-btn, .sg-chip, .sg-style-opt, .sg-font-btn, .sg-check {
    min-height: 44px;
  }
  .syl-pop-close {
    min-width: 44px;
    min-height: 44px;
    display: inline-grid;
    place-items: center;
  }
  .syl-pop-gap {
    width: 22px;
    height: 44px;
  }
}
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    transition-duration: 0.01ms !important;
    animation-duration: 0.01ms !important;
  }
}

/* ==========================================================================
   CRISP 1:1 A4 PRINT / PDF EXPORT (@media print)
   ========================================================================== */
@page {
  size: A4 portrait;
  margin: 0;
}

@media print {
  html, body {
    background: #FFFFFF !important;
    margin: 0 !important;
    padding: 0 !important;
    -webkit-print-color-adjust: exact !important;
    print-color-adjust: exact !important;
  }

  .sg-header,
  .sg-sidebar,
  .sg-stage-bar,
  .syl-popover,
  .sg-toast {
    display: none !important;
  }

  .sg-workspace {
    display: block !important;
    min-height: 0 !important;
  }

  .sg-stage {
    padding: 0 !important;
    margin: 0 !important;
    display: block !important;
  }

  .sg-sheet-wrap {
    display: block !important;
  }

  .a4-sheet {
    width: 210mm !important;
    max-width: none !important;
    min-height: 297mm !important;
    border: none !important;
    box-shadow: none !important;
    margin: 0 !important;
    padding: 17mm 18mm 14mm 18mm !important;
  }

  .ws-word:hover {
    background: transparent !important;
  }
  .ws-word.is-edited {
    text-decoration: none !important;
  }
}
