:root {
  --ink: #14231f;
  --ink-soft: #29413a;
  --paper: #f2efe7;
  --paper-deep: #e7e1d4;
  --panel: #fbfaf6;
  --line: #d4cdbf;
  --line-dark: #a9a091;
  --mint: #b9ffdf;
  --green: #168b68;
  --orange: #ef6a2e;
  --red: #d4493f;
  --blue: #2472d7;
  --shadow: 0 18px 55px rgba(20, 35, 31, 0.12);
  --topbar-height: 76px;
}

* {
  box-sizing: border-box;
}

[hidden] {
  display: none !important;
}

html,
body {
  width: 100%;
  height: 100%;
  min-height: 100%;
  margin: 0;
}

body {
  overflow: hidden;
  color: var(--ink);
  background:
    radial-gradient(circle at 12% 0%, rgba(255, 255, 255, 0.9), transparent 28%),
    linear-gradient(135deg, #eee9df 0%, #e4ded2 100%);
  font-family: "PingFang SC", "Hiragino Sans GB", "Microsoft YaHei", sans-serif;
  -webkit-font-smoothing: antialiased;
}

button,
input,
select,
textarea {
  font: inherit;
}

button,
label[for] {
  -webkit-tap-highlight-color: transparent;
}

button:focus-visible,
input:focus-visible,
select:focus-visible,
textarea:focus-visible {
  outline: 2px solid var(--orange);
  outline-offset: 2px;
}

.app-shell {
  display: grid;
  grid-template-rows: var(--topbar-height) minmax(0, 1fr);
  width: 100%;
  height: 100vh;
  height: 100dvh;
  min-height: 0;
  overflow: hidden;
}

.topbar {
  position: relative;
  z-index: 20;
  display: grid;
  grid-template-columns: 240px minmax(260px, 1fr) auto;
  align-items: center;
  height: 100%;
  min-height: 0;
  padding: 0 20px;
  color: #f6f2e9;
  background:
    linear-gradient(90deg, rgba(255, 255, 255, 0.035) 1px, transparent 1px) 0 0 / 34px 34px,
    linear-gradient(0deg, rgba(255, 255, 255, 0.03) 1px, transparent 1px) 0 0 / 34px 34px,
    var(--ink);
  border-bottom: 1px solid rgba(255, 255, 255, 0.12);
  box-shadow: 0 10px 35px rgba(20, 35, 31, 0.24);
}

.brand {
  display: flex;
  align-items: center;
  gap: 11px;
  min-width: 0;
  color: inherit;
  text-decoration: none;
}

.brand-mark {
  display: grid;
  place-items: center;
  width: 42px;
  height: 42px;
  color: var(--ink);
  background: var(--mint);
  border-radius: 7px 15px 7px 7px;
  font-family: Georgia, "Songti SC", serif;
  font-size: 22px;
  font-weight: 800;
  letter-spacing: -2px;
  transform: rotate(-2deg);
}

.brand-copy {
  display: flex;
  flex-direction: column;
  line-height: 1;
}

.brand-copy strong {
  font-family: Georgia, "Songti SC", serif;
  font-size: 22px;
  letter-spacing: 0.08em;
}

.brand-copy small {
  margin-top: 7px;
  color: rgba(246, 242, 233, 0.66);
  font-size: 11px;
  letter-spacing: 0.16em;
}

.project-title {
  justify-self: start;
  min-width: 280px;
  max-width: 560px;
  margin-left: 16px;
}

.eyebrow {
  display: block;
  color: #7d8b85;
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 0.2em;
  text-transform: uppercase;
}

.project-title .eyebrow {
  color: rgba(185, 255, 223, 0.72);
}

.project-title input {
  width: 100%;
  margin-top: 4px;
  padding: 0;
  color: #fff;
  background: transparent;
  border: 0;
  border-bottom: 1px solid transparent;
  font-family: "Songti SC", "STSong", serif;
  font-size: 17px;
  font-weight: 700;
}

.project-title input:hover,
.project-title input:focus {
  border-bottom-color: rgba(185, 255, 223, 0.45);
  outline: 0;
}

.top-actions,
.export-actions,
.inline-actions {
  display: flex;
  align-items: center;
  gap: 8px;
}

.button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 38px;
  padding: 0 14px;
  color: var(--ink);
  background: #fff;
  border: 1px solid var(--line);
  border-radius: 8px;
  cursor: pointer;
  font-size: 12px;
  font-weight: 700;
  white-space: nowrap;
  transition: transform 150ms ease, border-color 150ms ease, background 150ms ease;
}

.button:hover {
  transform: translateY(-1px);
}

.button svg {
  width: 16px;
  height: 16px;
  margin-right: 7px;
  fill: none;
  stroke: currentColor;
  stroke-linecap: round;
  stroke-linejoin: round;
  stroke-width: 1.8;
}

.button-ghost {
  color: #f5f2ea;
  background: rgba(255, 255, 255, 0.055);
  border-color: rgba(255, 255, 255, 0.16);
}

.button-ghost:hover {
  background: rgba(255, 255, 255, 0.1);
}

