:root {
  color-scheme: dark;
  --bg: #081114;
  --bg-raised: #0d191d;
  --panel: #112126;
  --panel-2: #15292f;
  --panel-3: #1b3339;
  --ink: #edf8f5;
  --ink-2: #a6bbb6;
  --ink-3: #6f8682;
  --line: #213a40;
  --line-soft: #193037;
  --accent: #65ddbd;
  --accent-strong: #8bf0d5;
  --accent-ink: #06251e;
  --blue: #71b5ff;
  --orange: #f3b05c;
  --red: #ff817d;
  --purple: #c7a5ff;
  --paper: #f2f2ea;
  --paper-ink: #183037;
  --shadow: 0 18px 48px rgba(0, 0, 0, .24);
  --radius: 20px;
  --radius-sm: 13px;
  --safe-top: env(safe-area-inset-top, 0px);
  --safe-bottom: env(safe-area-inset-bottom, 0px);
}

@media (prefers-color-scheme: light) {
  :root {
    color-scheme: light;
    --bg: #edf2ef;
    --bg-raised: #e4ebe7;
    --panel: #fbfdfb;
    --panel-2: #eff5f2;
    --panel-3: #e6efeb;
    --ink: #122426;
    --ink-2: #516a66;
    --ink-3: #7d918d;
    --line: #ccd9d4;
    --line-soft: #dfe7e4;
    --accent: #087f68;
    --accent-strong: #096a58;
    --accent-ink: #f3fff9;
    --blue: #276fb8;
    --orange: #b46e0d;
    --red: #c94f4c;
    --purple: #7752b5;
    --shadow: 0 16px 36px rgba(38, 64, 58, .1);
  }
}

* {
  box-sizing: border-box;
}

[hidden] {
  display: none !important;
}

html {
  min-height: 100%;
  background: var(--bg);
  -webkit-text-size-adjust: 100%;
}

body {
  min-width: 320px;
  min-height: 100%;
  margin: 0;
  background:
    radial-gradient(circle at 90% -12%, rgba(101, 221, 189, .1), transparent 33rem),
    var(--bg);
  color: var(--ink);
  font-family: -apple-system, BlinkMacSystemFont, "SF Pro Text", "PingFang SC", "Microsoft YaHei", sans-serif;
  font-size: 15px;
  line-height: 1.46;
  -webkit-font-smoothing: antialiased;
  overscroll-behavior-y: none;
}

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

button {
  color: inherit;
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
}

button:active {
  transform: scale(.985);
}

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

svg {
  fill: none;
  stroke: currentColor;
  stroke-linecap: round;
  stroke-linejoin: round;
  stroke-width: 1.8;
}

.app-shell {
  width: min(100%, 760px);
  min-height: 100dvh;
  margin: 0 auto;
  padding-bottom: calc(84px + var(--safe-bottom));
}

.topbar {
  position: sticky;
  z-index: 20;
  top: 0;
  display: flex;
  align-items: center;
  justify-content: space-between;
  height: calc(64px + var(--safe-top));
  padding: var(--safe-top) 20px 0;
  background: color-mix(in srgb, var(--bg) 88%, transparent);
  border-bottom: 1px solid color-mix(in srgb, var(--line) 62%, transparent);
  -webkit-backdrop-filter: blur(18px);
  backdrop-filter: blur(18px);
}

.brand {
  display: flex;
  align-items: center;
  gap: 11px;
}

.brand-mark {
  width: 35px;
  height: 35px;
  border-radius: 10px;
  box-shadow: 0 6px 16px rgba(0, 0, 0, .18);
}

.brand-name {
  font-size: 17px;
  font-weight: 650;
  letter-spacing: .03em;
}

.brand-en {
  margin-top: 1px;
  color: var(--ink-3);
  font-size: 9px;
  font-weight: 650;
  letter-spacing: .18em;
}

.icon-button {
  display: grid;
  width: 42px;
  height: 42px;
  padding: 10px;
  place-items: center;
  color: var(--ink-2);
  background: transparent;
  border: 1px solid var(--line);
  border-radius: 13px;
}

.icon-button svg {
  width: 21px;
  height: 21px;
}

