:root {
  --bg: #f5f6f2;
  --surface: #ffffff;
  --surface-soft: #f0f3ee;
  --surface-quiet: #fafbf8;
  --ink: #172117;
  --muted: #687268;
  --line: #d8ddd2;
  --line-strong: #c7d0c3;
  --green: #2f6b35;
  --green-strong: #214b27;
  --green-soft: #e3eee5;
  --blue: #243b78;
  --amber: #8a5a0a;
  --red: #a33123;
  --space-1: 4px;
  --space-2: 8px;
  --space-3: 12px;
  --space-4: 16px;
  --space-5: 20px;
  --space-6: 24px;
  --radius-control: 10px;
  --radius-panel: 16px;
  --radius-card: 14px;
  --shadow: 0 8px 24px rgba(30, 46, 31, 0.07);
  --shadow-overlay: 0 18px 48px rgba(18, 28, 19, 0.16);
}

* {
  box-sizing: border-box;
}

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

body {
  margin: 0;
  color: var(--ink);
  background: var(--bg);
  font-family: -apple-system, BlinkMacSystemFont, "PingFang SC", "Microsoft YaHei", sans-serif;
  font-size: 14px;
  -webkit-font-smoothing: antialiased;
}

button,
input,
select {
  font: inherit;
}

button {
  cursor: pointer;
}

.app-shell {
  width: min(1760px, calc(100vw - 32px));
  margin: 0 auto;
  padding: 0 0 var(--space-5);
}

.topbar {
  min-height: 64px;
  display: flex;
  position: sticky;
  top: 0;
  z-index: 30;
  justify-content: space-between;
  align-items: center;
  gap: var(--space-5);
  padding: var(--space-2) var(--space-3);
  border-bottom: 1px solid var(--line);
  background: var(--bg);
}

.app-identity {
  display: flex;
  min-width: 0;
  align-items: center;
  gap: 12px;
}

.app-logo {
  width: 76px;
  height: 38px;
  flex: 0 0 auto;
  object-fit: contain;
}

.app-title-row {
  display: block;
  min-width: 0;
}

.app-version {
  flex: 0 0 auto;
  border: 1px solid var(--line);
  border-radius: 999px;
  padding: 1px 7px;
  background: var(--surface);
  color: var(--muted);
  font-size: 11px;
  font-weight: 600;
  white-space: nowrap;
}

.app-controls {
  position: relative;
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 10px;
}

.shutdown-hint {
  margin: 0;
  color: var(--muted);
  font-size: 12px;
}

.shutdown-button {
  min-width: 88px;
  min-height: 40px;
  border: 1px solid rgba(163, 49, 35, 0.36);
  border-radius: 8px;
  padding: 0 14px;
  background: var(--surface);
  color: var(--red);
  font-weight: 700;
}

.shutdown-button:hover {
  border-color: var(--red);
  background: rgba(163, 49, 35, 0.06);
}

.secondary-button,
.language-switch select {
  min-height: 40px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
  color: var(--ink);
  font-weight: 700;
}

.secondary-button {
  padding: 0 12px;
}

.system-menu-wrap {
  position: relative;
}

.system-menu-wrap[hidden],
.account-drawer[hidden],
.account-drawer-backdrop[hidden],
.account-drawer button[hidden],
.account-drawer-group[hidden],
.language-switch[hidden],
.workspace[hidden] {
  display: none;
}

body.auth-locked #user-badge,
body.auth-locked #system-menu-wrap {
  display: none;
}

body:not(.auth-locked) #topbar-language-wrap {
  display: none;
}

.account-rail {
  display: flex;
  align-items: center;
}

.system-menu-button {
  min-height: 40px;
  display: inline-flex;
  position: relative;
  align-items: center;
  gap: 8px;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 4px 10px;
  background: var(--surface);
  color: var(--ink);
  font-weight: 700;
}

.system-menu-button:hover,
.system-menu-button:focus-visible,
.system-settings-shortcut:hover,
.system-settings-shortcut:focus-visible,
.account-drawer-close:hover,
.account-drawer-close:focus-visible {
  border-color: var(--green);
  outline: none;
}

.system-settings-shortcut {
  width: 42px;
  height: 42px;
  display: inline-grid;
  flex: 0 0 auto;
  place-items: center;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: var(--surface);
}

.system-settings-shortcut img {
  width: 20px;
  height: 20px;
}

.account-avatar {
  width: 30px;
  height: 30px;
  display: inline-grid;
  flex: 0 0 auto;
  place-items: center;
  border-radius: 50%;
  background: var(--green);
  color: #fff;
  font-size: 14px;
  font-weight: 800;
}

.account-avatar--large {
  width: 56px;
  height: 56px;
  font-size: 24px;
}

.account-status-dot {
  width: 9px;
  height: 9px;
  position: absolute;
  top: 4px;
  left: 32px;
  border: 2px solid var(--surface);
  border-radius: 50%;
  background: #2d8b43;
}

.account-drawer-backdrop {
  position: fixed;
  inset: 0;
  z-index: 40;
  border: 0;
  padding: 0;
  background: rgba(23, 33, 23, 0.12);
  cursor: default;
}

.account-drawer {
  width: 288px;
  position: fixed;
  top: 0;
  right: 0;
  bottom: 0;
  z-index: 42;
  display: flex;
  min-height: 0;
  flex-direction: column;
  overflow: hidden;
  border-left: 1px solid var(--line);
  background: var(--surface);
  box-shadow: -12px 0 32px rgba(18, 28, 19, 0.12);
}

.account-drawer-header {
  flex: 0 0 auto;
  border-bottom: 1px solid var(--line);
  padding: 14px 16px 16px;
}

.account-drawer-close {
  width: 36px;
  height: 36px;
  display: grid;
  margin: 0 0 12px -4px;
  place-items: center;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
  color: var(--ink);
  font-size: 24px;
  line-height: 1;
}

.account-profile {
  display: flex;
  align-items: center;
  gap: 12px;
}

.account-profile-copy {
  min-width: 0;
  display: grid;
  gap: 2px;
}

