:root {
  --ip-bg: #eef0f4;
  --ip-panel: #ffffff;
  --ip-text: #1c1c24;
  --ip-muted: #6b6b78;
  --ip-line: #dfe1e8;
  --ip-accent: #6d28d9;
  --ip-changed: #fff4c2;
  --ip-bezel: #1d1f26;
  --ip-wood: #a0703f;
  --ip-wood-dark: #6b4426;
  --ip-shadow: 0 18px 40px rgb(20 20 40 / 0.22);
}

@media (prefers-color-scheme: dark) {
  :root {
    --ip-bg: #0e0f14;
    --ip-panel: #181a22;
    --ip-text: #ececf2;
    --ip-muted: #9a9aab;
    --ip-line: #2a2c38;
    --ip-accent: #a78bfa;
    --ip-changed: #4a3d0a;
    --ip-bezel: #050608;
    --ip-shadow: 0 18px 40px rgb(0 0 0 / 0.6);
  }
}

* { box-sizing: border-box; }
html, .ip-body { height: 100%; }
.ip-body { margin: 0; background: var(--ip-bg); color: var(--ip-text); font: 14px/1.4 system-ui, -apple-system, "Segoe UI", sans-serif; overflow: hidden; }
.ip { position: relative; display: flex; flex-direction: column; height: 100vh; }
.ip button { font: inherit; color: inherit; cursor: pointer; }

