:root {
  --bg: #f4f3ee;
  --panel: #fffefa;
  --surface: #fbfaf6;
  --ink: #23211d;
  --muted: #6c675e;
  --line: #ded8ca;
  --accent: #b55b4d;
  --accent-strong: #80372f;
  --teal: #407f78;
  --blue: #647c9a;
  --ok: #517a57;
  --warn: #a66b2d;
  --shadow: 0 14px 34px rgba(38, 31, 24, 0.08);
}

* { box-sizing: border-box; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font-family: -apple-system, BlinkMacSystemFont, "PingFang SC", "Hiragino Sans GB", "Microsoft YaHei", sans-serif;
}

body:not(.authenticated) .rail,
body:not(.authenticated) main {
  display: none;
}

.authScreen {
  min-height: 100dvh;
  display: grid;
  place-items: center;
  padding: 28px;
  background:
    linear-gradient(90deg, rgba(222,216,202,.55) 1px, transparent 1px),
    linear-gradient(180deg, rgba(222,216,202,.55) 1px, transparent 1px),
    var(--bg);
  background-size: 42px 42px;
}
body.authenticated .authScreen {
  display: none;
}
.authCard {
  width: min(420px, 100%);
  display: grid;
  gap: 12px;
  padding: 28px;
  border: 1px solid var(--line);
  background: var(--panel);
  box-shadow: var(--shadow);
}
.authCard .mark {
  width: 58px;
  height: 58px;
}
.authCard h1 {
  margin: 4px 0 0;
  font-size: 28px;
}
.authCard p {
  margin: 0 0 6px;
}
.authCard code {
  padding: 2px 4px;
  background: #f1ecdf;
  color: var(--accent-strong);
  font-size: 12px;
}
.authMessage {
  min-height: 22px;
  color: var(--accent-strong);
  font-size: 13px;
}

.rail {
  position: fixed;
  inset: 0 auto 0 0;
  width: 300px;
  padding: 24px 20px;
  background: #ece8dd;
  border-right: 1px solid var(--line);
  display: flex;
  flex-direction: column;
  gap: 20px;
  overflow-y: auto;
}

.brand { display: flex; gap: 14px; align-items: center; }
.brand strong { display: block; font-size: 18px; }
.brand span { color: var(--muted); font-size: 13px; }
.mark {
  width: 52px;
  height: 52px;
  display: grid;
  place-items: center;
  background: var(--ink);
  color: #fff;
  font-weight: 800;
  letter-spacing: 0.04em;
}

.userPanel {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 10px;
  align-items: center;
  padding: 10px 12px;
  border: 1px solid var(--line);
  background: rgba(255,255,255,.32);
}
.userPanel strong {
  display: block;
  font-size: 14px;
}
.userPanel span {
  display: block;
  margin-top: 2px;
  color: var(--muted);
  font-size: 12px;
}

