:root {
  color-scheme: light;
  --ink: #232522;
  --muted: #73766f;
  --line: rgba(50, 54, 47, 0.1);
  --panel: rgba(255, 255, 255, 0.84);
  --panel-strong: rgba(255, 255, 255, 0.94);
  --cream: #f5f1ea;
  --sage: #dfe7dc;
  --clay: #d99873;
  --mint: #9ec8b9;
  --sky: #b8cfdf;
  --shadow: 0 20px 60px rgba(65, 71, 58, 0.12);
  --soft-shadow: 0 10px 28px rgba(55, 61, 49, 0.09);
  --radius: 20px;
  --radius-sm: 8px;
}

* {
  box-sizing: border-box;
}

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

body {
  margin: 0;
  overflow-x: hidden;
  background:
    radial-gradient(circle at 12% 12%, rgba(184, 207, 223, 0.62), transparent 30rem),
    radial-gradient(circle at 84% 18%, rgba(217, 152, 115, 0.22), transparent 26rem),
    linear-gradient(135deg, #f6f2eb 0%, #eef3ee 46%, #edf1f5 100%);
  color: var(--ink);
  font-family: Inter, "SF Pro Display", "Segoe UI", "PingFang SC", "Microsoft YaHei", Arial, sans-serif;
  letter-spacing: 0;
}

body::before {
  content: "";
  position: fixed;
  inset: 0;
  z-index: -2;
  pointer-events: none;
  opacity: 0.56;
  background-image:
    linear-gradient(rgba(35, 37, 34, 0.028) 1px, transparent 1px),
    linear-gradient(90deg, rgba(35, 37, 34, 0.024) 1px, transparent 1px);
  background-size: 28px 28px;
  mask-image: linear-gradient(to bottom, rgba(0, 0, 0, 0.9), transparent 78%);
}

button,
input,
select {
  font: inherit;
}

button {
  cursor: pointer;
}

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

svg {
  width: 18px;
  height: 18px;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.9;
  stroke-linecap: round;
  stroke-linejoin: round;
}

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

.glass {
  border: 1px solid rgba(255, 255, 255, 0.7);
  background: var(--panel);
  box-shadow: var(--shadow);
  backdrop-filter: blur(12px) saturate(120%);
  -webkit-backdrop-filter: blur(12px) saturate(120%);
}

.topbar {
  position: sticky;
  top: 12px;
  z-index: 20;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  min-height: 72px;
  padding: 12px 14px;
  border-radius: var(--radius);
}

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

.brand-mark {
  width: 46px;
  height: 46px;
  object-fit: contain;
  border-radius: 14px;
  background: rgba(255, 255, 255, 0.55);
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.85), 0 12px 22px rgba(82, 89, 73, 0.12);
  padding: 5px;
}

.brand strong,
.brand small {
  display: block;
  white-space: nowrap;
}

.brand strong {
  font-size: 18px;
  line-height: 1.2;
  font-weight: 760;
}

.brand small {
  margin-top: 2px;
  color: var(--muted);
  font-size: 12px;
}

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

.account-chip {
  display: inline-flex;
  align-items: center;
  min-height: 38px;
  padding: 0 12px;
  border: 1px solid rgba(50, 54, 47, 0.1);
  border-radius: var(--radius-sm);
  background: rgba(255, 255, 255, 0.72);
  color: var(--ink);
  font-size: 12px;
  font-weight: 800;
  text-decoration: none;
  box-shadow: var(--soft-shadow), inset 0 1px 0 rgba(255, 255, 255, 0.82);
  white-space: nowrap;
}

.icon-button,
.wide-button,
.square-button,
.export-grid button,
.text-button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  border: 1px solid rgba(255, 255, 255, 0.72);
  border-radius: var(--radius-sm);
  background: rgba(255, 255, 255, 0.72);
  color: var(--ink);
  box-shadow: var(--soft-shadow), inset 0 1px 0 rgba(255, 255, 255, 0.82);
  transition: transform 0.16s ease, box-shadow 0.16s ease, background 0.16s ease;
}

