:root {
  color-scheme: light;
  --ink: #202124;
  --muted: #667085;
  --line: #d7dde7;
  --panel: #ffffff;
  --paper: #f4f7fb;
  --accent: #0f766e;
  --accent-strong: #0b5f59;
  --warm: #f2b84b;
  --danger: #b42318;
  --shadow: 0 18px 60px rgba(23, 37, 84, 0.12);
}

* {
  box-sizing: border-box;
}

.hidden {
  display: none !important;
}

.modal-backdrop {
  position: fixed;
  inset: 0;
  z-index: 50;
  display: grid;
  place-items: center;
  padding: 20px;
  background: rgba(15, 23, 42, 0.42);
}

.confirm-dialog {
  width: min(420px, 100%);
  border: 1px solid rgba(215, 221, 231, 0.95);
  border-radius: 8px;
  padding: 22px;
  background: #ffffff;
  box-shadow: 0 24px 70px rgba(15, 23, 42, 0.22);
}

.confirm-dialog h2 {
  margin: 0 0 10px;
  color: #111827;
  font-size: 21px;
  line-height: 1.25;
}

.confirm-dialog p {
  margin: 0;
  color: #475467;
  font-size: 15px;
  line-height: 1.65;
}

.confirm-actions {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
  margin-top: 20px;
}

body {
  margin: 0;
  min-height: 100vh;
  color: var(--ink);
  background:
    linear-gradient(120deg, rgba(15, 118, 110, 0.08), transparent 32%),
    linear-gradient(260deg, rgba(242, 184, 75, 0.14), transparent 28%),
    var(--paper);
  font-family:
    Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI",
    "Microsoft YaHei", sans-serif;
}

.home-page {
  background: #eef4f7;
}

.home-nav {
  position: sticky;
  top: 0;
  z-index: 10;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 16px clamp(18px, 4vw, 56px);
  border-bottom: 1px solid rgba(148, 163, 184, 0.28);
  background: rgba(248, 250, 252, 0.92);
  backdrop-filter: blur(16px);
}

.home-brand,
.home-links a,
.home-actions a {
  color: inherit;
  text-decoration: none;
}

.home-brand {
  font-size: 18px;
  font-weight: 850;
}

.home-links {
  display: flex;
  align-items: center;
  gap: 18px;
  color: #475467;
  font-size: 14px;
  font-weight: 720;
}

.home-hero {
  position: relative;
  display: grid;
  min-height: calc(100vh - 68px);
  padding: clamp(42px, 8vw, 96px) clamp(18px, 4vw, 56px);
  overflow: hidden;
  background: #dfe9ec;
}

.home-hero::before {
  content: "";
  position: absolute;
  inset: 0;
  background:
    linear-gradient(rgba(255, 255, 255, 0.72), rgba(255, 255, 255, 0.72)),
    linear-gradient(90deg, rgba(15, 23, 42, 0.08) 1px, transparent 1px),
    linear-gradient(rgba(15, 23, 42, 0.08) 1px, transparent 1px);
  background-size:
    auto,
    28px 28px,
    28px 28px;
}

.home-hero-art {
  position: absolute;
  inset: 0;
  display: grid;
  place-items: center;
  padding: 28px;
  pointer-events: none;
}

.pixel-scene {
  width: min(780px, 92vw);
  aspect-ratio: 1.35;
  border: 1px solid rgba(71, 85, 105, 0.22);
  border-radius: 8px;
  overflow: hidden;
  background: #ffffff;
  box-shadow: 0 28px 90px rgba(15, 23, 42, 0.18);
  opacity: 0.92;
}

.pixel-toolbar {
  display: flex;
  gap: 8px;
  align-items: center;
  height: 42px;
  padding: 0 16px;
  border-bottom: 1px solid rgba(148, 163, 184, 0.3);
  background: #f8fafc;
}

.pixel-toolbar span {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  background: #0f766e;
}

.pixel-toolbar span:nth-child(2) {
  background: #f2b84b;
}

.pixel-toolbar span:nth-child(3) {
  background: #ef476f;
}

.pixel-board {
  position: relative;
  height: calc(100% - 42px);
  background:
    linear-gradient(90deg, rgba(71, 85, 105, 0.28) 1px, transparent 1px),
    linear-gradient(rgba(71, 85, 105, 0.28) 1px, transparent 1px),
    #ffffff;
  background-size: 34px 34px;
}

