/**
 * Oil Painting Assistant - Main Stylesheet
 */

/* ===== CSS Variables ===== */
:root {
  --bg: #0b0f17;
  --panel: rgba(255, 255, 255, 0.08);
  --panel-border: rgba(255, 255, 255, 0.12);
  --text: rgba(255, 255, 255, 0.92);
  --accent: #ffc107;
}

/* ===== Base Styles ===== */
html, body {
  height: 100%;
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: system-ui, -apple-system, Segoe UI, Roboto, Arial, sans-serif;
}

/* ===== Layout ===== */
.wrap {
  height: 100%;
  display: flex;
  flex-direction: column;
}

.bar {
  display: flex;
  gap: 10px;
  align-items: center;
  padding: 12px;
  background: var(--panel);
  border-bottom: 1px solid var(--panel-border);
  backdrop-filter: blur(10px);
  flex-shrink: 0;
}

.status {
  margin-left: auto;
  font-size: 14px;
  opacity: 0.85;
}

.view {
  position: relative;
  display: flex;
  flex: 1;
  min-height: 0;
  min-width: 0;
  padding: 0;
  width: 100%;
  height: 100%;
  box-sizing: border-box;
  overflow: hidden;
}

.view.hasCalPanel .feedWrap {
  flex: 1;
}

/* ===== Feed Wrapper ===== */
.feedWrap {
  position: relative;
  display: flex;
  align-items: center;
  justify-content: center;
  flex: 1;
  min-height: 0;
  min-width: 0;
  overflow: hidden;
  background: #000;
}

.feedViewport {
  position: relative;
  width: 100%;
  height: 100%;
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: hidden;
}

/* Main feed image/video - fill container maintaining aspect ratio */
.feedViewport img#feed,
.feedViewport video#webrtcFeed,
.feedViewport video.videoFeed {
  display: block;
  max-width: 100%;
  max-height: 100%;
  width: 100%;
  height: 100%;
  object-fit: contain;
  /* pointer-events enabled for calibration clicks */
  pointer-events: auto;
  user-select: none;
}

/* Overlays inside feedViewport - position absolute to cover the media */
.feedViewport .calOverlay,
.feedViewport .calEdges,
.feedViewport #clientOverlay,
.feedViewport #recipeMaskOverlay,
.feedViewport #loupe {
  position: absolute;
}