.icon-button {
  min-height: 44px;
  padding: 0 14px;
  font-weight: 700;
}

.icon-button:hover,
.wide-button:hover,
.square-button:hover,
.export-grid button:hover,
.text-button:hover {
  transform: translateY(-1px);
  background: rgba(255, 255, 255, 0.88);
}

.icon-button.primary,
.wide-button.primary {
  border-color: rgba(72, 117, 98, 0.22);
  background: linear-gradient(180deg, #4f8d73, #39745d);
  color: #fff;
  box-shadow: 0 14px 28px rgba(57, 116, 93, 0.22), inset 0 1px 0 rgba(255, 255, 255, 0.28);
}

.icon-button.dark {
  border-color: rgba(35, 37, 34, 0.14);
  background: linear-gradient(180deg, #2f332f, #20231f);
  color: #fff;
  box-shadow: 0 14px 28px rgba(35, 37, 34, 0.18), inset 0 1px 0 rgba(255, 255, 255, 0.18);
}

.workspace {
  display: grid;
  grid-template-columns: minmax(286px, 330px) minmax(0, 1fr) minmax(272px, 312px);
  gap: 14px;
  height: calc(100vh - 104px);
  min-height: 620px;
  padding-top: 14px;
}

.panel,
.stage-panel,
.canvas-wrap {
  min-height: 0;
  min-width: 0;
}

.panel {
  overflow: auto;
  border-radius: var(--radius);
  padding: 14px;
}

.controls-panel,
.inspector-panel {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.stage-panel {
  display: grid;
  grid-template-rows: auto minmax(0, 1fr);
  gap: 12px;
}

.canvas-toolbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  min-height: 66px;
  padding: 11px 12px 11px 16px;
  border-radius: var(--radius);
}

.status-stack {
  min-width: 0;
}

.status-stack strong,
.status-stack span {
  display: block;
}

.status-stack strong {
  font-size: 16px;
  font-weight: 760;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.status-stack span {
  margin-top: 2px;
  color: var(--muted);
  font-size: 12px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.canvas-wrap {
  position: relative;
  min-height: 0;
  overflow: hidden;
  border-radius: var(--radius);
  background:
    linear-gradient(rgba(255, 255, 255, 0.88), rgba(255, 255, 255, 0.72)),
    radial-gradient(circle at 30% 12%, rgba(158, 200, 185, 0.24), transparent 22rem);
}

#patternCanvas {
  width: 100%;
  height: 100%;
  display: block;
  margin: 0 auto;
}

.empty-state {
  position: absolute;
  inset: 0;
  display: grid;
  place-items: center;
  align-content: center;
  gap: 14px;
  padding: 24px;
  text-align: center;
  pointer-events: none;
}

.empty-state.hidden {
  display: none;
}

.busy-overlay {
  position: absolute;
  inset: 0;
  z-index: 4;
  display: grid;
  place-items: center;
  padding: 20px;
  background: rgba(247, 243, 236, 0.58);
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
}

.busy-overlay.hidden {
  display: none;
}

.busy-card {
  display: grid;
  justify-items: center;
  gap: 9px;
  min-width: 220px;
  max-width: min(320px, 80vw);
  padding: 18px 20px;
  border: 1px solid rgba(255, 255, 255, 0.76);
  border-radius: 16px;
  background: rgba(255, 255, 255, 0.86);
  box-shadow: 0 18px 44px rgba(48, 56, 44, 0.16), inset 0 1px 0 rgba(255, 255, 255, 0.86);
  text-align: center;
}

.busy-card strong {
  font-size: 15px;
  font-weight: 820;
}

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

.busy-dots {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  min-height: 18px;
}

.busy-dots i {
  width: 9px;
  height: 9px;
  border-radius: 50%;
  background: #39745d;
  opacity: 0.36;
  animation: busyDot 0.84s ease-in-out infinite;
}

.busy-dots i:nth-child(2) {
  animation-delay: 0.14s;
}

.busy-dots i:nth-child(3) {
  animation-delay: 0.28s;
}

@keyframes busyDot {
  0%,
  100% {
    opacity: 0.28;
  }

  45% {
    opacity: 1;
  }
}

.empty-state strong {
  font-size: clamp(22px, 3vw, 34px);
  line-height: 1.15;
  font-weight: 820;
}

.empty-state p {
  max-width: 440px;
  margin: 0;
  color: var(--muted);
  font-size: 14px;
}

.preview-grid {
  display: grid;
  grid-template-columns: repeat(6, 18px);
  gap: 7px;
  padding: 18px;
  border-radius: 18px;
  background: rgba(255, 255, 255, 0.42);
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.7), 0 18px 40px rgba(64, 71, 58, 0.1);
}

.preview-grid span {
  width: 18px;
  height: 18px;
  border-radius: 50%;
  background: var(--mint);
  box-shadow: inset -4px -5px 8px rgba(56, 68, 60, 0.16), inset 3px 3px 6px rgba(255, 255, 255, 0.55);
}

.preview-grid span:nth-child(3n) {
  background: var(--clay);
}

.preview-grid span:nth-child(4n) {
  background: var(--sky);
}

.drop-zone,
.control-group,
.metric-grid > div {
  border: 1px solid rgba(255, 255, 255, 0.72);
  border-radius: 16px;
  background: rgba(255, 255, 255, 0.52);
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.7);
}

.drop-zone {
  display: grid;
  place-items: center;
  gap: 8px;
  min-height: 164px;
  padding: 18px;
  text-align: center;
}

.drop-zone.is-dragging {
  outline: 2px solid rgba(57, 116, 93, 0.42);
  background: rgba(255, 255, 255, 0.78);
}

.drop-zone strong {
  font-size: 16px;
  font-weight: 780;
}

.drop-zone span {
  max-width: 230px;
  color: var(--muted);
  font-size: 12px;
  line-height: 1.55;
}

.drop-orbit {
  display: grid;
  place-items: center;
  width: 60px;
  height: 60px;
  border-radius: 50%;
  background:
    linear-gradient(180deg, rgba(255, 255, 255, 0.95), rgba(255, 255, 255, 0.48)),
    linear-gradient(135deg, rgba(158, 200, 185, 0.34), rgba(217, 152, 115, 0.18));
  color: #39745d;
  box-shadow: 0 14px 28px rgba(57, 116, 93, 0.14), inset 0 1px 0 rgba(255, 255, 255, 0.9);
}

.control-group {
  padding: 14px;
}

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

.section-title span {
  font-size: 13px;
  font-weight: 800;
}

.field-label {
  display: grid;
  gap: 7px;
  color: var(--muted);
  font-size: 12px;
}

select,
input[type="number"],
input[type="text"],
input[type="password"] {
  width: 100%;
  min-height: 42px;
  border: 1px solid rgba(50, 54, 47, 0.1);
  border-radius: var(--radius-sm);
  background: rgba(255, 255, 255, 0.7);
  color: var(--ink);
  padding: 0 12px;
  outline: none;
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.85);
}

