/* Layout: schmale App-Leiste, darunter zwei Spalten. Links der Ablauf als Zeitleiste (jeder Schritt sitzt mit seinem EPK-Symbol auf einer Linie),
   rechts die Zeichenflaeche mit Darstellung, Zoom und Export. Am Handy untereinander, Diagramm zuerst. */
:root {
  --bg: #f4f3f0;
  --surface: #ffffff;
  --sunken: #f7f6f3;
  --ink: #16161d;
  --ink-2: #3a3a46;
  --muted: #6c6b78;
  --line: #e3e1db;
  --line-strong: #cfccc4;
  --primary: #16161d;
  --primary-ink: #ffffff;
  --accent: #b8338c;
  --accent-soft: #f7e3f0;
  --focus: #b8338c;
  --ev: #b8338c;
  --ev-fill: #e9a6dc;
  --fn: #23874a;
  --fn-fill: #95d8a6;
  --org: #b08400;
  --info: #2f6fc4;
  --danger: #c0352b;
  --radius: 14px;
  --shadow-sm: 0 1px 2px rgba(22, 22, 29, .05);
  --shadow: 0 1px 2px rgba(22, 22, 29, .04), 0 8px 24px -8px rgba(22, 22, 29, .12);
  --ui: "Space Grotesk", system-ui, -apple-system, "Segoe UI", sans-serif;
  color-scheme: light;
}
/* Dunkel */
:root[data-theme="dark"] {
  --bg: #0f0f13; --surface: #17171d; --sunken: #121217; --ink: #f1f0ec; --ink-2: #cfcdd6; --muted: #9a98a6;
  --line: #26262f; --line-strong: #34343f; --primary: #f1f0ec; --primary-ink: #0f0f13;
  --accent: #ef8fd4; --accent-soft: #3a1c31; --focus: #ef8fd4;
  --ev: #ef8fd4; --fn: #74d69a; --org: #f2cf55; --info: #8ab8ff; --danger: #ff8f84;
  --shadow-sm: 0 1px 2px rgba(0, 0, 0, .4);
  --shadow: 0 1px 2px rgba(0, 0, 0, .35), 0 10px 30px -10px rgba(0, 0, 0, .6);
  color-scheme: dark;
}
* { box-sizing: border-box; }
[hidden] { display: none !important; }
html, body { margin: 0; }
body { background: var(--bg); color: var(--ink); font-family: var(--ui); font-size: 15px; line-height: 1.45; min-height: 100vh; display: flex; flex-direction: column; -webkit-font-smoothing: antialiased; }
button, input, select, textarea { font: inherit; color: inherit; }
:focus-visible { outline: 2px solid var(--focus); outline-offset: 2px; }
svg.i { width: 17px; height: 17px; flex: none; fill: none; stroke: currentColor; stroke-width: 1.9; stroke-linecap: round; stroke-linejoin: round; }

/* App-Leiste */
.appbar { background: color-mix(in srgb, var(--bg) 82%, transparent); backdrop-filter: blur(10px); -webkit-backdrop-filter: blur(10px); border-bottom: 1px solid var(--line); padding: calc(env(safe-area-inset-top, 0px) + 12px) 20px 12px; position: sticky; top: 0; z-index: 20; }
.appbar-inner { max-width: 1480px; margin: 0 auto; display: flex; align-items: center; gap: 12px; flex-wrap: wrap; }
.brand { display: flex; align-items: center; gap: 11px; text-decoration: none; color: inherit; margin-right: auto; }
.brand svg { width: 36px; height: 36px; flex: none; }
.brand b { display: block; font-size: 1.12rem; font-weight: 700; letter-spacing: -.02em; line-height: 1.1; }
.brand small { display: block; font-size: .78rem; color: var(--muted); letter-spacing: .01em; }

/* Buttons */
.btn { display: inline-flex; align-items: center; justify-content: center; gap: 8px; cursor: pointer; border-radius: 10px; border: 1px solid var(--line-strong); background: var(--surface); padding: 9px 14px; font-size: .9rem; font-weight: 600; line-height: 1.15; letter-spacing: -.005em; box-shadow: var(--shadow-sm); }
.btn:hover { border-color: var(--ink-2); }
.btn.primary { background: var(--primary); color: var(--primary-ink); border-color: var(--primary); }
.btn.primary:hover { opacity: .88; }
.btn.quiet { background: transparent; border-color: transparent; box-shadow: none; color: var(--ink-2); }
.btn.quiet:hover { background: var(--surface); border-color: var(--line); }
.btn.danger { color: var(--danger); }
.btn.danger:hover { border-color: var(--danger); }