.account-drawer .user-badge {
  min-height: 0;
  display: block;
  overflow: hidden;
  border: 0;
  border-radius: 0;
  padding: 0;
  background: transparent;
  color: var(--ink);
  font-size: 16px;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.account-role,
.account-source {
  color: var(--muted);
  font-size: 12px;
}

.account-source {
  width: fit-content;
  border-radius: 999px;
  padding: 2px 7px;
  background: rgba(47, 107, 53, 0.09);
  color: var(--green-strong);
  font-weight: 700;
}

.account-drawer-content {
  display: grid;
  grid-auto-rows: max-content;
  min-height: 0;
  flex: 1;
  align-content: start;
  gap: 12px;
  overflow-y: auto;
  padding: 14px 12px 20px;
}

.account-drawer-group {
  min-height: max-content;
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
}

.account-drawer-group h2 {
  margin: 0;
  padding: 10px 12px 8px;
  border-bottom: 1px solid var(--line);
  color: var(--green-strong);
  font-size: 12px;
  font-weight: 800;
}

.account-drawer-group button {
  width: 100%;
  min-height: 58px;
  display: grid;
  gap: 3px;
  border: 0;
  border-bottom: 1px solid var(--line);
  padding: 10px 12px;
  background: var(--surface);
  color: var(--ink);
  text-align: left;
}

.account-drawer-group button:last-child {
  border-bottom: 0;
}

.account-drawer-group button:hover,
.account-drawer-group button:focus-visible {
  background: var(--surface-soft);
  outline: none;
}

.account-drawer-group button:focus-visible {
  box-shadow: inset 3px 0 0 var(--green);
}

.account-drawer-group button span {
  font-size: 13px;
  font-weight: 800;
}

.account-drawer-group button small {
  color: var(--muted);
  font-size: 11px;
  line-height: 1.35;
}

.account-drawer-group--danger {
  margin-top: auto;
  border-color: rgba(163, 49, 35, 0.24);
}

.account-drawer-group--danger h2,
.account-drawer .danger-menu-item,
.account-drawer .danger-menu-item small {
  color: var(--red);
}

.language-switch {
  display: grid;
  grid-template-columns: auto 108px;
  align-items: center;
  gap: 8px;
  color: var(--muted);
  font-size: 12px;
}

.user-badge {
  min-height: 30px;
  display: inline-flex;
  align-items: center;
  border: 1px solid rgba(47, 107, 53, 0.25);
  border-radius: 999px;
  padding: 4px 10px;
  background: rgba(47, 107, 53, 0.07);
  color: var(--green-strong);
  font-size: 12px;
  font-weight: 700;
  white-space: nowrap;
}

.stopped-panel {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-top: 14px;
  padding: 12px 14px;
  border: 1px solid rgba(47, 107, 53, 0.28);
  border-radius: 8px;
  background: rgba(47, 107, 53, 0.07);
  color: var(--green-strong);
  font-size: 13px;
}

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

h1,
h2,
h3,
p {
  margin-top: 0;
  letter-spacing: 0;
}

h1 {
  width: max-content;
  max-width: 100%;
  margin-bottom: 0;
  display: grid;
  gap: 1px;
  line-height: 1.2;
}

.app-title-zh {
  display: block;
  font-size: 24px;
  font-weight: 800;
  white-space: nowrap;
}

.app-title-en {
  display: block;
  color: var(--muted);
  font-size: 12px;
  font-weight: 700;
  letter-spacing: 0.02em;
  white-space: nowrap;
}

.app-title-en-line {
  display: grid;
  grid-template-columns: auto auto;
  width: 100%;
  min-width: max-content;
  align-items: baseline;
  justify-content: space-between;
  column-gap: 12px;
  white-space: nowrap;
}

h2 {
  font-size: 16px;
  line-height: 1.3;
}

h3 {
  margin: 0 0 10px;
  color: var(--ink);
  font-size: 14px;
  line-height: 1.3;
}

.status-pill {
  min-width: 88px;
  min-height: 30px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 7px;
  border: 1px solid var(--line);
  border-radius: 999px;
  padding: 4px 10px;
  background: var(--surface);
  color: var(--muted);
  font-size: 12px;
  font-weight: 700;
  white-space: nowrap;
}

.status-pill::before {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: currentColor;
  content: "";
}

.status-pill[data-state="loading"] {
  color: var(--blue);
  border-color: rgba(36, 59, 120, 0.25);
  background: rgba(36, 59, 120, 0.06);
}

.status-pill[data-state="success"] {
  color: var(--green);
  border-color: rgba(47, 107, 53, 0.25);
  background: rgba(47, 107, 53, 0.07);
}

.status-pill[data-state="stale"] {
  color: var(--amber);
  border-color: rgba(138, 90, 10, 0.28);
  background: rgba(138, 90, 10, 0.08);
}

.status-pill[data-state="error"] {
  color: var(--red);
  border-color: rgba(163, 49, 35, 0.26);
  background: rgba(163, 49, 35, 0.07);
}

.status-pill[data-state="stopped"] {
  color: var(--muted);
  background: var(--surface-soft);
}

.workspace {
  display: grid;
  grid-template-columns: minmax(360px, 392px) minmax(0, 1fr);
  gap: var(--space-4);
  margin-top: var(--space-4);
  align-items: start;
}

.auth-panel {
  display: grid;
  place-items: center;
  min-height: max(520px, calc(100dvh - 84px));
  padding: var(--space-6) var(--space-4) 48px;
}

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

.auth-card {
  width: min(432px, 100%);
  border: 1px solid var(--line);
  border-radius: var(--radius-panel);
  padding: 28px;
  background: var(--surface);
  box-shadow: var(--shadow);
}

.auth-card[hidden] {
  display: none;
}

.auth-card p,
.recovery-details,
.recovery-confirm {
  color: var(--muted);
  font-size: 13px;
  line-height: 1.5;
}

.auth-card h2 {
  margin-bottom: var(--space-2);
  color: var(--ink);
  font-size: 22px;
  line-height: 1.35;
}

.auth-eyebrow {
  margin-bottom: var(--space-2);
  color: var(--green) !important;
  font-size: 12px !important;
  font-weight: 800;
  letter-spacing: 0.04em;
  text-transform: uppercase;
}

.recovery-confirm {
  display: flex;
  align-items: center;
  gap: 8px;
  margin: 12px 0;
}

.recovery-confirm input {
  width: auto;
  min-height: auto;
}

.auth-form {
  display: grid;
  gap: var(--space-4);
}

.auth-form + .recovery-details,
.auth-form ~ .recovery-details {
  margin-top: var(--space-5);
  padding-top: var(--space-4);
  border-top: 1px solid var(--line);
}

.recovery-details summary {
  width: fit-content;
  color: var(--green-strong);
  cursor: pointer;
  font-weight: 700;
}

.recovery-details[open] summary {
  margin-bottom: var(--space-4);
}

.auth-form[aria-busy="true"] {
  opacity: 0.78;
}

.auth-form button,
.auth-card > button,
#create-user-button,
#change-password-button,
#save-display-name-button,
#save-language-button {
  min-height: 46px;
  border: 1px solid var(--green);
  border-radius: var(--radius-control);
  padding: 0 14px;
  background: var(--green);
  color: #fff;
  font-weight: 700;
}