select:focus,
input:focus {
  border-color: rgba(57, 116, 93, 0.46);
}

.palette-meta {
  margin-top: 10px;
  padding: 9px 10px;
  border-radius: 10px;
  background: rgba(255, 255, 255, 0.48);
  color: var(--ink);
  font-size: 12px;
  font-weight: 760;
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.72);
}

.palette-meta.is-warning {
  border: 1px solid rgba(180, 83, 9, 0.28);
  background: rgba(255, 247, 237, 0.86);
  color: #92400e;
}

.palette-groups {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-top: 10px;
}

.palette-group-chip {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  max-width: 100%;
  min-height: 26px;
  padding: 0 8px;
  border: 1px solid rgba(50, 54, 47, 0.08);
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.42);
  color: var(--muted);
  cursor: pointer;
  font-family: inherit;
  font-size: 11px;
  font-weight: 760;
  white-space: nowrap;
}

.palette-group-chip em {
  font-style: normal;
  color: var(--ink);
  font-variant-numeric: tabular-nums;
}

.palette-group-chip.active {
  border-color: rgba(57, 116, 93, 0.24);
  background: rgba(219, 235, 225, 0.72);
  color: #2f6f59;
}

.palette-group-chip.warning {
  border-color: rgba(180, 83, 9, 0.22);
  background: rgba(255, 247, 237, 0.72);
  color: #92400e;
}

