/* ─────────────────────────────────────────────
   住宅最適設計ビジュアライザー — コンポーネントスタイル
   ───────────────────────────────────────────── */

/* ── App shell ──────────────────────────── */
.app {
  height: 100vh;
  display: grid;
  grid-template-rows: auto 1fr auto;
  background: var(--bg);
  color: var(--ink);
}

/* Full-bleed: 3D viewport fills the entire window;
   topbar/statusbar float as glass overlays on top of it. */
.app.is-fullbleed {
  display: block;
  position: relative;
  height: 100vh;
  overflow: hidden;
}
.app.is-fullbleed > main {
  position: absolute !important;
  inset: 0;
  display: block !important;
}
.app.is-fullbleed > .topbar {
  position: absolute;
  top: 12px;
  left: 12px;
  right: 12px;
  z-index: 40;
  border-radius: 14px;
  border: 1px solid color-mix(in oklch, var(--line) 70%, transparent);
  background: color-mix(in oklch, var(--surface) 80%, transparent);
  -webkit-backdrop-filter: blur(14px) saturate(140%);
  backdrop-filter: blur(14px) saturate(140%);
  box-shadow: var(--shadow-md);
  min-height: 56px;
  padding: 8px 16px;
}
.app.is-fullbleed > .statusbar {
  position: absolute;
  bottom: 12px;
  left: 12px;
  right: 12px;
  z-index: 40;
  border-radius: 999px;
  border: 1px solid color-mix(in oklch, var(--line) 70%, transparent);
  background: color-mix(in oklch, var(--surface) 80%, transparent);
  -webkit-backdrop-filter: blur(14px) saturate(140%);
  backdrop-filter: blur(14px) saturate(140%);
  box-shadow: var(--shadow-sm);
  min-height: 32px;
  padding: 6px 18px;
}
/* Push the dock above the floating statusbar */
.app.is-fullbleed .dock { bottom: 60px; }
.app.is-fullbleed .material-legend-wrap { bottom: 168px; }
.app.is-fullbleed .material-legend-bar { bottom: 168px; }
.app.is-fullbleed .project-info-card { top: 88px; right: 24px; }
.app.is-fullbleed .vp-mode-pill { top: 88px; }
.app.is-fullbleed .vp-tools { top: 168px; left: 24px; }
.app.is-fullbleed .vp-hint { bottom: 58px; }

/* ── Topbar ─────────────────────────────── */
.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 12px 20px;
  background: var(--surface);
  border-bottom: 1px solid var(--line);
  gap: 16px;
  min-height: 64px;
}
.topbar-l { display: flex; align-items: center; gap: 18px; }
.topbar-r { display: flex; align-items: center; gap: 6px; }
.brand { display: flex; align-items: center; gap: 11px; }
.brand-mark {
  width: 38px;
  height: 38px;
  border-radius: 9px;
  background: var(--accent);
  color: white;
  display: grid;
  place-items: center;
}
.brand-name { font-size: 16px; font-weight: 700; line-height: 1.15; color: var(--ink); white-space: nowrap; }
.brand-sub { font-size: 11px; color: var(--ink-3); letter-spacing: 0.02em; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; max-width: 160px; }
.topbar-divider { width: 1px; height: 32px; background: var(--line); }
.topbar-meta {
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  margin-right: 12px;
  padding-right: 12px;
  border-right: 1px solid var(--line);
  white-space: nowrap;
}
.topbar-meta .t-value { white-space: nowrap; }
@media (max-width: 1100px) {
  .topbar-meta { display: none; }
}

/* Mode switch — 上部のメインタブ */
.mode-switch {
  display: flex;
  gap: 2px;
  padding: 3px;
  background: var(--bg-2);
  border-radius: 11px;
  border: 1px solid var(--line);
}
.mode-tab {
  display: flex;
  align-items: center;
  gap: 9px;
  padding: 6px 14px;
  border-radius: 8px;
  color: var(--ink-2);
  transition: all 0.15s;
  text-align: left;
}
.mode-tab:hover { background: var(--surface-2); color: var(--ink); }
.mode-tab.is-active {
  background: var(--surface);
  color: var(--ink);
  box-shadow: var(--shadow-sm);
  border: 1px solid var(--line);
  margin: -1px;
}
.mode-tab-text { display: flex; flex-direction: column; line-height: 1.1; }
.mode-tab-label { font-size: 13px; font-weight: 600; white-space: nowrap; }
.mode-tab-sub { font-size: 10px; color: var(--ink-3); margin-top: 2px; letter-spacing: 0.02em; white-space: nowrap; }
@media (max-width: 1280px) {
  .mode-tab-sub { display: none; }
  .mode-tab { padding: 8px 12px; }
}

/* icon button */
.icon-btn {
  width: 36px;
  height: 36px;
  border-radius: 9px;
  display: grid;
  place-items: center;
  color: var(--ink-2);
  transition: all 0.15s;
  border: 1px solid transparent;
}
.icon-btn:hover { background: var(--surface-2); color: var(--ink); border-color: var(--line); }

.btn {
  padding: 8px 14px;
  border-radius: 9px;
  font-size: 13px;
  font-weight: 600;
  color: var(--ink-2);
  background: var(--surface);
  border: 1px solid var(--line);
  display: inline-flex;
  align-items: center;
  gap: 8px;
  transition: all 0.15s;
}
.btn:hover { color: var(--ink); border-color: var(--ink-3); }
.btn.is-primary { background: var(--accent); color: white; border-color: var(--accent); }
.btn.is-primary:hover { filter: brightness(1.05); }
.btn.is-ghost { background: transparent; border-color: transparent; }
.btn.is-ghost:hover { background: var(--surface-2); }