/* Generic img/video defaults (for other images in the app) */
img:not(#feed),
video.videoFeed:not(#webrtcFeed) {
  max-width: 100%;
  max-height: 100%;
  object-fit: contain;
  display: block;
}

/* ===== Buttons ===== */
.btn {
  appearance: none;
  border: 1px solid var(--panel-border);
  background: rgba(255, 255, 255, 0.10);
  color: var(--text);
  padding: 10px 14px;
  border-radius: 12px;
  font-size: 16px;
  font-weight: 600;
  cursor: pointer;
}

.btn:active {
  transform: translateY(1px);
}

.btn.icon {
  padding: 10px 12px;
  width: 44px;
  text-align: center;
}

.btn.danger {
  border-color: rgba(255, 59, 59, 0.40);
  background: rgba(255, 59, 59, 0.18);
}

.viewModeBtn {
  font-size: 12px !important;
  padding: 8px 10px !important;
  opacity: 0.7;
  transition: all 0.15s ease;
}

.viewModeBtn.active {
  opacity: 1;
  background: rgba(76, 175, 80, 0.3) !important;
  border-color: rgba(76, 175, 80, 0.6) !important;
  box-shadow: 0 0 8px rgba(76, 175, 80, 0.4);
}

/* ===== Calibration Overlay ===== */
.calOverlay {
  position: absolute;
  inset: 0;
  pointer-events: none;
}

.calOverlay.interactive {
  pointer-events: auto;
}

.calDot {
  position: absolute;
  width: 16px;
  height: 16px;
  border-radius: 999px;
  background: #ff3b3b;
  box-shadow: 0 0 0 3px rgba(0,0,0,0.45), 0 0 12px rgba(255,59,59,0.6);
  transform: translate(-50%, -50%);
  transition: transform 0.1s ease, box-shadow 0.15s ease;
}

.calDot.draggable {
  cursor: grab;
  pointer-events: auto;
}

.calDot.draggable:hover {
  transform: translate(-50%, -50%) scale(1.3);
  box-shadow: 0 0 0 3px rgba(0,0,0,0.45), 0 0 20px rgba(255,59,59,0.9);
}

.calDot.dragging {
  cursor: grabbing;
  transform: translate(-50%, -50%) scale(1.4);
  box-shadow: 0 0 0 4px rgba(255,255,255,0.5), 0 0 25px rgba(255,59,59,1);
}

.calDot.selected {
  background: #4CAF50;
  box-shadow: 0 0 0 3px rgba(0,0,0,0.45), 0 0 15px rgba(76,175,80,0.8);
}

.calDot.selected:hover {
  box-shadow: 0 0 0 3px rgba(0,0,0,0.45), 0 0 20px rgba(76,175,80,1);
}

.calDot .calDotLabel {
  position: absolute;
  top: -22px;
  left: 50%;
  transform: translateX(-50%);
  font-size: 11px;
  font-weight: 700;
  color: #fff;
  text-shadow: 0 1px 3px rgba(0,0,0,0.8);
  white-space: nowrap;
  pointer-events: none;
}

/* ===== Calibration Edges ===== */
.calEdge {
  position: absolute;
  pointer-events: none;
  stroke: rgba(255, 59, 59, 0.6);
  stroke-width: 2;
  stroke-dasharray: 6 4;
}

.calEdge.refined {
  stroke: rgba(76, 175, 80, 0.8);
  stroke-width: 3;
  stroke-dasharray: none;
}

/* ===== Calibration HUD Panel ===== */
.calHudPanel {
  width: 280px;
  min-width: 200px;
  max-width: min(35vw, 320px);
  display: none;
  align-self: flex-start;
  padding: 10px;
  box-sizing: border-box;
  flex-shrink: 0;
}

.calHudPanel.visible {
  display: flex;
  flex-direction: column;
}

.calHud {
  position: relative;
  display: none;
  flex-direction: column;
  align-items: stretch;
  gap: 12px;
  padding: 14px 16px;
  border-radius: 14px;
  background: rgba(14, 18, 28, 0.95);
  border: 1px solid var(--panel-border);
  backdrop-filter: blur(10px);
  pointer-events: auto;
  user-select: none;
  width: 100%;
  box-sizing: border-box;
}

.calHudText {
  font-size: 13px;
  font-weight: 600;
  opacity: 0.95;
  line-height: 1.4;
}

.calHudRight {
  display: flex;
  flex-direction: column;
  gap: 10px;
  align-items: stretch;
}

.calHudRatio {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  align-items: center;
  font-size: 12px;
  opacity: 0.9;
}

.calHudButtons {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 4px;
}

.calHudButtons .btn {
  flex: 1;
  min-width: 80px;
  font-size: 13px;
  padding: 10px 12px;
}

.calHudRatio input[type="number"] {
  width: 58px;
  padding: 6px 8px;
  border-radius: 10px;
  border: 1px solid var(--panel-border);
  background: rgba(255,255,255,0.08);
  color: var(--text);
  color-scheme: dark;
  font-size: 13px;
  font-weight: 700;
}

/* ===== Loupe ===== */
#loupe {
  position: absolute;
  display: none;
  width: 140px;
  height: 140px;
  border-radius: 50%;
  border: 2px solid rgba(255, 255, 255, 0.35);
  box-shadow: 0 12px 30px rgba(0,0,0,0.45);
  z-index: 7;
  pointer-events: none;
  background: rgba(0,0,0,0.25);
}

/* ===== Tuning Panel ===== */
.tuning {
  position: fixed;
  left: 12px;
  bottom: 12px;
  width: min(420px, calc(100vw - 24px));
  background: rgba(255, 255, 255, 0.08);
  border: 1px solid var(--panel-border);
  border-radius: 14px;
  padding: 12px;
  backdrop-filter: blur(10px);
  z-index: 5;
}