.palette-group-chip:hover {
  border-color: rgba(57, 116, 93, 0.2);
  background: rgba(255, 255, 255, 0.68);
}

.dual-input {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
}

.dual-input label {
  display: grid;
  gap: 6px;
}

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

.range-row {
  display: grid;
  grid-template-columns: 72px minmax(0, 1fr) 42px;
  align-items: center;
  gap: 10px;
  margin-top: 12px;
  color: var(--muted);
  font-size: 12px;
}

.range-row output {
  color: var(--ink);
  font-variant-numeric: tabular-nums;
  text-align: right;
}

input[type="range"] {
  width: 100%;
  accent-color: #4f8d73;
}

.segmented {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 4px;
  margin-top: 12px;
  padding: 4px;
  border-radius: 12px;
  background: rgba(43, 47, 41, 0.06);
}

.segmented input {
  position: absolute;
  opacity: 0;
  pointer-events: none;
}

.segmented label {
  min-width: 0;
  min-height: 34px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border-radius: 8px;
  color: var(--muted);
  font-size: 12px;
  font-weight: 720;
}

.segmented input:checked + label {
  background: rgba(255, 255, 255, 0.88);
  color: var(--ink);
  box-shadow: 0 8px 18px rgba(55, 61, 49, 0.08), inset 0 1px 0 #fff;
}

.switch,
.check-row {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  color: var(--muted);
  font-size: 12px;
  user-select: none;
}

.switch.wide,
.check-row {
  width: 100%;
  margin-top: 12px;
}

.switch input,
.check-row input {
  accent-color: #4f8d73;
}

.switch input {
  position: absolute;
  opacity: 0;
}

.switch span {
  position: relative;
  width: 34px;
  height: 20px;
  flex: 0 0 auto;
  border-radius: 999px;
  background: rgba(43, 47, 41, 0.14);
  transition: background 0.16s ease;
}

.switch span::after {
  content: "";
  position: absolute;
  top: 3px;
  left: 3px;
  width: 14px;
  height: 14px;
  border-radius: 50%;
  background: #fff;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.14);
  transition: transform 0.16s ease;
}

.switch input:checked + span {
  background: #4f8d73;
}

.switch input:checked + span::after {
  transform: translateX(14px);
}

.wide-button {
  min-height: 46px;
  width: 100%;
  font-weight: 800;
}

.square-button {
  width: 36px;
  height: 36px;
  padding: 0;
  font-size: 18px;
  font-weight: 700;
}

.zoom-label {
  display: inline-grid;
  grid-template-columns: minmax(90px, 140px) 48px;
  align-items: center;
  gap: 8px;
  color: var(--muted);
  font-size: 12px;
}

.metric-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 8px;
}

.metric-grid > div {
  min-height: 76px;
  padding: 13px;
}

.metric-grid span,
.metric-grid strong {
  display: block;
}

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

.metric-grid strong {
  margin-top: 7px;
  font-size: 22px;
  line-height: 1;
  font-weight: 820;
  font-variant-numeric: tabular-nums;
}

.legend-section {
  min-height: 236px;
}