nav { display: grid; gap: 8px; }
nav a {
  display: grid;
  grid-template-columns: 38px 1fr;
  align-items: center;
  gap: 10px;
  color: var(--ink);
  text-decoration: none;
  padding: 10px 12px;
  border: 1px solid transparent;
  background: rgba(255,255,255,.24);
}
nav a:hover { background: #fff9ef; border-color: var(--line); }
nav a b {
  color: var(--accent-strong);
  font-size: 12px;
  letter-spacing: .08em;
}
nav a span {
  font-size: 14px;
}

.railSettings {
  width: 100%;
  background: transparent;
  color: var(--ink);
  border-color: var(--line);
  text-align: left;
}
.railSettings:hover { background: #fff9ef; }

.historyPanel {
  min-height: 0;
  display: grid;
  gap: 10px;
  padding: 12px;
  border: 1px solid var(--line);
  background: rgba(255,255,255,.22);
}
.historyHeader {
  display: flex;
  justify-content: space-between;
  align-items: center;
  color: var(--ink);
}
.historyHeader strong { font-size: 15px; }
.historyHeaderActions {
  display: inline-flex;
  gap: 5px;
}
.historyRefresh {
  width: 30px;
  height: 30px;
  padding: 0;
  display: grid;
  place-items: center;
  background: transparent;
  color: var(--ink);
  border-color: var(--line);
}
.historyList {
  max-height: 430px;
  overflow-y: auto;
  overscroll-behavior: contain;
  display: grid;
  gap: 8px;
  padding-right: 4px;
  color: var(--muted);
  font-size: 12px;
}
.historyItem {
  display: grid;
  grid-template-columns: 54px 1fr;
  gap: 9px;
  align-items: center;
  width: 100%;
  padding: 7px;
  border: 1px solid var(--line);
  background: #fff9ef;
  color: var(--ink);
  cursor: pointer;
  text-align: left;
}
.historyItem:hover,
.historyItem.active {
  border-color: var(--accent);
  background: #fffdf8;
}
.historyItem img {
  width: 54px;
  height: 54px;
  object-fit: contain;
  background: #eee9df;
}
.historyItem strong {
  display: block;
  font-size: 12px;
  line-height: 1.25;
}
.historyItem span {
  display: block;
  margin-top: 3px;
  color: var(--muted);
  font-size: 11px;
  line-height: 1.25;
}
.historyMore {
  width: 100%;
  min-height: 38px;
  background: #fff;
  color: var(--accent-strong);
  border-color: var(--line);
  font-size: 13px;
}

.historyModalPanel {
  width: min(1180px, 100%);
}
.historyToolbar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
  margin-bottom: 16px;
}
.historyToolbar span {
  color: var(--muted);
  font-size: 13px;
}
.historyGridLarge {
  max-height: min(68vh, 680px);
  overflow-y: auto;
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(190px, 1fr));
  gap: 14px;
  padding-right: 6px;
  color: var(--muted);
}
.historyCardLarge {
  display: grid;
  gap: 9px;
  padding: 10px;
  border: 1px solid var(--line);
  background: #fffdf8;
  color: var(--ink);
  text-align: left;
}
.historyCardLarge:hover,
.historyCardLarge.active {
  border-color: var(--accent);
  box-shadow: inset 0 0 0 2px rgba(181,91,77,.16);
}
.historyCardLarge img {
  width: 100%;
  aspect-ratio: 1 / 1;
  object-fit: contain;
  background: #f0ece2;
}
.historyCardLarge strong,
.historyCardLarge span {
  display: block;
  line-height: 1.35;
}
.historyCardLarge strong {
  font-size: 13px;
}
.historyCardLarge span {
  margin-top: 3px;
  color: var(--muted);
  font-size: 12px;
}

