/* ==========================================================================
   Google Flutter & Material 3 (M3) Design System for 360° Mockup Studio
   ========================================================================== */

:root {
  /* febi & bilstein group Brand Tokens */
  --pf-febi-red: #e20613;
  --pf-febi-red-hover: linear-gradient(83deg, #95040c 0.41%, #e20613 62.78%);
  --pf-febi-red-active: #7c030a;
  --pf-burgundy: #730842;
  --pf-slate-dark: #2c3539;
  --pf-slate-medium: #5e6a70;
  --pf-slate-light: #616d73;

  /* Studio High-Contrast Canvas Surfaces */
  --md-sys-color-background: #1e2225;
  --md-sys-color-on-background: #f4f5f6;
  --md-sys-color-surface: #24292d;
  --md-sys-color-surface-dim: #1a1e20;
  --md-sys-color-surface-container: #2c3539;
  --md-sys-color-surface-container-high: #384247;
  --md-sys-color-surface-container-highest: #455057;
  --md-sys-color-on-surface: #ffffff;
  --md-sys-color-on-surface-variant: #dfe1e2;
  --md-sys-color-outline: #5e6a70;
  --md-sys-color-outline-variant: #3e484d;
  
  --md-sys-color-primary: #e20613;
  --md-sys-color-on-primary: #ffffff;
  --md-sys-color-primary-container: #95040c;
  --md-sys-color-on-primary-container: #ffffff;
  
  --md-sys-color-secondary-container: #730842;
  --md-sys-color-on-secondary-container: #ffffff;

  --md-sys-color-tertiary: #730842;
  --md-sys-color-success: #35a833;
  --md-sys-color-error: #e20613;

  /* Corner Handles (M3 Harmonized) */
  --corner-tl: #ff5449; /* Red-Orange */
  --corner-tr: #6dd58c; /* Mint Green */
  --corner-bl: #a8c7fa; /* Google Blue */
  --corner-br: #ffd066; /* Gold Amber */
  --corner-tc: #e879f9; /* Violet-Magenta (Top Center) */
  --corner-bc: #38bdf8; /* Sky Blue (Bottom Center) */

  /* M3 Shape / Radii */
  --md-shape-xs: 4px;
  --md-shape-sm: 8px;
  --md-shape-md: 12px;
  --md-shape-lg: 16px;
  --md-shape-xl: 28px;
  --md-shape-full: 9999px;

  /* Elevations */
  --md-elevation-1: 0 1px 3px 1px rgba(0, 0, 0, 0.25);
  --md-elevation-2: 0 2px 6px 2px rgba(0, 0, 0, 0.35);
  --md-elevation-3: 0 4px 12px 3px rgba(0, 0, 0, 0.45);
}

* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
  -webkit-tap-highlight-color: transparent;
  user-select: none;
}

body.m3-dark, body.pf-editor-body, body.pf-app-body {
  font-family: 'Roboto', -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  background-color: var(--pf-bg-body, #f4f6f8);
  color: var(--pf-slate-dark, #2c3539);
  height: 100vh;
  height: 100dvh;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  position: relative;
}

/* --------------------------------------------------------------------------
   febi partsfinder Top App Bar (#730842)
   -------------------------------------------------------------------------- */
.m3-app-bar {
  background-color: var(--pf-burgundy) !important;
  border-bottom: 2px solid var(--pf-febi-red);
  height: 56px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 14px;
  z-index: 3000;
  flex-shrink: 0;
  box-shadow: 0 2px 6px rgba(0, 0, 0, 0.2);
}

.m3-app-bar-start {
  display: flex;
  align-items: center;
  gap: 12px;
}

#btnToggleDrawer, .btn-toggle-drawer {
  background-color: var(--pf-burgundy-dark);
  color: #ffffff;
  border-radius: 20px;
  height: 34px;
  width: auto;
  padding: 0 14px;
  gap: 7px;
  font-size: 0.82rem;
  font-weight: 600;
  border: 1px solid rgba(255, 255, 255, 0.3);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: all 0.15s ease;
}
#btnToggleDrawer:hover, .btn-toggle-drawer:hover {
  background-color: #430426;
  border-color: rgba(255, 255, 255, 0.6);
}

.m3-title-wrap {
  display: flex;
  flex-direction: column;
}

.m3-app-title {
  font-size: 1.15rem;
  font-weight: 300;
  letter-spacing: -0.3px;
  color: #ffffff;
  display: flex;
  align-items: center;
  gap: 8px;
}
.m3-app-title strong {
  font-weight: 700;
}

.m3-app-subtitle {
  font-size: 0.72rem;
  color: rgba(255, 255, 255, 0.8);
}

.m3-app-bar-end {
  display: flex;
  align-items: center;
  gap: 8px;
}

