:root {
  --bg: #e9e9e9;
  --panel: #ffffff;
  --line: #d4d4d4;
  --text: #222;
  --muted: #777;
  --accent: #2b6cb0;
  --accent-soft: #dbe7f5;
  --sel: #1f4e8c;
}
* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; background: var(--bg); color: var(--text);
  font: 13px/1.4 -apple-system, "Helvetica Neue", Helvetica, Arial, sans-serif;
  overscroll-behavior: none; /* keine Vor/Zurück-Wischgeste des Browsers (Pfeil-Overlay) */
  overflow: hidden; }
body { display: flex; flex-direction: column; }
.hidden { display: none !important; }
.muted { color: var(--muted); }
.spacer { flex: 1; }
.sep { width: 1px; height: 22px; background: var(--line); margin: 0 6px; }

#topbar { display: flex; align-items: center; gap: 8px; padding: 6px 14px; background: var(--panel);
  border-bottom: 1px solid var(--line); flex-wrap: wrap; }
.brand { font-weight: 700; letter-spacing: .08em; font-size: 13px; color: #444; }
.brand span { color: var(--accent); }
button, select, input { font: inherit; color: inherit; }
button { border: 1px solid var(--line); background: #fff; padding: 4px 10px; border-radius: 4px; cursor: pointer; }
button:hover { background: #f3f3f3; }
button.ghost { border-color: transparent; background: transparent; }
button.ghost:hover { background: #eee; }
button.primary { background: var(--accent); color: #fff; border-color: var(--accent); }
button.primary:hover { background: #245a94; }
.group { display: flex; align-items: center; gap: 2px; }
.group .lbl { color: var(--muted); font-size: 11px; margin-right: 4px; text-transform: uppercase; letter-spacing: .05em; }
.seg { border-radius: 0; padding: 3px 9px; font-size: 12px; margin-left: -1px; }
.seg:first-of-type { border-radius: 4px 0 0 4px; }
.seg:last-of-type { border-radius: 0 4px 4px 0; }
.seg.active { background: var(--accent-soft); border-color: var(--accent); color: var(--accent); position: relative; z-index: 1; }
.seg:disabled { opacity: .4; cursor: default; }
select { border: 1px solid var(--line); background: #fff; padding: 4px 8px; border-radius: 4px; }
input[type=text], input:not([type]) { border: 1px solid var(--line); border-radius: 4px; padding: 4px 8px; background: #fff; }
.upload { position: relative; display: inline-block; border: 1px solid var(--line); border-radius: 4px; padding: 4px 10px; cursor: pointer; background: #fff; }
.upload:hover { background: #f3f3f3; }
.upload input { position: absolute; inset: 0; opacity: 0; cursor: pointer; width: 100%; }
.stats { color: var(--muted); font-size: 12px; white-space: nowrap; }
button.concept { background: #222; color: #fff; border-color: #222; font-weight: 600; letter-spacing: .02em; }
button.concept:hover { background: #000; }
button.concept.active { background: #2b6cb0; border-color: #2b6cb0; }
button.concept.plan { background: #6b6b6b; border-color: #6b6b6b; }
button.concept.plan:hover { background: #555; }
button.concept.plan.active { background: #2b6cb0; border-color: #2b6cb0; }
.concept-card { border-left: 5px solid #222; padding: 8px 12px 12px; }
.concept-card a.ghost { text-decoration: none; padding: 4px 10px; border-radius: 4px; color: inherit; font-size: 12px; }
.concept-card a.ghost:hover { background: #eee; }
.concept-card iframe { width: 100%; height: 60vh; border: 1px solid var(--line); border-radius: 4px; background: #444; margin-top: 8px; display: block; }
.concept-card.tall iframe { height: 85vh; }
.stats b { color: var(--text); font-weight: 600; }

main { flex: 1; display: flex; flex-direction: column; min-height: 0; }
#timelineWrap { position: relative; background: var(--bg); border-bottom: 1px solid var(--line); user-select: none; }
#timeline { display: block; width: 100%; height: 300px; cursor: default; }
#timeline.panning { cursor: grabbing !important; }
.hint { position: absolute; right: 10px; bottom: 3px; width: 16px; height: 16px; line-height: 15px; text-align: center; font-size: 11px;
  color: #777; border: 1px solid #bbb; border-radius: 50%; cursor: help; background: #f4f4f4; }
.flash { position: absolute; right: 34px; bottom: 5px; font-size: 11px; color: var(--accent); pointer-events: none; }
.legend { position: absolute; left: 12px; bottom: 4px; font-size: 11px; color: #666; display: flex; gap: 12px; align-items: center; pointer-events: none; }
.legend .sw { display: inline-block; width: 12px; height: 10px; border: 1px solid rgba(0,0,0,.2); border-radius: 2px; vertical-align: -1px; margin-right: 4px; }
.legend .dot { display: inline-block; width: 7px; height: 7px; border-radius: 50%; background: #4e79a7; vertical-align: 0; margin-right: 4px; }
input[type=color] { width: 28px; height: 26px; padding: 1px 2px; border: 1px solid var(--line); border-radius: 4px; background: #fff; cursor: pointer; }
.tooltip { position: absolute; pointer-events: none; background: rgba(30,30,30,.92); color: #fff; padding: 6px 9px;
  border-radius: 4px; font-size: 12px; max-width: 320px; z-index: 10; box-shadow: 0 2px 8px rgba(0,0,0,.2); }
.tooltip b { display: block; margin-bottom: 2px; }
.tooltip .m { color: #bbb; }

#panel { flex: 1; overflow-y: auto; overflow-x: hidden; overscroll-behavior: none; padding: 12px 16px; display: flex; flex-direction: column; gap: 12px; }
#timelineWrap { overscroll-behavior: none; touch-action: none; -webkit-user-select: none; }
#timeline { touch-action: none; -webkit-touch-callout: none; }
body.touch button, body.touch select { min-height: 32px; }
body.touch .hint { display: none; }
/* Touch: das DOKUMENT scrollt (iOS scrollt nur html, nicht body; im Querformat bleibt sonst keine Höhe) */
html.touch { height: auto; min-height: 100%; overflow-y: auto; overflow-x: hidden; }
html.touch body { height: auto; min-height: 100%; overflow: visible; display: block; }
html.touch main { display: block; }
html.touch #panel { overflow: visible; }
/* Vertikale Wischer auf der Timeline scrollt der Browser nativ (pan-y), horizontale + Pinch bleiben beim Canvas */
html.touch #timelineWrap, html.touch #timeline { touch-action: pan-y; }
/* Standalone (Home-Bildschirm) + Vollbild: Notch/Home-Indicator berücksichtigen */
#topbar { padding-top: max(6px, env(safe-area-inset-top)); padding-left: max(14px, env(safe-area-inset-left)); padding-right: max(14px, env(safe-area-inset-right)); }
#panel { padding-bottom: max(12px, env(safe-area-inset-bottom)); }
:fullscreen body, body:fullscreen { background: var(--bg); }
.concept-card iframe { overscroll-behavior: none; }
.row { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.scenelist { display: flex; flex-wrap: wrap; gap: 4px; margin-top: 8px; }
.chip { display: inline-flex; align-items: center; gap: 5px; padding: 2px 8px; border-radius: 3px; background: #fff;
  border: 1px solid var(--line); font-size: 12px; cursor: pointer; }
.chip:hover { border-color: #999; }
.chip.active { border-color: var(--accent); background: var(--accent-soft); }
.chip .sw { width: 9px; height: 9px; border-radius: 2px; display: inline-block; }
.card { background: var(--panel); border: 1px solid var(--line); border-radius: 6px; padding: 12px 14px; }
.card h3 { margin: 0 0 4px; font-size: 14px; font-weight: 600; }
.card .kv { display: grid; grid-template-columns: 110px 1fr; gap: 2px 10px; font-size: 12.5px; margin-top: 8px; }
.card .kv dt { color: var(--muted); }
.card .kv dd { margin: 0; }
.card pre { white-space: pre-wrap; font: 12px/1.45 "SF Mono", Menlo, Consolas, monospace; background: #f7f7f7;
  padding: 10px; border-radius: 4px; max-height: 260px; overflow: auto; margin: 10px 0 0; color: #333; }
.plan-entry { font-size: 12px; padding: 4px 0; border-top: 1px dashed var(--line); }
.plan-entry:first-child { border-top: none; }
.plan-entry .d { font-weight: 600; }
.seqlist { display: flex; flex-wrap: wrap; gap: 6px; }
.seqcard { display: flex; align-items: center; gap: 8px; background: #fff; border: 1px solid var(--line); border-radius: 4px;
  padding: 4px 8px; font-size: 12px; }
.seqcard .sw { width: 12px; height: 12px; border-radius: 3px; cursor: pointer; border: 1px solid rgba(0,0,0,.15); }
.seqcard .name { font-weight: 600; cursor: text; }
.seqcard .kind { color: var(--muted); font-size: 11px; text-transform: uppercase; letter-spacing: .04em; }
.seqcard button { padding: 0 5px; font-size: 12px; line-height: 18px; }
/* Karten-Spalten: Drehbuchtext (so breit wie der Text) · Fotos · Notizen */
.cols { display: flex; gap: 16px; margin-top: 10px; align-items: flex-start; }
.col-text { flex: none; max-width: 100%; }
.col-text pre { margin-top: 0; max-height: 520px; width: max-content; max-width: 100%; }
.col-photos, .col-notes { flex: 1; min-width: 220px; }
.col-head { font-size: 10px; letter-spacing: .06em; color: var(--muted); margin-bottom: 6px; }
.uploadfix { display: none; }
.items { display: flex; flex-wrap: wrap; gap: 6px; }
.items img { height: 92px; border-radius: 3px; border: 1px solid var(--line); cursor: zoom-in; display: block; }
.items img:hover { border-color: var(--accent); }
.items .it { position: relative; }
.items .it button { position: absolute; top: 2px; right: 2px; padding: 0 5px; font-size: 11px; background: rgba(255,255,255,.85); }
.dropzone { border: 1px dashed #bbb; border-radius: 4px; padding: 10px; text-align: center; color: var(--muted); font-size: 12px; margin-top: 8px; }
.lightbox { position: fixed; inset: 0; background: rgba(20,20,20,.9); display: none; align-items: center; justify-content: center; z-index: 100; }
.lightbox.open { display: flex; }
.lightbox figure { margin: 0; max-width: 92vw; max-height: 92vh; display: flex; flex-direction: column; align-items: center; gap: 8px; }
.lightbox img { max-width: 92vw; max-height: 86vh; object-fit: contain; border-radius: 4px; box-shadow: 0 4px 30px rgba(0,0,0,.5); }
.lightbox figcaption { color: #ccc; font-size: 12px; }
.lightbox button { position: absolute; background: rgba(255,255,255,.12); color: #fff; border: none; font-size: 28px; line-height: 1; width: 44px; height: 44px; border-radius: 22px; cursor: pointer; }
.lightbox button:hover { background: rgba(255,255,255,.25); }
.lightbox .lb-prev { left: 18px; top: 50%; transform: translateY(-50%); }
.lightbox .lb-next { right: 18px; top: 50%; transform: translateY(-50%); }
.lightbox .lb-close { right: 18px; top: 18px; font-size: 24px; }
@media (max-width: 1000px) { .cols { flex-wrap: wrap; } .col-text { flex-basis: 100%; } }
.card .cols .items img { height: 110px; }
.dropzone.over { border-color: var(--accent); color: var(--accent); background: var(--accent-soft); }
.small { font-size: 11px; }

.login { position: fixed; inset: 0; background: rgba(233,233,233,.96); z-index: 200; display: flex; align-items: center; justify-content: center; overflow: auto; }
.login-box { background: #fff; border: 1px solid var(--line); border-radius: 8px; padding: 26px 28px; width: 340px; box-shadow: 0 6px 30px rgba(0,0,0,.08); }
.login-box label { display: block; font-size: 12px; color: var(--muted); margin: 8px 0 2px; }
.login-box input { display: block; width: 100%; margin-top: 3px; font-size: 14px; padding: 7px 9px; }
.login-error { color: #c0392b; font-size: 12.5px; margin-top: 8px; }
.admin-box { background: #fff; border: 1px solid var(--line); border-radius: 8px; padding: 18px 22px; width: min(1100px, 96vw); max-height: 92vh; overflow: auto; box-shadow: 0 6px 30px rgba(0,0,0,.08); }
.utable { width: 100%; border-collapse: collapse; font-size: 12.5px; margin-top: 10px; }
.utable th { text-align: left; color: var(--muted); font-weight: 500; font-size: 11px; text-transform: uppercase; letter-spacing: .05em; padding: 6px 8px; border-bottom: 1px solid var(--line); }
.utable td { padding: 6px 8px; border-bottom: 1px solid #eee; vertical-align: top; }
.utable tr.inactive td { color: #aaa; }
.utable .badge { display: inline-block; font-size: 10px; padding: 1px 6px; border-radius: 3px; background: #eee; margin-left: 4px; vertical-align: 1px; }
.utable .badge.admin { background: #222; color: #fff; }
.utable button { padding: 2px 7px; font-size: 11px; }
.uform { display: grid; grid-template-columns: repeat(auto-fit, minmax(160px, 1fr)); gap: 8px; align-items: end; background: #f7f7f7; border: 1px solid var(--line); border-radius: 6px; padding: 10px 12px; margin-top: 8px; }
.uform label { font-size: 11px; color: var(--muted); display: flex; flex-direction: column; gap: 2px; }
.uform input, .uform select { padding: 4px 7px; }
.memb { display: inline-flex; align-items: center; gap: 4px; background: #f0f0f0; border-radius: 3px; padding: 1px 6px; margin: 1px 3px 1px 0; font-size: 11.5px; }
.memb button { padding: 0 4px; border: none; background: transparent; }
body.readonly .writeonly { display: none !important; }
.popover { position: absolute; top: 30px; left: 0; background: #fff; border: 1px solid var(--line); border-radius: 6px;
  box-shadow: 0 4px 16px rgba(0,0,0,.12); padding: 8px 10px; z-index: 50; min-width: 220px; font-size: 12.5px; }
.popover label { display: flex; align-items: center; gap: 6px; padding: 3px 0; cursor: pointer; white-space: nowrap; }
.popover label .cnt { margin-left: auto; color: var(--muted); }
.popover .dot, .items .dot { width: 9px; height: 9px; border-radius: 50%; display: inline-block; flex: none; }
.popover .actions { display: flex; gap: 6px; margin-top: 6px; padding-top: 6px; border-top: 1px solid var(--line); }
.popover .actions button { font-size: 11px; padding: 2px 7px; }
.items .it { display: flex; flex-direction: column; gap: 2px; position: relative; }
.dept-sec { border: 1px solid var(--line); border-radius: 5px; margin-bottom: 6px; background: #fff; }
.dept-head { display: flex; align-items: center; gap: 6px; padding: 5px 8px; cursor: pointer; user-select: none; font-weight: 600; font-size: 12px; }
.dept-head:hover { background: #f5f5f5; }
.dept-head .chev { width: 10px; color: #888; font-size: 10px; }
.dept-head .cnt { margin-left: auto; color: var(--muted); font-weight: 400; font-size: 11px; }
.dept-sec.collapsed .dept-body { display: none; }
.dept-body { padding: 2px 8px 8px; border-top: 1px solid #eee; }
.dept-body .items { margin-top: 6px; }
.note { position: relative; background: #fbf8e6; border: 1px solid #efe6b8; border-radius: 4px; padding: 6px 8px; margin: 6px 0; font-size: 12.5px; white-space: pre-wrap; }
.note .note-meta { display: flex; gap: 8px; align-items: center; color: var(--muted); font-size: 10.5px; margin-top: 4px; white-space: normal; }
.note .note-meta button { padding: 0 5px; font-size: 11px; line-height: 16px; border-color: transparent; background: transparent; }
.note .note-meta button:hover { background: rgba(0,0,0,.06); }
.note textarea { width: 100%; min-height: 60px; font: inherit; border: 1px solid var(--line); border-radius: 3px; padding: 4px 6px; resize: vertical; }
.note-add { margin-top: 6px; }
.note-add textarea { width: 100%; min-height: 48px; font: inherit; font-size: 12.5px; border: 1px solid var(--line); border-radius: 4px; padding: 5px 7px; resize: vertical; background: #fff; }
.note-add .row { margin-top: 4px; justify-content: flex-end; }
.items .it select { font-size: 10px; padding: 1px 2px; border: 1px solid var(--line); border-radius: 3px; background: #fff; color: #555; max-width: 122px; }
.items .it .dot { position: absolute; left: 4px; top: 4px; border: 1px solid #fff; box-shadow: 0 0 2px rgba(0,0,0,.4); }