.recovery-code {
  display: block;
  margin: 14px 0;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 14px;
  background: #fbfcfa;
  color: var(--ink);
  font-size: 20px;
  font-weight: 800;
  letter-spacing: 1px;
  text-align: center;
}

.account-dialog {
  width: min(760px, calc(100vw - 28px));
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 0;
  background: var(--surface);
  color: var(--ink);
}

.account-dialog::backdrop,
.shutdown-dialog::backdrop,
.drawing-viewer::backdrop {
  background: rgba(0, 0, 0, 0.32);
}

.account-shell {
  display: grid;
  gap: 18px;
  padding: 18px;
}

.dialog-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.dialog-header button {
  width: 40px;
  height: 40px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
  color: var(--ink);
  font-size: 22px;
}

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

.users-list {
  display: grid;
  gap: 8px;
}

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

.user-row strong,
.user-row span {
  display: block;
}

.user-row span {
  color: var(--muted);
  font-size: 12px;
}

.user-row button {
  min-height: 36px;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 0 10px;
  background: var(--surface);
  color: var(--ink);
  font-weight: 700;
}

.credit-search-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 8px;
  margin-bottom: 10px;
}

.credit-search-row input {
  min-height: 40px;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 0 12px;
}

.credit-balance {
  color: var(--green);
  font-size: 13px;
  font-weight: 800;
}

.dialog-subtitle,
.form-note {
  margin: 4px 0 0;
  color: var(--muted);
  font-size: 13px;
  line-height: 1.5;
}

.credit-dialog {
  width: min(720px, calc(100vw - 28px));
}

.credit-wallet-card,
.credit-shortfall {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 8px 18px;
  align-items: center;
  border: 1px solid rgba(37, 100, 52, 0.2);
  border-radius: 10px;
  padding: 14px;
  background: var(--surface-soft);
}

.credit-wallet-card strong,
.credit-shortfall strong {
  color: var(--green);
  font-size: 20px;
}

.credit-record-list {
  display: grid;
  gap: 8px;
}

.credit-record {
  display: grid;
  gap: 4px;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 10px 12px;
  background: #fbfcfa;
}

.credit-record span,
.credit-record small {
  color: var(--muted);
  font-size: 12px;
}

.credit-record .compact-button {
  width: max-content;
  min-height: 32px;
  margin-top: 4px;
}

.confirmation-summary {
  display: grid;
  gap: 6px;
  margin: 14px 0;
}

.confirmation-summary p {
  display: grid;
  grid-template-columns: 92px 1fr;
  gap: 12px;
  margin: 0;
}

.support-contact {
  display: grid;
  grid-template-columns: 132px 1fr;
  gap: 16px;
  align-items: center;
}

.support-qr-placeholder,
.support-contact img {
  width: 132px;
  height: 132px;
  border: 1px dashed var(--line-strong);
  border-radius: 8px;
  object-fit: cover;
}

.support-qr-placeholder {
  display: grid;
  place-items: center;
  color: var(--muted);
  text-align: center;
  font-size: 12px;
}

.recharge-packages {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 8px;
}

.recharge-package {
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 10px 6px;
  background: var(--surface-soft);
  text-align: center;
  font-weight: 700;
}

@media (max-width: 620px) {
  .recharge-packages {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .support-contact {
    grid-template-columns: 1fr;
  }
}

.form-panel,
.summary-panel,
.preview-panel {
  border: 1px solid var(--line);
  border-radius: var(--radius-panel);
  background: var(--surface);
  box-shadow: var(--shadow);
}

.form-panel {
  padding: var(--space-4);
}

.summary-panel,
.preview-panel {
  padding: var(--space-4);
}

.form-panel {
  position: sticky;
  top: 16px;
  max-height: calc(100vh - 32px);
  overflow: auto;
}

.field-group + .field-group {
  margin-top: 14px;
  padding-top: 14px;
  border-top: 1px solid var(--line);
}

.field-disclosure-summary {
  min-height: 40px;
  display: flex;
  align-items: center;
  gap: 10px;
  color: var(--ink);
  cursor: pointer;
  font-size: 16px;
  font-weight: 700;
  list-style: none;
}

.field-disclosure-summary::-webkit-details-marker {
  display: none;
}

.field-disclosure-summary::after {
  width: 8px;
  height: 8px;
  flex: 0 0 auto;
  margin-left: auto;
  border-right: 2px solid var(--muted);
  border-bottom: 2px solid var(--muted);
  content: "";
  transform: rotate(45deg) translate(-2px, -2px);
  transition: transform 120ms ease-out;
}

.field-disclosure[open] > .field-disclosure-summary::after {
  transform: rotate(225deg) translate(-2px, -2px);
}

.field-disclosure-summary:focus-visible {
  border-radius: 6px;
  outline: 3px solid var(--green);
  outline-offset: 2px;
}

.field-disclosure-meta {
  border: 1px solid var(--line);
  border-radius: 999px;
  padding: 2px 7px;
  color: var(--muted);
  font-size: 11px;
  font-weight: 600;
  line-height: 1.4;
}

.field-disclosure-content {
  padding-top: 9px;
}

.grid {
  display: grid;
  gap: 12px;
}

.grid.one {
  grid-template-columns: minmax(0, 1fr);
}

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

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

.grid.four {
  grid-template-columns: repeat(4, minmax(0, 1fr));
}

.dimension-block {
  padding: 0;
}

.dimension-block + .dimension-block {
  margin-top: 16px;
  padding-top: 16px;
  border-top: 1px solid var(--line);
}

.dimension-block h3 {
  margin-bottom: 10px;
  color: var(--ink);
  font-size: 14px;
}

.marking-dimension-groups {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 16px;
}

.marking-dimension-group {
  min-width: 0;
  margin: 0;
  padding: 0;
  border: 0;
}

.marking-dimension-group legend {
  margin-bottom: 10px;
  padding: 0;
  color: var(--ink);
  font-size: 14px;
  font-weight: 700;
}

.marking-radius-row {
  margin-top: 16px;
}

.input-help {
  margin: 6px 0 0;
  color: var(--muted);
  font-size: 11px;
  line-height: 1.5;
}

.geometry-result {
  display: flex;
  flex-wrap: nowrap;
  align-items: center;
  gap: 8px;
  margin-top: 10px;
  padding: 10px 12px;
  border: 1px solid rgba(47, 107, 53, 0.22);
  border-radius: 8px;
  background: rgba(47, 107, 53, 0.06);
  color: var(--green-strong);
  font-size: 12px;
  line-height: 1.6;
  overflow-x: auto;
  white-space: nowrap;
}

.geometry-result[data-state="error"] {
  border-color: rgba(163, 49, 35, 0.24);
  background: rgba(163, 49, 35, 0.07);
  color: var(--red);
}

.geometry-result[hidden] {
  display: none;
}

.turf-coverage-result {
  flex-wrap: wrap;
  white-space: normal;
}

#turf-coverage-length-field[hidden] {
  display: none;
}