.main-content {
  padding: 12px 16px 24px;
}

.page {
  display: none;
  scroll-margin-top: calc(80px + var(--safe-top));
  animation: page-in .22s ease-out;
}

.page.is-active {
  display: block;
}

@keyframes page-in {
  from { opacity: .3; transform: translateY(4px); }
  to { opacity: 1; transform: translateY(0); }
}

.page-heading {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 14px;
  padding: 17px 2px 20px;
}

.eyebrow,
.section-label {
  display: block;
  color: var(--accent);
  font-size: 10px;
  font-weight: 700;
  letter-spacing: .14em;
  text-transform: uppercase;
}

h1,
h2,
h3,
p {
  margin: 0;
}

h1 {
  margin-top: 4px;
  font-size: clamp(25px, 7.5vw, 34px);
  font-weight: 620;
  letter-spacing: -.035em;
  line-height: 1.1;
}

h2 {
  margin-top: 3px;
  font-size: 17px;
  font-weight: 620;
  letter-spacing: -.015em;
}

.page-heading p {
  max-width: 490px;
  margin-top: 8px;
  color: var(--ink-2);
  font-size: 13px;
}

.status-pill {
  display: inline-flex;
  flex: 0 0 auto;
  align-items: center;
  gap: 6px;
  margin-top: 4px;
  padding: 6px 9px;
  color: var(--ink-2);
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 999px;
  font-size: 10px;
  white-space: nowrap;
}

.status-pill span {
  width: 6px;
  height: 6px;
  background: var(--accent);
  border-radius: 50%;
  box-shadow: 0 0 0 3px color-mix(in srgb, var(--accent) 15%, transparent);
}

.metric-strip {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  margin-bottom: 14px;
  padding: 12px 4px;
  background: var(--panel);
  border: 1px solid var(--line-soft);
  border-radius: var(--radius);
}

.metric-strip > div {
  position: relative;
  display: flex;
  align-items: center;
  flex-direction: column;
  gap: 2px;
}

.metric-strip > div + div::before {
  position: absolute;
  top: 4px;
  bottom: 4px;
  left: 0;
  width: 1px;
  background: var(--line);
  content: "";
}

.metric-strip strong {
  font-size: 20px;
  font-variant-numeric: tabular-nums;
  font-weight: 620;
}

.metric-strip span {
  color: var(--ink-3);
  font-size: 10px;
}

.card {
  margin-bottom: 14px;
  padding: 16px;
  background: var(--panel);
  border: 1px solid var(--line-soft);
  border-radius: var(--radius);
}

.card-heading {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  margin-bottom: 13px;
}

.compact-actions {
  display: flex;
  align-items: center;
  gap: 7px;
}

.small-button {
  min-height: 36px;
  padding: 7px 12px;
  color: var(--ink-2);
  background: var(--panel-2);
  border: 1px solid var(--line);
  border-radius: 10px;
  font-size: 12px;
  font-weight: 570;
}

.small-button.accent {
  color: var(--accent);
  background: color-mix(in srgb, var(--accent) 9%, var(--panel));
  border-color: color-mix(in srgb, var(--accent) 36%, var(--line));
}

.reference-stage {
  position: relative;
  display: grid;
  min-height: 235px;
  overflow: hidden;
  place-items: center;
  background:
    linear-gradient(color-mix(in srgb, var(--line) 55%, transparent) 1px, transparent 1px),
    linear-gradient(90deg, color-mix(in srgb, var(--line) 55%, transparent) 1px, transparent 1px),
    var(--bg-raised);
  background-size: 24px 24px;
  border: 1px dashed var(--line);
  border-radius: 15px;
}

.reference-stage.has-image {
  min-height: 250px;
  background: var(--paper);
  border-style: solid;
}

#referenceImage {
  display: none;
  width: 100%;
  max-height: 430px;
  object-fit: contain;
  opacity: .38;
}

.reference-stage.has-image #referenceImage {
  display: block;
}

.reference-empty {
  position: absolute;
  display: flex;
  align-items: center;
  flex-direction: column;
  padding: 28px;
  text-align: center;
}

