/* ============================================================
   CLUEFORGE — APP STYLES
   ============================================================ */
:root {
  --cell: 36px;
  --cell-font: 'Playfair Display', Georgia, serif;
  --grid-bg: #c8a07a;

  /* Sidebar colors */
  --sidebar-bg:     #3d2b1f;
  --sidebar-text:   #f5ede4;
  --sidebar-muted:  #a8907e;
  --sidebar-border: #5a3e2e;
  --sidebar-input:  #2a1e14;
  --sidebar-hover:  #4f382a;

  /* Accent */
  --accent:         #d4622a;
  --accent-hover:   #b84f1f;
  --accent-light:   #fae8dc;

  /* Backgrounds */
  --bg:             #fdf6ef;
  --surface:        #fffaf6;
  --card:           #fff9f3;

  /* Grid */
  --cell-bg:        #fffdf9;
  --cell-border:    #c8a07a;
  --cell-border-outer: #8b5e3c;
  --cell-black:     #2d1f14;
  --cell-sol:       #fce9b4;
  --cell-sol-border:#d4962a;
  --cell-sol-num:   #8b5a00;

  /* Text */
  --text:           #2d1f14;
  --text-muted:     #8b7060;

  /* Messages */
  --error-bg:     #fef2f2;
  --error-text:   #b91c1c;
  --error-border: #fecaca;
  --warn-bg:      #fff8ed;
  --warn-text:    #92400e;
  --warn-border:  #fcd9a0;

  --radius: 10px;
  --font-ui:   'Lato', system-ui, sans-serif;
  --font-mono: 'JetBrains Mono', 'Menlo', monospace;
  --font-display: 'Playfair Display', Georgia, serif;
}

/* ============================================================
   RESET & BASE
   ============================================================ */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

html { height: 100%; overflow-x: hidden; }

body {
  font-family: var(--font-ui);
  font-size: 14px;
  background: var(--bg);
  color: var(--text);
  height: 100vh;
  overflow: hidden;
}

/* ============================================================
   LAYOUT
   ============================================================ */
.layout { display: flex; height: 100vh; }

/* ============================================================
   SIDEBAR
   ============================================================ */
.sidebar {
  width: 320px;
  min-width: 280px;
  background: var(--sidebar-bg);
  color: var(--sidebar-text);
  display: flex;
  flex-direction: column;
  overflow: hidden;
  flex-shrink: 0;
  border-right: 3px solid var(--sidebar-border);
}

.sidebar__inner {
  padding: 26px 22px;
  display: flex;
  flex-direction: column;
  gap: 18px;
  flex: 1;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
}

/* ============================================================
   LANGUAGE SWITCHER (sidebar)
   ============================================================ */
.lang-switch--sidebar {
  display: flex;
  align-self: flex-start;
}
.lang-select {
  background: var(--sidebar-input);
  border: 1.5px solid var(--sidebar-border);
  border-radius: 8px;
  font-family: var(--font-ui);
  font-size: 12px;
  font-weight: 600;
  padding: 5px 28px 5px 10px;
  cursor: pointer;
  color: var(--sidebar-text);
  appearance: none;
  -webkit-appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='10' height='6' viewBox='0 0 10 6'%3E%3Cpath d='M1 1l4 4 4-4' stroke='%23a8907e' stroke-width='1.5' fill='none' stroke-linecap='round'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 9px center;
  transition: border-color 0.15s;
}
.lang-select:hover { border-color: var(--accent); }
.lang-select:focus { outline: none; border-color: var(--accent); }

/* ============================================================
   LOGO
   ============================================================ */
.logo {
  display: flex;
  align-items: center;
  gap: 12px;
  padding-bottom: 18px;
  border-bottom: 1px solid var(--sidebar-border);
}

.logo__icon {
  font-size: 26px;
  line-height: 1;
  /* decorative grid icon */
}

.logo__title {
  font-family: var(--font-display);
  font-style: italic;
  font-size: 19px;
  font-weight: 700;
  color: #f5ede4;
  line-height: 1.15;
  letter-spacing: -0.2px;
}

