/* Gemeinsames Gerüst für alle Werkzeuge unter /tools/: Kopfzeile, Bühne, Panel, Regler.
   Gleiche Handschrift wie juliahertrich.com: Schibsted Grotesk, Schwarz/Weiss, Pillen. */
@font-face {
  font-family: 'Schibsted Grotesk Variable';
  font-style: normal; font-display: swap; font-weight: 400 900;
  src: url(fonts/schibsted-grotesk-latin-wght-normal.woff2) format('woff2-variations');
  unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+0304, U+0308, U+0329, U+2000-206F, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD;
}
@font-face {
  font-family: 'Schibsted Grotesk Variable';
  font-style: normal; font-display: swap; font-weight: 400 900;
  src: url(fonts/schibsted-grotesk-latin-ext-wght-normal.woff2) format('woff2-variations');
  unicode-range: U+0100-02BA, U+02BD-02C5, U+02C7-02CC, U+02CE-02D7, U+02DD-02FF, U+0304, U+0308, U+0329, U+1D00-1DBF, U+1E00-1E9F, U+1EF2-1EFF, U+2020, U+20A0-20AB, U+20AD-20C0, U+2113, U+2C60-2C7F, U+A720-A7FF;
}

:root {
  --t-bg: #ffffff;
  --t-fg: #000000;
  --t-fg-2: rgba(60, 60, 67, 0.6);
  --t-fg-3: rgba(60, 60, 67, 0.3);
  --t-line: rgba(60, 60, 67, 0.14);
  --t-fill: rgba(120, 120, 128, 0.12);
  --t-fill-2: rgba(120, 120, 128, 0.2);
  --t-stage: #f2f2f4;
  --t-accent: #000000;
  --t-font: 'Schibsted Grotesk Variable', 'Helvetica Neue', Arial, system-ui, sans-serif;
  --t-mono: ui-monospace, 'SF Mono', Menlo, monospace;
  --t-bar: 48px;
  --t-panel: 312px;
  color-scheme: light;
}
/* Werkzeuge mit dunkler Bühne setzen <body data-stage="dark"> */
body[data-stage='dark'] { --t-stage: #0b0b0d; }

*, *::before, *::after { box-sizing: border-box; }
html, body { height: 100%; margin: 0; }
body.tool {
  font: 400 13px/16px var(--t-font);
  color: var(--t-fg); background: var(--t-bg);
  display: grid; grid-template-rows: var(--t-bar) minmax(0, 1fr); grid-template-columns: minmax(0, 1fr);
  overflow: hidden; -webkit-font-smoothing: antialiased;
}
body.tool button, body.tool input, body.tool select { font: inherit; color: inherit; }
body.tool :focus-visible { outline: 2px solid var(--t-fg); outline-offset: 2px; }

/* ---------- Kopfzeile ---------- */
.t-bar {
  display: flex; align-items: center; gap: 12px; padding: 0 12px 0 16px;
  border-bottom: 1px solid var(--t-line); background: var(--t-bg); position: relative; z-index: 30;
}
.t-brand { display: flex; align-items: baseline; gap: 10px; min-width: 0; text-decoration: none; color: inherit; }
.t-mark { font-size: 19px; letter-spacing: -0.04em; line-height: 1; font-weight: 500; }
.t-mark sup { font-size: 0.35em; vertical-align: top; position: relative; top: -0.2em; }
.t-name { font-size: 15px; font-weight: 600; letter-spacing: -0.01em; white-space: nowrap; }
.t-tag { color: var(--t-fg-2); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.t-spacer { flex: 1; }
.t-actions { display: flex; gap: 6px; align-items: center; }

.t-btn {
  appearance: none; border: 0; cursor: pointer; border-radius: 999px;
  height: 32px; padding: 0 14px; background: var(--t-fill); white-space: nowrap;
  display: inline-flex; align-items: center; gap: 6px; transition: background 0.15s;
}
.t-btn:hover { background: var(--t-fill-2); }
.t-btn.is-primary { background: var(--t-fg); color: var(--t-bg); }
.t-btn.is-primary:hover { background: #333; }
.t-btn.is-on { background: var(--t-fg); color: var(--t-bg); }
.t-btn kbd, .t-kbd {
  font: 500 10px/1 var(--t-mono); padding: 3px 5px; border-radius: 4px;
  background: rgba(120, 120, 128, 0.16); color: inherit; opacity: 0.8;
}
.t-btn.is-primary kbd { background: rgba(255, 255, 255, 0.2); }
.t-btn.is-icon { width: 32px; padding: 0; justify-content: center; }
.t-btn.is-wide { width: 100%; justify-content: center; }
.t-btn[disabled] { opacity: 0.4; cursor: default; }

/* ---------- Arbeitsfläche ---------- */
.t-main { display: grid; grid-template-columns: 1fr var(--t-panel); min-height: 0; }
.t-stage {
  position: relative; background: var(--t-stage); min-width: 0; min-height: 0; overflow: hidden;
  display: flex; align-items: center; justify-content: center;
}
.t-stage > canvas, .t-stage > svg { max-width: calc(100% - 48px); max-height: calc(100% - 48px); display: block; }
.t-stage-info {
  position: absolute; left: 14px; bottom: 12px; font: 11px/1 var(--t-mono); color: var(--t-fg-2);
  pointer-events: none; letter-spacing: 0.02em;
}
body[data-stage='dark'] .t-stage-info { color: rgba(235, 235, 245, 0.5); }

.t-panel {
  border-left: 1px solid var(--t-line); background: var(--t-bg);
  overflow-y: auto; overscroll-behavior: contain; padding: 4px 16px 32px;
}
.t-group { padding: 14px 0 16px; border-top: 1px solid var(--t-line); display: grid; gap: 10px; }
.t-group:first-child { border-top: 0; }
.t-group-head { display: flex; justify-content: space-between; align-items: center; }
.t-label { font-size: 11px; line-height: 12px; letter-spacing: 0.4px; color: var(--t-fg-2); text-transform: none; }
.t-hint { font-size: 11px; line-height: 14px; color: var(--t-fg-2); margin: 0; }

/* Regler: Name links, Wert rechts, Spur darunter */
.t-slider { display: grid; grid-template-columns: 1fr auto; gap: 4px 8px; align-items: center; }
.t-slider .t-val { font: 11px/1 var(--t-mono); color: var(--t-fg-2); font-variant-numeric: tabular-nums; }
.t-slider input { grid-column: 1 / -1; }
input[type='range'].t-range, .t-slider input[type='range'] {
  -webkit-appearance: none; appearance: none; width: 100%; height: 20px; background: transparent; margin: 0; cursor: pointer;
}
.t-slider input[type='range']::-webkit-slider-runnable-track { height: 2px; background: var(--t-line); border-radius: 2px; }
.t-slider input[type='range']::-webkit-slider-thumb {
  -webkit-appearance: none; width: 14px; height: 14px; border-radius: 50%; background: var(--t-fg); margin-top: -6px; border: 0;
}
.t-slider input[type='range']::-moz-range-track { height: 2px; background: var(--t-line); }
.t-slider input[type='range']::-moz-range-thumb { width: 14px; height: 14px; border-radius: 50%; background: var(--t-fg); border: 0; }

/* Segmente: mehrere Optionen, eine aktiv */
.t-seg { display: flex; padding: 2px; border-radius: 999px; background: var(--t-fill); gap: 2px; flex-wrap: wrap; }
.t-seg button {
  flex: 1; appearance: none; border: 0; background: transparent; border-radius: 999px; height: 28px; padding: 0 8px;
  cursor: pointer; white-space: nowrap; color: var(--t-fg-2);
}
.t-seg button:hover { color: var(--t-fg); }
.t-seg button.is-on { background: var(--t-bg); color: var(--t-fg); box-shadow: 0 1px 3px rgba(0, 0, 0, 0.12); }

.t-select {
  appearance: none; width: 100%; height: 32px; border-radius: 999px; border: 0; background: var(--t-fill); padding: 0 32px 0 14px;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='10' height='6'%3E%3Cpath d='M1 1l4 4 4-4' fill='none' stroke='%23000' stroke-width='1.4'/%3E%3C/svg%3E");
  background-repeat: no-repeat; background-position: right 14px center; cursor: pointer;
}
.t-toggle { display: flex; align-items: center; justify-content: space-between; gap: 8px; cursor: pointer; min-height: 24px; }
.t-toggle input { appearance: none; width: 30px; height: 18px; border-radius: 999px; background: var(--t-fill-2); position: relative; cursor: pointer; flex: none; transition: background 0.15s; margin: 0; }
.t-toggle input::after { content: ''; position: absolute; top: 2px; left: 2px; width: 14px; height: 14px; border-radius: 50%; background: #fff; box-shadow: 0 1px 2px rgba(0,0,0,.2); transition: transform 0.15s; }
.t-toggle input:checked { background: var(--t-fg); }
.t-toggle input:checked::after { transform: translateX(12px); }

.t-color { display: flex; align-items: center; justify-content: space-between; gap: 8px; }
.t-color input[type='color'] { appearance: none; -webkit-appearance: none; width: 28px; height: 28px; border: 1px solid var(--t-line); border-radius: 50%; padding: 0; background: none; cursor: pointer; }
.t-color input[type='color']::-webkit-color-swatch-wrapper { padding: 0; }
.t-color input[type='color']::-webkit-color-swatch { border: 0; border-radius: 50%; }
.t-color input[type='color']::-moz-color-swatch { border: 0; border-radius: 50%; }

.t-swatches { display: grid; grid-template-columns: repeat(auto-fill, minmax(64px, 1fr)); gap: 6px; }
.t-swatch {
  appearance: none; border: 1px solid var(--t-line); background: none; border-radius: 8px; padding: 4px; cursor: pointer; display: grid; gap: 4px; text-align: left;
}
.t-swatch .t-sw { display: flex; height: 18px; border-radius: 4px; overflow: hidden; }
.t-swatch .t-sw span { flex: 1; }
.t-swatch .t-sw-name { font-size: 10px; line-height: 12px; color: var(--t-fg-2); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.t-swatch.is-on { border-color: var(--t-fg); box-shadow: inset 0 0 0 1px var(--t-fg); }

.t-row { display: flex; gap: 6px; flex-wrap: wrap; }
.t-row > .t-btn { flex: 1; justify-content: center; }

/* ---------- Export-Menü ---------- */
.t-menu {
  position: absolute; top: calc(var(--t-bar) - 4px); right: 12px; z-index: 40; min-width: 240px;
  background: var(--t-bg); border: 1px solid var(--t-line); border-radius: 14px; padding: 6px;
  box-shadow: 0 12px 40px rgba(0, 0, 0, 0.14); display: none;
}
.t-menu.is-open { display: grid; }
.t-menu button {
  appearance: none; border: 0; background: none; text-align: left; padding: 9px 10px; border-radius: 9px; cursor: pointer;
  display: grid; grid-template-columns: 1fr auto; gap: 2px 12px; align-items: center;
}
.t-menu button:hover { background: var(--t-fill); }
.t-menu .t-m-label { font-weight: 500; }
.t-menu .t-m-hint { grid-column: 1; font-size: 11px; color: var(--t-fg-2); }
.t-menu kbd { grid-row: 1 / span 2; grid-column: 2; }

/* ---------- Info-Fenster ---------- */
.t-info {
  border: 0; padding: 0; border-radius: 18px; width: min(560px, calc(100vw - 32px)); max-height: calc(100vh - 64px);
  color: var(--t-fg); background: var(--t-bg); box-shadow: 0 30px 80px rgba(0, 0, 0, 0.25);
}
.t-info::backdrop { background: rgba(0, 0, 0, 0.35); backdrop-filter: blur(2px); }
.t-info-body { padding: 28px 28px 24px; display: grid; gap: 18px; overflow-y: auto; max-height: calc(100vh - 64px); }
.t-info h2 { font-size: 32px; line-height: 1; letter-spacing: -0.03em; font-weight: 500; margin: 0; }
.t-info p { margin: 0; font-size: 15px; line-height: 20px; }
.t-info .t-lead { font-size: 17px; line-height: 22px; }
.t-info ol { margin: 0; padding-left: 18px; display: grid; gap: 4px; font-size: 14px; line-height: 18px; }
.t-keys { display: grid; grid-template-columns: 1fr 1fr; column-gap: 24px; font-size: 13px; }
.t-key { display: flex; align-items: center; gap: 10px; padding: 5px 0; border-top: 1px solid var(--t-line); }
.t-key .t-kbd { min-width: 22px; text-align: center; }
@media (max-width: 480px) { .t-keys { grid-template-columns: 1fr; } }
.t-info-foot { display: flex; justify-content: space-between; align-items: center; gap: 12px; padding-top: 6px; border-top: 1px solid var(--t-line); font-size: 12px; color: var(--t-fg-2); }
.t-info-foot a { color: var(--t-fg); }

/* ---------- Ablegen, Meldungen ---------- */
.t-drop {
  position: fixed; inset: 0; z-index: 50; display: none; place-items: center; pointer-events: none;
  background: rgba(0, 0, 0, 0.55); color: #fff; font-size: 28px; letter-spacing: -0.02em;
}
.t-drop.is-on { display: grid; }
.t-drop span { border: 2px dashed rgba(255, 255, 255, 0.7); border-radius: 24px; padding: 48px 64px; }
.t-toast {
  position: fixed; left: 50%; bottom: 24px; transform: translate(-50%, 20px); z-index: 60;
  background: var(--t-fg); color: var(--t-bg); border-radius: 999px; padding: 10px 18px; font-size: 13px;
  opacity: 0; transition: opacity 0.2s, transform 0.2s; pointer-events: none;
}
.t-toast.is-on { opacity: 1; transform: translate(-50%, 0); }
.t-rec { display: none; width: 8px; height: 8px; border-radius: 50%; background: #ff3b30; animation: t-blink 1s infinite; }
.t-rec.is-on { display: inline-block; }
@keyframes t-blink { 50% { opacity: 0.2; } }

/* Panel-Schalter nur auf schmalen Bildschirmen */
.t-panel-toggle { display: none; }

@media (max-width: 820px) {
  :root { --t-panel: 100%; }
  .t-tag { display: none; }
  .t-btn .t-lbl-long, .t-btn kbd { display: none; }
  .t-bar { gap: 6px; padding: 0 8px 0 12px; }
  .t-actions { gap: 4px; }
  .t-btn { padding: 0 11px; }
  .t-btn.is-icon { padding: 0; }
  .t-stage > canvas, .t-stage > svg { max-width: calc(100% - 24px); max-height: calc(100% - 24px); }
  .t-main { grid-template-columns: 1fr; grid-template-rows: 1fr auto; }
  .t-panel { border-left: 0; border-top: 1px solid var(--t-line); max-height: 46vh; display: none; }
  body.t-panel-open .t-panel { display: block; }
  .t-panel-toggle { display: inline-flex; }
}
@media (max-width: 480px) {
  .t-name { display: none; }
}
@media (prefers-reduced-motion: reduce) {
  * { transition: none !important; animation: none !important; }
}
