/* =========================
   TV Bad Ragaz – Social Tool
   ========================= */

*, *::before, *::after { box-sizing: border-box; }
html, body { height: 100%; }

body {
  margin: 0;
  font-family: system-ui, -apple-system, Segoe UI, Roboto, Arial, sans-serif;
  color: rgba(232, 238, 252, 0.92);
  background: linear-gradient(180deg, #070a10 0%, #0b111a 40%, #070a10 100%);
  overflow-x: hidden;
}

:root {
  --border:   rgba(255, 255, 255, 0.10);
  --panel:    rgba(255, 255, 255, 0.035);
  --textDim:  rgba(232, 238, 252, 0.72);
  --shadow:   0 12px 30px rgba(0, 0, 0, 0.30);
  --radius:   16px;
  --topbar-h: 72px;
  --cv-h:     min(calc(100vh - var(--topbar-h) - 36px), 700px);
  --cv-w:     calc(var(--cv-h) * 4 / 5);
  --ctrl-w:   340px;
  --thumb-w:  90px;
}

/* ============================================================
   TOPBAR
   ============================================================ */
.topbar {
  height: var(--topbar-h);
  padding: 0 16px;
  border-bottom: 1px solid var(--border);
  background: linear-gradient(180deg, rgba(255,255,255,0.03), transparent);
  display: flex;
  align-items: center;
  position: sticky;
  top: 0;
  z-index: 100;
  backdrop-filter: blur(8px);
}
.topbar-inner {
  width: 100%;
  max-width: 1600px;
  margin: 0 auto;
  display: flex;
  align-items: center;
  justify-content: space-between;
}
.brand       { display: flex; flex-direction: column; gap: 2px; }
.brand-title { font-weight: 900; font-size: 18px; }
.brand-sub   { font-size: 13px; color: var(--textDim); }

.tabs { display: flex; gap: 10px; }
.tabbtn {
  appearance: none;
  padding: 10px 14px;
  border: 1px solid var(--border);
  border-radius: 12px;
  background: rgba(255,255,255,0.03);
  color: rgba(232,238,252,0.92);
  font-weight: 800;
  cursor: pointer;
  transition: transform 0.12s, background 0.12s;
}
.tabbtn:hover  { transform: translateY(-1px); background: rgba(255,255,255,0.05); }
.tabbtn.active { background: rgba(26,53,91,0.55); border-color: rgba(120,150,210,0.35); }

.tabcontent        { display: none; }
.tabcontent.active { display: block; }

/* ============================================================
   MAIN LAYOUT
   Both tabs: flex row, centered, gap between elements.
   Thumbnail col uses display:none when empty → zero width
   → canvas stays centered identical to Titelbild tab.
   ============================================================ */
.main {
  max-width: 1600px;
  margin: 0 auto;
  padding: 18px 16px 28px;
  display: flex;
  flex-direction: column;
  gap: 16px;
}

@media (min-width: 1100px) {
  .main {
    flex-direction: row;
    align-items: flex-start;
    justify-content: center;
    gap: 16px;
  }
}

/* ============================================================
   CANVAS WRAP — always 4:5
   ============================================================ */
.canvas-wrap {
  flex-shrink: 0;
  width: 100%;
  aspect-ratio: 4 / 5;
  border-radius: var(--radius);
  overflow: hidden;
  background: #000;
  border: 1px solid var(--border);
  box-shadow: var(--shadow);
}

@media (min-width: 1100px) {
  .canvas-wrap {
    width: var(--cv-w);
    height: var(--cv-h);
    aspect-ratio: unset;
    position: sticky;
    top: calc(var(--topbar-h) + 18px);
  }
}

canvas {
  display: block;
  width: 100%;
  height: 100%;
  touch-action: none;
  user-select: none;
}

/* ============================================================
   CONTROLS PANEL
   ============================================================ */
.controls {
  flex-shrink: 0;
  width: 100%;
  padding: 12px;
  display: flex;
  flex-direction: column;
  gap: 14px;
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  align-self: flex-start;
}

@media (min-width: 1100px) {
  .controls { width: var(--ctrl-w); }
}

/* ============================================================
   THUMBNAIL STRIP
   ============================================================ */
.thumbnail-container {
  flex-shrink: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 6px;
  overflow-y: auto;
  overflow-x: hidden;
}

@media (min-width: 1100px) {
  .thumbnail-container {
    width: var(--thumb-w);
    height: var(--cv-h);
    position: sticky;
    top: calc(var(--topbar-h) + 18px);
  }
}

/* Empty = gone → canvas centers automatically */
.thumbnail-container:empty { display: none; }

.thumbnail-container img {
  width: 80px;
  height: 80px;
  object-fit: cover;
  cursor: pointer;
  border: 2px solid transparent;
  border-radius: 6px;
  flex-shrink: 0;
  transition: border-color 0.12s;
}
.thumbnail-container img:hover { border-color: rgba(120,150,210,0.5); }

/* ============================================================
   MOBILE  (< 1100px)
   ============================================================ */
@media (max-width: 1099px) {
  .thumbnail-container {
    flex-direction: row;
    order: 2;
    width: 100%;
    height: auto;
    max-height: 92px;
    overflow-x: auto;
    overflow-y: hidden;
  }
  .canvas-wrap { order: 1; }
  .controls    { order: 3; }
}

/* ============================================================
   FORM ELEMENTS
   ============================================================ */
.label {
  font-size: 13px;
  font-weight: 800;
  color: rgba(232,238,252,0.75);
  margin-top: 4px;
}
.control {
  width: 100%;
  padding: 11px 12px;
  border: 1px solid rgba(255,255,255,0.10);
  border-radius: 12px;
  background: rgba(255,255,255,0.03);
  color: rgba(232,238,252,0.92);
  outline: none;
}
.control:focus {
  border-color: rgba(120,150,210,0.45);
  box-shadow: 0 0 0 3px rgba(26,53,91,0.35);
}
input[type="file"].control { padding: 10px; }
select.control             { padding: 11px 12px; }

.form-group {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 14px;
  color: var(--textDim);
}

/* ============================================================
   BUTTONS
   ============================================================ */
.row      { display: flex; gap: 12px; }
.row .btn { flex: 1; width: auto; }

.btn {
  appearance: none;
  width: 100%;
  padding: 12px 14px;
  border: 1px solid rgba(255,255,255,0.12);
  border-radius: 14px;
  background: rgba(255,255,255,0.04);
  color: rgba(232,238,252,0.92);
  font-weight: 900;
  cursor: pointer;
  text-align: center;
  transition: transform 0.12s, background 0.12s;
}
.btn:hover  { transform: translateY(-1px); background: rgba(255,255,255,0.06); }
.btn:active { transform: translateY(0); }

.btn.primary       { background: rgba(26,53,91,0.65); border-color: rgba(120,150,210,0.35); }
.btn.primary:hover { background: rgba(26,53,91,0.78); }
.btn.secondary     { background: rgba(255,255,255,0.02); }

.iconbtn {
  width: 44px;
  height: 44px;
  flex-shrink: 0;
  border: 1px solid rgba(255,255,255,0.12);
  border-radius: 14px;
  background: rgba(255,255,255,0.04);
  color: rgba(232,238,252,0.92);
  font-size: 18px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: transform 0.12s, background 0.12s;
}
.iconbtn:hover { transform: translateY(-1px); background: rgba(255,255,255,0.06); }

/* ============================================================
   SLIDER BLOCKS
   ============================================================ */
.sliderBlock {
  display: flex;
  flex-direction: column;
  gap: 8px;
}
.sliderLabel {
  font-size: 14px;
  font-weight: 900;
  color: rgba(232,238,252,0.82);
}
.sliderLine {
  display: grid;
  grid-template-columns: 1fr 44px;
  gap: 12px;
  align-items: center;
}
.sliderLine input[type="range"].control {
  padding: 0;
  height: 40px;
  background: transparent;
  border: none;
  box-shadow: none;
}

/* ============================================================
   ACCORDION
   ============================================================ */
.accordion {
  border: 1px solid var(--border);
  border-radius: 14px;
  overflow: hidden;
}
.accordion-toggle {
  width: 100%;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 12px 14px;
  background: rgba(255,255,255,0.04);
  border: none;
  color: rgba(232,238,252,0.92);
  font-weight: 900;
  font-size: 14px;
  cursor: pointer;
  transition: background 0.12s;
}
.accordion-toggle:hover { background: rgba(255,255,255,0.07); }
.accordion-toggle[aria-expanded="true"] { background: rgba(26,53,91,0.35); }
.accordion-arrow { font-size: 12px; flex-shrink: 0; }
.accordion-body {
  max-height: 0;
  overflow: hidden;
  transition: max-height 0.25s ease;
  display: flex;
  flex-direction: column;
  gap: 12px;
  padding: 0 12px;
}
.accordion-toggle[aria-expanded="true"] + .accordion-body {
  padding: 12px;
}

/* ============================================================
   SMALL SCREENS
   ============================================================ */
@media (max-width: 520px) {
  .topbar      { height: auto; padding: 12px 16px; }
  .brand-title { font-size: 16px; }
  .tabbtn      { padding: 9px 12px; }
  .row         { flex-direction: column; }
  .row .btn    { flex: unset; width: 100%; }
}
/* ============================================================
   MOBILE SLIDER BAR (Grading Tab, < 1100px)
   ============================================================ */
.mobile-sliders { display: none; }

@media (max-width: 1099px) {
  .mobile-sliders {
    display: flex;
    flex-direction: column;
    order: 2;
    width: 100%;
    background: rgba(255,255,255,0.03);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    overflow: hidden;
  }

  .mobile-slider-btns {
    display: grid;
    grid-template-columns: repeat(6, 1fr);
  }

  .mslider-btn {
    appearance: none;
    border: none;
    border-right: 1px solid var(--border);
    border-bottom: 1px solid var(--border);
    background: transparent;
    color: rgba(232,238,252,0.6);
    padding: 7px 2px;
    cursor: pointer;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 3px;
    transition: background 0.12s, color 0.12s;
  }
  .mslider-btn:nth-child(6),
  .mslider-btn:nth-child(11) { border-right: none; }
  .mslider-btn:nth-child(n+7) { border-bottom: none; }
  .mslider-btn:hover { background: rgba(255,255,255,0.05); color: rgba(232,238,252,0.9); }
  .mslider-btn.active {
    background: rgba(26,53,91,0.45);
    color: rgba(232,238,252,0.95);
    box-shadow: inset 0 -2px 0 rgba(120,150,210,0.7);
  }

  .mslider-icon  { font-size: 15px; line-height: 1; }
  .mslider-label { font-size: 8px; font-weight: 700; letter-spacing: 0.2px; }

  .mobile-slider-track {
    padding: 12px 16px;
    background: rgba(0,0,0,0.2);
    display: flex;
    align-items: center;
    gap: 12px;
    min-height: 68px;
  }

  .mobile-slider-range {
    flex: 1;
    -webkit-appearance: auto;
    appearance: auto;
    height: 44px;
    cursor: pointer;
    accent-color: #4a7fd4;
  }

  .mobile-reset-btn {
    flex-shrink: 0;
    width: 44px;
    height: 44px;
    border: 1px solid rgba(255,255,255,0.12);
    border-radius: 12px;
    background: rgba(255,255,255,0.04);
    color: rgba(232,238,252,0.92);
    font-size: 18px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: background 0.12s;
  }
  .mobile-reset-btn:hover { background: rgba(255,255,255,0.08); }

  /* Accordion (desktop sliders) verstecken auf Mobile */
  #tab-grading .accordion { display: none; }

  /* Reihenfolge: canvas(1) → mobile-sliders(2) → thumbnails(3) → controls(4) */
  #tab-grading .canvas-wrap         { order: 1; }
  #tab-grading .mobile-sliders      { order: 2; }
  #tab-grading .thumbnail-container { order: 3; }
  #tab-grading .controls            { order: 4; }
}

/* Mobile-Slider-Bar auf Desktop verstecken */
@media (min-width: 1100px) {
  .mobile-sliders { display: none !important; }
}


.riege-checkboxes {
  display: flex;
  flex-direction: column;
  gap: 8px;
}
.riege-checkboxes label {
  display: flex;
  align-items: center;
  gap: 10px;
  font-size: 14px;
  color: var(--textDim);
  cursor: pointer;
  padding: 8px 12px;
  border: 1px solid var(--border);
  border-radius: 10px;
  background: rgba(255,255,255,0.03);
  transition: background 0.12s;
}
.riege-checkboxes label:hover {
  background: rgba(255,255,255,0.06);
}
.riege-checkboxes input[type="checkbox"] {
  width: 16px;
  height: 16px;
  accent-color: #4a7fd4;
  cursor: pointer;
}