:root {
  --bg: #f5f5f5;
  --paper: #ffffff;
  --ink: #111827;
  --muted: #64748b;
  --line: #d5d8dd;
  --line-strong: #9ca3af;
  --navy: #1e3a5f;
  --navy-dark: #152a45;
  --orange: #f97316;
  --orange-dark: #d95d0b;
  --cad-green: #0f766e;
  --neon-select: #d9ff00;
  --danger: #b91c1c;
  --shadow: 0 14px 30px rgba(15, 23, 42, 0.08);
}

* {
  box-sizing: border-box;
}

html {
  min-height: 100%;
  background: var(--bg);
  overflow-x: hidden;
  overflow-y: scroll;
  scrollbar-gutter: stable;
}

body {
  min-height: 100%;
  margin: 0;
  color: var(--ink);
  background:
    linear-gradient(rgba(30, 58, 95, 0.035) 1px, transparent 1px),
    linear-gradient(90deg, rgba(30, 58, 95, 0.035) 1px, transparent 1px),
    var(--bg);
  background-size: 28px 28px;
  font-family:
    Pretendard,
    "Noto Sans KR",
    "Apple SD Gothic Neo",
    system-ui,
    -apple-system,
    BlinkMacSystemFont,
    "Segoe UI",
    sans-serif;
  font-size: 15px;
  line-height: 1.45;
  overflow-x: hidden;
}

button,
input {
  font: inherit;
}

button {
  cursor: pointer;
}

button:disabled {
  cursor: not-allowed;
  opacity: 0.48;
}

button:focus-visible,
input:focus-visible {
  outline: 3px solid rgba(249, 115, 22, 0.35);
  outline-offset: 2px;
}

.app-shell {
  min-height: 100vh;
}

.topbar {
  position: sticky;
  top: 0;
  z-index: 10;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  min-height: 72px;
  padding: 12px 24px;
  color: #ffffff;
  background: var(--navy);
  border-bottom: 4px solid var(--orange);
  box-shadow: 0 8px 18px rgba(15, 23, 42, 0.12);
}

.brand-block {
  display: flex;
  align-items: center;
  gap: 18px;
  min-width: 0;
}

.brand {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  color: #ffffff;
  text-decoration: none;
  font-size: 24px;
  font-weight: 800;
  line-height: 1;
}

.brand-mark {
  display: grid;
  grid-template-columns: repeat(2, 13px);
  grid-template-rows: repeat(2, 13px);
  gap: 3px;
  width: 31px;
  height: 31px;
}

.brand-mark span {
  display: block;
  background: #ffffff;
  border: 2px solid rgba(255, 255, 255, 0.45);
}

.brand-block p {
  margin: 0;
  color: rgba(255, 255, 255, 0.82);
  font-size: 14px;
}

.top-status {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: flex-end;
  gap: 8px;
}

.top-status span {
  display: inline-flex;
  align-items: center;
  min-height: 30px;
  padding: 5px 10px;
  color: #ffffff;
  border: 1px solid rgba(255, 255, 255, 0.28);
  border-radius: 6px;
  background: rgba(255, 255, 255, 0.08);
  font-size: 13px;
}

.app-grid {
  display: grid;
  grid-template-columns: minmax(300px, 390px) minmax(0, 1fr);
  gap: 16px;
  width: min(1480px, 100%);
  min-width: 0;
  margin: 0 auto;
  padding: 16px;
}

.input-panel,
.plan-panel,
.result-panel {
  min-width: 0;
  background: var(--paper);
  border: 1px solid var(--line);
  border-radius: 8px;
  box-shadow: var(--shadow);
}

.input-panel {
  align-self: start;
  overflow: hidden;
}

.control-section {
  padding: 16px;
  border-bottom: 1px solid var(--line);
}

.control-section:last-child {
  border-bottom: 0;
}

.section-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 12px;
}

.section-head h1,
.section-head h2,
.section-head h3 {
  margin: 0;
  color: var(--ink);
  font-size: 16px;
  font-weight: 800;
  line-height: 1.25;
}

.unit-chip {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 26px;
  padding: 3px 8px;
  color: var(--navy);
  border: 1px solid rgba(30, 58, 95, 0.2);
  border-radius: 6px;
  background: #f8fafc;
  font-size: 12px;
  font-weight: 700;
}