.tuningTitle {
  font-weight: 800;
  font-size: 14px;
  opacity: 0.9;
  margin-bottom: 8px;
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.tuningRow {
  display: grid;
  gap: 6px;
  margin-top: 10px;
}

.tuningRow label {
  font-size: 12px;
  opacity: 0.85;
}

.tuningRow .sliderRow {
  grid-template-columns: 1fr auto;
}

.tuningHint {
  font-size: 12px;
  opacity: 0.75;
  margin-top: 8px;
}

/* ===== Modal ===== */
.overlay {
  position: fixed;
  inset: 0;
  display: none;
  place-items: center;
  background: rgba(0, 0, 0, 0.55);
  backdrop-filter: blur(6px);
  z-index: 10;
}

.modal {
  position: absolute;
  width: min(900px, calc(100vw - 28px));
  max-height: 90vh;
  background: rgba(14, 18, 28, 0.96);
  border: 1px solid var(--panel-border);
  border-radius: 16px;
  padding: 0;
  box-shadow: 0 18px 50px rgba(0,0,0,0.5);
  left: 50%;
  top: 50%;
  transform: translate(-50%, -50%);
}

.modal-header {
  padding: 16px;
  cursor: move;
  user-select: none;
  border-bottom: 1px solid var(--panel-border);
  display: flex;
  justify-content: space-between;
  align-items: center;
  border-radius: 16px 16px 0 0;
  background: rgba(255, 255, 255, 0.02);
}

.modal-header:active {
  cursor: grabbing;
}

.modal-body {
  padding: 16px;
  max-height: calc(90vh - 140px);
  overflow-y: auto;
}

.modal h2 {
  margin: 0;
  font-size: 18px;
}

.modal-footer {
  padding: 12px 16px;
  border-top: 1px solid var(--panel-border);
  display: flex;
  justify-content: space-between;
  gap: 10px;
  background: rgba(255, 255, 255, 0.02);
  border-radius: 0 0 16px 16px;
}

/* ===== Settings Grid ===== */
.settingsGrid {
  display: grid;
  gap: 14px;
  grid-template-columns: repeat(auto-fit, minmax(260px, 1fr));
}

.sectionCard {
  background: rgba(255, 255, 255, 0.04);
  border: 1px solid rgba(255, 255, 255, 0.08);
  border-radius: 12px;
  padding: 12px;
}

.sectionHeader {
  font-size: 13px;
  font-weight: 700;
  margin-bottom: 8px;
  opacity: 0.9;
}

.sectionCard.is-collapsible {
  padding: 0;
}

.sectionCard.is-collapsible > summary.sectionHeader {
  list-style: none;
  cursor: pointer;
  padding: 12px;
}

.sectionCard.is-collapsible > summary.sectionHeader::-webkit-details-marker {
  display: none;
}

.sectionCard.is-collapsible > summary.sectionHeader::after {
  content: '▸';
  float: right;
  opacity: 0.7;
  transition: transform 0.2s ease;
}

.sectionCard.is-collapsible[open] > summary.sectionHeader::after {
  transform: rotate(90deg);
}

.sectionCard.is-collapsible > .row {
  padding: 0 12px 12px 12px;
}

.settingsMessage {
  margin-top: 12px;
  font-size: 13px;
  opacity: 0.85;
}

.settingsMessage.is-error {
  color: #ff6b6b;
}

.settingsMessage.is-success {
  color: #7bd88f;
}

.controlRow {
  margin: 12px 0;
}

.controlRow.is-disabled {
  opacity: 0.6;
}

.controlLine {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
}

.fieldHint {
  font-size: 11px;
  opacity: 0.7;
  margin-top: 4px;
}

.valuePill {
  min-width: 36px;
  text-align: center;
  font-size: 12px;
  padding: 4px 6px;
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.08);
}