.field-note {
  margin: 10px 0 0;
  overflow-x: auto;
  color: var(--green-strong);
  font-size: 11px;
  line-height: 1.4;
  white-space: nowrap;
}

.field-note[hidden] {
  display: none;
}

.line-embedding-options {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 12px;
  margin-top: 12px;
}

.line-embedding-option {
  min-height: 48px;
  display: flex;
  grid-template-columns: none;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 8px 12px;
  border: 1px solid var(--line);
  border-radius: 6px;
  cursor: pointer;
}

.line-embedding-copy {
  display: grid;
  gap: 2px;
}

.line-embedding-copy strong {
  color: var(--ink);
  font-size: 13px;
}

.line-embedding-copy span {
  color: var(--muted);
  font-size: 11px;
}

.line-embedding-option input[type="checkbox"] {
  width: 44px;
  min-height: 24px;
  height: 24px;
  flex: 0 0 auto;
  appearance: none;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: var(--surface-soft);
  cursor: pointer;
  transition: background-color 120ms ease-out, border-color 120ms ease-out;
}

.line-embedding-option input[type="checkbox"]::after {
  width: 18px;
  height: 18px;
  display: block;
  margin: 2px;
  border-radius: 50%;
  background: #fff;
  box-shadow: 0 1px 2px rgba(19, 39, 24, 0.25);
  content: "";
  transition: transform 120ms ease-out;
}

.line-embedding-option input[type="checkbox"]:checked {
  border-color: var(--green);
  background: var(--green);
}

.line-embedding-option input[type="checkbox"]:checked::after {
  transform: translateX(20px);
}

.line-embedding-option input[type="checkbox"]:focus-visible {
  outline: 3px solid var(--green);
  outline-offset: 2px;
}

label {
  display: grid;
  gap: 6px;
  font-size: 13px;
  color: var(--muted);
}

input,
select {
  width: 100%;
  min-height: 42px;
  border: 1px solid var(--line-strong);
  border-radius: var(--radius-control);
  padding: 0 12px;
  color: var(--ink);
  background: var(--surface-quiet);
}

input:focus-visible,
select:focus-visible,
button:focus-visible,
.preview-viewport:focus-visible,
.preview-card img:focus-visible,
.viewer-action:focus-visible,
.viewer-viewport:focus-visible {
  outline: 3px solid var(--green);
  outline-offset: 2px;
}

.form-footer {
  position: sticky;
  bottom: -18px;
  z-index: 2;
  margin: 18px -18px -18px;
  padding: 12px 18px 18px;
  border-top: 1px solid var(--line);
  background: rgba(255, 255, 255, 0.97);
  box-shadow: 0 -8px 18px rgba(30, 46, 31, 0.06);
}

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

.actions button {
  min-height: 44px;
  padding: 0 16px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface-soft);
  color: var(--ink);
  font-weight: 700;
}

.actions button.primary,
#preview-button {
  background: var(--green);
  border-color: var(--green);
  color: #fff;
  grid-column: 1 / -1;
}

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

.error {
  margin-top: 14px;
  padding: 12px 14px;
  border-radius: 8px;
  border: 1px solid rgba(163, 49, 35, 0.24);
  background: rgba(163, 49, 35, 0.08);
  color: var(--red);
  font-size: 14px;
  line-height: 1.5;
}

.result-panel {
  display: grid;
  gap: var(--space-4);
}

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

.section-heading p {
  margin: 0;
  color: var(--muted);
  font-size: 12px;
}

.summary-grid {
  display: grid;
  grid-template-columns:
    repeat(3, minmax(112px, 0.78fr))
    minmax(250px, 1.5fr)
    minmax(320px, 1.9fr);
  gap: 0;
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fbfcfa;
}

.summary-item {
  display: flex;
  flex-direction: column;
  min-width: 0;
  border: 0;
  border-radius: 0;
  background: transparent;
  padding: 10px 12px;
  text-align: center;
}

.summary-item + .summary-item {
  border-left: 1px solid var(--line);
}

.summary-item--metric {
  grid-column: auto;
}

.summary-item--wide {
  grid-column: auto;
}

.summary-item .label {
  display: block;
  color: var(--muted);
  font-size: 12px;
  margin-bottom: 5px;
  text-align: center;
}

.summary-item .value {
  display: block;
  margin-top: auto;
  color: var(--ink);
  font-size: 17px;
  font-weight: 700;
  line-height: 1.15;
}

.summary-seam-option strong,
.summary-glue-option strong {
  color: var(--ink);
  font-size: 16px;
  line-height: 1.2;
}

.summary-seam-options,
.summary-glue-options {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  align-items: end;
  margin-top: auto;
  min-height: 40px;
}

.summary-seam-option,
.summary-glue-option {
  display: flex;
  min-width: 0;
  flex-direction: column;
  justify-content: flex-end;
  align-items: center;
  gap: 4px;
  padding-right: 12px;
  text-align: center;
}

.summary-seam-option + .summary-seam-option,
.summary-glue-option + .summary-glue-option {
  padding-right: 0;
  padding-left: 12px;
  border-left: 1px solid var(--line);
}