.legend-list {
  display: grid;
  gap: 7px;
  max-height: 220px;
  overflow: auto;
  padding-right: 2px;
}

.legend-item {
  display: grid;
  grid-template-columns: 58px minmax(0, 1fr) auto;
  align-items: center;
  gap: 9px;
  min-height: 44px;
  padding: 7px 8px;
  border-radius: 10px;
  background: rgba(255, 255, 255, 0.9);
  border: 1px solid rgba(35, 37, 34, 0.06);
}

.swatch {
  display: grid;
  place-items: center;
  width: 58px;
  height: 30px;
  border-radius: 7px;
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.7), inset -4px -5px 8px rgba(0, 0, 0, 0.16);
  border: 1px solid rgba(35, 37, 34, 0.08);
  overflow: hidden;
  padding: 0 3px;
  font-family: ui-monospace, SFMono-Regular, Consolas, "Microsoft YaHei", monospace;
  font-size: 10px;
  font-weight: 900;
  line-height: 1;
  text-align: center;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.legend-name {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  font-size: 12px;
  font-weight: 820;
}

.legend-count {
  color: #343831;
  font-size: 12px;
  font-weight: 760;
  font-variant-numeric: tabular-nums;
}

.hint-row {
  min-height: 80px;
  display: grid;
  place-items: center;
  border-radius: 12px;
  color: var(--muted);
  background: rgba(255, 255, 255, 0.38);
  font-size: 12px;
  text-align: center;
  padding: 14px;
}

.text-button {
  min-height: 28px;
  padding: 0 10px;
  font-size: 12px;
  font-weight: 760;
}

.export-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
}

.export-grid button {
  min-height: 40px;
  padding: 0 10px;
  font-size: 12px;
  font-weight: 760;
}

.server-export-result {
  margin-top: 10px;
  padding: 10px;
  border-radius: 12px;
  background: rgba(255, 255, 255, 0.62);
  color: var(--muted);
  font-size: 12px;
  line-height: 1.5;
  word-break: break-all;
}

.server-export-result.hidden {
  display: none;
}

.server-export-result a {
  display: inline-flex;
  align-items: center;
  min-height: 32px;
  margin-top: 6px;
  padding: 0 10px;
  border-radius: 10px;
  background: #222520;
  color: #fff;
  font-weight: 800;
  text-decoration: none;
}

.export-modal {
  position: fixed;
  inset: 0;
  z-index: 60;
  display: grid;
  place-items: center;
  padding: 18px;
  background: rgba(35, 37, 34, 0.26);
}

.export-modal.hidden {
  display: none;
}

.export-modal-card {
  position: relative;
  display: grid;
  gap: 12px;
  width: min(460px, calc(100vw - 36px));
  padding: 22px;
  border-radius: 18px;
  background: rgba(255, 255, 255, 0.94);
  color: var(--ink);
}

.export-modal-card strong {
  padding-right: 34px;
  font-size: 18px;
  line-height: 1.25;
  font-weight: 840;
}

.export-modal-card p {
  margin: 0;
  color: var(--muted);
  font-size: 13px;
  line-height: 1.65;
}

.export-modal-note {
  padding: 12px;
  border-radius: 12px;
  background: rgba(245, 241, 234, 0.84);
  border: 1px solid rgba(50, 54, 47, 0.08);
}

.activation-panel {
  display: grid;
  gap: 14px;
}

.activation-panel.hidden {
  display: none;
}

.activation-panel label {
  display: grid;
  gap: 10px;
  color: var(--muted);
  font-size: 13px;
  font-weight: 800;
}

.activation-panel input {
  min-height: 54px;
  font-size: 15px;
  font-weight: 760;
}

.activation-message {
  padding: 10px 12px;
  border-radius: 10px;
  background: rgba(245, 241, 234, 0.84);
  color: var(--muted);
  font-size: 12px;
  line-height: 1.5;
}

.activation-message.hidden {
  display: none;
}

