:root {
  color-scheme: light;
  --paper: #f3f1eb;
  --surface: #ffffff;
  --surface-2: #f7f7f3;
  --ink: #171b19;
  --muted: #66706b;
  --line: #d9ddd8;
  --line-strong: #aeb7b1;
  --green: #168b61;
  --green-dark: #0d6546;
  --cyan: #3eb6c3;
  --red: #e65c4a;
  --yellow: #f3c743;
  --purple: #7457a6;
  --shadow: 0 14px 38px rgba(25, 32, 29, 0.12);
  --header-h: 64px;
  font-family: Inter, ui-sans-serif, -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC", "Microsoft YaHei", sans-serif;
  font-synthesis: none;
}

* {
  box-sizing: border-box;
  letter-spacing: 0;
}

html,
body {
  margin: 0;
  min-width: 320px;
  min-height: 100%;
  background: var(--paper);
  color: var(--ink);
}

body {
  min-height: 100vh;
  min-height: 100dvh;
}

button,
input,
select {
  font: inherit;
}

button {
  color: inherit;
}

button:focus-visible,
input:focus-visible,
select:focus-visible {
  outline: 3px solid rgba(62, 182, 195, 0.3);
  outline-offset: 2px;
}

[hidden] {
  display: none !important;
}

.boot-screen {
  position: fixed;
  inset: 0;
  z-index: 1000;
  overflow: hidden;
  display: grid;
  place-items: center;
  background: #111513;
  color: #fff;
  transition: opacity 450ms ease, visibility 450ms ease;
}

.boot-screen.done {
  opacity: 0;
  visibility: hidden;
}

.boot-mosaic {
  position: absolute;
  inset: -8vmax;
  display: grid;
  grid-template-columns: repeat(16, minmax(40px, 1fr));
  grid-template-rows: repeat(10, minmax(40px, 1fr));
  gap: 3px;
  transform: rotate(-5deg) scale(1.08);
  opacity: 0.54;
}

.boot-mosaic i {
  background: #202724;
  transition: background 420ms ease, transform 420ms ease, opacity 420ms ease;
}

.boot-mosaic i.on {
  transform: scale(0.88);
  opacity: 1;
}

.boot-brand {
  position: relative;
  display: grid;
  justify-items: center;
  text-align: center;
  text-shadow: 0 3px 18px #111513;
}

.boot-brand strong {
  margin-top: 18px;
  font-size: 44px;
  line-height: 1;
}

.boot-brand small {
  margin-top: 8px;
  font-size: 12px;
  font-weight: 800;
}

.boot-status {
  position: absolute;
  bottom: max(44px, env(safe-area-inset-bottom));
  left: 50%;
  width: min(360px, calc(100vw - 56px));
  transform: translateX(-50%);
  color: #d5dbd7;
  font-size: 13px;
  text-align: center;
}

.boot-track,
.process-track {
  overflow: hidden;
  height: 3px;
  margin-top: 14px;
  background: rgba(255, 255, 255, 0.18);
}

.boot-track i {
  display: block;
  width: 42%;
  height: 100%;
  background: var(--yellow);
  animation: boot-progress 1.15s ease-in-out infinite alternate;
}

@keyframes boot-progress {
  from { transform: translateX(-20%); }
  to { transform: translateX(160%); }
}

.brand-mark {
  display: grid;
  flex: 0 0 auto;
  grid-template-columns: repeat(2, 10px);
  grid-template-rows: repeat(2, 10px);
  gap: 2px;
  width: 22px;
  height: 22px;
}

.brand-mark span:nth-child(1) { background: var(--cyan); }
.brand-mark span:nth-child(2) { background: var(--yellow); }
.brand-mark span:nth-child(3) { background: var(--red); }
.brand-mark span:nth-child(4) { background: var(--green); }
.brand-mark-light span { box-shadow: 0 0 0 1px rgba(255,255,255,.16); }

.toast-region {
  position: fixed;
  z-index: 1200;
  top: 18px;
  left: 50%;
  display: grid;
  gap: 8px;
  width: min(420px, calc(100vw - 32px));
  transform: translateX(-50%);
  pointer-events: none;
}