.summary-seam-option span,
.summary-glue-option span {
  color: var(--muted);
  font-size: 12px;
  line-height: 1.2;
}

.summary-seam-option strong,
.summary-glue-option strong {
  white-space: nowrap;
}

.preview-grid {
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  gap: 16px;
}

.preview-card {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  overflow: hidden;
}

.preview-toolbar {
  display: flex;
  flex-wrap: nowrap;
  justify-content: space-between;
  gap: 6px;
  align-items: center;
  min-height: 52px;
  padding: 6px 8px;
  border-bottom: 1px solid var(--line);
  background: #fbfcfa;
}

.preview-tabs {
  display: flex;
  align-self: stretch;
  min-width: 0;
  gap: 4px;
}

.preview-tab {
  min-height: 40px;
  padding: 0 14px;
  border: 0;
  border-bottom: 2px solid transparent;
  background: transparent;
  color: var(--muted);
  font-size: 13px;
  font-weight: 700;
  white-space: nowrap;
}

.preview-tab:hover:not(:disabled) {
  color: var(--green);
}

.preview-tab[aria-selected="true"] {
  border-bottom-color: var(--green);
  color: var(--green);
}

.preview-tab:disabled {
  cursor: not-allowed;
  opacity: 0.5;
}

.preview-toolbar-title {
  color: var(--ink);
  font-size: 14px;
  font-weight: 700;
}

.preview-toolbar-controls {
  display: flex;
  flex-wrap: nowrap;
  flex: 0 0 auto;
  gap: 6px;
  align-items: center;
}

.preview-tool {
  min-width: 40px;
  height: 40px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: var(--surface);
  color: var(--ink);
  font-size: 12px;
  font-weight: 700;
}

.preview-tool:hover {
  border-color: var(--green);
}

.preview-tool[data-action="drag"] {
  min-width: 52px;
}

.preview-tool[aria-pressed="true"] {
  border-color: var(--green);
  background: var(--green);
  color: #fff;
}

.preview-viewport {
  display: flex;
  align-items: center;
  justify-content: center;
  height: clamp(440px, calc(100dvh - 390px), 760px);
  min-height: 440px;
  overflow: hidden;
  background: #eef1ec;
  touch-action: none;
}

.preview-viewport.is-drag-enabled {
  cursor: grab;
}

.preview-viewport.is-dragging {
  cursor: grabbing;
}

.preview-card img {
  display: block;
  width: auto;
  height: auto;
  max-width: 100%;
  max-height: 100%;
  object-fit: contain;
  transform-origin: center center;
  transition: transform 120ms ease-out;
  user-select: none;
  will-change: transform;
  cursor: zoom-in;
}

.preview-viewport.is-drag-enabled img {
  cursor: grab;
}

.preview-viewport.is-dragging img {
  cursor: grabbing;
}

.empty-state {
  grid-column: 1 / -1;
  width: 100%;
  padding: 28px 16px;
  border: 1px dashed var(--line);
  border-radius: 8px;
  background: #fcfdfb;
  color: var(--muted);
  text-align: center;
}

.legal-notice {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 8px;
  margin-top: 8px;
  color: var(--muted);
  font-size: 11px;
  line-height: 1.4;
  text-align: center;
}

.legal-notice a {
  color: inherit;
  text-decoration: none;
}

.legal-notice a:hover {
  text-decoration: underline;
}

@media (min-width: 1280px) {
  body:not(.auth-locked) .app-shell {
    width: min(1692px, calc(100vw - 100px));
    margin-right: auto;
    margin-left: max(16px, calc((100vw - 1760px) / 2));
  }

  .account-rail {
    width: 68px;
    position: fixed;
    top: 0;
    right: max(0px, calc((100vw - 1760px) / 2));
    bottom: 0;
    z-index: 45;
    flex-direction: column;
    align-items: flex-start;
    justify-content: flex-start;
    border-left: 1px solid var(--line);
    background: var(--surface);
  }

  .system-menu-button {
    width: 68px;
    min-height: 104px;
    flex-direction: column;
    justify-content: flex-start;
    gap: 8px;
    border: 0;
    border-radius: 0;
    padding: 16px 5px 10px;
  }

  .system-settings-shortcut {
    width: 68px;
    height: 58px;
    border: 0;
    border-radius: 0;
  }

  .system-menu-button:hover,
  .system-menu-button:focus-visible,
  .system-settings-shortcut:hover,
  .system-settings-shortcut:focus-visible {
    background: var(--surface-soft);
    box-shadow: inset 3px 0 0 var(--green);
  }

  .account-status-dot {
    top: 17px;
    left: 39px;
  }

  .account-trigger-label {
    color: var(--muted);
    font-size: 11px;
    line-height: 1.25;
    text-align: center;
  }

  .account-drawer {
    right: calc(max(0px, calc((100vw - 1760px) / 2)) + 68px);
  }

  .account-drawer-backdrop {
    right: max(0px, calc((100vw - 1760px) / 2));
  }
}

@media (max-width: 1279px) {
  .account-drawer {
    right: 0;
  }

  .account-drawer-backdrop {
    right: 0;
  }
}

@media (min-width: 980px) and (max-width: 1279px) {
  .workspace {
    grid-template-columns: minmax(330px, 360px) minmax(0, 1fr);
  }
}

@media (max-width: 979px) {
  .account-drawer {
    width: min(360px, 100vw);
  }
}

@media (min-width: 980px) {
  .workspace {
    height: max(680px, calc(100dvh - 96px));
    align-items: stretch;
  }

  .form-panel {
    height: 100%;
    max-height: none;
  }

  .result-panel {
    min-height: 0;
    grid-template-rows: auto minmax(0, 1fr);
  }

  .preview-panel {
    display: flex;
    min-height: 0;
    flex-direction: column;
  }

  .preview-grid {
    min-height: 0;
    flex: 1;
  }

  .preview-card {
    display: grid;
    height: 100%;
    min-height: 0;
    grid-template-rows: auto minmax(0, 1fr);
  }

  .preview-viewport {
    height: auto;
    min-height: 0;
  }
}

@media (max-width: 560px) {
  .marking-dimension-groups {
    grid-template-columns: minmax(0, 1fr);
  }

  .legal-notice {
    flex-direction: column;
    gap: 2px;
  }
}