.pixel-board span {
  position: absolute;
  left: calc(var(--x) * 34px);
  top: calc(var(--y) * 34px);
  width: 34px;
  height: 34px;
  background: var(--c);
  box-shadow: inset 0 0 0 1px rgba(15, 23, 42, 0.08);
}

.home-hero-copy {
  position: relative;
  z-index: 1;
  align-self: end;
  max-width: 760px;
  padding-top: min(34vh, 280px);
}

.home-kicker {
  color: var(--accent);
  font-size: 15px;
  font-weight: 850;
}

.home-hero h1 {
  margin: 10px 0 16px;
  color: #111827;
  font-size: clamp(44px, 8vw, 88px);
  line-height: 0.98;
}

.home-hero p {
  max-width: 680px;
  color: #334155;
  font-size: clamp(17px, 2.2vw, 22px);
  line-height: 1.62;
}

.home-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
  margin-top: 28px;
}

.home-primary,
.home-secondary {
  display: inline-grid;
  place-items: center;
  min-height: 48px;
  padding: 0 22px;
  border-radius: 8px;
  font-size: 16px;
  font-weight: 850;
}

.home-primary {
  background: var(--accent);
  color: #ffffff !important;
  box-shadow: 0 14px 34px rgba(15, 118, 110, 0.24);
}

.home-primary:hover {
  background: var(--accent-strong);
}

.home-secondary {
  border: 1px solid rgba(71, 85, 105, 0.28);
  background: rgba(255, 255, 255, 0.82);
  color: #1f2937 !important;
}

.home-section {
  padding: 64px clamp(18px, 4vw, 56px);
  background: #ffffff;
}

.home-section-head {
  max-width: 720px;
  margin-bottom: 26px;
}

.home-section h2 {
  color: #111827;
  font-size: clamp(28px, 4vw, 42px);
}

.home-section-head p {
  margin-top: 10px;
  color: #64748b;
  font-size: 17px;
  line-height: 1.65;
}

.home-steps,
.home-features {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 14px;
}

.home-steps article,
.home-features div {
  border: 1px solid rgba(203, 213, 225, 0.86);
  border-radius: 8px;
  padding: 20px;
  background: #ffffff;
}

.home-steps span {
  display: inline-grid;
  place-items: center;
  width: 34px;
  height: 34px;
  border-radius: 50%;
  background: #e6f4f1;
  color: var(--accent);
  font-weight: 900;
}

.home-steps h3,
.home-features strong {
  display: block;
  margin: 16px 0 8px;
  color: #111827;
  font-size: 18px;
}

.home-steps p,
.home-features p {
  color: #64748b;
  font-size: 15px;
  line-height: 1.7;
}

.home-feature-band {
  border-top: 1px solid rgba(203, 213, 225, 0.78);
  background: #f8fafc;
}

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

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

button {
  cursor: pointer;
}

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

.workspace {
  display: grid;
  grid-template-columns: minmax(250px, 320px) minmax(360px, 1fr) minmax(250px, 320px);
  gap: 16px;
  height: calc(100vh - 36px);
  min-height: 620px;
}

.panel,
.stage {
  background: rgba(255, 255, 255, 0.92);
  border: 1px solid rgba(215, 221, 231, 0.9);
  box-shadow: var(--shadow);
}

.panel {
  border-radius: 8px;
  padding: 16px;
}

.source-panel,
.tools-panel {
  align-self: stretch;
  min-height: 0;
  overflow: auto;
}

.stage {
  border-radius: 8px;
  display: grid;
  grid-template-rows: auto 1fr;
  min-height: 0;
  min-width: 0;
  overflow: hidden;
}

.brand-row,
.legend-head,
.source-toolbar,
.preview-toolbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

h1,
h2,
p {
  margin: 0;
}

h1 {
  font-size: 22px;
  line-height: 1.15;
}

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

.brand-row p,
.legend-head p,
.source-toolbar p,
.preview-toolbar p,
.drop-meta {
  color: var(--muted);
  font-size: 13px;
  margin-top: 4px;
}

.icon-button {
  display: inline-grid;
  place-items: center;
  width: 38px;
  height: 38px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  color: var(--ink);
  font-size: 20px;
}

