/* iPhone参考メモ: iphone-design-notes.css。編集画面用に余白と文字サイズを調整。 */
:root {
  color-scheme: light;
  --ink: #1d1d1d;
  --muted: #666666;
  --line: #dedede;
  --paper: #f5f5f5;
  --surface: #ffffff;
  --soft: #fafafa;
  --selected: #ebebeb;
  --floor-lower: #2763a6;
  --floor-upper: #7651a8;
  --radius: 24px;
  --gutter: clamp(12px, 2vw, 24px);
  /* UI共通の文字階層。画面幅では縮めず、折り返しと配置で調整する。 */
  --type-title: 28px;
  --type-heading: 20px;
  --type-body: 14px;
  --type-caption: 12px;
  --type-input: 16px; /* iPhoneで入力時に自動ズームさせないための専用値 */
  --font: -apple-system, BlinkMacSystemFont, "Helvetica Neue", "Hiragino Kaku Gothic ProN", "Yu Gothic", sans-serif;
}
* { box-sizing: border-box; }
body { margin: 0; background: var(--paper); color: var(--ink); font: var(--type-body)/1.5 var(--font); -webkit-font-smoothing: antialiased; }
[hidden] { display: none !important; }
button, a, select, summary { -webkit-tap-highlight-color: transparent; }
button, select, input { font: inherit; }
button {
  min-height: 44px; padding: 10px 16px; cursor: pointer;
  color: var(--ink); background: var(--surface); border: 1px solid var(--line);
  border-radius: 999px; font-weight: 500; line-height: 1.4;
  transition: background-color 160ms ease, border-color 160ms ease;
}
button:hover:not(:disabled) { background: #f0f0f0; border-color: #b5b5b5; }
button:disabled { background: #f5f5f5; color: #898989; border-color: #e5e5e5; cursor: not-allowed; box-shadow: none; }
button:focus-visible, a:focus-visible, select:focus-visible, input:focus-visible, summary:focus-visible { outline: 2px solid var(--ink); outline-offset: 3px; }
a { color: var(--ink); text-underline-offset: 4px; }
summary { cursor: pointer; }
h1, h2, h3, p { margin-top: 0; }
.topbar { min-height: 64px; padding: 10px var(--gutter); display: flex; align-items: center; gap: 20px; background: var(--surface); border-bottom: 1px solid var(--line); }
.brand { display: flex; align-items: center; gap: 16px; text-decoration: none; font-weight: 700; letter-spacing: 1px; }
.brand span { font-weight: 400; color: var(--muted); letter-spacing: normal; }
.top-actions { display: flex; align-items: center; justify-content: flex-end; flex-wrap: wrap; gap: 8px 16px; margin-left: auto; }
.save-state { color: var(--muted); white-space: nowrap; }
.save-state::before { content: '✓ '; }
.quiet { background: transparent; }
h1 { margin: 0; font-weight: 600; line-height: 1.2; }
.workspace-title { font-weight: 500; }
.editor-layout { display: grid; grid-template-columns: minmax(0, 1fr) 320px; gap: 16px; height: calc(100dvh - 65px); min-height: 640px; padding: 16px var(--gutter); }
.panel { min-width: 0; background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); }
/* 操作は右サイドバーに集約し、図面とは別にスクロールする。 */
.editor-sidebar { display: flex; flex-direction: column; min-height: 0; overflow: hidden; }
.sidebar-tabs { display: flex; gap: 4px; padding: 12px; border-bottom: 1px solid var(--line); flex-shrink: 0; }
.sidebar-tabs button { flex: 1; padding: 10px 6px; border-color: transparent; background: transparent; white-space: nowrap; }
.sidebar-tabs [aria-selected=true] { background: var(--ink); color: white; }
.sidebar-tabs [aria-selected=true]:hover { background: #333333; color: white; }
.sidebar-scroll { flex: 1; min-height: 0; overflow-y: auto; overscroll-behavior: contain; }
.sidebar-pane { padding: 20px; }
.sidebar-pane > h2 { margin: 0 0 20px; font-weight: 600; }
.sidebar-description { color: var(--muted); line-height: 1.7; margin: 20px 0 0; }
#add-inspector-slot:not(:empty) { margin-top: 16px; }
#add-choose { margin: -8px 0 0 -8px; color: var(--muted); }
#building-inspector-slot:not(:empty) { padding: 18px 0; border-bottom: 1px solid var(--line); }
.site-alert { display: inline-block; width: 6px; height: 6px; border-radius: 50%; margin-left: 4px; background: currentColor; vertical-align: middle; }
.site-overview { padding-bottom: 16px; }
.site-overview > span, .site-overview p { color: var(--muted); }
.site-overview strong { display: flex; align-items: baseline; gap: 6px; font-weight: 600; margin: 8px 0 2px; }
.site-overview small { font-weight: 400; }
.site-overview p { margin: 0; }
#reset { width: 100%; margin-top: 20px; }

.panel-title { display: flex; align-items: center; justify-content: space-between; }
.panel-title h2 { margin: 0; font-weight: 600; }
.palette { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 8px; margin-top: 16px; }
.palette-item { width: 100%; display: flex; align-items: center; gap: 10px; padding: 12px 10px; text-align: left; border-radius: 14px; }
.palette-item.active { background: var(--selected); border-color: var(--ink); box-shadow: inset 0 0 0 1px var(--ink); }
.block-icon { display: grid; place-items: center; width: 22px; height: 22px; flex-shrink: 0; color: var(--ink); }
.block-icon svg { width: 22px; height: 22px; }
.palette-item strong { display: block; font-weight: 500; }
.palette-item small { display: block; margin-top: 3px; font-weight: 400; color: var(--muted); white-space: nowrap; }
.palette-item .plus { display: none; }
.drawing-panel { display: flex; flex-direction: column; min-height: 0; overflow: hidden; }
.canvas-toolbar { min-height: 66px; display: flex; align-items: center; justify-content: space-between; flex-wrap: wrap; flex-shrink: 0; gap: 8px; padding: 10px 16px; border-bottom: 1px solid var(--line); }
.floor-pill { font-weight: 600; white-space: nowrap; }
.floor-pill small { display: block; margin-top: 3px; color: var(--muted); font-weight: 400; }
.canvas-actions { display: flex; align-items: center; gap: 14px; margin-left: auto; }
.view-options { display: flex; align-items: center; gap: 6px; }
.view-options button { padding: 10px 12px; }
.view-options button[aria-pressed=true] { background: var(--selected); border-color: transparent; }
.primary, #dimensions-open, #dimensions-close, .inset-actions button { background: var(--ink); color: #ffffff; border-color: var(--ink); }
.primary:hover:not(:disabled), #dimensions-open:hover:not(:disabled), #dimensions-close:hover:not(:disabled), .inset-actions button:hover:not(:disabled) { background: #333333; border-color: #333333; color: #ffffff; }
.building-controls { display: grid; grid-template-columns: 1fr auto; align-items: center; gap: 12px; padding: 16px 0; border-block: 1px solid var(--line); }
.building-controls > div:first-child { grid-column: 1 / -1; }
.building-controls span { display: block; color: var(--muted); }
.building-controls strong { display: block; font-weight: 600; margin-top: 3px; white-space: nowrap; }
.lock-switch { display: flex; padding: 3px; border-radius: 999px; background: #ededed; gap: 2px; }
.lock-switch button { background: transparent; border-color: transparent; padding-inline: 12px; white-space: nowrap; }
.lock-switch button[aria-pressed=true] { background: var(--surface); color: var(--ink); border-color: #d2d2d2; }
#edit-building { padding-inline: 12px; white-space: nowrap; }
#edit-building[aria-pressed=true] { background: var(--ink); border-color: var(--ink); color: #ffffff; }
.site-settings { border-bottom: 1px solid var(--line); }
.site-settings summary { min-height: 48px; padding: 13px 0; line-height: 1.8; }
.site-settings summary strong { font-weight: 600; }
.site-settings summary > span { display: block; margin-left: 16px; color: var(--muted); }
.site-settings form { padding-bottom: 16px; }
.site-settings form > p { line-height: 1.7; margin: 0 0 14px; color: var(--muted); }
.inset-inputs { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; }
.inset-inputs label { font-weight: 500; }
.inset-inputs label > span { display: flex; align-items: center; gap: 5px; margin-top: 7px; color: var(--muted); }
.inset-inputs input { min-width: 0; width: 100%; min-height: 44px; padding: 9px 4px; border: 1px solid #b5b5b5; border-radius: 10px; background: #ffffff; color: var(--ink); font-weight: 500; text-align: center; }
.inset-inputs input[aria-invalid=true] { border: 2px solid var(--ink); }
.inset-actions { display: flex; flex-direction: column; align-items: stretch; gap: 12px; margin: 16px 0 12px; }
.inset-actions > span { color: var(--muted); }
.inset-actions button { flex-shrink: 0; }
.site-settings form > .inset-note { margin-bottom: 0; }
.site-settings form > .inset-error, .site-size-form > .inset-error { padding: 8px 12px; color: var(--ink); background: var(--selected); border-left: 3px solid var(--ink); border-radius: 6px; }
.site-legend { display: flex; flex-wrap: wrap; gap: 8px 16px; padding: 16px 0 8px; color: var(--muted); }
.site-legend > span { display: flex; align-items: center; gap: 6px; }
.site-legend i { display: inline-block; width: 16px; height: 12px; }
.legend-hatch { background: repeating-linear-gradient(135deg, #999999 0 1px, #f0f0f0 1px 5px); border: 1px solid #b5b5b5; }
.legend-boundary { border: 1.5px dashed #666666; }
.legend-conflict { background: repeating-linear-gradient(45deg, transparent 0 3px, #ffffff 3px 4px), repeating-linear-gradient(135deg, #555555 0 3px, #ffffff 3px 4px); border: 1px solid #555555; }
.site-status { margin: 8px 0 0; line-height: 1.6; color: var(--muted); }
.site-status.has-conflict, .dimension-conflict { padding: 10px 12px; color: var(--ink); background: #f0f0f0; border: 1px solid var(--line); border-left: 3px solid var(--ink); border-radius: 8px; }
.canvas-hint { flex-shrink: 0; padding: 10px 16px; margin: 0; color: var(--muted); line-height: 1.6; }
.canvas-hint.adding { color: var(--ink); font-weight: 500; }
.canvas-wrap { flex: 1; min-height: 0; position: relative; display: flex; background: #ffffff; padding: 8px 16px 0; }
#plan { display: block; width: 100%; height: 100%; min-height: 0; overflow: visible; touch-action: none; user-select: none; }
svg text { font-family: -apple-system, "Hiragino Kaku Gothic ProN", sans-serif; }
.room { cursor: pointer; transition: fill 120ms ease; }
.room:hover { fill: #f2f2f2; }
.room.selected { fill: #e8e8e8; }
.room.movable-stair { cursor: grab; }
.dragging .room.movable-stair { cursor: grabbing; }
.room:focus-visible { outline: none; stroke: #1d1d1d; stroke-width: 65; }
.room-label { pointer-events: none; }
.placing, .placing .room { cursor: crosshair; }
#plan:focus { outline: none; }
#plan.placing:focus-visible { outline: 2px solid var(--ink); outline-offset: -2px; }
.resize-handle, .shared-boundary { touch-action: none; outline: none; }
.resize-handle.horizontal, .shared-boundary.horizontal { cursor: ew-resize; }
.resize-handle.vertical, .shared-boundary.vertical { cursor: ns-resize; }
.resize-handle { color: #333333; }
.resize-handle .handle-face { fill: #ffffff; stroke: currentColor; stroke-width: 1; vector-effect: non-scaling-stroke; }
.resize-handle .handle-arrow { stroke: currentColor; }
.resize-handle:hover .handle-face, .resize-handle:focus-visible .handle-face { fill: #333333; }
.resize-handle:hover .handle-arrow, .resize-handle:focus-visible .handle-arrow { stroke: #ffffff; }
.resize-handle:focus-visible .handle-face { stroke-width: 2; }
.shared-boundary:hover .boundary-face, .shared-boundary:focus-visible .boundary-face { stroke: #1d1d1d; stroke-width: 2; }
.ldk-edge.blocked, .ldk-handle.blocked { cursor: not-allowed; }
.ldk-handle.blocked { color: #888888; opacity: .6; }
.ldk-handle.blocked:hover .handle-face { fill: #888888; }
.dragging { user-select: none; }
.drag-feedback { position: absolute; z-index: 2; bottom: 12px; left: 50%; transform: translateX(-50%); width: max-content; max-width: 94%; padding: 10px 14px; border-radius: 12px; background: #1d1d1def; color: #ffffff; line-height: 1.6; pointer-events: none; }
.drag-feedback.invalid { border: 2px solid #1d1d1d; background: #ffffff; color: var(--ink); }
.canvas-footer { flex-shrink: 0; min-height: 40px; display: flex; align-items: center; justify-content: space-between; gap: 10px; padding: 10px 16px; border-top: 1px solid var(--line); }
.history { display: flex; align-items: center; gap: 6px; }
.history button { width: 44px; padding: 0; }
.canvas-footer { color: var(--muted); }
#history-note { white-space: nowrap; }
.text-button { border-color: transparent; background: transparent; padding-inline: 8px; }
.inspector { padding: 0; }
.inspector h2 { margin: 0; font-weight: 600; line-height: 1.3; }
.room-metrics { display: flex; align-items: baseline; gap: 8px; margin: 16px 0 2px; }
.room-metrics strong { font-weight: 600; line-height: 1.25; letter-spacing: -.02em; font-variant-numeric: tabular-nums; }
.room-metrics span { color: var(--muted); }
.size-line { margin: 0; color: var(--muted); font-variant-numeric: tabular-nums; }
.divider { border-top: 1px solid var(--line); margin: 22px 0; }
.edit-context { color: var(--muted); line-height: 1.8; margin: 12px 0; }
.tool-row { display: flex; gap: 8px; margin-top: 16px; }
.tool-row button { flex: 1; padding: 10px 6px; }
.inspector label { display: block; color: var(--muted); }
.inspector select { display: block; min-height: 44px; width: 100%; margin-top: 8px; padding: 10px 12px; border: 1px solid #b5b5b5; border-radius: 12px; background: #ffffff; color: var(--ink); }
.primary { width: 100%; margin-top: 16px; }
.place-count { margin: 0; padding: 12px; background: var(--paper); border-radius: 12px; color: var(--muted); line-height: 1.7; }
/* 選択した部屋の情報は図面に付属させ、サイドバーの道具と分離する。 */
.selection-bar { flex-shrink: 0; padding: 10px 16px; border-top: 1px solid var(--line); }
.selection-bar .inspector { display: flex; align-items: center; justify-content: space-between; flex-wrap: wrap; gap: 12px 20px; }
.selection-info { display: flex; align-items: center; flex-wrap: wrap; gap: 8px 16px; min-width: 0; }
.selection-metrics { display: flex; align-items: baseline; flex-wrap: wrap; gap: 6px 12px; font-variant-numeric: tabular-nums; }
.selection-metrics strong { font-weight: 600; }
.selection-metrics strong span { margin-left: 4px; font-weight: 400; color: var(--muted); }
.selection-actions { display: flex; align-items: center; flex-wrap: wrap; gap: 8px; }
.selection-actions button { padding-inline: 12px; }
.selection-actions select { width: 112px; margin: 0; padding: 9px 10px; }
.stair-move-instruction { font-size: var(--type-caption); color: var(--muted); }
#stairs-toggle[aria-pressed=true] { background: var(--ink); color: white; border-color: var(--ink); }
.stair-edit-legend { width: 100%; display: flex; flex-wrap: wrap; align-items: center; gap: 8px 18px; font-size: var(--type-caption); }
.stair-edit-legend > span { display: inline-flex; align-items: center; gap: 6px; }
.stair-edit-legend strong { font-weight: 500; font-variant-numeric: tabular-nums; }
.stair-edit-legend small { color: var(--muted); font-size: inherit; }
.floor-1 { color: var(--floor-lower); }
.floor-2 { color: var(--floor-upper); }
.stair-key { width: 20px; border-top: 2px solid currentColor; }
.stair-key.reference { border-top-style: dashed; }
.stair-guide-fill { fill: currentColor; fill-opacity: .08; }
.stair-guide-other, .stair-guide-halo { fill: none; stroke: currentColor; stroke-width: 2.5; vector-effect: non-scaling-stroke; }
.stair-guide-other { stroke-dasharray: 6 4; }
.stair-guide-halo { stroke: white; stroke-width: 5; stroke-dasharray: 6 4; }
.stair-reference-label rect { fill: white; stroke: currentColor; stroke-width: 1.25; vector-effect: non-scaling-stroke; }
.stair-label-leader { fill: none; stroke: currentColor; stroke-width: 1.25; vector-effect: non-scaling-stroke; }
.no-overlap { text-decoration: underline; text-underline-offset: 3px; }
.stair-move-limits { width: 100%; font-size: var(--type-caption); color: var(--muted); }
.stair-move-limits summary { min-height: 30px; padding: 5px 0; }
.stair-move-limits > div { display: grid; grid-template-columns: repeat(2,minmax(0,1fr)); gap: 6px 18px; margin-top: 6px; }
.stair-move-limits > div span { display: flex; gap: 8px; }
.stair-move-limits strong { color: var(--ink); white-space: nowrap; font-weight: 500; }
.visually-hidden { position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip-path: inset(50%); white-space: nowrap; border: 0; }
.empty-inspector { padding: 30px 0; color: var(--muted); text-align: center; }
.editor-help { border-top: 1px solid var(--line); padding: 0 20px 8px; color: var(--muted); line-height: 1.8; }
.editor-help summary { width: fit-content; min-height: 44px; padding-block: 10px; }
.editor-help > div { max-width: 900px; padding: 3px 0; }
.editor-help p { margin: 10px 0; }
.toast { position: fixed; bottom: 28px; left: 50%; transform: translate(-50%, 15px); opacity: 0; pointer-events: none; transition: opacity 160ms ease, transform 160ms ease; padding: 13px 20px; max-width: 90vw; z-index: 10; background: #1d1d1d; color: #ffffff; border-radius: 14px; line-height: 1.6; }
.toast.show { opacity: 1; transform: translate(-50%, 0); }
.toast.error { background: #ffffff; color: var(--ink); border: 2px solid var(--ink); }

/* 文字サイズはこの対応表に集約。図面SVG内の室名・寸法は対象外。 */
h1, .dimension-toolbar h1, .room-metrics strong, .site-overview strong {
  font-size: var(--type-title);
}
.brand, .workspace-title, .panel-title h2, .inspector h2, .sidebar-pane > h2,
.dimension-sheet-heading h2, .dimension-schedule h3 {
  font-size: var(--type-heading);
}
button, .palette-item strong, .floor-pill, .building-controls strong,
.site-settings summary, .site-settings form > p, .inset-inputs label,
.inset-actions > span, .site-status, .canvas-hint, .drag-feedback,
.room-metrics span, .size-line, .edit-context, .selection-metrics strong,
.inspector label, .place-count, .editor-help, .toast, .sidebar-description, .site-overview > span, .site-overview small,
#dimension-export-status, .dimension-conflict, .dimension-schedule table {
  font-size: var(--type-body);
}
.save-state, #saved-link, .site-overview p, .canvas-footer, .selection-metrics .size-line,
.palette-item small, .floor-pill small, .building-controls span,
.site-settings summary > span, .inset-inputs label > span,
.site-settings form > .inset-note, .site-legend,
.dimension-toolbar h1 span,
#dimension-saved-link, .dimension-sheet-heading p,
.dimension-sheet-heading > div:last-child, .dimension-sheet-heading small,
.dimension-figure figcaption, .dimension-schedule th,
.dimension-schedule td:first-child > span, .dimension-schedule p,
.dimension-sheet-footer {
  font-size: var(--type-caption);
}
.inset-inputs input, .inspector select {
  font-size: var(--type-input);
}
/* 矢印・＋は文章ではなく操作アイコン。見出しと同じ20px。 */
.history button, .palette-item .plus {
  font-size: var(--type-heading);
}

/* 寸法表示と印刷にも同じ無彩色を使う。 */
#dimensions-dialog { position: fixed; inset: 0; width: 100%; height: 100dvh; max-width: none; max-height: none; margin: 0; padding: 0; border: 0; background: var(--paper); color: var(--ink); overflow: auto; }
#dimensions-dialog::backdrop { background: var(--paper); }
.dimension-toolbar { position: sticky; top: 0; z-index: 4; display: flex; align-items: center; justify-content: space-between; gap: 20px; flex-wrap: wrap; padding: 16px var(--gutter); background: #ffffff; border-bottom: 1px solid var(--line); }
.dimension-toolbar h1 { font-weight: 600; }
.dimension-toolbar h1 span { display: inline-block; vertical-align: middle; padding: 5px 9px; margin-left: 8px; border-radius: 999px; background: var(--paper); color: var(--muted); font-weight: 400; }
.dimension-actions { display: flex; align-items: center; flex-wrap: wrap; gap: 8px; }
.dimension-actions button { white-space: nowrap; }
#dimension-export-status { padding: 12px 16px; background: #ebebeb; border-radius: 12px; }
.dimension-content { max-width: 1540px; margin: auto; padding: 24px var(--gutter) 40px; }
.dimension-view-tabs { display: inline-flex; gap: 4px; padding: 4px; margin-bottom: 18px; background: #e8e8e8; border-radius: 999px; }
.dimension-view-tabs button { background: transparent; border-color: transparent; padding-inline: 20px; }
.dimension-view-tabs [aria-selected=true] { background: #ffffff; border-color: #d2d2d2; font-weight: 600; }
.dimension-conflict { line-height: 1.7; margin-bottom: 18px; }
.dimension-sheet { background: #ffffff; border: 1px solid var(--line); border-radius: 20px; padding: 28px; }
.dimension-sheet-heading { display: flex; justify-content: space-between; align-items: flex-start; gap: 20px; padding-bottom: 18px; border-bottom: 1px solid #b5b5b5; }
.dimension-sheet-heading h2 { font-weight: 600; margin: 0 0 8px; }
.dimension-sheet-heading p { color: var(--muted); margin: 0; }
.dimension-sheet-heading > div:last-child { text-align: right; line-height: 1.8; white-space: nowrap; }
.dimension-sheet-heading small { display: block; color: var(--muted); }
.dimension-sheet-body { display: grid; grid-template-columns: minmax(0, 1fr) 320px; gap: 24px; align-items: start; }
.dimension-figure { margin: 16px 0 0; min-width: 0; }
#dimension-plan { display: block; width: 100%; height: auto; overflow: visible; }
.dimension-figure figcaption { padding: 6px 10px; color: var(--muted); line-height: 1.8; text-align: center; }
.dimension-schedule { padding-top: 26px; }
.dimension-schedule h3 { margin: 0 0 14px; font-weight: 600; }
.dimension-schedule table { border-collapse: collapse; width: 100%; font-variant-numeric: tabular-nums; }
.dimension-schedule th { padding: 10px 5px; text-align: right; font-weight: 500; white-space: nowrap; color: var(--muted); background: var(--paper); }
.dimension-schedule td { padding: 12px 5px; text-align: right; border-bottom: 1px solid var(--line); white-space: nowrap; }
.dimension-schedule :is(th, td):first-child { text-align: left; }
.dimension-schedule td:first-child > span { color: var(--muted); margin-right: 4px; }
.dimension-schedule p { margin-top: 15px; color: var(--muted); line-height: 1.8; }
.dimension-schedule .site-legend { padding: 8px 0; }
.dimension-shortfall { background: #ebebeb; font-weight: 600; }
.dimension-shortfall td:first-child { border-left: 3px solid var(--ink); }
.dimension-sheet-footer { border-top: 1px solid var(--line); padding-top: 16px; margin-top: 20px; line-height: 1.8; color: var(--muted); }

@media (max-width: 1100px) {
  .editor-layout { grid-template-columns: minmax(0, 1fr) 300px; gap: 12px; }
  .canvas-toolbar { align-items: flex-start; }
  .canvas-actions { gap: 8px; }
  .floor-pill small { display: none; }
  .view-options button { padding-inline: 10px; }
  .sidebar-pane { padding: 18px; }
  .palette-item { gap: 6px; padding-inline: 8px; }
  .block-icon, .block-icon svg { width: 20px; height: 20px; }
  .dimension-sheet-body { grid-template-columns: 1fr; }
  .dimension-figure { max-width: 860px; margin-inline: auto; width: 100%; }
}
@media (max-width: 760px) {
  :root { --gutter: 12px; --radius: 18px; }
  .topbar { gap: 12px; flex-wrap: wrap; }
  .top-actions { gap: 6px; }
  .top-actions button { padding-inline: 12px; }
  .save-state { display: none; }
  .editor-layout { grid-template-columns: minmax(0, 1fr); height: auto; min-height: 0; }
  .drawing-panel { height: min(740px, 85dvh); min-height: 560px; }
  .editor-sidebar { min-height: 360px; }
  .sidebar-scroll { overflow: visible; }
  .sidebar-tabs { position: sticky; top: 0; z-index: 1; background: var(--surface); }
  .canvas-toolbar { padding: 10px 12px; }
  .canvas-actions { flex-wrap: wrap; justify-content: flex-end; gap: 6px; }
  .history { gap: 4px; }
  .view-options { gap: 4px; }
  .view-options button { padding-inline: 8px; }
  .canvas-wrap { padding-inline: 6px; }
  .canvas-hint, .canvas-footer, .selection-bar { padding-inline: 12px; }
  .selection-actions { gap: 6px; }
  .selection-actions select { width: 106px; }
  .selection-bar .inspector { gap: 10px; }
  .sidebar-pane { padding: 20px; }
  .palette { grid-template-columns: repeat(3, minmax(0, 1fr)); }
  .palette-item { flex-direction: column; text-align: center; }
  .palette-item .block-icon { display: none; }
  .toast { bottom: 18px; }
  .dimension-toolbar { gap: 12px; padding: 14px 12px; }
  .dimension-actions { width: 100%; justify-content: flex-end; gap: 6px; }
  .dimension-actions button { padding-inline: 12px; }
  .dimension-content { padding: 16px 10px 25px; }
  .dimension-view-tabs { display: flex; }
  .dimension-view-tabs button { flex: 1; padding-inline: 10px; }
  .dimension-sheet { padding: 16px 8px; border-radius: 16px; }
  .dimension-sheet-heading { gap: 12px; flex-wrap: wrap; padding: 0 6px 14px; }
  .dimension-sheet-heading > div:last-child { text-align: left; }
  .dimension-schedule { padding: 12px 6px 0; }
}
@media (prefers-reduced-motion: reduce) {
  button, .room, .toast { transition: none; }
}
@media print {
  @page { size: A3 landscape; margin: 12mm; }
  body:has(#dimensions-dialog[open]) > *:not(#dimensions-dialog) { display: none !important; }
  #dimensions-dialog[open] { position: static; display: block; height: auto; width: 100%; overflow: visible; background: #ffffff; max-height: none; }
  #dimensions-dialog::backdrop, .dimension-toolbar, .dimension-view-tabs, .dimension-figure figcaption, #dimension-export-status { display: none !important; }
  .dimension-content { padding: 0; max-width: none; }
  .dimension-sheet { border: 0; border-radius: 0; padding: 0; }
  .dimension-sheet-body { grid-template-columns: minmax(0, 1fr) 290px; gap: 20px; }
  .dimension-figure { width: 100%; margin: 0; max-width: none; }
  #dimension-plan { height: 205mm; width: 100%; }
  .dimension-schedule { padding-top: 18px; }
  .dimension-sheet-heading { padding-bottom: 12px; }
  .dimension-conflict { padding: 6px 10px; margin-bottom: 10px; }
  .dimension-sheet-footer { margin-top: 8px; padding-top: 8px; }
  * { -webkit-print-color-adjust: exact; print-color-adjust: exact; }
}

.site-size-form { padding-bottom: 16px; }
.site-size-form p { margin: 8px 0 0; line-height: 1.7; color: var(--muted); font-size: var(--type-caption); }

/* 建物全体を保存し、編集する階だけを大きく表示する。 */
.project-heading { min-width: 0; }
#plan-title { display: block; margin-top: 4px; max-width: 240px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; color: var(--muted); font-size: var(--type-caption); }
.topbar { gap: 16px; }
.top-actions { gap: 8px; }
#plan-save { background: var(--ink); color: white; }
#plan-save:disabled, #dimensions-open:disabled { background: #f5f5f5; color: #898989; border-color: #e5e5e5; }
.save-state::before { content: ''; }
.floor-tabs { display: flex; gap: 4px; padding: 3px; background: var(--paper); border-radius: 999px; }
.floor-tabs button { min-width: 64px; padding: 8px 14px; border-color: transparent; background: transparent; }
.floor-tabs button[aria-selected=true] { background: var(--ink); color: white; }
.floor-comparison { display: flex; flex-wrap: wrap; align-items: center; gap: 6px 14px; min-height: 58px; padding: 6px 16px; border-bottom: 1px solid var(--line); flex-shrink: 0; }
#floor-context { color: var(--muted); font-size: var(--type-caption); }
#edit-reference-controls { display: flex; gap: 8px; margin-left: auto; }
#floor-overlay-toggle[aria-pressed=true] { background: var(--selected); border-color: transparent; }
#floor-overlay-toggle[aria-pressed=true]::before { content: '✓ '; }
#comparison-heading { display: flex; align-items: center; flex: 0 0 138px; min-height: 50px; font-size: var(--type-body); font-weight: 600; }
.comparison-targets { display: flex; gap: 2px; padding: 2px; background: var(--paper); border-radius: 999px; }
.comparison-targets button { min-height: 40px; padding: 8px 16px; border-color: transparent; background: transparent; }
.comparison-targets button[aria-pressed=true] { background: var(--ink); color: white; }
.comparison-legend { display: flex; flex-wrap: wrap; gap: 12px; font-size: var(--type-caption); }
.comparison-legend span { display: inline-flex; align-items: center; gap: 6px; }
.comparison-legend i { width: 20px; border-top: 2px solid var(--ink); }
.comparison-legend .lower-key { border-color: var(--floor-lower); }
.comparison-legend .upper-key { border-color: var(--floor-upper); border-top-style: dashed; }
#comparison-close { margin-left: auto; }
.edit-reference-line { fill: none; stroke: #858585; stroke-width: 1.25; stroke-dasharray: 5 5; vector-effect: non-scaling-stroke; }
.outdoor-reference { stroke: #999; stroke-dasharray: 9 5; }
.comparison-edge { fill: none; stroke-width: 2; vector-effect: non-scaling-stroke; pointer-events: none; }
.comparison-edge.lower { stroke: var(--floor-lower); }
.comparison-edge.upper { stroke: var(--floor-upper); stroke-dasharray: 7 5; }
.comparison-edge.common { stroke: var(--ink); }
.comparison-outdoor { fill: #f3f3f3; stroke: #888; stroke-width: 1.5; stroke-dasharray: 9 5; vector-effect: non-scaling-stroke; pointer-events: none; }
.comparison-focus, .comparison-focus-halo { fill: none; stroke: #1d1d1d; stroke-width: 2.5; vector-effect: non-scaling-stroke; pointer-events: none; }
.comparison-focus-halo { stroke: white; stroke-width: 6; }
.comparison-marker { cursor: pointer; outline: none; }
.comparison-marker:hover circle:nth-child(2), .comparison-marker:focus-visible circle:nth-child(2) { fill: #e5e5e5; }
.comparison-results { padding: 24px 20px; overflow-y: auto; flex: 1; }
.comparison-results h2 { font-size: var(--type-heading); margin-bottom: 12px; }
.comparison-results > p { color: var(--muted); line-height: 1.7; }
#comparison-result-list { display: grid; gap: 10px; }
.comparison-result { display: block; width: 100%; text-align: left; border-radius: 14px; padding: 14px; border-left: 3px solid var(--ink); }
.comparison-result.lower { border-left-color: var(--floor-lower); }
.comparison-result.upper { border-left-color: var(--floor-upper); }
.comparison-result.outdoor { border-left-color: #888; }
.comparison-result[aria-pressed=true] { background: var(--paper); outline: 2px solid var(--ink); outline-offset: 1px; }
.comparison-result-heading { display: flex; gap: 8px; align-items: center; }
.comparison-result-heading strong { font-size: var(--type-body); font-weight: 500; }
.comparison-number { display: grid; place-items: center; flex: 0 0 22px; height: 22px; font-size: var(--type-caption); border: 1px solid currentColor; border-radius: 50%; }
.comparison-result.lower .comparison-number { color: var(--floor-lower); }
.comparison-result.upper .comparison-number { color: var(--floor-upper); }
.comparison-result-area { display: block; margin: 10px 0 6px 30px; font-size: var(--type-heading); font-weight: 600; font-variant-numeric: tabular-nums; }
.comparison-result-area small { font-size: var(--type-caption); font-weight: 400; margin-left: 5px; }
.comparison-result-description, .comparison-empty { display: block; color: var(--muted); font-size: var(--type-caption); line-height: 1.7; }
.comparison-footnote, .comparison-stair-note { font-size: var(--type-caption); line-height: 1.7; margin-top: 24px; }
#comparison-measurements { border-top: 1px solid var(--line); margin-top: 24px; padding-top: 16px; }
#comparison-measurements h3 { font-size: var(--type-body); font-weight: 500; }
#comparison-measurements p { display: flex; justify-content: space-between; gap: 12px; margin-bottom: 8px; }
#comparison-measurements small { font-size: var(--type-caption); color: var(--muted); }
#comparison-selection { font-size: var(--type-body); color: var(--muted); }
.comparing .selection-bar { display: flex; align-items: center; }
.comparison-preview + .comparison-preview { margin-top: 12px; }
.preview-highlight { fill: #1d1d1d15; stroke: #111; stroke-width: 1.5; vector-effect: non-scaling-stroke; }
.floor-previews { flex: 0 0 112px; align-self: flex-start; margin-top: 12px; margin-right: 8px; }
.floor-preview { width: 100%; padding: 9px; border-radius: 12px; text-align: left; background: #fafafa; }
.floor-preview > span { display: flex; justify-content: space-between; gap: 4px; font-weight: 600; }
.floor-preview small { font-size: var(--type-caption); font-weight: 400; color: var(--muted); }
.floor-preview svg { display: block; width: 100%; height: 94px; margin-top: 6px; }
#plan { min-width: 0; flex: 1; }
.project-dialog { width: min(660px,calc(100vw - 32px)); max-height: calc(100dvh - 48px); padding: 24px; border: 1px solid var(--line); border-radius: 22px; color: var(--ink); background: white; }
.project-dialog::backdrop { background: #0006; backdrop-filter: blur(3px); }
.project-dialog h2 { font-size: var(--type-heading); margin: 0; }
.project-dialog h3 { font-size: var(--type-body); margin: 24px 0 12px; }
.project-dialog p { font-size: var(--type-body); line-height: 1.7; color: var(--muted); margin-top: 16px; }
.dialog-heading { display: flex; align-items: center; justify-content: space-between; gap: 16px; margin-bottom: 20px; }
.project-dialog label { font-size: var(--type-body); }
#plan-name { display: block; width: 100%; min-height: 44px; margin-top: 8px; border: 1px solid #b5b5b5; border-radius: 10px; padding: 10px 12px; font: inherit; font-size: var(--type-input); }
.save-copy { display: flex; align-items: center; gap: 8px; }
.save-copy input { width: 18px; height: 18px; }
.switch-actions { display: grid; gap: 8px; }
.switch-actions .primary { margin-top: 0; }
#saved-plan-list { display: grid; grid-template-columns: repeat(2,minmax(0,1fr)); gap: 12px; }
.plan-card { width: 100%; padding: 14px; border-radius: 14px; text-align: left; }
.plan-card > strong { font-size: var(--type-body); overflow-wrap: anywhere; }
.plan-card-floors { display: flex; gap: 14px; margin-top: 14px; }
.plan-card-floors > span { flex: 1; min-width: 0; font-size: var(--type-caption); color: var(--muted); }
.plan-card svg { display: block; width: 100%; height: 130px; margin-top: 6px; }
@media(max-width:900px) { .topbar { flex-wrap: wrap; } .top-actions { flex-wrap: wrap; } .editor-layout { height: calc(100dvh - 100px); } }
@media(max-width:700px) {
 .project-heading { flex: 1; } #plan-title { max-width: 230px; }
 .top-actions { width: 100%; margin-left: 0; justify-content: flex-end; } .top-actions button { padding-inline: 12px; }
 .top-actions .save-state { display: block; margin-right: auto; }
 .floor-previews { flex-basis: 82px; margin-right: 4px; }
 .floor-preview { padding: 6px; } .floor-preview > span { display: block; } .floor-preview small { display: block; margin-top: 3px; } .floor-preview svg { height: 74px; }
 .project-dialog { padding: 20px; } #saved-plan-list { grid-template-columns: 1fr; }
 .floor-comparison { padding: 6px 12px; gap: 6px; min-height: 100px; }
 #floor-context { width: 100%; } #edit-reference-controls { margin-left: 0; width: 100%; }
 #edit-reference-controls button { flex: 1; padding-inline: 10px; }
 .comparison-legend { gap: 8px; } #comparison-close { min-height: 36px; padding: 6px 12px; }
 .comparison-results { overflow: visible; } #comparison-selection { font-size: var(--type-caption); }
}

/* Reference templates and the adjacent-floor selector for three-storey plans. */
#reference-floor-control { display:flex;align-items:center;gap:8px;font-size:var(--type-caption);color:var(--muted); }
#reference-floor-control[hidden] {display:none;}
#reference-floor {padding:6px 10px;border-radius:8px;width:auto;}
.floor-3 {color:#6a7046;}
.plan-card-description {display:block;font-size:var(--type-caption);color:var(--muted);margin-top:6px;}
.floor-preview + .floor-preview {margin-top:10px;}
#layout-dialog {width:min(880px,calc(100vw - 32px));}
#template-list {display:grid;grid-template-columns:repeat(2,minmax(0,1fr));gap:12px;}
#template-list .plan-card svg {height:100px;}
@media(max-width:600px) {#template-list {grid-template-columns:1fr;} #template-list .plan-card svg {height:120px;}}

.site-part { cursor: grab; outline: none; }
.site-part:focus-visible > path { stroke: #222; stroke-width: 65; }
.dragging .site-part { cursor: grabbing; }
.placing .site-part { cursor: crosshair; }
