:root {
  --ground: #eaf0ef;
  --surface: #ffffff;
  --raised: #f3f7f6;
  --active: #e7eeed;
  --border: #dfe7e5;
  --rule: #edf2f1;
  --control: #c5d1cf;
  --text: #162220;
  --muted: #566460;
  --faint: #586561;
  --accent: #17697a;
  --accent-strong: #0f5260;
  --accent-soft: #e3eff0;
  --primary: #182321;
  --primary-hover: #263431;
  --danger: #9b3a2f;
  --radius-sheet: 16px;
  --radius-card: 8px;
  --radius-control: 6px;
  --font-ui: "DengXian", "Microsoft YaHei UI", "Microsoft YaHei", system-ui, sans-serif;
  --font-label: "FangSong", "STFangsong", "Songti SC", serif;
  --font-mono: "Consolas", "Cascadia Mono", "SFMono-Regular", monospace;
  --font-num: "Bahnschrift", "DIN Alternate", "Consolas", sans-serif;
  --sidebar-width: 228px;
  --card-gap: 16px;
  --sheet-pad-x: 24px;
}

* {
  box-sizing: border-box;
}

html {
  height: 100%;
}

body {
  margin: 0;
  min-height: 100%;
  background: var(--ground);
  color: var(--text);
  font-family: var(--font-ui);
  font-size: 14px;
  line-height: 1.5;
  font-variant-numeric: tabular-nums;
  font-feature-settings: "tnum" 1;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}

button,
input {
  font: inherit;
}

button {
  color: inherit;
}

button,
a {
  -webkit-tap-highlight-color: transparent;
}

::selection {
  background: var(--accent-soft);
  color: var(--text);
}

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

svg {
  display: block;
}

.app {
  display: grid;
  grid-template-columns: var(--sidebar-width) minmax(0, 1fr);
  grid-template-rows: 48px minmax(0, 1fr);
  min-height: 100dvh;
  background: var(--ground);
}

/* ---------------------------------------------------------------- topbar */
.topbar {
  grid-column: 1 / -1;
  display: flex;
  align-items: center;
  height: 48px;
  padding: 0 10px 0 18px;
  gap: 0;
  min-width: 0;
  position: relative;
  z-index: 20;
}

.brand {
  display: flex;
  align-items: center;
  gap: 9px;
  width: 210px;
  flex: none;
  color: var(--text);
  text-decoration: none;
  min-width: 0;
}

.brand-mark {
  width: 26px;
  height: 26px;
  flex: none;
  color: var(--accent);
}

.brand-text {
  display: flex;
  flex-direction: column;
  min-width: 0;
  line-height: 1.18;
}

.brand-name {
  font-size: 15px;
  font-weight: 600;
  letter-spacing: .02em;
  white-space: nowrap;
}

.brand-sub {
  font-size: 13px;
  color: var(--muted);
  white-space: nowrap;
}

.crumb {
  display: flex;
  align-items: center;
  gap: 11px;
  margin-left: 12px;
  min-width: 0;
  font-size: 13px;
  color: var(--muted);
  white-space: nowrap;
}

.crumb strong {
  color: var(--text);
  font-weight: 500;
  overflow: hidden;
  text-overflow: ellipsis;
}

.crumb-rule {
  width: 18px;
  height: 1px;
  background: var(--control);
  display: block;
  flex: none;
}

.top-actions {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-left: auto;
  flex: none;
}

.local-state {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  color: var(--muted);
  font-size: 13px;
  white-space: nowrap;
}

.local-dot {
  width: 5px;
  height: 5px;
  border-radius: 50%;
  background: var(--accent);
  flex: none;
}

.menu-btn {
  display: none;
}

.drawer-close {
  display: none;
}

.sidebar .drawer-close {
  display: none;
}

.nav-scrim {
  display: none;
}

/* ---------------------------------------------------------------- buttons */
.icon-btn {
  width: 32px;
  height: 32px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border: 1px solid transparent;
  border-radius: var(--radius-control);
  background: transparent;
  color: var(--muted);
  cursor: pointer;
  flex: none;
  transition: background-color .14s ease, border-color .14s ease, color .14s ease;
}

.icon-btn svg {
  width: 18px;
  height: 18px;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.5;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.icon-btn:hover {
  background: rgba(255, 255, 255, .72);
  border-color: var(--border);
  color: var(--text);
}

.primary-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 7px;
  height: 32px;
  padding: 0 12px;
  border: 0;
  border-radius: var(--radius-control);
  background: var(--primary);
  color: #fff;
  font-size: 13px;
  font-weight: 500;
  letter-spacing: .01em;
  white-space: nowrap;
  cursor: pointer;
  transition: background-color .14s ease, opacity .14s ease;
}

.primary-btn svg {
  width: 14px;
  height: 14px;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.5;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.primary-btn:hover {
  background: var(--primary-hover);
}

.primary-btn:active {
  transform: translateY(1px);
}

.primary-btn:disabled {
  opacity: .42;
  cursor: not-allowed;
  transform: none;
}

.ghost-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  height: 30px;
  padding: 0 10px;
  border: 1px solid var(--border);
  border-radius: var(--radius-control);
  background: transparent;
  color: var(--text);
  font-size: 13px;
  white-space: nowrap;
  cursor: pointer;
  transition: background-color .14s ease, border-color .14s ease;
}

.ghost-btn svg {
  width: 14px;
  height: 14px;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.5;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.ghost-btn:hover {
  background: var(--raised);
  border-color: var(--control);
}

.ghost-btn:active {
  background: var(--active);
}

.ghost-btn.compact {
  height: 28px;
  padding: 0 9px;
  font-size: 13px;
}

.text-btn {
  border: 0;
  background: transparent;
  color: var(--muted);
  font-size: 13px;
  padding: 5px 4px;
  cursor: pointer;
  white-space: nowrap;
  border-radius: 4px;
}

.text-btn:hover {
  color: var(--text);
  background: rgba(255, 255, 255, .6);
}

/* ---------------------------------------------------------------- sidebar */
.sidebar {
  grid-column: 1;
  grid-row: 2;
  min-height: 0;
  display: flex;
  flex-direction: column;
  padding: 6px 14px 14px 18px;
  overflow: auto;
  scrollbar-width: thin;
  scrollbar-color: var(--control) transparent;
}

.side-scope {
  padding: 12px 8px 16px 4px;
  border-bottom: 1px solid rgba(197, 209, 207, .5);
}

.side-context {
  margin: 0 0 7px;
  color: var(--muted);
  font-size: 13px;
}

.scope-row {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 8px;
}

.scope-row strong {
  font-size: 14px;
  font-weight: 600;
}

.scope-row span {
  font-family: var(--font-mono);
  font-size: 11px;
  color: var(--muted);
}

.scope-note {
  margin: 6px 0 0;
  font-size: 13px;
  color: var(--muted);
}

.side-block {
  padding: 15px 4px 2px;
}

.side-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  min-height: 24px;
  margin-bottom: 5px;
  padding: 0 6px;
}