.libraryTools {
  display: grid;
  gap: 12px;
  padding: 14px;
  border: 1px solid var(--line);
  background: #fbf8f1;
}
.libraryTop {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 12px;
}
.compactBtn {
  width: auto;
  padding: 7px 10px;
  font-size: 13px;
  white-space: nowrap;
}
.selectedStyleBlend {
  display: grid;
  gap: 4px;
  padding: 12px;
  border: 1px solid #d9cab0;
  background: #fffaf0;
  color: var(--muted);
  line-height: 1.45;
}
.selectedStyleBlend strong {
  color: var(--ink);
  font-size: 14px;
}
.selectedStyleBlend span,
.selectedStyleBlend small {
  font-size: 12px;
}
.styleSearchRow {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 8px;
}
.styleLibrary {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(230px, 1fr));
  gap: 10px;
  min-height: 44px;
  max-height: 640px;
  overflow-y: auto;
  overscroll-behavior: contain;
  padding-right: 4px;
  color: var(--muted);
  font-size: 13px;
}
.styleLibraryTags {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  padding-bottom: 2px;
}
.styleTag {
  width: auto;
  min-height: 30px;
  padding: 5px 9px;
  border: 1px solid var(--line);
  background: #fff;
  color: var(--ink);
  font-size: 12px;
}
.styleTag:hover,
.styleTag.active {
  border-color: var(--accent);
  background: var(--accent);
  color: #fff;
}
.styleLibraryGroup {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 10px;
  grid-column: 1 / -1;
  margin: 10px 0 0;
  padding: 9px 10px;
  border: 1px solid var(--line);
  background: #efe8da;
  color: var(--accent-strong);
  font-size: 12px;
  font-weight: 700;
}
.styleLibraryGroup span {
  color: var(--muted);
  font-weight: 500;
}
.styleLibraryCard {
  display: grid;
  gap: 9px;
  padding: 12px;
  border: 1px solid var(--line);
  background: #fff;
  color: var(--ink);
  text-align: left;
}
.styleLibraryCard:hover,
.styleLibraryCard.active {
  border-color: var(--accent);
  background: #fffdf8;
}
.styleLibraryCard.primary {
  box-shadow: inset 3px 0 0 var(--accent);
}
.styleLibraryCard.aux {
  border-color: #d7c8a8;
  background: #fffaf0;
}
.styleCardHead {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 8px;
}
.styleCardHead small {
  display: block;
  margin-top: 3px;
  color: var(--muted);
  font-size: 11px;
  line-height: 1.2;
}
.styleCardHead b {
  flex: 0 0 auto;
  padding: 3px 6px;
  border: 1px solid var(--line);
  color: var(--accent-strong);
  background: #f7efe0;
  font-size: 11px;
  line-height: 1;
}
.styleLibraryCard strong {
  display: block;
  font-size: 13px;
}
.styleLibraryCard span {
  display: -webkit-box;
  -webkit-line-clamp: 3;
  -webkit-box-orient: vertical;
  overflow: hidden;
  color: var(--muted);
  font-size: 12px;
  line-height: 1.35;
}
.styleLibraryCard .tagLine {
  display: flex;
  flex-wrap: wrap;
  gap: 4px;
  margin-top: 8px;
}
.styleLibraryCard .tagLine i {
  font-style: normal;
  padding: 3px 5px;
  background: #f5efe2;
  color: var(--accent-strong);
  font-size: 11px;
}
.styleCardActions {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 6px;
  margin-top: 9px;
}
.styleCardActions button {
  min-height: 30px;
  padding: 5px 6px;
  font-size: 12px;
}

.generateTabs {
  display: none;
  gap: 8px;
  margin: -4px 0 18px;
}
.generateTabs button {
  border-color: var(--line);
  background: #fff;
  color: var(--ink);
}
.generateTabs button.active {
  background: var(--ink);
  color: #fff;
  border-color: var(--ink);
}
.generatePane {
  display: grid;
  gap: 12px;
}

.status {
  padding: 14px;
  border: 1px solid var(--line);
  background: #fff9ef;
  color: var(--muted);
  font-size: 13px;
  line-height: 1.45;
}
.stateGrid {
  display: grid;
  gap: 7px;
}
.stateRow {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
}
.stateRow strong {
  color: var(--ink);
  font-size: 12px;
}
.statePill {
  padding: 3px 7px;
  border: 1px solid var(--line);
  background: #fff;
  color: var(--muted);
  font-size: 11px;
}
.statePill.done {
  border-color: rgba(81,122,87,.35);
  background: #edf5ed;
  color: var(--ok);
}
.statePill.pending {
  border-color: rgba(166,107,45,.28);
  background: #fff6e8;
  color: var(--warn);
}

.logPanel {
  margin-top: auto;
  display: grid;
  gap: 8px;
}
.logHeader {
  display: flex;
  align-items: center;
  justify-content: space-between;
}
.logHeader strong {
  font-size: 15px;
}

main {
  margin-left: 300px;
  padding: 28px 36px 70px;
  max-width: 1600px;
}

.hero {
  min-height: 176px;
  display: grid;
  grid-template-columns: minmax(420px, 1fr) minmax(280px, 420px);
  align-items: end;
  gap: 24px;
  border-bottom: 1px solid var(--line);
  margin-bottom: 18px;
}
.eyebrow {
  margin: 0 0 8px;
  color: var(--accent-strong);
  font-size: 12px;
  font-weight: 700;
  letter-spacing: .12em;
  text-transform: uppercase;
}
.heroFacts {
  display: grid;
  gap: 8px;
  padding-bottom: 22px;
}
.heroFacts span {
  padding: 9px 11px;
  border: 1px solid var(--line);
  background: rgba(255,255,255,.52);
  color: var(--muted);
  font-size: 13px;
}