.activation-message.success {
  background: rgba(220, 252, 231, 0.86);
  color: #166534;
}

.activation-message.error {
  background: rgba(254, 226, 226, 0.86);
  color: #991b1b;
}

.export-modal-actions {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
}

.export-modal-actions.hidden,
.export-modal-note.hidden {
  display: none;
}

.export-modal-link {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  grid-column: 1 / -1;
  min-height: 42px;
  padding: 0 14px;
  border-radius: var(--radius-sm);
  background: #222520;
  color: #fff;
  font-size: 13px;
  font-weight: 820;
  text-decoration: none;
}

.export-modal-cancel {
  background: rgba(255, 255, 255, 0.76);
  color: var(--ink);
  border-color: rgba(50, 54, 47, 0.1);
}

.export-modal-link.hidden {
  display: none;
}

.export-modal-close {
  position: absolute;
  top: 12px;
  right: 12px;
  width: 32px;
  height: 32px;
  border: 0;
  border-radius: 50%;
  background: rgba(35, 37, 34, 0.08);
  color: var(--ink);
  font-size: 22px;
  line-height: 1;
  box-shadow: none;
}

.palette-strip {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(24px, 1fr));
  gap: 7px;
  max-height: 178px;
  overflow: auto;
}

.palette-dot {
  min-height: 24px;
  border-radius: 50%;
  border: 1px solid rgba(35, 37, 34, 0.08);
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.58), inset -4px -5px 8px rgba(0, 0, 0, 0.14);
}

@media (max-width: 1180px) {
  .workspace {
    grid-template-columns: 300px minmax(0, 1fr);
    height: auto;
    min-height: 0;
  }

  .stage-panel {
    min-height: 680px;
  }

  .inspector-panel {
    grid-column: 1 / -1;
    display: grid;
    grid-template-columns: 1fr 1fr;
  }

  .metric-grid,
  .legend-section {
    grid-column: span 1;
  }
}

@media (max-width: 760px) {
  html {
    scroll-behavior: auto !important;
    overscroll-behavior: none;
  }

  body {
    overscroll-behavior: none;
    touch-action: manipulation;
  }

  *,
  *::before,
  *::after {
    animation: none !important;
    transition: none !important;
    transform: none !important;
    scroll-behavior: auto !important;
    caret-color: auto;
  }

  .app-shell {
    padding: 10px;
    max-width: 100vw;
    overflow: hidden;
  }

  .glass {
    background: rgba(255, 255, 255, 0.94);
    backdrop-filter: none;
    -webkit-backdrop-filter: none;
    box-shadow: 0 8px 22px rgba(65, 71, 58, 0.08);
  }

  .icon-button,
  .wide-button,
  .square-button,
  .export-grid button,
  .text-button,
  .palette-group-chip,
  .palette-dot,
  .drop-zone,
  .preview-grid span,
  .switch span,
  .switch span::after {
    transition: none !important;
  }

  .icon-button:hover,
  .wide-button:hover,
  .square-button:hover,
  .export-grid button:hover,
  .text-button:hover,
  .palette-group-chip:hover,
  .drop-zone:hover {
    transform: none !important;
    box-shadow: inherit;
  }

  .drop-zone.is-dragging {
    background: rgba(255, 255, 255, 0.5);
    transform: none !important;
  }

  .topbar {
    position: static;
    min-height: auto;
    align-items: center;
    justify-content: space-between;
    padding: 10px;
    gap: 8px;
    width: calc(100vw - 20px);
  }

  .brand {
    flex: 1 1 auto;
    gap: 8px;
    min-width: 0;
  }

  .brand strong {
    max-width: none;
    overflow: visible;
    text-overflow: clip;
    white-space: normal;
    font-size: 15px;
    line-height: 1.15;
  }

  .brand small {
    display: none;
  }

  .brand-mark {
    width: 36px;
    height: 36px;
    flex: 0 0 36px;
  }

  .top-actions {
    gap: 5px;
    flex: 0 0 auto;
  }

  .icon-button {
    width: 38px;
    min-height: 38px;
    padding: 0;
  }

  .account-chip {
    min-height: 38px;
    padding: 0 8px;
    font-size: 11px;
  }

  .icon-button span {
    position: absolute;
    width: 1px;
    height: 1px;
    overflow: hidden;
    clip: rect(0, 0, 0, 0);
  }

  .workspace {
    grid-template-columns: 1fr;
    padding-top: 10px;
    width: calc(100vw - 20px);
    max-width: calc(100vw - 20px);
  }

  .stage-panel {
    min-height: 520px;
    width: calc(100vw - 20px);
    max-width: calc(100vw - 20px);
    order: -1;
  }

  .panel,
  .canvas-wrap {
    width: calc(100vw - 20px);
    max-width: calc(100vw - 20px);
  }

  .canvas-toolbar {
    width: calc(100vw - 20px);
    max-width: calc(100vw - 20px);
  }

  #patternCanvas {
    margin-left: 0;
    margin-right: 0;
    transform: none;
  }

  .empty-state {
    right: auto;
    width: calc(100vw - 20px);
  }

  .empty-state > * {
    transform: none;
  }

  .empty-state strong {
    max-width: 320px;
    font-size: 22px;
    white-space: normal;
  }

  .empty-state p {
    max-width: 310px;
  }

  .canvas-toolbar {
    align-items: stretch;
    flex-direction: column;
  }

  .view-tools {
    width: 100%;
    min-width: 0;
  }

  .zoom-label {
    flex: 1;
    min-width: 0;
    grid-template-columns: minmax(0, 1fr) 48px;
  }

  .inspector-panel {
    display: flex;
  }
}