.side-head h2 {
  margin: 0;
  font-size: 12px;
  font-weight: 600;
  color: var(--muted);
  letter-spacing: .02em;
}

.side-meta {
  font-family: var(--font-mono);
  font-size: 13px;
  color: var(--faint);
  white-space: nowrap;
}

.preset-list {
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.preset {
  width: 100%;
  min-height: 51px;
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 6px 7px;
  border: 0;
  border-radius: var(--radius-control);
  background: transparent;
  text-align: left;
  cursor: pointer;
  transition: background-color .14s ease;
}

.preset:hover {
  background: rgba(255, 255, 255, .62);
}

.preset[aria-pressed="true"] {
  background: var(--active);
}

.preset-glyph {
  width: 34px;
  height: 34px;
  flex: none;
  color: var(--muted);
}

.preset[aria-pressed="true"] .preset-glyph {
  color: var(--accent);
}

.preset-copy {
  min-width: 0;
  display: flex;
  flex-direction: column;
  gap: 1px;
}

.preset-name {
  font-size: 13px;
  font-weight: 500;
  color: var(--text);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.preset-meta {
  font-family: var(--font-mono);
  font-size: 13px;
  color: var(--muted);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.preset-no {
  margin-left: auto;
  padding-left: 4px;
  font-family: var(--font-mono);
  font-size: 13px;
  color: var(--faint);
  flex: none;
}

.preset.custom .preset-no {
  color: var(--accent);
}

.new-model {
  width: 100%;
  min-height: 34px;
  margin-top: 5px;
  display: flex;
  align-items: center;
  gap: 7px;
  padding: 0 9px;
  border: 1px dashed var(--control);
  border-radius: var(--radius-control);
  color: var(--muted);
  background: transparent;
  font-size: 13px;
  cursor: pointer;
  transition: border-color .14s ease, color .14s ease, background-color .14s ease;
}

.new-model svg {
  width: 14px;
  height: 14px;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.5;
  stroke-linecap: round;
}

.new-model:hover {
  border-color: var(--accent);
  color: var(--accent-strong);
  background: rgba(227, 239, 240, .48);
}

.new-model.new-line {
  border-style: solid;
  border-color: var(--accent);
  color: var(--accent-strong);
  background: var(--accent-soft);
}

.new-model.new-line:hover {
  background: #d7e9ea;
}

.block-editor-link {
  width: 100%;
  margin-top: 4px;
  padding: 5px 9px;
  border: 0;
  background: transparent;
  color: var(--muted);
  font-size: 12px;
  text-align: left;
  border-radius: var(--radius-control);
  cursor: pointer;
}

.block-editor-link:hover {
  color: var(--text);
  background: rgba(255, 255, 255, .58);
}

.switch-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  min-height: 34px;
  padding: 0 7px;
  font-size: 13px;
  color: var(--text);
}

.switch {
  position: relative;
  width: 29px;
  height: 17px;
  flex: none;
  padding: 0;
  border: 0;
  border-radius: 999px;
  background: var(--control);
  cursor: pointer;
  transition: background-color .14s ease;
}

.switch[aria-checked="true"] {
  background: var(--accent);
}

.switch-knob {
  position: absolute;
  left: 2px;
  top: 2px;
  width: 13px;
  height: 13px;
  border-radius: 50%;
  background: #fff;
  transition: transform .16s ease;
}

.switch[aria-checked="true"] .switch-knob {
  transform: translateX(12px);
}

.side-foot {
  margin-top: auto;
  padding: 18px 4px 0;
}

.side-link {
  width: 100%;
  display: flex;
  align-items: center;
  gap: 7px;
  padding: 7px 7px;
  border: 0;
  background: transparent;
  color: var(--muted);
  border-radius: var(--radius-control);
  font-size: 13px;
  text-align: left;
  cursor: pointer;
}

.side-link svg {
  width: 14px;
  height: 14px;
  flex: none;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.4;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.side-link:hover {
  background: rgba(255, 255, 255, .55);
  color: var(--text);
}

.local-note {
  margin: 10px 7px 0;
  font-size: 13px;
  line-height: 1.55;
  color: var(--faint);
}

/* ---------------------------------------------------------------- sheet */
.sheet {
  grid-column: 2;
  grid-row: 2;
  min-width: 0;
  min-height: 0;
  margin: 0 8px 8px 0;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-sheet);
  overflow: auto;
  scrollbar-width: thin;
  scrollbar-color: var(--control) transparent;
}

.sheet-inner {
  min-height: 100%;
  display: flex;
  flex-direction: column;
  padding: 20px var(--sheet-pad-x) 13px;
}

.title-row {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 24px;
  flex: none;
  padding: 0 1px 14px;
}

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

.title-copy h1 {
  margin: 0;
  font-size: 24px;
  line-height: 1.18;
  font-weight: 600;
  letter-spacing: -.01em;
  color: var(--text);
}

.title-copy p {
  margin: 5px 0 0;
  color: var(--muted);
  font-size: 13px;
  line-height: 1.45;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.title-actions {
  display: flex;
  align-items: center;
  gap: 18px;
  flex: none;
  min-height: 38px;
}

.title-fact {
  display: flex;
  flex-direction: column;
  justify-content: center;
  gap: 1px;
  min-width: 54px;
}

.title-fact + .title-fact {
  padding-left: 18px;
  border-left: 1px solid var(--rule);
}

.title-fact span {
  font-size: 13px;
  color: var(--muted);
  line-height: 1.25;
  white-space: nowrap;
}

.title-fact strong {
  font-family: var(--font-mono);
  font-size: 14px;
  font-weight: 500;
  line-height: 1.3;
  color: var(--text);
  white-space: nowrap;
}

.reset-btn {
  margin-left: 2px;
  color: var(--muted);
}

/* ---------------------------------------------------------------- workbench */
.workbench {
  flex: 1;
  min-height: 0;
  display: grid;
  grid-template-columns: minmax(350px, .94fr) minmax(410px, 1.12fr) minmax(280px, .76fr);
  gap: var(--card-gap);
}

.panel {
  min-width: 0;
  min-height: 0;
  display: flex;
  flex-direction: column;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-card);
  overflow: hidden;
  position: relative;
}

.panel-head {
  flex: none;
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 10px;
  padding: 13px 15px 0;
  min-height: 55px;
}

.panel-title {
  min-width: 0;
}

.panel-title h2 {
  margin: 0;
  font-size: 15px;
  line-height: 1.25;
  font-weight: 600;
  color: var(--text);
  letter-spacing: .01em;
}

.panel-title p {
  margin: 2px 0 0;
  color: var(--muted);
  font-size: 13px;
  line-height: 1.4;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.ghost-btn.compact svg {
  width: 13px;
  height: 13px;
}

/* three views */
.left-column {
  min-width: 0;
  min-height: 0;
  display: flex;
  flex-direction: column;
  gap: var(--card-gap);
}

.views-panel {
  flex: 1 1 auto;
  background: var(--surface);
}

.relation-panel {
  flex: 0 0 174px;
  padding-bottom: 11px;
}

.relation-head {
  min-height: 46px;
  padding: 12px 15px 0;
}

.relation-state {
  flex: none;
  display: inline-flex;
  align-items: center;
  gap: 4px;
  color: var(--accent-strong);
  font-size: 13px;
  white-space: nowrap;
}

.relation-state svg {
  width: 13px;
  height: 13px;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.6;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.relation-list {
  margin: 8px 15px 0;
}

.relation-row {
  display: grid;
  grid-template-columns: 43px minmax(0, 1fr) auto;
  align-items: baseline;
  gap: 8px;
  min-height: 29px;
  padding: 5px 0;
  border-top: 1px solid var(--rule);
}

.relation-row:first-child {
  border-top: 0;
}

.relation-key {
  font-size: 13px;
  font-weight: 600;
  color: var(--text);
  white-space: nowrap;
}

.relation-desc {
  font-size: 13px;
  color: var(--muted);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.relation-row strong {
  font-family: var(--font-mono);
  font-size: 13px;
  font-weight: 500;
  color: var(--text);
  white-space: nowrap;
}

.relation-note {
  margin: 2px 15px 0;
  color: var(--muted);
  font-size: 13px;
  line-height: 1.4;
}

.three-mount {
  flex: 1;
  min-height: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 4px 12px 0;
  overflow: hidden;
}

.three-mount svg {
  width: 100%;
  height: 100%;
  overflow: visible;
}

.legend-row {
  flex: none;
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 13px;
  padding: 0 16px;
  min-height: 26px;
  color: var(--muted);
  font-size: 13px;
}

.legend-row > span {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  white-space: nowrap;
}

.line-sample {
  width: 23px;
  height: 1px;
  display: inline-block;
  background: var(--text);
}

.line-sample.dashed {
  height: 0;
  background: none;
  border-top: 1px dashed var(--faint);
}

.line-sample.guide {
  height: 0;
  background: none;
  border-top: 1px dotted #b2c1be;
}

.readout-strip {
  flex: none;
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  margin: 7px 15px 13px;
  padding: 9px 0;
  background: var(--accent);
  border-radius: var(--radius-control);
}

.readout-strip > div {
  min-width: 0;
  padding: 0 11px;
}

.readout-strip > div + div {
  border-left: 1px solid rgba(255, 255, 255, .24);
}

.readout-strip span {
  display: block;
  font-size: 13px;
  line-height: 1.3;
  color: rgba(255, 255, 255, .82);
  white-space: nowrap;
}

.readout-strip strong {
  display: block;
  margin-top: 2px;
  font-family: var(--font-mono);
  font-size: 14px;
  font-weight: 500;
  line-height: 1.3;
  color: #ffffff;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

#readCells {
  color: #ffffff;
}

/* stage */
.stage-head {
  align-items: center;
  padding-bottom: 0;
}

.camera-group {
  display: flex;
  align-items: center;
  gap: 1px;
  padding: 2px;
  background: var(--raised);
  border-radius: var(--radius-control);
  flex: none;
}

.camera-group button {
  height: 24px;
  padding: 0 7px;
  border: 0;
  border-radius: 4px;
  background: transparent;
  color: var(--muted);
  font-size: 13px;
  cursor: pointer;
  transition: background-color .14s ease, color .14s ease;
}

.camera-group button:hover {
  color: var(--text);
}

.camera-group button[aria-pressed="true"] {
  background: var(--surface);
  color: var(--text);
  font-weight: 500;
  outline: 1px solid var(--border);
  outline-offset: -1px;
}

.stage-wrap {
  flex: 1;
  min-height: 0;
  margin: 10px 12px 0;
  border-radius: var(--radius-control);
  position: relative;
  background: var(--raised);
  overflow: hidden;
}

#stageCanvas {
  position: absolute;
  inset: 0;
  display: block;
  width: 100%;
  height: 100%;
  cursor: grab;
  touch-action: none;
}

#stageCanvas:active {
  cursor: grabbing;
}

#stageCanvas:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: -3px;
}

.stage-hint {
  position: absolute;
  left: 68px;
  right: 118px;
  bottom: 10px;
  color: var(--muted);
  font-size: 13px;
  line-height: 1.4;
  background: rgba(243, 247, 246, .9);
  padding: 2px 4px;
  border-radius: 3px;
  pointer-events: none;
  text-align: center;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.hint-narrow {
  display: none;
}

.stage-dims {
  position: absolute;
  right: 13px;
  bottom: 11px;
  color: var(--muted);
  font-family: var(--font-mono);
  font-size: 13px;
  line-height: 1.4;
  background: rgba(243, 247, 246, .9);
  padding: 2px 4px;
  border-radius: 3px;
  pointer-events: none;
  white-space: nowrap;
}

.stage-badge {
  position: absolute;
  top: 11px;
  left: 12px;
  padding: 2px 6px;
  border: 1px solid rgba(197, 209, 207, .9);
  border-radius: 4px;
  color: var(--accent-strong);
  background: rgba(255, 255, 255, .78);
  font-family: var(--font-mono);
  font-size: 13px;
  line-height: 1.4;
  pointer-events: none;
}

.stage-foot {
  flex: none;
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  padding: 10px 6px 12px;
  margin: 0 8px;
}

.stage-foot > div {
  min-width: 0;
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 6px;
  padding: 0 8px;
}

.stage-foot > div + div {
  border-left: 1px solid var(--rule);
}

.stage-foot span {
  font-size: 13px;
  color: var(--muted);
  white-space: nowrap;
}

.stage-foot strong {
  font-family: var(--font-mono);
  font-size: 13px;
  font-weight: 400;
  color: var(--text);
  white-space: nowrap;
}

/* right output column */
.right-column {
  min-height: 0;
  display: flex;
  flex-direction: column;
  gap: var(--card-gap);
}

.mini-panel {
  flex: 1 1 0;
}

.mini-head {
  align-items: flex-start;
  min-height: 49px;
  padding-top: 12px;
}

.rule-badge {
  flex: none;
  display: inline-flex;
  align-items: center;
  height: 20px;
  padding: 0 6px;
  border: 1px solid var(--border);
  border-radius: 4px;
  color: var(--muted);
  font-family: var(--font-mono);
  font-size: 13px;
  white-space: nowrap;
}

.rule-badge.mono {
  font-size: 13px;
}

.oblique-mount,
.axonometric-mount,
.front-mount {
  flex: 1;
  min-height: 0;
  padding: 0 10px;
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: hidden;
}

.oblique-mount svg,
.axonometric-mount svg,
.front-mount svg {
  width: 100%;
  height: 100%;
}

.mini-foot {
  flex: none;
  margin: 0;
  padding: 5px 15px 11px;
  color: var(--muted);
  font-size: 13px;
  line-height: 1.45;
}

/* footer */
.sheet-foot {
  flex: none;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  min-height: 24px;
  padding: 8px 1px 0;
}

.sheet-foot p {
  margin: 0;
  color: var(--muted);
  font-size: 13px;
  line-height: 1.4;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.foot-link {
  flex: none;
  border: 0;
  background: transparent;
  padding: 2px 0;
  color: var(--muted);
  font-size: 13px;
  cursor: pointer;
  text-decoration: underline;
  text-underline-offset: 3px;
  text-decoration-color: var(--control);
}

.foot-link:hover {
  color: var(--text);
  text-decoration-color: var(--text);
}

/* ---------------------------------------------------------------- drawing svg */
.dwg {
  color: var(--text);
}

.dwg-label {
  font-family: var(--font-label);
  font-size: 13px;
  font-weight: 600;
  fill: var(--text);
  letter-spacing: .04em;
}

.dwg-fill {
  fill: var(--surface);
}

.dwg-visible {
  fill: none;
  stroke: #263533;
  stroke-width: 1.15;
  stroke-linejoin: miter;
  stroke-linecap: butt;
}

.dwg-hidden {
  fill: none;
  stroke: #7a8985;
  stroke-width: .9;
  stroke-dasharray: 4 3.5;
  stroke-linecap: butt;
}

.dwg-guide {
  fill: none;
  stroke: #b2c1be;
  stroke-width: .8;
  stroke-dasharray: 2 5;
}

.dwg-note {
  font-family: var(--font-mono);
  font-size: 13px;
  fill: var(--muted);
  letter-spacing: 0;
}

.dwg-dim {
  stroke: #62716d;
  fill: none;
  stroke-width: .9;
}

.dwg-dim-text {
  font-family: var(--font-mono);
  font-size: 13px;
  fill: #465450;
}

.dwg-axis {
  stroke: #8b9b97;
  fill: none;
  stroke-width: .9;
}

.dwg-axis-label {
  font-family: var(--font-mono);
  font-size: 13px;
  fill: var(--muted);
}

/* ---------------------------------------------------------------- dialogs */
dialog.modal {
  width: min(900px, calc(100vw - 32px));
  max-height: calc(100dvh - 32px);
  padding: 0;
  border: 1px solid var(--border);
  border-radius: var(--radius-sheet);
  background: var(--surface);
  color: var(--text);
  overflow: hidden;
  box-shadow: 0 22px 70px rgba(19, 33, 30, .22);
}

dialog.modal[open] {
  animation: modal-in .16s ease-out both;
}

dialog.modal::backdrop {
  background: rgba(20, 32, 30, .34);
}

@keyframes modal-in {
  from { opacity: 0; transform: translateY(8px) scale(.995); }
  to { opacity: 1; transform: translateY(0) scale(1); }
}

.modal-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 20px;
  padding: 21px 24px 14px;
}

.modal-head h2 {
  margin: 0;
  font-size: 20px;
  line-height: 1.25;
  font-weight: 600;
  letter-spacing: -.01em;
}

.modal-head p {
  margin: 4px 0 0;
  color: var(--muted);
  font-size: 12px;
  line-height: 1.5;
}

.close-btn {
  margin-top: -2px;
}

.modal-foot {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 20px;
  padding: 13px 24px 16px;
  background: var(--raised);
}

.modal-foot p {
  margin: 0;
  color: var(--muted);
  font-size: 11px;
  line-height: 1.5;
}

.reference-modal {
  width: min(1060px, calc(100vw - 32px));
}

dialog.reference-modal {
  width: min(1060px, calc(100vw - 32px));
}

.reference-body {
  padding: 0 24px 18px;
  max-height: calc(100dvh - 190px);
  overflow: auto;
}

.reference-body img {
  display: block;
  width: 100%;
  height: auto;
  border: 1px solid var(--border);
  border-radius: var(--radius-card);
  background: var(--raised);
}

.method-modal {
  width: min(780px, calc(100vw - 32px));
}

dialog.method-modal {
  width: min(780px, calc(100vw - 32px));
}

.method-body {
  max-height: calc(100dvh - 200px);
  overflow: auto;
  padding: 0 24px 8px;
}

.method-body section {
  padding: 14px 0;
  border-top: 1px solid var(--rule);
  max-width: 68ch;
}

.method-body section:first-child {
  border-top: 0;
  padding-top: 4px;
}

.method-body h3 {
  margin: 0 0 5px;
  font-size: 13px;
  font-weight: 600;
}

.method-body p {
  margin: 0;
  color: var(--text);
  font-size: 12px;
  line-height: 1.7;
}

.method-body code {
  font-family: var(--font-mono);
  font-size: 11px;
  padding: 1px 4px;
  background: var(--raised);
  border-radius: 3px;
}

.method-callout {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 20px;
  margin: 12px 0 16px;
  padding: 14px 16px;
  background: var(--raised);
  border-radius: var(--radius-card);
}

.method-callout strong {
  display: block;
  font-size: 12px;
  font-weight: 600;
}

.method-callout p {
  margin: 3px 0 0;
  color: var(--muted);
  font-size: 11px;
  line-height: 1.55;
  max-width: 50ch;
}

/* editor */
dialog.edit-modal,
dialog.line-modal {
  width: min(1180px, calc(100vw - 32px));
  height: min(748px, calc(100dvh - 24px));
  max-height: calc(100dvh - 24px);
}

dialog.edit-modal[open],
dialog.line-modal[open] {
  display: flex;
  flex-direction: column;
}

dialog.edit-modal .modal-head,
dialog.line-modal .modal-head {
  flex: none;
}

.edit-body {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 300px;
  gap: 18px;
  padding: 0 24px 22px;
  min-height: 0;
  flex: 1;
  overflow: hidden;
}

.edit-drawing {
  min-width: 0;
  min-height: 0;
  display: flex;
  flex-direction: column;
  padding: 8px 10px 0;
  background: var(--raised);
  border-radius: var(--radius-card);
}

.editor-views {
  flex: 1;
  min-height: 0;
  overflow: auto;
  display: flex;
  align-items: flex-start;
  justify-content: center;
}

.editor-views svg {
  width: 100%;
  height: auto;
  flex: none;
}

.edit-tools {
  flex: none;
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
  padding: 8px 2px 10px;
}

.edit-footer {
  flex: none;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  min-height: 58px;
  padding: 10px 24px 14px;
  background: var(--raised);
}

.edit-footer #editToolHint {
  color: var(--muted);
  font-size: 13px;
  line-height: 1.4;
  white-space: nowrap;
}

.edit-inspector {
  min-height: 0;
  display: flex;
  flex-direction: column;
}

.edit-preview-head {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 10px;
}

.edit-preview-head h3 {
  margin: 0;
  font-size: 13px;
  font-weight: 600;
}

.edit-preview-head span {
  font-family: var(--font-mono);
  font-size: 11px;
  color: var(--muted);
}

.edit-preview-wrap {
  position: relative;
  flex: 1;
  min-height: 190px;
  margin-top: 8px;
  background: var(--raised);
  border-radius: var(--radius-card);
  overflow: hidden;
}

#editorCanvas,
#lineCanvas {
  position: absolute;
  inset: 0;
  display: block;
  width: 100%;
  height: 100%;
}

#lineCanvas,
#editorCanvas {
  touch-action: none;
  cursor: grab;
  outline: none;
  user-select: none;
}

