/* Gestaltung nach STIHL Design System (@stihl-design-system/components).
   Farbwerte = DS_COLOR_TOKEN.light, Schriften = STIHL Contraface (font-face.min.css aus dem npm-Paket),
   Radien 0, Fokus = 2px Outline mit 2px Abstand. */

:root {
  /* Core-Farben */
  --orange: #F37A1F;
  --orange-dark: #E9640C;
  --orange-deep: #D9480F;
  --orange-light: #FEE2CD;
  --orange-mid: #F7A669;
  --grey-ultra-deep: #252525;
  --grey-deep: #444444;
  --grey-dark: #666666;
  --grey-semi-dark: #8C8C8C;
  --grey-base: #B1B1B1;
  --grey-mid: #DADADA;
  --grey-light: #EDEDED;
  --grey-ultra-light: #F8F8F8;
  --green: #749F4A;
  --green-deep: #46762D;
  --green-light: #E5F0DB;
  --red: #D43B3B;
  --red-light: #EEBCBD;
  --yellow-deep: #EE8F00;
  --yellow-light: #FDECC3;

  /* Semantische Tokens (Light Theme) */
  --bg: var(--grey-ultra-light);          /* background.secondary */
  --panel: #FFFFFF;                       /* background.primary */
  --panel-2: var(--grey-light);           /* background.tertiary */
  --line: var(--grey-mid);                /* border.tertiary */
  --line-2: var(--grey-base);             /* border.secondary */
  --line-strong: var(--grey-ultra-deep);  /* border.primary */
  --text: var(--grey-ultra-deep);         /* content.primary */
  --muted: var(--grey-dark);              /* content.secondary */
  --faint: var(--grey-semi-dark);
  --accent: var(--orange);                /* background.brand */
  --accent-hover: var(--orange-dark);
  --accent-ink: var(--grey-ultra-deep);   /* content.primaryOnBrand */
  --brand-text: var(--orange-dark);       /* content.brand */
  --ok: var(--green);
  --warn: var(--yellow-deep);
  --danger: var(--red);

  --font-regular: 'STIHL Contraface Digital Text Regular', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;
  --font-demi: 'STIHL Contraface Digital Text Demi', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;
  --font-bold: 'STIHL Contraface Digital Text Bold', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;
  --font-display: 'STIHL Contraface Digital Display Title', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;
  --mono: ui-monospace, 'SF Mono', Menlo, monospace;

  --radius: 0;
  --shadow-m: 0 2px 12px 0 rgba(0, 0, 0, .08), 0 1px 2px 0 rgba(0, 0, 0, .16);
  --shadow-l: 0 8px 48px 0 rgba(0, 0, 0, .1), 0 2px 4px 0 rgba(0, 0, 0, .04);
  --ease: cubic-bezier(0, 0, .5, 1);
  color-scheme: light;
}

* { box-sizing: border-box; }
html, body { height: 100%; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font: 16px/1.5 var(--font-regular);
  font-size-adjust: .414;
  -webkit-font-smoothing: antialiased;
}
b, strong { font-family: var(--font-bold); font-weight: normal; }
a { color: var(--grey-ultra-deep); text-decoration: underline; text-underline-offset: 3px; }
a:hover { color: var(--brand-text); }
h1, h2, h3 { margin: 0; font-weight: normal; }
.mono { font-family: var(--mono); font-variant-numeric: tabular-nums; }
.muted { color: var(--muted); }
.hidden { display: none !important; }

:focus-visible { outline: 2px solid var(--grey-ultra-deep); outline-offset: 2px; }

/* Überschriften (heading-*-uppercase) */
.heading-xl {
  font-family: var(--font-display);
  font-size: 1.875rem;
  line-height: 1.25;
  text-transform: uppercase;
  font-size-adjust: cap-height .68;
}
.heading-xl::after { content: ''; display: block; width: 24px; height: 4px; background: var(--grey-ultra-deep); margin-top: 12px; }
.heading-m { font-family: var(--font-display); font-size: 1.25rem; line-height: 1.2; text-transform: uppercase; }
/* Display Title: DS gleicht über die Versalhöhe an (heading-*-uppercase). */
.heading-m, .platform-name, .section > h3 { font-size-adjust: cap-height .68; }