.segmented {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 0;
  overflow: hidden;
  border: 1px solid var(--line-strong);
  border-radius: 8px;
}

.segmented button {
  min-width: 0;
  min-height: 42px;
  padding: 9px 8px;
  color: var(--ink);
  background: #ffffff;
  border: 0;
  border-right: 1px solid var(--line-strong);
  font-weight: 800;
}

.segmented button:last-child {
  border-right: 0;
}

.segmented button[aria-pressed="true"] {
  color: #ffffff;
  background: var(--navy);
}

.status-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 8px;
  margin-bottom: 10px;
}

.status-card {
  min-height: 64px;
  padding: 10px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: #f8fafc;
}

.status-card strong {
  display: block;
  color: var(--navy);
  font-size: 24px;
  font-weight: 900;
  line-height: 1;
}

.status-card span {
  display: block;
  margin-top: 6px;
  color: var(--muted);
  font-size: 12px;
  font-weight: 800;
}

.drawing-actions {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 8px;
  margin-bottom: 10px;
}

.drawing-actions button {
  width: 100%;
  min-width: 0;
  padding-right: 6px;
  padding-left: 6px;
}

.field-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 10px;
}

.field {
  display: grid;
  gap: 6px;
  min-width: 0;
}

.field span {
  color: #334155;
  font-size: 13px;
  font-weight: 700;
}

.field input {
  width: 100%;
  min-height: 42px;
  padding: 8px 10px;
  color: var(--ink);
  background: #ffffff;
  border: 1px solid var(--line-strong);
  border-radius: 6px;
}

.field input:disabled {
  color: #94a3b8;
  background: #f1f5f9;
}

.toggle-row {
  display: flex;
  align-items: center;
  gap: 10px;
  min-height: 42px;
  margin-bottom: 10px;
  padding: 8px 10px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: #f8fafc;
  color: #334155;
  font-weight: 800;
}

.toggle-row input {
  width: 18px;
  height: 18px;
  accent-color: var(--orange);
}

.compact-toggle {
  margin-bottom: 0;
}

.edge-length-list {
  display: grid;
  gap: 8px;
  overflow: visible;
  padding-right: 2px;
}

.smart-dimension-panel {
  display: grid;
  gap: 10px;
}

.simple-dimension-panel {
  display: grid;
  gap: 10px;
}

.shape-review-panel {
  display: grid;
  gap: 10px;
}

.shape-review-panel strong {
  color: var(--ink);
  font-size: 18px;
  font-weight: 900;
}

.shape-review-panel span {
  color: var(--muted);
  font-size: 13px;
  font-weight: 800;
}

.shape-review-panel > button {
  width: 100%;
  min-height: 44px;
}

.shape-review-panel em {
  color: var(--muted);
  font-size: 12px;
  font-style: normal;
  font-weight: 800;
}

.shape-edge-tabs {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(44px, 1fr));
  gap: 6px;
}

.shape-edge-chip {
  min-height: 36px;
  color: var(--navy);
  background: #ffffff;
  border: 1px solid var(--line-strong);
  border-radius: 6px;
  font-weight: 900;
}

.shape-edge-chip.is-locked {
  color: #ffffff;
  background: var(--orange);
  border-color: var(--orange);
}

.simple-edge-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
}

.simple-edge-head strong {
  color: var(--ink);
  font-size: 19px;
  font-weight: 900;
}

.simple-edge-head span {
  color: var(--muted);
  font-size: 13px;
  font-weight: 900;
}

.simple-edge-actions {
  display: grid;
  grid-template-columns: 74px minmax(0, 1fr) 74px;
  gap: 8px;
}

.simple-edge-actions button {
  min-width: 0;
}

.simple-edge-tabs {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(46px, 1fr));
  gap: 6px;
}

.simple-edge-tabs .edge-summary-chip {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  min-height: 38px;
  padding: 6px;
  text-align: center;
}

.simple-edge-tabs .edge-summary-chip strong {
  width: auto;
  height: auto;
  min-width: 24px;
  border: 0;
}