/* Stepper Pill in App Bar */
.m3-view-stepper {
  display: flex;
  align-items: center;
  background-color: rgba(0, 0, 0, 0.22);
  border: 1px solid rgba(255, 255, 255, 0.25);
  border-radius: var(--pf-radius-pill);
  padding: 2px 6px;
}

.m3-stepper-btn {
  width: 32px;
  height: 32px;
  color: #ffffff;
}
.m3-stepper-btn:hover {
  background-color: rgba(255, 255, 255, 0.15);
}

.m3-view-pill {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 4px 12px;
  cursor: pointer;
  font-size: 0.82rem;
  font-weight: 700;
  color: #ffffff;
}

.m3-view-num {
  font-family: monospace;
  font-weight: 700;
  color: var(--md-sys-color-primary);
}

.m3-badge {
  padding: 2px 6px;
  border-radius: var(--md-shape-full);
  font-size: 0.65rem;
  font-weight: 700;
  letter-spacing: 0.5px;
}

.m3-badge.vs {
  background: rgba(109, 213, 140, 0.2);
  color: var(--md-sys-color-success);
}

.m3-badge.rs {
  background: rgba(115, 8, 66, 0.25);
  color: var(--md-sys-color-primary);
}

/* --------------------------------------------------------------------------
   M3 Buttons & Chips
   -------------------------------------------------------------------------- */
.m3-icon-btn {
  background: none;
  border: none;
  color: var(--md-sys-color-on-surface);
  width: 40px;
  height: 40px;
  border-radius: var(--md-shape-full);
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: background 0.15s ease;
}

.m3-icon-btn:hover {
  background-color: rgba(255, 255, 255, 0.08);
}

.m3-icon-btn:active {
  background-color: rgba(255, 255, 255, 0.14);
}

.m3-btn-filled {
  background-color: var(--md-sys-color-primary);
  color: var(--md-sys-color-on-primary);
  border: none;
  border-radius: var(--md-shape-full);
  padding: 8px 16px;
  font-size: 0.82rem;
  font-weight: 500;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  transition: all 0.15s ease;
  box-shadow: var(--md-elevation-1);
}

.m3-btn-filled:hover {
  filter: brightness(1.1);
  box-shadow: var(--md-elevation-2);
}

.m3-btn-save {
  background-color: var(--md-sys-color-success);
  color: #003919;
}

.m3-btn-tonal {
  background-color: var(--md-sys-color-surface-container-high);
  color: var(--md-sys-color-on-surface);
  border: 1px solid var(--md-sys-color-outline-variant);
  border-radius: var(--md-shape-full);
  padding: 7px 14px;
  font-size: 0.8rem;
  font-weight: 500;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  transition: all 0.15s ease;
}

.m3-btn-tonal:hover {
  background-color: var(--md-sys-color-surface-container-highest);
}

.m3-btn-outlined {
  background: transparent;
  color: var(--md-sys-color-primary);
  border: 1px solid var(--md-sys-color-outline);
  border-radius: var(--md-shape-full);
  padding: 7px 14px;
  font-size: 0.8rem;
  font-weight: 500;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  transition: all 0.15s ease;
}

.m3-btn-outlined:hover {
  background: rgba(226, 6, 19, 0.08);
  border-color: var(--md-sys-color-primary);
}

.m3-btn-text {
  background: none;
  border: none;
  color: var(--md-sys-color-primary);
  font-size: 0.8rem;
  font-weight: 500;
  cursor: pointer;
  padding: 4px 8px;
}

/* --------------------------------------------------------------------------
   Full-Screen Canvas Stage
   -------------------------------------------------------------------------- */
.m3-canvas-stage {
  flex: 1;
  position: relative;
  overflow: hidden;
  background-color: #f4f6f8;
  background-image: radial-gradient(rgba(0, 0, 0, 0.07) 1px, transparent 1px);
  background-size: 24px 24px;
  display: flex;
  align-items: center;
  justify-content: center;
}

#editorCanvas {
  position: absolute;
  top: 0;
  left: 0;
  cursor: crosshair;
  touch-action: none;
}

/* --------------------------------------------------------------------------
   Floating Magnifier Loupe (Corner-Zoom)
   -------------------------------------------------------------------------- */
.m3-magnifier-loupe {
  position: absolute;
  top: 14px;
  right: 14px;
  width: 170px;
  height: 170px;
  border-radius: 50%;
  border: 3px solid #ffffff;
  box-shadow: 0 10px 30px rgba(0, 0, 0, 0.7), 0 0 0 1px rgba(0,0,0,0.5);
  overflow: hidden;
  background: #111;
  pointer-events: none;
  z-index: 25;
  display: none;
  transform: scale(0.9);
  transition: transform 0.15s cubic-bezier(0.16, 1, 0.3, 1), opacity 0.15s ease;
  opacity: 0;
}