.button-accent {
  color: #101c18;
  background: var(--mint);
  border-color: var(--mint);
  box-shadow: 0 7px 22px rgba(87, 255, 180, 0.13);
}

.button-dark {
  color: #f5f2ea;
  background: var(--ink-soft);
  border-color: var(--ink-soft);
}

.button-small {
  min-height: 32px;
  padding: 0 10px;
  font-size: 11px;
}

.button.danger {
  color: var(--red);
  background: #fff7f5;
  border-color: #f1cbc6;
}

.workspace {
  display: grid;
  grid-template-columns: 76px minmax(0, 1fr) 390px;
  grid-template-rows: minmax(0, 1fr);
  min-height: 0;
  overflow: hidden;
}

.toolrail {
  position: relative;
  z-index: 8;
  display: flex;
  flex-direction: column;
  align-items: stretch;
  padding: 14px 8px 10px;
  background: rgba(251, 250, 246, 0.92);
  border-right: 1px solid var(--line);
  backdrop-filter: blur(20px);
  overflow-y: auto;
  min-height: 0;
}

.toolrail-label {
  margin: 2px 0 10px;
  color: #8d8578;
  font-family: Georgia, serif;
  font-size: 9px;
  font-weight: 700;
  letter-spacing: 0.18em;
  text-align: center;
}

.tool {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  min-height: 61px;
  margin-bottom: 5px;
  padding: 7px 2px;
  color: #5d6a65;
  background: transparent;
  border: 1px solid transparent;
  border-radius: 9px;
  cursor: pointer;
  font-size: 10px;
  font-weight: 700;
  transition: 160ms ease;
}

.tool svg {
  width: 22px;
  height: 22px;
  margin-bottom: 5px;
  fill: none;
  stroke: currentColor;
  stroke-linecap: round;
  stroke-linejoin: round;
  stroke-width: 1.65;
}

.tool:hover {
  color: var(--ink);
  background: #f0ece3;
}

.tool:disabled {
  color: #aaa59b;
  cursor: not-allowed;
  opacity: 0.48;
}

.tool:disabled:hover {
  background: transparent;
}

.tool.active {
  color: #0c674d;
  background: #daf8ea;
  border-color: #a6e6ca;
  box-shadow: inset 3px 0 0 var(--green);
}

.tool.compact {
  min-height: 54px;
}

.toolrail-spacer {
  flex: 1;
}

.stage-shell {
  position: relative;
  display: grid;
  grid-template-rows: 44px minmax(0, 1fr) 34px;
  min-width: 0;
  min-height: 0;
  overflow: hidden;
  background:
    linear-gradient(45deg, rgba(20, 35, 31, 0.025) 25%, transparent 25%) 0 0 / 24px 24px,
    linear-gradient(-45deg, rgba(20, 35, 31, 0.025) 25%, transparent 25%) 0 12px / 24px 24px,
    #ddd8ce;
}

.stage-toolbar,
.stage-status {
  position: relative;
  z-index: 5;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 14px;
  background: rgba(247, 244, 237, 0.92);
  backdrop-filter: blur(16px);
}

.stage-toolbar {
  border-bottom: 1px solid var(--line);
}

.stage-status {
  color: #6f786f;
  border-top: 1px solid var(--line);
  font-size: 10px;
}

.drawing-meta {
  display: flex;
  align-items: center;
  min-width: 0;
  gap: 8px;
  font-size: 11px;
}

.drawing-meta strong {
  overflow: hidden;
  max-width: 320px;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.drawing-meta > span:last-child {
  padding: 3px 7px;
  color: #6f786f;
  background: #e9e5dc;
  border-radius: 999px;
  font-size: 9px;
}

.live-dot {
  width: 7px;
  height: 7px;
  background: var(--green);
  border-radius: 50%;
  box-shadow: 0 0 0 4px rgba(22, 139, 104, 0.12);
}

.zoom-controls {
  display: flex;
  align-items: center;
  gap: 5px;
}

.zoom-controls button {
  min-width: 28px;
  height: 28px;
  padding: 0 8px;
  color: var(--ink-soft);
  background: #fff;
  border: 1px solid var(--line);
  border-radius: 6px;
  cursor: pointer;
  font-size: 11px;
}

.zoom-controls span {
  min-width: 43px;
  color: #6c766f;
  font-family: Georgia, serif;
  font-size: 11px;
  text-align: center;
}

.stage-viewport {
  position: relative;
  min-height: 0;
  overflow: auto;
  padding: 34px;
  scrollbar-color: #aaa296 transparent;
  scrollbar-width: thin;
}

.canvas-wrap {
  position: relative;
  width: fit-content;
  margin: auto;
  background: #fff;
  border: 1px solid rgba(20, 35, 31, 0.22);
  box-shadow: 0 25px 70px rgba(20, 35, 31, 0.18), 0 2px 7px rgba(20, 35, 31, 0.12);
  transform-origin: top left;
}

#designCanvas {
  display: block;
  touch-action: none;
  cursor: default;
}

.empty-state {
  position: absolute;
  top: 50%;
  left: 50%;
  width: min(430px, calc(100% - 50px));
  padding: 38px;
  background: rgba(251, 250, 246, 0.96);
  border: 1px solid var(--line);
  border-radius: 18px;
  box-shadow: var(--shadow);
  transform: translate(-50%, -50%);
  text-align: center;
}