/* Arbeitsbereich */
main { flex: 1; width: 100%; max-width: 1480px; margin: 0 auto; padding: 22px 20px 32px; display: grid; gap: 22px; grid-template-columns: minmax(400px, 5fr) minmax(0, 7fr); align-items: start; }
@media (max-width: 980px) { main { grid-template-columns: minmax(0, 1fr); padding-inline: 14px; } }
.panel { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow); min-width: 0; }
.panel-head { padding: 18px 20px 14px; display: grid; gap: 6px; }
.eyebrow { font-size: .72rem; font-weight: 700; text-transform: uppercase; letter-spacing: .12em; color: var(--accent); }
.panel-head h2 { margin: 0; font-size: 1.35rem; font-weight: 700; letter-spacing: -.025em; line-height: 1.15; text-wrap: balance; }
.panel-head p { margin: 0; color: var(--muted); font-size: .88rem; max-width: 60ch; }
.panel-head kbd { font-family: inherit; font-size: .8rem; background: var(--sunken); border: 1px solid var(--line); border-radius: 5px; padding: 0 5px; }
.panel-body { padding: 4px 20px 18px; }
.panel-foot { display: flex; flex-wrap: wrap; gap: 8px; padding: 14px 20px; border-top: 1px solid var(--line); background: var(--sunken); border-radius: 0 0 var(--radius) var(--radius); }

/* Ablauf als Zeitleiste */
.seq { position: relative; display: grid; gap: 10px; min-width: 0; padding-left: 30px; }
.seq::before { content: ""; position: absolute; left: 10px; top: 20px; bottom: 20px; width: 2px; border-radius: 2px; background: var(--line-strong); }
.item { position: relative; background: var(--surface); border: 1px solid var(--line); border-radius: 12px; padding: 8px 8px 8px 10px; display: grid; gap: 7px; min-width: 0; box-shadow: var(--shadow-sm); }
.item:focus-within { border-color: var(--line-strong); box-shadow: 0 0 0 4px color-mix(in srgb, var(--accent) 10%, transparent); }
.row { display: flex; gap: 4px; align-items: center; min-width: 0; }
/* Der Typ steht als Symbol auf der Zeitleiste, der Text dient nur Screenreadern */
.badge { flex: none; width: 0; height: 0; overflow: visible; font-size: 0; color: transparent; }
.badge::before { content: ""; position: absolute; left: -33px; top: 19px; width: 22px; height: 14px; box-shadow: 0 0 0 4px var(--surface); }
.item.e { border-left: 3px solid var(--ev); }
.item.f { border-left: 3px solid var(--fn); }
.item.e > .row .badge { color: var(--ev); }
.item.e > .row .badge::before { background: var(--ev-fill); clip-path: polygon(24% 0, 76% 0, 100% 50%, 76% 100%, 24% 100%, 0 50%); box-shadow: none; outline: 0; }
.item.f > .row .badge { color: var(--fn); }
.item.f > .row .badge::before { background: var(--fn-fill); border-radius: 4px; border: 1.5px solid var(--fn); box-shadow: 0 0 0 3px var(--surface); }
.item.s > .row .badge::before { width: 16px; height: 16px; left: -30px; top: 18px; border-radius: 50%; background: var(--surface); border: 2px solid var(--ink-2); box-shadow: 0 0 0 3px var(--surface); }
input[type="text"], select, textarea.ta { background: var(--sunken); border: 1px solid transparent; border-radius: 9px; padding: 8px 10px; min-width: 0; width: 100%; transition: border-color .12s, background-color .12s; }
input[type="text"]:hover, select:hover, textarea.ta:hover { border-color: var(--line); }
input[type="text"]::placeholder { color: var(--muted); opacity: .85; }
input[type="text"]:focus, select:focus, textarea.ta:focus { border-color: var(--accent); background-color: var(--surface); outline: none; }
.row > input[type="text"], .row > textarea.ta { font-weight: 500; }
textarea.ta { display: block; resize: none; overflow: hidden; line-height: 1.35; min-height: 38px; font-size: .97rem; }
.row > textarea.ta, .row > input[type="text"], .row > select { flex: 1; }
.extra { display: grid; grid-template-columns: 1fr 1fr; gap: 6px; padding-right: 0; }
.extra input, .extra input:focus { font-size: .84rem; padding: 6px 9px 6px 26px; background-repeat: no-repeat; background-position: 9px 50%; background-size: 11px 8px; }
.extra input:first-child { background-image: radial-gradient(ellipse at center, var(--org) 62%, transparent 66%); }
.extra input:last-child { background-image: linear-gradient(var(--info), var(--info)); }
@media (max-width: 560px) { .extra { padding: 0; grid-template-columns: 1fr; } }
.ic { flex: none; width: 34px; height: 34px; padding: 0; display: grid; place-items: center; cursor: pointer; border-radius: 9px; border: 1px solid transparent; background: transparent; color: var(--muted); font-size: 1rem; line-height: 1; }
.ic:hover { background: var(--sunken); color: var(--ink); }
.ic.del:hover { color: var(--danger); background: color-mix(in srgb, var(--danger) 10%, transparent); }
.adds { display: flex; flex-wrap: wrap; gap: 6px; position: relative; }
.adds::before { content: ""; position: absolute; left: -24px; top: 50%; width: 10px; height: 10px; margin-top: -5px; border-radius: 50%; border: 2px dashed var(--line-strong); background: var(--surface); }
.adds button { cursor: pointer; border: 1px dashed var(--line-strong); background: transparent; border-radius: 9px; font-size: .82rem; padding: 6px 11px; font-weight: 600; color: var(--ink-2); }
.adds button:hover { border-style: solid; background: var(--surface); }
.adds .ae:hover { color: var(--ev); border-color: var(--ev); } .adds .af:hover { color: var(--fn); border-color: var(--fn); }
.opsel { width: auto !important; flex: 1; font-weight: 600; }
.branches { display: grid; gap: 10px; }
.branch { border: 1px solid var(--line); border-radius: 11px; padding: 10px 10px 12px 6px; display: grid; gap: 8px; background: var(--sunken); min-width: 0; }
.branch .item { box-shadow: none; }
.branch .badge::before, .branch .item.f > .row .badge::before, .branch .item.s > .row .badge::before { box-shadow: 0 0 0 3px var(--surface); }
.bhead { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; justify-content: space-between; font-size: .84rem; padding-left: 8px; }
.bhead strong { font-size: .7rem; text-transform: uppercase; letter-spacing: .1em; color: var(--ink-2); }
.bhead label { display: inline-flex; gap: 7px; align-items: center; color: var(--muted); cursor: pointer; font-weight: 500; }
.bhead input[type="checkbox"] { accent-color: var(--accent); width: 16px; height: 16px; }
.addbranch { justify-self: start; cursor: pointer; border: 1px dashed var(--line-strong); background: transparent; border-radius: 9px; font-size: .82rem; padding: 6px 11px; font-weight: 600; color: var(--ink-2); }
.addbranch:hover { border-style: solid; }