.simple-edge-tabs .edge-summary-chip span {
  font-size: 12px;
}

.simple-edge-tabs .edge-summary-chip.is-locked {
  background: #fff7ed;
  border-color: rgba(249, 115, 22, 0.65);
}

.simple-edge-tabs .edge-summary-chip.is-active {
  border-color: var(--cad-green);
  box-shadow: inset 0 0 0 1px rgba(15, 118, 110, 0.45);
}

.selected-edge-card {
  display: grid;
  gap: 10px;
  padding: 12px;
  border: 1px solid rgba(30, 58, 95, 0.18);
  border-radius: 8px;
  background: #f8fafc;
}

.selected-edge-head {
  display: grid;
  grid-template-columns: auto minmax(0, 1fr) auto;
  align-items: center;
  gap: 10px;
}

.selected-edge-badge {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 40px;
  height: 40px;
  color: #ffffff;
  background: var(--navy);
  border-radius: 6px;
  font-size: 16px;
  font-weight: 900;
}

.selected-edge-head h3 {
  margin: 0;
  color: var(--ink);
  font-size: 17px;
  font-weight: 900;
}

.selected-edge-head span {
  display: block;
  margin-top: 2px;
  color: var(--muted);
  font-size: 12px;
  font-weight: 800;
}

.edge-status-pill {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 52px;
  min-height: 28px;
  padding: 4px 8px;
  color: #475569;
  border: 1px solid var(--line-strong);
  border-radius: 6px;
  background: #ffffff;
  font-size: 12px;
  font-style: normal;
  font-weight: 900;
  white-space: nowrap;
}

.edge-status-pill.is-locked,
.edge-summary-chip.is-locked em {
  color: #ffffff;
  background: var(--orange);
  border-color: var(--orange);
}

.edge-status-pill.is-conflict,
.edge-summary-chip.is-conflict em {
  color: #ffffff;
  background: var(--danger);
  border-color: var(--danger);
}

.edge-status-pill.is-inferred,
.edge-summary-chip.is-inferred em {
  color: var(--navy);
  background: #eaf0f7;
  border-color: rgba(30, 58, 95, 0.18);
}

.active-length-field {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  align-items: center;
  overflow: hidden;
  border: 2px solid var(--navy);
  border-radius: 8px;
  background: #ffffff;
}

.active-length-field:focus-within {
  border-color: var(--orange);
  box-shadow: 0 0 0 3px rgba(249, 115, 22, 0.16);
}

.active-length-field input {
  width: 100%;
  min-width: 0;
  min-height: 58px;
  padding: 8px 12px;
  color: var(--ink);
  background: transparent;
  border: 0;
  font-size: 28px;
  font-weight: 900;
  line-height: 1;
}

.active-length-field span {
  padding: 0 14px;
  color: var(--navy);
  font-size: 13px;
  font-weight: 900;
}

.complete-edge-button {
  width: 100%;
  min-height: 44px;
}

.edge-quick-actions {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 8px;
}

.edge-quick-actions button {
  min-width: 0;
  padding-right: 6px;
  padding-left: 6px;
}

.parallel-suggestion:empty {
  display: none;
}

.suggest-button {
  width: 100%;
  min-height: 38px;
  padding: 8px 10px;
  color: var(--cad-green);
  background: rgba(15, 118, 110, 0.08);
  border: 1px solid rgba(15, 118, 110, 0.35);
  border-radius: 6px;
  font-size: 13px;
  font-weight: 900;
}

.edge-progress-row {
  display: grid;
  grid-template-columns: auto minmax(0, 1fr);
  gap: 8px;
  color: #475569;
  font-size: 12px;
  font-weight: 900;
}

.edge-progress-row span:last-child {
  overflow: hidden;
  text-align: right;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.edge-summary-strip {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(82px, 1fr));
  gap: 6px;
  max-height: 152px;
  overflow: auto;
}

.edge-summary-chip {
  display: grid;
  grid-template-columns: auto minmax(0, 1fr);
  gap: 4px 6px;
  align-items: center;
  min-height: 52px;
  padding: 7px;
  color: var(--ink);
  text-align: left;
  background: #ffffff;
  border: 1px solid var(--line-strong);
  border-radius: 6px;
}