/* ── Section (collapsible) ──────────────── */
.section {
  border-bottom: 1px solid var(--line-2);
}
.section:last-child { border-bottom: none; }
.section-head {
  width: 100%;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 14px 18px;
  color: var(--ink-2);
  transition: color 0.15s;
}
.section-head:hover { color: var(--ink); }
.section.is-open .section-head { color: var(--ink); }
.section-head-left { display: flex; align-items: center; gap: 10px; }
.section-title { font-size: 12px; font-weight: 600; letter-spacing: 0.06em; text-transform: uppercase; }
.section-count {
  font-size: 11px;
  background: var(--bg-2);
  color: var(--ink-3);
  padding: 1px 7px;
  border-radius: 999px;
  font-weight: 600;
}
.section-body {
  padding: 4px 18px 18px;
  display: flex;
  flex-direction: column;
  gap: 14px;
}
.section.is-dense .section-body { padding: 2px 14px 12px; gap: 8px; }
.section.is-dense .section-head { padding: 10px 14px; }

/* ── Swatch (improved) ──────────────────── */
.swatch-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(88px, 1fr));
  gap: 10px;
}
.swatch-grid.is-list { grid-template-columns: 1fr; gap: 6px; }
.swatch-grid.is-list .swatch {
  flex-direction: row;
  align-items: center;
  padding: 8px 10px;
  border-radius: 9px;
  border: 1px solid transparent;
  text-align: left;
  width: 100%;
  gap: 12px;
}
.swatch-grid.is-list .swatch:hover { background: var(--surface-2); border-color: var(--line); }
.swatch-grid.is-list .swatch.is-selected { background: var(--accent-soft); border-color: var(--accent); }
.swatch-grid.is-list .swatch-chip { width: 36px !important; height: 36px !important; }
.swatch-grid.is-list .swatch-label { flex: 1; align-items: flex-start; text-align: left; }
.swatch-grid.is-list .swatch-name { font-size: 13px; color: var(--ink); }
.swatch-grid.is-list .swatch-sub  { font-size: 11px; color: var(--ink-3); }

.swatch {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 7px;
  background: transparent;
  padding: 0;
}
.swatch-chip {
  position: relative;
  width: var(--swatch-size, 48px);
  height: var(--swatch-size, 48px);
  border-radius: 10px;
  box-shadow: 0 0 0 1px rgba(0,0,0,0.08), inset 0 -8px 16px rgba(0,0,0,0.15);
  transition: transform 0.12s ease, box-shadow 0.15s ease;
}
.swatch:hover .swatch-chip { transform: translateY(-2px); box-shadow: 0 0 0 1px rgba(0,0,0,0.12), 0 6px 14px -4px rgba(0,0,0,0.18), inset 0 -8px 16px rgba(0,0,0,0.15); }
.swatch.is-selected .swatch-chip {
  box-shadow: 0 0 0 2px var(--accent), 0 4px 10px -2px var(--accent-soft), inset 0 -8px 16px rgba(0,0,0,0.15);
}
.swatch-check {
  position: absolute;
  inset: 0;
  display: grid;
  place-items: center;
  background: rgba(0,0,0,0.35);
  border-radius: 10px;
  color: white;
  animation: fadeIn 0.18s ease;
}
.swatch-label {
  display: flex;
  flex-direction: column;
  align-items: center;
  text-align: center;
  line-height: 1.2;
  gap: 1px;
  width: 100%;
  min-width: 0;
}
.swatch-name { font-size: 11px; color: var(--ink-2); font-weight: 500; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; max-width: 100%; }
.swatch.is-selected .swatch-name { color: var(--ink); font-weight: 600; }
.swatch-sub { font-size: 10px; color: var(--ink-3); }
.swatch-tag {
  font-size: 9px;
  letter-spacing: 0.05em;
  color: var(--accent);
  background: var(--accent-soft);
  padding: 1px 6px;
  border-radius: 999px;
  margin-top: 2px;
}

/* ── Viewport ───────────────────────────── */
.viewport {
  position: relative;
  width: 100%;
  height: 100%;
  background: var(--viewport-sky);
  overflow: hidden;
  isolation: isolate;
}
.viewport-iframe {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  border: 0;
  background: transparent;
}
.viewport-plan {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 32px 32px 64px;
  background: var(--bg);
}
.viewport-plan > svg { max-width: 100%; max-height: 100%; }
.viewport-canvas {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: stretch;
  justify-content: center;
}
.viewport-canvas > svg { width: 100%; height: 100%; }