#lineCanvas:active,
#editorCanvas:active {
  cursor: grabbing;
}

#lineCanvas:focus-visible,
#editorCanvas:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: -2px;
}

.edit-preview-hint {
  position: absolute;
  left: 0;
  right: 0;
  bottom: 7px;
  z-index: 1;
  pointer-events: none;
  text-align: center;
  font-family: var(--font-mono);
  font-size: 10px;
  letter-spacing: .01em;
  color: var(--faint);
  text-shadow: 0 1px 0 rgba(255, 255, 255, .86);
}

.edit-readout {
  margin-top: 12px;
  padding: 7px 0;
  background: var(--raised);
  border-radius: var(--radius-control);
}

.edit-readout > div {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 12px;
  padding: 5px 11px;
}

.edit-readout span {
  font-size: 11px;
  color: var(--muted);
}

.edit-readout strong {
  font-family: var(--font-mono);
  font-size: 11px;
  font-weight: 500;
  color: var(--text);
}

.edit-note {
  min-height: 32px;
  margin: 10px 0 0;
  color: var(--muted);
  font-size: 11px;
  line-height: 1.55;
}

.edit-actions {
  display: flex;
  justify-content: flex-end;
  gap: 8px;
  flex: none;
  padding: 0;
}

/* editor mask drawing */
.mask-title {
  font-family: var(--font-label);
  font-size: 13px;
  font-weight: 600;
  fill: var(--text);
}