.edge-summary-chip.is-active {
  border-color: var(--cad-green);
  box-shadow: inset 0 0 0 1px rgba(15, 118, 110, 0.35);
}

.edge-summary-chip strong {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 26px;
  height: 26px;
  color: var(--navy);
  border: 1px solid currentColor;
  border-radius: 4px;
  font-size: 12px;
  font-weight: 900;
}

.edge-summary-chip span {
  overflow: hidden;
  color: var(--ink);
  font-size: 12px;
  font-weight: 900;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.edge-summary-chip em {
  grid-column: 1 / -1;
  justify-self: start;
  min-height: 22px;
  padding: 3px 6px;
  color: #475569;
  border: 1px solid var(--line);
  border-radius: 4px;
  background: #f8fafc;
  font-size: 11px;
  font-style: normal;
  font-weight: 900;
}

.edge-length-field {
  display: grid;
  grid-template-columns: 34px 46px minmax(0, 1fr);
  align-items: center;
  gap: 8px;
  min-height: 44px;
  padding: 4px;
  border: 1px solid transparent;
  border-radius: 6px;
}

.edge-length-field strong {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 30px;
  height: 30px;
  color: var(--navy);
  border: 1px solid var(--navy);
  border-radius: 4px;
  font-size: 13px;
}

.edge-length-field.is-active {
  border-color: rgba(15, 118, 110, 0.55);
  background: rgba(15, 118, 110, 0.06);
}

.edge-length-field.is-locked strong {
  color: #ffffff;
  background: var(--orange);
  border-color: var(--orange);
}

.edge-length-field span {
  color: var(--muted);
  font-size: 12px;
  font-weight: 800;
}

.edge-length-field input {
  width: 100%;
  min-width: 0;
  min-height: 40px;
  padding: 7px 9px;
  color: var(--ink);
  background: #ffffff;
  border: 1px solid var(--line-strong);
  border-radius: 6px;
}

.empty-state {
  min-height: 42px;
  padding: 10px 12px;
  color: var(--muted);
  border: 1px dashed var(--line-strong);
  border-radius: 6px;
  background: #f8fafc;
  font-size: 13px;
  font-weight: 800;
}

.work-area {
  display: grid;
  grid-template-columns: minmax(0, 1.2fr) minmax(330px, 0.8fr);
  gap: 16px;
  min-width: 0;
  align-items: start;
}

.plan-panel,
.result-panel {
  padding: 16px;
}

.plan-head {
  align-items: flex-start;
}

.plan-head p {
  margin: 5px 0 0;
  color: var(--muted);
  font-size: 13px;
}

.plan-actions,
.result-actions {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: flex-end;
  gap: 8px;
}

.primary-button,
.secondary-button,
.ghost-button {
  min-height: 36px;
  padding: 8px 12px;
  border-radius: 6px;
  font-size: 13px;
  font-weight: 800;
  white-space: nowrap;
}

.primary-button {
  color: #ffffff;
  background: var(--orange);
  border: 1px solid var(--orange);
}

.primary-button:hover {
  background: var(--orange-dark);
  border-color: var(--orange-dark);
}

.secondary-button {
  color: var(--navy);
  background: #ffffff;
  border: 1px solid var(--navy);
}

.secondary-button:hover,
.ghost-button:hover {
  background: #f1f5f9;
}

.ghost-button {
  color: #334155;
  background: #ffffff;
  border: 1px solid var(--line-strong);
}

.plan-stage {
  position: relative;
  width: 100%;
  aspect-ratio: 16 / 10;
  min-height: 330px;
  overflow: hidden;
  background: #fbfcfd;
  border: 1px solid var(--line-strong);
  border-radius: 8px;
  cursor: crosshair;
  touch-action: none;
}

#planSvg {
  display: block;
  width: 100%;
  height: 100%;
  touch-action: none;
  user-select: none;
}

#planSvg.is-drawing-locked {
  cursor: default;
}

.plan-grid-minor {
  fill: none;
  stroke: rgba(30, 58, 95, 0.08);
  stroke-width: 1;
}

.plan-grid-major {
  fill: none;
  stroke: rgba(30, 58, 95, 0.16);
  stroke-width: 1.1;
}