.empty-index {
  display: block;
  color: var(--orange);
  font-family: Georgia, serif;
  font-size: 11px;
  letter-spacing: 0.2em;
}

.empty-state h2 {
  margin: 11px 0 8px;
  font-family: "Songti SC", "STSong", serif;
  font-size: 25px;
}

.empty-state p {
  margin: 0 0 24px;
  color: #69736e;
  font-size: 12px;
  line-height: 1.8;
}

.inspector {
  position: relative;
  z-index: 9;
  overflow-y: auto;
  min-width: 0;
  min-height: 0;
  padding: 18px;
  background:
    linear-gradient(rgba(20, 35, 31, 0.025) 1px, transparent 1px) 0 0 / 100% 28px,
    var(--paper);
  border-left: 1px solid var(--line-dark);
  box-shadow: -18px 0 48px rgba(20, 35, 31, 0.08);
}

.inspector-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  padding: 4px 2px 15px;
}

.inspector-head h1 {
  margin: 5px 0 0;
  font-family: "Songti SC", "STSong", serif;
  font-size: 21px;
  letter-spacing: -0.04em;
}

.version {
  padding: 4px 7px;
  color: #69736e;
  background: #ded8cc;
  border-radius: 4px;
  font-family: Georgia, serif;
  font-size: 9px;
  letter-spacing: 0.08em;
}

.panel {
  margin-bottom: 12px;
  background: rgba(251, 250, 246, 0.96);
  border: 1px solid var(--line);
  border-radius: 10px;
  box-shadow: 0 6px 20px rgba(20, 35, 31, 0.04);
}

.panel-title {
  display: flex;
  align-items: center;
  justify-content: space-between;
  width: 100%;
  min-height: 39px;
  padding: 0 12px;
  color: #65716b;
  background: transparent;
  border: 0;
  border-bottom: 1px solid var(--line);
  cursor: pointer;
  font-family: Georgia, "Songti SC", serif;
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 0.12em;
}

.panel-title.collapsed {
  border-bottom: 0;
}

.panel-body {
  padding: 12px;
}

.panel-body[hidden] {
  display: none;
}

.intelligence-panel {
  overflow: hidden;
  border-color: #b8c8c0;
  box-shadow: 0 10px 28px rgba(20, 35, 31, 0.075);
}

.intelligence-panel .panel-title {
  color: #213f36;
  background:
    linear-gradient(90deg, rgba(185, 255, 223, 0.38), transparent 42%),
    #f7f8f3;
}

.intelligence-body {
  position: relative;
  background:
    linear-gradient(rgba(20, 35, 31, 0.025) 1px, transparent 1px) 0 0 / 100% 24px,
    #fbfaf6;
}

.cloud-status {
  display: inline-flex;
  align-items: center;
  min-height: 21px;
  padding: 0 7px;
  border: 1px solid transparent;
  border-radius: 999px;
  font-family: "PingFang SC", sans-serif;
  font-size: 8px;
  letter-spacing: 0.04em;
}

.cloud-status::before {
  width: 5px;
  height: 5px;
  margin-right: 5px;
  background: currentColor;
  border-radius: 50%;
  content: "";
}

.cloud-status.online {
  color: #0b684e;
  background: #dff5ea;
  border-color: #b6dec9;
}

.cloud-status.auth {
  color: #8a5b12;
  background: #fbedd2;
  border-color: #ead19e;
}

.cloud-status.busy {
  color: #155c8a;
  background: #dfedf8;
  border-color: #b9d4e7;
}

.cloud-status.offline {
  color: #7b5550;
  background: #eee8e4;
  border-color: #d8cbc5;
}

.connection-row {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 10px;
  margin-bottom: 11px;
}

.connection-copy {
  color: #6f7c75;
  font-size: 9px;
  line-height: 1.5;
}

.text-button {
  flex: 0 0 auto;
  padding: 0;
  color: #126e54;
  background: transparent;
  border: 0;
  border-bottom: 1px solid rgba(18, 110, 84, 0.3);
  cursor: pointer;
  font-size: 9px;
}

.text-button:hover {
  border-bottom-color: currentColor;
}

.cloud-project-field {
  display: flex;
  flex-direction: column;
  gap: 5px;
  color: #67736d;
  font-size: 9px;
}

.cloud-project-field select {
  width: 100%;
  height: 34px;
  padding: 0 9px;
  color: var(--ink);
  background: #fff;
  border: 1px solid var(--line);
  border-radius: 6px;
  font-size: 11px;
}

.cloud-project-field select:disabled {
  color: #8a918d;
  background: #f0ede7;
}

.field-help,
.recognition-note {
  margin: 5px 0 10px;
  color: #7a847e;
  font-size: 8px;
  line-height: 1.5;
}

.source-file-card {
  display: grid;
  grid-template-columns: 34px minmax(0, 1fr) auto;
  align-items: center;
  gap: 9px;
  margin-bottom: 9px;
  padding: 8px;
  background: #f0ede6;
  border: 1px solid #ded8cc;
  border-radius: 7px;
}