.mask-sub {
  font-family: var(--font-mono);
  font-size: 11px;
  fill: var(--muted);
}

.mask-border {
  fill: none;
  stroke: var(--control);
  stroke-width: 1;
}

.mask-cell {
  fill: transparent;
  stroke: #e1e9e7;
  stroke-width: .6;
  cursor: crosshair;
}

.mask-cell:hover {
  fill: rgba(23, 105, 122, .09);
}

.mask-cell.on {
  fill: #cfe3e3;
  stroke: #a9c7c6;
}

.mask-cell.on:hover {
  fill: #ffd9cf;
  stroke: #d6a092;
}

/* line editor */
.line-drawing {
  padding-bottom: 0;
}

.poly-toolbar {
  flex: none;
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 8px;
  padding: 4px 2px 9px;
}

.poly-tool-group {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 6px;
}

.poly-toolbar-hint {
  color: var(--muted);
  font-size: 11px;
}

.poly-feature-bar {
  flex: none;
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 7px;
  padding: 0 2px 9px;
  color: var(--muted);
  font-size: 12px;
}

.line-inner-label {
  font-weight: 600;
  color: var(--text);
}

.line-select {
  height: 28px;
  padding: 0 8px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: #fff;
  color: var(--text);
  font-family: var(--font-ui);
  font-size: 12px;
}