.icon-button:disabled {
  cursor: not-allowed;
  opacity: 0.45;
}

.small-icon {
  width: 34px;
  height: 34px;
  font-size: 18px;
}

.drop-zone {
  display: grid;
  place-items: center;
  gap: 7px;
  margin: 18px 0;
  min-height: 148px;
  border: 1.5px dashed #9aa8bd;
  border-radius: 8px;
  background: #f9fbff;
  text-align: center;
  transition:
    border-color 160ms ease,
    background 160ms ease,
    transform 160ms ease;
}

.source-drop-zone {
  place-items: stretch;
  gap: 0;
  width: 100%;
  min-width: 0;
  min-height: 0;
  padding: 0;
  overflow: hidden;
  text-align: left;
}

.drop-zone.dragging {
  border-color: var(--accent);
  background: #ecfdf5;
  transform: translateY(-1px);
}

.drop-zone input {
  position: absolute;
  inline-size: 1px;
  block-size: 1px;
  overflow: hidden;
  clip: rect(0 0 0 0);
}

.drop-icon {
  display: grid;
  place-items: center;
  width: 48px;
  height: 48px;
  border-radius: 50%;
  background: #e6f4f1;
  color: var(--accent);
  font-size: 24px;
}

.drop-title {
  font-weight: 760;
}

.upload-command {
  display: grid;
  place-items: center;
  margin: 10px 12px 0;
  text-align: center;
  cursor: pointer;
}

.source-drop-zone .drop-meta {
  display: block;
  padding: 8px 12px 12px;
  text-align: center;
}

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

.dimension-grid {
  margin-top: 12px;
}

.control-grid label,
.range-control {
  display: grid;
  gap: 7px;
  color: #394150;
  font-size: 13px;
  font-weight: 680;
}

.control-grid input {
  width: 100%;
  min-height: 40px;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 8px 10px;
  background: #fff;
  color: var(--ink);
}

.range-control {
  margin-top: 16px;
}

.range-control span {
  display: flex;
  justify-content: space-between;
}

input[type="range"] {
  width: 100%;
  accent-color: var(--accent);
}

.secondary-command,
.primary-command {
  min-height: 40px;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 9px 12px;
  background: #fff;
  color: var(--ink);
  font-weight: 740;
}

.secondary-command {
  width: 100%;
  margin-top: 10px;
}

.secondary-command.active {
  border-color: var(--accent);
  background: #e6f4f1;
  color: var(--accent-strong);
}

.size-candidates {
  margin-top: 10px;
}

.size-candidate-heading {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 8px;
  color: #394150;
  font-size: 13px;
  font-weight: 760;
}

.size-candidate-heading small {
  color: #7a8494;
  font-size: 11px;
  font-weight: 650;
}

.size-candidate-list {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 7px;
  margin-top: 7px;
}

.size-candidate {
  min-width: 0;
  min-height: 48px;
  border: 1px solid #d7dde7;
  border-radius: 8px;
  padding: 7px 8px;
  background: #fff;
  color: var(--ink);
  text-align: left;
}

.size-candidate strong,
.size-candidate span {
  display: block;
  overflow-wrap: anywhere;
}

.size-candidate strong {
  font-size: 13px;
}

.size-candidate span {
  margin-top: 2px;
  color: #7a8494;
  font-size: 10px;
  font-weight: 680;
  line-height: 1.25;
}

.size-candidate.active {
  border-color: var(--accent);
  background: #e6f4f1;
  color: var(--accent-strong);
}

.size-candidate.active span {
  color: var(--accent-strong);
}

.primary-soft {
  border-color: var(--accent);
  background: #e6f4f1;
  color: var(--accent-strong);
}

.nudge-pad {
  display: grid;
  grid-template-columns: repeat(3, 38px);
  grid-template-areas:
    ". up ."
    "left down right";
  justify-content: center;
  gap: 6px;
  margin-top: 10px;
}

.nudge-up {
  grid-area: up;
}

.nudge-left {
  grid-area: left;
}

.nudge-right {
  grid-area: right;
}

.nudge-down {
  grid-area: down;
}

.step-nav {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
  margin: 10px 0 12px;
}

.step-nav .secondary-command {
  width: 100%;
}

.compact-command {
  width: auto;
  min-height: 34px;
  margin-top: 0;
  padding: 7px 10px;
  font-size: 13px;
}