.source-file-card.ready {
  background: #edf5f0;
  border-color: #c8dcd1;
}

.source-file-icon {
  display: grid;
  place-items: center;
  width: 34px;
  height: 34px;
  color: #fff;
  background: var(--ink-soft);
  border-radius: 5px 10px 5px 5px;
  font-family: Georgia, serif;
  font-size: 8px;
  font-weight: 700;
  letter-spacing: 0.05em;
}

.source-file-card.ready .source-file-icon {
  background: var(--green);
}

.source-file-copy {
  min-width: 0;
}

.source-file-copy strong,
.source-file-copy small {
  display: block;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.source-file-copy strong {
  color: var(--ink);
  font-size: 10px;
}

.source-file-copy small {
  margin-top: 4px;
  color: #79827d;
  font-size: 8px;
}

.local-only-badge {
  padding: 3px 6px;
  color: #69736e;
  background: #ded8cd;
  border-radius: 999px;
  font-size: 8px;
}

.source-file-card.ready .local-only-badge {
  color: #0c674d;
  background: #d2eddf;
}

.button-recognize {
  width: 100%;
  color: #f7f4ec;
  background: var(--ink);
  border-color: var(--ink);
  box-shadow: 0 8px 20px rgba(20, 35, 31, 0.12);
}

.button-recognize:not(:disabled):hover {
  background: #203b33;
}

.button-recognize:disabled {
  cursor: not-allowed;
  opacity: 0.44;
  transform: none;
}

.recognition-progress {
  margin-top: 10px;
  padding: 9px;
  background: #edf3f6;
  border: 1px solid #cadbe4;
  border-radius: 7px;
}

.progress-copy {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 7px;
  color: #47646f;
  font-size: 9px;
}

.progress-copy strong {
  color: #244956;
}

.progress-track {
  height: 5px;
  overflow: hidden;
  background: #d4e1e7;
  border-radius: 999px;
}

.progress-track > span {
  display: block;
  width: 0;
  height: 100%;
  background: linear-gradient(90deg, var(--green), #34a7b1);
  border-radius: inherit;
  transition: width 240ms ease;
}

.recognition-toggle {
  margin-top: 10px;
}

.recognition-summary {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 6px;
  margin-top: 10px;
}

.recognition-summary div {
  padding: 7px;
  background: #f0ede6;
  border-radius: 6px;
  text-align: center;
}

.recognition-summary strong,
.recognition-summary span {
  display: block;
}

.recognition-summary strong {
  font-family: Georgia, serif;
  font-size: 14px;
}

.recognition-summary span {
  margin-top: 2px;
  color: #79827d;
  font-size: 8px;
}

.recognition-actions {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 7px;
  margin-top: 8px;
}

.recognition-actions .button {
  width: 100%;
}

.recognition-note {
  margin-bottom: 0;
}

.spec-strip {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  margin-bottom: 13px;
  border: 1px solid #c6d1ca;
  border-radius: 7px;
  overflow: hidden;
}

.spec-strip > div {
  min-width: 0;
  padding: 9px 7px 8px;
  background: #eaf3ee;
  border-right: 1px solid #c6d1ca;
  text-align: center;
}

.spec-strip > div:last-child {
  border-right: 0;
}

.spec-strip span {
  display: block;
  color: #6f7f77;
  font-size: 9px;
}

.spec-strip strong {
  display: inline-block;
  margin-top: 3px;
  color: #126c52;
  font-family: Georgia, serif;
  font-size: 16px;
}

.spec-strip small {
  margin-left: 2px;
  color: #6f7f77;
  font-size: 8px;
}

.form-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
}

.form-grid label,
.selection-form label {
  display: flex;
  flex-direction: column;
  gap: 5px;
  color: #67736d;
  font-size: 10px;
}

.form-grid input,
.form-grid select,
.selection-form input,
.selection-form select {
  width: 100%;
  height: 32px;
  padding: 0 8px;
  color: var(--ink);
  background: #fff;
  border: 1px solid var(--line);
  border-radius: 5px;
  font-family: Georgia, "PingFang SC", sans-serif;
  font-size: 12px;
}

.simulation-panel {
  overflow: hidden;
  border-color: #9db9ad;
  box-shadow: 0 10px 28px rgba(20, 35, 31, 0.08);
}

.simulation-panel .panel-title {
  color: #173e32;
  background:
    linear-gradient(90deg, rgba(185, 255, 223, 0.46), transparent 48%),
    #f3f7f3;
}

.simulation-body {
  background:
    radial-gradient(circle at 100% 0%, rgba(185, 255, 223, 0.2), transparent 38%),
    #fbfaf6;
}

.simulation-status {
  display: inline-flex;
  align-items: center;
  min-height: 21px;
  padding: 0 7px;
  border-radius: 999px;
  font-family: "PingFang SC", sans-serif;
  font-size: 8px;
  letter-spacing: 0.04em;
}

.simulation-status.idle {
  color: #6b756f;
  background: #e9ebe7;
}

.simulation-status.queued,
.simulation-status.running {
  color: #155c8a;
  background: #dfedf8;
}

.simulation-status.succeeded {
  color: #0a6048;
  background: var(--mint);
  box-shadow: inset 0 0 0 1px #89d8b6;
}

.simulation-status.failed,
.simulation-status.timed_out {
  color: #a13931;
  background: #f8deda;
}

.simulation-intro {
  display: grid;
  grid-template-columns: 34px minmax(0, 1fr);
  align-items: center;
  gap: 9px;
  margin-bottom: 10px;
}

.simulation-mark {
  display: grid;
  place-items: center;
  width: 34px;
  height: 34px;
  color: #0d503e;
  background: var(--mint);
  border: 1px solid #8fd5b7;
  border-radius: 7px 12px 7px 7px;
  font-family: Georgia, serif;
  font-size: 17px;
  font-weight: 800;
}

.simulation-intro strong,
.simulation-intro small {
  display: block;
}

.simulation-intro strong {
  font-size: 11px;
}

.simulation-intro small {
  margin-top: 4px;
  color: #718079;
  font-size: 8px;
  line-height: 1.45;
}

.simulation-derived {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  margin-bottom: 10px;
  overflow: hidden;
  background: #edf3ef;
  border: 1px solid #c6d7cf;
  border-radius: 7px;
}

.simulation-derived div {
  padding: 8px 5px;
  border-right: 1px solid #c6d7cf;
  text-align: center;
}

.simulation-derived div:last-child {
  border-right: 0;
}

.simulation-derived span,
.simulation-derived strong {
  display: block;
}

.simulation-derived span {
  color: #6f7f77;
  font-size: 8px;
}

.simulation-derived strong {
  margin-top: 3px;
  color: #126c52;
  font-family: Georgia, "PingFang SC", sans-serif;
  font-size: 12px;
}

.simulation-form {
  margin-bottom: 10px;
}

.button-simulation {
  width: 100%;
  color: #f7fff9;
  background: var(--ink-soft);
  border-color: var(--ink-soft);
}

.button-simulation:hover {
  background: #183a31;
}

.button-simulation:disabled {
  cursor: wait;
  opacity: 0.58;
  transform: none;
}

.simulation-progress {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  min-height: 34px;
  margin-top: 8px;
  color: #44675d;
  background: #edf4f0;
  border-radius: 6px;
  font-size: 9px;
}

.simulation-spinner {
  width: 12px;
  height: 12px;
  border: 2px solid #b5c9bf;
  border-top-color: var(--green);
  border-radius: 50%;
  animation: simulation-spin 800ms linear infinite;
}

@keyframes simulation-spin {
  to {
    transform: rotate(360deg);
  }
}

.simulation-results {
  margin-top: 9px;
  padding: 9px;
  background: #14231f;
  border-radius: 8px;
  color: #f5f7f4;
}

.simulation-result-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 6px;
}

