/* PythonLab -- Tablet-first, hell/dunkel nach Systemeinstellung oder Umschalter. Keine externen Ressourcen.
   Kopf, Fuß und Grundfarben wie bei den anderen Labs (StateLab, StructoLab). */

:root {
  --bg: #f4f5f7;
  --panel: #ffffff;
  --ink: #1d2433;
  --muted: #5f6b7f;
  --line: #d5dae2;
  --accent: #2563eb;
  --accent-ink: #ffffff;
  --hi: #f59e0b;
  --ok: #15803d;
  --ok-bg: #e8f6ec;
  --bad: #dc2626;
  --bad-bg: #fdecec;
  --active-line: rgba(37, 99, 235, .06);
  --selection: rgba(37, 99, 235, .22);
  --syn-kw: #7c3aed;
  --syn-str: #0f7b3f;
  --syn-num: #b45309;
  --syn-com: #6b7280;
  --syn-fn: #1d4ed8;
  --syn-def: #0e7490;
  --echo: #1d4ed8;
  --logo: #2a2068;
  --code-size: 17px;
  --radius: 12px;
  font-family: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  color-scheme: light;
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #12161f;
    --panel: #1b212d;
    --ink: #e6e9ef;
    --muted: #9aa5b7;
    --line: #2f3747;
    --accent: #5b8cff;
    --hi: #fbbf24;
    --ok: #4ade80;
    --ok-bg: #173323;
    --bad: #f87171;
    --bad-bg: #3a1c1c;
    --active-line: rgba(91, 140, 255, .08);
    --selection: rgba(91, 140, 255, .30);
    --syn-kw: #c4a5ff;
    --syn-str: #7ee2a8;
    --syn-num: #fbbf6a;
    --syn-com: #8b95a7;
    --syn-fn: #8fb4ff;
    --syn-def: #67d4e6;
    --echo: #8fb4ff;
    --logo: #c9c3f2;
    color-scheme: dark;
  }
}
:root[data-theme="dark"] {
  --bg: #12161f;
  --panel: #1b212d;
  --ink: #e6e9ef;
  --muted: #9aa5b7;
  --line: #2f3747;
  --accent: #5b8cff;
  --hi: #fbbf24;
  --ok: #4ade80;
  --ok-bg: #173323;
  --bad: #f87171;
  --bad-bg: #3a1c1c;
  --active-line: rgba(91, 140, 255, .08);
  --selection: rgba(91, 140, 255, .30);
  --syn-kw: #c4a5ff;
  --syn-str: #7ee2a8;
  --syn-num: #fbbf6a;
  --syn-com: #8b95a7;
  --syn-fn: #8fb4ff;
  --syn-def: #67d4e6;
  --echo: #8fb4ff;
  --logo: #c9c3f2;
  color-scheme: dark;
}

* { box-sizing: border-box; }
html, body { margin: 0; background: var(--bg); color: var(--ink); }
body {
  font-size: 16px; line-height: 1.4; -webkit-text-size-adjust: 100%;
  display: flex; flex-direction: column; min-height: 100vh;
}
/* Arbeitsfläche: Seite füllt genau den Bildschirm, gescrollt wird in den Flächen */
body.ide-mode { height: 100vh; height: 100dvh; }
button { font: inherit; color: inherit; }
a { color: var(--accent); }
.loading { color: var(--muted); padding: 2rem 0; }
.icon { width: 1.15em; height: 1.15em; vertical-align: -0.2em; flex: none; }
.spacer { flex: 1; }

/* ---------------------------------------------------------------- Kopf und Fuß (wie die anderen Labs) */

.site-header {
  display: flex; align-items: center; gap: 12px; flex: none;
  padding: max(8px, env(safe-area-inset-top)) max(16px, env(safe-area-inset-right)) 8px
           max(16px, env(safe-area-inset-left));
  background: var(--panel); border-bottom: 1px solid var(--line);
}
.site-brand { display: flex; align-items: center; gap: 10px; color: var(--ink); width: 100%; }
.theme-toggle { flex: none; display: grid; place-items: center; width: 44px; height: 44px;
  border: 1px solid var(--line); border-radius: 50%; background: var(--bg); color: var(--ink); cursor: pointer; }