.primary-command {
  background: var(--accent);
  border-color: var(--accent);
  color: #fff;
}

.primary-command:hover {
  background: var(--accent-strong);
}

.primary-command:disabled {
  cursor: not-allowed;
  opacity: 0.45;
}

.notice {
  margin: -4px 0 16px;
  border: 1px solid #f2d28b;
  border-radius: 8px;
  background: #fff8e6;
  color: #5f4708;
  padding: 10px 12px;
  font-size: 12px;
  line-height: 1.55;
}

.ai-generator {
  margin: 0 0 16px;
  border-top: 1px solid #e3e8ef;
  border-bottom: 1px solid #e3e8ef;
  padding: 14px 0 16px;
}

.pixel-source-notice {
  display: grid;
  gap: 8px;
  margin: 0 0 16px;
  border: 1px solid #94d4ca;
  border-radius: 8px;
  padding: 11px 12px;
  background: #ecfdf5;
  color: var(--accent-strong);
  font-size: 13px;
  font-weight: 700;
  line-height: 1.5;
}

.text-command {
  width: max-content;
  border: 0;
  padding: 0;
  background: transparent;
  color: var(--accent-strong);
  font-size: 12px;
  font-weight: 760;
  text-decoration: underline;
  text-underline-offset: 3px;
}

.ai-generator-heading {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 10px;
}

.ai-generator-heading p {
  margin-top: 3px;
  color: var(--muted);
  font-size: 12px;
}

.service-indicator {
  flex: 0 0 auto;
  border: 1px solid #d7dde7;
  border-radius: 999px;
  background: #f8fafc;
  color: #667085;
  padding: 4px 7px;
  font-size: 10px;
  font-weight: 760;
}

.service-indicator.active {
  border-color: #94d4ca;
  background: #e6f4f1;
  color: var(--accent-strong);
}

.service-indicator.danger {
  border-color: #f0aaa5;
  background: #fff1f0;
  color: var(--danger);
}

.prompt-control {
  display: grid;
  gap: 7px;
  margin-top: 12px;
  color: #394150;
  font-size: 13px;
  font-weight: 680;
}

.prompt-control textarea {
  width: 100%;
  min-height: 76px;
  resize: vertical;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  color: var(--ink);
  padding: 9px 10px;
  line-height: 1.45;
}

.prompt-control textarea:focus,
.color-picker select:focus {
  border-color: var(--accent);
  outline: 2px solid rgba(15, 118, 110, 0.12);
}

.ai-generate-button {
  width: 100%;
  min-height: 44px;
  margin-top: 12px;
}

.generation-grid-controls {
  margin-top: 12px;
}

.generation-grid-controls select {
  width: 100%;
  min-width: 0;
  min-height: 40px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  color: var(--ink);
  padding: 8px 6px;
  font-size: 12px;
}

.ai-generation-status {
  margin-top: 8px;
}

.temporary-works {
  margin: 0 0 16px;
  border-top: 1px solid #e3e8ef;
  border-bottom: 1px solid #e3e8ef;
  padding: 14px 0 16px;
}

.temporary-works-heading {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 10px;
}

.temporary-works-heading span {
  color: var(--muted);
  font-size: 11px;
}

.temporary-work-list {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 8px;
  margin-top: 10px;
}

.temporary-work-item {
  position: relative;
  min-width: 0;
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
}

.temporary-work-preview {
  display: block;
  width: 100%;
  aspect-ratio: 1;
  border: 0;
  border-bottom: 1px solid var(--line);
  padding: 0;
  background: #f8fafc;
  cursor: pointer;
}

.temporary-work-preview img {
  display: block;
  width: 100%;
  height: 100%;
  object-fit: contain;
  image-rendering: pixelated;
}

.temporary-work-actions {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 5px;
  padding: 6px;
}

.temporary-work-actions button {
  min-width: 0;
  min-height: 30px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: #fff;
  color: var(--ink);
  font-size: 11px;
  font-weight: 740;
}

.temporary-work-delete {
  position: absolute;
  top: 5px;
  right: 5px;
  display: grid;
  place-items: center;
  width: 26px;
  height: 26px;
  border: 1px solid rgba(255, 255, 255, 0.72);
  border-radius: 50%;
  background: rgba(17, 24, 39, 0.72);
  color: #fff;
  font-size: 18px;
  line-height: 1;
}