/* ── Performance Dashboard ────────────── */
.perf-viewport {
  background: var(--bg);
  padding: 0;
  overflow: hidden;
  display: flex;
  flex-direction: column;
}
.perf-tabbar {
  display: flex;
  gap: 0;
  padding: 12px 18px 0;
  border-bottom: 1px solid var(--line);
  background: var(--surface);
  flex-shrink: 0;
  overflow-x: auto;
}
.perf-tab {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 16px 12px;
  border-bottom: 2px solid transparent;
  color: var(--ink-3);
  font-size: 13px;
  transition: color .15s, border-color .15s;
  white-space: nowrap;
}
.perf-tab:hover { color: var(--ink-2); }
.perf-tab.is-active {
  color: var(--accent-ink);
  border-bottom-color: var(--accent);
}
.perf-tab-icon { font-size: 16px; line-height: 1; }
.perf-tab-text { display: flex; flex-direction: column; align-items: flex-start; gap: 1px; line-height: 1.2; }
.perf-tab-label { font-weight: 700; font-size: 13px; }
.perf-tab-sub { font-size: 9px; letter-spacing: 0.12em; }
.perf-scroll {
  flex: 1;
  overflow: auto;
  padding: 22px 24px 80px; /* dock の上を避ける */
}
.perf-empty { padding: 60px; text-align: center; color: var(--ink-3); }
.perf-grid {
  display: grid;
  grid-template-columns: repeat(6, 1fr);
  grid-template-rows: auto auto auto;
  gap: 16px;
  max-width: 1280px;
  margin: 0 auto;
}
.perf-card {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 14px;
  padding: 18px 20px;
  display: flex;
  flex-direction: column;
  gap: 10px;
}
.perf-card-hero {
  grid-column: span 6;
  background: linear-gradient(135deg, var(--surface) 0%, var(--accent-soft) 100%);
}
.perf-card-sun {
  grid-column: span 3;
}
.perf-card-sunpath {
  grid-column: span 3;
}
.perf-card:not(.perf-card-hero):not(.perf-card-sun):not(.perf-card-sunpath) {
  grid-column: span 2;
}
.perf-card-eyebrow {
  font-size: 11px;
  letter-spacing: 0.06em;
  color: var(--ink-3);
  font-weight: 600;
  text-transform: uppercase;
}
.perf-card-value-row {
  display: flex;
  align-items: baseline;
  gap: 6px;
  color: var(--ink);
}
.perf-card-foot {
  font-size: 11px;
  color: var(--ink-3);
  border-top: 1px solid var(--line-2);
  padding-top: 10px;
}
.perf-hero-value {
  color: var(--accent-ink);
  display: flex;
  align-items: baseline;
}
.perf-grade-bar {
  display: grid;
  grid-template-columns: repeat(5, 1fr);
  gap: 4px;
}
.perf-grade-segment {
  padding: 10px 12px;
  border-radius: 8px;
  background: var(--bg-2);
  border: 1px solid var(--line);
  display: flex;
  flex-direction: column;
  gap: 2px;
  font-size: 11px;
  color: var(--ink-3);
  position: relative;
}
.perf-grade-segment span:first-child { font-weight: 600; color: var(--ink-2); }
.perf-grade-segment[data-active="true"] {
  background: oklch(0.92 0.04 145);
  border-color: oklch(0.72 0.10 145);
  color: oklch(0.30 0.10 145);
}
.perf-grade-segment[data-active="true"] span:first-child { color: oklch(0.30 0.10 145); }
.perf-grade-segment[data-active="current"] {
  background: var(--accent);
  border-color: var(--accent);
  color: white;
  transform: scale(1.05);
  z-index: 1;
  box-shadow: 0 6px 14px -4px var(--accent-soft);
}
.perf-grade-segment[data-active="current"] span:first-child { color: white; }
:root[data-theme="dark"] .perf-grade-segment[data-active="true"] {
  background: oklch(0.30 0.08 145);
  border-color: oklch(0.55 0.10 145);
  color: oklch(0.85 0.08 145);
}
:root[data-theme="dark"] .perf-grade-segment[data-active="true"] span:first-child { color: oklch(0.85 0.08 145); }

.perf-mini-bar {
  height: 6px;
  background: var(--bg-2);
  border-radius: 999px;
  overflow: hidden;
  margin-top: 4px;
}
.perf-mini-bar > div { height: 100%; border-radius: 999px; }

.perf-bar-stack {
  display: flex;
  height: 22px;
  border-radius: 8px;
  overflow: hidden;
  margin-top: 4px;
}
.perf-bar-stack > div {
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 10px;
  color: white;
  font-weight: 600;
  white-space: nowrap;
  letter-spacing: 0.02em;
}

.perf-sun-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 8px;
}
.perf-sun-face { display: flex; flex-direction: column; gap: 4px; align-items: center; }
.perf-sun-label { font-size: 11px; color: var(--ink-3); font-weight: 500; }
.perf-sun-cell {
  width: 100%;
  aspect-ratio: 1;
  border-radius: 10px;
  display: grid;
  place-items: end center;
  padding: 8px;
  border: 1px solid var(--line);
  font-size: 13px;
  font-weight: 700;
  color: var(--ink);
}
.perf-sun-foot {
  font-size: 11px;
  color: var(--ink-3);
  margin-top: 4px;
}
.vp-compass {
  position: absolute;
  top: 16px;
  left: 16px;
  width: 72px;
  height: 72px;
  color: var(--ink);
  filter: drop-shadow(0 2px 4px rgba(0,0,0,0.2));
}
.vp-compass svg { width: 100%; height: 100%; }
.vp-mode-pill {
  position: absolute;
  top: 16px;
  left: 50%;
  transform: translateX(-50%);
  display: flex;
  gap: 2px;
  padding: 3px;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 999px;
  box-shadow: var(--shadow-md);
}
.vp-mode-btn {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 6px 14px;
  border-radius: 999px;
  color: var(--ink-2);
  font-size: 12px;
  font-weight: 600;
  transition: all 0.15s;
}
.vp-mode-btn:hover { background: var(--surface-2); color: var(--ink); }
.vp-mode-btn.is-active { background: var(--ink); color: var(--surface); }
.vp-hint {
  position: absolute;
  bottom: 14px;
  left: 14px;
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 5px 12px;
  background: rgba(0,0,0,0.5);
  color: white;
  border-radius: 999px;
  font-size: 11px;
  letter-spacing: 0.02em;
  pointer-events: none;
  backdrop-filter: blur(4px);
  white-space: nowrap;
  max-width: calc(100% - 28px);
  overflow: hidden;
  text-overflow: ellipsis;
}
.vp-coord {
  position: absolute;
  bottom: 14px;
  right: 14px;
  padding: 5px 12px;
  background: rgba(0,0,0,0.5);
  color: #d8e4d4;
  border-radius: 6px;
  font-size: 11px;
  pointer-events: none;
  backdrop-filter: blur(4px);
}
.vp-tools {
  position: absolute;
  top: 100px;
  left: 16px;
  display: flex;
  flex-direction: column;
  gap: 2px;
  background: var(--surface);
  padding: 4px;
  border-radius: 10px;
  border: 1px solid var(--line);
  box-shadow: var(--shadow-md);
}
.vp-tools button {
  width: 32px;
  height: 32px;
  border-radius: 7px;
  display: grid;
  place-items: center;
  color: var(--ink-2);
}
.vp-tools button:hover { background: var(--surface-2); color: var(--ink); }