.logo__title span { color: #e8a87c; }

.logo__sub {
  font-size: 10px;
  text-transform: uppercase;
  letter-spacing: 2.5px;
  color: var(--sidebar-muted);
  margin-top: 2px;
}

/* ============================================================
   FORM
   ============================================================ */
.form-group { display: flex; flex-direction: column; gap: 8px; }

.form-label {
  display: flex;
  align-items: center;
  justify-content: space-between;
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 1.5px;
  color: var(--sidebar-muted);
}

.form-hint {
  font-size: 10px;
  font-weight: 400;
  text-transform: none;
  letter-spacing: 0;
  opacity: 0.65;
}

.keywords-fact-hint {
  margin-top: 6px;
  font-size: 11px;
  font-weight: 500;
  opacity: 1;
  color: var(--sidebar-muted);
  line-height: 1.4;
  transition: color 0.2s;
}
.keywords-fact-hint--warn {
  color: #f59e0b;
}

.json-textarea {
  width: 100%;
  font-family: var(--font-mono);
  font-size: 11.5px;
  line-height: 1.55;
  background: var(--sidebar-input);
  color: #d4b49a;
  border: 1px solid var(--sidebar-border);
  border-radius: var(--radius);
  padding: 12px;
  resize: vertical;
  outline: none;
  transition: border-color 0.15s;
  min-height: 200px;
}

.json-textarea:focus { border-color: var(--accent); }
.json-textarea::placeholder { color: #5a3e2e; font-size: 11px; }

/* ============================================================
   BUTTONS
   ============================================================ */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 7px;
  padding: 9px 16px;
  border-radius: var(--radius);
  font-family: var(--font-ui);
  font-size: 13.5px;
  font-weight: 700;
  cursor: pointer;
  border: 2px solid transparent;
  transition: background 0.15s, border-color 0.15s, color 0.15s, transform 0.1s;
  white-space: nowrap;
  text-decoration: none;
  user-select: none;
  letter-spacing: 0.2px;
}

.btn:active { transform: scale(0.97); }

.btn--primary {
  background: var(--accent);
  color: #fff;
  border-color: var(--accent);
  width: 100%;
  padding: 12px 16px;
  font-size: 14.5px;
  border-radius: 12px;
  box-shadow: 0 3px 0 var(--accent-hover);
}
.btn--primary:hover { background: var(--accent-hover); border-color: var(--accent-hover); }
.btn--primary:active { box-shadow: none; transform: translateY(2px); }

.btn--outline {
  background: transparent;
  color: var(--sidebar-text);
  border-color: var(--sidebar-border);
}
.btn--outline:hover { background: var(--sidebar-hover); border-color: #7a5540; }

.btn--secondary {
  background: var(--card);
  color: var(--text);
  border-color: #d4b49a;
}
.btn--secondary:hover { background: var(--accent-light); border-color: var(--accent); }

.btn--ghost {
  background: transparent;
  color: var(--text-muted);
  border-color: #ddd0c4;
}
.btn--ghost:hover { background: var(--accent-light); border-color: var(--accent); color: var(--accent); }

.btn--action { width: auto; }
.btn--sm { font-size: 12px; padding: 7px 11px; }
.btn:disabled { opacity: 0.5; cursor: not-allowed; transform: none; }

@keyframes highlightPulse {
  0%, 100% { border-color: #7a4830; }
  40%       { border-color: var(--accent); box-shadow: 0 0 0 3px rgba(212,98,42,0.25); }
}
.text-input.highlight-empty {
  animation: highlightPulse 1.8s ease forwards;
}

.btn-row { display: flex; gap: 8px; flex-wrap: wrap; }
.ai-btn-hint {
  flex-basis: 100%;
  font-size: 10px;
  color: #e8a87c;
  opacity: 0.7;
  text-align: right;
  margin: 2px 0 0 0;
}

#file-upload { display: none; }

/* ============================================================
   MESSAGES
   ============================================================ */
.msg-box {
  padding: 10px 14px;
  border-radius: var(--radius);
  font-size: 13px;
  line-height: 1.5;
  border: 1px solid;
}
.msg-box--error   { background: var(--error-bg); color: var(--error-text); border-color: var(--error-border); }
.msg-box--warning { background: var(--warn-bg);  color: var(--warn-text);  border-color: var(--warn-border); }

/* ============================================================
   SIDEBAR FOOTER
   ============================================================ */
.sidebar__footer {
  margin-top: auto;
  padding-top: 16px;
  border-top: 1px solid var(--sidebar-border);
  display: flex;
  flex-direction: column;
  gap: 5px;
}

.sidebar__footer p { font-size: 11px; color: var(--sidebar-muted); line-height: 1.5; }

.sidebar__footer code {
  font-family: var(--font-mono);
  font-size: 10px;
  background: var(--sidebar-input);
  padding: 1px 4px;
  border-radius: 3px;
  color: #e8a87c;
}

/* ============================================================
   UTILITIES
   ============================================================ */
.hidden { display: none !important; }
.print-only { display: none; }

/* ============================================================
   MAIN AREA
   ============================================================ */
.main {
  flex: 1;
  overflow-y: auto;
  overflow-x: hidden;
  padding: 36px 48px;
  min-width: 0;
  background: var(--bg);
}

/* ============================================================
   PLACEHOLDER
   ============================================================ */
.placeholder {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 70vh;
}

.placeholder__inner { text-align: center; max-width: 360px; }

/* Decorative mini-grid */
.placeholder__grid {
  display: inline-grid;
  grid-template-columns: repeat(5, 28px);
  grid-template-rows: repeat(3, 28px);
  gap: 3px;
  margin-bottom: 24px;
  padding: 6px;
  background: #e8d4c0;
  border-radius: 10px;
}

.placeholder__grid span {
  background: var(--cell-bg);
  border-radius: 4px;
  border: 1.5px solid var(--cell-border);
}

.placeholder__grid span.dark {
  background: var(--cell-black);
  border-color: var(--cell-black);
}

.placeholder__inner h2 {
  font-family: var(--font-display);
  font-style: italic;
  font-size: 26px;
  color: var(--text);
  margin-bottom: 10px;
}

.placeholder__inner p { color: var(--text-muted); font-size: 14px; line-height: 1.7; }

/* ============================================================
   STATUS BAR
   ============================================================ */
.status-bar { margin-bottom: 20px; }

.status-bar__text {
  font-size: 12px;
  color: var(--text-muted);
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 1px;
}

/* ============================================================
   CROSSWORD LAYOUT
   ============================================================ */
.cw-layout {
  display: flex;
  gap: 48px;
  align-items: flex-start;
  flex-wrap: wrap;
}

.cw-layout--solution { margin-top: 0; }
.cw-grid-area { flex-shrink: 0; }

.cw-clues-area {
  flex: 1;
  min-width: 200px;
  display: flex;
  flex-direction: column;
  gap: 28px;
}

/* ============================================================
   CROSSWORD TABLE
   ============================================================ */
.cw-table {
  border-collapse: separate;
  border-spacing: 2px;
  padding: 6px;
  background: var(--grid-bg, #c8a07a);
  border-radius: 12px;
  box-shadow: 0 4px 16px rgba(0, 0, 0, 0.10), 0 1px 4px rgba(0,0,0,0.06);
}

.cw-table td {
  width: var(--cell);
  height: var(--cell);
  padding: 0;
  position: relative;
  border-radius: 5px;
  overflow: hidden;
}

.cell-black {
  background: var(--cell-black);
}

.cell-white {
  background: var(--cell-bg);
  border: 1.5px solid var(--cell-border);
  box-shadow: inset 0 1px 2px rgba(0,0,0,0.04);
}

.cell-solution {
  background: var(--cell-sol);
  border: 1.5px solid var(--cell-sol-border) !important;
}

/* Clue number (top-left) */
.cell-clue-num {
  position: absolute;
  top: 2px;
  left: 3px;
  font-size: 7px;
  font-family: var(--font-ui);
  font-weight: 700;
  color: #6b4226;
  line-height: 1;
  pointer-events: none;
  z-index: 2;
}

/* Solution position number (bottom-right) */
.cell-sol-num {
  position: absolute;
  bottom: 2px;
  right: 3px;
  font-size: 7px;
  font-family: var(--font-ui);
  font-weight: 700;
  color: var(--cell-sol-num);
  line-height: 1;
  pointer-events: none;
  z-index: 2;
}

/* Letter (solution view) */
.cell-letter {
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  font-size: 15px;
  font-weight: 900;
  font-family: var(--font-display);
  color: var(--text);
  z-index: 1;
  pointer-events: none;
  margin-top: -2px;
}

/* ============================================================
   SOLUTION WORD LINE
   ============================================================ */
.sol-line {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 10px;
  margin-top: 18px;
  padding: 12px 16px;
  background: var(--card);
  border: 1.5px solid #e0c9b0;
  border-radius: 10px;
}

.sol-line__label {
  font-size: 13px;
  font-weight: 700;
  color: var(--text);
  font-family: var(--font-display);
  font-style: italic;
}

.sol-line__boxes { display: flex; gap: 5px; flex-wrap: wrap; }

.sol-box {
  display: inline-flex;
  flex-direction: column;
  align-items: center;
  gap: 3px;
}

.sol-box__num {
  font-size: 9px;
  font-weight: 700;
  color: var(--cell-sol-num);
  line-height: 1;
}

.sol-box__line {
  display: block;
  width: 26px;
  height: 2.5px;
  background: var(--cell-border-outer);
  border-radius: 2px;
}

/* ============================================================
   CLUE LISTS
   ============================================================ */
.clue-group__title {
  display: flex;
  align-items: center;
  gap: 8px;
  font-family: var(--font-display);
  font-style: italic;
  font-size: 16px;
  font-weight: 700;
  color: var(--accent);
  margin-bottom: 12px;
  padding-bottom: 8px;
  border-bottom: 2px solid var(--accent-light);
}

.clue-group__title svg { color: var(--accent); flex-shrink: 0; }

.clue-list { display: flex; flex-direction: column; gap: 7px; }

.clue-item {
  display: flex;
  align-items: baseline;
  gap: 8px;
  font-size: 13px;
  color: var(--text);
  line-height: 1.45;
  padding: 5px 8px;
  border-radius: 7px;
  transition: background 0.1s;
}

.clue-item:hover { background: var(--accent-light); }

.clue-item__num {
  font-weight: 700;
  min-width: 24px;
  flex-shrink: 0;
  color: var(--accent);
  font-size: 12px;
}

.clue-item__text { flex: 1; }

.clue-item__sol-badge {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 18px;
  height: 18px;
  padding: 0 3px;
  background: var(--cell-sol);
  border: 1.5px solid var(--cell-sol-border);
  border-radius: 5px;
  font-size: 9px;
  font-weight: 700;
  color: var(--cell-sol-num);
  flex-shrink: 0;
  cursor: help;
}

/* ============================================================
   ACTION BAR
   ============================================================ */
.action-bar {
  display: flex;
  gap: 10px;
  margin-top: 28px;
  padding-top: 20px;
  border-top: 2px dashed #e0c9b0;
  flex-wrap: wrap;
}

/* ============================================================
   EXPORT OPTIONS (paper size + wedding decoration)
   ============================================================ */
.export-options {
  display: flex;
  align-items: center;
  gap: 16px;
  flex-wrap: wrap;
  width: 100%;
}

.export-opt {
  display: flex;
  align-items: center;
  gap: 6px;
  font-family: var(--font-ui);
  font-size: 13px;
  color: var(--text-muted, #888);
  cursor: pointer;
  user-select: none;
  white-space: nowrap;
}

.export-opt span:first-child {
  font-weight: 600;
  color: var(--text);
}

.export-opt select {
  font-family: var(--font-ui);
  font-size: 13px;
  padding: 3px 8px;
  border: 1.5px solid #d0c4b8;
  border-radius: 6px;
  background: #fff;
  color: var(--text);
  cursor: pointer;
  outline: none;
  transition: border-color 0.15s;
}

.export-opt select:focus {
  border-color: var(--accent);
}

.export-opt input[type="checkbox"] {
  width: 15px;
  height: 15px;
  accent-color: var(--accent);
  cursor: pointer;
  flex-shrink: 0;
}

/* ============================================================
   SOLUTION PAGE
   ============================================================ */
.solution-page { margin-top: 32px; }

.solution-page__title {
  font-family: var(--font-display);
  font-style: italic;
  font-size: 22px;
  font-weight: 700;
  color: var(--text);
  margin-bottom: 20px;
  padding-bottom: 10px;
  border-bottom: 2px solid #e0c9b0;
}

.sol-reveal {
  margin-top: 16px;
  font-size: 15px;
  color: var(--text);
  font-family: var(--font-display);
  font-style: italic;
}

.sol-reveal strong {
  letter-spacing: 3px;
  color: var(--accent);
  font-size: 18px;
  font-style: normal;
}

.page-break { display: none; }

/* ============================================================
   PRINT HEADER
   ============================================================ */
.print-header__title {
  font-family: var(--font-display);
  font-style: italic;
  font-size: 28px;
  font-weight: 900;
  color: #2d1f14;
  margin-bottom: 4px;
}

.print-header__sub {
  font-size: 13px;
  color: var(--text-muted);
  margin-bottom: 24px;
}

/* ============================================================
   PDF EXPORT MODE (legacy)
   ============================================================ */
body.is-pdf-export .no-print         { display: none !important; }
body.is-pdf-export .print-only       { display: block !important; }
body.is-pdf-export #crossword-output  { display: block !important; }
body.is-pdf-export .page-break       { display: block; margin: 24px 0; border-top: 1px dashed #ccc; }
body.is-pdf-export #solution-page    { display: block !important; }
body.is-pdf-export .solution-page__title { display: none; }
body.is-pdf-export .cw-layout        { flex-wrap: nowrap; gap: 28px; }
body.is-pdf-export .main             { padding: 24px 28px; overflow: visible; background: #fff; }
body.is-pdf-export :root             { --cell: 28px; }

/* ============================================================
   LOGO BACK LINK
   ============================================================ */
.logo__back {
  font-size: 18px;
  color: var(--sidebar-muted);
  text-decoration: none;
  line-height: 1;
  padding: 4px 6px;
  border-radius: 6px;
  transition: background 0.15s, color 0.15s;
}
.logo__back:hover { background: var(--sidebar-hover); color: var(--sidebar-text); }

/* ============================================================
   OCCASION GRID
   ============================================================ */
.anlass-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 6px;
}

.anlass-btn {
  background: var(--sidebar-input);
  color: var(--sidebar-muted);
  border: 1.5px solid var(--sidebar-border);
  border-radius: 8px;
  padding: 8px 6px;
  font-size: 12px;
  font-family: var(--font-ui);
  font-weight: 700;
  cursor: pointer;
  transition: background 0.15s, border-color 0.15s, color 0.15s;
  text-align: center;
}
.anlass-btn:hover { background: var(--sidebar-hover); border-color: #7a5540; color: var(--sidebar-text); }
.anlass-btn.active {
  background: var(--accent);
  border-color: var(--accent);
  color: #fff;
}

/* ============================================================
   TEXT INPUTS (SIDEBAR)
   ============================================================ */
.text-input {
  width: 100%;
  font-family: var(--font-ui);
  font-size: 13px;
  background: var(--sidebar-input);
  color: var(--sidebar-text);
  border: 1px solid var(--sidebar-border);
  border-radius: var(--radius);
  padding: 9px 12px;
  outline: none;
  transition: border-color 0.15s;
}
.text-input:focus { border-color: var(--accent); }
.text-input::placeholder { color: #5a3e2e; }
.text-input--sm { font-size: 12px; padding: 7px 10px; margin-bottom: 5px; }

.form-required {
  font-size: 10px;
  font-weight: 400;
  text-transform: none;
  letter-spacing: 0;
  color: var(--accent);
}

/* ============================================================
   TEXTAREA (SIDEBAR)
   ============================================================ */
.text-input--textarea {
  resize: vertical;
  min-height: 60px;
  line-height: 1.5;
  font-size: 12px;
}

/* ============================================================
   DIFFICULTY PICKER
   ============================================================ */
.difficulty-grid {
  display: grid;
  grid-template-columns: 1fr 1fr 1fr;
  gap: 6px;
}
.difficulty-btn {
  background: var(--sidebar-input);
  color: var(--sidebar-muted);
  border: 1.5px solid var(--sidebar-border);
  border-radius: 8px;
  padding: 7px 4px;
  font-size: 11px;
  font-family: var(--font-ui);
  font-weight: 700;
  cursor: pointer;
  transition: background 0.15s, border-color 0.15s, color 0.15s;
  text-align: center;
}
.difficulty-btn:hover { background: var(--sidebar-hover); border-color: #7a5540; color: var(--sidebar-text); }
.difficulty-btn.active {
  background: var(--accent);
  border-color: var(--accent);
  color: #fff;
}

/* ============================================================
   QUESTIONS LIST
   ============================================================ */
.questions-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 8px;
}

.questions-counter {
  font-size: 10px;
  font-weight: 700;
  padding: 2px 7px;
  border-radius: 20px;
  border: 1.5px solid var(--sidebar-border);
  color: var(--sidebar-muted);
  transition: background 0.2s, color 0.2s, border-color 0.2s;
}
.questions-counter[data-ok="true"] {
  background: rgba(100, 180, 80, 0.15);
  border-color: #5a9e40;
  color: #8dd870;
}

.questions-list {
  display: flex;
  flex-direction: column;
  gap: 5px;
  margin-bottom: 8px;
}

.question-item {
  display: flex;
  align-items: flex-start;
  gap: 8px;
  background: var(--sidebar-input);
  border: 1px solid var(--sidebar-border);
  border-radius: 8px;
  padding: 7px 9px;
  transition: border-color 0.15s;
}
.question-item:hover { border-color: #7a5540; }

.question-item__body {
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
  gap: 2px;
}
.question-item__frage {
  font-size: 12px;
  color: var(--sidebar-text);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  line-height: 1.3;
}
.question-item__antwort {
  font-size: 10px;
  font-family: var(--font-mono);
  color: #e8a87c;
  letter-spacing: 1px;
}
.question-item__actions {
  display: flex;
  flex-direction: row;
  gap: 2px;
  flex-shrink: 0;
  align-items: flex-start;
}

.question-item__edit,
.question-item__remove {
  background: none;
  border: none;
  color: var(--sidebar-muted);
  cursor: pointer;
  font-size: 16px;
  line-height: 1;
  padding: 0 2px;
  flex-shrink: 0;
  transition: color 0.15s;
  display: flex;
  align-items: center;
  justify-content: center;
}
.question-item__edit:hover { color: var(--accent); }
.question-item__remove:hover { color: #e57373; }

.question-item__body--edit {
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
  gap: 6px;
}
.question-item__body--edit .btn-row {
  margin-top: 2px;
}

/* ============================================================
   ADD QUESTION FORM
   ============================================================ */
.add-question-form {
  background: var(--sidebar-input);
  border: 1.5px solid var(--accent);
  border-radius: var(--radius);
  padding: 10px;
  display: flex;
  flex-direction: column;
  gap: 6px;
  margin-bottom: 8px;
}

/* ============================================================
   AI BUTTON
   ============================================================ */
.btn--ai {
  background: linear-gradient(135deg, #3d2b1f 0%, #5a3020 100%);
  color: #e8a87c;
  border: 1.5px solid #7a4830;
  flex: 1;
}
.btn--ai:hover {
  background: linear-gradient(135deg, #4f382a 0%, #6a3d28 100%);
  border-color: var(--accent);
  color: #ffd0a0;
}
.btn--ai:disabled { opacity: 0.6; }

/* Spinner */
@keyframes spin { to { transform: rotate(360deg); } }
.spinner {
  display: inline-block;
  width: 10px; height: 10px;
  border: 2px solid rgba(232,168,124,0.3);
  border-top-color: #e8a87c;
  border-radius: 50%;
  animation: spin 0.7s linear infinite;
  vertical-align: middle;
}

/* ============================================================
   AI PANEL
   ============================================================ */
.ai-panel {
  background: var(--sidebar-input);
  border: 1.5px solid #7a4830;
  border-radius: var(--radius);
  padding: 12px;
  display: flex;
  flex-direction: column;
  gap: 8px;
}
.ai-panel__header {
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.suggestions-list {
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.suggestion-item {
  display: flex;
  align-items: flex-start;
  gap: 8px;
  padding: 6px 8px;
  border-radius: 7px;
  cursor: pointer;
  transition: background 0.1s;
}
.suggestion-item:hover { background: var(--sidebar-hover); }

.suggestion-cb { flex-shrink: 0; margin-top: 3px; accent-color: var(--accent); }

.suggestion-item__text {
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
  gap: 2px;
}
.suggestion-item__frage  { font-size: 12px; color: var(--sidebar-text); line-height: 1.3; }
.suggestion-item__antwort {
  font-size: 10px;
  font-family: var(--font-mono);
  color: #e8a87c;
  letter-spacing: 1px;
}

.ai-empty { font-size: 12px; color: var(--sidebar-muted); padding: 8px 0; text-align: center; }

/* ============================================================
   AI SUGGESTIONS SECTIONS
   ============================================================ */
.ai-section {
  border-top: 1px solid var(--sidebar-border);
  padding-top: 8px;
}
.ai-section:first-of-type { border-top: none; padding-top: 0; }

.ai-section__title {
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 1px;
  color: var(--sidebar-muted);
  margin-bottom: 6px;
  display: flex;
  align-items: center;
  gap: 5px;
}
.ai-section__title span { font-size: 13px; }

/* ============================================================
   QUESTION TYPE BADGE
   ============================================================ */
.question-badge {
  display: inline-block;
  font-size: 9px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  padding: 1px 5px;
  border-radius: 4px;
  line-height: 1.4;
  flex-shrink: 0;
}
.question-badge--personal {
  background: rgba(232, 168, 124, 0.18);
  color: #e8a87c;
}
.question-badge--allgemein {
  background: rgba(120, 180, 230, 0.18);
  color: #78b4e6;
}

/* ============================================================
   GENERATE SECTION
   ============================================================ */
.generate-section { display: flex; flex-direction: column; gap: 6px; margin-top: auto; }

.generate-hint {
  font-size: 11px;
  color: var(--sidebar-muted);
  text-align: center;
  line-height: 1.4;
  transition: color 0.2s;
}
.generate-hint[data-ok="true"] { color: #8dd870; }

/* ============================================================
   PLACEHOLDER HINT
   ============================================================ */
.placeholder__hint {
  margin-top: 12px;
  font-size: 12px;
  color: var(--accent);
}

/* ============================================================
   ACTION BAR — THEME PICKER
   ============================================================ */
.action-bar {
  flex-direction: column;
  align-items: flex-start;
  gap: 12px;
}

.theme-picker-wrap {
  display: flex;
  align-items: center;
  gap: 10px;
}
.theme-picker-label {
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 1.5px;
  color: var(--text-muted);
  white-space: nowrap;
}

.theme-picker {
  display: flex;
  gap: 6px;
}

.theme-btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 6px 12px;
  border-radius: 8px;
  border: 2px solid #ddd0c4;
  background: var(--card);
  color: var(--text-muted);
  font-size: 12px;
  font-family: var(--font-ui);
  font-weight: 700;
  cursor: pointer;
  transition: border-color 0.15s, background 0.15s, color 0.15s;
}
.theme-btn:hover { border-color: var(--accent); color: var(--text); }
.theme-btn.active { border-color: var(--accent); background: var(--accent-light); color: var(--accent); }

.theme-btn__preview {
  display: block;
  width: 14px; height: 14px;
  border-radius: 3px;
  border: 1px solid rgba(0,0,0,0.12);
  flex-shrink: 0;
}
.theme-btn__preview--hochzeit { background: linear-gradient(135deg, #8aab8a 50%, #ffffff 50%); }
.theme-btn__preview--romantik { background: linear-gradient(135deg, #3d1f2a 50%, #f5dde5 50%); }
.theme-btn__preview--warm     { background: linear-gradient(135deg, #2d1f14 50%, #fce9b4 50%); }
.theme-btn__preview--plain    { background: linear-gradient(135deg, #000000 50%, #ffffff 50%); }

.action-bar__btns { display: flex; gap: 10px; flex-wrap: wrap; }

/* ============================================================
   MOBILE DEFAULTS (hidden on desktop)
   ============================================================ */
.mobile-fab        { display: none; }
.sidebar__handle   { display: none; }
.sidebar-overlay   { display: none; }
.mobile-action-bar { display: none; }

/* ============================================================
   MOBILE — BOTTOM-SHEET LAYOUT (≤ 768px)
   ============================================================ */
@media (max-width: 768px) {

  /* Re-enable scrolling — vertical only */
  body    { height: auto; overflow-y: auto; overflow-x: hidden; }
  .layout { flex-direction: column; height: auto; min-height: 100dvh; overflow-x: hidden; }

  /* ---- Sidebar as bottom-sheet ---- */
  .sidebar {
    position: fixed;
    bottom: 0; left: 0; right: 0;
    width: 100%;
    min-width: unset;
    height: 88dvh;
    border-radius: 20px 20px 0 0;
    border-right: none;
    border-top: 3px solid var(--sidebar-border);
    transform: translateY(100%);
    transition: transform 0.35s cubic-bezier(0.4, 0, 0.2, 1);
    z-index: 200;
  }
  .sidebar.is-open { transform: translateY(0); }

  /* Drag-Handle */
  .sidebar__handle {
    display: block;
    width: 40px; height: 4px;
    background: var(--sidebar-border);
    border-radius: 4px;
    margin: 12px auto 0;
    flex-shrink: 0;
  }

  /* Backdrop */
  .sidebar-overlay {
    display: block;
    position: fixed; inset: 0;
    background: rgba(0, 0, 0, 0.45);
    z-index: 199;
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.3s;
  }
  .sidebar-overlay.active {
    opacity: 1;
    pointer-events: auto;
  }

  /* ---- FAB — Floating Action Button ---- */
  .mobile-fab {
    display: flex;
    align-items: center;
    gap: 8px;
    position: fixed;
    bottom: 20px; left: 50%;
    transform: translateX(-50%);
    z-index: 150;
    background: var(--accent);
    color: #fff;
    border: none;
    border-radius: 50px;
    padding: 14px 24px;
    font-family: var(--font-ui);
    font-size: 14px;
    font-weight: 700;
    cursor: pointer;
    box-shadow: 0 6px 20px rgba(212, 98, 42, 0.45);
    white-space: nowrap;
    transition: background 0.15s, transform 0.1s, box-shadow 0.15s;
  }
  .mobile-fab:active {
    transform: translateX(-50%) scale(0.96);
    box-shadow: 0 3px 10px rgba(212, 98, 42, 0.4);
  }
  /* Hide FAB when sidebar is open */
  .sidebar.is-open ~ * .mobile-fab,
  .mobile-fab.hidden { display: none !important; }

  /* ---- Main-Bereich ---- */
  .main {
    padding: 16px 16px 96px;
    overflow: visible;
  }

  /* ---- Grid horizontal scroll ---- */
  .cw-grid-area {
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    padding-bottom: 4px;
  }

  /* ---- Grid + clues stacked ---- */
  .cw-layout {
    flex-direction: column;
    gap: 24px;
  }
  .cw-clues-area { min-width: unset; }

  /* ---- Smaller cells ---- */
  :root { --cell: 28px; }

  /* ---- Action bar stacked ---- */
  .theme-picker-wrap { flex-wrap: wrap; }
  .theme-picker      { flex-wrap: wrap; }
  .action-bar__btns  { flex-wrap: wrap; }
  .btn--action { flex: 1; min-width: 130px; justify-content: center; }

  /* ---- Smaller placeholder ---- */
  .placeholder { min-height: 40vh; }

  /* ---- Mobile Action Bar (Print / PDF / Solution) ---- */
  .mobile-action-bar {
    display: flex;
    flex-wrap: wrap;
    position: fixed;
    bottom: 0; left: 0; right: 0;
    gap: 8px;
    padding: 10px 12px calc(10px + env(safe-area-inset-bottom, 0px));
    background: var(--surface);
    border-top: 2px solid var(--cell-border);
    z-index: 140;
    box-shadow: 0 -4px 20px rgba(0, 0, 0, 0.12);
  }
  .mobile-action-bar.hidden { display: none !important; }
  .btn--mab {
    flex: 1;
    justify-content: center;
    font-size: 12px;
    padding: 10px 6px;
    gap: 5px;
  }

  /* Push FAB above action bar when action bar is visible */
  body:has(.mobile-action-bar:not(.hidden)) .mobile-fab {
    bottom: calc(70px + env(safe-area-inset-bottom, 0px));
  }

  /* Extra bottom padding on main when action bar is visible */
  body:has(.mobile-action-bar:not(.hidden)) .main {
    padding-bottom: 160px;
  }
}

/* ============================================================
   EXPORT PAYWALL (Stripe)
   ============================================================ */
.export-paywall {
  position: fixed;
  inset: 0;
  z-index: 200;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
}
.export-paywall.hidden { display: none !important; }

.export-paywall__backdrop {
  position: absolute;
  inset: 0;
  background: rgba(45, 31, 20, 0.55);
  backdrop-filter: blur(3px);
}

.export-paywall__panel {
  position: relative;
  max-width: 420px;
  width: 100%;
  background: var(--surface);
  border: 2px solid var(--cell-border);
  border-radius: var(--radius);
  padding: 24px 22px 20px;
  box-shadow: 0 20px 50px rgba(0, 0, 0, 0.18);
}

.export-paywall__title {
  font-family: var(--font-display);
  font-size: 1.35rem;
  font-weight: 800;
  color: var(--text);
  margin-bottom: 12px;
  line-height: 1.25;
}

.export-paywall__intro,
.export-paywall__legal {
  font-size: 0.95rem;
  color: var(--text);
  line-height: 1.5;
  margin-bottom: 12px;
}

.export-paywall__legal {
  font-size: 0.88rem;
  color: var(--text-muted);
}

.export-paywall__legal a {
  color: var(--accent);
  font-weight: 600;
}

.export-paywall__check {
  display: flex;
  gap: 10px;
  align-items: flex-start;
  font-size: 0.82rem;
  line-height: 1.45;
  color: var(--text);
  margin: 16px 0 18px;
  cursor: pointer;
}

.export-paywall__check input {
  margin-top: 3px;
  flex-shrink: 0;
  accent-color: var(--accent);
}

.export-paywall__error {
  font-size: 0.82rem;
  color: var(--error, #c0392b);
  margin: -10px 0 14px;
  line-height: 1.4;
}
.export-paywall__error.hidden { display: none; }

.export-paywall__actions {
  display: flex;
  gap: 10px;
  justify-content: flex-end;
  flex-wrap: wrap;
}

/* ============================================================
   CHECKOUT SUCCESS (post-Stripe restore)
   ============================================================ */
.checkout-success {
  position: fixed;
  inset: 0;
  z-index: 210;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
}
.checkout-success.hidden { display: none !important; }

.checkout-success__backdrop {
  position: absolute;
  inset: 0;
  background: rgba(45, 31, 20, 0.55);
  backdrop-filter: blur(3px);
}

.checkout-success__panel {
  position: relative;
  max-width: 420px;
  width: 100%;
  background: var(--surface);
  border: 2px solid var(--cell-border);
  border-radius: var(--radius);
  padding: 24px 22px 20px;
  box-shadow: 0 20px 50px rgba(0, 0, 0, 0.18);
}

.checkout-success__title {
  font-family: var(--font-display);
  font-size: 1.35rem;
  font-weight: 800;
  color: var(--text);
  margin-bottom: 12px;
  line-height: 1.25;
}

.checkout-success__intro {
  font-size: 0.95rem;
  color: var(--text);
  line-height: 1.5;
  margin-bottom: 18px;
}

.checkout-success__actions {
  display: flex;
  gap: 10px;
  justify-content: flex-end;
  flex-wrap: wrap;
}