h1 { font-size: 42px; margin: 0 0 10px; letter-spacing: 0; }
h2 { margin: 0; font-size: 25px; }
p { color: var(--muted); line-height: 1.6; }

.flowBoard {
  display: grid;
  grid-template-columns: repeat(5, minmax(0, 1fr));
  gap: 10px;
  margin-bottom: 26px;
}
.flowStep {
  display: grid;
  gap: 6px;
  min-height: 82px;
  padding: 12px;
  border: 1px solid var(--line);
  background: var(--surface);
  text-decoration: none;
}
.flowStep b {
  color: var(--ink);
  font-size: 13px;
}
.flowStep span {
  color: var(--muted);
  font-size: 12px;
  line-height: 1.35;
}
.flowStep small {
  width: fit-content;
  padding: 3px 6px;
  border: 1px solid var(--line);
  background: #fff;
  color: var(--muted);
  font-size: 11px;
}
.flowStep.done {
  border-color: rgba(81,122,87,.45);
  background: #f3f8f1;
}
.flowStep.done small {
  border-color: rgba(81,122,87,.35);
  background: #edf5ed;
  color: var(--ok);
}
.flowStep.current {
  border-color: var(--accent);
  box-shadow: inset 4px 0 0 var(--accent);
  background: #fffaf2;
}
.flowStep.current small {
  border-color: rgba(181,91,77,.38);
  background: #fff0ec;
  color: var(--accent-strong);
}

.panel {
  background: var(--panel);
  border: 1px solid var(--line);
  box-shadow: var(--shadow);
  padding: 28px;
  margin: 0 0 28px;
}

.section-title {
  display: flex;
  align-items: flex-start;
  gap: 16px;
  margin-bottom: 22px;
  padding-bottom: 18px;
  border-bottom: 1px solid var(--line);
}
.section-title span {
  width: 38px;
  height: 38px;
  display: grid;
  place-items: center;
  background: var(--accent);
  color: #fff;
  font-weight: 800;
}
.section-title p { margin: 6px 0 0; }

.grid.two {
  display: grid;
  grid-template-columns: minmax(300px, 0.82fr) minmax(420px, 1.18fr);
  gap: 26px;
}

.controls {
  display: grid;
  gap: 12px;
  align-content: start;
}
.workControls {
  position: sticky;
  top: 18px;
  align-self: start;
}
.workPreview {
  min-width: 0;
}

.configCard {
  border: 1px solid var(--line);
  background: #fff;
  padding: 18px;
}

.configCard h3 {
  margin: 0 0 4px;
  font-size: 20px;
}

.configActions {
  margin-top: 18px;
}