/* ── Metrics ────────────────────────────── */
.metric {
  display: flex;
  flex-direction: column;
  gap: 3px;
  padding: 12px 14px;
  background: var(--surface-2);
  border-radius: 10px;
  border: 1px solid var(--line-2);
}
.metric-label {
  font-size: 11px;
  color: var(--ink-3);
  letter-spacing: 0.04em;
  font-weight: 500;
}
.metric-value { display: flex; align-items: baseline; gap: 4px; }
.metric-num { font-size: 22px; font-weight: 700; color: var(--ink); font-family: "Shippori Mincho", serif; letter-spacing: -0.01em; }
.metric-unit { font-size: 11px; color: var(--ink-3); font-weight: 500; }
.metric-hint { font-size: 10px; color: var(--ink-3); margin-top: 2px; }

/* ── Statusbar ──────────────────────────── */
.statusbar {
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 8px 20px;
  background: var(--surface);
  border-top: 1px solid var(--line);
  font-size: 11px;
  color: var(--ink-3);
  min-height: 36px;
}
.status-chip { display: inline-flex; align-items: center; gap: 5px; }
.status-divider { width: 1px; height: 14px; background: var(--line); }
.status-spacer { flex: 1; }

/* ── Bottom dock (layout B) ─────────────── */
.dock {
  position: absolute;
  bottom: 24px;
  left: 50%;
  transform: translateX(-50%);
  display: flex;
  align-items: center;
  gap: 4px;
  background: var(--surface);
  border: 1px solid var(--line);
  padding: 6px;
  border-radius: 16px;
  box-shadow: var(--shadow-lg);
  z-index: 20;
}
.dock-btn {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
  padding: 9px 16px;
  border-radius: 11px;
  color: var(--ink-2);
  transition: all 0.15s;
  min-width: 78px;
}
.dock-btn:hover { background: var(--surface-2); color: var(--ink); }
.dock-btn.is-active { background: var(--accent-soft); color: var(--accent-ink); }
.dock-btn-label { font-size: 11px; font-weight: 600; }
.dock-divider { width: 1px; height: 30px; background: var(--line); margin: 0 4px; }

/* ── Floating panel (layout B) ──────────── */
.float-panel {
  position: absolute;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 16px;
  box-shadow: var(--shadow-lg);
  padding: 16px;
  display: flex;
  flex-direction: column;
  gap: 12px;
  z-index: 10;
}
.float-panel-h {
  display: flex;
  justify-content: space-between;
  align-items: center;
}
.float-panel-h h3 { font-size: 13px; font-weight: 700; }

/* ── Drawer (layout C) ──────────────────── */
.drawer-tab {
  position: absolute;
  display: flex;
  align-items: center;
  gap: 8px;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 10px 16px;
  box-shadow: var(--shadow-md);
  z-index: 20;
  font-size: 12px;
  font-weight: 600;
  color: var(--ink);
}
.drawer-tab:hover { background: var(--surface-2); }
.drawer {
  position: absolute;
  background: var(--surface);
  border-radius: 16px;
  box-shadow: var(--shadow-lg);
  border: 1px solid var(--line);
  z-index: 30;
  overflow: hidden;
  display: flex;
  flex-direction: column;
}

/* ── Spec dot (in-line tiny indicator) ──── */
/* 使用素材レジェンド: 平面図A 風の枠なしチップ（3Dの上に浮かせても邪魔になりにくい） */
.spec-dot {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 2px 4px;
  background: transparent;
  border: none;
  border-radius: 0;
  font-size: 12px;
  color: var(--ink-2);
  white-space: nowrap;
  flex-shrink: 0;
  /* 背景帯なしでも明るい3D背景で読めるよう、白い縁取り(多方向シャドウ)を強めにかける */
  text-shadow:
    0 0 2px #fff, 0 0 2px #fff, 0 0 3px #fff,
    1px 1px 1px rgba(255,255,255,0.95), -1px -1px 1px rgba(255,255,255,0.95);
}
.spec-dot strong { font-weight: 700; }
.spec-dot-chip {
  width: 13px;
  height: 13px;
  border-radius: 4px;
  box-shadow: inset 0 0 0 1px rgba(0,0,0,0.18), 0 1px 2px rgba(0,0,0,0.25);
}

/* ── Variation thumbnail (compare) ──────── */
.variation-row {
  display: flex;
  gap: 10px;
  overflow-x: auto;
  padding-bottom: 4px;
}
.variation-card {
  flex-shrink: 0;
  width: 130px;
  border: 1px solid var(--line);
  border-radius: 11px;
  overflow: hidden;
  background: var(--surface-2);
  cursor: pointer;
  transition: all 0.15s;
}
.variation-card:hover { border-color: var(--accent); transform: translateY(-2px); }
.variation-card.is-active { border-color: var(--accent); box-shadow: 0 0 0 1px var(--accent); }
.variation-thumb {
  height: 78px;
  background: var(--viewport-sky);
  display: grid;
  place-items: center;
  overflow: hidden;
}
.variation-meta { padding: 7px 9px; }
.variation-name { font-size: 11px; font-weight: 600; }
.variation-tag { font-size: 9px; color: var(--ink-3); letter-spacing: 0.05em; }