/* ---------- Buttons (DS Button: filled / highlight / outline / ghost) ---------- */
button, .btn {
  font: 1rem/1.25 var(--font-bold);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  min-height: 32px;
  padding: 5px 15px;
  border-radius: 0;
  border: 1px solid var(--grey-ultra-deep);
  background: transparent;
  color: var(--grey-ultra-deep);
  cursor: pointer;
  white-space: nowrap;
  text-decoration: none !important;
  transition: background-color 100ms linear, color 100ms linear, border-color 100ms linear;
}
button:hover, .btn:hover { background: var(--grey-light); color: var(--grey-ultra-deep); }
button:disabled { color: rgba(0, 0, 0, .5); border-color: rgba(0, 0, 0, .1); background: transparent; cursor: not-allowed; }
button.primary, .btn.primary { background: var(--accent); border-color: transparent; color: var(--accent-ink); }
button.primary:hover, .btn.primary:hover { background: var(--accent-hover); }
button.primary:disabled { background: var(--grey-mid); color: rgba(0, 0, 0, .5); }
button.filled, .btn.filled { background: var(--grey-ultra-deep); border-color: transparent; color: #fff; }
button.filled:hover, .btn.filled:hover { background: var(--grey-deep); color: #fff; }
button.ghost { border-color: transparent; }
button.ghost:hover { background: rgba(0, 0, 0, .1); }
button.danger { color: var(--red); border-color: var(--red); }
button.danger:hover { background: var(--red-light); color: var(--grey-ultra-deep); }
button.ghost.danger { border-color: transparent; }
button.icon { width: 32px; padding: 0; flex: none; }
button.sm { min-height: 28px; padding: 3px 10px; font-size: .875rem; }
.btn-m { min-height: 48px !important; padding: 11px 23px !important; }

/* ---------- Inputs (DS Input small) ---------- */
input, select, textarea {
  font: 1rem/1.25 var(--font-regular);
  color: var(--text);
  background: #fff;
  border: 1px solid var(--grey-ultra-deep);
  border-radius: 0;
  height: 32px;
  padding: 0 8px;
  width: 100%;
  min-width: 0;
}
textarea { height: auto; padding: 7px 8px; resize: vertical; line-height: 1.5; }
input:hover, select:hover, textarea:hover { border-color: var(--grey-dark); }
input:focus, select:focus, textarea:focus { outline: 2px solid var(--grey-ultra-deep); outline-offset: 2px; }
input:disabled, select:disabled { border-color: rgba(0, 0, 0, .5); color: rgba(0, 0, 0, .5); background: #fff; }
input::placeholder, textarea::placeholder { color: var(--grey-dark); }
input[type=checkbox] { width: 20px; height: 20px; accent-color: var(--grey-ultra-deep); margin: 0; flex: none; }
input[type=color] { padding: 2px; width: 40px; flex: none; }
input[type=number] { font-family: var(--mono); font-size: .875rem; }

label.field { display: grid; gap: 4px; font-size: .875rem; line-height: 1.14; color: var(--text); }
label.check { display: flex; align-items: center; gap: 8px; font-size: .875rem; cursor: pointer; }
.row { display: flex; gap: 8px; align-items: center; }
.grid2 { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.grid3 { display: grid; grid-template-columns: 1fr 1fr 1fr; gap: 12px; }
.input-suffix { position: relative; display: block; }
.input-suffix input { padding-right: 28px; }
.input-suffix span { position: absolute; right: 8px; top: 50%; transform: translateY(-50%); color: var(--grey-dark); font-size: .75rem; pointer-events: none; }

/* ---------- Header (DS TopBar) ---------- */
.topbar {
  height: 64px;
  display: flex;
  align-items: center;
  gap: 16px;
  padding: 0 24px;
  border-bottom: 1px solid var(--line);
  background: var(--panel);
}
.topbar .brand { display: flex; align-items: center; gap: 16px; color: var(--text); text-decoration: none; min-width: 0; }
.topbar .brand:hover { color: var(--text); }
.logo { height: 40px; width: auto; flex: none; display: block; }
.logo path:first-of-type { fill: var(--orange); }
.logo path + path { fill: #fff; }
.platform-name { font-family: var(--font-display); font-size: 1.25rem; line-height: 1.1; text-transform: uppercase; white-space: nowrap; }
.topbar .spacer { flex: 1; }
.topbar input.title { max-width: 360px; border-color: transparent; font-family: var(--font-bold); font-size: 1rem; }
.topbar input.title:hover { border-color: var(--grey-base); }
.save-state { font-size: .75rem; color: var(--grey-dark); }

.panel { background: var(--panel); }
.section { padding: 16px 20px; border-bottom: 1px solid var(--line); display: grid; gap: 12px; }
.section > h3 { font-family: var(--font-display); font-size: 1rem; line-height: 1.5; text-transform: uppercase; display: flex; align-items: center; justify-content: space-between; }
.hint { font-size: .75rem; line-height: 1.33; color: var(--grey-dark); }
.warn-text { color: var(--grey-ultra-deep); font-size: .75rem; line-height: 1.33; background: var(--yellow-light); border-left: 4px solid var(--yellow-deep); padding: 8px 10px; display: grid; gap: 4px; }

/* Segmented Control */
.seg { display: inline-flex; background: var(--grey-light); padding: 2px; gap: 2px; }
.seg button { border: 0; min-height: 28px; padding: 3px 10px; background: transparent; color: var(--grey-ultra-deep); font-size: .875rem; }
.seg button:hover { background: rgba(0, 0, 0, .1); }
.seg button.on { background: var(--grey-ultra-deep); color: #fff; }

/* Badges */
.badge { font: .75rem/1.33 var(--font-demi); padding: 2px 8px; background: var(--grey-light); color: var(--grey-ultra-deep); white-space: nowrap; }
.badge.ok { background: var(--green-light); color: var(--green-deep); }

/* ---------- Stage ---------- */
.stage-host { position: relative; display: grid; place-items: center; overflow: hidden; min-height: 0; background: var(--grey-light); }
.stage-frame { position: relative; background: #000; box-shadow: var(--shadow-m); }
.stage { position: absolute; left: 0; top: 0; transform-origin: 0 0; --ui: 1; }
.stage-frame > video { position: absolute; inset: 0; width: 100%; height: 100%; display: block; }
.stage-overlay { position: absolute; inset: 0; }
.stage-empty { position: absolute; inset: 0; display: grid; place-items: center; color: var(--grey-dark); text-align: center; padding: 24px; }

.tbox {
  position: absolute;
  display: flex;
  flex-direction: column;
  outline: calc(2px * var(--ui)) dashed rgba(255, 255, 255, .8);
  outline-offset: 0;
}
.tbox .ttext {
  display: block;
  width: 100%;
  margin: 0;
  padding: 0;
  border: 0;
  border-radius: 0;
  background: transparent;
  overflow: hidden;
  resize: none;
  white-space: pre-wrap;
  overflow-wrap: normal;
  word-break: normal;
  height: auto;
  font-kerning: normal;
  font-size-adjust: none;
  caret-color: currentColor;
}
.tbox .ttext:focus { outline: none; }
.tbox .ttext::placeholder { color: inherit; opacity: .45; }
.tbox .tlabel {
  position: absolute;
  left: 0;
  bottom: 100%;
  margin-bottom: calc(6px * var(--ui));
  font: calc(14px * var(--ui))/1.14 var(--font-bold);
  letter-spacing: 0;
  text-transform: none;
  color: #fff;
  background: var(--grey-ultra-deep);
  padding: calc(4px * var(--ui)) calc(8px * var(--ui));
  white-space: nowrap;
  pointer-events: none;
}

/* ---------- Transport & Zeitleiste ---------- */
.transport { display: flex; align-items: center; gap: 8px; padding: 10px 20px; border-top: 1px solid var(--line); background: var(--panel); }
.transport .tc { font-family: var(--mono); font-size: 1rem; font-variant-numeric: tabular-nums; min-width: 112px; }
.transport .frame-input { width: 90px; }
.transport .dur { color: var(--grey-dark); font-family: var(--mono); font-size: .75rem; white-space: nowrap; }

.timeline { position: relative; background: var(--panel); border-top: 1px solid var(--line); user-select: none; }
.timeline .ruler { position: relative; height: 24px; border-bottom: 1px solid var(--line); cursor: pointer; }
.timeline .tick { position: absolute; top: 0; bottom: 0; border-left: 1px solid var(--grey-mid); font: 10px var(--mono); color: var(--grey-dark); padding: 5px 0 0 4px; white-space: nowrap; }
.timeline .lanes { position: relative; padding: 6px 0; cursor: pointer; overflow-y: auto; }
.timeline .lane { position: relative; height: 28px; margin: 4px 0; }
.timeline .bar {
  position: absolute;
  top: 0;
  bottom: 0;
  background: var(--orange-light);
  border: 1px solid var(--orange-mid);
  color: var(--grey-ultra-deep);
  font: .75rem/1 var(--font-demi);
  padding: 0 8px;
  display: flex;
  align-items: center;
  overflow: hidden;
  white-space: nowrap;
  min-width: 4px;
  cursor: grab;
}
.timeline .bar.selected { background: var(--orange); border-color: var(--orange); font-family: var(--font-bold); }
.timeline .bar.filled { background: var(--green-light); border-color: var(--green); }
.timeline .bar .grip { position: absolute; top: 0; bottom: 0; width: 7px; cursor: ew-resize; }
.timeline .bar .grip.l { left: 0; }
.timeline .bar .grip.r { right: 0; }
.timeline .playhead { position: absolute; top: 0; bottom: 0; width: 2px; background: var(--grey-ultra-deep); pointer-events: none; z-index: 3; margin-left: -1px; }
.timeline .playhead::before { content: ''; position: absolute; top: 0; left: -5px; border: 6px solid transparent; border-top-color: var(--grey-ultra-deep); }
.timeline-inner { position: relative; margin: 0 20px; }

/* ---------- Toast (DS Toast) ---------- */
.toast {
  position: fixed;
  left: 50%;
  bottom: 24px;
  transform: translateX(-50%) translateY(20px);
  background: var(--grey-ultra-deep);
  color: #fff;
  padding: 12px 16px;
  box-shadow: var(--shadow-l);
  opacity: 0;
  transition: opacity 250ms var(--ease), transform 250ms var(--ease);
  pointer-events: none;
  z-index: 100;
  max-width: calc(100vw - 32px);
  font-size: .875rem;
  border-left: 4px solid var(--green);
}
.toast.show { opacity: 1; transform: translateX(-50%); }
.toast.error { border-left-color: var(--red); }

/* ---------- Dialog ---------- */
.modal-bg { position: fixed; inset: 0; background: rgba(0, 0, 0, .5); display: grid; place-items: center; z-index: 50; padding: 16px; }
.modal { background: var(--panel); padding: 32px; width: 480px; max-width: 100%; display: grid; gap: 16px; box-shadow: var(--shadow-l); }
.progress { height: 4px; background: var(--grey-light); overflow: hidden; }
.progress > i { display: block; height: 100%; width: 0; background: var(--accent); transition: width .2s linear; }

.shake { animation: shake .3s; }
@keyframes shake { 25% { transform: translateX(-4px); } 75% { transform: translateX(4px); } }
@media (prefers-reduced-motion: reduce) { * { transition-duration: 0ms !important; animation: none !important; } }