@media (max-width: 1280px) {
  .summary-grid {
    grid-template-columns: repeat(6, minmax(0, 1fr));
  }

  .summary-item--metric {
    grid-column: span 2;
  }

  .summary-item--wide {
    grid-column: span 3;
    border-top: 1px solid var(--line);
  }

  .summary-item--wide:nth-child(4) {
    border-left: 0;
  }
}

.drawing-viewer {
  width: calc(100vw - 32px);
  max-width: none;
  height: calc(100dvh - 32px);
  max-height: none;
  margin: auto;
  padding: 0;
  border: 1px solid #c8cec4;
  border-radius: 8px;
  background: var(--surface);
  color: var(--ink);
  box-shadow: 0 18px 50px rgba(18, 28, 19, 0.2);
}

.drawing-viewer::backdrop {
  background: rgba(13, 21, 14, 0.68);
}

.shutdown-dialog {
  width: min(480px, calc(100vw - 32px));
  padding: 0;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
  color: var(--ink);
  box-shadow: 0 18px 50px rgba(18, 28, 19, 0.2);
}

.shutdown-dialog::backdrop {
  background: rgba(13, 21, 14, 0.58);
}

.shutdown-shell {
  display: grid;
  gap: 20px;
  padding: 22px;
}

.shutdown-shell h2 {
  margin-bottom: 10px;
  font-size: 20px;
}

.shutdown-shell p {
  margin-bottom: 0;
  color: var(--muted);
  font-size: 14px;
  line-height: 1.6;
}

.dialog-kicker {
  margin-bottom: 4px !important;
  color: var(--green) !important;
  font-size: 12px !important;
  font-weight: 700;
}

.dialog-error {
  margin-top: 12px !important;
  padding: 10px 12px;
  border: 1px solid rgba(163, 49, 35, 0.24);
  border-radius: 8px;
  background: rgba(163, 49, 35, 0.08);
  color: var(--red) !important;
}

.dialog-actions {
  display: flex;
  justify-content: flex-end;
  gap: 10px;
}

.dialog-actions button {
  min-width: 96px;
  min-height: 40px;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 0 14px;
  background: var(--surface);
  color: var(--ink);
  font-weight: 700;
}

.dialog-actions .danger {
  border-color: var(--red);
  background: var(--red);
  color: #fff;
}

.app-stopped .workspace {
  opacity: 0.62;
}

.auth-locked .legal-notice {
  margin-top: 0;
}

.viewer-shell {
  display: grid;
  grid-template-rows: auto minmax(0, 1fr);
  width: 100%;
  height: 100%;
}

.viewer-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 18px;
  padding: 12px 14px;
  border-bottom: 1px solid var(--line);
  background: #fbfcfa;
}

.viewer-header h2,
.viewer-kicker {
  margin-bottom: 0;
}

.viewer-kicker {
  color: var(--muted);
  font-size: 11px;
}

.viewer-toolbar {
  display: flex;
  flex-wrap: wrap;
  justify-content: flex-end;
  align-items: center;
  gap: 6px;
}

.viewer-toolbar button,
.viewer-action {
  min-width: 40px;
  min-height: 40px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border: 1px solid var(--line);
  border-radius: 6px;
  padding: 0 12px;
  background: var(--surface);
  color: var(--ink);
  font-size: 12px;
  font-weight: 700;
  line-height: 1;
  text-decoration: none;
}

.viewer-toolbar button:hover,
.viewer-action:hover {
  border-color: var(--green);
}

.viewer-toolbar button[aria-pressed="true"] {
  border-color: var(--green);
  background: var(--green);
  color: #fff;
}

.viewer-scale {
  min-width: 48px;
  color: var(--muted);
  font-size: 12px;
  font-variant-numeric: tabular-nums;
  text-align: center;
}

.viewer-toolbar .viewer-secondary {
  color: var(--muted);
}

.viewer-toolbar .viewer-close {
  padding: 0;
  font-size: 24px;
  font-weight: 400;
}

.viewer-viewport {
  min-width: 0;
  min-height: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: hidden;
  background: #e9ece7;
  touch-action: none;
}

.viewer-viewport img {
  display: block;
  max-width: 100%;
  max-height: 100%;
  object-fit: contain;
  transform-origin: center center;
  transition: transform 100ms ease-out;
  user-select: none;
  will-change: transform;
}

.viewer-viewport.is-drag-enabled {
  cursor: grab;
}

.viewer-viewport.is-dragging {
  cursor: grabbing;
}

@media (max-width: 979px) {
  .workspace {
    grid-template-columns: 1fr;
  }

  .form-panel {
    position: static;
    max-height: none;
    overflow: visible;
  }

  .form-footer {
    position: fixed;
    right: 10px;
    bottom: 0;
    left: 10px;
    z-index: 20;
    margin: 0;
    padding: 10px 12px calc(10px + env(safe-area-inset-bottom));
    border: 1px solid var(--line);
    border-bottom: 0;
    border-radius: 8px 8px 0 0;
    box-shadow: 0 -8px 18px rgba(30, 46, 31, 0.09);
  }

  body {
    padding-bottom: calc(112px + env(safe-area-inset-bottom));
  }

  body.auth-locked {
    padding-bottom: 0;
  }

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

  .preview-viewport {
    height: clamp(360px, 65dvh, 640px);
    min-height: 360px;
  }
}

@media (max-width: 760px) {
  .app-shell {
    width: calc(100vw - 20px);
  }

  .drawing-viewer {
    width: 100vw;
    height: 100dvh;
    border: 0;
    border-radius: 0;
  }

  .viewer-header {
    align-items: flex-start;
    padding: 10px;
  }

  .viewer-header > div:first-child {
    min-width: 90px;
  }

  .viewer-toolbar {
    gap: 4px;
  }

  .viewer-toolbar button,
  .viewer-action {
    padding: 0 9px;
  }
}