.simulation-result-grid > div {
  min-width: 0;
  padding: 7px;
  background: rgba(255, 255, 255, 0.065);
  border: 1px solid rgba(255, 255, 255, 0.08);
  border-radius: 6px;
}

.simulation-result-grid span,
.simulation-result-grid strong,
.simulation-result-grid small {
  display: block;
}

.simulation-result-grid span {
  color: rgba(245, 247, 244, 0.62);
  font-size: 8px;
}

.simulation-result-grid strong {
  margin-top: 3px;
  color: var(--mint);
  font-family: Georgia, "PingFang SC", sans-serif;
  font-size: 14px;
}

.simulation-result-grid small {
  margin-top: 2px;
  color: rgba(245, 247, 244, 0.48);
  font-size: 7px;
}

.simulation-result-note,
.simulation-note {
  margin: 8px 0 0;
  font-size: 8px;
  line-height: 1.55;
}

.simulation-result-note {
  color: rgba(245, 247, 244, 0.66);
}

.simulation-note {
  color: #78837d;
}

.setting-toggle,
.recognition-switch {
  display: grid;
  grid-template-columns: auto minmax(0, 1fr);
  grid-template-rows: auto auto;
  align-items: center;
  column-gap: 10px;
  margin-top: 12px;
  padding: 10px;
  color: var(--ink);
  background: #edf4f0;
  border: 1px solid #c9d9d1;
  border-radius: 7px;
  cursor: pointer;
}

.setting-toggle > input,
.recognition-switch > input {
  position: absolute;
  width: 1px;
  height: 1px;
  opacity: 0;
  pointer-events: none;
}

.toggle-track {
  position: relative;
  grid-row: 1 / 3;
  width: 36px;
  height: 20px;
  background: #aab6b0;
  border-radius: 999px;
  transition: 160ms ease;
}

.toggle-track span {
  position: absolute;
  top: 3px;
  left: 3px;
  width: 14px;
  height: 14px;
  background: #fff;
  border-radius: 50%;
  box-shadow: 0 1px 4px rgba(20, 35, 31, 0.25);
  transition: 160ms ease;
}

.setting-toggle > input:checked + .toggle-track,
.recognition-switch > input:checked + .toggle-track {
  background: var(--green);
}

.setting-toggle > input:checked + .toggle-track span,
.recognition-switch > input:checked + .toggle-track span {
  transform: translateX(16px);
}