.buttonGroup {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

.referenceList {
  display: grid;
  gap: 8px;
  margin-top: 8px;
}

.referenceItem {
  display: flex;
  gap: 8px;
  align-items: center;
  padding: 8px;
  background: rgba(255, 255, 255, 0.05);
  border-radius: 8px;
}

.referenceItem.active {
  background: rgba(255, 255, 255, 0.15);
}

.nudgeRow {
  display: grid;
  grid-template-columns: repeat(5, minmax(0, 1fr));
  gap: 6px;
}

.statusText {
  font-size: 12px;
  opacity: 0.75;
  margin-top: 6px;
}

.colorRow {
  display: flex;
  align-items: center;
  gap: 10px;
}

.emptyState {
  font-size: 12px;
  opacity: 0.6;
  text-align: center;
  padding: 12px;
}

.btn.primary {
  background: rgba(0, 180, 200, 0.2);
  border-color: rgba(0, 180, 200, 0.6);
}

.btn.mini {
  padding: 4px 8px;
  font-size: 11px;
}

.btn.accent {
  background: rgba(0, 180, 200, 0.2);
  border-color: rgba(0, 180, 200, 0.5);
  color: rgba(0, 180, 200, 1);
}

.histLegend {
  font-size: 11px;
  opacity: 0.7;
  margin-top: 6px;
  display: flex;
  gap: 12px;
  align-items: center;
}

.legendItem {
  display: inline-flex;
  align-items: center;
  gap: 4px;
}

.legendSwatch {
  display: inline-block;
  width: 12px;
  height: 8px;
  border-radius: 2px;
}

.legendRef {
  background: rgba(0, 180, 200, 0.8);
}

.legendLive {
  height: 2px;
  background: rgba(255, 180, 0, 0.9);
  border-radius: 1px;
}

.legendSpacer {
  flex: 1;
}

.valuesToggle {
  display: flex;
  gap: 4px;
}

.valuesToggle .values-mode-btn {
  flex: 1;
  padding: 6px 8px;
  font-size: 11px;
  background: rgba(255, 255, 255, 0.05);
  border: 1px solid rgba(255, 255, 255, 0.2);
  border-radius: 4px;
  color: rgba(255, 255, 255, 0.7);
  cursor: pointer;
  transition: all 0.2s;
}

.valuesToggle .values-mode-btn.active {
  background: rgba(0, 180, 200, 0.3);
  border-color: rgba(0, 180, 200, 0.6);
  color: rgba(0, 180, 200, 1);
}

.tuningSubSection {
  margin-top: 12px;
  padding-top: 12px;
  border-top: 1px solid rgba(255, 255, 255, 0.1);
}

.subHeader {
  font-size: 13px;
  margin-bottom: 8px;
  display: block;
}

.toggleLabel {
  display: flex;
  align-items: center;
  gap: 8px;
  cursor: pointer;
  font-size: 13px;
}

.inlineSpinner {
  display: none;
  font-size: 14px;
  animation: spin 1s linear infinite;
}

.hintIcon {
  font-size: 11px;
  opacity: 0.6;
  margin-left: auto;
}

.densityRow {
  margin-top: 8px;
}

.densityLine {
  display: flex;
  align-items: center;
  gap: 8px;
}

.mixingHeader {
  display: flex;
  align-items: center;
  gap: 8px;
  cursor: pointer;
}

.mixingRow {
  display: flex;
  align-items: center;
  gap: 6px;
  margin-bottom: 10px;
  font-size: 11px;
  opacity: 0.7;
}

.mixingOverlayToggle {
  display: flex;
  align-items: center;
  gap: 8px;
  cursor: pointer;
  font-size: 12px;
  margin-bottom: 10px;
  padding: 6px 8px;
  background: rgba(255, 255, 255, 0.05);
  border-radius: 6px;
}

.tuningMode {
  font-size: 12px;
  opacity: 0.75;
}

.span-2 {
  grid-column: 1 / -1;
}

/* ===== Plugins Styles ===== */
.pluginsPanel {
  max-height: 85vh;
  overflow-y: auto;
}

.plugin-card {
  background: rgba(255,255,255,0.05);
  border: 1px solid rgba(255,255,255,0.1);
  border-radius: 8px;
  padding: 15px;
  margin-bottom: 15px;
}

.plugin-header {
  font-size: 16px;
  font-weight: 600;
  margin-bottom: 8px;
  color: var(--accent);
}

.plugin-runtime-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  border-bottom: 1px solid rgba(255,255,255,0.1);
  padding-bottom: 8px;
  margin-bottom: 8px;
}