/* Zeichenflaeche */
.stage { position: sticky; top: 84px; display: flex; flex-direction: column; max-height: calc(100vh - 106px); }
@media (max-width: 980px) { .stage { position: static; order: -1; max-height: none; } }
.toolbar { display: flex; flex-wrap: wrap; gap: 10px; align-items: center; padding: 14px 16px; border-bottom: 1px solid var(--line); }
.tgroup { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; }
.seg { display: inline-flex; padding: 3px; gap: 2px; border-radius: 10px; background: var(--sunken); border: 1px solid var(--line); }
.seg button { cursor: pointer; border: 0; background: transparent; padding: 6px 11px; font-size: .82rem; font-weight: 600; border-radius: 7px; color: var(--muted); }
.seg button:hover { color: var(--ink); }
.seg button[aria-pressed="true"] { background: var(--surface); color: var(--ink); box-shadow: 0 1px 2px rgba(0, 0, 0, .12), 0 0 0 1px var(--line); }
.zoom { display: inline-flex; align-items: center; gap: 2px; padding: 3px; border-radius: 10px; background: var(--sunken); border: 1px solid var(--line); }
.zoom button { cursor: pointer; border: 0; background: transparent; width: 30px; height: 30px; border-radius: 7px; display: grid; place-items: center; color: var(--ink-2); }
.zoom button:hover { background: var(--surface); }
.zoom output { min-width: 50px; text-align: center; font-size: .82rem; font-weight: 600; font-variant-numeric: tabular-nums; color: var(--ink-2); }
.spacer { flex: 1; }
.canvas-scroll { flex: 1; min-height: 0; overflow: auto; scrollbar-gutter: stable; padding: 18px; background-color: var(--sunken); background-image: radial-gradient(color-mix(in srgb, var(--muted) 30%, transparent) 1px, transparent 1.2px); background-size: 20px 20px; }
@media (max-width: 980px) { .canvas-scroll { max-height: 72vh; } }
.canvas-wrap { position: relative; height: 480px; margin: 0 auto; border-radius: 10px; overflow: hidden; box-shadow: var(--shadow); border: 1px solid var(--line); }
canvas { display: block; width: 100%; height: 100%; }
.empty { position: absolute; inset: 0; display: grid; place-content: center; justify-items: center; gap: 10px; text-align: center; padding: 24px; color: var(--muted); }
.empty svg { width: 64px; height: 64px; opacity: .8; }
.empty b { color: var(--ink); font-size: 1.05rem; }
.legend { display: flex; flex-wrap: wrap; gap: 8px 18px; padding: 12px 16px; border-top: 1px solid var(--line); font-size: .8rem; color: var(--muted); background: var(--surface); border-radius: 0 0 var(--radius) var(--radius); }
.legend span { display: inline-flex; align-items: center; gap: 7px; }
.legend svg { width: 24px; height: 15px; flex: none; }
#status { position: fixed; left: 50%; bottom: calc(env(safe-area-inset-bottom, 0px) + 22px); transform: translateX(-50%); background: var(--primary); color: var(--primary-ink); padding: 11px 18px; border-radius: 12px; font-size: .9rem; font-weight: 600; box-shadow: var(--shadow); z-index: 30; max-width: calc(100% - 32px); margin: 0; }
#status:empty { display: none; }

