:root {
  color-scheme: light;
  --accent: #116dff;
  --accent-2: #5f2dff;
  --bg: #eef3fb;
  --panel: rgba(255, 255, 255, 0.86);
  --panel-solid: #ffffff;
  --card: #f7faff;
  --text: #1c2430;
  --muted: #617083;
  --border: rgba(17, 109, 255, 0.14);
  --shadow: 0 24px 80px rgba(15, 40, 80, 0.12);
  --sheet: #ffffff;
  --sheet-line: rgba(17, 109, 255, 0.09);
  --wall: #111827;
  --aux: #116dff;
  --wall-thickness: 4;
  --aux-thickness: 1.8;
  --zone-varanda: rgba(0, 174, 255, 0.08);
  --zone-quarto: rgba(114, 95, 255, 0.08);
  --zone-banheiro: rgba(49, 153, 120, 0.1);
  --zone-gourmet: rgba(255, 146, 43, 0.08);
  --zone-dispensa: rgba(255, 68, 99, 0.08);
  --dim-bg: rgba(255, 255, 255, 0.92);
  --dim-text: #116dff;
}

body.theme-dark {
  color-scheme: dark;
  --accent: #35d7ff;
  --accent-2: #9c7bff;
  --bg: #071019;
  --panel: rgba(13, 20, 31, 0.84);
  --panel-solid: #0e1620;
  --card: #121d2a;
  --text: #eef4fb;
  --muted: #96a9bc;
  --border: rgba(53, 215, 255, 0.14);
  --shadow: 0 24px 80px rgba(0, 0, 0, 0.45);
  --sheet: #0d1722;
  --sheet-line: rgba(53, 215, 255, 0.08);
  --wall: #f4f8ff;
  --aux: #35d7ff;
  --zone-varanda: rgba(53, 215, 255, 0.08);
  --zone-quarto: rgba(156, 123, 255, 0.08);
  --zone-banheiro: rgba(88, 207, 159, 0.08);
  --zone-gourmet: rgba(255, 173, 92, 0.08);
  --zone-dispensa: rgba(255, 97, 124, 0.08);
  --dim-bg: rgba(12, 22, 32, 0.92);
  --dim-text: #35d7ff;
}

* { box-sizing: border-box; }
html, body { min-height: 100%; }
body {
  margin: 0;
  font-family: Inter, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  color: var(--text);
  background:
    radial-gradient(circle at top left, rgba(17, 109, 255, 0.18), transparent 28%),
    radial-gradient(circle at bottom right, rgba(95, 45, 255, 0.14), transparent 22%),
    var(--bg);
  transition: background 220ms ease, color 220ms ease;
}

button, input { font: inherit; }
button { border: none; }

.app-shell {
  max-width: 1480px;
  margin: 0 auto;
  padding: 24px;
}

.panel {
  background: var(--panel);
  border: 1px solid var(--border);
  box-shadow: var(--shadow);
  backdrop-filter: blur(16px);
}

.app-header {
  display: flex;
  justify-content: space-between;
  gap: 20px;
  align-items: flex-start;
  padding: 24px 26px;
  border-radius: 28px;
  margin-bottom: 18px;
}

.eyebrow {
  margin: 0 0 10px;
  font-size: 0.8rem;
  line-height: 1;
  text-transform: uppercase;
  letter-spacing: 0.18em;
  color: var(--accent);
  font-weight: 800;
}

h1, h2, p { margin: 0; }
.app-header h1 {
  font-size: clamp(1.6rem, 2vw, 2.3rem);
  letter-spacing: -0.03em;
  margin-bottom: 10px;
}

.lead {
  max-width: 920px;
  color: var(--muted);
  line-height: 1.65;
}

.icon-btn {
  width: 52px;
  height: 52px;
  border-radius: 16px;
  background: linear-gradient(135deg, var(--accent), var(--accent-2));
  color: white;
  cursor: pointer;
  box-shadow: 0 18px 40px rgba(17, 109, 255, 0.22);
}

.layout-grid {
  display: grid;
  grid-template-columns: 320px minmax(0, 1fr);
  gap: 18px;
}

.sidebar,
.workspace {
  border-radius: 28px;
}

.sidebar {
  padding: 22px;
  position: sticky;
  top: 16px;
  height: fit-content;
  display: grid;
  gap: 22px;
}

.section-head {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 14px;
}

.section-head h2 {
  font-size: 0.84rem;
  text-transform: uppercase;
  letter-spacing: 0.12em;
  color: var(--accent);
}

.section-head span {
  width: 28px;
  height: 28px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border-radius: 999px;
  background: var(--card);
  color: var(--muted);
  font-size: 0.8rem;
  font-weight: 800;
}