/* ── Scrollbar ──────────────────────────── */
.scroll {
  overflow-y: auto;
  scrollbar-width: thin;
  scrollbar-color: var(--ink-4) transparent;
}
.scroll::-webkit-scrollbar { width: 8px; }
.scroll::-webkit-scrollbar-track { background: transparent; }
.scroll::-webkit-scrollbar-thumb { background: var(--ink-4); border-radius: 4px; border: 2px solid var(--surface); }
.scroll::-webkit-scrollbar-thumb:hover { background: var(--ink-3); }

/* ── Animations ─────────────────────────── */
@keyframes fadeIn { from { opacity: 0; } to { opacity: 1; } }
@keyframes slideUp { from { transform: translateY(8px); opacity: 0; } to { transform: translateY(0); opacity: 1; } }

/* ── Density (compact toggle) ───────────── */
.app.density-compact .section-body { padding: 2px 14px 10px; gap: 8px; }
.app.density-compact .section-head { padding: 9px 14px; }
.app.density-compact .swatch-grid { gap: 7px; }
.app.density-compact .swatch-chip { width: 40px !important; height: 40px !important; }

/* Side panel tabs */
.side-tabs {
  display: flex;
  gap: 2px;
  padding: 6px;
  background: var(--bg-2);
  border-bottom: 1px solid var(--line);
}
.side-tab {
  flex: 1;
  padding: 8px 6px;
  border-radius: 7px;
  color: var(--ink-3);
  font-size: 12px;
  font-weight: 600;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  transition: all 0.15s;
}
.side-tab:hover { color: var(--ink-2); }
.side-tab.is-active {
  background: var(--surface);
  color: var(--ink);
  box-shadow: var(--shadow-sm);
}

/* Action footer in panel */
.panel-foot {
  display: flex;
  gap: 6px;
  padding: 12px 16px;
  border-top: 1px solid var(--line);
  background: var(--surface-2);
}
.panel-foot .btn {
  white-space: nowrap;
  padding: 8px 10px;
  font-size: 12px;
  justify-content: center;
}

/* Panel header (top of side/drawer panel) */
.panel-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 14px 18px;
  background: var(--surface-2);
  border-bottom: 1px solid var(--line);
  min-height: 52px;
}

/* Reopen button on viewport edge */
.panel-reopen {
  position: absolute;
  top: 16px;
  left: 16px;
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px 12px 8px 12px;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 12px;
  color: var(--ink);
  font-size: 12px;
  font-weight: 600;
  box-shadow: var(--shadow-md);
  z-index: 20;
  transition: all 0.15s;
}
.panel-reopen:hover { background: var(--surface-2); border-color: var(--accent); }

/* Side panel transitions */
.side-panel.is-closed { border-right-width: 0; }

/* Quick stat (used in viewport overlay) */
.quick-stat {
  position: absolute;
  display: flex;
  flex-direction: column;
  gap: 0;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 10px 14px;
  box-shadow: var(--shadow-md);
}
.quick-stat-lbl { font-size: 10px; color: var(--ink-3); letter-spacing: 0.04em; }
.quick-stat-val { font-size: 18px; font-weight: 700; color: var(--ink); font-family: "Shippori Mincho", serif; }

/* Tag list */
.tag-row { display: flex; gap: 6px; flex-wrap: wrap; }
.tag {
  font-size: 11px;
  padding: 3px 9px;
  border-radius: 999px;
  background: var(--surface-2);
  color: var(--ink-2);
  border: 1px solid var(--line);
}
.tag.is-active { background: var(--accent-soft); color: var(--accent-ink); border-color: var(--accent); }

/* Inline current value display */
.current-value {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px 12px;
  background: var(--bg-2);
  border-radius: 9px;
  font-size: 12px;
}
.current-value-label { color: var(--ink-3); }
.current-value-strong { font-weight: 600; color: var(--ink); }

/* Toggle switch */
.toggle {
  display: inline-flex;
  align-items: center;
  gap: 9px;
  cursor: pointer;
  user-select: none;
}
.toggle input { display: none; }
.toggle-track {
  position: relative;
  width: 32px;
  height: 18px;
  background: var(--ink-4);
  border-radius: 999px;
  transition: background 0.18s;
  flex-shrink: 0;
}
.toggle-thumb {
  position: absolute;
  top: 2px;
  left: 2px;
  width: 14px;
  height: 14px;
  background: var(--surface);
  border-radius: 50%;
  transition: transform 0.18s;
  box-shadow: 0 1px 2px rgba(0,0,0,0.2);
}
.toggle input:checked + .toggle-track { background: var(--accent); }
.toggle input:checked + .toggle-track > .toggle-thumb { transform: translateX(14px); }

.current-summary {
  /* 帯はほぼ無し（3D図の邪魔をしない）。読みやすさは各チップの文字縁取りで確保 */
  background: transparent;
  border-radius: 999px;
  padding: 2px 6px;
  scrollbar-width: thin;
  scrollbar-color: var(--ink-4) transparent;
}
.current-summary::-webkit-scrollbar { height: 4px; }
.current-summary::-webkit-scrollbar-thumb { background: var(--ink-4); border-radius: 2px; }
.current-summary::-webkit-scrollbar-track { background: transparent; }

