/* ===== Global Reset & Basics ===== */
*, *::before, *::after { box-sizing: border-box; }
html, body { height: 100%; }
body{
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font: 14px/1.6 system-ui, -apple-system, Segoe UI, Roboto, Inter, Helvetica, Arial, sans-serif;
}

/* ===== Design Tokens / Theme Vars ===== */
:root {
  color-scheme: light dark;

  /* Light (Default) */
  --text: #1c1d20;
  --bg: #f5f7fb;
  --panel: #ffffff;
  --panel-2: #f7f7f8;
  --border: #e2e4e8;
  --shadow: 0 1px 2px rgba(0,0,0,.04), 0 6px 24px rgba(0,0,0,.06);
  --muted: #6b7280;

  --primary: #2563eb;
  --ring: #93c5fd;

  --table-wrap-bg: #f1f3f5;
  --table-head-bg: #e9ecef;
  --row-hover-bg: rgba(37, 99, 235, 0.06);

  --danger: #c62828;

  --radius: 14px;
  --gap: 16px;
}

/* Dark automatisch über OS */
@media (prefers-color-scheme: dark) {
  :root {
    --text: #e7e9ee;
    --bg: #0d0f12;
    --panel: #121417;
    --panel-2: #171a1f;
    --border: #2a2f37;
    --shadow: 0 1px 2px rgba(0,0,0,.6), 0 6px 24px rgba(0,0,0,.45);
    --muted: #9aa3b2;

    --primary: #60a5fa;
    --ring: #1d4ed8;

    --table-wrap-bg: #0f1114;
    --table-head-bg: #1e232b;
    --row-hover-bg: rgba(96, 165, 250, 0.08);

    --danger: #ef4444;
  }
}

/* Manuelle Umschaltung */
[data-theme="light"] {
  --text: #1c1d20;
  --bg: #f5f7fb;
  --panel: #ffffff;
  --panel-2: #f7f7f8;
  --border: #e2e4e8;
  --shadow: 0 1px 2px rgba(0,0,0,.04), 0 6px 24px rgba(0,0,0,.06);
  --muted: #6b7280;

  --primary: #2563eb;
  --ring: #93c5fd;

  --table-wrap-bg: #f1f3f5;
  --table-head-bg: #e9ecef;
  --row-hover-bg: rgba(37, 99, 235, 0.06);

  --danger: #c62828;
}
[data-theme="dark"] {
  --text: #e7e9ee;
  --bg: #0d0f12;
  --panel: #121417;
  --panel-2: #171a1f;
  --border: #2a2f37;
  --shadow: 0 1px 2px rgba(0,0,0,.6), 0 6px 24px rgba(0,0,0,.45);
  --muted: #9aa3b2;

  --primary: #60a5fa;
  --ring: #1d4ed8;

  --table-wrap-bg: #0f1114;
  --table-head-bg: #1e232b;
  --row-hover-bg: rgba(96, 165, 250, 0.08);

  --danger: #ef4444;
}

/* ===== Shell & Navigation ===== */
.page-shell{
  display: grid;
  grid-template-columns: 180px 1fr;
  gap: var(--gap);
  min-height: 100dvh;
  padding: 16px;
}

/* Left Sidebar */
.left-box{
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 16px;
  position: sticky;
  top: 16px;
  align-self: start;
  height: auto;
}
.left-box-top h3{
  margin: 0 0 12px 0;
  font-size: 16px;
}
.nav{
  display: grid;
  gap: 8px;
}

/* Right Content Area — wächst mit Content */
.right-box{
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 20px;

  min-height: 60dvh;    /* Startgröße, darf wachsen */
  height: auto;
  max-height: none;
  overflow-x: hidden;     /* horizontales Scrollen der Box verhindern */
  overflow-y: visible;  /* Seite scrollt global */
  display: block;
}

/* Content-Container in der Right-Box: Overflows vermeiden */
.container-rightbox{
  display: grid;
  gap: 16px;
  min-width: 0;
}
.container-rightbox > *{ min-width: 0; }

/* Canvas/Editor-Flächen */
.canvas[hidden]{ display: none; }
.canvas:focus{ outline: none; }
.lead{ color: var(--muted); }

/* ===== Buttons (global) ===== */
.btn{
  appearance: none;
  border: 1px solid var(--border);
  background: var(--panel-2);
  color: var(--text);
  padding: 10px 12px;
  border-radius: 10px;
  cursor: pointer;
  transition: transform .06s ease, box-shadow .12s ease, border-color .12s ease, background .12s ease;
  text-align: left;
}
.btn:hover{ border-color: var(--primary); }
.btn:focus{ outline: none; box-shadow: 0 0 0 3px color-mix(in srgb, var(--ring) 30%, transparent); }
.btn:active{ transform: translateY(1px); }
.btn--ghost{ background: linear-gradient(180deg, rgba(255,255,255,.02), rgba(0,0,0,.05)); }
.is-active{ border-color: var(--primary); box-shadow: inset 0 0 0 1px var(--primary); }
.btn--primary{
  background: linear-gradient(180deg, color-mix(in srgb, var(--primary) 35%, #000 0%), rgba(0,0,0,.07));
  border-color: color-mix(in srgb, var(--primary) 60%, var(--border));
  color: #fff;
}
.btn--danger{
  background: linear-gradient(180deg, color-mix(in srgb, var(--danger) 35%, #000 0%), rgba(0,0,0,.07));
  border-color: color-mix(in srgb, var(--danger) 60%, var(--border));
  color: #fff;
}
.btn--sm{ padding: 6px 10px; border-radius: 8px; font-size: 12px; }
.btn--ghost-dark{ background: linear-gradient(180deg, rgba(255,255,255,.02), rgba(0,0,0,.05)); }

/* Typo & Utilities */
.muted{ color: var(--muted); }
.small{ font-size: 12px; }
.field__input--sm { padding: 6px 10px; font-size: .9rem; }

/* Responsive */
@media (max-width: 900px){
  .page-shell{ grid-template-columns: 1fr; }
  .left-box{ position: static; order: -1; }
}

/* Accessible Focus */
:focus-visible{
  outline: 2px solid var(--ring);
  outline-offset: 2px;
}