.modalOverlay {
  position: fixed;
  inset: 0;
  z-index: 20;
  display: none;
  align-items: center;
  justify-content: center;
  padding: 28px;
  background: rgba(31, 27, 23, 0.42);
}
.modalOverlay.show { display: flex; }
.modalPanel {
  width: min(1120px, 100%);
  max-height: min(860px, calc(100vh - 56px));
  overflow: auto;
  background: var(--panel);
  border: 1px solid var(--line);
  box-shadow: 0 30px 90px rgba(20, 17, 14, 0.24);
  padding: 26px;
}
.modalHeader {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 18px;
  margin-bottom: 20px;
}
.modalHeader h2 { margin: 0; }
.modalHeader p { margin: 6px 0 0; }
.iconButton {
  width: 42px;
  height: 42px;
  padding: 0;
  display: grid;
  place-items: center;
  font-size: 26px;
  line-height: 1;
}
.configGrid {
  grid-template-columns: repeat(2, minmax(0, 1fr));
}
.settingsTabs {
  display: inline-flex;
  gap: 6px;
  padding: 5px;
  margin: 20px 0;
  border: 1px solid var(--line);
  background: #fbf8f1;
}
.settingsTabs button {
  border-color: transparent;
  background: transparent;
  color: var(--ink);
  padding: 9px 14px;
}
.settingsTabs button.active {
  background: var(--ink);
  color: #fff;
}
.settingsPane { display: none; }
.settingsPane.active { display: block; }
.blankGarmentList {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(180px, 1fr));
  gap: 12px;
  min-height: 160px;
  color: var(--muted);
}
.blankGarmentCard {
  border: 1px solid var(--line);
  background: #fffdf8;
  padding: 10px;
  cursor: pointer;
}
.blankGarmentCard:hover {
  border-color: var(--accent);
}
.blankGarmentCard img {
  width: 100%;
  aspect-ratio: 4 / 3;
  object-fit: contain;
  background: #f5f1e8;
  display: block;
}
.blankGarmentCard strong {
  display: block;
  margin-top: 9px;
  color: var(--ink);
  font-size: 14px;
}
.blankGarmentCard span {
  display: block;
  margin-top: 4px;
  font-size: 12px;
  line-height: 1.35;
}
.userList {
  display: grid;
  gap: 10px;
  min-height: 160px;
  color: var(--muted);
}
.userItem {
  display: grid;
  grid-template-columns: minmax(180px, 1fr) minmax(280px, auto);
  gap: 12px;
  align-items: center;
  padding: 12px;
  border: 1px solid var(--line);
  background: #fffdf8;
}
.userItem.disabled {
  opacity: .66;
}
.userMeta strong {
  display: block;
  color: var(--ink);
  font-size: 15px;
}
.userMeta span,
.userMeta small {
  display: block;
  margin-top: 4px;
  color: var(--muted);
  font-size: 12px;
  line-height: 1.35;
}
.userActions {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 6px;
}
.userActions button {
  min-height: 32px;
  padding: 5px 7px;
  font-size: 12px;
}

label, .hint {
  color: var(--muted);
  font-size: 14px;
}

input, textarea, select, button {
  font: inherit;
  border: 1px solid var(--line);
  background: #fff;
  color: var(--ink);
}

input, textarea, select {
  width: 100%;
  padding: 11px 12px;
}

textarea { min-height: 120px; resize: vertical; }

.briefInput {
  line-height: 1.55;
  background: #fffdf8;
}
.directionBrief {
  min-height: 92px;
  font-size: 15px;
  border-left: 4px solid var(--accent);
}
.promptBrief {
  min-height: 190px;
  font-size: 14px;
}