/* ── Material legend (layout B 右下) — A平面図の凡例風 ─ */
.material-legend-wrap {
  position: absolute;
  right: 16px;
  bottom: 100px; /* dock の上に乗らない高さ */
  z-index: 12;
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  gap: 6px;
  max-width: min(340px, 38vw);
}
.material-legend-wrap.is-collapsed { gap: 0; }
.material-legend {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 8px;
  box-shadow: var(--shadow-md);
  padding: 10px 12px 8px;
  min-width: 280px;
  font-family: inherit;
}
.material-legend-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  padding-bottom: 6px;
  margin-bottom: 6px;
  border-bottom: 1px solid var(--line-2);
}
.material-legend-head .t-eyebrow {
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 0.10em;
  color: var(--ink-3);
}
.material-legend-count {
  font-size: 10px;
  color: var(--ink-3);
  font-family: 'JetBrains Mono', monospace;
  padding: 1px 6px;
  border-radius: 0;
  border: none;
  background: transparent;
}
.material-legend-body {
  display: grid;
  gap: 2px;
}
.material-legend-row {
  display: grid;
  grid-template-columns: 14px 64px 1fr;
  align-items: center;
  gap: 8px;
  font-size: 11px;
  padding: 2px 0;
  line-height: 1.4;
}
.material-legend-chip {
  width: 14px;
  height: 14px;
  border-radius: 2px;
  border: 0.6px solid currentColor;
  color: var(--line);
  box-shadow: none;
}
.material-legend-label {
  color: var(--ink-2);
  font-weight: 600;
  letter-spacing: 0;
}
.material-legend-name {
  color: var(--ink-3);
  font-weight: 400;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  font-size: 10.5px;
}
.material-legend-toggle {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 999px;
  padding: 5px 12px;
  font-size: 11px;
  font-weight: 600;
  color: var(--ink-2);
  box-shadow: var(--shadow-sm);
  cursor: pointer;
}
.material-legend-toggle:hover { background: var(--surface-2); color: var(--ink); }

/* ── Material legend BAR — 横スクロール一列(平面図A spec-dot スタイル・枠なし) ── */
.material-legend-bar {
  position: absolute;
  left: 50%;
  bottom: 96px;
  transform: translateX(-50%);
  z-index: 12;
  display: flex;
  align-items: center;
  gap: 0;
  max-width: min(1100px, calc(100vw - 48px));
  /* 枠なし・背景なし — spec-dot と同じ透明フロート */
  background: transparent;
  border: none;
  border-radius: 0;
  box-shadow: none;
  padding: 4px 0;
  overflow: visible;
}
.material-legend-bar-head {
  flex-shrink: 0;
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding-right: 8px;
  margin-right: 4px;
  border-right: none;
}
.material-legend-bar-head .t-eyebrow {
  font-size: 10px;
  letter-spacing: 0.14em;
  color: var(--ink-3);
}
.material-legend-bar-count {
  font-size: 10px;
  color: var(--ink-3);
  font-family: 'JetBrains Mono', monospace;
}
.material-legend-bar-scroll {
  display: flex;
  align-items: center;
  gap: 6px;
  overflow-x: auto;
  scrollbar-width: none;
  padding: 0 4px;
  flex: 1;
  min-width: 0;
  scroll-behavior: smooth;
}
.material-legend-bar-scroll::-webkit-scrollbar { display: none; }
.material-legend-bar-chip {
  flex-shrink: 0;
  display: inline-flex;
  align-items: center;
  gap: 7px;
  padding: 5px 12px 5px 8px;
  background: var(--surface-2);
  border: 1px solid var(--line-2);
  border-radius: 999px;
  font-size: 11.5px;
  line-height: 1.2;
  white-space: nowrap;
  color: var(--ink-2);
}
.material-legend-bar-chip-swatch {
  width: 14px;
  height: 14px;
  border-radius: 4px;
  box-shadow: inset 0 0 0 1px rgba(0,0,0,0.12);
  flex-shrink: 0;
}
.material-legend-bar-chip-label {
  font-size: 10px;
  color: var(--ink-3);
  letter-spacing: 0.02em;
}
.material-legend-bar-chip-name {
  font-weight: 600;
  color: var(--ink);
}
.material-legend-bar-toggle {
  flex-shrink: 0;
  margin-left: 4px;
  width: 28px;
  height: 28px;
  border-radius: 50%;
  display: grid;
  place-items: center;
  color: var(--ink-3);
  background: transparent;
  cursor: pointer;
}
.material-legend-bar-toggle:hover { background: var(--surface-2); color: var(--ink); }

/* Collapsed pill */
.material-legend-bar.is-collapsed {
  padding: 6px 14px;
  cursor: pointer;
}
.material-legend-bar.is-collapsed .material-legend-bar-scroll,
.material-legend-bar.is-collapsed .material-legend-bar-head { display: none; }
.material-legend-bar.is-collapsed .material-legend-bar-pill-text {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  font-size: 11px;
  font-weight: 600;
  color: var(--ink-2);
}

/* ── Layout A フルブリード補正 ── */
/* vp-tools をサイドバーと重ならないよう右端に配置 */
.layout-a.app.is-fullbleed .vp-tools {
  left: auto !important;
  right: 16px;
}
/* vp-hint も右寄り(左サイドバーと重ならないよう) */
.layout-a.app.is-fullbleed .vp-hint {
  left: auto;
  right: 16px;
  max-width: calc(100% - 340px);
}