.view-list,
.toggle-list,
.action-stack {
  display: grid;
  gap: 10px;
}

.view-card,
.toggle-chip,
.primary-btn,
.secondary-btn {
  width: 100%;
  text-align: left;
  cursor: pointer;
  border-radius: 18px;
  padding: 14px 16px;
  background: var(--card);
  border: 1px solid transparent;
  color: var(--text);
  transition: transform 180ms ease, border-color 180ms ease, background 180ms ease, color 180ms ease;
}

.view-card:hover,
.toggle-chip:hover,
.primary-btn:hover,
.secondary-btn:hover {
  transform: translateY(-1px);
  border-color: var(--border);
}

.view-card strong {
  display: block;
  margin-bottom: 4px;
  font-size: 0.98rem;
}

.view-card small,
.notes-card p,
.info-panel p,
.slider-field span,
.stage-toolbar small,
.status-badge,
.hint-list span,
code,
#viewDescription {
  color: var(--muted);
}

.view-card.active,
.toggle-chip.active,
.primary-btn {
  background: linear-gradient(135deg, var(--accent), var(--accent-2));
  color: #fff;
}

.view-card.active small,
.toggle-chip.active {
  color: rgba(255,255,255,0.84);
}

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

.toggle-chip {
  text-align: center;
  font-weight: 700;
}

.primary-btn,
.secondary-btn {
  text-align: center;
  font-weight: 800;
}

.secondary-btn {
  border: 1px solid var(--border);
}

.slider-field {
  display: grid;
  gap: 8px;
  margin-bottom: 12px;
}

.slider-field span {
  font-size: 0.78rem;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  font-weight: 700;
}

.slider-field input { width: 100%; }

.notes-card {
  padding: 18px;
  background: linear-gradient(180deg, rgba(17, 109, 255, 0.08), transparent), var(--card);
  border-radius: 20px;
  border: 1px solid var(--border);
}

.notes-card strong,
.info-panel strong {
  display: block;
  margin-bottom: 8px;
  color: var(--accent);
}

.workspace {
  padding: 24px;
}

.workspace-top {
  display: flex;
  justify-content: space-between;
  gap: 20px;
  align-items: flex-start;
  margin-bottom: 18px;
}

.workspace-top h2 {
  font-size: clamp(1.35rem, 1.8vw, 2rem);
  margin-bottom: 6px;
}

.badge-row {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  justify-content: flex-end;
}

.status-badge {
  display: inline-flex;
  align-items: center;
  min-height: 34px;
  padding: 0 12px;
  border-radius: 999px;
  background: var(--card);
  border: 1px solid var(--border);
  font-size: 0.84rem;
  font-weight: 700;
}

.drawing-stage {
  border-radius: 24px;
  overflow: hidden;
  border: 1px solid var(--border);
  background: linear-gradient(180deg, rgba(17, 109, 255, 0.06), transparent 24%), var(--card);
}

.stage-toolbar {
  display: flex;
  justify-content: space-between;
  gap: 14px;
  align-items: center;
  padding: 14px 18px;
  border-bottom: 1px solid var(--border);
}

.stage-toolbar strong {
  display: block;
  margin-bottom: 4px;
}

.hint-list {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
}

.hint-list span {
  display: inline-flex;
  align-items: center;
  min-height: 30px;
  padding: 0 10px;
  border-radius: 999px;
  background: var(--panel-solid);
  border: 1px solid var(--border);
  font-size: 0.75rem;
  font-weight: 700;
}

.stage-frame {
  padding: 18px;
}

.svg-host {
  display: none;
  border-radius: 20px;
  overflow: auto;
  background: var(--sheet);
  border: 1px solid var(--border);
}

.svg-host.active { display: block; }

svg {
  display: block;
  width: 100%;
  min-width: 780px;
  height: auto;
  background: var(--sheet);
}