.reference-stage.has-image .reference-empty {
  display: none;
}

.reference-empty svg {
  width: 31px;
  height: 31px;
  margin-bottom: 12px;
  color: var(--accent);
}

.reference-empty strong {
  font-size: 14px;
  font-weight: 570;
}

.reference-empty span {
  margin-top: 4px;
  color: var(--ink-3);
  font-size: 11px;
}

.image-opacity {
  position: absolute;
  right: 10px;
  bottom: 9px;
  left: 10px;
  display: none;
  align-items: center;
  gap: 10px;
  padding: 7px 10px;
  color: #365056;
  background: rgba(250, 250, 244, .9);
  border-radius: 9px;
  -webkit-backdrop-filter: blur(8px);
  backdrop-filter: blur(8px);
}

.reference-stage.has-image .image-opacity {
  display: flex;
}

.image-opacity label {
  flex: 0 0 auto;
  font-size: 10px;
}

.image-opacity input {
  width: 100%;
  accent-color: #087f68;
}

.mini-legend {
  display: flex;
  align-items: center;
  gap: 5px;
  color: var(--ink-3);
  font-size: 9px;
}

.mini-legend i {
  display: inline-block;
  width: 13px;
  height: 2px;
  margin-left: 5px;
  border-radius: 2px;
}

.line-pressure { background: var(--red); }
.line-tank { background: var(--blue); }
.line-work { background: var(--accent); }

.schematic-scroll {
  overflow-x: auto;
  border: 1px solid var(--line-soft);
  border-radius: 14px;
  scrollbar-width: none;
}

.schematic-scroll::-webkit-scrollbar {
  display: none;
}

.schematic-svg {
  display: block;
  width: 100%;
  min-width: 620px;
  height: auto;
  background: var(--bg-raised);
}

.hint {
  margin-top: 10px;
  color: var(--ink-3);
  font-size: 10px;
}

.primary-action,
.secondary-action,
.danger-link {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 7px;
  width: 100%;
  min-height: 50px;
  padding: 12px 18px;
  background: var(--accent);
  color: var(--accent-ink);
  border: 0;
  border-radius: 14px;
  font-size: 14px;
  font-weight: 680;
}

.primary-action svg {
  width: 18px;
  height: 18px;
}

.primary-action.compact {
  width: auto;
  min-height: 44px;
  padding-inline: 20px;
}

.secondary-action {
  color: var(--ink);
  background: var(--panel-2);
  border: 1px solid var(--line);
  font-size: 13px;
  font-weight: 590;
}

.danger-link {
  min-height: 40px;
  margin-top: 8px;
  color: var(--red);
  background: transparent;
  font-size: 12px;
  font-weight: 550;
}

.callout,
.notice {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  margin: 14px 0;
  padding: 12px 14px;
  color: var(--ink-2);
  background: color-mix(in srgb, var(--panel-2) 72%, transparent);
  border-left: 2px solid var(--accent);
  border-radius: 3px 12px 12px 3px;
  font-size: 11px;
}

.callout strong,
.notice strong {
  flex: 0 0 auto;
  color: var(--ink);
  font-weight: 600;
}

.notice.warning {
  margin-top: 0;
  border-color: var(--orange);
  background: color-mix(in srgb, var(--orange) 8%, var(--panel));
}

.editor-list {
  display: grid;
  gap: 12px;
}

.catalog-card {
  margin-bottom: 10px;
  background:
    linear-gradient(135deg, color-mix(in srgb, var(--accent) 7%, transparent), transparent 62%),
    var(--panel);
}

.catalog-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
}

.catalog-head p {
  margin-top: 4px;
  color: var(--ink-3);
  font-size: 10px;
}

.source-seal {
  display: grid;
  min-width: 42px;
  height: 42px;
  padding: 0 8px;
  place-items: center;
  color: var(--accent);
  background: color-mix(in srgb, var(--accent) 9%, transparent);
  border: 1px solid color-mix(in srgb, var(--accent) 28%, var(--line));
  border-radius: 13px;
  font-size: 15px;
  font-variant-numeric: tabular-nums;
  font-weight: 680;
}

