:root {
  --bg: #FAF8F4;
  --bg-panel: #ffffff;
  --sidebar: #F3F1EC;
  --border: #E3DFD6;
  --border-soft: #ECE9E1;
  --ink: #1E1B16;
  --muted: #8B857A;
  --accent: #A6480A;
  --accent-dark: #7E3608;
  --accent-soft: #F3E3D6;
  --danger: #8A1F1F;
  --mono: 'IBM Plex Mono', monospace;
  --sans: 'Helvetica Neue', Helvetica, Arial, sans-serif;
}

body { background: var(--bg); color: var(--ink); font-family: var(--sans); color-scheme: light; }
* { box-sizing: border-box; }
.mono { font-family: var(--mono); }
.muted { color: var(--muted); }
.small { font-size: 11px; }

#app { display: flex; min-height: 100vh; width: 100%; }

.sidebar { flex: none; width: 240px; display: flex; flex-direction: column; background: var(--sidebar); border-right: 1px solid var(--border); }
.brand { padding: 22px 20px 16px; border-bottom: 1px solid var(--border); }
.brand-title { font-size: 15px; font-weight: 700; letter-spacing: 0.02em; }
.brand-sub { font-size: 10px; color: var(--muted); letter-spacing: 0.06em; margin-top: 3px; }
.sidebar-project { padding: 12px 16px 4px; }
.current-project-pill { font-size: 12px; padding: 6px 10px; background: var(--bg); border: 1px solid var(--border); border-radius: 7px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.nav { flex: 1; padding: 10px 12px; display: flex; flex-direction: column; gap: 3px; }
.nav-item { display: flex; align-items: center; gap: 10px; padding: 9px 10px; border: none; border-radius: 7px; font-size: 13px; font-weight: 500; text-align: left; cursor: pointer; background: transparent; color: #3A3630; }
.nav-item.active { background: var(--accent-soft); color: var(--accent-dark); font-weight: 600; }
.nav-badge { font-family: var(--mono); font-size: 9.5px; padding: 2px 5px; border-radius: 4px; background: var(--border); color: #5B5750; }
.nav-item.active .nav-badge { background: var(--accent); color: #fff; }
.sidebar-footer { padding: 14px 20px; border-top: 1px solid var(--border); font-size: 10px; color: var(--muted); }

.main { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.topbar { flex: none; height: 56px; display: flex; align-items: center; padding: 0 28px; border-bottom: 1px solid var(--border); }
.screen-title { font-size: 16px; font-weight: 700; }
.content { flex: 1; overflow: auto; padding: 24px 28px; }

.btn { padding: 8px 14px; border: 1px solid var(--border); background: #fff; border-radius: 6px; font-size: 12.5px; font-weight: 600; cursor: pointer; color: var(--ink); white-space: nowrap; }
.btn-primary { background: var(--accent); border-color: var(--accent); color: #fff; }
.btn-secondary { background: transparent; }
.btn-danger-ghost { background: transparent; border-color: var(--border); color: var(--danger); }
.btn:disabled { opacity: 0.4; cursor: not-allowed; }
.btn-link { border: none; background: none; color: var(--accent); font-weight: 600; font-size: 11.5px; cursor: pointer; }
.btn-icon { border: none; background: none; cursor: pointer; color: var(--muted); font-size: 13px; padding: 2px 6px; }
.btn-icon:hover { color: var(--danger); }

.input { padding: 8px 10px; border: 1px solid var(--border); border-radius: 6px; font-size: 12.5px; font-family: inherit; background: #fff; color: var(--ink); color-scheme: light; }
select.input { color: var(--ink); }
label { display: flex; flex-direction: column; gap: 5px; font-size: 11px; color: var(--muted); margin-bottom: 10px; }
label input, label select { color: var(--ink); font-size: 12.5px; }
.inline-label { flex-direction: row; align-items: center; gap: 6px; display: inline-flex; margin-right: 10px; }
.inline-check { flex-direction: row; align-items: center; gap: 6px; font-size: 12px; color: var(--ink); }

.toolbar { display: flex; align-items: center; justify-content: space-between; margin-bottom: 18px; flex-wrap: wrap; gap: 12px; }
.toolbar-wrap { flex-direction: column; align-items: stretch; }
.placement-tools { display: flex; gap: 8px; flex-wrap: wrap; }

.grid-cards { display: grid; grid-template-columns: repeat(auto-fill, minmax(240px, 1fr)); gap: 18px; }
.project-card { border: 1px solid var(--border); border-radius: 10px; background: var(--bg-panel); overflow: hidden; }
.project-preview { height: 100px; background: repeating-linear-gradient(135deg, #EFEBE2 0 8px, #F6F3EC 8px 16px); display: flex; align-items: center; justify-content: center; font-family: var(--mono); font-size: 9.5px; letter-spacing: 0.06em; color: var(--muted); }
.project-body { padding: 14px 15px; }
.project-name { font-size: 13.5px; font-weight: 600; margin-bottom: 4px; }
.project-meta { font-family: var(--mono); font-size: 10.5px; color: var(--muted); margin-bottom: 10px; }
.project-row { display: flex; align-items: center; justify-content: space-between; margin-bottom: 10px; }
.project-actions { display: flex; gap: 8px; }
.status-pill { font-size: 10.5px; font-weight: 600; padding: 3px 8px; border-radius: 20px; background: var(--border); color: #5B5750; }
.status-simulated { background: #EAF2ED; color: #3E6B54; }
.status-archived { background: var(--accent-soft); color: #8A5A2E; }

.empty-state { padding: 40px; text-align: center; color: var(--muted); border: 1px dashed var(--border); border-radius: 10px; }

.panel { border: 1px solid var(--border); border-radius: 10px; background: var(--bg-panel); padding: 16px; margin-bottom: 16px; }
.panel-title { font-size: 12px; font-weight: 700; margin-bottom: 12px; }
.panel-title-row { display: flex; justify-content: space-between; align-items: baseline; margin-bottom: 12px; }

.two-col { display: flex; gap: 24px; align-items: flex-start; flex-wrap: wrap; }
.col-side { flex: none; width: 320px; min-width: 280px; }
.col-main { flex: 1; min-width: 340px; }

.canvas-wrap { position: relative; border: 1px solid var(--border); border-radius: 10px; overflow: hidden; background: #fff; }
.hint-bar { margin-top: 8px; font-size: 11.5px; color: var(--muted); min-height: 16px; }
.floating-actions { position: absolute; bottom: 12px; right: 12px; display: flex; gap: 8px; }

.placement-canvas-row { display: flex; gap: 10px; align-items: stretch; }
.heatmap-legend { flex: none; width: 34px; display: flex; flex-direction: column; align-items: center; gap: 4px; }
.heatmap-legend-bar { flex: 1; width: 14px; border-radius: 6px; border: 1px solid var(--border); }
.heatmap-legend-label { font-size: 10px; font-family: var(--mono); color: var(--muted); }
.heatmap-legend-unit { color: var(--muted); }

.wizard-steps { display: flex; align-items: flex-start; margin-bottom: 16px; }
.wizard-step { flex: 1; display: flex; flex-direction: column; align-items: center; gap: 6px; position: relative; font-size: 11px; color: var(--muted); text-align: center; }
.wizard-step + .wizard-step::before { content: ''; position: absolute; top: 11px; right: 50%; width: 100%; height: 1px; background: var(--border); z-index: 0; }
.wizard-step.done + .wizard-step::before { background: var(--accent); }
.wizard-step-dot { width: 22px; height: 22px; border-radius: 50%; border: 1px solid var(--border); background: #fff; display: flex; align-items: center; justify-content: center; font-size: 11px; font-weight: 600; color: var(--muted); position: relative; z-index: 1; }
.wizard-step.current .wizard-step-dot { border-color: var(--accent); background: var(--accent-soft); color: var(--accent-dark); }
.wizard-step.current .wizard-step-label { color: var(--ink); font-weight: 600; }
.wizard-step.done .wizard-step-dot { background: var(--accent); border-color: var(--accent); color: #fff; }
.wizard-step.done .wizard-step-label { color: var(--ink); }

.venue-nudge { border: 1px solid var(--border); border-radius: 10px; background: var(--accent-soft); padding: 12px 14px; margin-bottom: 12px; font-size: 12.5px; color: var(--ink); }
.venue-nudge .btn { margin-top: 8px; }

.list-row { display: flex; align-items: center; gap: 8px; padding: 7px 0; border-top: 1px solid var(--border-soft); font-size: 12px; }
.list-row:first-child { border-top: none; }
.list-row span:first-of-type { flex: 1; }
.list-row.selected { background: var(--accent-soft); border-radius: 6px; padding-left: 6px; }
.speaker-select { cursor: pointer; }

.form-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 4px 16px; margin: 16px 0; }
.form-errors { color: var(--danger); font-size: 11.5px; margin-bottom: 8px; }
.modal-backdrop { position: fixed; inset: 0; background: rgba(30,27,22,0.35); display: flex; align-items: center; justify-content: center; z-index: 50; }
.modal { background: #fff; border-radius: 10px; padding: 20px; width: 560px; max-width: 92vw; max-height: 88vh; overflow: auto; }
.modal-title { font-size: 14px; font-weight: 700; margin-bottom: 8px; }
.modal-actions { display: flex; justify-content: flex-end; gap: 10px; }

.catalog-table-wrap { overflow-x: auto; border: 1px solid var(--border); border-radius: 10px; background: #fff; }
.catalog-table { width: 100%; border-collapse: collapse; font-size: 12px; }
.catalog-table th, .catalog-table td { padding: 10px 12px; border-top: 1px solid var(--border-soft); text-align: left; white-space: nowrap; }
.catalog-table th { color: var(--muted); font-weight: 600; font-size: 10.5px; letter-spacing: 0.04em; }
.model-name { font-weight: 600; }
.row-actions { display: flex; gap: 6px; }

.band-selector { display: flex; gap: 8px; flex-wrap: wrap; margin-bottom: 12px; }
.band-btn { padding: 7px 14px; border-radius: 20px; border: 1px solid var(--border); background: #fff; color: #5B5750; font-size: 12px; font-weight: 600; cursor: pointer; }
.band-btn.active { border-color: var(--accent); background: var(--accent); color: #fff; }

.row-between { display: flex; justify-content: space-between; margin-top: 6px; }

.eq-bands { display: flex; justify-content: space-between; gap: 10px; }
.eq-band { display: flex; flex-direction: column; align-items: center; gap: 6px; flex: 1; }
.eq-slider { -webkit-appearance: slider-vertical; writing-mode: vertical-lr; direction: rtl; width: 22px; height: 100px; }

.air-absorption-grid { display: grid; grid-template-columns: repeat(4, 1fr); gap: 10px; }
.air-absorption-grid label { font-size: 10px; }
.formula-box { background: var(--sidebar); border-radius: 6px; padding: 8px 10px; font-size: 12.5px; overflow-x: auto; }

.speaker-marker:hover polygon { filter: brightness(1.2); }
.viewport3d-fallback { padding: 24px; color: var(--muted); text-align: center; }

.login-gate-overlay {
  position: fixed; inset: 0; z-index: 1000; color-scheme: light;
  display: flex; align-items: center; justify-content: center;
  background:
    radial-gradient(560px circle at 18% 12%, var(--accent-soft) 0%, transparent 60%),
    radial-gradient(600px circle at 85% 88%, var(--sidebar) 0%, transparent 60%),
    var(--bg);
  animation: login-gate-in 0.25s ease-out;
}
@keyframes login-gate-in { from { opacity: 0; } to { opacity: 1; } }

.login-gate-box {
  width: 320px; display: flex; flex-direction: column; align-items: center;
  padding: 36px 32px 30px; border: 1px solid var(--border); border-radius: 14px;
  background: var(--bg-panel); box-shadow: 0 12px 40px -12px rgba(30, 27, 22, 0.18);
}
.login-gate-mark {
  width: 48px; height: 48px; border-radius: 50%; background: var(--accent);
  display: flex; align-items: center; justify-content: center; margin-bottom: 16px;
  box-shadow: 0 6px 16px -4px rgba(166, 72, 10, 0.5);
}
.login-gate-title { font-size: 17px; font-weight: 700; letter-spacing: 0.03em; }
.login-gate-sub { font-size: 10px; color: var(--muted); letter-spacing: 0.08em; margin-top: 3px; margin-bottom: 26px; }
.login-gate-form { width: 100%; display: flex; flex-direction: column; gap: 14px; }
.login-gate-label { text-align: left; }
.login-gate-box input { width: 100%; box-sizing: border-box; padding: 10px 12px; font-size: 13px; }
.login-gate-box input:focus { outline: none; border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); }
.login-gate-box button { width: 100%; padding: 10px 14px; font-size: 13px; }
.login-gate-error { color: var(--danger); font-size: 11.5px; text-align: center; }
.login-gate-logout {
  position: fixed; bottom: 14px; right: 16px; z-index: 999;
  border: 1px solid var(--border); background: var(--bg-panel); color: var(--muted);
  font-size: 11px; font-weight: 600; padding: 6px 12px; border-radius: 20px; cursor: pointer;
  box-shadow: 0 2px 8px -2px rgba(30, 27, 22, 0.12);
}
.login-gate-logout:hover { color: var(--danger); border-color: var(--danger); }

@media (max-width: 780px) {
  #app { flex-direction: column; min-height: auto; }
  .sidebar { width: 100%; border-right: none; border-bottom: 1px solid var(--border); }
  .nav { flex-direction: row; flex-wrap: wrap; }
  .nav-item { flex: 1 1 auto; justify-content: center; }
  .content { padding: 16px; }
  .catalog-table th, .catalog-table td { white-space: normal; }
}