.sheet-bg { fill: var(--sheet); }
.sheet-plate { fill: rgba(255,255,255,0.26); stroke: rgba(17, 109, 255, 0.1); }
.grid-line { stroke: var(--sheet-line); stroke-width: 1; }
.draft-grid { opacity: 0.45; }
.wall { stroke: var(--wall); stroke-width: var(--wall-thickness); fill: none; }
.aux { stroke: var(--aux); stroke-width: var(--aux-thickness); fill: none; }
.opening { stroke: var(--sheet); stroke-width: calc(var(--wall-thickness) + 2); }
.swing { stroke: var(--aux); stroke-width: 1.5; fill: none; stroke-dasharray: 6 5; }
.zone { stroke: rgba(17, 109, 255, 0.18); stroke-width: 1.2; }
.varanda { fill: var(--zone-varanda); }
.quarto { fill: var(--zone-quarto); }
.banheiro { fill: var(--zone-banheiro); }
.gourmet { fill: var(--zone-gourmet); }
.dispensa { fill: var(--zone-dispensa); }
.furniture { fill: rgba(17, 109, 255, 0.1); stroke: var(--aux); stroke-width: 1.5; }
.furniture.soft { fill: rgba(95, 45, 255, 0.08); }
.furniture-label { fill: var(--aux); font-size: 16px; font-weight: 800; }
.sheet-title { fill: var(--text); font-size: 28px; font-weight: 900; letter-spacing: 0.12em; }
.sheet-subtitle { fill: var(--muted); font-size: 18px; }
.room-label { fill: var(--text); font-size: 28px; font-weight: 900; letter-spacing: 0.04em; }
.room-label.vertical { writing-mode: vertical-rl; glyph-orientation-vertical: 0; }
.room-label.room-small { font-size: 22px; }
.room-note { fill: var(--muted); font-size: 16px; font-style: italic; }
.dimension-line { stroke: var(--aux); stroke-width: 1.4; fill: none; }
.dimension-box { fill: var(--dim-bg); stroke: var(--aux); stroke-width: 1.2; }
.dimension-text { fill: var(--dim-text); font-size: 16px; font-weight: 900; }
.info-card { fill: rgba(17, 109, 255, 0.05); stroke: rgba(17, 109, 255, 0.14); }
.info-title { fill: var(--accent); font-size: 18px; font-weight: 900; }
.info-copy { fill: var(--muted); font-size: 15px; }
.roof-fill { fill: rgba(17, 109, 255, 0.06); }
.roof-line { stroke: var(--wall); stroke-width: 3; fill: none; }
.ground-line { fill: var(--wall); }
.pillar { fill: rgba(17, 109, 255, 0.12); stroke: var(--aux); stroke-width: 1.5; }

body.hide-legendas .legend-layer,
body.hide-mobilia .furniture-layer,
body.hide-cotas .dimension-layer,
body.hide-cotas .info-card,
body.hide-cotas .info-title,
body.hide-cotas .info-copy {
  display: none;
}

body.mode-rascunho .draft-grid { opacity: 0.86; }
body.mode-rascunho .wall,
body.mode-rascunho .aux,
body.mode-rascunho .roof-line,
body.mode-rascunho .dimension-line {
  stroke-dasharray: 7 5;
}
body.mode-rascunho .room-fill,
body.mode-rascunho .zone,
body.mode-rascunho .furniture,
body.mode-rascunho .roof-fill,
body.mode-rascunho .info-card {
  fill: none;
}

.info-grid {
  margin-top: 18px;
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 12px;
}

.info-panel {
  padding: 16px;
  border-radius: 20px;
  background: var(--card);
  border: 1px solid var(--border);
}

.stage-frame:fullscreen,
#drawingStage:fullscreen,
#stageFrame:fullscreen {
  background: var(--bg);
  padding: 20px;
}

@media (max-width: 1100px) {
  .layout-grid { grid-template-columns: 1fr; }
  .sidebar { position: static; }
  .workspace-top,
  .stage-toolbar { flex-direction: column; align-items: flex-start; }
  .badge-row { justify-content: flex-start; }
  .info-grid { grid-template-columns: 1fr; }
}

@media (max-width: 760px) {
  .app-shell { padding: 14px; }
  .app-header,
  .sidebar,
  .workspace { border-radius: 22px; }
  .toggle-list { grid-template-columns: 1fr 1fr; }
  svg { min-width: 680px; }
}

@media print {
  body {
    background: #fff !important;
    color: #000 !important;
  }

  .app-header,
  .sidebar,
  .workspace-top,
  .stage-toolbar,
  .info-grid {
    display: none !important;
  }

  .app-shell,
  .layout-grid,
  .workspace,
  .drawing-stage,
  .stage-frame,
  .svg-host {
    padding: 0 !important;
    margin: 0 !important;
    display: block !important;
    border: none !important;
    box-shadow: none !important;
    background: #fff !important;
    max-width: 100% !important;
  }

  .svg-host:not(.active) { display: none !important; }

  svg {
    min-width: auto;
    width: 100% !important;
    background: #fff !important;
  }

  .wall, .roof-line, .ground-line { stroke: #000 !important; fill: none !important; }
  .ground-line { fill: #000 !important; }
  .dimension-box { fill: #fff !important; }
}