.plan-hit-area {
  fill: url(#majorGrid);
}

.plan-fill {
  fill: rgba(30, 58, 95, 0.08);
}

.plan-outline {
  fill: none;
  stroke: var(--navy);
  stroke-width: 4;
  stroke-linejoin: bevel;
}

.plan-open-line {
  fill: none;
  stroke: var(--navy);
  stroke-width: 3;
  stroke-linejoin: bevel;
  stroke-dasharray: 8 7;
}

.sketch-stroke {
  fill: none;
  stroke: var(--orange);
  stroke-width: 5;
  stroke-linecap: round;
  stroke-linejoin: round;
  opacity: 0.72;
}

.plan-edge {
  stroke: rgba(30, 58, 95, 0.28);
  stroke-width: 14;
  stroke-linecap: square;
  opacity: 0;
  cursor: pointer;
}

.plan-edge-visible {
  stroke: var(--navy);
  stroke-width: 4;
  stroke-linecap: square;
  pointer-events: none;
}

.plan-edge.is-active + .plan-edge-visible {
  stroke: var(--neon-select);
  stroke-width: 11;
  filter: drop-shadow(0 0 5px rgba(217, 255, 0, 0.9));
}

.plan-jolly-slash {
  stroke: var(--orange);
  stroke-width: 3;
  stroke-linecap: round;
  pointer-events: none;
}

.jolly-point {
  cursor: pointer;
}

.jolly-point-hit {
  fill: transparent;
  stroke: transparent;
  stroke-width: 1;
}

.jolly-point-leader {
  stroke: var(--orange);
  stroke-width: 1.2;
  stroke-linecap: round;
  pointer-events: none;
}

.jolly-point-bg {
  fill: #ffffff;
  stroke: rgba(249, 115, 22, 0.82);
  stroke-width: 1.8;
  pointer-events: none;
}

.jolly-point-symbol {
  fill: var(--orange);
  font-size: 20px;
  font-weight: 900;
  paint-order: stroke;
  stroke: #ffffff;
  stroke-linejoin: round;
  stroke-width: 2.4px;
}

.jolly-point.is-on .jolly-point-symbol {
  fill: var(--orange);
  filter: drop-shadow(0 0 3px rgba(249, 115, 22, 0.75));
}

.jolly-point.is-off .jolly-point-symbol {
  display: none;
}

.jolly-point.is-off .jolly-point-bg {
  stroke: var(--orange);
  stroke-width: 2.4px;
}

.plan-dimension-leader {
  stroke: #94a3b8;
  stroke-width: 1.4;
  stroke-linecap: round;
  pointer-events: none;
}

.plan-dimension-anchor {
  fill: #ffffff;
  stroke: #94a3b8;
  stroke-width: 1.6;
  pointer-events: none;
}

.edge-callout {
  cursor: pointer;
}

.edge-callout.is-active .edge-label-bg,
.edge-callout.is-active .edge-code-bg {
  stroke: var(--neon-select);
  stroke-width: 2;
}

.plan-edge-visible.is-locked {
  stroke-dasharray: 0;
}

.drawing-point {
  cursor: pointer;
}

.drawing-point-hit {
  fill: transparent;
  stroke: transparent;
  stroke-width: 1;
}

.drawing-point-dot {
  fill: #ffffff;
  stroke: var(--navy);
  stroke-width: 3;
}

.drawing-point-dot.is-anchor {
  stroke: var(--orange);
  stroke-width: 4;
}

.edge-label-bg {
  fill: rgba(255, 255, 255, 0.92);
  stroke: rgba(30, 58, 95, 0.15);
  stroke-width: 1;
}

.edge-code-bg {
  fill: #ffffff;
  stroke: rgba(30, 58, 95, 0.28);
  stroke-width: 1;
}

.edge-jolly-bg {
  fill: var(--orange);
  stroke: var(--orange-dark);
  stroke-width: 1;
}

.edge-label,
.edge-code,
.edge-jolly {
  fill: var(--ink);
  font-weight: 800;
}

.edge-label {
  font-size: 20px;
}

.edge-code {
  font-size: 13px;
  fill: var(--navy);
}

.edge-jolly {
  fill: #ffffff;
  font-size: 13px;
}

.area-label {
  fill: var(--navy);
  font-size: 17px;
  font-weight: 900;
}

.notice {
  margin-top: 12px;
  padding: 10px 12px;
  color: var(--danger);
  border: 1px solid rgba(185, 28, 28, 0.25);
  border-radius: 6px;
  background: #fff7f7;
  font-size: 13px;
  font-weight: 700;
}

.edge-tools {
  margin-top: 14px;
}

.edge-title,
.summary-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 10px;
}

