/* ============================================================
   WEBSITE BUILDER — CODEBLOOM LABS
   Workspace styles. Shared chrome (tokens, base, buttons,
   header, rail, modal) lives in shared.css — loaded first.
   ============================================================ */

/* --- Selection chrome token (Website Builder-specific) --- */
/* A dedicated UI colour for canvas selection chrome — the outlines and labels of
   selected sections, cells, and elements. Kept SEPARATE from --primary on purpose:
   --primary doubles as a content colour kids paint with (the default main-color is
   the same #4e4eff), so a selected blue element's outline used to vanish into its
   own fill. Reserving a distinct azure — the hue Figma, Webflow, and the OS accent
   colours all converge on — means it rarely lands on content, reads as "system
   chrome" rather than content, and stays the most colour-blind-safe hue. One colour
   for every selection state; no red anywhere on selections. */
:root {
  --ui-select: #0a84ff;
}

/* --- Modal (Website Builder-specific extensions) --- */

.modal__hint {
  font-size: var(--fs-sm);
  color: #888;
  margin-top: 4px;
}

.modal__code {
  background: var(--black);
  color: #e0e0e0;
  padding: var(--large);
  border-radius: var(--radius-md);
  font-family: var(--font);
  font-size: var(--fs-sm);
  line-height: 1.6;
  overflow: auto;
  max-height: 50vh;
  white-space: pre;
  tab-size: 2;
}

.modal__subtitle {
  color: #888;
  font-size: var(--fs-md);
  margin-top: -12px;
  margin-bottom: var(--large);
}

/* --- Starters Grid --- */

.starters-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
  gap: 12px;
}

.starters-grid__card {
  text-align: left;
  padding: 16px;
  border: 2px solid rgba(78, 78, 255, 0.2);
  border-radius: var(--radius-md);
  background: var(--white);
  cursor: pointer;
  transition:
    border-color 0.15s,
    box-shadow 0.15s;
  font-family: var(--font);
}

.starters-grid__card:hover {
  border-color: var(--primary);
  box-shadow: 0 2px 8px rgba(78, 78, 255, 0.15);
}

.starters-grid__name {
  font-size: var(--fs-md);
  font-weight: 700;
  color: var(--primary);
  margin-bottom: 4px;
}

.starters-grid__desc {
  font-size: var(--fs-sm);
  color: #666;
  margin-bottom: 10px;
}

.starters-grid__preview {
  display: flex;
  gap: 6px;
}

.starters-grid__dot {
  width: 20px;
  height: 20px;
  border-radius: 50%;
  border: 1px solid rgba(0, 0, 0, 0.1);
}

/* --- Header (Website Builder-specific extensions) --- */

