/* ==========================================================================
   Studio Preview Rumah — Modern Architectural Theme
   Follows modern-web-guidance: color-scheme + light-dark() + accessible toolbar
   ========================================================================== */

:root {
  color-scheme: light dark;

  &:has(> head > meta[name="color-scheme"][content="dark"]) {
    color-scheme: dark;
  }
  &:has(> head > meta[name="color-scheme"][content="light"]) {
    color-scheme: light;
  }

  /* Semantic architectural color tokens */
  --bg-app: light-dark(#f4f2ed, #111315);
  --bg-surface: light-dark(#ffffff, #181b1f);
  --bg-elevated: light-dark(#faf9f6, #20242a);
  --bg-canvas: light-dark(#ece9e1, #0d0f12);

  --text-primary: light-dark(#1a1d1f, #f1f3f5);
  --text-secondary: light-dark(#525860, #a0a8b0);
  --text-muted: light-dark(#767e87, #6f7782);

  --border-subtle: light-dark(rgba(26, 29, 31, 0.1), rgba(255, 255, 255, 0.09));
  --border-strong: light-dark(rgba(26, 29, 31, 0.2), rgba(255, 255, 255, 0.18));

  /* Architectural forest green & warm terracotta accents */
  --accent: light-dark(#1b4d3e, #4cb897);
  --accent-soft: light-dark(rgba(27, 77, 62, 0.12), rgba(76, 184, 151, 0.16));
  --accent-text: light-dark(#ffffff, #0b1914);
  --warm: light-dark(#c85a32, #e8845c);
  --warm-soft: light-dark(rgba(200, 90, 50, 0.12), rgba(232, 132, 92, 0.16));

  --shadow-sm: light-dark(0 1px 3px rgba(0, 0, 0, 0.06), 0 1px 3px rgba(0, 0, 0, 0.35));
  --shadow-md: light-dark(0 6px 20px rgba(0, 0, 0, 0.08), 0 8px 24px rgba(0, 0, 0, 0.45));

  --radius-sm: 6px;
  --radius-md: 10px;
  --radius-lg: 14px;

  --header-height: 60px;
  --sidebar-width: 340px;

  --font-sans: 'Inter', system-ui, -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
  --font-mono: 'JetBrains Mono', ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
}

*, *::before, *::after {
  box-sizing: border-box;
}

[hidden] {
  display: none !important;
}

html, body {
  margin: 0;
  padding: 0;
  height: 100%;
  font-family: var(--font-sans);
  background-color: var(--bg-app);
  color: var(--text-primary);
  -webkit-font-smoothing: antialiased;
  overflow: hidden;
}

.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

.mono {
  font-family: var(--font-mono);
  font-variant-numeric: tabular-nums;
}

/* App Shell Layout */
.app-shell {
  display: flex;
  flex-direction: column;
  height: 100dvh;
  width: 100%;
}

/* Header */
.app-header {
  height: var(--header-height);
  flex-shrink: 0;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 0 16px;
  background-color: var(--bg-surface);
  border-bottom: 1px solid var(--border-subtle);
  z-index: 20;
}

.brand {
  display: flex;
  align-items: center;
  gap: 10px;
  min-width: 0;
}

.brand-mark {
  width: 34px;
  height: 34px;
  border-radius: var(--radius-sm);
  background-color: var(--accent);
  color: var(--accent-text);
  display: grid;
  place-items: center;
  flex-shrink: 0;
}

.brand-text {
  display: flex;
  align-items: center;
  gap: 10px;
  min-width: 0;
}

.brand-text h1 {
  margin: 0;
  font-size: 0.95rem;
  font-weight: 600;
  letter-spacing: -0.01em;
  white-space: nowrap;
}

.phase-pill {
  font-size: 0.72rem;
  font-weight: 500;
  padding: 3px 8px;
  border-radius: 999px;
  background-color: var(--accent-soft);
  color: var(--accent);
  white-space: nowrap;
}

.header-controls {
  display: flex;
  align-items: center;
  gap: 8px;
  min-width: 0;
}

/* Accessible Toolbar */
.main-toolbar {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 4px;
  background-color: var(--bg-elevated);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-md);
  overflow-x: auto;
  scrollbar-width: none;
}

.main-toolbar::-webkit-scrollbar {
  display: none;
}

.main-toolbar [role="group"] {
  display: flex;
  align-items: center;
  gap: 2px;
}

.main-toolbar [role="separator"] {
  inline-size: 1px;
  block-size: 20px;
  border-inline-start: 1px solid var(--border-strong);
  margin: 0 2px;
  flex-shrink: 0;
}

.main-toolbar button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  min-inline-size: 32px;
  min-block-size: 32px;
  padding: 0 10px;
  border: 1px solid transparent;
  border-radius: var(--radius-sm);
  background: transparent;
  color: var(--text-secondary);
  font-family: inherit;
  font-size: 0.8rem;
  font-weight: 500;
  cursor: pointer;
  white-space: nowrap;
}

@media (prefers-reduced-motion: no-preference) {
  .main-toolbar button,
  .seg-btn,
  .theme-btn,
  .icon-btn {
    transition: background-color 140ms ease, color 140ms ease, border-color 140ms ease;
  }
}

@media (hover: hover) {
  .main-toolbar button:hover:not([aria-pressed="true"]) {
    background-color: var(--border-subtle);
    color: var(--text-primary);
  }
}

.main-toolbar button:focus-visible,
.seg-btn:focus-visible,
.theme-btn:focus-visible,
.icon-btn:focus-visible,
#btn-compass:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

.main-toolbar button[aria-pressed="true"] {
  background-color: var(--accent);
  color: var(--accent-text);
  border-color: var(--accent);
  box-shadow: var(--shadow-sm);
}

.zoom-label {
  font-family: var(--font-mono);
  font-size: 0.75rem;
  min-inline-size: 40px;
  text-align: center;
}

@media (pointer: coarse) {
  .main-toolbar button {
    min-inline-size: 40px;
    min-block-size: 40px;
  }
}

@media (forced-colors: active) {
  .main-toolbar button[aria-pressed="true"] {
    background-color: Highlight;
    color: HighlightText;
    border-color: Highlight;
  }
  .main-toolbar [role="separator"] {
    border-inline-start-color: ButtonText;
  }
}

/* Main Workspace */
.workspace {
  flex: 1;
  display: flex;
  min-height: 0;
  position: relative;
}

/* Stage Canvas Area */
.stage-container {
  flex: 1;
  position: relative;
  background-color: var(--bg-canvas);
  overflow: hidden;
  min-width: 0;
}

#land-canvas {
  display: block;
  width: 100%;
  height: 100%;
  cursor: grab;
  touch-action: none;
}

#land-canvas:active {
  cursor: grabbing;
}

#land-canvas.mode-measure {
  cursor: crosshair;
}

/* Floating Stage HUDs */
.stage-hud-top {
  position: absolute;
  top: 14px;
  left: 14px;
  right: 76px;
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  pointer-events: none;
}

.hud-chip {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 6px 12px;
  border-radius: 999px;
  background-color: var(--bg-surface);
  border: 1px solid var(--border-subtle);
  box-shadow: var(--shadow-sm);
  font-size: 0.76rem;
  font-weight: 500;
  color: var(--text-secondary);
  pointer-events: auto;
}

.hud-chip .dot {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background-color: var(--accent);
}

.hud-measure-chip {
  border-color: var(--warm);
  color: var(--text-primary);
}

.chip-clear {
  border: none;
  background: var(--warm-soft);
  color: var(--warm);
  font-size: 0.72rem;
  font-weight: 600;
  padding: 2px 8px;
  border-radius: 999px;
  cursor: pointer;
}

.compass-widget {
  position: absolute;
  top: 14px;
  right: 14px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
}

#btn-compass {
  width: 52px;
  height: 52px;
  border-radius: 50%;
  border: 1px solid var(--border-subtle);
  background-color: var(--bg-surface);
  color: var(--text-primary);
  box-shadow: var(--shadow-sm);
  display: grid;
  place-items: center;
  cursor: pointer;
  padding: 0;
}

#compass-svg {
  will-change: transform;
}

.compass-deg {
  font-family: var(--font-mono);
  font-size: 0.68rem;
  color: var(--text-secondary);
  background-color: var(--bg-surface);
  padding: 2px 6px;
  border-radius: 4px;
  border: 1px solid var(--border-subtle);
}

.stage-hud-bottom {
  position: absolute;
  bottom: 14px;
  left: 50%;
  transform: translateX(-50%);
  padding: 6px 14px;
  border-radius: 999px;
  background-color: var(--bg-surface);
  border: 1px solid var(--border-subtle);
  box-shadow: var(--shadow-sm);
  font-size: 0.74rem;
  color: var(--text-secondary);
  white-space: nowrap;
  max-width: calc(100% - 28px);
  overflow: hidden;
  text-overflow: ellipsis;
  pointer-events: none;
}

/* Sidebar */
.sidebar {
  width: var(--sidebar-width);
  flex-shrink: 0;
  background-color: var(--bg-surface);
  border-left: 1px solid var(--border-subtle);
  display: flex;
  flex-direction: column;
  min-height: 0;
  z-index: 15;
}

.sidebar-scroll {
  flex: 1;
  overflow-y: auto;
  padding: 16px;
  display: flex;
  flex-direction: column;
  gap: 20px;
}

.panel-section {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.section-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
}

.section-header h2 {
  margin: 0;
  font-size: 0.75rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--text-muted);
}

.tag-verified {
  font-size: 0.68rem;
  font-weight: 600;
  padding: 2px 7px;
  border-radius: 4px;
  background-color: var(--accent-soft);
  color: var(--accent);
}

/* Hero Area Card */
.hero-area-card {
  padding: 14px 16px;
  border-radius: var(--radius-md);
  background-color: var(--bg-elevated);
  border: 1px solid var(--border-subtle);
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.hero-area-label {
  font-size: 0.76rem;
  color: var(--text-secondary);
}

.hero-area-value {
  display: flex;
  align-items: baseline;
  gap: 6px;
}

.hero-area-value .num {
  font-family: var(--font-mono);
  font-size: 1.85rem;
  font-weight: 600;
  letter-spacing: -0.03em;
  color: var(--accent);
}

.hero-area-value .unit {
  font-size: 0.95rem;
  font-weight: 600;
  color: var(--text-secondary);
}

.hero-area-sub {
  font-size: 0.74rem;
  color: var(--text-muted);
}

/* Spec Grid */
.spec-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
  margin: 0;
}

.spec-item {
  padding: 10px 12px;
  border-radius: var(--radius-sm);
  background-color: var(--bg-elevated);
  border: 1px solid var(--border-subtle);
}

.spec-item dt {
  font-size: 0.7rem;
  color: var(--text-muted);
  margin-bottom: 4px;
}

.spec-item dd {
  margin: 0;
  font-size: 0.92rem;
  font-weight: 600;
  color: var(--text-primary);
}

/* Toggle Rows */
.toggle-list {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.toggle-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 9px 11px;
  border-radius: var(--radius-sm);
  background-color: var(--bg-elevated);
  border: 1px solid var(--border-subtle);
  cursor: pointer;
}

.toggle-copy {
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.toggle-copy strong {
  font-size: 0.82rem;
  font-weight: 500;
  color: var(--text-primary);
}

.toggle-copy small {
  font-size: 0.72rem;
  color: var(--text-muted);
}

.toggle-row input[type="checkbox"] {
  accent-color: var(--accent);
  width: 17px;
  height: 17px;
  cursor: pointer;
  flex-shrink: 0;
}

/* Setback Summary */
.setback-summary {
  padding: 10px 12px;
  border-radius: var(--radius-sm);
  background-color: var(--warm-soft);
  border: 1px solid color-mix(in srgb, var(--warm) 35%, transparent);
  display: flex;
  flex-direction: column;
  gap: 6px;
  font-size: 0.76rem;
}

.setback-row {
  display: flex;
  justify-content: space-between;
  gap: 8px;
  color: var(--text-secondary);
}

.setback-row.highlight {
  padding-top: 6px;
  border-top: 1px dashed var(--border-strong);
  color: var(--text-primary);
  font-weight: 600;
}

.setback-note {
  margin: 2px 0 0;
  font-size: 0.7rem;
  color: var(--text-muted);
  line-height: 1.4;
}

/* Segmented Control */
.segmented-control,
.theme-switcher {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 4px;
  padding: 4px;
  border-radius: var(--radius-sm);
  background-color: var(--bg-elevated);
  border: 1px solid var(--border-subtle);
}

.theme-switcher {
  grid-template-columns: repeat(3, 1fr);
}

.seg-btn,
.theme-btn {
  padding: 7px 8px;
  border: none;
  border-radius: 4px;
  background: transparent;
  color: var(--text-secondary);
  font-family: inherit;
  font-size: 0.76rem;
  font-weight: 500;
  cursor: pointer;
}

.seg-btn[aria-pressed="true"],
.theme-btn[aria-pressed="true"] {
  background-color: var(--bg-surface);
  color: var(--text-primary);
  box-shadow: var(--shadow-sm);
  font-weight: 600;
}

/* Roadmap */
.roadmap {
  list-style: none;
  margin: 0;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.roadmap-item {
  display: flex;
  align-items: flex-start;
  gap: 10px;
}

.step-dot {
  width: 22px;
  height: 22px;
  border-radius: 50%;
  display: grid;
  place-items: center;
  font-family: var(--font-mono);
  font-size: 0.72rem;
  font-weight: 600;
  flex-shrink: 0;
  margin-top: 1px;
}

.roadmap-item.is-active .step-dot {
  background-color: var(--accent);
  color: var(--accent-text);
}

.roadmap-item.is-upcoming .step-dot {
  background-color: var(--bg-elevated);
  border: 1px solid var(--border-strong);
  color: var(--text-muted);
}

.step-body strong {
  display: block;
  font-size: 0.82rem;
  font-weight: 600;
  color: var(--text-primary);
}

.roadmap-item.is-upcoming .step-body strong {
  color: var(--text-secondary);
  font-weight: 500;
}

.step-body p {
  margin: 2px 0 0;
  font-size: 0.74rem;
  color: var(--text-muted);
  line-height: 1.4;
}

/* Mobile Responsive */
.icon-btn {
  display: none;
  align-items: center;
  justify-content: center;
  width: 36px;
  height: 36px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border-subtle);
  background-color: var(--bg-elevated);
  color: var(--text-primary);
  cursor: pointer;
}

@media (max-width: 900px) {
  .brand-text .phase-pill {
    display: none;
  }

  .main-toolbar button span {
    display: none;
  }

  .main-toolbar .zoom-label {
    display: inline;
  }

  .mobile-only {
    display: inline-flex;
  }

  .sidebar {
    position: absolute;
    top: 0;
    right: 0;
    bottom: 0;
    width: min(340px, 88vw);
    box-shadow: var(--shadow-md);
    transform: translateX(100%);
    transition: transform 220ms cubic-bezier(0.22, 1, 0.36, 1);
  }

  .sidebar.is-open {
    transform: translateX(0);
  }
}

@media (max-width: 520px) {
  .brand-text h1 {
    font-size: 0.85rem;
  }
  .stage-hud-bottom {
    font-size: 0.68rem;
    padding: 5px 10px;
  }
}