.toast {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 12px 14px;
  border: 1px solid #303936;
  border-radius: 6px;
  background: #171c1a;
  color: #fff;
  box-shadow: var(--shadow);
  font-size: 14px;
  animation: toast-in 220ms ease both;
}

.toast.error { border-color: var(--red); }
.toast svg { width: 18px; }

@keyframes toast-in {
  from { opacity: 0; transform: translateY(-8px); }
}

.auth-view {
  display: grid;
  height: 100vh;
  height: 100dvh;
  min-height: 100vh;
  min-height: 100dvh;
  grid-template-columns: minmax(420px, 1.15fr) minmax(420px, .85fr);
  overflow: hidden;
  background: var(--surface);
}

.auth-visual {
  position: relative;
  height: 100%;
  min-height: 0;
  overflow: hidden;
  background: #f4b5c3;
}

.auth-art {
  position: absolute;
  inset: 0;
  display: flex;
  justify-content: flex-end;
  overflow: hidden;
  width: 100%;
  height: 100%;
}

.auth-art img {
  display: block;
  width: auto;
  height: 100%;
  max-width: none;
  object-fit: contain;
  object-position: center;
}

.auth-visual::after {
  content: "";
  position: absolute;
  inset: 0;
  background: rgba(35, 22, 25, .05);
  pointer-events: none;
}

.auth-visual-copy {
  position: absolute;
  z-index: 1;
  inset: 0;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  padding: 44px;
  color: #fff;
}

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

.brand-lockup > div:last-child {
  display: grid;
}

.brand-lockup strong {
  font-size: 20px;
  line-height: 1.05;
}

.brand-lockup small {
  margin-top: 3px;
  font-size: 9px;
  font-weight: 800;
}

.auth-visual-copy > p {
  margin: auto 0 10px;
  max-width: 560px;
  font-size: clamp(42px, 5vw, 72px);
  font-weight: 820;
  line-height: 1.05;
  text-shadow: 0 2px 18px rgba(57, 24, 34, .2);
}

.auth-visual-copy > span {
  font-size: 14px;
  font-weight: 650;
  color: rgba(255,255,255,.84);
}

.auth-panel {
  display: grid;
  place-items: center;
  min-height: 100vh;
  padding: 48px;
}

.auth-inner {
  width: min(410px, 100%);
}

.auth-mobile-brand {
  display: none;
  align-items: center;
  gap: 10px;
}

.eyebrow {
  margin: 0 0 8px;
  color: var(--green);
  font-size: 10px;
  font-weight: 850;
  text-transform: uppercase;
}

.auth-heading h1,
.panel-title-row h1,
.library-inner h1 {
  margin: 0;
  font-size: 30px;
  line-height: 1.2;
}

.auth-heading > p:last-child,
.library-inner header > p:last-child {
  margin: 10px 0 0;
  color: var(--muted);
  font-size: 14px;
}

.auth-tabs {
  display: grid;
  grid-template-columns: 1fr 1fr;
  margin: 34px 0 26px;
  border-bottom: 1px solid var(--line);
}

.auth-tab {
  position: relative;
  border: 0;
  padding: 12px;
  background: transparent;
  color: var(--muted);
  cursor: pointer;
  font-weight: 750;
}

.auth-tab.active { color: var(--ink); }
.auth-tab.active::after {
  content: "";
  position: absolute;
  right: 0;
  bottom: -1px;
  left: 0;
  height: 3px;
  background: var(--green);
}

.auth-form,
.settings-form {
  display: grid;
  gap: 18px;
}

.field {
  display: grid;
  gap: 8px;
}

.field > span,
.select-label > span {
  color: #3c4541;
  font-size: 12px;
  font-weight: 740;
}

.input-shell {
  display: flex;
  align-items: center;
  min-height: 50px;
  border: 1px solid var(--line-strong);
  border-radius: 6px;
  background: #fff;
}

.input-shell:focus-within { border-color: var(--green); }
.input-shell > svg {
  width: 18px;
  margin-left: 14px;
  color: var(--muted);
}