.header__site-name {
  font-size: var(--fs-sm);
  font-weight: 500;
  opacity: 0.4;
  margin-left: 8px;
  max-width: 160px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.header__class-btn {
  font-family: var(--font);
  font-size: var(--fs-sm);
  font-weight: 700;
  text-transform: uppercase;
  padding: var(--small) var(--medium);
  border: 2px solid var(--primary);
  border-radius: var(--radius-sm);
  background: var(--primary);
  color: var(--white);
  cursor: pointer;
}

.header__class.active .header__class-btn {
  display: none;
}

/* --- Workspace --- */

.workspace {
  display: grid;
  grid-template-columns: 70px 150px 1fr 290px;
  flex: 1;
  overflow: hidden;
  padding: 0 var(--medium) 0 0;
}

/* --- Palette (field-type contents of the .left-panel column) --- */

.palette {
  padding: var(--medium);
}

.palette__body {
  flex: 1;
  min-height: 0;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.palette__footer {
  display: flex;
  justify-content: center;
  gap: var(--small);
  flex-shrink: 0;
  margin-top: var(--medium);
  padding-top: var(--medium);
  border-top: 1px solid rgba(78, 78, 255, 0.15);
}

.palette__icon-btn {
  width: 42px;
  height: 42px;
  display: flex;
  align-items: center;
  justify-content: center;
  border: 2px solid rgba(78, 78, 255, 0.25);
  border-radius: var(--radius-sm);
  background: transparent;
  color: var(--black);
  cursor: pointer;
  font-family: var(--font);
  font-size: 18px;
  transition: all 0.15s;
}

.palette__icon-btn:hover {
  background: var(--primary);
  border-color: var(--primary);
  color: var(--white);
}

.palette__title {
  text-transform: uppercase;
  margin-bottom: var(--small);
}

.palette__btn {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: var(--small);
  background: transparent;
  border: 2px solid var(--black);
  border-radius: var(--radius-lg);
  color: var(--black);
  cursor: pointer;
  transition: all 0.15s;
  font-family: var(--font);
}

.palette__btn:hover {
  background: var(--primary);
  border-color: var(--primary);
  color: var(--white);
}

/* Featured palette action (Templates) — yellow, like the primary button */
.palette__btn--featured {
  background: var(--secondary);
  border-color: var(--secondary);
  color: var(--primary);
}

.palette__btn--featured:hover {
  background: var(--primary);
  border-color: var(--primary);
  color: var(--white);
}

.palette__separator {
  height: 1px;
  background: rgba(78, 78, 255, 0.15);
  margin: var(--small) 2px;
}

.palette__icon {
  flex-shrink: 0;
}

.palette__label {
  font-size: var(--fs-sm);
  font-weight: 600;
  text-transform: uppercase;
}

/* Layouts: visual presets picked by their shape, not by name — a 3-column grid
   of icon buttons (so 5 presets wrap 3 + 2). */
.palette__grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 6px;
}

.palette__layout-btn {
  aspect-ratio: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  border: 2px solid var(--black);
  border-radius: var(--radius-sm);
  background: transparent;
  color: var(--black);
  cursor: pointer;
  transition: all 0.15s;
}

.palette__layout-btn:hover {
  background: var(--primary);
  border-color: var(--primary);
  color: var(--white);
}

/* --- Outline drawer (slides over the canvas's left edge) --- */

/* The pull-tab handle: protrudes from the drawer's right edge, so it travels with
   the drawer (closed → sits at the canvas's left edge; open → rides at the drawer's
   edge). It's the sole open/close control — the chevron flips when open. */
.outline-drawer__handle {
  position: absolute;
  /* -2px so the handle's top edge lines up with the drawer's outer top border
     (absolute offsets are measured from inside the drawer's 2px border). */
  top: -2px;
  right: -28px;
  width: 28px;
  height: 44px;
  display: flex;
  align-items: center;
  justify-content: center;
  border: 2px solid var(--border);
  border-left: none;
  border-radius: 0 var(--radius-sm) var(--radius-sm) 0;
  background: var(--bg);
  color: var(--primary);
  cursor: pointer;
  transition: all 0.15s;
}

.outline-drawer__handle:hover {
  background: var(--primary);
  color: var(--white);
}

.outline-drawer__handle svg {
  transition: transform 0.18s ease;
}

.outline-drawer--open .outline-drawer__handle svg {
  transform: rotate(180deg);
}

/* The drawer: docked to the builder's left edge, inset from top and bottom so it
   reads as a floating panel (top aligns with the handle). The left edge is flush
   against the canvas (no left border); the free bottom-right corner is rounded.
   The builder clips it (overflow: hidden), so the hidden state never spills. */
.outline-drawer {
  position: absolute;
  top: var(--large);
  bottom: var(--large);
  left: 0;
  width: 240px;
  z-index: 20;
  display: flex;
  flex-direction: column;
  background: var(--bg);
  border: 2px solid var(--border);
  border-left: none;
  border-radius: 0 0 var(--radius-md) 0;
  transform: translateX(-100%);
  transition: transform 0.18s ease;
}

.outline-drawer--open {
  transform: translateX(0);
  /* box-shadow: 4px 0 16px rgba(0, 0, 0, 0.08); */
}

.outline-drawer__body {
  position: relative;
  flex: 1;
  min-height: 0;
  overflow-y: auto;
  padding: var(--small);
}

/* --- Outline (page tree) --- */

.outline {
  width: calc(100% - 16px);
  display: flex;
  flex-direction: column;
  /* gap: 6px; */
}

/* Each section + its children sit in a light-blue card, matching the grouped
   panels in the inspector. */
.outline__group {
  background: var(--bg);
  border-radius: var(--radius-md);
  /* padding: 4px; */
}

.outline__row {
  position: relative;
  display: flex;
  align-items: center;
  gap: 4px;
  padding: 5px 8px;
  border-radius: var(--radius-sm);
  cursor: pointer;
  font-size: var(--fs-sm);
  color: var(--black);
  white-space: nowrap;
  overflow: hidden;
  transition: background 0.1s;
}

.outline__row:not(.outline__row--selected):hover {
  background: rgba(78, 78, 255, 0.1);
  color: var(--black);
}

.outline__row--selected {
  background: var(--primary);
  color: var(--white);
}

/* Sections are the page's top-level structure — weight them up from their blocks. */
.outline__row--section {
  font-weight: 600;
}

/* Drag-to-reorder feedback (accent, like the canvas drop indicator): a line at
   the row's edge for a before/after drop, a dashed ring for a drop-inside. */
.outline__row--drop-before {
  box-shadow: inset 0 2px 0 var(--accent);
}

.outline__row--drop-after {
  box-shadow: inset 0 -2px 0 var(--accent);
}

.outline__row--drop-into {
  outline: 2px dashed var(--accent);
  outline-offset: -2px;
}

.outline__twisty {
  flex-shrink: 0;
  width: 12px;
  text-align: center;
  font-size: 9px;
  opacity: 0.7;
}

.outline__twisty--active:hover {
  opacity: 1;
}

.outline__label {
  flex: 1;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
}

/* Drag handle: hidden until the row is hovered, so draggable rows advertise that
   they can be grabbed (cells and Page have no grip). */
.outline__row[draggable="true"] {
  cursor: grab;
}

.outline__row[draggable="true"]:active {
  cursor: grabbing;
}

/* Hover action cluster, anchored to the row's right edge. Hidden (and click-
   through) until the row is hovered. Its background matches the row's state so it
   cleanly covers the label tail beneath it. */
.outline__actions {
  position: absolute;
  right: 4px;
  top: 0;
  bottom: 0;
  display: flex;
  align-items: center;
  gap: 2px;
  padding-left: 10px;
  background: var(--bg);
  opacity: 0;
  pointer-events: none;
}

.outline__row:hover .outline__actions {
  opacity: 1;
  pointer-events: auto;
}

.outline__row:not(.outline__row--selected):hover .outline__actions {
  background: color-mix(in srgb, var(--primary) 10%, var(--bg));
}

.outline__row--selected .outline__actions {
  background: var(--primary);
}

.outline__action {
  flex-shrink: 0;
  width: 18px;
  height: 18px;
  display: flex;
  align-items: center;
  justify-content: center;
  border: none;
  background: none;
  color: currentColor;
  font-family: var(--font);
  font-size: var(--fs-md);
  line-height: 1;
  cursor: pointer;
  opacity: 0.7;
}

.outline__action:hover {
  opacity: 1;
}

.outline__action--del:hover {
  color: var(--accent);
}

.outline__grip {
  flex-shrink: 0;
  padding-left: 2px;
  letter-spacing: -2px;
  color: currentColor;
  opacity: 0.5;
  cursor: grab;
}

/* --- Builder --- */

/* --- Canvas Area (wrapper, consistent with Studio/Animation Station) --- */

.canvas-area {
  grid-row: 1;
  display: flex;
  min-height: 0;
  min-width: 0;
  padding: 0 var(--medium);
  position: relative;
}

/* Floating output controls (Preview / Source), like Studio's canvas controls */
.canvas-controls {
  position: absolute;
  bottom: var(--medium);
  left: 50%;
  transform: translateX(-50%);
  display: flex;
  gap: var(--small);
  background: var(--white);
  /* border: 2px solid var(--primary); */
  border-radius: var(--radius-md);
  padding: var(--small);
  z-index: 10;
}

/* --- Builder (the framed canvas stage) --- */

.builder {
  flex: 1;
  min-height: 0;
  background: var(--bg);
  border: 2px solid var(--border);
  border-radius: var(--radius-lg);
  overflow: hidden;
  position: relative;
  display: flex;
}

/* The live canvas: an iframe rendering the real exported page. */
.canvas-frame {
  flex: 1;
  width: 100%;
  height: 100%;
  border: none;
  display: block;
  background: var(--white);
}

.builder__empty {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  height: 100%;
  gap: var(--medium);
  opacity: 0.5;
}

.builder__empty-text {
  font-size: var(--fs-md);
  color: #888;
  text-align: center;
}

.builder__fields {
  display: flex;
  flex-direction: column;
  gap: var(--medium);
  max-width: 700px;
  margin: 0 auto;
}

/* --- Field Tabs --- */

/* Segmented buttons, matching .share-tabs in shared.css */
.field-tabs {
  display: inline-flex;
  align-self: flex-start;
  border: 2px solid var(--primary);
  border-radius: var(--radius-sm);
  overflow: hidden;
  margin-top: var(--medium);
  margin-bottom: var(--medium);
}

.field-tabs__btn {
  font-family: var(--font);
  font-size: var(--fs-sm);
  font-weight: 700;
  text-transform: uppercase;
  padding: var(--small) var(--medium);
  border: none;
  border-right: 2px solid var(--primary);
  background: var(--white);
  color: var(--primary);
  cursor: pointer;
  transition: all 0.15s;
}

.field-tabs__btn:last-child {
  border-right: none;
}

.field-tabs__btn:hover:not(.field-tabs__btn--active) {
  background: var(--bg);
}

.field-tabs__btn--active {
  background: var(--primary);
  color: var(--white);
}

.field-tabs__panel {
  display: none;
}

.field-tabs__panel--active {
  display: block;
}

/* --- Property Editors --- */

.prop {
  margin-top: var(--small);
  background: var(--bg);
  padding: var(--small);
  border-radius: var(--radius-sm);
}

/* Horizontal variant: label + control on one row (compact; Page panel). */
.prop--row {
  display: flex;
  align-items: center;
  gap: var(--small);
}

.prop--row .prop__label {
  margin-bottom: 0;
  flex-shrink: 0;
  min-width: 104px;
}

.prop--row .prop__select {
  flex: 1;
  width: 100%;
  padding: 4px 6px;
}

/* Disabled control (e.g. Bold on a single-weight font) + its explainer note. */
.prop--disabled {
  opacity: 0.6;
}

.prop__toggle:disabled {
  cursor: default;
}

.prop__note {
  font-size: 10px;
  color: #888;
  line-height: 1.4;
  margin-top: var(--small);
}

/* Compact number + unit (e.g. type sizes): fixed-width box then "px". */
.prop__num {
  width: 64px;
  font-family: var(--font);
  font-size: var(--fs-md);
  padding: 4px 6px;
  border: 2px solid rgba(78, 78, 255, 0.2);
  border-radius: var(--radius-sm);
  background: var(--white);
  color: var(--black);
  outline: none;
}

.prop__num:focus {
  border-color: var(--primary);
}

.prop__unit {
  font-size: var(--fs-sm);
  color: #888;
}

.prop__label {
  font-size: var(--fs-sm);
  font-weight: 600;
  text-transform: uppercase;
  color: var(--black);
  margin-bottom: var(--small);
  display: block;
}

.prop__input {
  width: 100%;
  font-family: var(--font);
  font-size: var(--fs-sm);
  padding: 6px 10px;
  border: 2px solid rgba(78, 78, 255, 0.2);
  border-radius: var(--radius-sm);
  background: var(--white);
  color: var(--black);
  outline: none;
  transition: border-color 0.15s;
}

.prop__input:focus {
  border-color: var(--primary);
}

/* Numeric input + unit label (e.g. divider height in px). */
.prop__number {
  display: flex;
  align-items: center;
  gap: 6px;
}

.prop__input--number {
  width: 80px;
}

.prop__unit {
  font-family: var(--font);
  font-size: var(--fs-sm);
  color: var(--black);
}

.prop__select {
  width: auto;
  font-family: var(--font);
  font-size: var(--fs-sm);
  padding: 6px 10px;
  border: 2px solid rgba(78, 78, 255, 0.2);
  border-radius: var(--radius-sm);
  background: var(--white);
  color: var(--black);
  outline: none;
  cursor: pointer;
}

.prop__textarea {
  width: 100%;
  font-family: var(--font);
  font-size: var(--fs-md);
  padding: 6px 10px;
  border: 2px solid rgba(78, 78, 255, 0.2);
  border-radius: var(--radius-sm);
  background: var(--white);
  color: var(--black);
  outline: none;
  resize: vertical;
  min-height: 60px;
  transition: border-color 0.15s;
}

.prop__textarea:focus {
  border-color: var(--primary);
}

/* Toggle buttons (alignment, heading level) */

/* Outlined segmented control — white-filled buttons split by primary
   dividers inside a primary border. */
.prop__toggles {
  display: flex;
  gap: 0;
  border: 2px solid var(--primary);
  border-radius: var(--radius-sm);
  overflow: hidden;
}

.prop__toggle {
  flex: 1;
  font-family: var(--font);
  font-size: var(--fs-sm);
  font-weight: 600;
  padding: 4px 12px;
  border: none;
  border-right: 1px solid var(--primary);
  background: var(--white);
  color: var(--black);
  cursor: pointer;
  transition: all 0.15s;
}

.prop__toggle:last-child {
  border-right: none;
}

.prop__toggle:hover:not(.prop__toggle--active) {
  background: var(--border);
  color: var(--white);
}

.prop__toggle--active {
  background: var(--primary);
  color: var(--white);
}

/* Color chooser */

.color-chooser {
  display: flex;
  flex-direction: column;
  gap: 8px;
  width: 100%;
}

.color-chooser__vars {
  display: flex;
  flex-wrap: wrap;
  gap: 4px;
}

.color-chooser__var-btn {
  display: flex;
  align-items: center;
  gap: 4px;
  font-family: var(--font);
  font-size: 10px;
  font-weight: 600;
  padding: 4px 8px;
  border: 2px solid rgba(78, 78, 255, 0.2);
  border-radius: var(--radius-sm);
  background: var(--white);
  color: var(--black);
  cursor: pointer;
  transition: all 0.15s;
}

.color-chooser__var-btn--none {
  align-self: flex-start;
}

.color-chooser__var-btn:hover {
  border-color: var(--primary);
}

.color-chooser__var-btn--active {
  border-color: var(--primary);
}

.color-chooser__var-dot {
  width: 12px;
  height: 12px;
  border-radius: 50%;
  border: 1px solid rgba(0, 0, 0, 0.15);
  flex-shrink: 0;
}

.color-chooser__hex {
  font-family: var(--font);
  font-size: var(--fs-sm);
  width: 80px;
  padding: 4px 6px;
  border: 2px solid rgba(78, 78, 255, 0.2);
  border-radius: var(--radius-sm);
  outline: none;
}

.color-chooser__hex:focus {
  border-color: var(--primary);
}

/* Active = this field is using a custom color, echoing the primary highlight on
   an active variable button. Outline (not border) so there's no layout shift. */
.color-chooser__hex--active {
  border-color: var(--primary);
}

/* Collapsed trigger: one row showing the current color + its name/hex. The full
   set of choices (variables + custom picker) opens in .color-popover on click. */
.color-chooser__swatch {
  display: flex;
  align-items: center;
  gap: 8px;
  width: 100%;
  font-family: var(--font);
  font-size: var(--fs-sm);
  font-weight: 600;
  padding: 6px 8px;
  border: 2px solid rgba(78, 78, 255, 0.2);
  border-radius: var(--radius-sm);
  background: var(--white);
  color: var(--black);
  cursor: pointer;
  transition: border-color 0.15s;
}

.color-chooser__swatch:hover,
.color-chooser__swatch--open {
  border-color: var(--primary);
}

.color-chooser__swatch-dot {
  width: 20px;
  height: 20px;
  border-radius: var(--radius-sm);
  border: 1px solid rgba(0, 0, 0, 0.15);
  flex-shrink: 0;
}

/* No color / unset: a slashed empty chip, so "None" reads differently from black. */
.color-chooser__swatch-dot--empty {
  background:
    linear-gradient(
      45deg,
      transparent 44%,
      #e23b3b 45%,
      #e23b3b 55%,
      transparent 56%
    ),
    var(--white);
}

.color-chooser__swatch-text {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

/* Floating popover, mounted on <body> so the scrolling inspector never clips it.
   Positioned in JS; it starts off-screen here so the first paint never flashes. */
.color-popover {
  position: fixed;
  top: 0;
  left: -9999px;
  z-index: 1000;
  width: 232px;
  padding: 10px;
  background: var(--white);
  border: 2px solid var(--primary);
  border-radius: var(--radius-md);
  box-shadow: 0 8px 24px rgba(10, 10, 15, 0.18);
}

.color-popover__content {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

/* Section headings inside the popover ("Color Variable" / "Custom Color"). */
.color-popover__label {
  font-size: var(--fs-sm);
  font-weight: 600;
  text-transform: uppercase;
  color: var(--black);
}

/* Pull each heading closer to the group it labels than to the group above it. */
.color-popover__label + * {
  margin-top: -2px;
}
.color-popover__label:not(:first-child) {
  margin-top: 4px;
}

/* Custom inline picker: saturation/value square + hue slider. Hand-built because
   the native <input type=color> can only open as a separate, unstyleable OS
   dialog. Dragging either control selects a custom color. */
.cpick {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.cpick__area {
  position: relative;
  width: 100%;
  height: 130px;
  border-radius: var(--radius-sm);
  cursor: crosshair;
  touch-action: none;
}

.cpick__hue {
  position: relative;
  width: 100%;
  height: 14px;
  border-radius: 999px;
  cursor: pointer;
  touch-action: none;
  background: linear-gradient(
    to right,
    #f00 0%,
    #ff0 17%,
    #0f0 33%,
    #0ff 50%,
    #00f 67%,
    #f0f 83%,
    #f00 100%
  );
}

.cpick__area-thumb,
.cpick__hue-thumb {
  position: absolute;
  width: 14px;
  height: 14px;
  border-radius: 50%;
  border: 2px solid var(--white);
  box-shadow: 0 0 0 1px rgba(0, 0, 0, 0.35);
  transform: translate(-50%, -50%);
  pointer-events: none;
}

.cpick__hue-thumb {
  top: 50%;
}

/* Size chooser */

.size-chooser {
  display: flex;
  flex-wrap: wrap;
  gap: 4px;
}

.size-chooser__var-btn {
  display: flex;
  align-items: center;
  gap: 4px;
  font-family: var(--font);
  font-size: 10px;
  font-weight: 600;
  padding: 4px 8px;
  border: 2px solid rgba(78, 78, 255, 0.2);
  border-radius: var(--radius-sm);
  background: transparent;
  color: var(--black);
  cursor: pointer;
  transition: all 0.15s;
}

.size-chooser__var-btn:hover {
  border-color: var(--primary);
}

.size-chooser__var-btn--active {
  border-color: var(--primary);
  background: var(--bg);
}

/* Image upload */

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

.prop__upload-btn {
  font-family: var(--font);
  font-size: var(--fs-sm);
  font-weight: 600;
  text-transform: uppercase;
  padding: 6px 12px;
  border: 2px solid var(--primary);
  border-radius: var(--radius-sm);
  background: transparent;
  color: var(--primary);
  cursor: pointer;
  transition: all 0.15s;
  white-space: nowrap;
}

.prop__upload-btn:hover {
  background: var(--primary);
  color: var(--white);
}

.prop__file-name {
  font-size: var(--fs-sm);
  color: #888;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.prop__image-preview {
  max-width: 80px;
  max-height: 60px;
  border-radius: var(--radius-sm);
  border: 1px solid rgba(78, 78, 255, 0.2);
  margin-top: var(--small);
}

/* --- Layout Editor --- */

.layout-editor__hint {
  font-size: var(--fs-sm);
  color: #999;
  margin-top: var(--medium);
  line-height: 1.4;
}

/* --- Settings Panel --- */

.settings {
  gap: var(--medium);
  padding: var(--medium);
}

.settings::-webkit-scrollbar {
  width: 4px;
}

.settings::-webkit-scrollbar-thumb {
  background: var(--primary);
  border-radius: 2px;
}

.settings__row {
  margin-bottom: 12px;
}

.settings__label {
  display: block;
  font-size: var(--fs-sm);
  font-weight: 600;
  text-transform: uppercase;
  color: var(--black);
  margin-bottom: var(--small);
}

.settings__input {
  width: 100%;
  font-family: var(--font);
  font-size: var(--fs-md);
  padding: 6px 10px;
  border: 2px solid rgba(78, 78, 255, 0.2);
  border-radius: var(--radius-sm);
  background: var(--white);
  color: var(--black);
  outline: none;
}

.settings__input:focus {
  border-color: var(--primary);
}

.settings__select {
  width: 100%;
  font-family: var(--font);
  font-size: var(--fs-md);
  padding: 6px 10px;
  border: 2px solid rgba(78, 78, 255, 0.2);
  border-radius: var(--radius-sm);
  background: var(--white);
  color: var(--black);
  outline: none;
  cursor: pointer;
}

.settings__color-row {
  display: flex;
  gap: 6px;
  align-items: center;
}

.settings__color-picker {
  width: 36px;
  height: 30px;
  border: 2px solid rgba(78, 78, 255, 0.2);
  border-radius: var(--radius-sm);
  padding: 0;
  cursor: pointer;
  background: none;
}

.settings__hex-input {
  flex: 1;
  font-family: var(--font);
  font-size: var(--fs-sm);
  padding: 5px 8px;
  border: 2px solid rgba(78, 78, 255, 0.2);
  border-radius: var(--radius-sm);
  outline: none;
}

.settings__hex-input:focus {
  border-color: var(--primary);
}

.settings__hint {
  font-size: var(--fs-sm);
  color: #999;
  margin-bottom: var(--medium);
  line-height: 1.4;
}

/* Variable items in settings */

.variable-item {
  display: flex;
  align-items: center;
  gap: 6px;
  margin-top: var(--small);
  background: var(--bg);
  padding: var(--small);
  border-radius: var(--radius-sm);
}

.variable-item__name {
  font-size: var(--fs-sm);
  font-weight: 600;
  color: var(--black);
  min-width: 80px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.variable-item__value {
  flex: 1;
  display: flex;
  align-items: center;
  gap: 4px;
}

.variable-item__delete {
  font-family: var(--font);
  font-size: var(--fs-md);
  background: none;
  border: none;
  color: #ccc;
  cursor: pointer;
  padding: 0 2px;
  flex-shrink: 0;
}

.variable-item__delete:hover {
  color: var(--accent);
}

/* --- Toast --- */

.toast {
  position: fixed;
  bottom: 20px;
  left: 50%;
  transform: translateX(-50%) translateY(100px);
  font-family: var(--font);
  font-size: var(--fs-sm);
  font-weight: 600;
  padding: 10px 20px;
  border-radius: var(--radius-md);
  background: var(--black);
  color: var(--white);
  z-index: 2000;
  transition: transform 0.3s ease;
  pointer-events: none;
}

.toast--visible {
  transform: translateX(-50%) translateY(0);
}

/* --- Scrollbar (builder) --- */

.builder::-webkit-scrollbar {
  width: 6px;
}

.builder::-webkit-scrollbar-thumb {
  background: rgba(78, 78, 255, 0.3);
  border-radius: 3px;
}

.builder::-webkit-scrollbar-thumb:hover {
  background: rgba(78, 78, 255, 0.5);
}

/* ============================================================
   INSPECTOR (right panel) — folder tabs (the selection path) hanging
   the bordered card below them. The column is a flex stack: the tab row
   stays put while .inspector__scroll (the card) scrolls. The current
   tab connects into the card; ancestor tabs sit closed beside it.
   ============================================================ */

.inspector {
  /* Override .right-panel's scroll: the card scrolls, the tabs stay put. */
  overflow: hidden;
  gap: 0;
  padding: 0;
}

.inspector__tabs {
  display: flex;
  flex-wrap: wrap;
  align-items: flex-end;
  gap: 4px;
  flex-shrink: 0;
}

.inspector__tab {
  font-family: var(--font);
  font-size: var(--fs-sm);
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  padding: var(--small) var(--medium);
  border: 2px solid var(--border);
  border-bottom: none;
  border-radius: var(--radius-md) var(--radius-md) 0 0;
  background: var(--bg);
  color: var(--primary);
  cursor: pointer;
}

.inspector__tab:hover:not(.inspector__tab--active) {
  background: var(--white);
}

/* The front tab: white like the card and dipped 2px down so it covers the
   card's top border beneath it — the "open folder" connection. */
.inspector__tab--active {
  background: var(--white);
  color: var(--black);
  margin-bottom: -2px;
  position: relative;
  z-index: 1;
  cursor: default;
}

/* The card frame: clips its content (and the overlay scrollbar) to the rounded
   corners. Flat top so the tabs sit on a straight edge and the active tab
   connects anywhere along it; rounded only at the bottom. */
.inspector__scroll {
  position: relative;
  flex: 1;
  min-height: 0;
  display: flex;
  flex-direction: column;
  background: var(--white);
  border: 2px solid var(--border);
  border-radius: 0 var(--radius-lg) var(--radius-lg) var(--radius-lg);
  overflow: hidden;
}

/* The actual scroller inside the frame; its native bar is hidden (.osb-hide-
   native) and replaced by the custom overlay thumb (see attachOverlayScrollbar). */
.inspector__scroll-inner {
  flex: 1;
  min-height: 0;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: var(--medium);
  padding: var(--medium);
}

.inspector__body {
  display: flex;
  flex-direction: column;
  gap: var(--medium);
}

/* ============================================================
   OVERLAY SCROLLBAR — one custom scrollbar used everywhere (inspector,
   palette, canvas) so they all match across browsers. The native bar is
   hidden and a thin thumb is drawn over the content's right edge, so it
   never steals layout width (no reflow, nothing reserved). See
   attachOverlayScrollbar in app.js. The canvas iframe carries a matching
   copy of .osb-thumb in canvasChromeHead.
   ============================================================ */
.osb-hide-native {
  scrollbar-width: none; /* Firefox */
  -ms-overflow-style: none; /* legacy Edge */
}

.osb-hide-native::-webkit-scrollbar {
  width: 0;
  height: 0;
  display: none; /* Chrome / Safari / Edge */
}

.osb-thumb {
  position: absolute;
  width: 4px;
  right: 3px;
  border-radius: 4px;
  background: color-mix(in srgb, var(--primary) 35%, transparent);
  cursor: grab;
  pointer-events: auto;
  z-index: 50;
  transition: background 0.15s;
}

.osb-thumb:hover,
.osb-thumb:active {
  background: color-mix(in srgb, var(--primary) 60%, transparent);
}

.osb-thumb:active {
  cursor: grabbing;
}

.inspector__empty {
  font-size: var(--fs-sm);
  color: #888;
  line-height: 1.5;
  padding: var(--small) 0;
}

/* Palette hint under the title */
.palette__hint {
  font-size: 10px;
  color: #888;
  line-height: 1.4;
  margin: -2px 0 4px;
}