/* Fuss */
footer { padding: 18px 20px calc(env(safe-area-inset-bottom, 0px) + 18px); color: var(--muted); font-size: .8rem; }
footer div { max-width: 1480px; margin: 0 auto; display: flex; flex-wrap: wrap; gap: 6px 18px; justify-content: space-between; border-top: 1px solid var(--line); padding-top: 16px; }
footer svg { vertical-align: -3px; margin-right: 4px; }
footer a { color: inherit; text-underline-offset: 3px; }
footer a:hover { color: var(--accent); }

/* Bild-Fenster */
.overlay { position: fixed; inset: 0; background: rgba(10, 10, 14, .7); display: grid; place-items: center; padding: 16px; z-index: 40; }
.overlay .box { background: var(--surface); border-radius: var(--radius); padding: 18px; display: grid; gap: 12px; max-width: min(960px, 100%); max-height: 100%; overflow: auto; }
.overlay img { max-width: 100%; height: auto; border: 1px solid var(--line); border-radius: 8px; }
.overlay p { margin: 0; }
/* Handy */
.show-sm, .mobnav { display: none; }
@media (max-width: 980px) {
  body { padding-bottom: calc(env(safe-area-inset-bottom, 0px) + 76px); }
  .mobnav { display: flex; position: fixed; left: 12px; right: 12px; bottom: calc(env(safe-area-inset-bottom, 0px) + 10px); z-index: 25; padding: 5px; gap: 4px; border-radius: 16px; background: color-mix(in srgb, var(--surface) 88%, transparent); backdrop-filter: blur(12px); -webkit-backdrop-filter: blur(12px); border: 1px solid var(--line); box-shadow: var(--shadow); }
  .mobnav button { flex: 1; display: inline-flex; align-items: center; justify-content: center; gap: 8px; border: 0; background: transparent; padding: 12px; border-radius: 12px; font-weight: 600; color: var(--muted); cursor: pointer; }
  .mobnav button[aria-pressed="true"] { background: var(--primary); color: var(--primary-ink); }
  body[data-view="edit"] #viewPanel, body[data-view="view"] #editPanel { display: none; }
  .stage { order: 0; }
  #status { bottom: calc(env(safe-area-inset-bottom, 0px) + 84px); }
  .canvas-scroll { max-height: none; height: calc(100dvh - 330px); min-height: 320px; }
}
@media (max-width: 640px) {
  .hide-sm { display: none; }
  .show-sm { display: inline; }
  .appbar { position: static; padding: calc(env(safe-area-inset-top, 0px) + 10px) 14px 10px; }
  .brand small { display: none; }
  .appbar-inner { flex-wrap: nowrap; gap: 6px; }
  .brand { min-width: 0; }
  .brand b { font-size: 1.02rem; white-space: nowrap; }
  .brand svg { width: 32px; height: 32px; }
  .btn { padding: 8px 11px; }
  main { padding: 12px 10px 20px; gap: 12px; }
  .panel-head { padding: 16px 14px 12px; }
  .panel-head h2 { font-size: 1.15rem; }
  .panel-body { padding: 4px 10px 14px 8px; }
  .panel-foot { padding: 12px 14px; }
  /* Eingabefeld bekommt die ganze Breite, die Knoepfe rutschen klein darunter */
  .row { flex-wrap: wrap; row-gap: 2px; }
  .row > input[type="text"], .row > select { flex: 1 1 100%; }
  .row > .ic { width: 34px; height: 30px; }
  .row > .ic:first-of-type { margin-left: auto; }
  .row > .badge + input + .ic, .row > .badge + select + .ic { margin-left: auto; }
  /* weniger Einrueckung bei verschachtelten Wegen */
  .seq { padding-left: 24px; gap: 8px; }
  .seq::before { left: 8px; }
  .badge::before { left: -27px; }
  .item.s > .row .badge::before { left: -24px; }
  .adds::before { left: -20px; }
  .item { padding: 7px; }
  .branch { padding: 8px 6px 10px 2px; }
  .bhead { padding-left: 6px; }
  .toolbar { padding: 10px; gap: 8px; }
  .tgroup { gap: 6px; }
  .seg button { padding: 6px 9px; }
  .canvas-scroll { padding: 10px; }
  .legend { gap: 6px 12px; padding: 10px 12px; }
}

@media (prefers-reduced-motion: no-preference) { .btn, .ic, .seg button, .adds button, .zoom button { transition: background-color .12s, border-color .12s, color .12s, opacity .12s; } }