.line-level {
  display: inline-flex;
  align-items: center;
  gap: 5px;
}

.line-level input {
  width: 46px;
  height: 28px;
  padding: 0 6px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: #fff;
  color: var(--text);
  font-family: var(--font-mono);
  font-size: 12px;
}

.poly-feature-hint {
  font-size: 11px;
  color: var(--faint);
}

.line-poly.inner {
  fill: #f6ead8;
  fill-opacity: .62;
  stroke: #8e6636;
  stroke-dasharray: 5 3;
  stroke-width: 1.7;
}

.line-handle.inner {
  stroke: #8e6636;
}

.line-handle.inner.selected {
  fill: #8e6636;
  stroke: #fff;
}

.line-views {
  flex: 1;
  min-height: 0;
  overflow: auto;
  display: flex;
  align-items: flex-start;
  justify-content: center;
  padding: 10px 12px;
  background: #fbfcfa;
  border: 1px solid var(--line);
  border-radius: 10px;
}

.line-views svg {
  width: auto;
  max-width: 100%;
  height: auto;
  flex: none;
}

.line-frame {
  fill: transparent;
  stroke: none;
}

.line-grid {
  stroke: #e3ebe9;
  stroke-width: .55;
  fill: none;
  pointer-events: none;
}

.line-grid-major {
  stroke: #d1dfdc;
  stroke-width: .8;
  fill: none;
  pointer-events: none;
}

.line-axis-label {
  font-family: var(--font-mono);
  font-size: 11px;
  fill: var(--muted);
  pointer-events: none;
}

.line-title {
  font-family: var(--font-label);
  font-size: 14px;
  font-weight: 600;
  fill: var(--text);
}

.line-meta {
  font-family: var(--font-mono);
  font-size: 11px;
  fill: var(--muted);
}

.line-hit {
  fill: transparent;
  cursor: crosshair;
}

.line-poly {
  fill: var(--accent-soft);
  fill-opacity: .62;
  stroke: var(--accent);
  stroke-width: 1.7;
  stroke-linejoin: round;
  stroke-linecap: round;
  cursor: crosshair;
  pointer-events: none;
}

.line-poly.invalid {
  fill: #f6e5e1;
  fill-opacity: .55;
  stroke: var(--danger);
}

.line-handle {
  fill: #fff;
  stroke: var(--accent);
  stroke-width: 1.7;
  pointer-events: none;
}

.line-handle.selected {
  fill: var(--accent);
  stroke: #fff;
}

.line-handle-hit {
  fill: transparent;
  cursor: grab;
}

.line-handle-hit:active {
  cursor: grabbing;
}

.line-origin {
  fill: #fff;
  stroke: var(--accent);
  stroke-width: 1.5;
  pointer-events: none;
}

.line-origin.inner {
  stroke: #8e6636;
}

.line-stroke-guide {
  fill: none;
  stroke: var(--accent);
  stroke-width: 1.6;
  stroke-dasharray: 5 4;
  stroke-linecap: round;
  pointer-events: none;
}

.line-stroke-guide.inner {
  stroke: #8e6636;
}

.line-seg {
  stroke: var(--accent);
  stroke-width: 1.7;
  stroke-linecap: round;
  pointer-events: none;
}

.line-seg.inner {
  stroke: #8e6636;
}

.line-node {
  fill: var(--accent);
  pointer-events: none;
}

.line-node.inner {
  fill: #8e6636;
}

.line-fill {
  fill: var(--accent-soft);
  fill-opacity: .38;
  stroke: none;
  pointer-events: none;
}

