:root {
  color-scheme: light;
  font-family: "PingFang SC", "Hiragino Sans GB", "Noto Sans SC", system-ui, sans-serif;
  color: #202d35;
  background: #f4f2ed;
  --paper: #fbfaf7;
  --muted: #536570;
  --rule: #d9ddd9;
  --ink: #213846;
  --accent: #2b5267;
  --radius: 16px;
}
* { box-sizing: border-box; }
[hidden] { display: none !important; }
body { margin: 0 auto; width: min(100% - 64px, 1540px); }
button {
  appearance: none; padding: 0 16px; min-height: 42px;
  font-family: inherit; font-size: 14px;
  font-weight: 600; color: var(--ink); background: var(--paper);
  border: 1px solid #c8d2d4; border-radius: 9px; cursor: pointer; white-space: nowrap;
}
button:hover:not(:disabled) { background: #e9edf0; border-color: #9aadb7; }
button:focus-visible, input:focus-visible, select:focus-visible, .stage:focus-visible { outline: 3px solid #477e98; outline-offset: 3px; }
button:disabled { opacity: .52; cursor: default; }
.primary { color: #fff; background: var(--accent); border-color: var(--accent); }
.primary:hover:not(:disabled) { color: #fff; background: #214355; border-color: #214355; }

.page-header { display: flex; justify-content: space-between; align-items: end; gap: 24px; margin: 32px 0 23px; }
.brand {
  margin: 0 0 10px; font-family: Georgia, "Times New Roman", serif; font-size: 15px;
  letter-spacing: .22em; color: #334b59;
}
h1 { margin: 0; font-size: clamp(30px, 3.8vw, 47px); font-weight: 650; letter-spacing: -.045em; line-height: 1.1; }
h2, h3, p { margin: 0; }
h2 { font-size: 17px; font-weight: 650; }
h3 { font-size: 14px; font-weight: 650; }
.actions { display: flex; gap: 10px; padding-bottom: 2px; }

.review-layout { display: grid; grid-template-columns: minmax(0, 1fr) minmax(265px, 322px); align-items: start; gap: 16px; }
.model-panel, .summary-panel { border: 1px solid var(--rule); border-radius: var(--radius); background: var(--paper); min-width: 0; }
.model-toolbar, .viewport-footer { padding: 11px 17px; }
.model-toolbar { display: flex; align-items: center; justify-content: space-between; gap: 12px; }
.segment { display: flex; gap: 2px; background: #ebeeed; border: 1px solid #e2e7e5; border-radius: 9px; padding: 3px; }
.segment button { min-height: 33px; padding: 0 12px; border: 1px solid transparent; border-radius: 6px; background: transparent; font-size: 13px; }
.segment button[aria-pressed="true"] { border-color: #ccd9dc; background: #fcfdfc; }
.stage {
  position: relative; height: clamp(380px, 55vh, 640px); overflow: hidden; touch-action: none;
  background: radial-gradient(ellipse at 49% 46%, #e8edf0 3%, #d3dce1 62%, #c4cfd6 100%);
  border-block: 1px solid #d5dfe4; isolation: isolate;
}
.stage[data-dragging="true"] { box-shadow: inset 0 0 0 3px #3b7f9d; }
#canvas, #canvas canvas { display: block; width: 100%; height: 100%; }
#canvas canvas { cursor: grab; }
#canvas canvas:active { cursor: grabbing; }
.stage[data-placing="true"] canvas { cursor: crosshair; }
.stage-message {
  position: absolute; inset: 0; display: grid; place-items: center; padding: 30px;
  text-align: center; font-size: 15px; color: #263f4d; pointer-events: none;
}
.stage-message[hidden], .stage-label[hidden] { display: none; }
.stage-label {
  position: absolute; left: 16px; bottom: 14px; min-width: 46px; padding: 5px 8px;
  border: 1px solid #758d9e61; border-radius: 5px; color: #344e5e; text-align: center;
  font-size: 11px; font-weight: 650; letter-spacing: .08em; background: #f5fafb9e; pointer-events: none;
}
.viewport-footer { display: grid; grid-template-columns: minmax(145px, 1fr) auto minmax(98px, 1fr); align-items: center; gap: 10px; }
#gesture { font-size: 12px; color: var(--muted); }
.view-controls { display: flex; gap: 4px; }
.view-controls button, .reset { min-height: 36px; padding: 0 10px; font-size: 13px; }
.view-controls button { border-color: transparent; background: transparent; }
.view-controls button[aria-pressed="true"] { border-color: #c5d3d8; background: #e6edf0; }
.reset { justify-self: end; }

.stone-panel { padding: 15px 17px 17px; border-top: 1px solid var(--rule); }
.stone-head { display: flex; justify-content: space-between; align-items: center; gap: 12px; }
.stone-head .hint { margin-top: 4px; }
.toggle { display: flex; align-items: center; gap: 5px; flex-shrink: 0; font-size: 13px; color: var(--ink); cursor: pointer; }
.toggle input { margin: 0; width: 16px; height: 16px; accent-color: var(--accent); }
.stone-editor { padding-top: 13px; }
.stone-tools { display: flex; flex-wrap: wrap; align-items: end; gap: 9px; }
.stone-tools button { min-height: 35px; padding: 0 10px; font-size: 13px; }
.stone-tools button[aria-pressed="true"] { background: #dceaf0; border-color: #81a9ba; }
.stone-values { display: grid; grid-template-columns: repeat(5, minmax(0, 1fr)); gap: 8px; margin-top: 12px; }
.stone-editor > .hint { margin-top: 9px; }
.field { display: grid; gap: 4px; min-width: 0; font-size: 12px; color: var(--muted); }
.field input, .field select {
  min-width: 0; width: 100%; height: 35px; border: 1px solid #cbd4d4; border-radius: 7px;
  padding: 0 8px; font: inherit; color: var(--ink); background: #fff; font-variant-numeric: tabular-nums;
}
.field input[type="color"] { padding: 3px; width: 52px; cursor: pointer; }
.field input[aria-invalid="true"] { border-color: #953c2a; }
.stone-tools select { width: 132px; }
.seat-fit { margin-top: 13px; padding: 12px 0 1px; border-top: 1px solid var(--rule); }
.seat-actions { display: flex; flex-wrap: wrap; align-items: end; gap: 8px; }
.seat-actions button { min-height: 35px; padding: 0 11px; font-size: 13px; }
.seat-actions select { min-width: 132px; }
.seat-fit .hint { margin-top: 7px; }
#seat-status[data-level="attention"] { color: #873c2d; }

.summary-panel { display: flex; flex-direction: column; }
.summary-head, .summary-block { padding: 19px 19px 20px; border-bottom: 1px solid var(--rule); }
.summary-head p { margin-top: 9px; color: var(--muted); font-size: 14px; overflow-wrap: anywhere; }
.summary-head .source-label { margin-top: 6px; color: var(--accent); font-size: 12px; }
.summary-section-head { display: flex; align-items: center; justify-content: space-between; gap: 8px; }
.unit { font-size: 11px; color: var(--muted); }
.dimensions { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 7px; margin: 12px 0 10px; }
.dimensions div { min-width: 0; background: #edf0ef; border-radius: 8px; padding: 10px 7px; }
.dimensions dt { font-size: 11px; letter-spacing: .09em; color: var(--muted); }
.dimensions dd { margin: 3px 0 0; font-size: 18px; font-weight: 650; font-variant-numeric: tabular-nums; overflow-wrap: anywhere; }
.hint, .review-note { font-size: 12px; color: var(--muted); line-height: 1.65; }
.mass-controls {
  display: grid; grid-template-columns: 1fr 1fr; min-width: 0; border: 0;
  padding: 0; margin: 11px 0 0; gap: 9px;
}
.mass-controls > :first-child { grid-column: 1 / -1; }
.mass-results {
  display: grid; grid-template-columns: 1fr 1fr; gap: 7px; margin: 11px 0 8px;
}
.mass-results div { min-width: 0; background: #e9eeec; border-radius: 8px; padding: 9px 8px; }
.mass-results dt, .mass-results dd span { font-size: 11px; color: var(--muted); }
.mass-results dd { margin: 5px 0 0; font-size: 19px; font-weight: 650; font-variant-numeric: tabular-nums; overflow-wrap: anywhere; }
.mass-results dd span { white-space: nowrap; }
.findings { margin: 7px 0 0; }
.findings div { display: flex; justify-content: space-between; gap: 8px; padding: 7px 0; }
.findings div + div { border-top: 1px solid #ebedeb; }
.findings dt { font-size: 13px; color: var(--muted); }
.findings dd { margin: 0; font-size: 13px; font-weight: 650; font-variant-numeric: tabular-nums; }
.findings dd[data-warning="true"] { color: #9b3b2a; }
.review-note { padding: 16px 19px 20px; margin-top: auto; }

.page-footer { display: flex; justify-content: space-between; gap: 14px; margin: 13px 0 25px; color: var(--muted); font-size: 12px; line-height: 1.65; }
#status { color: #244d60; font-weight: 600; }
#status[data-level="error"] { color: #943b28; }

#share-dialog {
  width: min(100% - 32px, 500px); max-height: calc(100% - 32px); padding: 23px;
  border: 1px solid var(--rule); border-radius: var(--radius); color: var(--ink);
  background: var(--paper); box-shadow: 0 18px 58px #172b3b30;
}
#share-dialog::backdrop { background: #1a2c3a7a; }
.share-heading { display: flex; justify-content: space-between; align-items: center; gap: 12px; }
.share-heading h2 { font-size: 20px; }
.close-share { padding: 0; width: 42px; flex-shrink: 0; font-size: 24px; line-height: 1; }
.share-filename { margin: 9px 0 5px; font-size: 14px; font-weight: 600; overflow-wrap: anywhere; }
.share-fields { margin-top: 16px; }
.share-fields .field input { height: 42px; font-size: 16px; }
.share-remember { margin-top: 11px; }
.share-footer { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-top: 16px; }
#share-status[data-level="error"] { color: #943b28; }

@media (max-width: 980px) {
  body { width: calc(100% - 40px); }
  .review-layout { grid-template-columns: minmax(0, 1fr) 250px; gap: 12px; }
  .viewport-footer { grid-template-columns: 1fr auto; }
  #gesture { grid-column: 1 / -1; }
  .view-controls { grid-column: 1; }
}
@media (max-width: 720px) {
  body { width: calc(100% - 28px); }
  .page-header { align-items: start; flex-direction: column; margin: 22px 0 14px; gap: 15px; }
  .actions { width: 100%; }
  .actions button { flex: 1; padding-inline: 9px; }
  .review-layout { grid-template-columns: 1fr; }
  .stage { height: clamp(290px, 72vw, 460px); }
  .model-toolbar, .viewport-footer { padding-inline: 10px; }
  .model-toolbar { flex-wrap: wrap; }
  .segment button { padding-inline: 9px; }
  .stone-panel { padding-inline: 11px; }
  .stone-head { align-items: start; }
  #stone-description { max-width: 31ch; }
  .stone-values { grid-template-columns: repeat(6, minmax(0, 1fr)); }
  .stone-values .field { grid-column: span 2; }
  .stone-values .field:nth-child(-n+2) { grid-column: span 3; }
  .view-controls { gap: 1px; }
  .view-controls button, .reset { min-height: 40px; padding-inline: 8px; }
  .page-footer { flex-direction: column; gap: 5px; }
}
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { scroll-behavior: auto; }
}