button {
  padding: 12px 16px;
  border-color: var(--ink);
  background: var(--ink);
  color: #fff;
  cursor: pointer;
  transition: background .16s ease, border-color .16s ease, transform .12s ease;
}
button:hover { background: #161411; }
button:active { transform: translateY(1px); }
button.secondary {
  background: transparent;
  color: var(--ink);
  border-color: var(--line);
}
button.secondary:hover { background: #fff7eb; }

.errorBox {
  padding: 12px 14px;
  border: 1px solid #d25a4d;
  background: #fff3ef;
  color: #7f271f;
  font-size: 13px;
  line-height: 1.5;
  white-space: pre-wrap;
  max-height: 220px;
  overflow: auto;
}
.errorBox strong {
  display: block;
  margin-bottom: 6px;
  color: #5f1914;
}
.errorBox a {
  display: block;
  margin-top: 5px;
  color: #7f271f;
  word-break: break-all;
}
.errorBox.mutedLog {
  border-color: var(--line);
  background: #fff9ef;
  color: var(--muted);
}

.actions, .row {
  display: flex;
  gap: 10px;
  align-items: center;
}
.row label { white-space: nowrap; }
.row input[type="number"] { max-width: 95px; }
.row output { min-width: 34px; color: var(--muted); }

.cards {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(210px, 1fr));
  gap: 14px;
  margin-top: 14px;
}
.card {
  border: 1px solid var(--line);
  background: #fff;
  padding: 10px;
}
.card.active {
  border-color: var(--accent);
  box-shadow: inset 0 0 0 2px var(--accent);
}
.cardMeta {
  display: flex;
  justify-content: space-between;
  gap: 8px;
  margin-top: 8px;
  color: var(--muted);
  font-size: 12px;
}
.cardMeta b {
  color: var(--ink);
}
.card img {
  width: 100%;
  aspect-ratio: 1 / 1;
  object-fit: contain;
  background: #f1eee8;
  display: block;
}
.card button {
  width: 100%;
  margin-top: 10px;
}

.qc {
  display: grid;
  gap: 10px;
}
.canvasWrap {
  position: relative;
  width: 100%;
  min-height: 560px;
  border: 1px solid var(--line);
  background-color: #ddd;
  background-image:
    linear-gradient(45deg, #c9c9c9 25%, transparent 25%),
    linear-gradient(-45deg, #c9c9c9 25%, transparent 25%),
    linear-gradient(45deg, transparent 75%, #c9c9c9 75%),
    linear-gradient(-45deg, transparent 75%, #c9c9c9 75%);
  background-size: 32px 32px;
  background-position: 0 0, 0 16px, 16px -16px, -16px 0;
  overflow: hidden;
}
canvas {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
}

.preview {
  width: 100%;
  max-height: 760px;
  object-fit: contain;
  background: #fff;
  border: 1px solid var(--line);
  display: none;
}

.filelink, .links a {
  display: block;
  color: var(--accent-strong);
  word-break: break-all;
  line-height: 1.5;
}

.analysisBox {
  min-height: 230px;
  margin: 8px 0 20px;
  padding: 16px;
  border: 1px solid var(--line);
  background: #fff;
  color: var(--ink);
  line-height: 1.58;
  white-space: pre-wrap;
  max-height: 520px;
  overflow: auto;
}
.analysisBox.empty {
  color: var(--muted);
  background: #fbf8f1;
}
.analysisBox b {
  color: var(--accent-strong);
}
.palette {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin: 10px 0 12px;
}
.swatch {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 6px 8px;
  border: 1px solid var(--line);
  background: #fffefa;
  font-size: 12px;
}
.swatch i {
  display: inline-block;
  width: 18px;
  height: 18px;
  border: 1px solid rgba(0,0,0,.15);
}

.segmented {
  display: grid;
  grid-template-columns: 1fr 1fr;
  border: 1px solid var(--line);
  background: #fff;
}
.segmented button {
  border: 0;
  background: transparent;
  color: var(--ink);
}
.segmented button.active {
  background: var(--accent);
  color: #fff;
}

.recommendationStrip {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(145px, 1fr));
  gap: 10px;
}
.recCard,
.styleCard {
  border: 1px solid var(--line);
  background: #fff;
  padding: 10px;
  cursor: pointer;
}
.recCard:hover,
.styleCard:hover,
.colorChip:hover { border-color: var(--accent); }
.recCard.active,
.styleCard.active,
.colorChip.active {
  outline: 2px solid var(--accent);
  outline-offset: 0;
}
.recCard img {
  width: 100%;
  aspect-ratio: 3 / 2;
  object-fit: contain;
  background: #f8f6f0;
  display: block;
}
.recCard strong,
.styleCard strong {
  display: block;
  margin-top: 8px;
  font-size: 14px;
}
.recCard span,
.styleCard span {
  display: block;
  margin-top: 4px;
  color: var(--muted);
  font-size: 12px;
  line-height: 1.4;
}
.styleCards {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(150px, 1fr));
  gap: 10px;
}
.colorSwatches {
  display: flex;
  flex-wrap: wrap;
  gap: 9px;
}
.colorChip {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  min-height: 38px;
  padding: 8px 10px;
  border: 1px solid var(--line);
  background: #fff;
  cursor: pointer;
}
.colorChip i {
  width: 22px;
  height: 22px;
  border: 1px solid rgba(0,0,0,.18);
}
.choiceNote {
  min-height: 42px;
  padding: 10px 12px;
  background: #fbf8f1;
  border: 1px solid var(--line);
  color: var(--muted);
  line-height: 1.45;
}
.choiceNote b {
  color: var(--ink);
}
.placementStage {
  width: 100%;
  min-height: 520px;
  border: 1px solid var(--line);
  background: #fff;
  display: grid;
  place-items: center;
  overflow: hidden;
  margin-bottom: 10px;
}
#placementCanvas {
  position: static;
  display: block;
  max-width: 100%;
  height: auto;
  cursor: grab;
}
#placementCanvas.dragging { cursor: grabbing; }
#placementCanvas.resizing,
#placementCanvas.resizeHover { cursor: nwse-resize; }

#toast {
  position: fixed;
  right: 26px;
  bottom: 26px;
  max-width: 420px;
  padding: 14px 16px;
  background: var(--ink);
  color: #fff;
  opacity: 0;
  transform: translateY(10px);
  transition: 0.2s ease;
  pointer-events: none;
}
#toast.show { opacity: 1; transform: translateY(0); }

@media (max-width: 1100px) {
  .rail { position: static; width: auto; }
  .historyPanel,
  .logPanel {
    display: none;
  }
  main { margin-left: 0; padding: 24px; }
  .hero { grid-template-columns: 1fr; }
  .heroFacts { padding-bottom: 12px; }
  .flowBoard { grid-template-columns: 1fr; }
  .grid.two { grid-template-columns: 1fr; }
  .workControls { position: static; }
  .generateTabs {
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
  }
  body[data-generate-tab="style"] #generate .generatePanePrompt,
  body[data-generate-tab="style"] #generate .generatePaneResult,
  body[data-generate-tab="prompt"] #generate .generatePaneStyle,
  body[data-generate-tab="prompt"] #generate .generatePaneResult,
  body[data-generate-tab="result"] #generate .generatePaneStyle,
  body[data-generate-tab="result"] #generate .generatePanePrompt {
    display: none;
  }
  .actions,
  .row {
    flex-direction: column;
    align-items: stretch;
  }
  .actions button,
  .row input,
  .row select {
    width: 100%;
    max-width: none;
  }
  .row label {
    white-space: normal;
  }
  .configGrid { grid-template-columns: 1fr; }
  .userItem { grid-template-columns: 1fr; }
  .historyGridLarge {
    grid-template-columns: repeat(auto-fill, minmax(150px, 1fr));
    max-height: 70vh;
  }
  .modalOverlay { padding: 16px; align-items: flex-start; }
  .canvasWrap { min-height: 460px; }
}