.setting-toggle > input:focus-visible + .toggle-track,
.recognition-switch > input:focus-visible + .toggle-track {
  outline: 2px solid var(--orange);
  outline-offset: 2px;
}

.toggle-copy {
  min-width: 0;
}

.toggle-copy strong,
.toggle-copy small {
  display: block;
}

.toggle-copy strong {
  font-size: 11px;
}

.toggle-copy small {
  margin-top: 3px;
  color: #708078;
  font-size: 9px;
  line-height: 1.45;
}

.selection-empty {
  padding: 7px 3px;
  color: #7d847e;
  font-size: 11px;
  line-height: 1.7;
}

.selection-form {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
}

.selection-form[hidden] {
  display: none;
}

.selected-token {
  grid-column: 1 / -1;
  display: flex;
  align-items: center;
  gap: 7px;
  font-size: 11px;
}

.selected-token span {
  width: 12px;
  height: 12px;
  background: var(--green);
  border-radius: 50%;
}

.selection-metrics {
  grid-column: 1 / -1;
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 7px;
}

.selection-metrics div {
  padding: 8px;
  background: #f0ede6;
  border-radius: 6px;
}

.selection-metrics span {
  display: block;
  color: #7a847e;
  font-size: 9px;
}

.selection-metrics strong {
  display: block;
  margin-top: 3px;
  font-family: Georgia, serif;
  font-size: 13px;
}

.inline-actions {
  grid-column: 1 / -1;
  flex-wrap: wrap;
  justify-content: flex-end;
}

.summary-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 7px;
  margin-bottom: 10px;
}

.summary-grid > div {
  padding: 8px;
  background: var(--ink);
  border-radius: 6px;
}

.summary-grid span {
  display: block;
  color: rgba(246, 242, 233, 0.6);
  font-size: 8px;
}