.segmented,
.view-tabs {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 4px;
  padding: 4px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #edf2f7;
}

.segmented {
  margin-top: 16px;
}

.tool-segments {
  grid-template-columns: repeat(3, 1fr);
  margin-top: 7px;
}

.edit-tools {
  margin-top: 16px;
  border-top: 1px solid #eef1f5;
  padding-top: 14px;
}

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

.edit-status {
  margin-top: 8px;
  border: 1px solid #d7dde7;
  border-radius: 8px;
  background: #f8fafc;
  color: #667085;
  padding: 8px 10px;
  font-size: 12px;
  line-height: 1.45;
}

.edit-status.active {
  border-color: #f2d28b;
  background: #fff8e6;
  color: #5f4708;
}

.pixel-grid-quality {
  margin-top: 6px;
}

.edit-status.warning {
  border-color: #f2d28b;
  background: #fff8e6;
  color: #7a5200;
}

.edit-status.danger {
  border-color: #f0aaa5;
  background: #fff1f0;
  color: #a8342a;
}

.tool-hint {
  margin: -4px 0 12px;
  color: #667085;
  font-size: 12px;
  line-height: 1.45;
}

.compose-hint {
  padding-left: 28px;
}

.tool-label {
  display: block;
  color: #394150;
  font-size: 13px;
  font-weight: 760;
}

.color-picker {
  display: grid;
  gap: 7px;
  margin-top: 12px;
  color: #394150;
  font-size: 13px;
  font-weight: 680;
}

.color-picker select {
  min-height: 40px;
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  color: var(--ink);
  padding: 8px 10px;
}

.paint-color-select {
  display: flex;
  align-items: center;
  gap: 10px;
}

.paint-color-select select {
  flex: 1 1 auto;
  min-width: 0;
}

.paint-color-swatch {
  width: 32px;
  height: 32px;
  flex: 0 0 32px;
  border: 1px solid #cbd5e1;
  border-radius: 7px;
  background: #000;
  box-shadow: inset 0 0 0 1px rgba(255, 255, 255, 0.45);
}

.segment,
.tab {
  min-height: 34px;
  border: 0;
  border-radius: 6px;
  background: transparent;
  color: #475467;
  font-size: 13px;
  font-weight: 760;
}

.segment.active,
.tab.active {
  background: #fff;
  color: var(--ink);
  box-shadow: 0 1px 3px rgba(15, 23, 42, 0.12);
}

.toggle-row {
  display: flex;
  gap: 9px;
  align-items: center;
  margin-top: 14px;
  color: #344054;
  font-size: 13px;
  font-weight: 640;
}

.toggle-row input {
  width: 18px;
  height: 18px;
  accent-color: var(--accent);
}

.actions {
  display: grid;
  gap: 10px;
  margin-top: 18px;
}

.tools-panel > h2 {
  margin-bottom: 12px;
}

.first-tool {
  margin-top: 0;
}

.source-toolbar,
.preview-toolbar {
  padding: 14px 16px;
  border-bottom: 1px solid var(--line);
  background: rgba(255, 255, 255, 0.85);
}

.source-panel .source-toolbar {
  align-items: flex-start;
  padding: 12px;
}

.source-actions {
  display: flex;
  justify-content: flex-end;
  gap: 8px;
  flex-wrap: wrap;
}

.source-wrap {
  position: relative;
  display: flex;
  align-items: center;
  justify-content: center;
  width: 100%;
  min-width: 0;
  min-height: 220px;
  max-height: 38vh;
  padding: 10px 12px;
  border-bottom: 1px solid var(--line);
  background: #f8fafc;
  overflow: clip;
  contain: inline-size layout paint;
}

#sourceCanvas {
  display: block;
  flex: 0 1 auto;
  min-width: 0;
  max-width: calc(100% - 1px);
  max-height: min(34vh, 320px);
  width: auto;
  height: auto;
  border: 1px solid #aab4c3;
  background: #fff;
  touch-action: none;
}

.source-empty {
  position: absolute;
  inset: 12px 16px;
  display: grid;
  place-items: center;
  color: var(--muted);
  font-size: 13px;
  pointer-events: none;
}

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

