* { box-sizing: border-box; }
:root { --pf-blue:#45628b; --pf-sky:#9bbcd0; --pf-mist:#e4f7f8; --pf-coral:#e27354; --pf-navy:#2b3445; --pf-white:#ffffff; --pf-ink:#2b3445; --pf-soft:#f6fbfc; --pf-line:#d7e6ec; }
html, body { margin: 0; padding: 0; background: var(--pf-white); color: var(--pf-ink); font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', 'Inter', 'SF Pro Display', system-ui, sans-serif; }
button, input, select { font: inherit; }
button { cursor: pointer; }
.page-shell { max-width: 1480px; margin: 0 auto; padding: 16px; }
.card { background: var(--pf-white); border: 1px solid var(--pf-line); border-radius: 16px; box-shadow: 0 12px 34px rgba(43,52,69,0.10); }
.header-card { padding: 18px; display: flex; flex-direction: column; gap: 16px; margin-bottom: 16px; }
h1, h2, h3 { margin: 0; color: var(--pf-navy); }
h1 { font-size: 28px; font-weight: 600; }
h2 { font-size: 20px; font-weight: 600; }
.muted { color: #45628b; margin: 6px 0 0; line-height: 1.4; }
.controls-grid { display: grid; grid-template-columns: repeat(5, minmax(0, 1fr)); gap: 12px; }
.field { display: flex; flex-direction: column; gap: 6px; }
.field label { font-size: 12px; text-transform: uppercase; letter-spacing: 0.05em; color: var(--pf-blue); font-weight: 700; }
.field input, .field select { width: 100%; padding: 11px 12px; border-radius: 10px; border: 1px solid var(--pf-sky); background: var(--pf-white); color: var(--pf-navy); }
.field input:focus, .field select:focus { outline: none; border-color: var(--pf-coral); box-shadow: 0 0 0 3px rgba(226, 115, 84, 0.16); }
.button-row { display: flex; gap: 10px; flex-wrap: wrap; }
.primary, .secondary { padding: 11px 14px; border-radius: 10px; border: 1px solid transparent; font-weight: 500; transition: all 0.15s ease; }
.primary { background: var(--pf-coral); color: white; }
.primary:hover { background: #cf6240; }
.secondary { background: var(--pf-white); color: var(--pf-navy); border-color: var(--pf-sky); }
.secondary:hover { background: var(--pf-mist); border-color: var(--pf-blue); }
.status-line { background: var(--pf-mist); border: 1px solid var(--pf-sky); border-radius: 12px; padding: 10px 12px; color: var(--pf-blue); font-size: 13px; }
.planner-start-card { padding: 22px; margin-bottom: 16px; display: flex; align-items: center; justify-content: space-between; gap: 18px; }
.start-actions { display: flex; gap: 12px; flex-wrap: wrap; }
.start-action { min-width: 210px; padding: 14px 18px; font-size: 16px; }
body.planner-start .top-settings-card,
body.planner-start .workspace-grid,
body.planner-start .page-footer,
body.planner-create .start-only,
body.planner-create .workspace-grid,
body.planner-load-mode .top-settings-card,
body.planner-load-mode .start-only,
body.planner-load-mode .stage-card,
body.planner-load-mode .sidebar-stack .card:not(.saved-layouts-card),
body.planner-editing .top-settings-card,
body.planner-editing .start-only,
body.planner-editing .load-only,
body.planner-settings .load-only,
body.planner-settings .start-only { display: none !important; }
body.planner-load-mode .workspace-grid { grid-template-columns: minmax(0, 760px); justify-content: center; }
body.planner-load-mode .saved-layouts-card { display: block !important; }
body.planner-create .top-settings-card,
body.planner-settings .top-settings-card { display: flex !important; }
body.planner-create .secondary-settings-action,
body.planner-settings .secondary-settings-action,
body.planner-create .top-settings-card > div:first-child,
body.planner-settings .top-settings-card > div:first-child,
body.planner-create .status-line,
body.planner-settings .status-line { display: none !important; }
body.planner-start .planner-start-card { max-width: 560px; margin: 15vh auto 16px; justify-content: center; }
.workspace-grid { display: grid; grid-template-columns: minmax(0, 1fr) 380px; gap: 16px; align-items: start; }
.stage-card { padding: 18px; }
.section-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-bottom: 14px; }
.section-head.compact { margin-bottom: 12px; }
.canvas-wrap { display: flex; justify-content: center; align-items: center; height: clamp(520px, calc(100vh - 245px), 760px); min-height: 420px; background: linear-gradient(180deg, var(--pf-mist) 0%, #ffffff 100%); border: 1px solid var(--pf-line); border-radius: 16px; padding: 0; overflow: hidden; }
.canvas-actions { margin-top: 12px; display: flex; gap: 10px; flex-wrap: wrap; }
.stage-shell { width: 100%; height: 100%; display: flex; align-items: center; justify-content: center; background: transparent; border: 0; border-radius: 16px; padding: 0; box-shadow: none; }
.room-stage { position: relative; background: #ffffff; border: 3px solid var(--pf-blue); overflow: visible; border-radius: 8px; touch-action: none; }
.room-grid { position: absolute; inset: 0; background-image: linear-gradient(to right, rgba(155, 188, 208, 0.22) 1px, transparent 1px), linear-gradient(to bottom, rgba(155, 188, 208, 0.22) 1px, transparent 1px); }
.room-label { display: none; }
.item { position: absolute; display: flex; align-items: center; justify-content: center; text-align: center; padding: 0; overflow: visible; background: transparent; border: none; border-radius: 0; box-shadow: none; user-select: none; cursor: pointer; transition: all 0.2s ease; touch-action: none; }
.item:hover { border: none; box-shadow: none; z-index: 5; }
.item.sectional-piece { background: transparent; }
.item.selected { border: none; box-shadow: none; z-index: 6; }
.item-inner { position: absolute; left: 50%; top: 50%; display: flex; flex-direction: column; align-items: center; justify-content: center; overflow: visible; transform-origin: center center; transition: transform 120ms ease; }
.item-placeholder { width: 100%; height: 100%; min-width: 28px; min-height: 28px; display: flex; align-items: center; justify-content: center; padding: 4px; background: var(--item-custom-color, var(--series-fill, #247489)); border: 2px solid var(--series-border, rgba(255,255,255,0.92)); border-radius: 4px; box-shadow: inset 0 0 0 1px rgba(255,255,255,0.28), 0 5px 13px rgba(43,52,69,0.16); }
.item-placeholder-label { font-size: 10px; line-height: 1.1; font-weight: 800; color: #ffffff; text-align: center; word-break: break-word; text-shadow: 0 1px 2px rgba(0,0,0,0.36); }
.item.selected .item-placeholder { border-color: #ffffff; box-shadow: 0 0 0 3px rgba(129,25,47,0.28), inset 0 0 0 1px rgba(255,255,255,0.28); }
.item-hover-thumb { position: absolute; left: calc(100% + 10px); top: 50%; transform: translateY(-50%); display: none; width: 140px; min-height: 52px; padding: 8px; background: rgba(255,255,255,0.98); border: 1px solid rgba(91, 159, 170, 0.6); border-radius: 10px; box-shadow: 0 10px 28px rgba(0,0,0,0.25); pointer-events: none; z-index: 20; }
.item:hover .item-hover-thumb { display: block; }
.item-hover-thumb.show-left { left: auto; right: calc(100% + 10px); }
.item-hover-thumb.show-above { top: auto; bottom: calc(100% + 10px); transform: none; }
.item-hover-thumb.show-left.show-above { transform: none; }
.item-hover-thumb.no-image { width: auto; min-width: 120px; }
.item-hover-thumb-label { font-size: 12px; line-height: 1.2; font-weight: 800; color: var(--pf-navy); text-align: center; margin-bottom: 6px; word-break: break-word; }
.item-hover-thumb.no-image .item-hover-thumb-label { margin-bottom: 0; }
.item-hover-thumb-img { width: 100%; height: auto; max-height: 120px; object-fit: contain; display: block; }
.item-avatar { width: 100%; height: 100%; object-fit: contain; object-position: center center; display: block; transform: scale(1.08); transform-origin: center center; }
.item-topdown { width: 100%; height: 100%; display: block; transform: scale(1.16); transform-origin: center center; }
.item-topdown .shadow { fill: var(--topdown-shadow, rgba(45, 69, 89, 0.12)); }
.item-topdown .surface { fill: var(--topdown-surface, #e9dccb); stroke: var(--topdown-line, #69564b); stroke-width: 2; }
.item-topdown .detail { fill: var(--topdown-detail, #dbc9b1); stroke: var(--topdown-line, #69564b); stroke-width: 1.3; }
.item-topdown .detail-soft { fill: var(--topdown-detail-soft, #efe5d8); }
.item-topdown .detail-strong { fill: var(--topdown-detail-strong, #cfb79a); }
.item-topdown .accent { fill: var(--topdown-accent, #b78b6d); stroke: var(--topdown-line, #69564b); stroke-width: 1.3; }
.item-topdown .line { stroke: var(--topdown-line, #7a6659); stroke-width: 1.2; stroke-linecap: round; fill: none; }
.item-topdown-rug .rug-surface { fill: var(--topdown-rug-surface, #d9e5eb); stroke-dasharray: 4 3; }
.item-topdown-rug .rug-line { stroke: rgba(91, 159, 170, 0.55); }
.item-topdown-table-round .table-surface,
.item-topdown-table-rect .table-surface { fill: var(--topdown-accent, #d3b08a); }
.item-topdown-cabinet .cabinet-surface { fill: var(--topdown-accent, #d2b28d); }
.item-copy { display: none; }
.item .dims { display: none; }
.item.obstruction .item-placeholder { background: #d9d9d9; border-color: #8f8f8f; box-shadow: inset 0 0 0 1px rgba(255,255,255,0.65), 0 4px 10px rgba(43,52,69,0.12); }
.item.obstruction .item-placeholder-label { color: #000000; text-shadow: none; font-weight: 900; }
.item.series-color-0 { --series-fill: #81192f; --series-border: #6b1427; }
.item.series-color-1 { --series-fill: #5c6f28; --series-border: #495820; }
.item.series-color-2 { --series-fill: #745995; --series-border: #5f497a; }
.item.series-color-3 { --series-fill: #247489; --series-border: #1b5f70; }
.item.series-color-4 { --series-fill: #ac4804; --series-border: #8d3a03; }
.item.series-color-5 { --series-fill: #81192f; --series-border: #6b1427; }
.item.series-color-6 { --series-fill: #5c6f28; --series-border: #495820; }
.item.series-color-7 { --series-fill: #745995; --series-border: #5f497a; }
.item.series-color-8 { --series-fill: #247489; --series-border: #1b5f70; }
.item.series-color-9 { --series-fill: #ac4804; --series-border: #8d3a03; }
.item.series-color-10 { --series-fill: #81192f; --series-border: #6b1427; }
.item.series-color-11 { --series-fill: #5c6f28; --series-border: #495820; }
.sidebar-stack { display: flex; flex-direction: column; gap: 16px; }
.sidebar-stack .card { padding: 16px; }
.catalog-results, .layout-list, .preset-list { display: flex; flex-direction: column; gap: 10px; }
.result-card, .saved-card, .info-card { background: var(--pf-soft); border: 1px solid var(--pf-line); border-radius: 12px; padding: 12px; }
.result-card h3, .saved-card h3, .info-card h3 { font-size: 15px; margin-bottom: 4px; font-weight: 600; }
.result-card p, .saved-card p, .info-card p { margin: 0 0 10px; color: var(--pf-blue); font-size: 13px; line-height: 1.4; }
.preset-card { background: var(--pf-soft); border: 1px solid var(--pf-line); border-radius: 12px; padding: 12px; }
.preset-card h3 { font-size: 15px; margin: 0 0 4px; font-weight: 600; }
.preset-card p { margin: 0 0 10px; color: var(--pf-blue); font-size: 13px; line-height: 1.4; }
.obstruction-note { margin-bottom: 10px; }
.obstruction-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 8px; }
.obstruction-tool { display: flex; flex-direction: column; align-items: flex-start; gap: 2px; padding: 10px; text-align: left; }
.obstruction-tool span { font-weight: 800; }
.obstruction-tool small { color: var(--pf-blue); font-size: 11px; }
.inline-field { margin-bottom: 12px; }
.group-note { margin: 10px 0; }
.group-chip { display: inline-flex; align-items: center; gap: 6px; }
.sectional-empty { padding: 2px 0; }
.meta-row { display: flex; gap: 8px; flex-wrap: wrap; margin-bottom: 10px; }
.badge { border: 1px solid var(--pf-sky); border-radius: 999px; padding: 4px 8px; font-size: 12px; color: var(--pf-blue); background: rgba(228, 247, 248, 0.85); }
.kv-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.helper { color: var(--pf-blue); font-size: 12px; line-height: 1.45; }
.selected-empty { color: var(--pf-blue); font-size: 14px; line-height: 1.5; }
.notice { background: var(--pf-mist); border: 1px solid var(--pf-sky); border-radius: 12px; padding: 12px; color: var(--pf-blue); font-size: 13px; }
#warningsPanel { display: none; }
.warning-section { margin-bottom: 14px; }
.warning-section h3 { font-size: 14px; margin-bottom: 8px; font-weight: 600; }
.error-section h3 { color: #e9a199; }
.warning-section.warning-section h3 { color: #f5c4b8; }
.warning-item { background: var(--pf-soft); border: 1px solid var(--pf-sky); border-radius: 8px; padding: 10px 12px; margin-bottom: 6px; font-size: 13px; line-height: 1.4; }
.warning-item.error { border-color: #c8767d; background: rgba(200, 118, 125, 0.12); color: #e9a199; }
.warning-item.warning { border-color: #f5c4b8; background: rgba(245, 196, 184, 0.12); color: #f5c4b8; }
@media (max-width: 1100px) {
  .workspace-grid { grid-template-columns: 1fr; }
  .controls-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}
@media (max-width: 700px) {
  .page-shell { padding: 12px; }
  .header-card, .stage-card, .sidebar-stack .card { padding: 14px; }
  .controls-grid { grid-template-columns: 1fr; }
  .kv-grid { grid-template-columns: 1fr; }
  .canvas-wrap { min-height: 300px; padding: 12px; }
  h1 { font-size: 24px; }
  .planner-start-card { align-items: stretch; flex-direction: column; }
  .start-action { width: 100%; min-width: 0; }
}

.item-rotate-handle { position: absolute; right: -12px; top: -12px; width: 24px; height: 24px; border-radius: 999px; border: 2px solid var(--pf-white); background: var(--pf-coral); color: white; display: none; align-items: center; justify-content: center; font-size: 14px; line-height: 1; box-shadow: 0 6px 16px rgba(43,52,69,0.22); cursor: grab; z-index: 30; user-select: none; }
.item.selected .item-rotate-handle { display: flex; }
.item-rotate-handle:active { cursor: grabbing; }
.item-context-menu { position: fixed; z-index: 1000; min-width: 210px; padding: 8px; background: var(--pf-white); border: 1px solid var(--pf-line); border-radius: 14px; box-shadow: 0 18px 48px rgba(43,52,69,0.20); color: var(--pf-navy); }
.item-context-menu.hidden { display: none; }
.item-context-menu .menu-title { padding: 8px 10px 10px; font-weight: 800; font-size: 13px; color: var(--pf-blue); border-bottom: 1px solid var(--pf-line); margin-bottom: 6px; }
.item-context-menu button { width: 100%; border: 0; background: transparent; color: var(--pf-navy); text-align: left; padding: 9px 10px; border-radius: 9px; font-weight: 650; }
.item-context-menu button:hover { background: var(--pf-mist); }
.item-context-menu .danger-action { color: #b5482a; }
.context-color-row { display: grid; grid-template-columns: repeat(5, 1fr); gap: 6px; padding: 8px 10px 4px; }
.context-color-row button { width: 26px; height: 26px; min-width: 26px; padding: 0; border-radius: 999px; border: 2px solid #ffffff; box-shadow: 0 0 0 1px var(--pf-line); }
.context-color-row button:hover { transform: translateY(-1px); background: initial; }