.input-shell input {
  min-width: 0;
  flex: 1;
  border: 0;
  padding: 0 12px;
  outline: 0;
  background: transparent;
}

.icon-button {
  display: inline-grid;
  place-items: center;
  width: 36px;
  height: 36px;
  flex: 0 0 auto;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: var(--surface);
  cursor: pointer;
}

.icon-button:hover { border-color: var(--line-strong); background: var(--surface-2); }
.icon-button svg { width: 17px; height: 17px; }
.password-toggle { margin-right: 6px; border: 0; }

.primary,
.secondary {
  min-height: 42px;
  border: 1px solid transparent;
  border-radius: 6px;
  padding: 0 16px;
  cursor: pointer;
  font-weight: 780;
}

.primary {
  background: var(--ink);
  color: #fff;
}

.primary:hover:not(:disabled) { background: #2c3531; }
.secondary { border-color: var(--line-strong); background: #fff; }
.secondary:hover { border-color: var(--ink); }
.primary:disabled { cursor: not-allowed; opacity: .4; }

.auth-submit {
  display: flex;
  align-items: center;
  justify-content: space-between;
  min-height: 52px;
  margin-top: 6px;
}

.auth-submit svg { width: 18px; }
.auth-note {
  display: flex;
  align-items: center;
  gap: 8px;
  margin: 24px 0 0;
  color: var(--muted);
  font-size: 12px;
}
.auth-note svg { width: 16px; color: var(--green); }

.app-view { min-height: 100vh; }

.app-header {
  position: sticky;
  z-index: 50;
  top: 0;
  display: flex;
  align-items: center;
  height: var(--header-h);
  border-bottom: 1px solid var(--line);
  padding: 0 24px;
  background: rgba(255,255,255,.96);
}

.app-brand { width: 240px; }
.app-nav {
  display: flex;
  align-self: stretch;
  gap: 4px;
}

.nav-button {
  position: relative;
  display: flex;
  align-items: center;
  gap: 7px;
  border: 0;
  padding: 0 18px;
  background: transparent;
  color: var(--muted);
  cursor: pointer;
  font-size: 13px;
  font-weight: 740;
}

.nav-button svg { width: 17px; }
.nav-button.active { color: var(--ink); }
.nav-button.active::after {
  content: "";
  position: absolute;
  right: 16px;
  bottom: 0;
  left: 16px;
  height: 3px;
  background: var(--green);
}

.header-actions {
  position: relative;
  display: flex;
  align-items: center;
  gap: 16px;
  margin-left: auto;
}

.privacy-state {
  display: flex;
  align-items: center;
  gap: 6px;
  color: var(--green-dark);
  font-size: 11px;
  font-weight: 750;
}
.privacy-state svg { width: 14px; }

.user-button {
  display: flex;
  align-items: center;
  gap: 9px;
  border: 0;
  background: transparent;
  cursor: pointer;
  text-align: left;
}

.avatar {
  display: grid;
  place-items: center;
  width: 34px;
  height: 34px;
  border-radius: 50%;
  background: #e3f1eb;
  color: var(--green-dark);
  font-size: 13px;
  font-weight: 850;
}

.user-meta { display: grid; }
.user-meta strong { max-width: 120px; overflow: hidden; font-size: 12px; text-overflow: ellipsis; white-space: nowrap; }
.user-meta small { max-width: 150px; overflow: hidden; color: var(--muted); font-size: 9px; text-overflow: ellipsis; white-space: nowrap; }
.user-button > svg { width: 14px; color: var(--muted); }

.user-menu {
  position: absolute;
  top: calc(100% + 12px);
  right: 0;
  min-width: 168px;
  border: 1px solid var(--line);
  border-radius: 6px;
  padding: 6px;
  background: #fff;
  box-shadow: var(--shadow);
}
.user-menu button {
  display: flex;
  align-items: center;
  gap: 8px;
  width: 100%;
  border: 0;
  border-radius: 4px;
  padding: 10px;
  background: transparent;
  cursor: pointer;
  font-size: 12px;
  text-align: left;
}
.user-menu button:hover { background: var(--surface-2); }
.user-menu svg { width: 16px; }

.studio-view {
  display: grid;
  min-height: calc(100vh - var(--header-h));
  grid-template-columns: 390px minmax(0, 1fr);
}

.control-panel {
  border-right: 1px solid var(--line);
  padding: 24px;
  background: var(--surface);
}

.panel-title-row,
.result-heading,
.materials-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
}

.panel-title-row h1 { font-size: 23px; }
.upload-section { margin-top: 24px; }
.upload-zone {
  display: grid;
  align-items: center;
  width: 100%;
  min-height: 76px;
  grid-template-columns: 42px minmax(0, 1fr) 18px;
  gap: 12px;
  border: 1px dashed var(--line-strong);
  border-radius: 6px;
  padding: 11px;
  background: var(--surface-2);
  cursor: pointer;
  text-align: left;
}
.upload-zone.dragging { border-color: var(--green); background: #eef8f3; }
.upload-zone > svg { width: 18px; color: var(--muted); }
.upload-icon {
  display: grid;
  place-items: center;
  width: 42px;
  height: 42px;
  border-radius: 5px;
  background: #e4f3ee;
  color: var(--green-dark);
}
.upload-icon svg { width: 20px; }
.upload-zone > span:nth-child(2) { display: grid; min-width: 0; gap: 3px; }
.upload-zone strong { font-size: 13px; }
.upload-zone small { overflow: hidden; color: var(--muted); font-size: 10px; text-overflow: ellipsis; white-space: nowrap; }

.file-summary {
  display: grid;
  align-items: center;
  grid-template-columns: 56px minmax(0, 1fr) 36px;
  gap: 12px;
  min-height: 72px;
  border: 1px solid var(--line);
  border-radius: 6px;
  padding: 8px;
}
.file-summary img { width: 56px; height: 56px; border-radius: 4px; object-fit: cover; }
.file-summary > div { display: grid; min-width: 0; gap: 4px; }
.file-summary strong { overflow: hidden; font-size: 12px; text-overflow: ellipsis; white-space: nowrap; }
.file-summary span { color: var(--muted); font-size: 10px; }

.recommendation {
  display: grid;
  align-items: center;
  grid-template-columns: 34px minmax(0,1fr) auto;
  gap: 10px;
  margin-top: 12px;
  border-left: 3px solid var(--yellow);
  padding: 10px 10px 10px 12px;
  background: #fff9dc;
}
.recommendation-icon { display: grid; place-items: center; width: 30px; height: 30px; color: #7a5c00; }
.recommendation-icon svg { width: 17px; }
.recommendation div { display: grid; gap: 2px; min-width: 0; }
.recommendation strong { font-size: 11px; }
.recommendation p { margin: 0; color: #6e5a14; font-size: 10px; line-height: 1.35; }
.recommendation button { border: 0; padding: 7px; background: transparent; color: #705600; cursor: pointer; font-size: 11px; font-weight: 800; }

.settings-form { margin-top: 4px; gap: 0; }
.settings-form fieldset {
  min-width: 0;
  margin: 0;
  border: 0;
  border-bottom: 1px solid var(--line);
  padding: 22px 0;
}
.settings-form legend {
  display: flex;
  align-items: center;
  width: 100%;
  gap: 8px;
  margin-bottom: 14px;
  padding: 0;
  font-size: 12px;
  font-weight: 820;
}
.settings-form legend > span:first-child {
  display: grid;
  place-items: center;
  width: 25px;
  height: 21px;
  background: var(--ink);
  color: #fff;
  font-size: 9px;
}
.required { margin-left: auto; color: var(--red); font-size: 9px; font-weight: 700; }

.segmented {
  display: grid;
  gap: 6px;
}
.segmented.three { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.segmented label { min-width: 0; cursor: pointer; }
.segmented input { position: absolute; opacity: 0; pointer-events: none; }
.segmented label > span {
  display: grid;
  gap: 2px;
  min-height: 53px;
  border: 1px solid var(--line);
  border-radius: 5px;
  padding: 9px 10px;
  background: #fff;
}
.segmented label:hover > span { border-color: var(--line-strong); }
.segmented input:checked + span { border-color: var(--ink); box-shadow: inset 0 -3px var(--green); }
.segmented strong { font-size: 12px; }
.segmented small { color: var(--muted); font-size: 9px; }
.field-hint { margin: 9px 0 0; color: var(--muted); font-size: 10px; }

.size-presets {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 6px;
  margin-bottom: 7px;
}
.size-presets button {
  display: grid;
  gap: 3px;
  min-width: 0;
  min-height: 70px;
  border: 1px solid var(--line);
  border-radius: 5px;
  padding: 8px 9px;
  background: #fff;
  color: var(--ink);
  text-align: left;
  cursor: pointer;
}
.size-presets button:hover:not(:disabled) { border-color: var(--line-strong); }
.size-presets button.active {
  border-color: var(--ink);
  background: #f4faf7;
  box-shadow: inset 0 -3px var(--green);
}
.size-presets button:disabled { cursor: default; opacity: .52; }
.size-presets span { overflow: hidden; font-size: 9px; font-weight: 750; text-overflow: ellipsis; white-space: nowrap; }
.size-presets span b { color: var(--green-dark); font-size: 8px; }
.size-presets strong { font-size: 12px; }
.size-presets small { overflow: hidden; color: var(--muted); font-size: 8px; text-overflow: ellipsis; white-space: nowrap; }
.preset-hint { margin: 0 0 12px; color: var(--muted); font-size: 9px; line-height: 1.45; }

.dimension-row {
  display: grid;
  align-items: end;
  grid-template-columns: minmax(0,1fr) 14px minmax(0,1fr) 20px;
  gap: 8px;
}
.dimension-row label { display: grid; gap: 5px; }
.dimension-row label span { color: var(--muted); font-size: 9px; }
.dimension-row input {
  width: 100%;
  height: 42px;
  border: 1px solid var(--line-strong);
  border-radius: 5px;
  padding: 0 10px;
  font-weight: 750;
}
.dimension-row > svg { width: 13px; margin-bottom: 14px; color: var(--muted); }
.dimension-row .unit { margin-bottom: 13px; color: var(--muted); font-size: 11px; }

.inline-options,
.output-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
  margin-top: 12px;
}
.select-label { display: grid; gap: 6px; min-width: 0; }
.select-label.full { margin-bottom: 14px; }
.select-label select {
  width: 100%;
  height: 38px;
  border: 1px solid var(--line);
  border-radius: 5px;
  padding: 0 30px 0 10px;
  background: #fff;
  color: var(--ink);
  font-size: 11px;
}
.check-control { display: flex; align-items: end; cursor: pointer; }
.check-control input { position: absolute; opacity: 0; }
.check-control span {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 5px;
  width: 100%;
  height: 38px;
  border: 1px solid var(--line);
  border-radius: 5px;
  color: var(--muted);
  font-size: 10px;
  font-weight: 700;
}
.check-control input:checked + span { border-color: var(--green); background: #eef8f3; color: var(--green-dark); }
.check-control svg { width: 13px; }

.focus-editor {
  display: grid;
  grid-template-columns: 120px minmax(0, 1fr);
  gap: 12px;
  align-items: center;
  margin-top: 12px;
  padding: 10px;
  border: 1px solid var(--line);
  border-radius: 5px;
  background: var(--surface-2);
}
.focus-preview {
  display: grid;
  place-items: center;
  width: 120px;
  height: 132px;
  overflow: hidden;
  background: #1d2421;
}
.focus-preview canvas { display: block; max-width: 100%; max-height: 100%; }
.focus-controls { display: grid; gap: 15px; min-width: 0; }
.focus-zoom { display: grid; gap: 8px; color: var(--muted); font-size: 10px; }
.focus-zoom span { display: flex; justify-content: space-between; gap: 6px; }
.focus-zoom output { color: var(--ink); font-weight: 750; }
.focus-zoom input { width: 100%; margin: 0; accent-color: var(--green); }

.range-heading { display: flex; justify-content: space-between; margin: 0 0 7px; font-size: 10px; }
.range-heading output { color: var(--green-dark); font-weight: 800; }
.range { width: 100%; accent-color: var(--green); }
.family-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 5px;
  margin-top: 10px;
}
.family-grid input { position: absolute; opacity: 0; }
.family-grid label { min-width: 0; cursor: pointer; }
.family-grid label span {
  display: flex;
  align-items: center;
  gap: 5px;
  min-height: 30px;
  border: 1px solid var(--line);
  border-radius: 4px;
  padding: 5px 6px;
  color: var(--muted);
  font-size: 9px;
  white-space: nowrap;
}
.family-grid input:checked + span { border-color: var(--line-strong); background: var(--surface-2); color: var(--ink); font-weight: 760; }
.family-grid input:not(:checked) + span { opacity: .45; }
.swatch { width: 9px; height: 9px; flex: 0 0 auto; border: 1px solid rgba(0,0,0,.12); }
.swatch.a { background: #f3c743; } .swatch.b { background: #35a569; } .swatch.c { background: #3eb6c3; }
.swatch.d { background: #7457a6; } .swatch.e { background: #e580ad; } .swatch.f { background: #e65c4a; }
.swatch.g { background: #a9734f; } .swatch.h { background: #e7e8e5; } .swatch.m { background: #7b8873; }

.toggle-list { display: grid; gap: 8px; }
.toggle-list label { display: flex; align-items: center; justify-content: space-between; gap: 12px; cursor: pointer; }
.toggle-list label > span { display: grid; gap: 2px; }
.toggle-list strong { font-size: 11px; }
.toggle-list small { color: var(--muted); font-size: 9px; }
.toggle-list input { position: absolute; opacity: 0; }
.toggle-list label > i {
  position: relative;
  width: 34px;
  height: 20px;
  flex: 0 0 auto;
  border-radius: 10px;
  background: #cdd2cf;
  transition: background 160ms ease;
}
.toggle-list label > i::after {
  content: "";
  position: absolute;
  top: 3px;
  left: 3px;
  width: 14px;
  height: 14px;
  border-radius: 50%;
  background: #fff;
  transition: transform 160ms ease;
}
.toggle-list input:checked + i { background: var(--green); }
.toggle-list input:checked + i::after { transform: translateX(14px); }

.generate-button {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 9px;
  min-height: 48px;
  margin-top: 20px;
  box-shadow: 0 8px 24px rgba(23,27,25,.18);
}
.generate-button svg { width: 17px; }

.preview-panel {
  min-width: 0;
  padding: 22px;
  background: var(--paper);
}
.preview-toolbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  min-height: 42px;
  margin-bottom: 14px;
}
.view-tabs { display: flex; gap: 4px; }
.view-tabs button {
  border: 0;
  border-radius: 4px;
  padding: 9px 12px;
  background: transparent;
  color: var(--muted);
  cursor: pointer;
  font-size: 11px;
  font-weight: 760;
}
.view-tabs button.active { background: #fff; color: var(--ink); box-shadow: 0 1px 0 var(--line); }
.zoom-tools { display: flex; align-items: center; gap: 4px; }
.zoom-tools output { width: 48px; color: var(--muted); font-size: 10px; text-align: center; }

.canvas-stage {
  position: relative;
  display: grid;
  place-items: center;
  min-height: clamp(420px, calc(100vh - 160px), 800px);
  overflow: auto;
  border: 1px solid #2c3531;
  border-radius: 6px;
  background: #151a18;
}
.empty-preview {
  display: grid;
  align-items: center;
  width: min(580px, calc(100% - 48px));
  grid-template-columns: minmax(150px, 44%) minmax(0, 1fr);
  gap: 28px;
  color: #fff;
}
.empty-pattern-art {
  display: grid;
  width: 100%;
  aspect-ratio: 1;
  border: 1px solid #424c47;
  grid-template-columns: repeat(10, 1fr);
  grid-template-rows: repeat(10, 1fr);
  gap: 3px;
  padding: 16px;
  background: #202724;
}
.empty-pattern-art i { background: #2f3935; }
.empty-pattern-art i[data-tone="1"] { background: #ec6f91; }
.empty-pattern-art i[data-tone="2"] { background: #f4a4bb; }
.empty-pattern-art i[data-tone="3"] { background: #f3c743; }
.empty-preview > div { display: grid; gap: 8px; }
.empty-preview span { color: var(--yellow); font-size: 10px; font-weight: 800; }
.empty-preview strong { max-width: 260px; font-size: 18px; line-height: 1.45; }

.canvas-wrap {
  position: relative;
  display: grid;
  place-items: center;
  min-width: 100%;
  min-height: 100%;
  padding: 30px;
}
.canvas-wrap canvas,
.canvas-wrap img {
  display: block;
  max-width: none;
  background: #fff;
  box-shadow: 0 18px 48px rgba(0,0,0,.35);
  image-rendering: pixelated;
  transform-origin: center;
}
.canvas-wrap img { object-fit: contain; }

.processing-overlay {
  position: absolute;
  inset: 0;
  display: grid;
  place-content: center;
  justify-items: center;
  padding: 24px;
  background: rgba(15,20,18,.92);
  color: #fff;
  text-align: center;
}
.process-orbit { position: relative; width: 76px; height: 76px; margin-bottom: 22px; animation: orbit 2.2s linear infinite; }
.process-orbit i { position: absolute; width: 19px; height: 19px; }
.process-orbit i:nth-child(1) { top: 0; left: 29px; background: var(--yellow); }
.process-orbit i:nth-child(2) { right: 4px; bottom: 7px; background: var(--cyan); }
.process-orbit i:nth-child(3) { bottom: 7px; left: 4px; background: var(--red); }
@keyframes orbit { to { transform: rotate(360deg); } }
.processing-overlay strong { font-size: 18px; }
.processing-overlay span { margin-top: 7px; color: #aeb8b3; font-size: 11px; }
.processing-overlay .process-track { width: min(300px, 60vw); margin-top: 22px; }
.process-track i { display: block; width: 0; height: 100%; background: var(--green); transition: width 300ms ease; }
.processing-overlay output { margin-top: 8px; color: #c7cfcb; font-size: 10px; }

.quality-strip {
  display: grid;
  grid-template-columns: repeat(6, 1fr);
  border: 1px solid var(--line);
  border-top: 0;
  background: #fff;
}
.quality-strip > div {
  display: grid;
  gap: 4px;
  border-right: 1px solid var(--line);
  padding: 12px 14px;
}
.quality-strip > div:last-child { border-right: 0; }
.quality-strip span { color: var(--muted); font-size: 9px; }
.quality-strip strong { font-size: 14px; }
#qualityGrade { color: var(--green-dark); }

.result-panel {
  margin-top: 18px;
  border-top: 1px solid var(--line-strong);
  padding: 22px 2px 50px;
}
.result-heading h2 { margin: 0; font-size: 20px; }
.result-heading > span { color: var(--muted); font-size: 11px; }
.download-actions { display: flex; flex-wrap: wrap; gap: 8px; margin: 18px 0 24px; }
.download-actions button { display: inline-flex; align-items: center; gap: 7px; }
.download-actions svg { width: 16px; }
.materials-head { padding-bottom: 10px; border-bottom: 1px solid var(--line); }
.materials-head strong { font-size: 13px; }
.materials-head span { color: var(--muted); font-size: 10px; }
.materials-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(160px, 1fr));
  gap: 0 18px;
}
.material-item {
  display: grid;
  align-items: center;
  grid-template-columns: 20px 42px minmax(0,1fr) auto;
  gap: 8px;
  min-height: 42px;
  border-bottom: 1px solid var(--line);
  font-size: 10px;
}
.material-item i { width: 18px; height: 18px; border: 1px solid rgba(0,0,0,.18); }
.material-item strong { font-size: 11px; }
.material-item span { color: var(--muted); }
.material-item b { font-size: 10px; }

.library-view { min-height: calc(100vh - var(--header-h)); padding: 40px 24px; }
.library-inner { width: min(1000px, 100%); margin: 0 auto; }
.history-list { display: grid; margin-top: 30px; border-top: 1px solid var(--line-strong); }
.history-item {
  display: grid;
  align-items: center;
  grid-template-columns: minmax(0, 1.4fr) repeat(4, minmax(90px,.5fr));
  gap: 18px;
  border-bottom: 1px solid var(--line);
  padding: 18px 0;
}
.history-item > div { display: grid; gap: 4px; }
.history-item span { color: var(--muted); font-size: 9px; }
.history-item strong { overflow: hidden; font-size: 12px; text-overflow: ellipsis; white-space: nowrap; }
.history-empty { padding: 42px 0; color: var(--muted); font-size: 13px; }

@media (max-width: 1100px) {
  .studio-view { grid-template-columns: 360px minmax(0,1fr); }
  .materials-grid { grid-template-columns: repeat(3, minmax(150px,1fr)); }
  .user-meta { display: none; }
}

@media (max-width: 860px) {
  :root { --header-h: 58px; }
  .auth-view { height: auto; min-height: 100dvh; grid-template-columns: 1fr; overflow: auto; }
  .auth-visual { display: none; }
  .auth-panel { min-height: 100vh; padding: 32px 24px; }
  .auth-mobile-brand { display: flex; margin-bottom: 56px; }
  .studio-view { display: block; }
  .control-panel { border-right: 0; border-bottom: 1px solid var(--line); padding: 22px max(20px, env(safe-area-inset-left)); }
  .preview-panel { padding: 18px max(16px, env(safe-area-inset-left)) 40px; }
  .canvas-stage { min-height: 560px; }
  .app-brand { width: auto; }
  .app-brand small { display: none; }
  .app-nav { margin-left: 28px; }
  .privacy-state { display: none; }
  .quality-strip { grid-template-columns: repeat(6, minmax(100px,1fr)); overflow-x: auto; }
  .materials-grid { grid-template-columns: repeat(2, minmax(150px,1fr)); }
}

@media (max-width: 600px) {
  .app-header { padding: 0 14px; }
  .app-brand .brand-mark { width: 20px; height: 20px; grid-template-columns: repeat(2,9px); grid-template-rows: repeat(2,9px); }
  .app-brand strong { font-size: 16px; }
  .app-nav { margin-left: 10px; }
  .nav-button { width: 42px; justify-content: center; padding: 0; }
  .nav-button span { display: none; }
  .nav-button.active::after { right: 8px; left: 8px; }
  .header-actions { gap: 6px; }
  .user-button > svg { display: none; }
  .control-panel { padding-top: 18px; }
  .panel-title-row h1 { font-size: 21px; }
  .settings-form fieldset { padding: 19px 0; }
  .size-presets { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .canvas-stage { min-height: 430px; }
  .preview-toolbar { margin-bottom: 8px; }
  .empty-preview { grid-template-columns: 1fr; width: min(300px, calc(100% - 52px)); gap: 16px; }
  .empty-pattern-art { max-height: 210px; padding: 12px; gap: 2px; }
  .empty-preview strong { font-size: 14px; }
  .canvas-wrap { padding: 18px; }
  .zoom-tools .icon-button:nth-of-type(1),
  .zoom-tools .icon-button:nth-of-type(2),
  .zoom-tools output { display: none; }
  .quality-strip > div { padding: 10px; }
  .quality-strip strong { font-size: 12px; }
  .result-heading { align-items: flex-start; flex-direction: column; gap: 8px; }
  .download-actions { display: grid; grid-template-columns: 1fr 1fr; }
  .download-actions button { justify-content: center; padding: 0 8px; font-size: 11px; }
  .materials-grid { grid-template-columns: 1fr; }
  .library-view { padding: 28px 18px; }
  .history-item { grid-template-columns: 1fr 1fr; gap: 12px; }
  .history-item > div:first-child { grid-column: 1 / -1; }
}

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