.plugin-runtime-badge {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 74px;
  padding: 3px 8px;
  border-radius: 999px;
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 0.04em;
  border: 1px solid transparent;
}

.plugin-runtime-badge.is-ready {
  color: #34d399;
  background: rgba(52, 211, 153, 0.12);
  border-color: rgba(52, 211, 153, 0.45);
}

.plugin-runtime-badge.is-degraded {
  color: #fbbf24;
  background: rgba(251, 191, 36, 0.12);
  border-color: rgba(251, 191, 36, 0.45);
}

.plugin-runtime-badge.is-error {
  color: #f87171;
  background: rgba(248, 113, 113, 0.12);
  border-color: rgba(248, 113, 113, 0.45);
}

.plugin-runtime-badge.is-unknown {
  color: rgba(255,255,255,0.7);
  background: rgba(255,255,255,0.08);
  border-color: rgba(255,255,255,0.22);
}

.plugin-controls {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.plugin-control-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 15px;
}

.plugin-desc {
  font-size: 11px;
  color: rgba(255,255,255,0.5);
  margin-top: 4px;
}

.plugin-warning {
  color: #fbbf24;
}

.plugin-error {
  color: #f87171;
}

/* ===== Form Elements ===== */
.row {
  display: grid;
  gap: 8px;
  margin: 12px 0;
}

label {
  font-size: 13px;
  opacity: 0.9;
}

select {
  appearance: none;
  border: 1px solid var(--panel-border);
  background: rgba(255, 255, 255, 0.08);
  color: var(--text);
  padding: 10px 12px;
  border-radius: 12px;
  font-size: 16px;
  color-scheme: dark;
}

select option {
  background: rgba(14, 18, 28, 0.98);
  color: rgba(255, 255, 255, 0.92);
}

select:focus {
  outline: 2px solid rgba(255, 193, 7, 0.9);
  outline-offset: 2px;
}

input[type="file"] {
  color: var(--text);
}

input[type="range"] {
  width: 100%;
}

.sliderRow {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 10px;
  align-items: center;
}

.actions {
  display: flex;
  justify-content: flex-end;
  gap: 10px;
  margin-top: 14px;
}

.sectionTitle {
  margin: 16px 0 6px 0;
  font-size: 14px;
  opacity: 0.9;
  font-weight: 700;
}

/* ===== Histogram & Threshold Editor ===== */
.threshold-marker {
  position: absolute;
  width: 12px;
  height: 20px;
  background: #ffc107;
  border: 2px solid #fff;
  border-radius: 3px;
  cursor: ew-resize;
  transform: translateX(-50%);
  z-index: 5;
  box-shadow: 0 2px 6px rgba(0,0,0,0.4);
  transition: background 0.15s, transform 0.1s;
}

.threshold-marker:hover {
  background: #ffca2c;
  transform: translateX(-50%) scale(1.1);
}

.threshold-marker:active {
  background: #e0a800;
  transform: translateX(-50%) scale(1.15);
}

.threshold-marker::after {
  content: '';
  position: absolute;
  top: -62px;
  left: 50%;
  width: 1px;
  height: 60px;
  background: rgba(255, 193, 7, 0.6);
  transform: translateX(-50%);
  pointer-events: none;
}

.threshold-label {
  position: absolute;
  top: -14px;
  left: 50%;
  transform: translateX(-50%);
  font-size: 10px;
  color: #ffc107;
  font-weight: 700;
  pointer-events: none;
  white-space: nowrap;
}

/* ===== Animations ===== */
@keyframes spin {
  from { transform: rotate(0deg); }
  to { transform: rotate(360deg); }
}

@keyframes recipeBlink {
  0%, 100% { opacity: 0; }
  50% { opacity: 1; }
}

.recipe-blinking {
  animation: recipeBlink 0.5s ease-in-out 2;
  opacity: 1 !important;
}

