/* Ruhe-Zoo · Warmes, ruhiges Bilderbuch-Design für die Grundschule */

:root {
  --bg: #F8F4EC;
  --surface: #FDFBF7;
  --surface-subtle: #F2ECE0;
  --ink: #2C2722;
  --ink-muted: #6E655B;
  --border: #E5DDD0;
  --border-strong: #D3C8B8;

  --sage: #4E7A5B;
  --sage-soft: #E5EFE7;
  --amber: #C68B2C;
  --amber-soft: #F8EEDB;
  --terracotta: #C25943;
  --terracotta-soft: #F9E6E1;

  --accent: #3C5D4A;
  --accent-hover: #2E4A3A;

  --font-serif: 'Fraunces', Georgia, 'Times New Roman', serif;
  --font-sans: 'Plus Jakarta Sans', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;

  --radius-sm: 8px;
  --radius-md: 12px;
  --radius-lg: 16px;
}

* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

html, body {
  height: 100%;
  background: var(--bg);
  color: var(--ink);
  font-family: var(--font-sans);
  font-size: 14px;
  line-height: 1.45;
  -webkit-font-smoothing: antialiased;
  overflow: hidden;
}

.app {
  display: flex;
  flex-direction: column;
  height: 100vh;
  width: 100vw;
}

/* Kopfleiste */
.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 12px 22px;
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  flex-shrink: 0;
}

.brand {
  display: flex;
  align-items: center;
  gap: 11px;
  min-width: 170px;
}

.brand-mark {
  width: 12px;
  height: 12px;
  border-radius: 50%;
  background: var(--sage);
  box-shadow: 0 0 0 4px var(--sage-soft);
  flex-shrink: 0;
}

.brand-title {
  font-family: var(--font-serif);
  font-size: 20px;
  font-weight: 600;
  letter-spacing: -0.015em;
  line-height: 1.1;
  color: var(--ink);
}

.brand-sub {
  font-size: 11.5px;
  color: var(--ink-muted);
  margin-top: 1px;
}

/* Themenwelten-Reiter */
.world-tabs {
  display: flex;
  align-items: center;
  gap: 4px;
  border-bottom: 1px solid transparent;
  overflow-x: auto;
  scrollbar-width: none;
}
.world-tabs::-webkit-scrollbar { display: none; }

.world-tab {
  background: transparent;
  border: 1px solid transparent;
  color: var(--ink-muted);
  font-family: var(--font-sans);
  font-size: 13px;
  font-weight: 500;
  padding: 7px 12px;
  border-radius: var(--radius-sm);
  cursor: pointer;
  white-space: nowrap;
  transition: color 0.16s ease, background 0.16s ease, border-color 0.16s ease;
}

.world-tab:hover {
  color: var(--ink);
  background: var(--surface-subtle);
}

.world-tab.is-active {
  color: var(--ink);
  background: var(--surface-subtle);
  border-color: var(--border-strong);
  font-weight: 600;
}

/* Aktionen rechts */
.topbar-actions {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-shrink: 0;
}

/* Schaltflächen */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 7px;
  font-family: var(--font-sans);
  font-size: 13px;
  font-weight: 600;
  padding: 8px 13px;
  border-radius: var(--radius-sm);
  border: 1px solid transparent;
  cursor: pointer;
  transition: background 0.15s ease, border-color 0.15s ease, color 0.15s ease, transform 0.08s ease;
  white-space: nowrap;
}

.btn:active {
  transform: translateY(1px);
}

.btn-primary {
  background: var(--accent);
  color: #FDFBF7;
}
.btn-primary:hover {
  background: var(--accent-hover);
}
.btn-primary.is-recording {
  background: var(--terracotta);
}
.btn-primary.is-recording:hover {
  background: #A84A36;
}

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

.btn-ghost {
  background: transparent;
  color: var(--ink-muted);
  border-color: var(--border);
}
.btn-ghost:hover {
  color: var(--ink);
  background: var(--surface-subtle);
}

.btn-full {
  width: 100%;
  padding: 10px 14px;
}

.btn-icon {
  width: 34px;
  height: 34px;
  padding: 0;
  font-size: 18px;
  line-height: 1;
}

.link-btn {
  background: none;
  border: none;
  color: var(--accent);
  font-family: var(--font-sans);
  font-size: 12.5px;
  font-weight: 600;
  cursor: pointer;
  padding: 2px 4px;
}
.link-btn:hover {
  text-decoration: underline;
}

kbd {
  font-family: var(--font-sans);
  font-size: 11px;
  font-weight: 600;
  padding: 1px 5px;
  border-radius: 4px;
  background: rgba(255, 255, 255, 0.18);
  border: 1px solid rgba(255, 255, 255, 0.25);
  line-height: 1.3;
}
.btn-secondary kbd,
.btn-ghost kbd,
.floating-restore kbd {
  background: var(--surface-subtle);
  border-color: var(--border-strong);
  color: var(--ink-muted);
}

/* Arbeitsbereich */
.workspace {
  display: flex;
  flex: 1;
  min-height: 0;
  width: 100%;
}