.ip-top { display: flex; align-items: center; gap: 12px; padding: 6px 16px; background: var(--ip-panel); border-bottom: 1px solid var(--ip-line); position: relative; z-index: 5; }
.ip-back { display: flex; text-decoration: none; color: var(--ip-muted); }
.ip-icon { width: 18px; height: 18px; flex-shrink: 0; }
.ip-titles { flex: 1; min-width: 0; }
.ip-title { font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.ip-subline { display: flex; gap: 8px; align-items: baseline; min-width: 0; white-space: nowrap; }
.ip-state { color: var(--ip-muted); font-size: 12px; flex: none; }
.ip-state::after { content: " ·"; }
.ip-controls { display: flex; gap: 4px; }
.ip-controls button { border: 1px solid var(--ip-line); background: var(--ip-panel); border-radius: 8px; padding: 4px 9px; min-width: 34px; }
.ip-controls button.ip-on { background: var(--ip-accent); color: #fff; border-color: var(--ip-accent); }

.ip-progress { display: flex; gap: 2px; padding: 5px 16px; background: var(--ip-panel); border-bottom: 1px solid var(--ip-line); position: relative; z-index: 5; }
.ip-dot { flex: 1 1 0; min-width: 3px; height: 7px; border: 0; border-radius: 4px; background: color-mix(in srgb, var(--color) 25%, transparent); padding: 0; }
.ip-dot.ip-dot-impact { height: 4px; align-self: center; }
.ip-dot.ip-past { background: color-mix(in srgb, var(--color) 60%, transparent); }
.ip-dot.ip-current { background: var(--color); outline: 2px solid var(--ip-text); outline-offset: 1px; }

/* The table takes a quarter of the screen: the active role sits at the far side facing us, the others fade behind the monitor. */
.ip-scene { height: 16vh; min-height: 110px; position: relative; z-index: 1; overflow: visible; }
.ip-table { position: absolute; inset: 0; }
.ip-table-top { position: absolute; left: 50%; top: 9vh; width: 46vh; height: 8vh; translate: -50% 0; border-radius: 50%; background: radial-gradient(ellipse at 50% 35%, color-mix(in srgb, var(--ip-wood) 80%, white), var(--ip-wood) 70%); box-shadow: 0 0 0 4px var(--ip-wood-dark), 0 14px 26px rgb(0 0 0 / 0.3); z-index: 50; }
.ip-seat { position: absolute; border: 0; background: none; padding: 0; translate: -50% -100%; transform-origin: 50% 100%; display: flex; flex-direction: column; align-items: center; filter: blur(1.5px) saturate(.6); opacity: .6; }
.ip-seat svg { width: 6.5vh; height: 8vh; overflow: visible; }
.ip-chair-back { fill: color-mix(in srgb, var(--color) 35%, #2b2b2b); }
.ip-torso { fill: var(--color); }
.ip-head { fill: color-mix(in srgb, var(--color) 25%, #f2d6c0); stroke: var(--color); stroke-width: 2; }
.ip-seat-label { position: absolute; top: 100%; margin-top: 2px; font-size: 1.4vh; color: var(--ip-muted); white-space: nowrap; }
.ip-seat.ip-active { filter: none; opacity: 1; }
.ip-seat.ip-active .ip-seat-label { top: 25%; left: 100%; margin: 0 0 0 8px; color: var(--ip-text); font-weight: 600; font-size: 1.5vh; }

/* The monitor takes the rest; its top edge covers the near side of the table. */
.ip-main { flex: 1; min-height: 0; display: flex; flex-direction: column; align-items: center; gap: 6px; padding: 0 12px 8px; margin-top: -4vh; position: relative; z-index: 2; }
.ip-row { flex: 1; min-height: 0; width: 100%; display: flex; gap: 12px; }
.ip-screen-wrap { flex: 1; min-width: 0; min-height: 0; display: flex; justify-content: center; align-items: flex-start; position: relative; }
.ip-recordbar { flex: none; width: 210px; align-self: flex-start; max-height: 100%; overflow-y: auto; margin-top: 4vh; padding: 10px 12px; background: var(--ip-panel); border: 1px solid var(--ip-line); border-radius: 10px; font-size: 12px; box-shadow: var(--ip-shadow); }
.ip-rb-head { font-weight: 700; font-size: 13px; margin-bottom: 6px; }
.ip-recordbar dl { margin: 0; display: grid; grid-template-columns: 1fr; }
.ip-recordbar dt { color: var(--ip-muted); font-size: 10px; text-transform: uppercase; letter-spacing: .04em; margin-top: 5px; }
.ip-recordbar dd { margin: 0; color: var(--ip-muted); overflow-wrap: anywhere; font-variant-numeric: tabular-nums; }
.ip-recordbar .ip-shown { color: var(--ip-text); font-weight: 700; }
.ip-recordbar dd.ip-shown { border-left: 3px solid var(--ip-accent); padding-left: 5px; }
.ip-recordbar dd.ip-rb-changed { background: var(--ip-changed); border-radius: 3px; }
.ip-rb-legend { margin: 8px 0 0; font-size: 10px; color: var(--ip-muted); }
.ip-monitor { padding: 12px; background: var(--ip-bezel); border-radius: 14px; box-shadow: 0 0 0 3px var(--color), var(--ip-shadow); }
.ip-monitor.ip-phone { padding: 14px 10px; border-radius: 30px; }
.ip-screens { display: flex; gap: 18px; align-items: flex-start; }
.ip-screen-wrap > .ip-screens.ip-leaving { position: absolute; left: 50%; top: 0; translate: -50% 0; pointer-events: none; }
.ip-shot { position: relative; overflow: hidden; background: var(--ip-panel); border-radius: 3px; }
.ip-phone .ip-shot { border-radius: 18px; }
.ip-shot img { display: block; width: 100%; height: 100%; user-select: none; }
.ip-placeholder { position: absolute; inset: 0; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 6px; padding: 16px; text-align: center; background: repeating-linear-gradient(45deg, transparent 0 14px, color-mix(in srgb, var(--color) 7%, transparent) 14px 28px); color: var(--ip-muted); }
.ip-placeholder strong { color: var(--ip-text); font-size: 20px; }
.ip-highlight { position: absolute; translate: -50% -50%; border-radius: 999px; pointer-events: none; --spot: var(--color); border: 4px solid var(--spot); box-shadow: 0 0 22px 4px var(--spot); z-index: 2; }
.ip-highlight.ip-kind-value, .ip-highlight.ip-kind-aggregate, .ip-highlight.ip-kind-export { --spot: #2563eb; }
.ip-highlight.ip-kind-availability { --spot: #f59e0b; border-style: dashed; }
.ip-highlight.ip-kind-missing { --spot: #dc2626; border-style: dashed; background: #dc262622; }
.ip-highlight > span { position: absolute; inset: -4px; border-radius: 999px; border: 4px solid var(--spot); animation: ip-ring 1.6s ease-out infinite; }
.ip-highlight > span + span { animation-delay: .8s; }
.ip-pressed { animation: ip-press 1.6s ease-in-out infinite; }
@keyframes ip-ring { from { transform: scale(1); opacity: .9; } to { transform: scale(1.5); opacity: 0; } }
@keyframes ip-press { 50% { box-shadow: 0 0 40px 12px var(--spot); } }
@media (prefers-reduced-motion: reduce) { .ip-pressed, .ip-highlight > span { animation: none; } }
.ip-note-box { position: absolute; border: 2px solid #f59e0b; background: #f59e0b22; border-radius: 4px; }
.ip-pin { position: absolute; width: 16px; height: 16px; margin: -8px 0 0 -8px; border-radius: 50%; background: #f59e0b; border: 2px solid #fff; box-shadow: var(--ip-shadow); }
.ip-editing .ip-shot { cursor: crosshair; outline: 3px dashed #f59e0b; outline-offset: 2px; }

.ip-caption { min-width: 0; font-size: 13px; font-weight: 600; overflow: hidden; text-overflow: ellipsis; }
.ip-kind { display: inline-block; padding: 0 8px; border-radius: 4px; font-size: 12px; font-weight: 500; background: #2563eb22; color: #2563eb; }
.ip-kind.ip-kind-missing { background: #dc262622; color: #dc2626; }
.ip-kind.ip-kind-availability { background: #d9770622; color: #d97706; }
.ip-alternatives select { max-width: 32vw; border: 1px solid var(--ip-line); border-radius: 8px; padding: 4px 6px; background: var(--ip-panel); color: var(--ip-text); font: inherit; font-size: 12px; }
.ip-alternatives:empty { display: none; }

.ip-timeline { width: 100%; max-width: 900px; }
.ip-timeline-label { font-size: 12px; color: var(--ip-muted); margin-bottom: 4px; text-align: center; }
.ip-days { display: flex; gap: 4px; overflow-x: auto; }
.ip-day { flex: 1 0 64px; border: 1px solid var(--ip-line); border-radius: 6px; padding: 3px; font-size: 12px; background: var(--ip-panel); }
.ip-day.ip-available { border-bottom: 4px solid #16a34a; }
.ip-day.ip-unavailable { border-bottom: 4px solid #dc2626; color: var(--ip-muted); }
.ip-day.ip-tipping { outline: 2px solid #f59e0b; }
.ip-day.ip-on { background: var(--ip-accent); color: #fff; }

.ip-settings { position: absolute; top: 46px; right: 16px; z-index: 6; width: min(320px, calc(100% - 32px)); max-height: 70vh; overflow-y: auto; background: var(--ip-panel); border: 1px solid var(--ip-line); border-radius: 12px; box-shadow: var(--ip-shadow); padding: 12px; display: flex; flex-direction: column; gap: 10px; font-size: 13px; }
.ip-settings[hidden] { display: none; }
.ip-settings fieldset { border: 0; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 4px; }
.ip-settings legend { font-weight: 600; margin-bottom: 4px; }
.ip-settings label { display: flex; align-items: center; gap: 8px; cursor: pointer; }
.ip-swatch { width: 10px; height: 10px; border-radius: 50%; background: var(--ip-muted); flex: none; }
.ip-settings > button { align-self: flex-start; border: 1px solid var(--ip-line); background: var(--ip-panel); border-radius: 8px; padding: 3px 10px; font-size: 12px; }

/* Drawer: record, details and annotations, only when asked for. */
.ip-drawer[hidden] { display: none; }
.ip-drawer { position: absolute; top: 0; right: 0; bottom: 0; width: min(420px, 100%); z-index: 4; background: var(--ip-panel); border-left: 1px solid var(--ip-line); box-shadow: var(--ip-shadow); overflow-y: auto; overflow-x: hidden; padding: 56px 14px 14px; display: flex; flex-direction: column; gap: 14px; }
.ip-details dl { display: grid; grid-template-columns: auto 1fr; gap: 4px 10px; margin: 0; font-size: 13px; }
.ip-details dt { color: var(--ip-muted); }
.ip-details dd { margin: 0; overflow-wrap: anywhere; }
.ip-record-head { font-weight: 600; margin-bottom: 4px; }
.ip-diff { width: 100%; border-collapse: collapse; font-size: 12px; font-variant-numeric: tabular-nums; table-layout: fixed; }
.ip-diff th { text-align: left; color: var(--ip-muted); font-weight: 500; border-bottom: 1px solid var(--ip-line); padding: 3px 4px; }
.ip-diff td { padding: 3px 4px; border-bottom: 1px solid var(--ip-line); font-family: ui-monospace, monospace; overflow-wrap: anywhere; }
.ip-diff tr.ip-changed td:nth-child(3) { background: var(--ip-changed); font-weight: 600; }
.ip-diff tr.ip-same-id td:first-child::after { content: " · ID bleibt"; color: #16a34a; font-family: system-ui; font-size: 11px; }
.ip-diff tr.ip-new-id td:first-child::after { content: " · neue ID"; color: #dc2626; font-family: system-ui; font-size: 11px; }
.ip-diff tr.ip-version.ip-changed td:first-child::after { content: " · Version hochgezählt"; color: #d97706; font-family: system-ui; font-size: 11px; }
.ip-muted { color: var(--ip-muted); margin: 0; }
.ip-notes { display: flex; flex-direction: column; gap: 8px; }
.ip-notes-head { font-size: 12px; color: var(--ip-muted); }
.ip-note { border: 1px solid var(--ip-line); border-left: 4px solid #f59e0b; border-radius: 8px; padding: 6px 8px; overflow-wrap: anywhere; }
.ip-note-accepted { border-left-color: #2563eb; }
.ip-note-rejected { border-left-color: var(--ip-muted); opacity: 0.7; }
.ip-note-fixed { border-left-color: #16a34a; }
.ip-note p { margin: 0 0 4px; }
.ip-note code { display: block; font-size: 11px; color: var(--ip-muted); }
.ip-note-meta { font-size: 11px; color: var(--ip-muted); display: flex; flex-wrap: wrap; gap: 4px; align-items: center; }
.ip-note-meta button, .ip-note-meta select { border: 0; background: none; color: var(--ip-accent); font-size: 11px; padding: 0; }
.ip-add-note { border: 1px dashed var(--ip-line); background: none; border-radius: 8px; padding: 8px; color: var(--ip-muted); }
.ip-composer { display: flex; flex-direction: column; gap: 6px; }
.ip-composer textarea { width: 100%; border: 1px solid var(--ip-line); border-radius: 8px; padding: 6px; background: var(--ip-bg); color: var(--ip-text); font: inherit; }
.ip-composer button { border: 1px solid var(--ip-line); background: var(--ip-panel); border-radius: 6px; padding: 3px 8px; }
.ip-composer button[type=submit] { background: var(--ip-accent); color: #fff; border-color: var(--ip-accent); }

@media (max-width: 900px) {
  .ip-recordbar { display: none; }
}

@media (max-width: 700px) {
  .ip-controls button { min-width: 30px; padding: 4px 6px; }
  .ip-scene { height: 20vh; }
}