/* ===== Mixing Recipes Panel ===== */
.mixingCountBtn {
  padding: 4px 8px;
  font-size: 11px;
  background: rgba(255,255,255,0.08);
  border: 1px solid rgba(255,255,255,0.15);
  border-radius: 4px;
  color: var(--text);
  cursor: pointer;
  transition: all 0.2s;
}

.mixingCountBtn:hover {
  background: rgba(255,255,255,0.15);
}

.mixingCountBtn.active {
  background: var(--accent);
  border-color: var(--accent);
  color: #000;
  font-weight: 600;
}

.mixingRecipeItem {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  padding: 8px;
  margin-bottom: 6px;
  background: rgba(0,0,0,0.2);
  border-radius: 6px;
  font-size: 11px;
  transition: all 0.2s ease;
}

.mixingRecipeItem:hover {
  background: rgba(0, 180, 200, 0.15);
  border: 1px solid rgba(0, 180, 200, 0.4);
}

.mixingRecipeItem.highlighted {
  background: rgba(0, 180, 200, 0.3);
  border: 2px solid rgba(0, 180, 200, 0.8);
  box-shadow: 0 0 10px rgba(0, 180, 200, 0.4);
}

.mixingRecipeItem.out-of-gamut {
  border: 1px solid #e74c3c;
  background: rgba(231, 76, 60, 0.1);
}

.mixingColorSwatch {
  width: 32px;
  height: 32px;
  border-radius: 50%;
  border: 2px solid rgba(255,255,255,0.3);
  flex-shrink: 0;
}

.mixingProportions {
  flex: 1;
  line-height: 1.5;
}

.mixingPigment {
  display: inline-block;
  padding: 1px 4px;
  margin: 1px 2px;
  background: rgba(255,255,255,0.1);
  border-radius: 3px;
  font-family: monospace;
  font-size: 10px;
}

.mixingWarning {
  color: #e74c3c;
  font-size: 10px;
  margin-top: 2px;
}

.mixingImportance {
  font-size: 9px;
  opacity: 0.5;
  margin-top: 2px;
}

/* ===== Zoom Controls ===== */
.zoomControls {
  position: absolute;
  top: 10px;
  right: 10px;
  display: flex;
  align-items: center;
  gap: 6px;
  background: rgba(14, 18, 28, 0.9);
  border: 1px solid var(--panel-border);
  border-radius: 10px;
  padding: 6px 10px;
  z-index: 8;
  backdrop-filter: blur(8px);
}

.zoomBtn {
  appearance: none;
  border: 1px solid var(--panel-border);
  background: rgba(255, 255, 255, 0.08);
  color: var(--text);
  width: 32px;
  height: 32px;
  border-radius: 8px;
  font-size: 18px;
  font-weight: 600;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all 0.15s ease;
}

.zoomBtn:hover {
  background: rgba(255, 255, 255, 0.15);
}

.zoomBtn:active {
  transform: scale(0.95);
}

.zoomBtn.panModeBtn {
  width: auto;
  padding: 0 10px;
  font-size: 11px;
  letter-spacing: 0.2px;
}

.zoomBtn.panModeBtn.active {
  background: rgba(255, 255, 255, 0.2);
  border-color: rgba(255, 255, 255, 0.35);
}

.zoomLevel {
  font-size: 12px;
  font-weight: 600;
  min-width: 50px;
  text-align: center;
  opacity: 0.9;
}

/* ===== Workspace UX-1 ===== */
html, body {
  font-family: "Avenir Next", "Futura", "Helvetica Neue", sans-serif;
}

.topBar {
  padding: 10px 12px;
  gap: 8px;
}

.topBar .btn {
  font-size: 14px;
  padding: 8px 12px;
}

.topBar .btn.icon {
  width: 40px;
  padding: 8px;
}

.workspaceMain {
  display: flex;
  flex: 1;
  min-height: 0;
  min-width: 0;
}

.workspaceCanvas {
  flex: 1;
  min-width: 0;
  min-height: 0;
}