/* Bühne */
.stage-wrap {
  position: relative;
  flex: 1;
  min-width: 0;
  min-height: 0;
  background: #EFE9DC;
  overflow: hidden;
}

.scene-canvas {
  display: block;
  width: 100%;
  height: 100%;
}

/* HUD oben links auf der Bühne */
.stage-hud-top {
  position: absolute;
  top: 16px;
  left: 18px;
  display: flex;
  align-items: center;
  gap: 10px;
  pointer-events: none;
  z-index: 4;
}

.status-indicator,
.count-indicator {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  background: rgba(253, 251, 247, 0.88);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  border: 1px solid rgba(44, 39, 34, 0.1);
  border-radius: 999px;
  padding: 6px 13px;
  color: var(--ink);
  font-size: 13px;
  font-weight: 600;
  box-shadow: 0 2px 10px rgba(44, 39, 34, 0.06);
}

.status-dot {
  width: 9px;
  height: 9px;
  border-radius: 50%;
  background: #9E9589;
  transition: background 0.25s ease, transform 0.25s ease;
}

.status-indicator[data-state="quiet"] .status-dot {
  background: var(--sage);
}
.status-indicator[data-state="warn"] .status-dot {
  background: var(--amber);
  transform: scale(1.15);
}
.status-indicator[data-state="loud"] .status-dot {
  background: var(--terracotta);
  transform: scale(1.25);
}

.count-indicator #countNumber {
  font-family: var(--font-serif);
  font-size: 16px;
  font-weight: 600;
  color: var(--accent);
}

/* Timer oben rechts auf der Bühne */
.timer-widget {
  position: absolute;
  top: 16px;
  right: 18px;
  display: flex;
  align-items: center;
  gap: 10px;
  background: rgba(253, 251, 247, 0.9);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  border: 1px solid rgba(44, 39, 34, 0.1);
  border-radius: 14px;
  padding: 7px 14px 7px 9px;
  box-shadow: 0 2px 12px rgba(44, 39, 34, 0.07);
  z-index: 4;
  transition: opacity 0.2s ease, transform 0.2s ease;
}

.timer-widget.is-hidden {
  opacity: 0;
  pointer-events: none;
  transform: translateY(-6px);
}

.timer-widget.is-finished {
  border-color: var(--sage);
  background: rgba(229, 239, 231, 0.95);
}

.timer-ring {
  width: 44px;
  height: 44px;
  transform: rotate(-90deg);
}

.timer-ring-bg {
  fill: none;
  stroke: rgba(44, 39, 34, 0.1);
  stroke-width: 5;
}

.timer-ring-fg {
  fill: none;
  stroke: var(--sage);
  stroke-width: 5;
  stroke-linecap: round;
  stroke-dasharray: 169.65;
  stroke-dashoffset: 0;
  transition: stroke-dashoffset 0.4s linear, stroke 0.3s ease;
}

.timer-readout {
  display: flex;
  flex-direction: column;
}

.timer-digits {
  font-family: var(--font-serif);
  font-size: 22px;
  font-weight: 600;
  line-height: 1.05;
  font-variant-numeric: tabular-nums;
  color: var(--ink);
}

