* { margin: 0; padding: 0; box-sizing: border-box; }
html, body { width: 100%; height: 100%; overflow: hidden; background: #000; font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif; color: #e8e8e8; }
#canvas-container { position: fixed; inset: 0; }
#canvas-container canvas { display: block; touch-action: none; }

#topbar {
  position: fixed; top: 0; left: 0; right: 0; z-index: 10;
  background: linear-gradient(to bottom, rgba(10,15,35,.9), rgba(10,15,35,.55));
  border-bottom: 1px solid rgba(120,160,255,.25);
  padding: 8px 16px;
  padding-top: calc(8px + env(safe-area-inset-top));
}
.topbar-inner { display: flex; align-items: center; justify-content: space-between; max-width: 1400px; margin: 0 auto; gap: 16px; }
.brand { font-weight: 700; font-size: 15px; letter-spacing: .5px; color: #fff; white-space: nowrap; }
#readout { display: flex; gap: 14px; align-items: baseline; font-variant-numeric: tabular-nums; min-width: 0; }
#date-display { font-size: 18px; font-weight: 600; color: #ffd76a; white-space: nowrap; }
#time-display { font-size: 13px; color: #9fb3ff; white-space: nowrap; }

/* Panel-Toggle-Button (nur mobil sichtbar) */
#btn-panel-toggle {
  display: none;
  position: fixed; left: 10px; top: 64px; z-index: 12;
  width: 44px; height: 44px; border-radius: 10px;
  background: rgba(10,15,35,.9); border: 1px solid rgba(120,160,255,.35);
  color: #ffd76a; font-size: 20px; cursor: pointer; backdrop-filter: blur(6px);
  box-shadow: 0 4px 16px rgba(0,0,0,.5);
}