.line-fill.inner {
  fill: #f6ead8;
  fill-opacity: .5;
}

.line-empty {
  font-family: var(--font-ui);
  font-size: 12px;
  fill: var(--faint);
  text-anchor: middle;
  pointer-events: none;
}

.live-badge {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  color: var(--accent-strong);
  font-size: 11px;
  white-space: nowrap;
}

.live-badge i {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: var(--accent);
  flex: none;
}

.line-body .edit-preview-head {
  align-items: center;
}

.line-body .edit-readout > div {
  padding: 4px 11px;
}

.line-body .edit-readout > div[hidden] {
  display: none;
}

.line-body .edit-note {
  min-height: 28px;
}

/* toast */
.toast {
  position: fixed;
  z-index: 90;
  left: 50%;
  bottom: 24px;
  transform: translate(-50%, 12px);
  padding: 9px 13px;
  border-radius: var(--radius-control);
  background: var(--primary);
  color: #fff;
  font-size: 11px;
  line-height: 1.4;
  opacity: 0;
  pointer-events: none;
  transition: opacity .16s ease, transform .16s ease;
  max-width: calc(100vw - 32px);
  text-align: center;
}

.toast.show {
  opacity: 1;
  transform: translate(-50%, 0);
}

/* ---------------------------------------------------------------- tablet */
@media (max-width: 1240px) {
  :root {
    --sidebar-width: 210px;
    --sheet-pad-x: 20px;
  }

  .brand {
    width: 192px;
  }

  .local-state {
    display: none;
  }

  .workbench {
    grid-template-columns: minmax(330px, .95fr) minmax(390px, 1.1fr) minmax(265px, .78fr);
  }

  .stage-foot span {
    font-size: 13px;
  }
}

@media (max-width: 1360px) {
  .app {
    display: block;
    min-height: 100dvh;
  }

  .topbar {
    position: relative;
    top: auto;
    height: 48px;
    padding: 0 12px;
    background: var(--ground);
    z-index: 20;
  }

  .menu-btn {
    display: inline-flex;
    margin-right: 2px;
  }

  .sidebar .drawer-close {
    display: inline-flex;
    align-self: flex-end;
    margin-bottom: 6px;
  }

  .brand {
    width: auto;
    margin-right: 8px;
  }

  .brand-sub {
    display: none;
  }

  .crumb {
    margin-left: 8px;
    font-size: 13px;
  }

  .crumb > span:first-child,
  .crumb-rule {
    display: none;
  }

  .sheet {
    min-height: calc(100dvh - 56px);
    margin: 0 8px 8px;
    overflow: visible;
  }

  .sheet-inner {
    min-height: 0;
  }

  .workbench {
    grid-template-columns: minmax(0, 1.04fr) minmax(0, .96fr);
    grid-template-rows: 580px auto;
    flex: none;
  }

  .right-column {
    grid-column: 1 / -1;
    flex-direction: row;
    min-height: 330px;
  }

  .mini-panel {
    flex: 1;
  }

  .sidebar {
    position: fixed;
    top: 0;
    left: 0;
    bottom: 0;
    z-index: 50;
    width: 286px;
    padding: 20px 14px 18px;
    background: var(--ground);
    border-right: 1px solid var(--border);
    box-shadow: 12px 0 32px rgba(20, 32, 30, .12);
    transform: translateX(-102%);
    visibility: hidden;
    transition: transform .18s ease, visibility .18s ease;
    overflow: auto;
  }

  .nav-open .sidebar {
    transform: translateX(0);
    visibility: visible;
  }

  .nav-scrim {
    display: block;
    position: fixed;
    inset: 0;
    z-index: 45;
    border: 0;
    padding: 0;
    margin: 0;
    background: rgba(18, 31, 28, .32);
    visibility: hidden;
    opacity: 0;
    pointer-events: none;
    transition: opacity .18s ease, visibility .18s ease;
  }

  .nav-open .nav-scrim {
    visibility: visible;
    opacity: 1;
    pointer-events: auto;
  }

  .side-scope {
    padding-top: 0;
  }

  .top-actions {
    gap: 8px;
  }

  .reference-top {
    display: none;
  }

  .side-foot {
    margin-top: 20px;
  }
}

/* ---------------------------------------------------------------- phone */
@media (max-width: 900px) {
  .workbench {
    grid-template-columns: minmax(0, 1fr);
    grid-template-rows: none;
  }

  .stage-panel {
    order: -1;
    min-height: 455px;
  }

  .views-panel {
    min-height: 455px;
  }

  .right-column {
    grid-column: auto;
    flex-direction: row;
    min-height: 320px;
  }

  .stage-head {
    flex-wrap: wrap;
    padding-bottom: 2px;
  }

  .stage-head .panel-title {
    flex: 1;
  }

  .camera-group {
    margin-left: auto;
  }

  .camera-group button {
    height: 26px;
    padding: 0 8px;
    font-size: 13px;
  }

  .stage-wrap {
    min-height: 320px;
  }

  .title-row {
    gap: 14px;
  }

  .title-actions {
    gap: 14px;
  }

  .reset-btn span {
    display: none;
  }

  .reset-btn {
    width: 30px;
    padding: 0;
  }
}

@media (max-width: 900px) {
  dialog.edit-modal,
  dialog.line-modal {
    height: calc(100dvh - 16px);
    max-height: calc(100dvh - 16px);
  }

  dialog.edit-modal .edit-body,
  dialog.line-modal .edit-body {
    display: flex;
    flex-direction: column;
    gap: 12px;
    overflow: auto;
    padding: 0 16px 16px;
  }

  .edit-drawing {
    flex: none;
    min-height: 500px;
  }

  .line-drawing {
    min-height: 540px;
  }

  .edit-inspector {
    flex: none;
    min-height: 340px;
  }

  .edit-preview-wrap {
    height: 180px;
  }

  .edit-actions {
    margin-top: 0;
  }

  .edit-footer {
    flex-wrap: wrap;
    gap: 8px;
    padding: 10px 16px 12px;
  }

  .edit-footer #editToolHint {
    white-space: normal;
  }

  dialog.line-modal {
    width: calc(100vw - 16px);
  }

  .line-drawing {
    flex: 0 0 auto;
    height: min(720px, calc(100dvh - 230px));
    min-height: 0;
  }

  .line-views {
    min-height: 0;
  }

  .poly-toolbar-hint {
    width: 100%;
  }
}