html.is-mobile-static,
html.is-mobile-static body {
  scroll-behavior: auto !important;
  overscroll-behavior: none;
}

html.is-mobile-static *,
html.is-mobile-static *::before,
html.is-mobile-static *::after {
  animation: none !important;
  transition: none !important;
  transform: none !important;
  transform-style: flat !important;
  scroll-behavior: auto !important;
}

html.is-mobile-static .icon-button:hover,
html.is-mobile-static .wide-button:hover,
html.is-mobile-static .square-button:hover,
html.is-mobile-static .export-grid button:hover,
html.is-mobile-static .text-button:hover,
html.is-mobile-static .palette-group-chip:hover,
html.is-mobile-static .drop-zone:hover,
html.is-mobile-static .drop-zone.is-dragging {
  transform: none !important;
}

html.is-mobile-static .busy-dots i {
  animation: busyDot 0.84s ease-in-out infinite !important;
}

.auth-page,
.dashboard-page {
  min-height: 100vh;
}

.auth-layout {
  width: min(1020px, calc(100vw - 32px));
  min-height: 100vh;
  margin: 0 auto;
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(320px, 420px);
  align-items: center;
  gap: 24px;
  padding: 32px 0;
}

.auth-brand img {
  width: 72px;
  height: 72px;
  object-fit: contain;
}

.auth-brand h1 {
  margin: 18px 0 10px;
  font-size: 38px;
  line-height: 1.12;
}

.auth-brand p,
.muted-text {
  margin: 0;
  color: var(--muted);
  line-height: 1.7;
}

.ip-badge {
  display: inline-flex;
  align-items: center;
  min-height: 34px;
  margin-top: 18px;
  padding: 0 12px;
  border: 1px solid rgba(50, 54, 47, 0.1);
  border-radius: var(--radius-sm);
  background: rgba(255, 255, 255, 0.68);
  color: var(--ink);
  font-size: 13px;
  font-weight: 800;
}

.auth-card,
.dashboard-card {
  border-radius: 18px;
  padding: 20px;
}

.auth-tabs {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
  margin-bottom: 16px;
}