.workspaceSidebar {
  width: min(420px, 36vw);
  min-width: 320px;
  border-left: 1px solid var(--panel-border);
  background: rgba(10, 14, 20, 0.88);
  backdrop-filter: blur(12px);
  display: flex;
  flex-direction: column;
  min-height: 0;
  overflow: hidden;
}

#workspace.sidebar-collapsed .workspaceSidebar {
  width: 0;
  min-width: 0;
  border-left: 0;
}

#workspace.sidebar-collapsed #sidebarRoot,
#workspace.sidebar-collapsed #settingsError {
  display: none;
}

.sidebarShell {
  display: flex;
  flex-direction: column;
  flex: 1;
  min-height: 0;
}

.workspaceTabs {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  border-bottom: 1px solid var(--panel-border);
  padding: 8px;
  gap: 6px;
  flex-shrink: 0;
}

.workspaceTab {
  appearance: none;
  border: 1px solid rgba(255, 255, 255, 0.10);
  background: rgba(255, 255, 255, 0.04);
  color: var(--text);
  border-radius: 10px;
  padding: 10px 8px;
  font-size: 12px;
  font-weight: 700;
  letter-spacing: 0.2px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
}

.workspaceTab.is-active {
  border-color: rgba(0, 180, 200, 0.55);
  background: rgba(0, 180, 200, 0.16);
  color: #9de8f2;
}

.tabDirtyDot {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: #ff9f43;
  box-shadow: 0 0 6px rgba(255, 159, 67, 0.8);
}

.workspacePanels {
  flex: 1;
  min-height: 0;
  position: relative;
}

.workspacePanel {
  display: none;
  flex-direction: column;
  height: 100%;
}

.workspacePanel.is-active {
  display: flex;
}

.panelHead {
  padding: 12px 14px 8px 14px;
  border-bottom: 1px solid rgba(255, 255, 255, 0.08);
  flex-shrink: 0;
}

.panelTitle {
  font-size: 13px;
  font-weight: 800;
  letter-spacing: 0.3px;
  opacity: 0.92;
}

.panelBody {
  flex: 1;
  min-height: 0;
  overflow-y: auto;
  padding: 12px 14px 14px 14px;
}

.tabFooter {
  position: sticky;
  bottom: 0;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding: 10px 14px;
  border-top: 1px solid rgba(255, 255, 255, 0.10);
  background: rgba(9, 13, 18, 0.98);
  backdrop-filter: blur(12px);
  flex-shrink: 0;
}

.dirtyChip {
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.25px;
  color: rgba(255, 255, 255, 0.72);
}

.dirtyChip.is-dirty {
  color: #ffb563;
}

.modeBtn,
.viewModeBtn {
  font-size: 11px !important;
  padding: 8px 9px !important;
  opacity: 0.78;
}

.modeBtn.active,
.viewModeBtn.active {
  opacity: 1;
  background: rgba(0, 180, 200, 0.24) !important;
  border-color: rgba(0, 180, 200, 0.58) !important;
  box-shadow: 0 0 8px rgba(0, 180, 200, 0.28);
}

.tuningWorkspace {
  margin-top: 10px;
  padding: 12px;
  border-radius: 12px;
  border: 1px solid rgba(255, 255, 255, 0.10);
  background: rgba(255, 255, 255, 0.03);
}

#settingsError {
  margin: 8px 14px 14px 14px;
}

@media (max-width: 1080px) {
  .workspaceSidebar {
    width: min(480px, 45vw);
    min-width: 280px;
  }

  .workspaceTabs {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
}

@media (max-width: 860px) {
  .workspaceMain {
    flex-direction: column;
  }

  .workspaceSidebar {
    width: 100%;
    min-width: 0;
    height: 48vh;
    border-left: 0;
    border-top: 1px solid var(--panel-border);
  }

  #workspace.sidebar-collapsed .workspaceSidebar {
    height: 0;
    width: 100%;
    min-height: 0;
    border-top: 0;
  }

  .topBar {
    flex-wrap: wrap;
  }

  .status {
    margin-left: 0;
    width: 100%;
  }
}