/* Umschalter zwischen den Werkzeugen */
.pagenav { display: inline-flex; max-width: 100%; overflow-x: auto; scrollbar-width: none; padding: 3px; gap: 2px; border-radius: 11px; background: var(--sunken); border: 1px solid var(--line); margin-right: auto; }
.pagenav a { padding: 7px 14px; border-radius: 8px; font-size: .88rem; font-weight: 600; color: var(--muted); text-decoration: none; white-space: nowrap; }
.pagenav a:hover { color: var(--ink); }
.pagenav a[aria-current="page"] { background: var(--surface); color: var(--ink); box-shadow: 0 1px 2px rgba(0, 0, 0, .12), 0 0 0 1px var(--line); }
.brand { margin-right: 6px; }
@media (max-width: 640px) {
  .brand b { display: none; }
  .pagenav a { padding: 6px 10px; font-size: .84rem; }
}

/* Grossansicht: Diagramm ueber die ganze Breite */
body[data-wide="1"] main { grid-template-columns: minmax(0, 1fr); }
body[data-wide="1"] #editPanel { display: none; }
body[data-wide="1"] .stage { position: static; max-height: none; }
body[data-wide="1"] .canvas-scroll { max-height: calc(100vh - 210px); }
.btn.icon { padding: 9px; }
.btn[aria-pressed="true"] { background: var(--primary); color: var(--primary-ink); border-color: var(--primary); }
@media (max-width: 980px) { #wideBtn { display: none; } }

/* Geheimer Regel-Check */
.check { margin: 12px 16px 0; border-radius: 12px; padding: 10px 14px; font-size: .88rem; border: 1px solid transparent; }
.check.ok { background: color-mix(in srgb, #1d7a45 12%, var(--surface)); color: #1d7a45; border-color: color-mix(in srgb, #1d7a45 30%, transparent); }
.check.bad { background: color-mix(in srgb, #b26b00 12%, var(--surface)); color: #9a5b00; border-color: color-mix(in srgb, #b26b00 30%, transparent); }
:root[data-theme="dark"] .check.ok { color: #74d39a; } :root[data-theme="dark"] .check.bad { color: #ffc56b; }
.check strong { display: flex; align-items: center; gap: 8px; margin-bottom: 4px; }
.check strong .tag { font-size: .66rem; letter-spacing: .1em; text-transform: uppercase; padding: 2px 7px; border-radius: 999px; background: currentColor; }
.check strong .tag span { color: var(--surface); }
.check ul { margin: 0; padding-left: 18px; display: grid; gap: 3px; }

/* Export-Menue */
details.menu { position: relative; }
details.menu > summary { list-style: none; }
details.menu > summary::-webkit-details-marker { display: none; }
details.menu > summary .chev { transition: transform .15s; }
details.menu[open] > summary .chev { transform: rotate(180deg); }
.menu-pop { position: absolute; right: 0; top: calc(100% + 6px); z-index: 15; min-width: 236px; padding: 6px; border-radius: 12px; background: var(--surface); border: 1px solid var(--line); box-shadow: var(--shadow); display: grid; gap: 2px; }
.menu-pop button { display: flex; align-items: center; gap: 10px; width: 100%; text-align: left; cursor: pointer; border: 0; background: transparent; padding: 9px 10px; border-radius: 8px; font-size: .9rem; font-weight: 500; }
.menu-pop button:hover { background: var(--sunken); }
.menu-pop button small { display: block; color: var(--muted); font-size: .76rem; }
.menu-pop hr { border: 0; border-top: 1px solid var(--line); margin: 4px 2px; }

/* Rueckgaengig / Wiederholen */
.history { display: inline-flex; gap: 4px; margin-right: auto; }
.history .btn { padding: 9px; }
.history .btn:disabled { opacity: .4; cursor: default; }

/* Status mit Aktion */
.status-action { margin-left: 12px; cursor: pointer; border: 0; border-radius: 8px; padding: 5px 10px; font-weight: 700; background: var(--primary-ink); color: var(--primary); }

/* Dialog */
.dialog { width: min(440px, 100%); gap: 14px !important; }
.dialog h3 { margin: 0; font-size: 1.15rem; letter-spacing: -.02em; }
.dialog p { color: var(--muted); font-size: .88rem; }
.dialog label { display: grid; gap: 5px; font-size: .78rem; font-weight: 700; text-transform: uppercase; letter-spacing: .08em; color: var(--muted); }
.dialog input { text-transform: none; letter-spacing: normal; font-size: .95rem; font-weight: 500; color: var(--ink); }
.dialog-actions { display: flex; justify-content: flex-end; gap: 8px; }

/* Datei auf die Seite ziehen */
body.dropping::after { content: "Loslassen zum Öffnen"; position: fixed; inset: 12px; z-index: 50; display: grid; place-items: center; border: 3px dashed var(--accent); border-radius: 20px; background: color-mix(in srgb, var(--bg) 82%, transparent); font-size: 1.3rem; font-weight: 700; color: var(--accent); pointer-events: none; }

/* Verschieben mit der Maus */
.canvas-scroll.pannable { cursor: grab; }
.canvas-scroll.panning { cursor: grabbing; user-select: none; }

/* Teilen-Auswahl */
.choice { display: flex; gap: 12px; align-items: flex-start; text-align: left; width: 100%; cursor: pointer; padding: 14px; border-radius: 12px; border: 1px solid var(--line); background: var(--sunken); }
.choice:hover, .choice:focus-visible { border-color: var(--accent); background: var(--accent-soft); }
.choice svg { width: 22px; height: 22px; margin-top: 1px; color: var(--accent); }
.choice b { display: block; font-size: .98rem; }
.choice small { display: block; color: var(--muted); font-size: .84rem; margin-top: 2px; line-height: 1.4; }

/* Nur-Ansehen-Modus */
.readonly-bar { max-width: 1480px; width: calc(100% - 40px); margin: 16px auto 0; display: flex; flex-wrap: wrap; align-items: center; gap: 10px 12px; padding: 12px 16px; border-radius: 14px; background: var(--accent-soft); border: 1px solid color-mix(in srgb, var(--accent) 35%, transparent); font-size: .92rem; }
.readonly-bar > svg { color: var(--accent); width: 20px; height: 20px; }
body[data-readonly="1"] main { grid-template-columns: minmax(0, 1fr); }
body[data-readonly="1"] #editPanel, body[data-readonly="1"] .mobnav, body[data-readonly="1"] #wideBtn,
body[data-readonly="1"] #openProject, body[data-readonly="1"] #saveProject { display: none !important; }
body[data-readonly="1"] #viewPanel { display: flex !important; position: static; max-height: none; }
body[data-readonly="1"] .canvas-scroll { max-height: calc(100vh - 260px); }
@media (max-width: 980px) { body[data-readonly="1"] { padding-bottom: 0; } .readonly-bar { width: calc(100% - 20px); } }

/* Projektliste */
details.proj > summary { max-width: 230px; }
details.proj .projname { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.projpop { min-width: 270px; max-height: 70vh; overflow: auto; }
.projhead { font-size: .7rem; font-weight: 700; letter-spacing: .1em; text-transform: uppercase; color: var(--muted); padding: 6px 10px 4px; }
.projpop button.on { background: var(--accent-soft); }
.projpop button b { display: block; font-size: .92rem; }
.projpop button.act { font-weight: 600; padding: 8px 10px; }
.projpop button.danger { color: var(--danger); }
body[data-readonly="1"] #projMenu { display: none !important; }
@media (max-width: 640px) { details.proj .projname { display: none; } details.proj > summary .chev { display: none; } }

/* Kopfzeile kompakt halten, seit es sieben Werkzeuge gibt */
@media (max-width: 1500px) {
  .brand small { display: none; }
  details.proj > summary { max-width: 170px; }
  .pagenav a { padding: 7px 11px; }
}
@media (max-width: 1360px) {
  .brand b { display: none; }
  .pagenav .hide-sm { display: none; }
  .pagenav .show-sm { display: inline; }
}
@media (max-width: 1180px) {
  #openProject .hide-sm, #saveProject .hide-sm { display: none; }
  details.proj > summary { max-width: 130px; }
  .pagenav a { padding: 7px 9px; font-size: .84rem; }
}

/* Vorlagen und Aufgabenleiste */
.dialog.tpl { width: min(640px, 100%); }
.tpllist { display: grid; gap: 8px; }
.tplrow { display: flex; gap: 12px; align-items: center; justify-content: space-between; padding: 12px 14px; border: 1px solid var(--line); border-radius: 12px; background: var(--sunken); }
.tplrow b { display: block; }
.tplrow small { display: block; color: var(--muted); font-size: .84rem; margin-top: 2px; }
.tplbtns { display: flex; gap: 6px; flex: none; }
@media (max-width: 520px) { .tplrow { flex-direction: column; align-items: stretch; } }
.taskbar { margin: 0 20px 14px; padding: 12px 14px; border-radius: 12px; background: var(--accent-soft); border: 1px solid color-mix(in srgb, var(--accent) 30%, transparent); display: grid; gap: 6px; }
.taskhead { display: flex; gap: 8px; align-items: center; }
.taskhead .tlabel { font-size: .7rem; font-weight: 700; letter-spacing: .1em; text-transform: uppercase; color: var(--accent); }
.taskhead .btn { padding: 6px 10px; font-size: .82rem; }
.taskbar p { margin: 0; font-size: .93rem; line-height: 1.55; white-space: pre-line; }
@media (max-width: 640px) { .taskbar { margin: 0 14px 12px; } }

/* Versteckte Extras */
html:not([data-extras="1"]) .extra-only { display: none !important; }

/* Code-Import im Struktogramm */
.dialog.code { width: min(680px, 100%); }
.dialog.code textarea { min-height: 280px; resize: vertical; font: .86rem/1.5 ui-monospace, "SFMono-Regular", Menlo, Consolas, monospace; tab-size: 4; white-space: pre; overflow: auto; color: var(--ink); }
.dialog .err { color: var(--danger); margin: 0; }

/* Text zum Abtippen im Dialog, markier- und kopierbar */
.asktext { margin: -4px 0 0; }
.copychip { display: flex; align-items: center; gap: 10px; padding: 6px 6px 6px 14px; border-radius: 12px; border: 1px dashed var(--line-strong); background: var(--sunken); transition: border-color .2s, background-color .2s; }
.copychip.done { border-style: solid; border-color: #2f9e57; background: color-mix(in srgb, #2f9e57 12%, var(--sunken)); }
.copytext { flex: 1; min-width: 0; font-weight: 700; font-size: 1rem; color: var(--ink); user-select: all; -webkit-user-select: all; overflow-wrap: anywhere; cursor: text; }
.copybtn { flex: none; display: inline-flex; align-items: center; gap: 6px; padding: 7px 12px; border-radius: 9px; border: 1px solid var(--line); background: var(--surface); color: var(--ink); font: inherit; font-size: .85rem; font-weight: 700; cursor: pointer; transition: background-color .15s, color .15s, border-color .15s; }
.copybtn:hover { border-color: var(--accent); color: var(--accent); }
.copybtn .i { width: 16px; height: 16px; }
.copychip.done .copybtn { color: #2f9e57; border-color: #2f9e57; }
.dialog input.match { border-color: #2f9e57; }
.btn.danger-fill { background: var(--danger); border-color: var(--danger); color: #fff; }
.btn.danger-fill:disabled { opacity: .45; cursor: not-allowed; }

/* breitere Dialoge (Aufgabe teilen, Arbeitsblatt) */
.dialog.wide { width: min(560px, 100%); }
.dialog textarea { font: inherit; font-size: .95rem; text-transform: none; letter-spacing: normal; font-weight: 500; color: var(--ink); resize: vertical; min-height: 110px; line-height: 1.5; width: 100%; background: var(--sunken); border: 1px solid transparent; border-radius: 9px; padding: 9px 11px; }
.dialog textarea:hover { border-color: var(--line); }
.dialog textarea:focus { border-color: var(--accent); background-color: var(--surface); outline: none; }
.dlgrow { display: grid; gap: 6px; }
.dlglabel { font-size: .78rem; font-weight: 700; text-transform: uppercase; letter-spacing: .08em; color: var(--muted); }
.dlgrow .seg { justify-self: start; flex-wrap: wrap; }
.dialog label.chk { display: flex; align-items: center; gap: 8px; text-transform: none; letter-spacing: normal; font-size: .92rem; font-weight: 600; color: var(--ink); }
.dialog label.chk input { flex: none; width: 18px; height: 18px; margin: 0; padding: 0; accent-color: var(--accent); }

/* zwischen Tablet und kleinem Laptop: Werkzeugleiste darf scrollen statt umzubrechen */
@media (min-width: 641px) and (max-width: 1100px) {
  .appbar-inner { flex-wrap: nowrap; }
  .pagenav { flex: 0 1 auto; min-width: 0; }
  #openProject .hide-sm, #saveProject .hide-sm, details.proj .projname { display: none; }
  details.proj > summary .chev { display: none; }
}

/* ===================== Nubiko-Look =====================
   Abgeleitet vom Logo: dunkle Kachel (Tinte), Prompt-Pink, Cursor-Gruen, 16px-Ecken.
   Die Kopfzeile ist die "Kachel" des Logos, Ueberschriften bekommen Prompt und Cursor. */
:root {
  --ink-tile: #16161d; --prompt: #e9a6dc; --cursor: #95d8a6;
  --accent: #c9459f; --accent-soft: #fbeaf6; --focus: #c9459f; --ok: #2f8c52;
  --radius: 16px;
}
/* Dunkel */
:root[data-theme="dark"] { --accent: #e9a6dc; --accent-soft: #351a2e; --focus: #e9a6dc; --ok: #74d39a; }
::selection { background: color-mix(in srgb, var(--prompt) 55%, transparent); }
:focus-visible { outline: 2px solid var(--focus); outline-offset: 2px; }

/* Kopfzeile als dunkle Kachel, in hell und dunkel gleich */
.appbar { background: var(--ink-tile); border-bottom: 1px solid #000; color: #f4f3f0; backdrop-filter: none; -webkit-backdrop-filter: none; }
.appbar .brand small { color: #9a98a6; }
.appbar .brand b { color: #f4f3f0; }
.appbar .pagenav { background: rgba(255, 255, 255, .06); border-color: rgba(255, 255, 255, .08); }
.appbar .pagenav a { color: #a9a7b4; }
.appbar .pagenav a:hover { color: #f4f3f0; }
.appbar .pagenav a[aria-current="page"] { background: var(--prompt); color: var(--ink-tile); box-shadow: none; }
.appbar .btn { background: rgba(255, 255, 255, .08); border-color: rgba(255, 255, 255, .12); color: #f4f3f0; box-shadow: none; }
.appbar .btn:hover { border-color: var(--prompt); }
.appbar .btn.quiet { background: transparent; border-color: transparent; color: #cfcdd6; }
.appbar .btn.quiet:hover { background: rgba(255, 255, 255, .08); border-color: transparent; color: #f4f3f0; }
.appbar .menu-pop { color: var(--ink); }

/* Ueberschriften-Label wie eine Eingabezeile: "> LABEL_" */
.eyebrow::before { content: "> "; color: var(--accent); }
.eyebrow::after { content: ""; display: inline-block; width: .62em; height: .24em; margin-left: .35em; border-radius: 2px; background: var(--cursor); vertical-align: .05em; }
@media (prefers-reduced-motion: no-preference) {
  .eyebrow::after { animation: nubiko-cursor 1.1s steps(1, end) infinite; }
}
@keyframes nubiko-cursor { 50% { opacity: 0; } }

/* Hauptknoepfe in Tinte mit Pink beim Darueberfahren */
.btn.primary:hover { opacity: 1; box-shadow: 0 0 0 3px color-mix(in srgb, var(--prompt) 55%, transparent); }

/* Meldung unten: dunkle Kachel */
#status:not(:empty) { background: var(--ink-tile); color: #f4f3f0; }
#status .status-action { background: var(--prompt); color: var(--ink-tile); }
:root[data-theme="dark"] #status:not(:empty) { box-shadow: 0 0 0 1px #2a2a33, var(--shadow); }

/* Fusszeile: kleiner Prompt vor dem Namen */
footer a:hover { color: var(--accent); }
/* Das Logo darf in der Kopfzeile nie gestaucht werden */
.appbar .brand { flex: none; }

/* Konto-Knopf in der Kopfzeile */
.kontobtn .ava, .ava { display: inline-grid; place-items: center; width: 26px; height: 26px; border-radius: 8px; background: var(--prompt); color: var(--ink-tile); font-size: .74rem; font-weight: 700; letter-spacing: 0; flex: none; }
a.btn { text-decoration: none; color: var(--ink); }
.einfach .appbar .brand b { display: block; }
.kontobtn.nur-ava { padding: 5px; }
.appbar .kontobtn { flex: none; }
/* Wortmarke in der Kopfzeile statt Text, Abstand zum Symbol nach den Markenregeln */
.brand b .wm { display: block; height: 19px; width: 77px; }
.brand { gap: 12px; }
.brand small { margin-top: 3px; }
/* Platz in der Kopfzeile: Untertitel nur auf einfachen Seiten, Anmelden-Text nur auf sehr breiten Bildschirmen */
.appbar-inner:has(.pagenav) .brand small { display: none; }
@media (max-width: 1600px) { .kontobtn .hide-sm { display: none; } .kontobtn { padding: 8px 10px; } }
@media (max-width: 1440px) { .appbar-inner:has(.pagenav) .brand b { display: none; } .pagenav .hide-sm { display: none; } .pagenav .show-sm { display: inline; } }
/* Die Kopfzeile bleibt immer einzeilig: notfalls scrollt die Werkzeugleiste, statt dass etwas in eine zweite Zeile rutscht */
@media (min-width: 641px) {
  .appbar-inner { flex-wrap: nowrap; }
  .appbar-inner > * { flex-shrink: 0; }
  .appbar-inner > .pagenav { flex: 0 1 auto; min-width: 0; }
}
.btn { white-space: nowrap; }
@media (max-width: 1800px) { .kontobtn .hide-sm { display: none; } .kontobtn { padding: 8px 10px; } }

/* Vorlagen: Abschnitt mit Uebungen anderer Lehrkraefte */
.tplbib { display: grid; gap: 8px; margin-top: 4px; padding-top: 14px; border-top: 1px solid var(--line); }
.tplbib h4 { margin: 0; font-size: .78rem; letter-spacing: .1em; text-transform: uppercase; color: var(--accent); }
.tplleer { margin: 0; color: var(--muted); font-size: .9rem; }
.tplmehr { font-size: .9rem; font-weight: 700; color: var(--accent); }
.dialog.tpl { max-height: calc(100dvh - 32px); overflow: auto; }

/* Darstellung (Hell/Dunkel, Schrift) */
.darpop { min-width: 280px; }
.darpop .darkopf { font-size: .7rem; font-weight: 700; letter-spacing: .1em; text-transform: uppercase; color: var(--muted); padding: 6px 10px 2px; }
.darpop .darseg { display: flex; margin: 4px 6px; }
.darpop .darseg button { flex: 1; justify-content: center; }
.darpop button[data-schrift] { align-items: center; }
.darpop button[data-schrift] small { font-family: var(--ui); }
.darpop button[aria-pressed="true"][data-schrift] { background: var(--accent-soft); box-shadow: inset 0 0 0 1px var(--accent); }
.darpop .probe { flex: none; width: 34px; height: 34px; border-radius: 8px; display: grid; place-items: center; background: var(--sunken); border: 1px solid var(--line); font-size: 1rem; font-weight: 700; }
.darpop .darhinweis { margin: 4px 10px 4px; font-size: .74rem; color: var(--muted); }