.summary-grid strong {
  display: block;
  overflow: hidden;
  margin-top: 4px;
  color: var(--mint);
  font-family: Georgia, serif;
  font-size: 14px;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.calculation-level {
  display: grid;
  grid-template-columns: auto minmax(0, 1fr);
  gap: 7px;
  align-items: start;
  margin: 8px 0 10px;
  padding: 7px 8px;
  color: #5f6c66;
  background: #edf4f0;
  border: 1px solid #c9d9d1;
  border-radius: 6px;
  font-size: 8px;
  line-height: 1.45;
}

.calculation-level strong {
  color: #0c7758;
  font-size: 9px;
  white-space: nowrap;
}

.loop-list {
  display: flex;
  flex-direction: column;
  gap: 6px;
  max-height: 260px;
  overflow-y: auto;
  padding-right: 2px;
}

.loop-card {
  display: grid;
  grid-template-columns: 28px minmax(0, 1fr) auto;
  align-items: center;
  gap: 8px;
  min-height: 43px;
  padding: 7px 8px;
  background: #f2efe8;
  border: 1px solid transparent;
  border-radius: 7px;
  cursor: pointer;
}

.loop-card:hover {
  border-color: #b9c7c0;
}

.loop-id {
  display: grid;
  place-items: center;
  width: 27px;
  height: 27px;
  color: #fff;
  background: var(--loop-color, var(--green));
  border-radius: 7px 7px 11px 7px;
  font-family: Georgia, serif;
  font-size: 10px;
  font-weight: 700;
}

.loop-copy {
  min-width: 0;
}

.loop-copy strong,
.loop-copy span {
  display: block;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.loop-copy strong {
  font-size: 10px;
}

.loop-copy span {
  margin-top: 3px;
  color: #78817c;
  font-size: 8px;
}

.loop-length {
  font-family: Georgia, serif;
  font-size: 13px;
  font-weight: 700;
}

.loop-length.ok {
  color: #0c7758;
}

.loop-length.warn {
  color: var(--orange);
}

.loop-length.bad {
  color: var(--red);
}

.panel-title-tail {
  display: inline-flex;
  align-items: center;
  gap: 8px;
}

.review-status {
  display: inline-flex;
  align-items: center;
  min-height: 21px;
  padding: 0 7px;
  border-radius: 999px;
  font-family: "PingFang SC", sans-serif;
  font-size: 8px;
  letter-spacing: 0.04em;
}

.review-status.pending {
  color: #8c5a13;
  background: #f8e7c6;
}

.review-status.ready {
  color: #0f6e54;
  background: #d9f2e7;
}

.review-status.stale {
  color: #a13931;
  background: #f8deda;
}

.review-status.approved {
  color: #0a6048;
  background: var(--mint);
  box-shadow: inset 0 0 0 1px #89d8b6;
}

.review-observations {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 6px;
  margin-bottom: 10px;
}

.review-observation {
  min-width: 0;
  padding: 7px;
  color: #66736d;
  background: #f0ede6;
  border-radius: 6px;
  font-size: 8px;
  line-height: 1.35;
  text-align: center;
}

.review-observation strong {
  display: block;
  margin-bottom: 2px;
  color: var(--ink);
  font-family: Georgia, serif;
  font-size: 13px;
}

.review-observation.alert strong {
  color: var(--red);
}

.review-field {
  display: flex;
  flex-direction: column;
  gap: 5px;
  margin-top: 9px;
  color: #67736d;
  font-size: 9px;
}

.review-field input,
.review-field textarea {
  width: 100%;
  padding: 7px 8px;
  color: var(--ink);
  background: #fff;
  border: 1px solid var(--line);
  border-radius: 5px;
  font-size: 11px;
}

.review-field input {
  height: 32px;
}

.review-field textarea {
  min-height: 54px;
  resize: vertical;
  line-height: 1.55;
}

.review-checklist {
  display: grid;
  gap: 5px;
  margin-top: 10px;
}

.review-checklist label {
  display: grid;
  grid-template-columns: 16px minmax(0, 1fr);
  align-items: start;
  gap: 7px;
  padding: 6px 7px;
  color: #596660;
  background: #f7f5ef;
  border: 1px solid #e0dacd;
  border-radius: 6px;
  cursor: pointer;
  font-size: 9px;
  line-height: 1.45;
}

.review-checklist label:has(input:checked) {
  color: #0d684f;
  background: #e6f5ed;
  border-color: #badfcd;
}

.review-checklist input {
  width: 14px;
  height: 14px;
  margin: 0;
  accent-color: var(--green);
}

.review-confirm-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  margin-top: 10px;
}

.review-confirm-row > span {
  color: #78817c;
  font-size: 8px;
  line-height: 1.45;
}

.button-review {
  min-height: 34px;
  padding: 0 10px;
  color: #fff;
  background: var(--green);
  border-color: var(--green);
  font-size: 10px;
}

.button-review:disabled {
  cursor: not-allowed;
  opacity: 0.45;
  transform: none;
}

.export-panel {
  padding: 15px;
  color: #f4f1e9;
  background:
    radial-gradient(circle at 90% 0%, rgba(185, 255, 223, 0.18), transparent 38%),
    var(--ink);
  border-radius: 11px;
}

.export-copy .eyebrow {
  color: rgba(185, 255, 223, 0.72);
}

.export-copy p {
  margin: 7px 0 12px;
  color: rgba(244, 241, 233, 0.65);
  font-size: 10px;
  line-height: 1.65;
}

.button-dxf {
  justify-content: space-between;
  width: 100%;
  min-height: 46px;
  margin-bottom: 9px;
  padding: 7px 11px;
  color: var(--ink);
  background: var(--mint);
  border-color: var(--mint);
}

.button-dxf small {
  padding: 3px 6px;
  color: #0d6048;
  background: rgba(20, 35, 31, 0.09);
  border-radius: 999px;
  font-size: 8px;
}

.button-dxf.locked {
  color: rgba(244, 241, 233, 0.75);
  background: rgba(255, 255, 255, 0.07);
  border-color: rgba(255, 255, 255, 0.15);
}

.button-dxf.locked small {
  color: rgba(244, 241, 233, 0.62);
  background: rgba(255, 255, 255, 0.07);
}

.export-actions {
  flex-wrap: wrap;
}

.export-actions .button {
  flex: 1 1 calc(50% - 4px);
}

.toast {
  position: fixed;
  z-index: 100;
  right: 24px;
  bottom: 24px;
  max-width: min(390px, calc(100vw - 48px));
  padding: 12px 15px;
  color: #fff;
  background: var(--ink);
  border: 1px solid rgba(255, 255, 255, 0.12);
  border-radius: 9px;
  box-shadow: 0 16px 50px rgba(20, 35, 31, 0.28);
  font-size: 12px;
  line-height: 1.5;
  opacity: 0;
  pointer-events: none;
  transform: translateY(12px);
  transition: 180ms ease;
}

.toast.show {
  opacity: 1;
  transform: translateY(0);
}

@media (max-width: 1360px) {
  .workspace {
    grid-template-columns: 70px minmax(0, 1fr) 350px;
  }

  .topbar {
    grid-template-columns: 220px minmax(220px, 1fr) auto;
  }

  .project-title {
    min-width: 220px;
  }
}

@media (max-width: 1180px) {
  .workspace {
    grid-template-columns: 68px minmax(0, 1fr) 330px;
  }

  .topbar {
    grid-template-columns: 210px minmax(220px, 1fr) auto;
  }

  .top-actions .button-ghost:not(.file-button) {
    display: none;
  }
}

@media (min-width: 861px) {
  .workspace > .toolrail,
  .workspace > .stage-shell,
  .workspace > .inspector {
    height: 100%;
    min-height: 0;
    max-height: 100%;
  }
}

@media (min-width: 861px) and (max-height: 820px) {
  .toolrail {
    padding: 10px 6px;
  }

  .tool {
    min-height: 55px;
    margin-bottom: 3px;
  }

  .tool.compact {
    min-height: 48px;
  }
}

@media (min-width: 861px) and (max-height: 720px) {
  :root {
    --topbar-height: 64px;
  }

  .topbar {
    padding: 0 14px;
  }

  .brand-mark {
    width: 38px;
    height: 38px;
    font-size: 20px;
  }

  .brand-copy small {
    display: none;
  }

  .project-title {
    margin-left: 8px;
  }

  .toolrail {
    padding: 8px 6px;
  }

  .toolrail-label {
    margin-bottom: 5px;
  }

  .tool {
    min-height: 50px;
    margin-bottom: 3px;
    padding: 5px 2px;
    font-size: 9px;
  }

  .tool svg {
    width: 19px;
    height: 19px;
    margin-bottom: 3px;
  }

  .tool.compact {
    min-height: 46px;
  }

  .stage-viewport {
    padding: 18px;
  }

  .inspector {
    padding: 12px;
  }

  .inspector-head {
    padding: 0 2px 10px;
  }

  .inspector-head h1 {
    font-size: 18px;
  }

  .panel {
    margin-bottom: 9px;
  }

  .panel-body {
    padding: 10px;
  }

  .spec-strip {
    margin-bottom: 10px;
  }

  .form-grid {
    gap: 8px;
  }

  .setting-toggle,
  .recognition-switch {
    margin-top: 8px;
    padding: 8px;
  }
}

@media (min-width: 861px) and (max-height: 620px) {
  .toolrail {
    padding: 6px;
  }

  .toolrail-label,
  .toolrail-spacer {
    display: none;
  }

  .tool span {
    position: absolute;
    width: 1px;
    height: 1px;
    overflow: hidden;
    clip-path: inset(50%);
    white-space: nowrap;
  }

  .tool,
  .tool.compact {
    min-height: 42px;
    margin-bottom: 0;
    padding: 3px;
  }

  .tool svg {
    width: 20px;
    height: 20px;
    margin-bottom: 0;
  }
}

@media (max-width: 860px) {
  body {
    overflow: auto;
  }

  .app-shell {
    display: block;
    height: auto;
    min-height: 100vh;
    min-height: 100dvh;
    overflow: visible;
  }

  .topbar {
    position: sticky;
    top: 0;
    grid-template-columns: 1fr auto;
    height: 66px;
    padding: 0 12px;
  }

  .brand-copy small,
  .project-title,
  .top-actions .button-ghost {
    display: none;
  }

  .top-actions .button-accent {
    min-height: 36px;
    padding: 0 11px;
    font-size: 11px;
  }

  .workspace {
    display: grid;
    grid-template-columns: 1fr;
    grid-template-rows: minmax(590px, calc(100vh - 66px)) auto;
    height: auto;
  }

  .stage-shell {
    grid-row: 1;
    grid-template-rows: 42px minmax(0, 1fr) 35px;
  }

  .stage-viewport {
    padding: 18px;
  }

  .drawing-meta strong {
    max-width: 150px;
  }

  .zoom-controls button:last-child {
    display: none;
  }

  .stage-status {
    gap: 12px;
    overflow: hidden;
  }

  #toolHint {
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
  }

  .toolrail {
    position: fixed;
    z-index: 60;
    right: 10px;
    bottom: 10px;
    left: 10px;
    display: grid;
    grid-template-columns: repeat(10, minmax(44px, 1fr));
    padding: 6px;
    background: rgba(20, 35, 31, 0.96);
    border: 1px solid rgba(255, 255, 255, 0.12);
    border-radius: 13px;
    box-shadow: 0 14px 45px rgba(20, 35, 31, 0.35);
    overflow-x: auto;
    overflow-y: hidden;
    scrollbar-width: none;
  }

  .toolrail::-webkit-scrollbar {
    display: none;
  }

  .toolrail-label,
  .toolrail-spacer,
  #clearButton {
    display: none;
  }

  .tool {
    min-height: 48px;
    margin: 0;
    color: rgba(255, 255, 255, 0.7);
    border-radius: 8px;
    min-width: 0;
    font-size: 7px;
  }

  .tool svg {
    width: 19px;
    height: 19px;
    margin-bottom: 2px;
  }

  .tool:hover {
    color: #fff;
    background: rgba(255, 255, 255, 0.08);
  }

  .tool.active {
    color: var(--mint);
    background: rgba(185, 255, 223, 0.12);
    border-color: rgba(185, 255, 223, 0.28);
    box-shadow: inset 0 -2px 0 var(--mint);
  }

  .inspector {
    grid-row: 2;
    overflow: visible;
    padding: 18px 14px 100px;
    border-top: 1px solid var(--line-dark);
    border-left: 0;
  }

  .inspector-head {
    max-width: 760px;
    margin: 0 auto;
  }

  .panel,
  .export-panel {
    max-width: 760px;
    margin-right: auto;
    margin-left: auto;
  }
}

@media (max-width: 480px) {
  .brand-mark {
    width: 38px;
    height: 38px;
    font-size: 20px;
  }

  .brand-copy strong {
    font-size: 19px;
  }

  .button-accent svg {
    display: none;
  }

  .stage-viewport {
    padding: 12px;
  }

  .drawing-meta > span:last-child,
  #scaleStatus {
    display: none;
  }

  .form-grid {
    grid-template-columns: 1fr 1fr;
  }

  .inspector-head h1 {
    font-size: 19px;
  }

  .review-confirm-row {
    align-items: stretch;
    flex-direction: column;
  }

  .button-review {
    width: 100%;
  }
}

@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    scroll-behavior: auto !important;
    transition-duration: 0.01ms !important;
    animation-duration: 0.01ms !important;
  }
}