/* ── Layout A ガラスサイドバーオーバーレイ ── */
/* 3D全幅表示の上に浮かぶ左サイドパネル */
.layout-a-sidebar {
  z-index: 20;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  background: color-mix(in oklch, var(--surface) 90%, transparent);
  border: 1px solid color-mix(in oklch, var(--line) 70%, transparent);
  border-radius: 16px;
  box-shadow: 0 24px 48px -16px rgba(40,28,14,0.18), 0 4px 12px rgba(40,28,14,0.06);
  -webkit-backdrop-filter: blur(18px) saturate(150%);
  backdrop-filter: blur(18px) saturate(150%);
}
.layout-a-sidebar .panel-header {
  background: transparent;
  border-bottom: 1px solid color-mix(in oklch, var(--line) 60%, transparent);
}
.layout-a-sidebar .panel-foot {
  background: transparent;
  border-top: 1px solid color-mix(in oklch, var(--line) 60%, transparent);
}
.layout-a-sidebar .scroll {
  background: transparent;
}

/* ── Project info card (top-right, minimal) ── */
.project-info-card {
  position: absolute;
  top: 16px;
  right: 16px;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 12px;
  box-shadow: var(--shadow-md);
  padding: 12px 14px;
  display: flex;
  flex-direction: column;
  gap: 4px;
  z-index: 12;
  min-width: 220px;
  backdrop-filter: blur(6px);
}

/* ── Perf — 共通小物 ─────────────────────── */
.perf-pill {
  display: inline-flex;
  align-items: center;
  padding: 2px 9px;
  border-radius: 999px;
  border: 1px solid var(--line-2);
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 0.06em;
  font-family: 'JetBrains Mono', monospace;
}
.perf-score5 {
  display: inline-flex;
  gap: 3px;
}
.perf-score5 .dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--line);
  display: inline-block;
}
.perf-score5 .dot.on { background: var(--accent); }

/* ── Perf — 設備選択 ─────────────────────── */
.perf-equip {
  display: grid;
  grid-template-columns: 280px 1fr;
  gap: 18px;
  max-width: 1280px;
  margin: 0 auto;
}
.perf-equip-side {
  display: flex;
  flex-direction: column;
  gap: 4px;
  position: sticky;
  top: 0;
  align-self: flex-start;
}
.perf-equip-cat {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px 14px;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 10px;
  text-align: left;
  transition: border-color .15s, background .15s;
}
.perf-equip-cat:hover { border-color: var(--accent); }
.perf-equip-cat.is-open {
  border-color: var(--accent);
  background: var(--accent-soft);
}
.perf-equip-cat-icon { font-size: 22px; flex-shrink: 0; }
.perf-equip-cat-text { flex: 1; display: flex; flex-direction: column; gap: 2px; min-width: 0; }
.perf-equip-cat-label { font-size: 13px; font-weight: 700; color: var(--ink); }
.perf-equip-cat-pick {
  font-size: 11px;
  color: var(--ink-3);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.perf-equip-detail {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 14px;
  padding: 24px;
}
.perf-equip-head { margin-bottom: 18px; }
.perf-equip-opts { display: flex; flex-direction: column; gap: 14px; }
.perf-equip-opt {
  border: 1px solid var(--line-2);
  border-radius: 10px;
  padding: 16px 18px;
  background: var(--bg);
  transition: border-color .15s, background .15s;
}
.perf-equip-opt.is-picked {
  border-color: var(--accent);
  background: var(--accent-soft);
}
.perf-equip-opt-h {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-bottom: 10px;
}
.perf-equip-opt-meta {
  display: flex;
  gap: 18px;
  flex-wrap: wrap;
  font-size: 12px;
  color: var(--ink-2);
  padding: 8px 0;
  border-top: 1px dashed var(--line-2);
  border-bottom: 1px dashed var(--line-2);
  margin-bottom: 12px;
}
.perf-equip-opt-meta .t-eyebrow { font-size: 9px; margin-right: 4px; }
.perf-equip-opt-meta strong { font-weight: 700; color: var(--ink); }
.perf-equip-opt-scores {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: 8px;
  margin-bottom: 12px;
}
.perf-axis {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 11px;
  padding: 4px 0;
}
.perf-axis-l { font-weight: 600; color: var(--ink-2); width: 56px; flex-shrink: 0; }
.perf-axis-reason { color: var(--ink-3); flex: 1; line-height: 1.4; }
.perf-equip-opt-proscons {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 14px;
  margin-bottom: 10px;
}
.perf-pros, .perf-cons {
  background: var(--surface);
  border: 1px solid var(--line-2);
  border-radius: 8px;
  padding: 10px 12px;
}
.perf-pros .t-eyebrow { color: var(--positive); margin-bottom: 6px; }
.perf-cons .t-eyebrow { color: var(--negative); margin-bottom: 6px; }
.perf-pros ul, .perf-cons ul { list-style: none; padding: 0; }
.perf-pros li, .perf-cons li {
  font-size: 11.5px;
  line-height: 1.55;
  padding: 2px 0 2px 14px;
  position: relative;
  color: var(--ink-2);
}
.perf-pros li::before { content: '+'; position: absolute; left: 0; color: var(--positive); font-weight: 700; }
.perf-cons li::before { content: '−'; position: absolute; left: 0; color: var(--negative); font-weight: 700; }
.perf-equip-opt-comment {
  font-size: 12px;
  line-height: 1.6;
  padding: 10px 12px;
  border-radius: 6px;
  background: var(--surface);
  border-left: 3px solid var(--ink-4);
  color: var(--ink-2);
}
.perf-equip-opt-comment.good    { border-left-color: var(--positive); }
.perf-equip-opt-comment.caution { border-left-color: var(--warn); }
.perf-equip-opt-comment strong { color: var(--ink); margin-right: 4px; }
.perf-equip-opt-rec {
  margin-top: 8px;
  font-size: 12px;
  line-height: 1.6;
  padding: 10px 12px;
  border-radius: 6px;
  background: var(--accent-soft);
  border-left: 3px solid var(--accent);
  color: var(--ink-2);
}
.perf-equip-opt-rec strong { color: var(--accent-ink); margin-right: 4px; }

/* ── Perf — 動線 ─────────────────────────── */
.perf-flow {
  max-width: 1100px;
  margin: 0 auto;
  display: flex;
  flex-direction: column;
  gap: 20px;
}
.perf-flow-totals {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 14px;
}
.perf-flow-total-card {
  background: linear-gradient(135deg, var(--surface) 0%, var(--accent-soft) 100%);
  border: 1px solid var(--line);
  border-radius: 14px;
  padding: 22px 24px;
  display: flex;
  flex-direction: column;
  gap: 6px;
}
.perf-flow-total-v { display: flex; align-items: baseline; gap: 8px; }
.perf-flow-list { display: flex; flex-direction: column; gap: 12px; }
.perf-flow-item {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 18px 22px;
}
.perf-flow-item-h {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 14px;
}
.perf-flow-icon { font-size: 22px; }
.perf-flow-save {
  margin-left: auto;
  background: var(--accent-soft);
  color: var(--accent-ink);
  padding: 4px 10px;
  border-radius: 999px;
  font-size: 11px;
  font-weight: 700;
}
.perf-flow-ba {
  display: grid;
  grid-template-columns: 1fr auto 1fr;
  gap: 14px;
  align-items: center;
  background: var(--bg);
  border: 1px dashed var(--line-2);
  border-radius: 10px;
  padding: 12px 14px;
  margin-bottom: 12px;
}
.perf-flow-before, .perf-flow-after { font-size: 12px; line-height: 1.55; color: var(--ink-2); }
.perf-flow-before .t-eyebrow, .perf-flow-after .t-eyebrow { display: block; margin-bottom: 4px; font-size: 9px; }
.perf-flow-arrow { color: var(--accent); font-size: 22px; font-weight: 300; }
.perf-flow-tips { list-style: none; padding: 0; display: flex; flex-direction: column; gap: 4px; }
.perf-flow-tips li {
  font-size: 12px;
  line-height: 1.55;
  color: var(--ink-2);
  padding-left: 14px;
  position: relative;
}
.perf-flow-tips li::before {
  content: '·';
  position: absolute;
  left: 4px;
  color: var(--accent);
  font-weight: 700;
}

/* ── Perf — コスト ───────────────────────── */
.perf-cost {
  max-width: 1100px;
  margin: 0 auto;
  display: flex;
  flex-direction: column;
  gap: 20px;
}
.perf-cost-totals {
  display: grid;
  grid-template-columns: 1fr 1fr 1fr;
  gap: 14px;
}
.perf-cost-total {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 14px;
  padding: 20px 22px;
}
.perf-cost-total.accent {
  background: linear-gradient(135deg, var(--surface) 0%, var(--accent-soft) 100%);
}
.perf-cost-total-v { display: flex; align-items: baseline; gap: 8px; margin-top: 4px; }
.perf-cost-table {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 12px;
  overflow: hidden;
}
.perf-cost-row {
  display: grid;
  grid-template-columns: 1.2fr 2fr 0.7fr 0.7fr 0.7fr;
  gap: 12px;
  align-items: center;
  padding: 12px 18px;
  border-bottom: 1px solid var(--line-2);
  font-size: 13px;
}
.perf-cost-row:last-child { border-bottom: none; }
.perf-cost-row.perf-cost-head {
  background: var(--surface-2);
  font-size: 11px;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--ink-3);
  font-weight: 700;
}
.perf-cost-row.perf-cost-foot {
  background: var(--accent-soft);
  font-weight: 700;
  color: var(--accent-ink);
}
.perf-cost-row .ta-r { text-align: right; }