@media (max-width: 560px) {
  .auth-panel {
    min-height: calc(100dvh - 72px);
    padding: var(--space-4) 0 32px;
  }

  .auth-card {
    padding: var(--space-5);
  }

  .grid.two,
  .grid.three,
  .grid.four {
    grid-template-columns: 1fr;
  }

  .line-embedding-options {
    grid-template-columns: 1fr;
  }

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

  .summary-item--metric,
  .summary-item--wide {
    grid-column: auto;
  }

  .summary-item + .summary-item,
  .summary-item--wide {
    border-top: 1px solid var(--line);
    border-left: 0;
  }

  .preview-viewport {
    height: min(62dvh, 480px);
    min-height: 300px;
  }

  .section-heading {
    flex-direction: column;
    align-items: flex-start;
  }

  .topbar {
    align-items: flex-start;
  }

  .app-identity {
    gap: 8px;
  }

  .app-logo {
    width: 58px;
    height: 34px;
  }

  .app-title-row {
    align-items: flex-start;
    flex-direction: column;
    gap: 2px;
  }

  .app-controls {
    flex-direction: column;
    align-items: flex-end;
  }

  .system-menu-button {
    width: 42px;
    min-width: 42px;
    justify-content: center;
    padding: 4px;
  }

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

  .shutdown-hint {
    max-width: 120px;
    text-align: right;
  }

  .stopped-panel {
    align-items: flex-start;
    flex-direction: column;
  }
}

@media (max-width: 420px) {
  .account-drawer {
    width: 100%;
  }

  .account-drawer-header {
    padding-right: 12px;
    padding-left: 12px;
  }

  .account-drawer-content {
    padding-right: 8px;
    padding-left: 8px;
  }

  .account-drawer-group button {
    min-height: 58px;
  }

  .preview-toolbar {
    flex-wrap: wrap;
  }

  .preview-tabs,
  .preview-toolbar-controls {
    width: 100%;
  }

  .preview-toolbar-controls {
    justify-content: flex-end;
  }
}

@media (max-width: 360px) {
  .summary-seam-options,
  .summary-glue-options {
    grid-template-columns: 1fr;
    gap: 10px;
  }

  .summary-seam-option,
  .summary-glue-option {
    padding: 0 0 10px;
  }

  .summary-seam-option + .summary-seam-option,
  .summary-glue-option + .summary-glue-option {
    padding: 10px 0 0;
    border-top: 1px solid var(--line);
    border-left: 0;
  }
}

.visually-hidden {
  width: 1px;
  height: 1px;
  position: absolute;
  overflow: hidden;
  margin: -1px;
  padding: 0;
  border: 0;
  clip: rect(0 0 0 0);
  clip-path: inset(50%);
  white-space: nowrap;
}

/* Stage 9: shared dialog surface, scrolling, actions, and focus treatment. */
.account-dialog,
.shutdown-dialog {
  max-height: min(820px, calc(100dvh - 32px));
  overflow: hidden;
  border-color: var(--line-strong);
  border-radius: var(--radius-panel);
  box-shadow: var(--shadow-overlay);
}

#settings-dialog {
  width: min(680px, calc(100vw - 28px));
}

#about-dialog {
  width: min(560px, calc(100vw - 28px));
}

.trim-shipping-dialog {
  width: min(620px, calc(100vw - 28px));
}

.drawing-frame-template-dialog {
  width: min(960px, calc(100vw - 28px));
}

.turf-color-dialog {
  width: min(760px, calc(100vw - 28px));
}

.account-dialog::backdrop,
.shutdown-dialog::backdrop {
  background: rgba(17, 25, 18, 0.48);
}

.account-shell {
  max-height: min(820px, calc(100dvh - 32px));
  gap: 14px;
  overflow-y: auto;
  overscroll-behavior: contain;
  padding: 0 18px 18px;
}

.account-shell > .dialog-header {
  position: sticky;
  top: 0;
  z-index: 2;
  margin: 0 -18px;
  padding: 14px 18px;
  border-bottom: 1px solid var(--line);
  background: rgba(255, 255, 255, 0.98);
}

.dialog-header h2 {
  margin-bottom: 0;
  font-size: 18px;
}

.dialog-header button {
  width: 38px;
  height: 38px;
  border-radius: var(--radius-control);
  font-weight: 400;
}

.account-shell > section {
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 14px;
  background: var(--surface-quiet);
}

.account-shell > section h3 {
  margin-bottom: 12px;
}

.account-shell > section > button {
  min-height: 42px;
  border-radius: var(--radius-control);
}

.trim-shipping-options {
  display: grid;
  gap: 10px;
  margin: 0;
  border: 0;
  padding: 0;
}

.trim-shipping-option {
  display: grid;
  grid-template-columns: auto 1fr;
  align-items: start;
  gap: 10px;
  border: 1px solid var(--line);
  border-radius: 9px;
  padding: 12px;
  background: var(--surface);
  cursor: pointer;
}

.trim-shipping-option:has(input:checked) {
  border-color: var(--green);
  box-shadow: inset 3px 0 0 var(--green);
  background: rgba(47, 107, 53, 0.05);
}

.trim-shipping-option input {
  margin-top: 3px;
}

.trim-shipping-option span {
  display: grid;
  gap: 4px;
}

.trim-shipping-option strong {
  font-size: 14px;
}

.trim-shipping-option small,
.trim-shipping-scope,
.trim-shipping-permission {
  color: var(--muted);
  font-size: 12px;
  line-height: 1.55;
}

.trim-shipping-scope {
  margin: 12px 0 0;
  border-left: 3px solid var(--line-strong);
  padding-left: 10px;
}

.trim-shipping-permission {
  margin: 10px 0 0;
  color: var(--red);
  font-weight: 700;
}

.drawing-frame-template-options {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 12px;
  margin: 0;
  border: 0;
  padding: 0;
}

.drawing-frame-template-draft-status {
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  gap: 4px;
  margin: 0 0 12px;
  border: 1px solid var(--line);
  border-radius: 9px;
  padding: 9px 11px;
  background: var(--surface-soft);
  color: var(--muted);
  font-size: 12px;
  line-height: 1.5;
}

.drawing-frame-template-draft-status strong {
  color: var(--ink);
  font-size: 13px;
}

.drawing-frame-template-option {
  display: grid;
  grid-template-columns: auto minmax(0, 1fr);
  align-items: start;
  gap: 10px;
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 12px;
  background: var(--surface);
  cursor: pointer;
}

.drawing-frame-template-option:has(input:checked) {
  border-color: var(--green);
  background: rgba(47, 107, 53, 0.05);
  box-shadow: inset 3px 0 0 var(--green);
}

.drawing-frame-template-option:has(input:disabled) {
  cursor: default;
}

.drawing-frame-template-option > input {
  margin-top: 3px;
}

.drawing-frame-template-option__body,
.drawing-frame-template-option__copy {
  min-width: 0;
  display: grid;
}

.drawing-frame-template-option__body {
  gap: 10px;
}