.edge-title {
  min-height: 48px;
  padding: 9px 10px;
  border: 1px solid rgba(249, 115, 22, 0.32);
  border-left: 5px solid var(--orange);
  border-radius: 6px;
  background: rgba(249, 115, 22, 0.08);
}

.edge-title-label {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  min-width: 0;
}

.edge-title-label strong {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 28px;
  height: 28px;
  color: #ffffff;
  background: var(--orange);
  border: 1px solid var(--orange-dark);
  border-radius: 6px;
  font-size: 13px;
  font-weight: 900;
}

.edge-title h3,
.summary-head h3 {
  margin: 0;
  font-size: 15px;
}

.summary-head span {
  color: var(--navy);
  font-size: 13px;
  font-weight: 900;
}

.edge-title span {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 30px;
  padding: 5px 9px;
  color: var(--orange-dark);
  background: #ffffff;
  border: 1px solid rgba(249, 115, 22, 0.35);
  border-radius: 6px;
  font-size: 13px;
  font-weight: 900;
  white-space: nowrap;
}

.edge-list {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(136px, 1fr));
  gap: 8px;
}

.jolly-edge-card {
  position: relative;
  min-width: 0;
}

.edge-button {
  display: flex;
  align-items: flex-start;
  width: 100%;
  min-height: 86px;
  padding: 11px 10px 40px;
  text-align: left;
  color: var(--ink);
  background: #ffffff;
  border: 1px solid var(--line-strong);
  border-radius: 6px;
}

.jolly-edge-card.is-selected:not(.is-active) .edge-button {
  color: var(--navy);
  background: #fff7ed;
  border-color: rgba(249, 115, 22, 0.7);
  box-shadow: inset 0 0 0 1px rgba(249, 115, 22, 0.18);
}

.jolly-edge-card.is-active .edge-button {
  color: #ffffff;
  background: var(--orange);
  border-color: var(--orange);
}

.edge-card-main {
  display: grid;
  grid-template-columns: auto minmax(0, 1fr);
  align-items: center;
  gap: 8px;
  min-width: 0;
  width: 100%;
}

.edge-card-main strong {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 26px;
  height: 26px;
  color: inherit;
  border: 1px solid currentColor;
  border-radius: 4px;
  font-size: 12px;
}

.edge-card-main span {
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  font-size: 12px;
  font-weight: 800;
  text-align: right;
}

.jolly-edge-points {
  position: absolute;
  right: 8px;
  bottom: 8px;
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 5px;
}

.jolly-edge-card:not(.is-selected) .jolly-edge-points {
  pointer-events: none;
}

.jolly-edge-points button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 34px;
  height: 28px;
  min-width: 0;
  min-height: 0;
  color: var(--navy);
  background: #ffffff;
  border: 1px solid var(--line-strong);
  border-radius: 6px;
  font-size: 16px;
  font-weight: 900;
  line-height: 1;
}

.jolly-edge-points button[aria-pressed="true"] {
  color: #ffffff;
  background: var(--orange);
  border-color: var(--orange);
}

.result-head {
  align-items: flex-start;
}

.result-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 10px;
}

.metric-card {
  min-height: 108px;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #ffffff;
}

.metric-card strong {
  display: block;
  margin-bottom: 8px;
  color: #334155;
  font-size: 13px;
}

.metric-card span {
  display: block;
  color: var(--navy);
  font-size: 24px;
  font-weight: 900;
  line-height: 1.1;
}

.metric-card em {
  display: block;
  margin-top: 8px;
  color: var(--muted);
  font-size: 12px;
  font-style: normal;
  font-weight: 700;
}