.catalog-actions {
  display: flex;
  gap: 7px;
  margin-top: 13px;
}

a.small-button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  text-decoration: none;
}

.catalog-note {
  margin-top: 10px;
  color: var(--ink-3);
  font-size: 9px;
}

.catalog-search {
  position: relative;
  display: flex;
  align-items: center;
  margin: 11px 0;
}

.catalog-search svg {
  position: absolute;
  left: 12px;
  width: 17px;
  height: 17px;
  color: var(--ink-3);
  pointer-events: none;
}

.catalog-search input {
  width: 100%;
  min-height: 44px;
  padding: 9px 12px 9px 38px;
  color: var(--ink);
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 12px;
  outline: none;
  -webkit-appearance: none;
  appearance: none;
}

.catalog-search input:focus {
  border-color: var(--accent);
}

.editor-card[open] {
  padding-bottom: 0;
}

.editor-card > summary {
  list-style: none;
  cursor: pointer;
}

.editor-card > summary::-webkit-details-marker {
  display: none;
}

.editor-card > summary::after {
  width: 8px;
  height: 8px;
  flex: 0 0 auto;
  margin: -4px 10px 0 0;
  border-right: 1.5px solid var(--ink-3);
  border-bottom: 1.5px solid var(--ink-3);
  content: "";
  transform: rotate(45deg);
}

.editor-card[open] > summary::after {
  margin-top: 4px;
  transform: rotate(225deg);
}

.source-badge {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 4px 7px;
  color: var(--accent);
  background: color-mix(in srgb, var(--accent) 8%, transparent);
  border: 1px solid color-mix(in srgb, var(--accent) 22%, transparent);
  border-radius: 6px;
  font-size: 8px;
  font-weight: 650;
  letter-spacing: .03em;
  white-space: nowrap;
}

.source-badge.modified {
  color: var(--orange);
  background: color-mix(in srgb, var(--orange) 8%, transparent);
  border-color: color-mix(in srgb, var(--orange) 25%, transparent);
}

.source-line {
  display: flex;
  align-items: center;
  justify-content: space-between;
  grid-column: 1 / -1;
  gap: 10px;
  margin-top: 3px;
  padding: 10px 11px;
  color: var(--ink-3);
  background: var(--bg-raised);
  border: 1px solid var(--line-soft);
  border-radius: 10px;
  font-size: 9px;
}

.source-line a {
  flex: 0 0 auto;
  color: var(--accent);
  text-decoration: none;
  font-weight: 600;
}

.catalog-empty {
  padding: 28px 16px;
  color: var(--ink-3);
  text-align: center;
  font-size: 12px;
}

.editor-card {
  overflow: hidden;
  background: var(--panel);
  border: 1px solid var(--line-soft);
  border-radius: var(--radius);
}

.editor-card-head {
  display: flex;
  align-items: center;
  gap: 11px;
  padding: 13px 14px;
  background: var(--panel-2);
  border-bottom: 1px solid var(--line-soft);
}

.editor-index {
  display: grid;
  width: 31px;
  height: 31px;
  flex: 0 0 auto;
  place-items: center;
  color: var(--accent);
  background: color-mix(in srgb, var(--accent) 10%, transparent);
  border: 1px solid color-mix(in srgb, var(--accent) 22%, transparent);
  border-radius: 9px;
  font-size: 11px;
  font-variant-numeric: tabular-nums;
  font-weight: 650;
}

.editor-title {
  min-width: 0;
  flex: 1;
}