.timer-state {
  font-size: 11px;
  font-weight: 600;
  color: var(--ink-muted);
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

/* Lautstärke-Balken unten */
.meter-strip {
  position: absolute;
  left: 18px;
  right: 18px;
  bottom: 14px;
  z-index: 4;
  pointer-events: none;
}

.meter-track {
  position: relative;
  height: 8px;
  background: rgba(253, 251, 247, 0.72);
  backdrop-filter: blur(4px);
  border-radius: 999px;
  overflow: visible;
  border: 1px solid rgba(44, 39, 34, 0.1);
}

.meter-fill {
  height: 100%;
  width: 0%;
  border-radius: 999px;
  background: var(--sage);
  transition: width 0.08s linear, background-color 0.2s ease;
}

.meter-threshold {
  position: absolute;
  top: -4px;
  bottom: -4px;
  width: 3px;
  left: 38%;
  background: var(--ink);
  border-radius: 2px;
  opacity: 0.65;
}

/* Schwebender Wiederherstellen-Button in Kinder-Ansicht */
.floating-restore {
  display: none;
  position: absolute;
  right: 18px;
  bottom: 32px;
  z-index: 6;
  background: rgba(253, 251, 247, 0.85);
  border: 1px solid var(--border-strong);
  color: var(--ink);
  font-family: var(--font-sans);
  font-size: 12px;
  font-weight: 600;
  padding: 6px 11px;
  border-radius: var(--radius-sm);
  cursor: pointer;
  opacity: 0.35;
  transition: opacity 0.2s ease;
}
.floating-restore:hover {
  opacity: 1;
}

/* Steuerungs-Seitenleiste */
.controls-panel {
  width: 310px;
  flex-shrink: 0;
  background: var(--surface);
  border-left: 1px solid var(--border);
  padding: 18px 20px 24px;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.control-section {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.section-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.section-head h2 {
  font-family: var(--font-serif);
  font-size: 16px;
  font-weight: 600;
  color: var(--ink);
}

.divider {
  border: none;
  border-top: 1px solid var(--border);
  margin: 2px 0;
}

.field-row {
  display: flex;
  flex-direction: column;
  gap: 5px;
}

.field-row label,
.slider-label label {
  font-size: 12.5px;
  font-weight: 600;
  color: var(--ink-muted);
}

.select-input {
  width: 100%;
  font-family: var(--font-sans);
  font-size: 13px;
  color: var(--ink);
  background: var(--bg);
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-sm);
  padding: 7px 10px;
  outline: none;
}
.select-input:focus {
  border-color: var(--accent);
}

.preset-row {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(56px, 1fr));
  gap: 6px;
}

.preset-btn {
  background: var(--bg);
  border: 1px solid var(--border);
  color: var(--ink-muted);
  font-family: var(--font-sans);
  font-size: 12px;
  font-weight: 600;
  padding: 6px 8px;
  border-radius: var(--radius-sm);
  cursor: pointer;
  transition: all 0.15s ease;
}
.preset-btn:hover {
  border-color: var(--border-strong);
  color: var(--ink);
}
.preset-btn.is-active {
  background: var(--sage-soft);
  border-color: var(--sage);
  color: var(--accent-hover);
}

.slider-field {
  display: flex;
  flex-direction: column;
  gap: 5px;
}

.slider-label {
  display: flex;
  justify-content: space-between;
  align-items: center;
}
.slider-label span {
  font-size: 12.5px;
  font-weight: 600;
  color: var(--ink);
  font-variant-numeric: tabular-nums;
}

input[type="range"] {
  -webkit-appearance: none;
  appearance: none;
  width: 100%;
  height: 5px;
  border-radius: 999px;
  background: var(--border-strong);
  outline: none;
}

input[type="range"]::-webkit-slider-thumb {
  -webkit-appearance: none;
  appearance: none;
  width: 16px;
  height: 16px;
  border-radius: 50%;
  background: var(--accent);
  border: 2px solid var(--surface);
  box-shadow: 0 1px 4px rgba(0, 0, 0, 0.2);
  cursor: pointer;
}

.field-hint {
  font-size: 12px;
  color: var(--ink-muted);
  line-height: 1.45;
}

.demo-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
}

.toggle-label {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  font-size: 13px;
  color: var(--ink);
  cursor: pointer;
  user-select: none;
}
.toggle-label.small {
  font-size: 12.5px;
  color: var(--ink-muted);
}
.toggle-label input[type="checkbox"] {
  accent-color: var(--accent);
  width: 15px;
  height: 15px;
  cursor: pointer;
}

.timer-custom-row {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 14px;
}

.timer-setup-display {
  font-family: var(--font-serif);
  font-size: 22px;
  font-weight: 600;
  min-width: 68px;
  text-align: center;
  font-variant-numeric: tabular-nums;
}

.timer-actions {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 8px;
}

.is-hidden {
  display: none !important;
}

/* Kinder-Ansicht (UI ausgeblendet) */
.app.is-clean .topbar,
.app.is-clean .controls-panel {
  display: none;
}
.app.is-clean .floating-restore {
  display: inline-flex;
  align-items: center;
  gap: 6px;
}

/* Tafel- / Mini-Fenster-Modus (?mode=board oder PiP) */
body.is-board-mode .topbar,
body.is-board-mode .controls-panel,
body.is-board-mode .floating-restore {
  display: none !important;
}

body.is-board-mode .stage-hud-top {
  top: 10px;
  left: 10px;
  gap: 6px;
}

body.is-board-mode .status-indicator,
body.is-board-mode .count-indicator {
  padding: 4px 10px;
  font-size: 12px;
}

body.is-board-mode .timer-widget {
  top: 10px;
  right: 10px;
  padding: 5px 10px 5px 7px;
  gap: 7px;
}

body.is-board-mode .timer-ring {
  width: 34px;
  height: 34px;
}

body.is-board-mode .timer-digits {
  font-size: 17px;
}

body.is-board-mode .timer-state {
  display: none;
}

body.is-board-mode .meter-strip {
  left: 10px;
  right: 10px;
  bottom: 8px;
}

/* Toast */
.toast {
  position: fixed;
  left: 50%;
  bottom: 24px;
  transform: translateX(-50%) translateY(20px);
  background: var(--ink);
  color: #FDFBF7;
  font-size: 13px;
  font-weight: 500;
  padding: 9px 16px;
  border-radius: 999px;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.2s ease, transform 0.2s ease;
  z-index: 50;
  box-shadow: 0 6px 20px rgba(0, 0, 0, 0.18);
}
.toast.is-visible {
  opacity: 1;
  transform: translateX(-50%) translateY(0);
}

/* Kleinere Bildschirme */
@media (max-width: 980px) {
  .topbar {
    flex-wrap: wrap;
    padding: 10px 14px;
  }
  .controls-panel {
    width: 270px;
    padding: 14px;
  }
}