.m3-magnifier-loupe.active {
  display: block;
  opacity: 1;
  transform: scale(1);
}

#magnifierCanvas {
  width: 100%;
  height: 100%;
}

.m3-loupe-reticle {
  display: none;
}

.m3-loupe-reticle::before,
.m3-loupe-reticle::after {
  content: "";
  position: absolute;
  background: #00ff7f;
  box-shadow: 0 0 3px #000;
}

.m3-loupe-reticle::before {
  top: 11px;
  left: 0;
  width: 24px;
  height: 2px;
}

.m3-loupe-reticle::after {
  top: 0;
  left: 11px;
  width: 2px;
  height: 24px;
}

.m3-loupe-tag {
  position: absolute;
  top: 8px;
  left: 50%;
  transform: translateX(-50%);
  background: rgba(0, 0, 0, 0.75);
  color: #fff;
  font-size: 0.72rem;
  font-weight: 700;
  padding: 2px 8px;
  border-radius: 10px;
  letter-spacing: 0.5px;
}

.m3-loupe-coords {
  position: absolute;
  bottom: 8px;
  left: 50%;
  transform: translateX(-50%);
  background: rgba(0, 0, 0, 0.75);
  color: #a8c7fa;
  font-size: 0.65rem;
  font-family: monospace;
  padding: 2px 6px;
  border-radius: 6px;
  white-space: nowrap;
}

/* --------------------------------------------------------------------------
   Floating Editor Control Cluster: Gebinde & Dosen Navigation + Koordinaten
   -------------------------------------------------------------------------- */
.editor-control-cluster {
  position: absolute;
  top: 12px;
  left: 50%;
  transform: translateX(-50%);
  z-index: 20;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
  pointer-events: none;
  max-width: 95vw;
}

.editor-control-cluster > * {
  pointer-events: auto;
}