.editor-title strong {
  display: block;
  overflow: hidden;
  font-size: 14px;
  font-weight: 600;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.editor-title span {
  display: block;
  overflow: hidden;
  margin-top: 1px;
  color: var(--ink-3);
  font-size: 10px;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.delete-button {
  display: grid;
  width: 34px;
  height: 34px;
  flex: 0 0 auto;
  padding: 8px;
  place-items: center;
  color: var(--ink-3);
  background: transparent;
  border: 0;
  border-radius: 9px;
}

.delete-button svg {
  width: 17px;
  height: 17px;
}

.editor-body {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 11px;
  padding: 14px;
}

.field {
  display: flex;
  min-width: 0;
  flex-direction: column;
  gap: 5px;
}

.field.wide {
  grid-column: 1 / -1;
}

.field > span {
  color: var(--ink-2);
  font-size: 10px;
  font-weight: 520;
}

.field input,
.field select {
  width: 100%;
  min-width: 0;
  min-height: 41px;
  padding: 8px 10px;
  color: var(--ink);
  background: var(--bg-raised);
  border: 1px solid var(--line);
  border-radius: 10px;
  font-size: 14px;
  font-variant-numeric: tabular-nums;
  -webkit-appearance: none;
  appearance: none;
  outline: none;
}

.field select {
  padding-right: 28px;
  background-image:
    linear-gradient(45deg, transparent 50%, var(--ink-3) 50%),
    linear-gradient(135deg, var(--ink-3) 50%, transparent 50%);
  background-position:
    calc(100% - 15px) 17px,
    calc(100% - 10px) 17px;
  background-repeat: no-repeat;
  background-size: 5px 5px, 5px 5px;
}

.field input:focus,
.field select:focus {
  border-color: var(--accent);
}

.field small {
  color: var(--ink-3);
  font-size: 9px;
}

.connection-group {
  grid-column: 1 / -1;
  margin-top: 3px;
  padding-top: 11px;
  border-top: 1px solid var(--line-soft);
}

.connection-label {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 8px;
  color: var(--ink-2);
  font-size: 10px;
}

.connection-label strong {
  color: var(--ink);
  font-weight: 540;
}

.connection-fields {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 7px;
}

.connection-field {
  display: flex;
  min-width: 0;
  flex-direction: column;
  gap: 4px;
}

.connection-field label {
  color: var(--ink-3);
  font-size: 9px;
  text-align: center;
}

.connection-field input {
  width: 100%;
  min-width: 0;
  min-height: 38px;
  padding: 7px;
  color: var(--ink);
  background: color-mix(in srgb, var(--panel-2) 70%, var(--bg-raised));
  border: 1px solid var(--line-soft);
  border-radius: 8px;
  font-size: 13px;
  font-weight: 590;
  text-align: center;
  text-transform: uppercase;
}

.inline-presets {
  display: flex;
  gap: 5px;
  margin-top: 8px;
  overflow-x: auto;
  scrollbar-width: none;
}

.inline-presets::-webkit-scrollbar {
  display: none;
}

.preset-chip {
  flex: 0 0 auto;
  padding: 5px 8px;
  color: var(--ink-3);
  background: transparent;
  border: 1px dashed var(--line);
  border-radius: 7px;
  font-size: 9px;
}

.generate-button {
  position: relative;
  display: flex;
  align-items: center;
  width: 100%;
  gap: 13px;
  margin: 6px 0 16px;
  padding: 15px 17px;
  overflow: hidden;
  color: var(--accent-ink);
  background:
    linear-gradient(110deg, color-mix(in srgb, var(--accent-strong) 92%, white), var(--accent));
  border: 0;
  border-radius: 18px;
  box-shadow: 0 14px 30px color-mix(in srgb, var(--accent) 18%, transparent);
  text-align: left;
}

.generate-button::after {
  position: absolute;
  top: -40px;
  right: 52px;
  width: 100px;
  height: 150px;
  background: rgba(255, 255, 255, .15);
  content: "";
  transform: rotate(26deg);
}

.generate-icon {
  display: grid;
  width: 42px;
  height: 42px;
  flex: 0 0 auto;
  place-items: center;
  background: rgba(0, 46, 37, .12);
  border-radius: 13px;
}

.generate-icon svg {
  width: 24px;
  height: 24px;
  stroke-width: 1.7;
}

.generate-button > span:nth-child(2) {
  z-index: 1;
  display: flex;
  flex: 1;
  flex-direction: column;
}

.generate-button strong {
  font-size: 15px;
  font-weight: 700;
}

.generate-button small {
  margin-top: 2px;
  font-size: 10px;
  opacity: .72;
}

.generate-arrow {
  z-index: 1;
  width: 19px;
  height: 19px;
}

.empty-result {
  display: flex;
  align-items: center;
  flex-direction: column;
  padding: 45px 24px;
  color: var(--ink-3);
  text-align: center;
}

.empty-result h2 {
  margin: 20px 0 5px;
  color: var(--ink);
  font-size: 15px;
}

.empty-result p {
  max-width: 300px;
  font-size: 11px;
}

.blueprint-mark {
  position: relative;
  width: 72px;
  height: 58px;
  border: 1px solid var(--line);
  border-radius: 8px;
}

.blueprint-mark::before,
.blueprint-mark::after {
  position: absolute;
  background: var(--line);
  content: "";
}

.blueprint-mark::before {
  top: 50%;
  right: -12px;
  left: -12px;
  height: 1px;
}

.blueprint-mark::after {
  top: -12px;
  bottom: -12px;
  left: 50%;
  width: 1px;
}

.blueprint-mark span {
  position: absolute;
  z-index: 1;
  width: 15px;
  height: 15px;
  background: var(--panel);
  border: 1px solid var(--accent);
  border-radius: 50%;
}

.blueprint-mark span:nth-child(1) { top: 8px; left: 10px; }
.blueprint-mark span:nth-child(2) { top: 8px; right: 10px; }
.blueprint-mark span:nth-child(3) { bottom: 8px; left: 10px; }
.blueprint-mark span:nth-child(4) { right: 10px; bottom: 8px; }

.result-summary {
  display: grid;
  grid-template-columns: 1.35fr 1fr;
  gap: 10px;
  margin-bottom: 12px;
}

.result-main,
.score-block {
  padding: 16px;
  background: var(--panel);
  border: 1px solid var(--line-soft);
  border-radius: var(--radius);
}

.result-main span,
.score-block span {
  display: block;
  color: var(--ink-3);
  font-size: 10px;
}

.result-main strong {
  display: block;
  margin-top: 4px;
  font-size: 20px;
  font-variant-numeric: tabular-nums;
  font-weight: 640;
  letter-spacing: -.03em;
}

.result-main small {
  display: block;
  margin-top: 2px;
  color: var(--ink-2);
  font-size: 10px;
}

.score-block strong {
  display: block;
  margin: 5px 0 9px;
  font-size: 20px;
  font-variant-numeric: tabular-nums;
  font-weight: 620;
}

.score-bar {
  height: 4px;
  overflow: hidden;
  background: var(--panel-3);
  border-radius: 3px;
}

.score-bar i {
  display: block;
  width: 0;
  height: 100%;
  background: var(--accent);
  border-radius: inherit;
  transition: width .45s ease;
}

.view-switcher {
  display: flex;
  gap: 3px;
  margin: 12px 0 9px;
  padding: 3px;
  background: var(--panel);
  border: 1px solid var(--line-soft);
  border-radius: 12px;
}

.view-switcher button {
  flex: 1;
  padding: 8px 5px;
  color: var(--ink-3);
  background: transparent;
  border: 0;
  border-radius: 9px;
  font-size: 11px;
}

.view-switcher button.is-active {
  color: var(--ink);
  background: var(--panel-3);
  font-weight: 590;
}

.drawing-card {
  overflow: hidden;
  background: var(--paper);
  border: 1px solid color-mix(in srgb, var(--line) 70%, transparent);
  border-radius: 17px;
}

.drawing-toolbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  min-height: 48px;
  padding: 8px 12px;
  color: var(--paper-ink);
  background: #e5e6dc;
  border-bottom: 1px solid #cdd0c5;
}

.drawing-toolbar span {
  display: block;
  font-size: 12px;
  font-weight: 650;
}

.drawing-toolbar small {
  display: block;
  margin-top: 1px;
  color: #6a7774;
  font-size: 9px;
}

.drawing-toolbar .small-button {
  min-height: 31px;
  color: #2e494a;
  background: transparent;
  border-color: #bfc5ba;
}

.drawing-stage {
  overflow: auto;
  padding: 10px;
  background:
    linear-gradient(rgba(51, 70, 75, .045) 1px, transparent 1px),
    linear-gradient(90deg, rgba(51, 70, 75, .045) 1px, transparent 1px),
    var(--paper);
  background-size: 18px 18px;
  scrollbar-width: thin;
}

.drawing-stage.is-zoomed {
  align-items: flex-start;
}

.drawing-svg-wrap {
  min-width: 0;
}

.drawing-stage.is-zoomed .drawing-svg-wrap {
  min-width: 980px;
}

.drawing-svg-wrap svg {
  display: block;
  width: 100%;
  height: auto;
  color: var(--paper-ink);
}

.export-row {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 7px;
  margin: 10px 0 14px;
}

.export-row .secondary-action {
  min-height: 43px;
  padding-inline: 5px;
  font-size: 11px;
}

.count-badge {
  display: grid;
  min-width: 28px;
  height: 28px;
  padding: 0 7px;
  place-items: center;
  color: var(--orange);
  background: color-mix(in srgb, var(--orange) 10%, transparent);
  border-radius: 9px;
  font-size: 11px;
  font-variant-numeric: tabular-nums;
  font-weight: 620;
}

.check-list {
  display: grid;
  gap: 2px;
}

.check-item {
  display: flex;
  align-items: flex-start;
  gap: 9px;
  padding: 10px 0;
  border-top: 1px solid var(--line-soft);
}

.check-item:first-child {
  border-top: 0;
}

.check-dot {
  width: 7px;
  height: 7px;
  flex: 0 0 auto;
  margin-top: 5px;
  background: var(--orange);
  border-radius: 50%;
}

.check-item.ok .check-dot {
  background: var(--accent);
}

.check-item.error .check-dot {
  background: var(--red);
}

.check-item div {
  min-width: 0;
}

.check-item strong {
  display: block;
  color: var(--ink);
  font-size: 11px;
  font-weight: 560;
}

.check-item span {
  display: block;
  margin-top: 2px;
  color: var(--ink-3);
  font-size: 10px;
}

.table-wrap {
  overflow-x: auto;
}

table {
  width: 100%;
  border-collapse: collapse;
  font-size: 11px;
}

th {
  color: var(--ink-3);
  font-size: 9px;
  font-weight: 560;
  text-align: left;
}

th,
td {
  padding: 9px 5px;
  border-top: 1px solid var(--line-soft);
  white-space: nowrap;
}

td {
  color: var(--ink-2);
}

td strong {
  color: var(--ink);
  font-weight: 580;
}

.tabbar {
  position: fixed;
  z-index: 30;
  right: 0;
  bottom: 0;
  left: 0;
  display: flex;
  align-items: flex-start;
  justify-content: space-around;
  width: min(100%, 760px);
  min-height: calc(64px + var(--safe-bottom));
  margin: 0 auto;
  padding: 6px 7px var(--safe-bottom);
  background: color-mix(in srgb, var(--bg-raised) 92%, transparent);
  border-top: 1px solid var(--line);
  -webkit-backdrop-filter: blur(22px);
  backdrop-filter: blur(22px);
}

.tabbar button {
  display: flex;
  width: 20%;
  min-height: 52px;
  align-items: center;
  flex-direction: column;
  justify-content: center;
  gap: 2px;
  padding: 4px;
  color: var(--ink-3);
  background: transparent;
  border: 0;
  border-radius: 12px;
  font-size: 9px;
}

.tabbar button.is-active {
  color: var(--accent);
}

.tabbar button.is-active::before {
  position: absolute;
  width: 19px;
  height: 2px;
  margin-top: -49px;
  background: var(--accent);
  border-radius: 2px;
  content: "";
}

.tabbar svg {
  width: 21px;
  height: 21px;
  stroke-width: 1.7;
}

.sheet-dialog {
  width: min(100%, 760px);
  max-width: none;
  max-height: calc(100dvh - 20px);
  margin: auto auto 0;
  padding: 0;
  overflow: visible;
  color: var(--ink);
  background: transparent;
  border: 0;
}

.sheet-dialog::backdrop {
  background: rgba(1, 8, 10, .68);
  -webkit-backdrop-filter: blur(4px);
  backdrop-filter: blur(4px);
}

.sheet {
  max-height: calc(100dvh - 20px);
  padding: 9px 18px calc(22px + var(--safe-bottom));
  overflow-y: auto;
  background: var(--bg-raised);
  border: 1px solid var(--line);
  border-bottom: 0;
  border-radius: 24px 24px 0 0;
  box-shadow: var(--shadow);
}

.export-dialog {
  width: min(calc(100% - 24px), 740px);
  max-height: calc(100dvh - 32px);
  padding: 16px;
  overflow-y: auto;
  color: var(--ink);
  background: var(--bg-raised);
  border: 1px solid var(--line);
  border-radius: 22px;
  box-shadow: var(--shadow);
}

.export-dialog::backdrop {
  background: rgba(1, 8, 10, .72);
  -webkit-backdrop-filter: blur(4px);
  backdrop-filter: blur(4px);
}

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

.export-preview {
  display: grid;
  min-height: 180px;
  overflow: auto;
  place-items: center;
  background: var(--paper);
  border-radius: 13px;
}

.export-preview img {
  display: block;
  width: 100%;
  height: auto;
}

.export-tip {
  margin: 11px 2px;
  color: var(--ink-2);
  font-size: 10px;
}

.export-dialog .primary-action {
  text-decoration: none;
}

.sheet-grabber {
  width: 34px;
  height: 4px;
  margin: 0 auto 15px;
  background: var(--line);
  border-radius: 4px;
}

.sheet-heading {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  margin-bottom: 18px;
}

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

.sheet-rule {
  height: 1px;
  margin: 18px 0 12px;
  background: var(--line);
}

.sheet-actions {
  display: grid;
  grid-template-columns: 1fr 1fr 1fr;
  gap: 7px;
}

.sheet-actions .secondary-action,
.sheet-actions .primary-action {
  min-height: 44px;
  padding: 8px;
  font-size: 11px;
}

.toast {
  position: fixed;
  z-index: 100;
  right: 18px;
  bottom: calc(80px + var(--safe-bottom));
  left: 18px;
  max-width: 430px;
  margin: 0 auto;
  padding: 11px 14px;
  color: var(--ink);
  background: var(--panel-3);
  border: 1px solid var(--line);
  border-radius: 12px;
  box-shadow: var(--shadow);
  font-size: 11px;
  opacity: 0;
  pointer-events: none;
  transform: translateY(8px);
  transition: opacity .18s, transform .18s;
}

.toast.is-visible {
  opacity: 1;
  transform: translateY(0);
}

@media (min-width: 680px) {
  .main-content {
    padding: 19px 28px 32px;
  }

  .page-heading {
    padding-top: 25px;
  }

  .editor-body {
    grid-template-columns: repeat(3, minmax(0, 1fr));
  }

  .field.wide {
    grid-column: span 2;
  }

  .connection-group {
    grid-column: 1 / -1;
  }

  .result-summary {
    grid-template-columns: 1.8fr 1fr;
  }

  .sheet {
    margin-bottom: 20px;
    border-bottom: 1px solid var(--line);
    border-radius: 24px;
  }
}

@media (max-width: 390px) {
  .main-content {
    padding-inline: 12px;
  }

  .card {
    padding: 14px;
  }

  .page-heading p {
    font-size: 12px;
  }

  .status-pill {
    display: none;
  }

  .mini-legend {
    display: none;
  }

  .result-main strong {
    font-size: 17px;
  }

  .sheet-actions {
    grid-template-columns: 1fr 1fr;
  }

  .sheet-actions .primary-action {
    grid-column: 1 / -1;
  }
}

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

@media print {
  body {
    background: white;
  }

  .topbar,
  .tabbar,
  .page:not(#page-layout),
  #page-layout > :not(#layoutResult),
  .view-switcher,
  .drawing-toolbar,
  .export-row,
  .checks-card,
  #page-layout .card:last-child {
    display: none !important;
  }

  .app-shell,
  .main-content,
  .page {
    width: 100%;
    max-width: none;
    padding: 0;
    margin: 0;
  }

  .drawing-card {
    border: 0;
  }

  .drawing-stage {
    overflow: visible;
    padding: 0;
    background: white;
  }

  .drawing-svg-wrap {
    min-width: 0 !important;
  }

  .result-summary {
    display: none;
  }
}