.theme-toggle .icon { width: 22px; height: 22px; }
.hs-logo { height: 30px; width: auto; color: var(--logo); flex: none; }
.site-org { font-weight: 600; color: var(--logo); }
.site-name { font-weight: 800; padding-left: 10px; border-left: 2px solid var(--line); }
.site-brand a { display: flex; align-items: center; gap: 10px; color: inherit; text-decoration: none; }
.site-brand .hs-link:hover .site-org { text-decoration: underline; }
.site-footer { flex: none; text-align: center; font-size: .75rem; color: var(--muted);
               padding: 6px 16px max(6px, env(safe-area-inset-bottom)); }
.site-footer a { color: inherit; }
@media (max-width: 500px) {
  .site-org { display: none; }
  .site-name { padding-left: 0; border-left: 0; }
}

/* ---------------------------------------------------------------- Arbeitsfläche */

#app {
  flex: 1; width: 100%; max-width: 1800px; margin: 0 auto;
  padding: 10px max(12px, env(safe-area-inset-right)) 4px max(12px, env(safe-area-inset-left));
}
body.ide-mode #app { min-height: 0; display: flex; flex-direction: column; }
.workbench { flex: 1; min-height: 0; display: flex; flex-direction: column; gap: 10px; }

.toolbar { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; flex: none; }
.toolbar button, .pane-head button {
  display: inline-flex; align-items: center; gap: 6px; min-height: 44px; padding: 0 16px;
  border-radius: 10px; border: 1px solid var(--line); background: var(--panel); cursor: pointer;
  font-weight: 600; touch-action: manipulation;
}
.toolbar button:disabled { opacity: .45; cursor: default; }
.toolbar button.primary { background: var(--ok); border-color: var(--ok); color: #fff; }
:root[data-theme="dark"] .toolbar button.primary { color: #0b1a10; }
@media (prefers-color-scheme: dark) { :root:not([data-theme="light"]) .toolbar button.primary { color: #0b1a10; } }
.toolbar button.danger:not(:disabled) { background: var(--bad); border-color: var(--bad); color: #fff; }
.toolbar .icon-btn { min-width: 44px; padding: 0 10px; justify-content: center; }
.toolbar .icon-btn sup { font-size: .7em; }
.status { color: var(--muted); font-size: .95rem; padding: 0 4px; }
.status[data-state="input"] { color: var(--accent); font-weight: 600; }
.status[data-state="running"] { color: var(--ok); font-weight: 600; }
.status[data-state="failed"], .status[data-state="unsupported"] { color: var(--bad); font-weight: 600; }
.status[data-state="loading"]::before {
  content: ""; display: inline-block; width: .9em; height: .9em; margin-right: 6px; vertical-align: -0.1em;
  border: 2px solid var(--line); border-top-color: var(--accent); border-radius: 50%;
  animation: spin .8s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

.ide {
  flex: 1; min-height: 0; display: grid; gap: 10px;
  grid-template-columns: minmax(0, 3fr) minmax(0, 2fr); grid-template-rows: minmax(0, 1fr);
}
@media (orientation: portrait), (max-width: 800px) {
  .ide { grid-template-columns: minmax(0, 1fr); grid-template-rows: minmax(0, 3fr) minmax(0, 2fr); }
}
/* Mit Zeichenfläche: Editor links, rechts Zeichnung über Ausgabe; hochkant untereinander */
.ide .turtle-pane { display: none; } /* .ide davor: schlägt die spätere Regel .pane { display: flex } */
.ide.with-turtle .turtle-pane { display: flex; }
.ide.with-turtle {
  grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
  grid-template-rows: minmax(0, 3fr) minmax(0, 2fr);
  grid-template-areas: "ed tu" "ed co";
}
.ide.with-turtle .editor-pane { grid-area: ed; }
.ide.with-turtle .turtle-pane { grid-area: tu; }
.ide.with-turtle .console-pane { grid-area: co; }
@media (orientation: portrait), (max-width: 800px) {
  .ide.with-turtle {
    grid-template-columns: minmax(0, 1fr);
    grid-template-rows: minmax(0, 4fr) minmax(0, 4fr) minmax(0, 2fr);
    grid-template-areas: "ed" "tu" "co";
  }
}
.turtle-stage { flex: 1; min-height: 0; display: grid; place-items: center; overflow: hidden; padding: 4px; }
.turtle-canvas { display: block; border-radius: 4px; box-shadow: 0 0 0 1px var(--line); touch-action: none; }

@media (max-height: 520px) and (orientation: landscape) {
  /* Handy quer: Seite darf scrollen */
  body.ide-mode { height: auto; }
  .ide { min-height: 520px; }
}

.pane { min-height: 0; display: flex; flex-direction: column; background: var(--panel);
        border: 1px solid var(--line); border-radius: var(--radius); overflow: hidden; }
.editor-pane .cm-editor { flex: 1; min-height: 0; }
.editor-pane .cm-editor.cm-focused { outline: none; }
.editor-pane:focus-within { border-color: var(--accent); }

.pane-head { display: flex; align-items: center; gap: 6px; padding: 4px 6px 4px 12px;
             border-bottom: 1px solid var(--line); flex: none; }
.pane-title { font-weight: 700; font-size: .9rem; color: var(--muted); text-transform: uppercase; letter-spacing: .04em; }
.pane-head button.small { min-height: 36px; padding: 0 10px; font-size: .85rem; font-weight: 500; border-color: transparent; background: none; }

/* ---------------------------------------------------------------- Konsole */

.console {
  flex: 1; min-height: 0; overflow: auto; padding: 8px 12px 24px; cursor: text;
  font-family: ui-monospace, "SF Mono", Menlo, Consolas, "Roboto Mono", monospace;
  font-size: var(--code-size); line-height: 1.45; -webkit-overflow-scrolling: touch;
}
.console-out { white-space: pre-wrap; overflow-wrap: anywhere; }
.c-err, .c-error { color: var(--bad); }
.c-info { color: var(--muted); font-style: italic; font-family: system-ui, -apple-system, sans-serif; font-size: .85em; }
.c-echo { color: var(--echo); font-weight: 600; }
.c-prompt { color: var(--muted); }
.console-input-row { display: inline-flex; align-items: center; gap: 6px; vertical-align: baseline; max-width: 100%; }
.console-input {
  font: inherit; font-size: max(16px, var(--code-size)); /* < 16px: iOS zoomt beim Fokussieren */
  color: var(--echo); font-weight: 600; background: var(--bg);
  border: 1px solid var(--accent); border-radius: 6px; padding: 2px 8px; min-width: 8ch; width: 18ch; max-width: 60vw;
}
.console-input:focus { outline: 2px solid color-mix(in srgb, var(--accent) 35%, transparent); }
.console-send { min-width: 40px; min-height: 36px; border-radius: 8px; border: 1px solid var(--accent);
                background: var(--accent); color: var(--accent-ink); font-weight: 700; cursor: pointer; }

/* ---------------------------------------------------------------- Symbolleiste über der Bildschirmtastatur */

.symbar {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 50;
  display: flex; gap: 4px; overflow-x: auto; padding: 6px max(8px, env(safe-area-inset-left));
  background: var(--panel); border-top: 1px solid var(--line); box-shadow: 0 -2px 8px rgba(0, 0, 0, .08);
  scrollbar-width: none; -webkit-user-select: none; user-select: none;
}
.symbar[hidden] { display: none; }
.symbar button {
  flex: none; min-width: 44px; height: 44px; padding: 0 6px; border-radius: 8px;
  border: 1px solid var(--line); background: var(--bg); cursor: pointer; touch-action: manipulation;
  font-family: ui-monospace, "SF Mono", Menlo, Consolas, monospace; font-size: 1.15rem; font-weight: 600;
}
.symbar button.wide { min-width: 52px; }
.symbar button:active { background: var(--selection); }
body.symbar-open #app { padding-bottom: 64px; }

/* ---------------------------------------------------------------- Knöpfe (Ergänzungen) */

.toolbar button.accent:not(:disabled) { background: var(--hi); border-color: var(--hi); color: #1d2433; }
.toolbar button.check:not(:disabled) { border-color: var(--accent); color: var(--accent); }
.toolbar button[hidden] { display: none; }
.toolbar .small-btn { font-weight: 500; }
@media (max-width: 1100px) {
  .toolbar .small-btn span, .toolbar button[data-short] span { display: none; }
  .toolbar .small-btn { padding: 0 12px; }
}
@media (max-width: 700px) {
  .toolbar button span { display: none; }
  .toolbar button { padding: 0 12px; }
  .status { flex-basis: 100%; order: 10; }
}
.pane-head button.seg { border: 1px solid var(--line); background: var(--bg); }
.pane-head button.seg.active { background: var(--accent); color: var(--accent-ink); border-color: var(--accent); }
.step-count { color: var(--muted); font-size: .8rem; margin-left: 4px; }

/* ---------------------------------------------------------------- Variablen (Schrittmodus) */

:root { --step-next: rgba(245, 158, 11, .22); --step-prev: rgba(21, 128, 61, .12); }
@media (prefers-color-scheme: dark) { :root:not([data-theme="light"]) { --step-next: rgba(251, 191, 36, .22); --step-prev: rgba(74, 222, 128, .12); } }
:root[data-theme="dark"] { --step-next: rgba(251, 191, 36, .22); --step-prev: rgba(74, 222, 128, .12); }

.ide .vars-pane { display: none; }
.ide.with-vars .vars-pane { display: flex; }
.ide.with-vars { grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); grid-template-rows: minmax(0, 3fr) minmax(0, 2fr);
                 grid-template-areas: "ed va" "ed co"; }
.ide.with-vars.with-turtle { grid-template-rows: minmax(0, 3fr) minmax(0, 3fr) minmax(0, 2fr);
                             grid-template-areas: "ed tu" "ed va" "ed co"; }
.ide.with-vars .editor-pane, .ide.with-turtle .editor-pane { grid-area: ed; }
.ide.with-vars .vars-pane { grid-area: va; }
.ide.with-vars .console-pane, .ide.with-turtle .console-pane { grid-area: co; }
@media (orientation: portrait), (max-width: 800px) {
  .ide.with-vars { grid-template-columns: minmax(0, 1fr); grid-template-rows: minmax(0, 4fr) minmax(0, 3fr) minmax(0, 2fr);
                   grid-template-areas: "ed" "va" "co"; }
  .ide.with-vars.with-turtle { grid-template-rows: minmax(0, 3fr) minmax(0, 3fr) minmax(0, 3fr) minmax(0, 2fr);
                               grid-template-areas: "ed" "tu" "va" "co"; }
}
.vars-body { flex: 1; min-height: 0; overflow: auto; padding: 6px 10px 12px; }
.vars-empty { color: var(--muted); font-size: .9rem; margin: 8px 2px; }
.vars-where { color: var(--muted); font-size: .85rem; margin: 2px 0 8px; }
.frame { margin-bottom: 10px; }
.frame h3 { font-size: .8rem; text-transform: uppercase; letter-spacing: .04em; color: var(--muted); margin: 4px 0; }
.frame.local { border-left: 3px solid var(--accent); padding-left: 8px; }
.vars { border-collapse: collapse; width: 100%; font-variant-numeric: tabular-nums; }
.vars th { font-size: .75rem; color: var(--muted); font-weight: 600; text-align: left; padding: 4px 6px;
           border-bottom: 2px solid var(--line); }
.vars td { padding: 5px 6px; border-bottom: 1px solid var(--line); vertical-align: top;
           font-family: ui-monospace, "SF Mono", Menlo, Consolas, monospace; font-size: calc(var(--code-size) * .9); }
.vars td.v-val { word-break: break-word; }
.vars td.v-type { color: var(--muted); font-size: .8rem; font-family: system-ui, sans-serif; white-space: nowrap; }
.vars tr.changed td, .vars td.changed { background: color-mix(in srgb, var(--hi) 25%, transparent); font-weight: 700; }
.vars tr.new td { background: color-mix(in srgb, var(--ok) 15%, transparent); font-weight: 700; }
.vars tr.changed td.v-val, .vars tr.new td.v-val { animation: flash .7s ease; }
@keyframes flash { from { background: color-mix(in srgb, var(--hi) 70%, transparent); } }
.vars.history th, .vars.history td { text-align: center; white-space: nowrap; }
.vars.history td.v-step { color: var(--muted); font-family: system-ui, sans-serif; }
.vars.history thead th { position: sticky; top: -6px; background: var(--panel); }

/* ---------------------------------------------------------------- Übersicht */

.overview { max-width: 760px; margin: 0 auto; padding-bottom: 24px; }
.overview h1 { font-size: 2.2rem; margin: .5rem 0 .25rem; }
.overview h2 { font-size: 1.2rem; margin: 28px 0 10px; display: flex; gap: 10px; align-items: baseline; }
.overview h2 .muted { color: var(--muted); font-size: .9rem; font-weight: 500; }
.lead { color: var(--muted); margin: 0 0 1rem; }
.muted { color: var(--muted); }
.task-list { list-style: none; padding: 0; margin: 0; display: grid; gap: 10px; }
.task-card {
  display: grid; grid-template-columns: 2.4rem 1fr auto; align-items: center; gap: 12px;
  padding: 14px 16px; min-height: 64px; border-radius: var(--radius);
  background: var(--panel); border: 1px solid var(--line); color: var(--ink); text-decoration: none;
}
.task-card:active { transform: scale(.99); }
.task-card .num { width: 2.2rem; height: 2.2rem; border-radius: 50%; display: grid; place-items: center;
                  background: var(--bg); font-weight: 700; color: var(--muted); }
.task-card .title { font-weight: 600; font-size: 1.1rem; display: flex; flex-direction: column; gap: 2px; }
.task-card .title small { font-weight: 400; color: var(--muted); font-size: .9rem; }
.task-card .stars { color: var(--hi); font-size: 1.2rem; letter-spacing: 1px; white-space: nowrap; }
.task-card.playground { margin-bottom: 20px; border-color: var(--ok); }
.task-card.playground .num { background: var(--ok); color: #fff; }
.level-path .task-card.done .num { background: var(--ok-bg); color: var(--ok); }
.level-path .task-card.next { border-color: var(--accent); box-shadow: 0 0 0 2px color-mix(in srgb, var(--accent) 35%, transparent); }
.level-path .task-card.next .num { background: var(--accent); color: var(--accent-ink); }
.tags { display: flex; gap: 6px; flex-wrap: wrap; }
.tags:empty { display: none; }
.tag { font-size: .75rem; font-weight: 700; color: var(--accent-ink); background: var(--accent); border-radius: 999px; padding: 1px 8px; }
.tag.optional, .tag.turtle { color: var(--muted); background: none; border: 1px solid var(--muted); padding: 0 8px; }
.progress { display: flex; align-items: center; gap: 12px; margin: 0 0 8px; font-weight: 700; color: var(--hi); }
.progress .bar { flex: 1; height: 12px; border-radius: 999px; background: var(--line); overflow: hidden; }
.progress .bar div { height: 100%; background: var(--hi); border-radius: 999px; transition: width .6s ease; }
.privacy { color: var(--muted); font-size: .85rem; margin-top: 1.5rem; }
.link-btn { background: none; border: 0; padding: 4px 0; margin-left: .4em; color: var(--accent);
  text-decoration: underline; cursor: pointer; font-size: inherit; }
.reset-confirm { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; font-size: .9rem;
  padding: 10px 12px; border: 1px solid var(--bad); border-radius: 8px; background: var(--bad-bg); }
.reset-confirm[hidden] { display: none; }
.reset-confirm button { padding: 8px 14px; border-radius: 8px; border: 1px solid var(--muted); background: var(--bg); cursor: pointer; }
.reset-confirm button.danger { background: var(--bad); border-color: var(--bad); color: #fff; }
.load-error { color: var(--bad); padding: 2rem 0; }

/* ---------------------------------------------------------------- Aufgabenkopf */

.task-head { flex: none; max-height: 34vh; overflow: auto; }
.task-head .back { display: inline-flex; align-items: center; gap: 4px; padding: 2px 0; text-decoration: none; font-weight: 600; }
.task-head .head-row { display: flex; align-items: baseline; gap: 14px; flex-wrap: wrap; }
.task-head h1 { font-size: 1.4rem; margin: 2px 0; }
.task-head .stars { color: var(--hi); font-size: 1.2rem; letter-spacing: 1px; }
.task-head p { margin: 2px 0 6px; max-width: 95ch; }
.examples { margin: 4px 0; font-size: .95rem; }
.examples summary { cursor: pointer; color: var(--accent); font-weight: 600; min-height: 32px; }
.examples ul { margin: 4px 0; padding-left: 1.2em; }
code { font-family: ui-monospace, "SF Mono", Menlo, Consolas, monospace; background: var(--bg); border: 1px solid var(--line);
       border-radius: 5px; padding: 0 5px; font-size: .92em; }
.hint-row { display: flex; gap: 12px; align-items: flex-start; flex-wrap: wrap; margin: 4px 0; }
.hint-btn { display: inline-flex; align-items: center; gap: 6px; min-height: 40px; padding: 0 12px; border-radius: 10px;
            border: 1px solid var(--hi); background: var(--panel); cursor: pointer; font-weight: 600; }
.hint-btn:disabled { opacity: .45; cursor: default; }
.hints { margin: 0; padding: 8px 12px 8px 2em; background: color-mix(in srgb, var(--hi) 12%, var(--panel)); border-radius: 10px; flex: 1; min-width: 260px; }
.barometer { margin: 2px 0 6px !important; color: var(--hi); font-weight: 600; }
@media (max-height: 700px) { .task-head p { display: -webkit-box; -webkit-line-clamp: 3; -webkit-box-orient: vertical; overflow: hidden; } }

/* ---------------------------------------------------------------- Prüfergebnis */

.check-result { font-family: system-ui, -apple-system, sans-serif; font-size: 1rem; margin-bottom: 10px; }
.check-result[hidden] { display: none; }
.check-result.stale { opacity: .55; }
.check-result .solved { display: flex; flex-direction: column; gap: 4px; margin-bottom: 8px; }
.check-result .stars { font-size: 2rem; color: var(--hi); letter-spacing: 3px; }
.check-result p { margin: 4px 0; }
.bad-summary { color: var(--bad); font-weight: 700; display: flex; align-items: center; gap: 6px; }
.case-table { border-collapse: collapse; width: 100%; margin: 6px 0; font-variant-numeric: tabular-nums; }
.case-table th { font-size: .75rem; color: var(--muted); text-align: left; padding: 4px 6px; border-bottom: 2px solid var(--line); }
.case-table td { padding: 5px 6px; border-bottom: 1px solid var(--line); vertical-align: top; }
.case-table td.num { color: var(--muted); width: 2em; }
.case-table tr.ok .mark { color: var(--ok); }
.case-table tr.bad { background: var(--bad-bg); }
.case-table tr.bad .mark { color: var(--bad); }
.case-table code.wrong { border-color: var(--bad); color: var(--bad); font-weight: 700; }
.case-table code.missing { border-style: dashed; }
.check-result pre.err { color: var(--bad); white-space: pre-wrap; font-size: calc(var(--code-size) * .85); margin: 6px 0; }
.hint-line, .c-hint { color: var(--ink); background: color-mix(in srgb, var(--hi) 14%, transparent); border-radius: 8px; padding: 4px 8px; }
.c-hint { display: block; font-family: system-ui, -apple-system, sans-serif; font-size: .9em; margin-top: 4px; }
.next-task { display: inline-flex; align-self: flex-start; align-items: center; gap: 6px; margin-top: 6px; padding: 10px 14px;
             border-radius: 10px; background: var(--ok); color: var(--panel); font-weight: 700; text-decoration: none; }
.stars.pop { animation: pop .6s cubic-bezier(.2, 1.6, .4, 1); transform-origin: left center; }
@keyframes pop { 0% { transform: scale(.3); opacity: 0; } 100% { transform: scale(1); opacity: 1; } }
.confetti { position: fixed; inset: 0; width: 100vw; height: 100vh; pointer-events: none; z-index: 40; }
@media (prefers-reduced-motion: reduce) { .stars.pop, .vars tr td { animation: none !important; } }

/* ---------------------------------------------------------------- Dialoge (Teilen, Vorlage) */

.share-dialog { border: 1px solid var(--line); border-radius: var(--radius); background: var(--panel); color: var(--ink);
                padding: 18px 20px; max-width: min(520px, 92vw); width: 100%; }
.share-dialog::backdrop { background: rgba(0, 0, 0, .45); }
.share-dialog h2 { margin: 0 0 6px; font-size: 1.2rem; }
.share-dialog .qr { display: grid; place-items: center; margin: 10px auto; width: min(260px, 70vw); background: #fff; border-radius: 8px; padding: 6px; }
.share-dialog .qr svg { width: 100%; height: auto; display: block; }
.share-nr { text-align: center; font: 700 clamp(2.4rem, 9vw, 3.4rem)/1.1 ui-monospace, Menlo, monospace;
  letter-spacing: .06em; margin: 8px 0 4px; color: var(--accent); font-variant-numeric: tabular-nums; }
.fetch-form { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; margin: 14px 0 6px; }
.fetch-form label { font-weight: 600; }
.fetch-form input { width: 11ch; font: 600 1.2rem ui-monospace, Menlo, monospace; letter-spacing: .08em; padding: 8px 10px;
  border-radius: 10px; border: 1px solid var(--line); background: var(--panel); color: var(--ink); min-height: 44px; }
.fetch-form button { min-height: 44px; padding: 0 14px; border-radius: 10px; border: 1px solid var(--accent);
  background: var(--panel); color: var(--accent); font: inherit; font-weight: 600; cursor: pointer; }
.fetch-form .fetch-msg { flex-basis: 100%; color: var(--bad); margin: 0; }
.share-row { display: flex; gap: 8px; margin: 10px 0; }
.share-row input { flex: 1; min-width: 0; font: 14px ui-monospace, Menlo, monospace; padding: 8px; border-radius: 8px;
                   border: 1px solid var(--line); background: var(--bg); color: var(--ink); }
.share-dialog button { display: inline-flex; align-items: center; gap: 6px; min-height: 44px; padding: 0 14px; border-radius: 10px;
                       border: 1px solid var(--line); background: var(--bg); cursor: pointer; font-weight: 600; }
.share-dialog button.danger { background: var(--bad); border-color: var(--bad); color: #fff; }
.share-dialog button.primary-soft { border-color: var(--accent); color: var(--accent); }
.dialog-buttons { display: flex; justify-content: flex-end; gap: 8px; margin-top: 8px; }