.view-tabs {
  grid-template-columns: repeat(3, 1fr);
  min-width: 230px;
}

.preview-tools {
  display: grid;
  gap: 8px;
  justify-items: end;
}

.zoom-controls {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 8px;
}

.zoom-controls strong {
  min-width: 48px;
  color: #344054;
  font-size: 13px;
  text-align: center;
}

.canvas-wrap {
  position: relative;
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 0;
  padding: 16px;
  background:
    linear-gradient(45deg, #eef2f6 25%, transparent 25%),
    linear-gradient(-45deg, #eef2f6 25%, transparent 25%),
    linear-gradient(45deg, transparent 75%, #eef2f6 75%),
    linear-gradient(-45deg, transparent 75%, #eef2f6 75%);
  background-color: #f8fafc;
  background-position:
    0 0,
    0 12px,
    12px -12px,
    -12px 0;
  background-size: 24px 24px;
  overflow: hidden;
  touch-action: none;
}

.canvas-wrap.panning {
  cursor: grab;
}

.canvas-wrap.panning:active {
  cursor: grabbing;
}

#patternCanvas {
  display: block;
  max-width: 100%;
  max-height: calc(100vh - 128px);
  width: auto;
  height: auto;
  border: 1px solid #aab4c3;
  background: #fff;
  image-rendering: auto;
  transform-origin: 0 0;
  will-change: transform;
}

.empty-state {
  position: absolute;
  inset: 16px;
  display: grid;
  place-items: center;
  align-content: center;
  gap: 12px;
  color: #5b6575;
  text-align: center;
  pointer-events: none;
}

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

.empty-mark {
  display: grid;
  place-items: center;
  width: 82px;
  height: 82px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.8);
  color: var(--accent);
  font-size: 42px;
}

.legend-list {
  display: grid;
  gap: 8px;
  margin: 16px 0 0;
  padding: 0;
  list-style: none;
}

.legend-item {
  display: grid;
  grid-template-columns: 30px 1fr auto;
  gap: 9px;
  align-items: center;
  min-height: 42px;
  border-bottom: 1px solid #eef1f5;
  padding-bottom: 8px;
}

.swatch {
  display: grid;
  place-items: center;
  width: 30px;
  height: 30px;
  border: 1px solid rgba(0, 0, 0, 0.2);
  border-radius: 50%;
  color: #111827;
  font-size: 12px;
  font-weight: 900;
  text-shadow:
    0 1px 0 rgba(255, 255, 255, 0.8),
    1px 0 0 rgba(255, 255, 255, 0.8);
}

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

.legend-name {
  min-width: 0;
  font-size: 13px;
  font-weight: 760;
}

.legend-code {
  display: block;
  color: var(--muted);
  font-size: 12px;
}

.legend-count {
  color: var(--ink);
  font-size: 13px;
  font-weight: 820;
}

.app-internals {
  display: none !important;
}

.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

@media (max-width: 900px) {
  .home-steps,
  .home-features {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .app-shell {
    padding: 10px;
  }

  .workspace {
    grid-template-columns: 1fr;
    height: auto;
    min-height: auto;
  }

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

  .preview-tools {
    justify-items: stretch;
  }

  .zoom-controls {
    justify-content: flex-start;
    flex-wrap: wrap;
  }

  #patternCanvas {
    max-height: 68vh;
  }
}

@media (max-width: 640px) {
  .home-nav {
    align-items: flex-start;
    flex-direction: column;
    padding: 14px 18px;
  }

  .home-links {
    width: 100%;
    justify-content: space-between;
    gap: 10px;
  }

  .home-hero {
    min-height: 720px;
    padding: 34px 18px;
  }

  .home-hero-art {
    align-items: start;
    padding: 92px 18px 0;
  }

  .pixel-scene {
    width: 100%;
    aspect-ratio: 0.88;
  }

  .pixel-board {
    background-size: 24px 24px;
  }

  .pixel-board span {
    left: calc(var(--x) * 24px - 48px);
    top: calc(var(--y) * 24px + 10px);
    width: 24px;
    height: 24px;
  }

  .home-hero-copy {
    align-self: end;
    padding-top: 360px;
  }

  .home-actions,
  .home-actions a {
    width: 100%;
  }

  .home-steps,
  .home-features {
    grid-template-columns: 1fr;
  }
}