.panel {
  position: fixed; left: 14px; top: 70px; width: 200px; z-index: 10;
  background: rgba(10,15,35,.82); border: 1px solid rgba(120,160,255,.25);
  border-radius: 10px; padding: 10px; backdrop-filter: blur(6px);
  max-height: calc(100vh - 220px); overflow-y: auto; -webkit-overflow-scrolling: touch;
}
.panel-header { font-size: 12px; text-transform: uppercase; letter-spacing: 1px; color: #9fb3ff; margin-bottom: 8px; display: flex; align-items: center; justify-content: space-between; gap: 6px; }
.panel-header .hint { text-transform: none; letter-spacing: 0; color: #667; font-size: 11px; }
.panel-close { display: none; background: none; border: 1px solid rgba(120,160,255,.3); color: #9fb3ff; border-radius: 6px; width: 26px; height: 26px; cursor: pointer; font-size: 13px; line-height: 1; }
#body-list { display: flex; flex-direction: column; gap: 3px; }
.body-item {
  display: flex; align-items: center; gap: 8px; padding: 5px 8px; border-radius: 6px;
  cursor: pointer; font-size: 13px; transition: background .15s;
  border: 1px solid transparent;
}
.body-item:active { background: rgba(120,160,255,.2); }
.body-item.active { background: rgba(255,215,106,.18); border-color: rgba(255,215,106,.5); }
.body-item .swatch { width: 12px; height: 12px; border-radius: 50%; flex-shrink: 0; box-shadow: 0 0 6px currentColor; }
.body-item .name { flex: 1; }
.section-header {
  font-size: 10px; text-transform: uppercase; letter-spacing: 1px; color: #6a7bc0;
  margin: 10px 4px 3px; padding-top: 6px; border-top: 1px solid rgba(120,160,255,.18);
}
.section-header:first-child { margin-top: 0; border-top: none; padding-top: 0; }

#info-bar {
  position: fixed; top: 70px; right: 14px; z-index: 10;
  display: flex; align-items: center; gap: 12px;
  background: rgba(10,15,35,.85); border: 1px solid rgba(120,160,255,.3);
  border-radius: 10px; padding: 8px 14px; backdrop-filter: blur(8px);
  box-shadow: 0 6px 24px rgba(0,0,0,.5);
}
#info-text { display: flex; flex-direction: column; line-height: 1.25; min-width: 0; }
#info-name { font-size: 15px; font-weight: 700; color: #ffd76a; }
#info-detail { font-size: 11px; color: #9fb3ff; }
#btn-overview {
  background: linear-gradient(to bottom, #2a3a7a, #1a2555); color: #fff;
  border: 1px solid rgba(255,215,106,.5); border-radius: 8px; padding: 8px 14px;
  font-size: 13px; font-weight: 600; cursor: pointer; transition: all .15s; white-space: nowrap;
}
#btn-overview:active { transform: translateY(1px); }

#controls {
  position: fixed; bottom: 12px; left: 50%; transform: translateX(-50%); z-index: 10;
  background: rgba(10,15,35,.85); border: 1px solid rgba(120,160,255,.3);
  border-radius: 12px; padding: 10px 14px; width: min(760px, 92vw);
  backdrop-filter: blur(8px); box-shadow: 0 8px 30px rgba(0,0,0,.5);
  max-height: calc(100vh - 160px); overflow-y: auto; -webkit-overflow-scrolling: touch;
}
.ctrl-row { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.ctrl-row + .ctrl-row { margin-top: 8px; }
.ctrl-row button {
  background: linear-gradient(to bottom, #2a3a7a, #1a2555); color: #fff;
  border: 1px solid rgba(120,160,255,.4); border-radius: 7px; padding: 6px 12px;
  font-size: 13px; cursor: pointer; transition: all .15s;
}
.ctrl-row button:active { transform: translateY(1px); }
.ctrl-row button#btn-play { min-width: 44px; min-height: 44px; font-size: 16px; }
.speed-label { font-size: 12px; color: #9fb3ff; }
.speed-hint { font-size: 11px; color: #667; }
select, input[type="date"] {
  background: #14205a; color: #fff; border: 1px solid rgba(120,160,255,.4);
  border-radius: 6px; padding: 8px 10px; font-size: 14px; min-height: 44px;
  color-scheme: dark;
}
.timeline-row { gap: 12px; }
#timeline { flex: 1; -webkit-appearance: none; appearance: none; height: 6px; background: linear-gradient(to right, #1a2555, #2a3a7a); border-radius: 3px; outline: none; }
#timeline::-webkit-slider-thumb { -webkit-appearance: none; width: 22px; height: 22px; background: #ffd76a; border-radius: 50%; cursor: pointer; box-shadow: 0 0 8px #ffd76a; }
#timeline::-moz-range-thumb { width: 22px; height: 22px; background: #ffd76a; border-radius: 50%; cursor: pointer; box-shadow: 0 0 8px #ffd76a; }
.timeline-hint { font-size: 11px; color: #667; }
.chk { font-size: 12px; color: #c8d0ff; display: inline-flex; align-items: center; gap: 5px; cursor: pointer; user-select: none; min-height: 32px; }
.chk input { accent-color: #ffd76a; width: 18px; height: 18px; }

#help {
  position: fixed; bottom: 12px; right: 14px; z-index: 9;
  font-size: 11px; color: #667; background: rgba(10,15,35,.6);
  padding: 6px 10px; border-radius: 6px; max-width: 280px;
}
.help-touch { display: none; }

/* ── Mobil (iPhone & Co) ─────────────────────────────────────────────── */
@media (max-width: 640px) {
  .brand { font-size: 13px; }
  #readout { gap: 8px; }
  #date-display { font-size: 14px; }
  #time-display { font-size: 11px; }

  /* Panel wird Drawer: ausgeblendet bis ☰ */
  #btn-panel-toggle { display: block; top: calc(64px + env(safe-area-inset-top)); }
  .panel {
    left: 0; right: 0; top: 0; bottom: 0; width: 100%;
    max-height: none; border-radius: 0; border: none;
    padding: 60px 14px 20px; padding-top: calc(60px + env(safe-area-inset-top));
    transform: translateX(-105%); transition: transform .25s ease;
    z-index: 20;
  }
  .panel.panel-open { transform: translateX(0); }
  .panel-close { display: inline-block; position: absolute; top: 14px; right: 14px; top: calc(14px + env(safe-area-inset-top)); }
  .body-item { padding: 10px; font-size: 15px; }
  .body-item .swatch { width: 16px; height: 16px; }

  /* Info-Leiste: kompakt, über den Controls */
  #info-bar {
    top: auto; bottom: auto;
    left: 62px; right: 10px; top: calc(64px + env(safe-area-inset-top));
    padding: 6px 10px; gap: 8px;
  }
  #info-name { font-size: 13px; }
  #info-detail { font-size: 10px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; max-width: 130px; }
  #btn-overview { padding: 8px 10px; font-size: 12px; }

  /* Controls: Bottom-Sheet, mehr Platz, große Touch-Targets */
  #controls {
    width: calc(100vw - 16px); left: 50%; bottom: 8px;
    bottom: calc(8px + env(safe-area-inset-bottom));
    border-radius: 14px;
  }
  .ctrl-row { gap: 8px; }
  .ctrl-row button { min-height: 44px; padding: 8px 12px; font-size: 14px; }
  .speed-label { display: none; }
  .speed-hint { font-size: 10px; }
  .timeline-hint { display: none; }
  #timeline { height: 8px; }
  #timeline::-webkit-slider-thumb { width: 26px; height: 26px; }
  #timeline::-moz-range-thumb { width: 26px; height: 26px; }
  .chk { font-size: 13px; }
  .chk input { width: 22px; height: 22px; }

  /* Help: Touch-Anleitung statt Maus */
  #help { display: none; }
  #help.show {
    display: block; bottom: auto; top: auto;
    left: 10px; right: 10px;
    bottom: calc(12px + env(safe-area-inset-bottom));
    max-width: none; font-size: 12px; text-align: center;
    padding: 8px 10px;
  }
  .help-desktop { display: none; }
  .help-touch { display: inline; }
}