/* Obere Leiste: Gebinde & 360°-Dosen Stepper */
.editor-nav-bar {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  background: rgba(255, 255, 255, 0.95);
  backdrop-filter: blur(12px);
  border: 1px solid var(--pf-border-light, #d0d7de);
  border-radius: 24px;
  padding: 3px 8px;
  box-shadow: 0 4px 16px rgba(0, 0, 0, 0.08);
}

.editor-gebinde-btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  background: transparent;
  border: none;
  color: var(--pf-slate-dark, #2c3539);
  font-size: 0.8rem;
  font-weight: 700;
  padding: 4px 10px;
  border-radius: 16px;
  cursor: pointer;
  transition: all 0.15s ease;
  max-width: 190px;
}
.editor-gebinde-btn:hover {
  background: rgba(0, 0, 0, 0.06);
  color: var(--pf-burgundy, #730842);
}
.editor-gebinde-btn span {
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.editor-nav-divider {
  width: 1px;
  height: 20px;
  background: #d0d7de;
  margin: 0 2px;
}

.editor-dose-stepper {
  display: inline-flex;
  align-items: center;
  gap: 2px;
}

.editor-step-btn {
  background: transparent;
  border: none;
  width: 28px;
  height: 28px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--pf-slate-medium, #5e6a70);
  cursor: pointer;
  transition: all 0.15s ease;
}
.editor-step-btn:hover {
  background: rgba(0, 0, 0, 0.06);
  color: var(--pf-burgundy, #730842);
}

.editor-view-pill {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 3px 9px;
  border-radius: 14px;
  background: #f4f6f8;
  cursor: pointer;
  font-size: 0.8rem;
  font-weight: 700;
  color: var(--pf-slate-dark, #2c3539);
  transition: background 0.15s ease;
}
.editor-view-pill:hover {
  background: #e8ecf0;
}
.editor-view-num {
  font-weight: 900;
  color: var(--pf-slate-dark, #2c3539);
}
.editor-view-angle {
  color: var(--pf-slate-medium, #5e6a70);
  font-size: 0.76rem;
}
.editor-view-badge {
  font-size: 0.65rem;
  font-weight: 800;
  padding: 2px 5px;
  border-radius: 6px;
  text-transform: uppercase;
}
.editor-view-badge.vs {
  background: var(--pf-febi-red, #e20613);
  color: #ffffff;
}
.editor-view-badge.rs {
  background: var(--pf-burgundy, #730842);
  color: #ffffff;
}

/* --------------------------------------------------------------------------
   Corner Zoom Segmented Button Bar (Unterer Teil: Fit, TL, TR, BL, BR)
   -------------------------------------------------------------------------- */
.m3-corner-bar {
  background: rgba(255, 255, 255, 0.95);
  backdrop-filter: blur(12px);
  border: 1px solid var(--pf-border-light, #d0d7de);
  border-radius: var(--md-shape-full);
  padding: 3px 4px;
  box-shadow: 0 4px 16px rgba(0, 0, 0, 0.08);
}

.m3-segmented-button {
  display: flex;
  align-items: center;
  gap: 2px;
}

.m3-seg-item {
  background: transparent;
  border: none;
  color: #5e6a70;
  font-size: 0.74rem;
  font-weight: 600;
  padding: 5px 11px;
  border-radius: 14px;
  cursor: pointer;
  display: flex;
  align-items: center;
  gap: 6px;
  transition: all 0.15s ease;
}

.m3-seg-item:hover {
  background: rgba(0, 0, 0, 0.05);
  color: #2c3539;
}

.m3-seg-item.active {
  background-color: #ffffff;
  color: var(--pf-burgundy, #730842);
  font-weight: 700;
  box-shadow: 0 2px 6px rgba(0, 0, 0, 0.12);
}

.m3-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
}

.tl-dot { background: var(--corner-tl); }
.tr-dot { background: var(--corner-tr); }
.bl-dot { background: var(--corner-bl); }
.br-dot { background: var(--corner-br); }
.tc-dot { background: var(--corner-tc); }
.bc-dot { background: var(--corner-bc); }

.tc-bc-toggle-btn {
  border-left: 1px solid #d0d7de;
  margin-left: 2px;
  border-radius: 14px;
  color: #5e6a70;
}
.tc-bc-toggle-btn.is-enabled {
  background: rgba(232, 121, 249, 0.16);
  color: #86198f;
  font-weight: 700;
}

/* --------------------------------------------------------------------------
   Floating Nudge D-Pad (Phone Micro-Adjustments)
   -------------------------------------------------------------------------- */
.m3-nudge-pad {
  position: absolute;
  bottom: calc(28px + env(safe-area-inset-bottom, 0px));
  left: 20px;
  width: 104px;
  height: 104px;
  background: rgba(255, 255, 255, 0.96);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  border: 1px solid var(--pf-border-light, #d0d7de);
  border-radius: 50%;
  box-shadow: 0 4px 18px rgba(0, 0, 0, 0.12);
  z-index: 20;
  display: grid;
  grid-template-areas:
    ". up ."
    "left center right"
    ". down .";
  grid-template-columns: 1fr 1fr 1fr;
  grid-template-rows: 1fr 1fr 1fr;
  place-items: center;
  overflow: hidden;
}

.nudge-btn {
  background: none;
  border: none;
  color: var(--pf-slate-medium, #5e6a70);
  width: 100%;
  height: 100%;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 0;
  margin: 0;
  transition: all 0.12s ease;
}

.nudge-btn svg {
  display: block;
  pointer-events: none;
}

.nudge-btn:hover {
  background: rgba(115, 8, 66, 0.08);
  color: var(--pf-burgundy, #730842);
}

.nudge-btn:active {
  background: rgba(115, 8, 66, 0.2);
  color: var(--pf-burgundy, #730842);
  transform: scale(0.92);
}

.nudge-up { grid-area: up; }
.nudge-down { grid-area: down; }
.nudge-left { grid-area: left; }
.nudge-right { grid-area: right; }

.nudge-center {
  grid-area: center;
  font-size: 0.76rem;
  font-weight: 800;
  color: var(--pf-burgundy, #730842);
  pointer-events: none;
  display: flex;
  align-items: center;
  justify-content: center;
  width: 100%;
  height: 100%;
  line-height: 1;
}

/* --------------------------------------------------------------------------
   Floating HUD (Zoom & State)
   -------------------------------------------------------------------------- */
.m3-floating-hud {
  position: absolute;
  bottom: calc(28px + env(safe-area-inset-bottom, 0px));
  right: 88px;
  background: rgba(255, 255, 255, 0.95);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  border: 1px solid var(--pf-border-light, #d0d7de);
  border-radius: var(--md-shape-full);
  padding: 4px 8px;
  display: flex;
  align-items: center;
  gap: 4px;
  box-shadow: 0 4px 16px rgba(0, 0, 0, 0.08);
  z-index: 20;
}

.m3-hud-btn {
  background: none;
  border: none;
  color: var(--pf-slate-dark, #2c3539);
  width: 32px;
  height: 32px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: background 0.12s ease;
}

.m3-hud-btn:hover {
  background: rgba(0, 0, 0, 0.06);
}

.m3-hud-val {
  font-size: 0.78rem;
  font-family: monospace;
  font-weight: 700;
  color: var(--pf-slate-dark, #2c3539);
  min-width: 42px;
  text-align: center;
}

/* Mobile Quick-Save FAB (#fabSave) */
.m3-fab {
  position: absolute;
  bottom: calc(28px + env(safe-area-inset-bottom, 0px));
  right: 20px;
  width: 54px;
  height: 54px;
  border-radius: 50%;
  border: none;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  box-shadow: 0 4px 16px rgba(0, 0, 0, 0.18);
  z-index: 20;
  transition: transform 0.15s ease, background-color 0.2s ease, box-shadow 0.2s ease;
}

/* Wenn entsperrt (Bearbeitungsmodus aktiv): febi Lila (#730842) mit Leuchteffekt */
.m3-fab.is-unlocked, .m3-fab.is-dirty {
  background-color: var(--pf-burgundy, #730842) !important;
  color: #ffffff !important;
  border: 1px solid rgba(255, 255, 255, 0.45) !important;
  box-shadow: 0 6px 20px rgba(115, 8, 66, 0.6) !important;
}

/* Wenn gesperrt (Standard & geschützt): Neutral Slate Dunkelgrau */
.m3-fab.is-locked, .m3-fab.is-clean {
  background-color: #47545b !important;
  color: #ffffff !important;
  border: 1px solid rgba(255, 255, 255, 0.25) !important;
  box-shadow: 0 2px 10px rgba(0, 0, 0, 0.25) !important;
  opacity: 0.95;
}

.m3-fab:hover {
  transform: scale(1.05);
}

.m3-fab:active {
  transform: scale(0.95);
}

/* Nudge Pad wenn gesperrt */
.m3-nudge-pad.is-locked {
  opacity: 0.45;
  filter: grayscale(0.5);
}
.m3-nudge-pad.is-locked .nudge-btn {
  cursor: not-allowed;
}

/* Auto-Save Indikator Punkt im Top-Button */
.save-indicator-dot {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background-color: #6dd58c;
  display: inline-block;
  opacity: 0;
  transition: opacity 0.3s ease, transform 0.3s ease;
  margin-left: 2px;
}
.save-indicator-dot.saving {
  opacity: 1;
  background-color: #ffd066;
  animation: pulse-dot 0.8s infinite alternate;
}
.save-indicator-dot.saved {
  opacity: 1;
  background-color: #6dd58c;
  transform: scale(1.3);
}
@keyframes pulse-dot {
  from { transform: scale(0.8); opacity: 0.5; }
  to { transform: scale(1.2); opacity: 1; }
}

/* --------------------------------------------------------------------------
   partsfinder Drawer / Left Navigation Panel
   -------------------------------------------------------------------------- */
.m3-drawer {
  position: fixed;
  top: 56px;
  right: 0;
  bottom: 0;
  width: 360px;
  max-width: 90vw;
  background-color: var(--pf-surface, #ffffff);
  border-left: 1px solid var(--pf-border-light);
  z-index: 1500;
  display: flex;
  flex-direction: column;
  transform: translateX(100%);
  visibility: hidden;
  pointer-events: none;
  transition: transform 0.25s cubic-bezier(0.16, 1, 0.3, 1), visibility 0.25s ease;
  box-shadow: -4px 0 24px rgba(0, 0, 0, 0.25);
  color: var(--pf-slate-dark);
}

.m3-drawer.open {
  transform: translateX(0);
  visibility: visible;
  pointer-events: auto;
}

.m3-drawer-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.6);
  backdrop-filter: blur(4px);
  z-index: 45;
  display: none;
  opacity: 0;
  transition: opacity 0.2s ease;
}

.m3-drawer-backdrop.open {
  display: block;
  opacity: 1;
}

.m3-drawer-header {
  padding: 14px 16px;
  border-bottom: 1px solid var(--pf-border-light);
  background-color: #ffffff;
  display: flex;
  align-items: center;
  justify-content: space-between;
  color: var(--pf-slate-dark);
}

.m3-drawer-title {
  font-size: 0.95rem;
  font-weight: 700;
  color: var(--pf-slate-dark);
}

.m3-drawer-content {
  flex: 1;
  overflow-y: auto;
  padding: 12px;
  display: flex;
  flex-direction: column;
  gap: 12px;
}

/* Cards inside Drawer (partsfinder Clean White Cards) */
.m3-card {
  background-color: #ffffff;
  border: 1px solid var(--pf-border-light);
  border-radius: var(--pf-radius-xs);
  padding: 14px;
  color: var(--pf-slate-dark);
  box-shadow: var(--pf-shadow-card);
}

.m3-card-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  font-size: 0.85rem;
  font-weight: 700;
  margin-bottom: 10px;
  color: var(--pf-slate-dark);
}

.m3-caption {
  font-size: 0.72rem;
  color: var(--pf-slate-medium);
}

.m3-form-field {
  margin-bottom: 10px;
}

.m3-label {
  display: block;
  font-size: 0.74rem;
  color: var(--pf-slate-medium);
  margin-bottom: 4px;
  font-weight: 600;
}

.m3-select {
  width: 100%;
  background-color: #ffffff;
  color: var(--pf-slate-dark);
  border: 1px solid var(--pf-border-medium);
  border-radius: var(--pf-radius-xs);
  padding: 8px 10px;
  font-size: 0.82rem;
  outline: none;
}

.m3-select:focus {
  border-color: var(--pf-burgundy);
}

.m3-filter-tabs {
  display: flex;
  gap: 4px;
  margin-bottom: 8px;
}

.m3-filter-chip {
  flex: 1;
  background: var(--pf-surface-zebra);
  border: 1px solid var(--pf-border-light);
  border-radius: var(--pf-radius-pill);
  color: var(--pf-slate-medium);
  padding: 5px 0;
  font-size: 0.72rem;
  font-weight: 700;
  cursor: pointer;
  transition: all 0.15s ease;
}

.m3-filter-chip.active {
  background: var(--pf-burgundy);
  border-color: var(--pf-burgundy);
  color: #ffffff;
}

.m3-views-listbox {
  background: #ffffff;
  border: 1px solid var(--pf-border-light);
  border-radius: var(--pf-radius-xs);
  max-height: 200px;
  overflow-y: auto;
}

.m3-view-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 6px 10px;
  font-size: 0.78rem;
  font-family: monospace;
  cursor: pointer;
  border-bottom: 1px solid var(--pf-border-light);
  color: var(--pf-slate-dark);
}

.m3-view-row:hover {
  background: var(--pf-surface-hover);
}

.m3-view-row.active {
  background: rgba(115, 8, 66, 0.08);
  color: var(--pf-burgundy);
  border-left: 3px solid var(--pf-febi-red);
  font-weight: 700;
}

.m3-slider {
  width: 100%;
  accent-color: var(--md-sys-color-primary);
}

/* Coords micro-inputs */
.m3-coords-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
}

.m3-coord-box {
  background: var(--md-sys-color-surface-container-highest);
  border-radius: var(--md-shape-sm);
  padding: 6px;
  display: flex;
  align-items: center;
  gap: 4px;
}

.m3-coord-box.tl { border-left: 3px solid var(--corner-tl); }
.m3-coord-box.tr { border-left: 3px solid var(--corner-tr); }
.m3-coord-box.bl { border-left: 3px solid var(--corner-bl); }
.m3-coord-box.br { border-left: 3px solid var(--corner-br); }
.m3-coord-box.tc { border-left: 3px solid var(--corner-tc); }
.m3-coord-box.bc { border-left: 3px solid var(--corner-bc); }

.m3-coord-tag {
  font-size: 0.65rem;
  font-weight: 700;
  width: 20px;
}

.m3-coord-inp {
  width: 100%;
  background: none;
  border: none;
  color: #fff;
  font-size: 0.75rem;
  font-family: monospace;
  outline: none;
}

/* --------------------------------------------------------------------------
   M3 Modals (360 Player, Batch)
   -------------------------------------------------------------------------- */
.m3-modal-overlay {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.7);
  backdrop-filter: blur(6px);
  z-index: 100;
  align-items: center;
  justify-content: center;
  padding: 16px;
}

.m3-modal-overlay.active {
  display: flex;
}

.m3-modal-dialog {
  background: var(--md-sys-color-surface-container-high);
  border-radius: var(--md-shape-xl);
  width: 100%;
  max-width: 620px;
  overflow: hidden;
  box-shadow: var(--md-elevation-3);
  animation: m3DialogEnter 0.2s cubic-bezier(0.16, 1, 0.3, 1);
}

@keyframes m3DialogEnter {
  from { opacity: 0; transform: scale(0.92); }
  to { opacity: 1; transform: scale(1); }
}

.m3-modal-header {
  padding: 16px 20px;
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.m3-modal-title {
  font-size: 1.05rem;
  font-weight: 500;
}

.m3-modal-body {
  padding: 16px 20px;
}

.m3-modal-footer {
  padding: 14px 20px;
  display: flex;
  justify-content: flex-end;
  gap: 8px;
}

.player-stage {
  width: 100%;
  height: 380px;
  background: #000;
  border-radius: var(--md-shape-md);
  display: flex;
  align-items: center;
  justify-content: center;
  position: relative;
  overflow: hidden;
  cursor: grab;
}

.player-stage:active {
  cursor: grabbing;
}

.player-stage img {
  max-width: 100%;
  max-height: 100%;
  object-fit: contain;
}

.player-loading {
  position: absolute;
  color: #fff;
  background: rgba(0, 0, 0, 0.65);
  padding: 8px 16px;
  border-radius: 8px;
  font-size: 0.85rem;
  display: none;
}

.player-controls {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-top: 14px;
}

.player-frame-label {
  font-family: monospace;
  font-size: 0.85rem;
  min-width: 90px;
  text-align: right;
}

/* Desktop layout adaptations */
@media (min-width: 960px) {
  #btnToggleDrawer {
    display: inline-flex !important;
  }
  body.m3-dark {
    flex-direction: column;
  }
  .m3-canvas-stage {
    display: flex;
  }
  .app-layout-horizontal {
    display: flex;
    flex: 1;
    overflow: hidden;
  }
}

@media (max-width: 600px) {
  .desktop-only {
    display: none !important;
  }

  /* Header Title & Action Buttons */
  .m3-app-bar, .pf-header {
    padding: 0 10px 0 0 !important;
  }
  .pf-header-brand {
    padding-left: 8px !important;
    gap: 4px !important;
  }
  .pf-header-logo-text {
    font-size: 16px !important;
  }
  .pf-header-app-tag {
    display: none !important;
  }
  .save-btn-text {
    display: none !important;
  }
  .btn-save-coord, .btn-save-burgundy {
    padding: 0 10px !important;
    height: 36px !important;
    min-width: 36px !important;
    justify-content: center !important;
  }
  #btnToggleDrawer {
    width: 36px !important;
    height: 36px !important;
    padding: 0 !important;
    justify-content: center !important;
  }
  #btnToggleDrawer span {
    display: none !important;
  }

  /* Floating Editor Control Cluster */
  .editor-control-cluster {
    top: 6px !important;
    width: 98vw !important;
    max-width: 360px !important;
    gap: 5px !important;
  }
  .editor-nav-bar {
    width: 100% !important;
    justify-content: space-between !important;
    padding: 2px 4px !important;
  }
  .editor-gebinde-btn {
    max-width: 120px !important;
    font-size: 0.72rem !important;
    padding: 2px 4px !important;
  }
  .editor-dose-stepper {
    gap: 2px !important;
  }
  .editor-step-btn {
    width: 24px !important;
    height: 24px !important;
  }
  .editor-view-pill {
    padding: 2px 6px !important;
    font-size: 0.72rem !important;
    gap: 4px !important;
  }
  .m3-corner-bar {
    width: 100% !important;
    padding: 2px 4px !important;
    display: flex !important;
    justify-content: center !important;
  }
  .m3-segmented-button {
    width: 100% !important;
    justify-content: space-around !important;
    gap: 2px !important;
  }
  .m3-seg-item {
    padding: 4px 6px !important;
    font-size: 0.68rem !important;
    gap: 3px !important;
  }
  .m3-dot {
    width: 6px !important;
    height: 6px !important;
  }

  /* Floating Tools */
  .m3-nudge-pad {
    bottom: calc(34px + env(safe-area-inset-bottom, 0px)) !important;
    left: 14px !important;
    width: 96px !important;
    height: 96px !important;
    grid-template-columns: 1fr 1fr 1fr !important;
    grid-template-rows: 1fr 1fr 1fr !important;
  }
  .m3-floating-hud {
    bottom: calc(34px + env(safe-area-inset-bottom, 0px)) !important;
    right: 76px !important;
    padding: 3px 8px !important;
  }
  .m3-fab {
    bottom: calc(34px + env(safe-area-inset-bottom, 0px)) !important;
    right: 14px !important;
    width: 50px !important;
    height: 50px !important;
  }
}

/* --------------------------------------------------------------------------
   Image Management & Side Toggles
   -------------------------------------------------------------------------- */
.m3-badge-btn {
  cursor: pointer;
  border: 1px solid transparent;
  transition: all 0.15s ease;
  user-select: none;
  font-family: inherit;
}
.m3-badge-btn:hover {
  filter: brightness(1.25);
  transform: scale(1.05);
}
.m3-badge-btn:active {
  transform: scale(0.95);
}

.m3-dropzone.dragover {
  border-color: var(--md-sys-color-primary) !important;
  background: rgba(226, 6, 19, 0.1) !important;
}

.m3-image-manage-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 8px 12px;
  background: rgba(255, 255, 255, 0.03);
  border: 1px solid var(--md-sys-color-outline-variant);
  border-radius: 8px;
  gap: 10px;
  transition: background 0.15s;
}
.m3-image-manage-row:hover {
  background: rgba(255, 255, 255, 0.06);
}
.m3-image-thumb {
  width: 44px;
  height: 44px;
  border-radius: 6px;
  object-fit: cover;
  background: #111;
  border: 1px solid var(--md-sys-color-outline);
}

/* --------------------------------------------------------------------------
   API Documentation Section & Modal
   -------------------------------------------------------------------------- */
.api-doc-container {
  display: flex;
  flex-direction: column;
  gap: 14px;
  max-height: 72vh;
  overflow-y: auto;
  padding-right: 6px;
}
.api-endpoint-card {
  background: rgba(255, 255, 255, 0.03);
  border: 1px solid var(--md-sys-color-outline-variant);
  border-radius: var(--md-shape-md);
  overflow: hidden;
  transition: border-color 0.2s, background 0.2s;
}
.api-endpoint-card:hover {
  border-color: rgba(226, 6, 19, 0.35);
}
.api-endpoint-header {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 14px;
  cursor: pointer;
  user-select: none;
  background: rgba(255, 255, 255, 0.02);
  transition: background 0.15s;
}
.api-endpoint-header:hover {
  background: rgba(255, 255, 255, 0.05);
}
.api-method-badge {
  font-size: 0.7rem;
  font-weight: 700;
  padding: 2px 7px;
  border-radius: 4px;
  letter-spacing: 0.5px;
  text-transform: uppercase;
  flex-shrink: 0;
}
.api-method-badge.get {
  background: rgba(226, 6, 19, 0.18);
  color: #a8c7fa;
  border: 1px solid rgba(226, 6, 19, 0.4);
}
.api-method-badge.post {
  background: rgba(109, 213, 140, 0.18);
  color: #6dd58c;
  border: 1px solid rgba(109, 213, 140, 0.4);
}
.api-method-badge.delete {
  background: rgba(255, 180, 171, 0.18);
  color: #ffb4ab;
  border: 1px solid rgba(255, 180, 171, 0.4);
}
.api-endpoint-path {
  font-family: 'Roboto Mono', Consolas, monospace;
  font-size: 0.82rem;
  font-weight: 600;
  color: #fff;
  flex: 1;
  word-break: break-all;
}
.api-endpoint-desc {
  font-size: 0.78rem;
  color: var(--md-sys-color-on-surface-variant);
  margin-left: auto;
}
.api-endpoint-body {
  padding: 12px 14px;
  border-top: 1px solid var(--md-sys-color-outline-variant);
  display: flex;
  flex-direction: column;
  gap: 10px;
  background: rgba(0, 0, 0, 0.15);
}
.api-tabs-bar {
  display: flex;
  gap: 6px;
  border-bottom: 1px solid var(--md-sys-color-outline-variant);
  padding-bottom: 6px;
}
.api-tab-btn {
  background: transparent;
  border: none;
  color: var(--md-sys-color-on-surface-variant);
  font-size: 0.74rem;
  font-weight: 600;
  padding: 4px 10px;
  border-radius: 4px;
  cursor: pointer;
  transition: all 0.15s;
}
.api-tab-btn:hover {
  color: #fff;
}
.api-tab-btn.active {
  background: var(--md-sys-color-primary-container);
  color: var(--md-sys-color-on-primary-container);
}
.api-code-wrapper {
  position: relative;
  background: #0e0d12;
  border: 1px solid #2d2936;
  border-radius: 8px;
  overflow: hidden;
}
.api-code-content {
  font-family: 'Roboto Mono', Consolas, monospace;
  font-size: 0.75rem;
  color: #e6e1e5;
  padding: 10px 12px;
  margin: 0;
  overflow-x: auto;
  white-space: pre;
  line-height: 1.42;
}
.api-copy-btn {
  position: absolute;
  top: 6px;
  right: 6px;
  background: rgba(255, 255, 255, 0.08);
  border: 1px solid rgba(255, 255, 255, 0.15);
  color: #e6e1e5;
  font-size: 0.68rem;
  padding: 3px 8px;
  border-radius: 4px;
  cursor: pointer;
  transition: all 0.15s;
  display: flex;
  align-items: center;
  gap: 4px;
}
.api-copy-btn:hover {
  background: rgba(255, 255, 255, 0.2);
  color: #fff;
}
.api-copy-btn.copied {
  background: rgba(109, 213, 140, 0.3);
  color: #6dd58c;
  border-color: #6dd58c;
}
.api-base-url-pill {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  background: rgba(226, 6, 19, 0.1);
  border: 1px solid rgba(226, 6, 19, 0.25);
  padding: 6px 12px;
  border-radius: 20px;
  font-family: 'Roboto Mono', monospace;
  font-size: 0.78rem;
  color: var(--md-sys-color-primary);
}

/* febi lila / Burgundy Speichern Button */
.btn-save-burgundy {
  background-color: var(--pf-burgundy, #730842) !important;
  color: #ffffff !important;
  border: 1px solid rgba(255, 255, 255, 0.35) !important;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.25) !important;
  padding: 6px 18px !important;
  font-size: 0.82rem !important;
  font-weight: 700 !important;
  border-radius: 20px !important;
  display: inline-flex !important;
  align-items: center !important;
  gap: 7px !important;
  cursor: pointer !important;
  transition: all 0.15s ease !important;
  text-decoration: none !important;
}

.btn-save-burgundy:hover {
  background-color: #8e1455 !important;
  border-color: rgba(255, 255, 255, 0.7) !important;
  box-shadow: 0 4px 14px rgba(115, 8, 66, 0.45) !important;
  transform: translateY(-1px) !important;
}

.btn-save-burgundy:active {
  background-color: #540630 !important;
  transform: translateY(0) !important;
}