/* ── Perf — 設計指針 ─────────────────────── */
.perf-guide {
  max-width: 1100px;
  margin: 0 auto;
  display: flex;
  flex-direction: column;
  gap: 28px;
}
.perf-guide-section {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 14px;
  padding: 22px 24px;
}
.perf-guide-bullets {
  list-style: none;
  padding: 0;
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px 22px;
}
.perf-guide-bullets li {
  font-size: 12.5px;
  line-height: 1.55;
  color: var(--ink-2);
  padding-left: 18px;
  position: relative;
}
.perf-guide-bullets li::before {
  content: '◆';
  position: absolute;
  left: 0;
  color: var(--accent);
  font-size: 9px;
  top: 4px;
}
.perf-guide-rules {
  display: grid;
  gap: 12px;
}
.perf-guide-rule {
  display: grid;
  grid-template-columns: 36px 1fr;
  gap: 12px;
  padding: 12px 14px;
  background: var(--bg);
  border-radius: 8px;
  border: 1px solid var(--line-2);
}
.perf-guide-rule-num {
  font-size: 22px;
  font-weight: 700;
  color: var(--accent);
  line-height: 1;
}
.perf-guide-recs {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
  gap: 12px;
}
.perf-guide-rec {
  background: var(--bg);
  border: 1px solid var(--line-2);
  border-radius: 10px;
  padding: 14px 16px;
}
.perf-guide-specs {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: 12px;
}
.perf-guide-spec {
  background: var(--bg);
  border: 1px solid var(--line-2);
  border-radius: 10px;
  padding: 14px 16px;
}
.perf-guide-spec ul { list-style: none; padding: 0; display: flex; flex-direction: column; gap: 4px; }
.perf-guide-spec li {
  font-size: 11.5px;
  line-height: 1.55;
  color: var(--ink-2);
  padding-left: 12px;
  position: relative;
}
.perf-guide-spec li::before {
  content: '·';
  position: absolute;
  left: 2px;
  color: var(--accent);
  font-weight: 700;
}