@media (max-width: 720px) {
  .poly-feature-bar {
    gap: 5px;
    padding-bottom: 6px;
  }

  .poly-feature-hint {
    display: none;
  }

  .line-level input {
    width: 40px;
  }
  :root {
    --sheet-pad-x: 14px;
  }

  .topbar {
    padding: 0 8px;
  }

  .brand-mark {
    width: 24px;
    height: 24px;
  }

  .brand-name {
    font-size: 14px;
  }

  .crumb {
    display: none;
  }

  .primary-btn {
    height: 32px;
    padding: 0 10px;
    font-size: 13px;
  }

  .sheet {
    margin: 0 6px 6px;
    border-radius: 12px;
  }

  .sheet-inner {
    padding: 16px 14px 12px;
  }

  .title-row {
    flex-direction: column;
    align-items: stretch;
    gap: 11px;
    padding-bottom: 12px;
  }

  .title-copy h1 {
    font-size: 22px;
  }

  .title-copy p {
    white-space: normal;
    font-size: 13px;
  }

  .title-actions {
    justify-content: space-between;
    width: 100%;
    min-height: 34px;
  }

  .title-fact + .title-fact {
    padding-left: 14px;
  }

  .reset-btn {
    margin-left: auto;
  }

  .workbench {
    gap: 12px;
  }

  .right-column {
    flex-direction: column;
    gap: 12px;
    min-height: 0;
  }

  .mini-panel {
    min-height: 330px;
  }

  .stage-panel,
  .views-panel {
    min-height: 440px;
  }

  .stage-wrap {
    min-height: 300px;
    margin: 8px 8px 0;
  }

  .panel-head {
    padding: 12px 12px 0;
  }

  .panel-title h2 {
    font-size: 13px;
  }

  .panel-title p {
    font-size: 13px;
  }

  .three-mount {
    padding: 3px 6px 0;
  }

  .legend-row {
    padding: 0 12px;
    gap: 10px;
  }

  .readout-strip {
    margin: 6px 12px 11px;
  }

  .readout-strip > div {
    padding: 0 9px;
  }

  .stage-foot {
    margin: 0 4px;
  }

  .stage-foot > div {
    flex-direction: column;
    align-items: flex-start;
    justify-content: flex-start;
    gap: 1px;
    padding: 0 7px;
  }

  .stage-foot span {
    font-size: 13px;
  }

  .stage-foot strong {
    font-size: 13px;
  }

  .sheet-foot {
    gap: 8px;
  }

  .sheet-foot p {
    font-size: 13px;
    white-space: normal;
  }

  .foot-link {
    font-size: 13px;
    white-space: nowrap;
  }

  .stage-hint {
    font-size: 13px;
    left: 68px;
    right: 116px;
  }

  .hint-wide {
    display: none;
  }

  .hint-narrow {
    display: inline;
  }

  .stage-dims {
    font-size: 13px;
  }

  dialog.modal {
    width: calc(100vw - 16px);
    max-height: calc(100dvh - 16px);
    border-radius: 12px;
  }

  .modal-head {
    padding: 16px 16px 12px;
  }

  .modal-head h2 {
    font-size: 18px;
  }

  .modal-head p {
    font-size: 11px;
  }

  .modal-foot {
    padding: 11px 16px 13px;
    gap: 10px;
    flex-wrap: wrap;
  }

  .modal-foot p {
    font-size: 11px;
  }

  .reference-body {
    padding: 0 16px 14px;
    max-height: calc(100dvh - 160px);
  }

  .method-body {
    padding: 0 16px 8px;
    max-height: calc(100dvh - 170px);
  }

  .method-callout {
    flex-direction: column;
    align-items: flex-start;
    gap: 10px;
  }

  .edit-modal {
    width: calc(100vw - 8px);
    max-height: calc(100dvh - 8px);
  }

  dialog.edit-modal,
  dialog.line-modal {
    width: calc(100vw - 8px);
  }

  .line-drawing {
    min-height: 0;
    height: calc(100dvh - 230px);
    padding: 6px 6px 0;
  }

  .line-views {
    justify-content: flex-start;
    align-items: flex-start;
  }

  .line-views svg {
    min-height: 0;
  }

  .poly-toolbar {
    align-items: flex-start;
  }

  .poly-toolbar-hint {
    font-size: 11px;
  }

  .edit-body {
    display: flex;
    flex-direction: column;
    gap: 12px;
    max-height: none;
    overflow: auto;
    padding: 0 12px 14px;
  }

  .edit-drawing {
    flex: none;
    min-height: 440px;
    padding: 6px 6px 0;
  }

  .editor-views {
    justify-content: flex-start;
    align-items: flex-start;
  }

  .editor-views svg {
    min-height: 0;
  }

  .edit-inspector {
    flex: none;
  }

  .edit-preview-wrap {
    height: 180px;
  }

  .edit-actions {
    margin-top: 0;
  }

  .side-scope {
    padding-top: 0;
  }

  .toast {
    bottom: 16px;
    font-size: 11px;
  }
}

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

/* ------------------------------------------------------------- work / gallery / welcome */
.work-modal {
  width: min(680px, calc(100vw - 32px));
}

.work-body {
  padding: 2px 24px 18px;
}

.work-fields {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
}

.work-fields label {
  display: flex;
  flex-direction: column;
  gap: 6px;
  color: var(--muted);
  font-size: 12px;
}

.work-fields input,
.work-share-input {
  height: 36px;
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 7px;
  background: #fff;
  color: var(--text);
  padding: 0 10px;
  font: inherit;
  font-size: 13px;
}

.work-fields input:focus,
.work-share-input:focus {
  outline: 2px solid var(--accent);
  outline-offset: 1px;
}

.work-status {
  margin: 12px 0 10px;
  color: var(--muted);
  font-size: 12px;
}

.work-share-row {
  display: flex;
  gap: 8px;
  align-items: center;
}

.work-share-row .ghost-btn {
  flex: none;
}

.work-share-input {
  min-width: 0;
  font-family: var(--font-mono);
  font-size: 11px;
  color: var(--muted);
}

.work-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 14px;
}

.gallery-modal {
  width: min(980px, calc(100vw - 32px));
}

.gallery-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 10px;
  padding: 2px 24px 20px;
  max-height: min(620px, calc(100dvh - 220px));
  overflow: auto;
}

.gallery-card {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 5px;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: #fff;
  color: var(--text);
  text-align: left;
  cursor: pointer;
}

.gallery-card:hover,
.gallery-card:focus-visible {
  border-color: var(--accent);
  outline: none;
}

.gallery-card svg {
  width: 54px;
  height: 54px;
}

.gallery-card strong {
  font-size: 13px;
  font-weight: 600;
}

.gallery-card span {
  color: var(--muted);
  font-size: 11px;
  line-height: 1.4;
}

.gallery-card em {
  color: var(--faint);
  font-family: var(--font-mono);
  font-size: 10px;
  font-style: normal;
}

.welcome-modal {
  width: min(600px, calc(100vw - 32px));
}

.welcome-body {
  padding: 4px 24px 20px;
}

.welcome-steps {
  margin: 0;
  padding: 0;
  list-style: none;
  display: grid;
  gap: 12px;
  counter-reset: welcome-step;
}