.auth-tab-button,
.dashboard-nav a,
.table-action {
  min-height: 34px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 0 12px;
  border-radius: var(--radius-sm);
  background: rgba(255, 255, 255, 0.72);
  color: var(--ink);
  font-size: 12px;
  font-weight: 800;
  text-decoration: none;
  border: 0;
}

.auth-card[data-active-tab="login"] .auth-tab-button[data-tab-target="login"],
.auth-card[data-active-tab="register"] .auth-tab-button[data-tab-target="register"] {
  background: #39745d;
  color: #fff;
}

.auth-card[data-active-tab="login"] #register,
.auth-card[data-active-tab="register"] #login {
  display: none;
}

.auth-form,
.compact-form {
  display: grid;
  gap: 12px;
}

.auth-form h2,
.dashboard-card h2 {
  margin: 0 0 4px;
  font-size: 18px;
}

.auth-form label,
.compact-form label {
  display: grid;
  gap: 7px;
  color: var(--muted);
  font-size: 12px;
  font-weight: 700;
}

.notice {
  grid-column: 1 / -1;
  padding: 12px 14px;
  border-radius: 12px;
  font-size: 13px;
  font-weight: 760;
}

.notice.error {
  border: 1px solid rgba(185, 28, 28, 0.18);
  background: rgba(254, 226, 226, 0.88);
  color: #991b1b;
}

.notice.success {
  border: 1px solid rgba(22, 101, 52, 0.16);
  background: rgba(220, 252, 231, 0.8);
  color: #166534;
}

.dashboard-top {
  position: sticky;
  top: 12px;
  z-index: 10;
  width: min(1180px, calc(100vw - 32px));
  min-height: 72px;
  margin: 16px auto 0;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 12px 14px;
  border-radius: 18px;
}

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

.dashboard-grid {
  width: min(1180px, calc(100vw - 32px));
  margin: 16px auto 32px;
  display: grid;
  grid-template-columns: minmax(280px, 360px) minmax(0, 1fr);
  gap: 14px;
}

.admin-grid {
  grid-template-columns: minmax(280px, 380px) minmax(0, 1fr);
}

.balance-card {
  display: grid;
  gap: 6px;
}

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

.balance-card strong {
  font-size: 26px;
}

.balance-card em {
  font-style: normal;
  font-weight: 840;
  color: #39745d;
}

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

.table-card {
  overflow: auto;
}

.table-card table {
  width: 100%;
  border-collapse: collapse;
  min-width: 680px;
}

.table-card th,
.table-card td {
  padding: 10px;
  border-bottom: 1px solid rgba(50, 54, 47, 0.08);
  text-align: left;
  font-size: 12px;
  vertical-align: middle;
}

.table-card th {
  color: var(--muted);
  font-weight: 840;
}

.table-card small {
  color: var(--muted);
}

.table-input,
.table-select {
  min-height: 34px;
  padding: 0 8px;
}

.table-input {
  width: 86px;
}

.table-select {
  width: 96px;
}

.button-like {
  border: 0;
  cursor: pointer;
}

.card-output {
  width: 100%;
  min-height: 210px;
  resize: vertical;
  border: 1px solid rgba(50, 54, 47, 0.1);
  border-radius: var(--radius-sm);
  padding: 12px;
  background: rgba(255, 255, 255, 0.78);
  color: var(--ink);
  font: 13px/1.55 ui-monospace, SFMono-Regular, Consolas, monospace;
}

@media (max-width: 760px) {
  .auth-layout,
  .dashboard-grid,
  .admin-grid {
    grid-template-columns: 1fr;
  }

  .auth-layout {
    min-height: auto;
  }

  .auth-brand h1 {
    font-size: 28px;
  }

  .dashboard-top {
    position: static;
    flex-direction: column;
    align-items: stretch;
  }

  .dashboard-nav {
    justify-content: stretch;
  }

  .dashboard-nav a {
    flex: 1;
  }
}