.drawing-frame-template-option__body img {
  width: 100%;
  aspect-ratio: 297 / 210;
  display: block;
  object-fit: contain;
  border: 1px solid var(--line);
  border-radius: 7px;
  background: #fff;
}

.drawing-frame-template-option__copy {
  gap: 4px;
}

.drawing-frame-template-option__copy strong {
  font-size: 14px;
}

.drawing-frame-template-option__copy small,
.drawing-frame-template-scope {
  color: var(--muted);
  font-size: 12px;
  line-height: 1.55;
}

.drawing-frame-template-scope {
  margin: 12px 0 0;
  border-left: 3px solid var(--line-strong);
  padding-left: 10px;
}

.drawing-frame-template-quick-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 12px;
}

.turf-color-scope {
  margin: 0 0 12px;
  color: var(--muted);
  font-size: 12px;
  line-height: 1.6;
}

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

.turf-color-card {
  display: grid;
  gap: 12px;
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 12px;
  background: var(--surface);
}

.turf-color-card header {
  display: flex;
  align-items: center;
  gap: 10px;
}

.turf-color-preview {
  display: inline-block;
  flex: 0 0 auto;
  width: 28px;
  height: 28px;
  border: 1px solid rgba(17, 25, 18, 0.26);
  border-radius: 8px;
  background: transparent;
  box-shadow: inset 0 0 0 1px rgba(255, 255, 255, 0.34);
}

.turf-color-inputs {
  display: grid;
  grid-template-columns: 48px minmax(0, 1fr);
  gap: 8px;
}

.turf-color-inputs input[type="color"] {
  width: 48px;
  height: 42px;
  border: 1px solid var(--line-strong);
  border-radius: var(--radius-control);
  padding: 4px;
  background: var(--surface);
  cursor: pointer;
}

.turf-color-inputs label,
.turf-color-inputs input[type="text"] {
  width: 100%;
}

.turf-eyedropper-button {
  grid-column: 1 / -1;
  min-height: 40px;
}

.turf-color-warning {
  margin-top: 12px;
  border-left: 3px solid #b87916;
  padding: 8px 10px;
  color: #79520f;
  font-size: 12px;
  line-height: 1.55;
  background: rgba(184, 121, 22, 0.08);
}

.turf-color-quick-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 12px;
}

.turf-color-quick-actions button {
  min-height: 40px;
}

.about-content p {
  margin-bottom: 10px;
  color: var(--muted);
  line-height: 1.65;
}

.about-content p:last-child {
  margin-bottom: 0;
}

.shutdown-shell {
  gap: 18px;
  padding: 24px;
}

.dialog-actions {
  padding-top: 14px;
  border-top: 1px solid var(--line);
}

.dialog-actions button {
  min-height: 42px;
  border-radius: var(--radius-control);
}

.drawing-viewer {
  border-color: var(--line-strong);
  border-radius: var(--radius-panel);
  box-shadow: var(--shadow-overlay);
}

.viewer-header {
  min-height: 64px;
  padding: 10px 14px;
  background: var(--surface);
}

.viewer-toolbar button,
.viewer-action {
  border-radius: var(--radius-control);
}

@media (min-width: 980px) and (max-width: 1279px) {
  .summary-grid {
    grid-template-columns:
      minmax(88px, 1fr)
      minmax(94px, 1fr)
      minmax(78px, 0.82fr)
      minmax(180px, 1.5fr)
      minmax(230px, 1.9fr);
  }
}

@media (min-width: 980px) and (max-width: 1099px) {
  .summary-grid {
    grid-template-columns: repeat(6, minmax(0, 1fr));
  }
}

@media (min-width: 1100px) and (max-width: 1280px) {
  .summary-grid {
    grid-template-columns:
      minmax(76px, 1fr)
      minmax(82px, 1fr)
      minmax(68px, 0.78fr)
      minmax(168px, 1.48fr)
      minmax(210px, 1.82fr);
  }

  .summary-item--metric,
  .summary-item--wide {
    grid-column: auto;
  }

  .summary-item--wide {
    border-top: 0;
  }

  .summary-item--wide:nth-child(4) {
    border-left: 1px solid var(--line);
  }
}

@media (max-width: 979px) {
  .summary-grid {
    grid-template-columns: repeat(6, minmax(0, 1fr));
  }

  .summary-item--metric {
    grid-column: span 2;
  }

  .summary-item--wide {
    grid-column: span 3;
  }
}

@media (min-width: 701px) and (max-width: 899px) {
  .drawing-frame-template-options {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
}

@media (max-width: 700px) {
  .summary-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .summary-item--metric,
  .summary-item--wide {
    grid-column: auto;
  }

  .summary-item--wide:last-child {
    grid-column: 1 / -1;
  }

  .account-grid {
    grid-template-columns: minmax(0, 1fr);
  }

  .user-row {
    grid-template-columns: minmax(0, 1fr);
  }

  .account-dialog,
  #settings-dialog,
  #about-dialog,
  .drawing-frame-template-dialog,
  .turf-color-dialog,
  .shutdown-dialog {
    width: calc(100vw - 20px);
    max-height: calc(100dvh - 20px);
  }

  .account-shell {
    max-height: calc(100dvh - 20px);
    padding-right: 12px;
    padding-bottom: 12px;
    padding-left: 12px;
  }

  .account-shell > .dialog-header {
    margin-right: -12px;
    margin-left: -12px;
    padding-right: 12px;
    padding-left: 12px;
  }

  .turf-color-grid {
    grid-template-columns: minmax(0, 1fr);
  }

  .drawing-frame-template-options {
    grid-template-columns: minmax(0, 1fr);
  }

}

@media (max-width: 560px) {
  .summary-grid {
    grid-template-columns: minmax(0, 1fr);
  }

  .summary-item--wide:last-child {
    grid-column: auto;
  }

  .summary-glue-options {
    grid-template-columns: minmax(0, 1fr);
    gap: 8px;
  }

  .summary-glue-option,
  .summary-glue-option + .summary-glue-option {
    padding: 0;
    border-left: 0;
  }

  .summary-glue-option + .summary-glue-option {
    padding-top: 8px;
    border-top: 1px solid var(--line);
  }

  .dialog-actions {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .dialog-actions button {
    min-width: 0;
  }

  .drawing-frame-template-quick-actions button {
    width: 100%;
  }
}