@media (max-width: 760px) {
  .rail {
    padding: 18px 16px;
    gap: 14px;
  }
  .brand {
    align-items: flex-start;
  }
  .mark {
    width: 46px;
    height: 46px;
  }
  nav {
    grid-template-columns: 1fr 1fr;
  }
  nav a {
    grid-template-columns: 30px 1fr;
    padding: 9px 10px;
  }
  .railSettings {
    min-height: 42px;
  }
  .status {
    padding: 10px;
  }
  .stateGrid {
    grid-template-columns: 1fr 1fr;
    gap: 6px;
  }
  .stateRow {
    display: grid;
    gap: 3px;
    align-items: start;
  }
  main {
    padding: 18px 14px 54px;
  }
  .hero {
    min-height: auto;
    gap: 14px;
    margin-bottom: 14px;
    padding-bottom: 16px;
  }
  h1 {
    font-size: 34px;
  }
  .heroFacts {
    gap: 6px;
  }
  .flowBoard {
    gap: 8px;
  }
  .flowStep {
    min-height: auto;
  }
  .panel {
    padding: 18px;
  }
  .section-title {
    gap: 12px;
  }
  .section-title span {
    width: 34px;
    height: 34px;
  }
  h2 {
    font-size: 21px;
  }
  .styleLibrary {
    max-height: 420px;
    grid-template-columns: 1fr;
  }
  .styleSearchRow,
  .libraryTop,
  .historyToolbar {
    grid-template-columns: 1fr;
    display: grid;
  }
  .styleSearchRow .compactBtn,
  .libraryTop .compactBtn {
    width: 100%;
  }
  .historyGridLarge {
    grid-template-columns: 1fr 1fr;
  }
  .settingsTabs {
    width: 100%;
    flex-wrap: wrap;
  }
  .settingsTabs button {
    flex: 1 1 120px;
  }
  .userActions {
    grid-template-columns: 1fr 1fr;
  }
  .segmented button {
    min-height: 44px;
  }
  .canvasWrap,
  .placementStage {
    min-height: 360px;
  }
}