.metric-card.is-primary {
  border-color: rgba(249, 115, 22, 0.42);
  background: #fff7ed;
}

.metric-card.is-primary span {
  color: var(--orange-dark);
}

.summary-box {
  margin-top: 14px;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #f8fafc;
}

.summary-box pre {
  min-height: 152px;
  max-height: 280px;
  margin: 0;
  overflow: auto;
  white-space: pre-wrap;
  color: #0f172a;
  font-family:
    "SFMono-Regular",
    Consolas,
    "Liberation Mono",
    monospace;
  font-size: 12px;
  line-height: 1.55;
}

@media (max-width: 1180px) {
  .app-grid,
  .work-area {
    grid-template-columns: 1fr;
  }

  .input-panel {
    position: static;
  }
}

@media (max-width: 720px) {
  body {
    font-size: 14px;
  }

  .topbar {
    position: static;
    align-items: flex-start;
    flex-direction: column;
    min-height: 0;
    padding: 14px 16px;
  }

  .brand-block {
    align-items: flex-start;
    flex-direction: column;
    gap: 6px;
  }

  .brand {
    font-size: 22px;
  }

  .top-status {
    justify-content: flex-start;
  }

  .app-grid {
    display: flex;
    flex-direction: column;
    padding: 10px;
    gap: 10px;
  }

  .work-area {
    display: contents;
  }

  .plan-panel {
    order: 1;
  }

  .input-panel {
    order: 2;
  }

  .result-panel {
    order: 3;
  }

  .field-grid,
  .result-grid {
    grid-template-columns: 1fr;
  }

  .plan-panel,
  .result-panel,
  .control-section {
    padding: 12px;
  }

  .plan-head,
  .result-head {
    display: grid;
    align-items: stretch;
  }

  .plan-actions,
  .result-actions {
    justify-content: stretch;
  }

  .plan-actions button,
  .result-actions button {
    flex: 1 1 0;
  }

  .plan-stage {
    min-height: 300px;
    aspect-ratio: 1 / 1;
  }

  .edge-list {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
}

@page {
  size: A4 portrait;
  margin: 12mm;
}

@media print {
  html,
  body {
    min-height: auto;
    background: #ffffff;
    overflow: visible;
  }

  body {
    font-size: 11pt;
    -webkit-print-color-adjust: exact;
    print-color-adjust: exact;
  }

  .app-shell {
    min-height: auto;
  }

  .topbar,
  .input-panel,
  .plan-actions,
  .result-actions,
  #warningList,
  .edge-tools {
    display: none;
  }

  .app-grid,
  .work-area {
    display: block;
    width: 100%;
    max-width: none;
    margin: 0;
    padding: 0;
  }

  .plan-panel,
  .result-panel {
    background: #ffffff;
    border: 0;
    border-radius: 0;
    box-shadow: none;
    page-break-inside: auto;
    break-inside: auto;
  }

  .plan-panel {
    display: flex;
    flex-direction: column;
    min-height: calc(297mm - 24mm);
    padding: 0;
    page-break-after: always;
    break-after: page;
  }

  .plan-head {
    margin-bottom: 8mm;
  }

  .plan-head p {
    display: none;
  }

  .plan-stage {
    flex: 1 1 auto;
    min-height: 0;
    height: 225mm;
    aspect-ratio: auto;
    border-radius: 0;
    page-break-inside: avoid;
    break-inside: avoid;
  }

  .result-panel {
    padding: 0;
  }

  .result-head {
    margin-bottom: 8mm;
  }

  .result-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 5mm;
    align-content: start;
    min-height: 230mm;
  }

  .metric-card {
    min-height: 34mm;
    padding: 5mm;
    page-break-inside: avoid;
    break-inside: avoid;
  }

  .summary-box {
    min-height: calc(297mm - 24mm);
    margin-top: 0;
    padding: 0;
    background: #ffffff;
    border: 0;
    border-radius: 0;
    page-break-before: always;
    break-before: page;
  }

  .summary-head {
    padding-bottom: 4mm;
    border-bottom: 1px solid var(--line-strong);
  }

  .summary-box pre {
    min-height: auto;
    max-height: none;
    overflow: visible;
    font-size: 10pt;
  }
}