.welcome-steps li {
  display: grid;
  grid-template-columns: 26px 1fr;
  gap: 4px 10px;
  align-items: baseline;
  counter-increment: welcome-step;
}

.welcome-steps li::before {
  content: counter(welcome-step);

  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 22px;
  height: 22px;
  border-radius: 50%;
  background: var(--accent-soft);
  color: var(--accent);
  font-family: var(--font-mono);
  font-size: 11px;
}

.welcome-steps strong {
  font-size: 14px;
  font-weight: 600;
}

.welcome-steps span {
  grid-column: 2;
  color: var(--muted);
  font-size: 12px;
  line-height: 1.5;
}

.welcome-actions {
  display: flex;
  justify-content: flex-end;
  gap: 8px;
  margin-top: 20px;
}

.side-more {
  border: 0;
  background: transparent;
  color: var(--accent);
  font: inherit;
  font-size: 11px;
  cursor: pointer;
  padding: 2px 4px;
}

.side-more:hover,
.side-more:focus-visible {
  text-decoration: underline;
  outline: none;
}

.mobile-dock {
  display: none;
}

@media (max-width: 900px) {
  .work-fields {
    grid-template-columns: 1fr;
  }

  .work-body {
    padding-left: 18px;
    padding-right: 18px;
  }

  .work-share-row {
    align-items: stretch;
    flex-direction: column;
  }

  .gallery-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
    padding-left: 18px;
    padding-right: 18px;
  }

  .gallery-modal {
    width: calc(100vw - 20px);
  }

  .welcome-body {
    padding-left: 18px;
    padding-right: 18px;
  }

  .top-actions .primary-btn {
    display: none;
  }

  .mobile-dock {
    position: fixed;
    left: 0;
    right: 0;
    bottom: 0;
    z-index: 60;
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 1px;
    padding: 7px 10px calc(7px + env(safe-area-inset-bottom));
    background: rgba(248, 250, 249, .96);
    border-top: 1px solid var(--border);
  }

  .mobile-dock button {
    min-height: 42px;
    border: 0;
    border-radius: 8px;
    background: transparent;
    color: var(--text);
    font: inherit;
    font-size: 12px;
    font-weight: 600;
  }

  .mobile-dock button:active {
    background: var(--accent-soft);
  }

  .sheet {
    padding-bottom: 72px;
  }
}

/* ------------------------------------------------------------- cloud / workshop */
[hidden] {
  display: none !important;
}

.workshop-top {
  white-space: nowrap;
}

.cloud-panel {
  margin-top: 12px;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: #fbfcfa;
}

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

.cloud-head h3 {
  margin: 0;
  font-size: 13px;
  font-weight: 600;
}

.cloud-head span {
  color: var(--muted);
  font-size: 11px;
}

.cloud-code-row {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-top: 10px;
  color: var(--muted);
  font-size: 12px;
}

.cloud-code-row code {
  padding: 4px 8px;
  border-radius: 5px;
  background: #fff;
  border: 1px solid var(--line);
  color: var(--text);
  font-family: var(--font-mono);
  font-size: 14px;
  letter-spacing: .08em;
}

.cloud-code-row .ghost-btn {
  margin-left: auto;
}

.cloud-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 10px;
}

.cloud-open-row {
  display: flex;
  align-items: stretch;
  gap: 8px;
  margin-top: 10px;
}

.cloud-open-row input {
  flex: 1;
  min-width: 0;
  height: 34px;
  padding: 0 9px;
  border: 1px solid var(--line);
  border-radius: 7px;
  background: #fff;
  color: var(--text);
  font: inherit;
  font-size: 13px;
}

.cloud-open-row input:focus {
  outline: 2px solid var(--accent);
  outline-offset: 1px;
}

.cloud-hint {
  margin: 8px 0 0;
  color: var(--muted);
  font-size: 11px;
  line-height: 1.5;
}

.workshop-modal {
  width: min(1120px, calc(100vw - 32px));
}

.workshop-toolbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 0 24px 10px;
  color: var(--muted);
  font-size: 12px;
}

.workshop-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 12px;
  padding: 2px 24px 20px;
  max-height: min(600px, calc(100dvh - 230px));
  overflow: auto;
}

.workshop-card {
  display: flex;
  flex-direction: column;
  gap: 7px;
  padding: 13px;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: #fff;
  color: var(--text);
  text-align: left;
  cursor: pointer;
}

.workshop-card:hover,
.workshop-card:focus-visible {
  border-color: var(--accent);
  outline: none;
}

.workshop-card svg {
  width: 76px;
  height: 76px;
  color: var(--muted);
}

.workshop-card strong {
  font-size: 14px;
  font-weight: 600;
}

.workshop-card .workshop-author {
  color: var(--muted);
  font-size: 11px;
}

.workshop-card .workshop-summary {
  color: var(--muted);
  font-size: 12px;
  line-height: 1.5;
}

.workshop-code-row {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-top: 2px;
  padding-top: 8px;
  border-top: 1px solid var(--line);
}

.workshop-code-row code {
  font-family: var(--font-mono);
  font-size: 13px;
  letter-spacing: .08em;
}

.workshop-code-row button {
  margin-left: auto;
}

.workshop-card-actions {
  display: flex;
  gap: 6px;
  margin-top: 2px;
}

.workshop-empty {
  padding: 30px 24px;
  color: var(--muted);
  font-size: 13px;
  text-align: center;
}

.teacher-modal {
  width: min(820px, calc(100vw - 32px));
}

.teacher-body {
  padding: 2px 24px 18px;
}

.teacher-gate label {
  display: block;
  margin-bottom: 6px;
  color: var(--muted);
  font-size: 12px;
}

.teacher-list {
  display: flex;
  flex-direction: column;
  gap: 6px;
  max-height: min(560px, calc(100dvh - 280px));
  overflow: auto;
}

.teacher-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 8px;
  align-items: center;
  padding: 9px 10px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
}

.teacher-row-main {
  min-width: 0;
}

.teacher-row-title {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  font-size: 13px;
  font-weight: 600;
}

.teacher-row-meta {
  margin-top: 2px;
  color: var(--muted);
  font: 11px var(--font-mono);
}

.teacher-row-actions {
  display: flex;
  gap: 5px;
}

.teacher-row-actions button {
  min-height: 28px;
  padding: 0 7px;
  font-size: 11px;
}

.teacher-hidden {
  color: var(--muted);
  text-decoration: line-through;
}

@media (max-width: 900px) {
  .mobile-dock {
    grid-template-columns: repeat(5, 1fr);
  }

  .workshop-top {
    display: none;
  }

  .workshop-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
    padding-left: 18px;
    padding-right: 18px;
  }

  .workshop-modal,
  .teacher-modal {
    width: calc(100vw - 20px);
  }

  .workshop-toolbar,
  .teacher-body {
    padding-left: 18px;
    padding-right: 18px;
  }

  .teacher-row {
    grid-template-columns: 1fr;
  }
}
