/* =========================================================
   豆格 DOUGE — bead pattern studio
   ========================================================= */
:root {
  --bg: #f2ecdf;
  --bg-deep: #e9e1d1;
  --surface: #fffdf8;
  --surface-2: #faf5ea;
  --surface-3: #f3ecdf;
  --ink: #211e18;
  --ink-soft: #3d372e;
  --muted: #7d7466;
  --faint: #a79c8b;
  --line: #e8dfd0;
  --line-strong: #d8ccb8;
  --accent: #f05a36;
  --accent-deep: #d84524;
  --accent-soft: #ffe5da;
  --green: #3c6850;
  --green-soft: #e1ebe1;
  --gold: #e4b450;
  --blue: #53798b;
  --shadow-sm: 0 1px 2px rgba(54, 42, 26, 0.05);
  --shadow-panel: 0 18px 50px -38px rgba(54, 42, 26, 0.5), 0 1px 0 rgba(255, 255, 255, 0.9) inset;
  --shadow-float: 0 20px 45px -22px rgba(54, 42, 26, 0.35);
  --radius-xl: 26px;
  --radius-lg: 20px;
  --radius-md: 14px;
  --radius-sm: 10px;
  --font: "Segoe UI", "PingFang SC", "Hiragino Sans GB", "Microsoft YaHei UI", "Microsoft YaHei", sans-serif;
  --mono: "Cascadia Code", "SFMono-Regular", "Consolas", "Liberation Mono", monospace;
}

* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
[hidden] { display: none !important; }
body {
  height: 100vh;
  overflow: hidden;
  color: var(--ink);
  background: var(--bg);
  font-family: var(--font);
  font-size: 13px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}
body::before {
  content: "";
  position: fixed;
  inset: 0;
  z-index: -1;
  background:
    radial-gradient(circle at 8% 0%, rgba(249, 221, 181, 0.6), transparent 30%),
    radial-gradient(circle at 100% 12%, rgba(219, 234, 218, 0.45), transparent 28%),
    radial-gradient(circle at 48% 100%, rgba(242, 221, 208, 0.5), transparent 36%),
    var(--bg);
}
button, input, select, textarea { font: inherit; color: inherit; }
button { border: 0; background: none; cursor: pointer; }
button:disabled { cursor: not-allowed; }
a { color: inherit; }
img { display: block; max-width: 100%; }
h1, h2, h3, p { margin: 0; }
ul { margin: 0; padding: 0; list-style: none; }
::selection { background: var(--accent-soft); color: var(--accent-deep); }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
.svg-sprite { position: absolute; width: 0; height: 0; overflow: hidden; }
.icon { width: 18px; height: 18px; fill: none; stroke: currentColor; stroke-width: 1.7; stroke-linecap: round; stroke-linejoin: round; flex: 0 0 auto; }

* { scrollbar-width: thin; scrollbar-color: #d5c9b5 transparent; }
*::-webkit-scrollbar { width: 6px; height: 6px; }
*::-webkit-scrollbar-track { background: transparent; }
*::-webkit-scrollbar-thumb { background: #d5c9b5; border-radius: 99px; }
*::-webkit-scrollbar-thumb:hover { background: #bfb19b; }

/* ======================= Top bar ======================= */
.app-shell { height: 100dvh; display: flex; flex-direction: column; }
.topbar {
  height: 70px;
  flex: 0 0 70px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 24px;
  padding: 0 24px;
  position: relative;
  z-index: 20;
}
.brand-block { display: flex; align-items: center; gap: 12px; flex: 0 0 auto; }
.logo-mark {
  width: 38px;
  height: 38px;
  border-radius: 12px;
  background: var(--ink);
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 3px;
  padding: 7px;
  box-shadow: 0 6px 14px -8px rgba(30, 24, 16, 0.7), inset 0 1px 0 rgba(255,255,255,.15);
}
.logo-mark span { border-radius: 50%; background: #f5ecd9; opacity: .9; }
.logo-mark .logo-accent { background: var(--accent); opacity: 1; }
.logo-mark .logo-green { background: #9bb88c; opacity: 1; }
.brand-copy { display: flex; flex-direction: column; gap: 1px; }
.brand-row { display: flex; align-items: baseline; gap: 7px; }
.brand-name { font-size: 20px; line-height: 1.1; font-weight: 800; letter-spacing: -0.04em; }
.brand-latin { font-family: var(--mono); font-size: 9px; letter-spacing: .16em; color: var(--muted); font-weight: 600; }
.brand-copy p { font-size: 10.5px; color: var(--muted); letter-spacing: .02em; }
.topbar-center { display: flex; align-items: center; gap: 14px; min-width: 0; }
.workspace-pill {
  display: inline-flex; align-items: center; gap: 7px;
  height: 28px; padding: 0 11px;
  border: 1px solid var(--line); background: rgba(255, 253, 248, .58);
  border-radius: 99px; font-size: 11px; color: var(--ink-soft); white-space: nowrap;
}
.live-dot { width: 6px; height: 6px; border-radius: 50%; background: #5f8a66; box-shadow: 0 0 0 3px rgba(95,138,102,.12); flex: 0 0 auto; }
.project-title { font-size: 12px; color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; max-width: 260px; }
.topbar-actions { display: flex; align-items: center; gap: 10px; flex: 0 0 auto; }
.icon-text-btn { display: inline-flex; align-items: center; gap: 7px; height: 36px; padding: 0 10px; color: var(--muted); border-radius: 10px; font-size: 12px; transition: .18s ease; position: relative; }
.icon-text-btn:hover { background: rgba(255,253,248,.7); color: var(--ink); }
.cloud-entry-dot { width: 5px; height: 5px; border-radius: 50%; background: #c9bdab; flex: 0 0 auto; transition: .2s ease; }
.cloud-entry-dot.is-online { background: #6d9771; box-shadow: 0 0 0 2px rgba(109,151,113,.15); }
.cloud-entry-dot.is-error { background: var(--accent); box-shadow: 0 0 0 2px rgba(240,90,54,.12); }
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  border-radius: 12px; height: 40px; padding: 0 16px;
  font-weight: 700; font-size: 12.5px; letter-spacing: .01em;
  transition: transform .16s ease, background .16s ease, border-color .16s ease, box-shadow .16s ease, opacity .16s ease;
  white-space: nowrap;
}
.btn .icon { width: 17px; height: 17px; }
.btn:active { transform: translateY(1px); }
.btn:disabled { opacity: .4; pointer-events: none; }
.btn-primary { background: var(--accent); color: #fff9f2; box-shadow: 0 9px 20px -10px rgba(240,90,54,.75), inset 0 1px 0 rgba(255,255,255,.22); }
.btn-primary:hover { background: var(--accent-deep); box-shadow: 0 12px 24px -12px rgba(240,90,54,.9); }
.btn-ghost { background: rgba(255,253,248,.8); border: 1px solid var(--line); color: var(--ink); }
.btn-ghost:hover { border-color: var(--line-strong); background: #fffdf8; }
.btn-outline { border: 1px solid var(--line-strong); background: var(--surface); color: var(--ink-soft); }
.btn-outline:hover { border-color: var(--ink-soft); }
.btn-quiet { background: var(--surface-3); color: var(--muted); }
.btn-quiet:hover { color: var(--ink); background: #ece3d4; }
.top-export { height: 38px; padding: 0 15px; }
.demo-dot { width: 8px; height: 8px; border-radius: 50%; background: var(--gold); box-shadow: 0 0 0 3px rgba(228,180,80,.18); }

/* ======================= Layout ======================= */
.app-grid {
  flex: 1;
  min-height: 0;
  display: grid;
  grid-template-columns: 300px minmax(420px, 1fr) 314px;
  gap: 16px;
  padding: 0 18px 18px;
}
.panel {
  min-height: 0;
  background: rgba(255, 253, 248, .82);
  border: 1px solid rgba(221, 210, 193, .85);
  border-radius: var(--radius-xl);
  box-shadow: var(--shadow-panel);
  backdrop-filter: blur(12px);
}
.panel-scroll { height: 100%; overflow-y: auto; overflow-x: hidden; padding: 20px 18px; }
.left-panel { display: flex; flex-direction: column; }
.left-panel .panel-scroll { flex: 1; min-height: 0; height: auto; padding: 22px 18px 12px; }
.left-panel > .generate-zone {
  flex: 0 0 auto;
  padding: 12px 18px 15px;
  border-top: 1px solid rgba(226, 216, 201, .8);
  background: linear-gradient(180deg, rgba(255, 253, 248, .72), var(--surface) 38%);
  box-shadow: 0 -14px 28px -26px rgba(49, 36, 20, .38);
  position: relative;
  z-index: 2;
}
.right-panel .panel-scroll { padding: 20px 16px; }

/* ======================= Left panel ======================= */
.panel-intro { padding: 2px 4px 16px; }
.eyebrow, .card-kicker, .modal-kicker {
  font-family: var(--mono); font-size: 9px; font-weight: 600;
  letter-spacing: .14em; color: var(--faint); text-transform: uppercase;
}
.panel-intro h1 { margin-top: 8px; font-size: 23px; line-height: 1.3; letter-spacing: -.035em; font-weight: 800; }
.panel-intro p { margin-top: 7px; color: var(--muted); font-size: 11.5px; line-height: 1.65; }
.setup-card {
  border: 1px solid var(--line);
  background: rgba(255, 253, 248, .76);
  border-radius: 18px;
  padding: 14px;
  margin-bottom: 10px;
}
.section-heading { display: flex; gap: 9px; align-items: flex-start; margin-bottom: 12px; }
.step-index {
  width: 25px; height: 25px; border-radius: 8px;
  border: 1px solid var(--line-strong);
  background: var(--surface-2);
  color: var(--muted);
  display: grid; place-items: center;
  font-family: var(--mono); font-size: 9px; font-weight: 700;
  flex: 0 0 auto;
}
.section-heading h2 { font-size: 13.5px; font-weight: 750; letter-spacing: -.01em; margin-top: 1px; }
.section-heading p { margin-top: 2px; font-size: 10.5px; color: var(--faint); }

.dropzone {
  border: 1.5px dashed var(--line-strong);
  border-radius: 14px;
  background: var(--surface-2);
  min-height: 136px;
  transition: .2s ease;
  position: relative;
  overflow: hidden;
}
.dropzone:hover, .dropzone:focus-visible, .dropzone.is-dragging { border-color: var(--accent); background: #fff7ef; }
.dropzone.is-dragging { box-shadow: 0 0 0 4px var(--accent-soft); }
.upload-idle { min-height: 136px; padding: 20px 12px; display: flex; flex-direction: column; align-items: center; justify-content: center; text-align: center; gap: 4px; }
.upload-icon { width: 36px; height: 36px; border-radius: 11px; display: grid; place-items: center; background: var(--surface); border: 1px solid var(--line); color: var(--accent); margin-bottom: 4px; box-shadow: var(--shadow-sm); }
.upload-icon .icon { width: 19px; height: 19px; }
.upload-idle strong { font-size: 12px; font-weight: 700; }
.upload-idle > span:last-child { font-size: 9.5px; color: var(--faint); max-width: 190px; line-height: 1.5; }
.upload-loaded { display: flex; gap: 11px; align-items: flex-start; padding: 10px; min-height: 136px; }
.thumb-wrap { position: relative; width: 88px; height: 112px; border-radius: 10px; overflow: hidden; flex: 0 0 auto; background: #e6ddce; }
.thumb-wrap img { width: 100%; height: 100%; object-fit: cover; }
.thumb-badge {
  position: absolute; left: 5px; bottom: 5px;
  background: rgba(24,20,15,.72); color: #fff; font-size: 8px;
  border-radius: 5px; padding: 2px 5px;
  backdrop-filter: blur(4px);
}
.thumb-copy { min-width: 0; flex: 1; padding-top: 2px; display: flex; flex-direction: column; align-items: flex-start; }
.thumb-copy strong { font-size: 11.5px; max-width: 124px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.thumb-copy > span { color: var(--faint); font-size: 9.5px; margin-top: 2px; }
.thumb-actions { margin-top: auto; display: flex; flex-direction: column; align-items: flex-start; gap: 5px; }
.thumb-actions > span { display: none; }
.text-btn { display: inline-flex; align-items: center; gap: 4px; font-size: 10.5px; font-weight: 650; color: var(--ink-soft); padding: 0; }
.text-btn .icon { width: 13px; height: 13px; }
.text-btn:hover { color: var(--accent); }
.remove-img { position: absolute; top: 6px; right: 6px; }
.mini-icon-btn {
  width: 29px; height: 29px; border-radius: 8px;
  display: inline-grid; place-items: center; color: var(--muted);
  border: 1px solid transparent; transition: .15s ease;
}
.mini-icon-btn .icon { width: 16px; height: 16px; }
.mini-icon-btn:hover { background: var(--surface-2); border-color: var(--line); color: var(--ink); }
.mini-icon-btn:disabled { opacity: .32; pointer-events: none; }
.field-help { margin-top: 8px; font-size: 9.5px; color: var(--faint); line-height: 1.55; padding: 0 2px; }

.dimension-editor { display: flex; align-items: center; gap: 7px; }
.dim-field {
  position: relative;
  height: 50px; flex: 1; min-width: 0;
  border: 1px solid var(--line); border-radius: 11px;
  background: var(--surface-2);
  display: grid; grid-template-columns: auto minmax(0,1fr) auto; align-items: center;
  padding: 0 10px; gap: 2px;
  transition: .15s ease;
}
.dim-field:focus-within { border-color: var(--ink-soft); background: var(--surface); box-shadow: 0 0 0 3px rgba(33,30,24,.05); }
.dim-field > span { font-size: 9px; color: var(--faint); position: absolute; transform: translateY(-13px); pointer-events: none; }
.dim-field input { width: 100%; border: 0; background: none; outline: none; font-family: var(--mono); font-size: 18px; font-weight: 700; letter-spacing: -.05em; padding: 8px 0 0; text-align: left; -moz-appearance: textfield; }
.dim-field input::-webkit-outer-spin-button, .dim-field input::-webkit-inner-spin-button { -webkit-appearance: none; margin: 0; }
.dim-field em { font-style: normal; font-size: 9px; color: var(--faint); padding-top: 9px; }
.ratio-lock { width: 29px; height: 29px; flex: 0 0 auto; border-radius: 8px; display: grid; place-items: center; color: var(--muted); background: var(--surface-3); transition: .15s ease; }
.ratio-lock:hover { color: var(--ink); background: var(--line); }
.ratio-lock.is-locked { color: var(--accent); background: var(--accent-soft); }
.ratio-lock .lock-off { display: none; }
.ratio-lock:not(.is-locked) .lock-off { display: block; }
.ratio-lock:not(.is-locked) .lock-on { display: none; }
.ratio-lock .icon { width: 14px; height: 14px; }
.size-presets { display: grid; grid-template-columns: repeat(4, 1fr); gap: 5px; margin-top: 8px; }
.size-presets button {
  min-width: 0; height: 44px; border-radius: 9px; border: 1px solid var(--line);
  background: var(--surface-2); display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 1px;
  transition: .15s ease; color: var(--muted);
}
.size-presets button strong { font-family: var(--mono); font-size: 12px; color: var(--ink-soft); }
.size-presets button span { font-size: 8px; color: var(--faint); white-space: nowrap; }
.size-presets button:hover { border-color: var(--line-strong); background: var(--surface); }
.size-presets button.is-active { border-color: var(--ink); background: var(--ink); color: #fff; box-shadow: 0 5px 12px -7px rgba(30,24,16,.65); }
.size-presets button.is-active strong { color: #fff; }
.size-presets button.is-active span { color: rgba(255,255,255,.55); }
.board-setting { display: flex; align-items: center; justify-content: space-between; gap: 10px; margin-top: 10px; }
.board-setting > label { font-size: 10.5px; color: var(--muted); }
.select-wrap { position: relative; }
.select-wrap select {
  appearance: none; -webkit-appearance: none;
  height: 30px; border: 1px solid var(--line); border-radius: 8px;
  background: var(--surface); padding: 0 25px 0 9px; font-size: 10.5px; color: var(--ink-soft); cursor: pointer; outline: none;
}
.select-wrap .icon { width: 12px; height: 12px; position: absolute; right: 8px; top: 9px; pointer-events: none; color: var(--faint); }
.estimate-strip {
  display: flex; align-items: center; justify-content: center; flex-wrap: wrap; gap: 6px;
  margin-top: 9px; padding: 7px 8px; border-radius: 8px;
  background: var(--surface-3); color: var(--muted);
  font-size: 9.5px; line-height: 1.3; text-align: center;
}
.estimate-strip b { color: var(--ink-soft); font-family: var(--mono); font-weight: 600; }
.estimate-strip i { width: 1px; height: 9px; background: var(--line-strong); }
.physical-size { margin-top: 5px; text-align: center; color: var(--faint); font-size: 8.5px; letter-spacing: .01em; }

.style-tabs { display: grid; grid-template-columns: repeat(3,1fr); gap: 5px; padding: 3px; border-radius: 10px; background: var(--surface-3); }
.style-tabs button { height: 32px; border-radius: 8px; display: flex; align-items: center; justify-content: center; gap: 5px; font-size: 10.5px; color: var(--muted); transition: .15s ease; }
.style-tabs button:hover { color: var(--ink); }
.style-tabs button.is-active { background: var(--surface); color: var(--ink); box-shadow: var(--shadow-sm); font-weight: 650; }
.style-dot { width: 7px; height: 7px; border-radius: 50%; }
.dot-cartoon { background: var(--accent); box-shadow: 0 0 0 2px var(--accent-soft); }
.dot-real { background: var(--blue); box-shadow: 0 0 0 2px rgba(83,121,139,.15); }
.dot-soft { background: var(--gold); box-shadow: 0 0 0 2px rgba(228,180,80,.18); }
.palette-row { display: flex; align-items: center; justify-content: space-between; gap: 10px; margin-top: 12px; }
.field-label { display: block; color: var(--faint); font-size: 9px; margin-bottom: 1px; }
.palette-name { font-family: var(--mono); font-size: 11.5px; font-weight: 600; letter-spacing: -.02em; }
.palette-mini { display: flex; gap: 2px; height: 25px; border-radius: 6px; overflow: hidden; width: 126px; border: 1px solid rgba(33,30,24,.08); }
.palette-mini i { flex: 1; min-width: 0; }
.range-block { margin-top: 13px; }
.range-label { display: flex; align-items: center; justify-content: space-between; gap: 8px; margin-bottom: 6px; font-size: 10px; color: var(--muted); }
.range-label output { font-family: var(--mono); font-size: 10px; font-weight: 600; color: var(--ink-soft); background: var(--surface-3); padding: 2px 6px; border-radius: 5px; }
input[type="range"] { -webkit-appearance: none; appearance: none; width: 100%; height: 16px; background: transparent; cursor: pointer; display: block; }
input[type="range"]::-webkit-slider-runnable-track { height: 4px; border-radius: 99px; background: linear-gradient(to right, var(--accent) var(--range-progress, 30%), #e7ddcd var(--range-progress, 30%)); }
input[type="range"]::-moz-range-track { height: 4px; border-radius: 99px; background: #e7ddcd; }
input[type="range"]::-moz-range-progress { height: 4px; border-radius: 99px; background: var(--accent); }
input[type="range"]::-webkit-slider-thumb { -webkit-appearance: none; width: 14px; height: 14px; margin-top: -5px; border-radius: 50%; background: var(--surface); border: 2px solid var(--accent); box-shadow: 0 1px 4px rgba(40,30,15,.2); transition: transform .1s; }
input[type="range"]::-moz-range-thumb { width: 12px; height: 12px; border-radius: 50%; background: var(--surface); border: 2px solid var(--accent); }
input[type="range"]:active::-webkit-slider-thumb { transform: scale(1.12); }
.range-ticks { display: flex; align-items: center; justify-content: space-between; margin-top: 2px; color: var(--faint); font-size: 8px; }
.switch-row { display: flex; align-items: center; gap: 10px; margin-top: 12px; cursor: pointer; position: relative; }
.switch-row > span { flex: 1; display: flex; flex-direction: column; min-width: 0; }
.switch-row strong { font-size: 10.5px; font-weight: 650; }
.switch-row small { font-size: 8.5px; color: var(--faint); margin-top: 1px; line-height: 1.45; }
.switch-row input { position: absolute; opacity: 0; pointer-events: none; }
.switch-track { width: 31px; height: 18px; flex: 0 0 auto; border-radius: 99px; background: #ddd2c1; position: relative; transition: .18s ease; }
.switch-track::after { content: ""; position: absolute; width: 14px; height: 14px; border-radius: 50%; top: 2px; left: 2px; background: #fffdf8; box-shadow: 0 1px 3px rgba(40,30,15,.25); transition: .18s ease; }
.switch-row input:checked + .switch-track { background: var(--green); }
.switch-row input:checked + .switch-track::after { transform: translateX(13px); }
.switch-row input:focus-visible + .switch-track { outline: 2px solid var(--accent); outline-offset: 2px; }
.generate-zone { padding: 4px 0 3px; }
.left-panel > .generate-zone .generate-note { margin-bottom: 0; }
.btn-generate { width: 100%; height: 51px; border-radius: 15px; font-size: 13.5px; justify-content: flex-start; padding: 0 15px 0 17px; position: relative; overflow: hidden; }
.btn-generate::after { content: ""; position: absolute; inset: 0; background: linear-gradient(115deg, transparent 10%, rgba(255,255,255,.2) 45%, transparent 70%); transform: translateX(-120%); transition: transform .6s ease; }
.btn-generate:hover::after { transform: translateX(120%); }
.btn-generate .icon { width: 19px; height: 19px; }
.btn-generate .btn-arrow { margin-left: auto; width: 25px; height: 25px; border-radius: 50%; background: rgba(255,255,255,.16); display: grid; place-items: center; }
.btn-generate .btn-arrow .icon { width: 14px; height: 14px; }
.btn-generate.has-changes { animation: gentlePulse 2s infinite; }
@keyframes gentlePulse { 0%,100% { box-shadow: 0 9px 20px -10px rgba(240,90,54,.6); } 50% { box-shadow: 0 10px 26px -8px rgba(240,90,54,.9), 0 0 0 4px rgba(240,90,54,.08); } }
.generate-note { text-align: center; color: var(--faint); font-size: 8.8px; line-height: 1.5; margin-top: 7px; padding: 0 7px; }

/* ======================= Workspace ======================= */
.workspace { min-width: 0; min-height: 0; display: flex; flex-direction: column; }
.workspace-head { display: flex; align-items: center; justify-content: space-between; gap: 16px; padding: 1px 2px 10px; }
.doc-heading-row { display: flex; align-items: center; gap: 9px; }
.document-title h1 { font-size: 19px; font-weight: 800; letter-spacing: -.035em; line-height: 1.2; }
.doc-badge { display: inline-flex; align-items: center; height: 20px; padding: 0 8px; border-radius: 5px; background: var(--surface-3); border: 1px solid var(--line); color: var(--faint); font-family: var(--mono); font-size: 8px; letter-spacing: .02em; white-space: nowrap; }
.doc-badge.is-ready { background: var(--green-soft); border-color: rgba(60,104,80,.15); color: var(--green); }
.doc-badge.is-dirty { background: #fbebcd; border-color: #f2ddb4; color: #8a6223; }
.document-title > p { color: var(--faint); font-size: 10px; margin-top: 3px; }
.head-controls { display: flex; align-items: center; gap: 4px; flex: 0 0 auto; }
.mode-switch { display: flex; padding: 3px; border-radius: 10px; background: rgba(255,253,248,.74); border: 1px solid var(--line); gap: 2px; margin-right: 5px; }
.mode-switch button { height: 28px; border-radius: 7px; padding: 0 9px; display: inline-flex; align-items: center; gap: 4px; font-size: 10px; color: var(--muted); transition: .15s ease; }
.mode-switch button .icon { width: 13px; height: 13px; }
.mode-switch button:hover:not(:disabled) { color: var(--ink); }
.mode-switch button.is-active { background: var(--ink); color: #fffdf8; box-shadow: 0 2px 6px -2px rgba(30,25,18,.4); }
.mode-switch button:disabled { opacity: .4; }

.canvas-toolbar {
  flex: 0 0 45px; height: 45px;
  display: flex; align-items: center; justify-content: space-between; gap: 10px;
  padding: 0 8px; margin-bottom: 8px;
  background: rgba(255,253,248,.7); border: 1px solid var(--line); border-radius: 14px;
  backdrop-filter: blur(10px);
}
.toolbar-group { display: flex; align-items: center; gap: 3px; min-width: 0; }
.display-switch { display: flex; gap: 2px; padding: 3px; border-radius: 8px; background: var(--surface-3); }
.display-switch button { height: 26px; border-radius: 6px; padding: 0 9px; font-size: 9.5px; color: var(--muted); transition: .15s; }
.display-switch button.is-active { background: var(--surface); color: var(--ink); box-shadow: var(--shadow-sm); font-weight: 650; }
.toolbar-sep { width: 1px; height: 16px; background: var(--line); margin: 0 5px; flex: 0 0 auto; }
.tool-toggle {
  height: 29px; border-radius: 7px; padding: 0 7px; display: inline-flex; align-items: center; gap: 4px;
  font-size: 9.5px; color: var(--faint); transition: .15s; white-space: nowrap;
}
.tool-toggle .icon { width: 14px; height: 14px; }
.tool-toggle:hover:not(:disabled) { background: var(--surface-2); color: var(--ink); }
.tool-toggle.is-on { color: var(--ink-soft); background: var(--surface); border: 1px solid var(--line); }
.tool-toggle.is-on .icon { color: var(--accent); }
.tool-toggle:disabled { opacity: .35; }
.toolbar-zoom { gap: 0; }
.zoom-readout { width: 44px; text-align: center; font-family: var(--mono); font-size: 9.5px; color: var(--muted); }

.edit-toolbar {
  flex: 0 0 48px; height: 48px;
  display: flex; align-items: center; gap: 4px;
  padding: 0 8px 0 7px; margin-bottom: 8px;
  border-radius: 14px; background: var(--ink); color: #f9f3e7;
  box-shadow: 0 10px 25px -17px rgba(30,24,16,.8);
  overflow-x: auto; overflow-y: hidden;
}
.edit-row { display: contents; }
.edit-tools { display: flex; gap: 2px; }
.edit-tool { height: 34px; padding: 0 8px; border-radius: 7px; display: inline-flex; align-items: center; gap: 4px; font-size: 9.5px; color: rgba(249,243,231,.58); transition: .15s; white-space: nowrap; }
.edit-tool .icon { width: 14px; height: 14px; }
.edit-tool:hover { background: rgba(255,255,255,.08); color: #fff; }
.edit-tool.is-active { background: rgba(255,255,255,.12); color: #fff; box-shadow: inset 0 0 0 1px rgba(255,255,255,.09); }
.edit-tool.is-active .icon { color: var(--accent); }
.edit-toolbar .toolbar-sep { background: rgba(255,255,255,.14); margin: 0 4px; }
.brush-sizes { display: flex; gap: 2px; }
.brush-sizes button { width: 26px; height: 26px; border-radius: 50%; font-family: var(--mono); font-size: 9px; color: rgba(249,243,231,.55); border: 1px solid transparent; }
.brush-sizes button:hover { color: #fff; }
.brush-sizes button.is-active { background: #f9f3e7; color: var(--ink); font-weight: 700; }
.edit-toolbar .mirror-sync { margin-left: 2px; flex: 0 0 auto; color: rgba(249,243,231,.55); font-size: 9px; }
.edit-toolbar .mirror-sync:hover { background: rgba(255,255,255,.08); color: #fff; }
.edit-toolbar .mirror-sync.is-on { background: rgba(240,90,54,.18); border-color: rgba(240,90,54,.25); color: #fff; }
.edit-toolbar .mirror-sync.is-on .icon { color: var(--accent); }
.edit-spacer { flex: 1; min-width: 6px; }
.active-color-btn { height: 32px; display: flex; align-items: center; gap: 7px; border-radius: 8px; background: rgba(255,255,255,.07); padding: 0 7px; color: #f9f3e7; flex: 0 0 auto; border: 1px solid rgba(255,255,255,.09); }
.active-color-btn:hover { background: rgba(255,255,255,.12); }
.active-swatch { width: 20px; height: 20px; border-radius: 5px; border: 1px solid rgba(255,255,255,.35); box-shadow: inset 0 0 0 1px rgba(30,24,16,.1); background: #FFE44B; }
.active-meta { display: flex; flex-direction: column; line-height: 1.1; text-align: left; }
.active-meta small { font-size: 7px; color: rgba(249,243,231,.45); letter-spacing: .03em; }
.active-meta strong { font-family: var(--mono); font-size: 10px; margin-top: 2px; }
.active-color-btn > .icon { width: 11px; height: 11px; color: rgba(249,243,231,.45); }
.text-pill { height: 30px; border-radius: 7px; padding: 0 8px; display: inline-flex; align-items: center; gap: 4px; font-size: 8.5px; color: rgba(249,243,231,.62); border: 1px solid rgba(255,255,255,.12); white-space: nowrap; flex: 0 0 auto; }
.text-pill:hover { color: #fff; background: rgba(255,255,255,.08); }
.text-pill .icon { width: 12px; height: 12px; }

.canvas-shell {
  flex: 1; min-height: 0; position: relative; overflow: hidden;
  background: #f8f3e9;
  border: 1px solid var(--line);
  border-radius: var(--radius-xl);
  box-shadow: 0 22px 50px -38px rgba(54, 42, 26, .55), inset 0 1px 0 rgba(255,255,255,.8);
  isolation: isolate;
}
.canvas-bg {
  position: absolute; inset: 0;
  background:
    radial-gradient(circle at 1px 1px, rgba(113, 96, 70, .10) 1px, transparent 1px) 0 0 / 18px 18px,
    linear-gradient(135deg, rgba(255,255,255,.55), transparent 45%),
    #f6f0e5;
}
.canvas-bg::after {
  content: ""; position: absolute; inset: 0;
  background: radial-gradient(ellipse at 50% 40%, transparent 45%, rgba(90,70,45,.055) 100%);
  pointer-events: none;
}
#boardCanvas { position: absolute; inset: 0; width: 100%; height: 100%; touch-action: none; display: block; z-index: 1; }
#boardCanvas.is-view { cursor: grab; }
#boardCanvas.is-panning { cursor: grabbing; }
#boardCanvas.is-editing { cursor: crosshair; }
.interaction-canvas { position: absolute; inset: 0; width: 100%; height: 100%; pointer-events: none; z-index: 2; }
body.modal-open { overflow: hidden; }

.empty-state {
  position: absolute; inset: 0; z-index: 2;
  display: grid; grid-template-columns: minmax(0, 1.14fr) minmax(230px, .86fr);
  align-items: center; gap: 20px;
  padding: clamp(28px, 5vw, 54px);
  overflow: hidden;
}
.hero-copy { position: relative; z-index: 2; max-width: 440px; }
.hero-kicker { display: inline-flex; align-items: center; gap: 8px; font-family: var(--mono); font-size: 8.5px; letter-spacing: .15em; color: var(--faint); }
.kicker-line { width: 22px; height: 1px; background: var(--line-strong); }
.hero-copy h2 { margin-top: 13px; font-size: clamp(27px, 2.9vw, 39px); line-height: 1.23; letter-spacing: -.055em; font-weight: 800; }
.hero-copy > p { max-width: 360px; margin-top: 12px; color: var(--muted); font-size: 11.5px; line-height: 1.7; }
.hero-actions { display: flex; gap: 8px; margin-top: 21px; flex-wrap: wrap; }
.hero-actions .btn { height: 42px; padding: 0 16px; }
.hero-actions .btn-ghost { height: 42px; }
.hero-features { display: flex; flex-wrap: wrap; gap: 12px; margin-top: 19px; color: var(--faint); font-size: 9px; }
.hero-features span { display: inline-flex; align-items: center; gap: 4px; }
.hero-features .icon { width: 11px; height: 11px; color: var(--green); stroke-width: 2.2; }
.hero-art-wrap { position: relative; min-height: 330px; display: flex; align-items: center; justify-content: center; }
.art-card { position: absolute; width: min(255px, 90%); aspect-ratio: 1; border-radius: 17px; background: #fffdf8; border: 1px solid var(--line); padding: 10px; box-shadow: 0 25px 45px -30px rgba(60,45,25,.45); }
.art-card-back { transform: rotate(-8deg) translate(-46px, 18px); opacity: .78; background: #f6ecd9; }
.art-card-front { transform: rotate(2.5deg) translate(20px, -6px); z-index: 2; }
.art-card-top { display: flex; align-items: center; justify-content: space-between; gap: 6px; padding: 2px 3px 8px; font-family: var(--mono); font-size: 8px; color: var(--muted); letter-spacing: .01em; }
.art-tag { background: var(--surface-3); padding: 2px 5px; border-radius: 4px; color: var(--faint); font-size: 7px; }
.art-grid { display: grid; width: 100%; height: calc(100% - 25px); grid-template-columns: repeat(15, 1fr); grid-template-rows: repeat(15, 1fr); gap: 1.5px; align-content: center; border-radius: 8px; overflow: hidden; background: #f3ebdc; padding: 7px; }
.art-grid i { border-radius: 50%; display: block; background: transparent; box-shadow: inset 0 0 0 0.5px rgba(58,44,27,.03); }
.art-grid i.has-color { box-shadow: inset 0 -1.2px 1.5px rgba(70,40,10,.16), inset 0 1px 1px rgba(255,255,255,.3); }
.floating-note { position: absolute; z-index: 4; background: var(--surface); border: 1px solid var(--line); box-shadow: var(--shadow-float); border-radius: 7px; padding: 5px 8px; font-family: var(--mono); font-size: 8px; color: var(--ink-soft); white-space: nowrap; }
.note-one { right: 2%; top: 9%; transform: rotate(5deg); }
.note-one::before { content: "●"; color: #f3c95e; margin-right: 5px; font-size: 7px; }
.note-two { left: 2%; bottom: 7%; transform: rotate(-4deg); }
.note-two::before { content: "▦"; color: var(--green); margin-right: 5px; font-size: 8px; }

.photo-stage { position: absolute; inset: 0; z-index: 2; overflow: hidden; }
.photo-stage > img { width: 100%; height: 100%; object-fit: cover; filter: saturate(.98) contrast(1.02); }
.photo-scrim { position: absolute; inset: 0; background: linear-gradient(180deg, rgba(27,21,14,.04) 20%, rgba(27,21,14,.38) 62%, rgba(24,19,13,.66) 100%); }
.photo-stage-content { position: absolute; left: clamp(26px, 5vw, 52px); bottom: 82px; right: 28px; color: #fffaf0; text-shadow: 0 2px 16px rgba(25,18,10,.24); }
.ready-pill { display: inline-flex; align-items: center; gap: 6px; background: rgba(255,250,240,.14); border: 1px solid rgba(255,250,240,.2); backdrop-filter: blur(10px); border-radius: 99px; padding: 4px 9px; font-size: 8.5px; letter-spacing: .03em; color: rgba(255,250,240,.9); }
.ready-pill .live-dot { background: #c6e2b5; box-shadow: 0 0 0 3px rgba(198,226,181,.13); }
.photo-stage-content h2 { margin-top: 12px; font-size: clamp(24px, 2.6vw, 34px); font-weight: 800; letter-spacing: -.045em; }
.photo-stage-content p { margin-top: 6px; color: rgba(255,250,240,.7); font-size: 10.5px; }
.photo-stage-content .btn { margin-top: 18px; }
.photo-meta-strip { position: absolute; left: 24px; right: 24px; bottom: 20px; display: flex; align-items: center; justify-content: space-between; gap: 10px; color: rgba(255,250,240,.62); font-size: 9px; border-top: 1px solid rgba(255,250,240,.16); padding-top: 11px; }
.photo-meta-strip button { display: inline-flex; align-items: center; gap: 4px; color: rgba(255,250,240,.8); font-size: 9px; }
.photo-meta-strip button:hover { color: #fff; }
.photo-meta-strip .icon { width: 12px; height: 12px; }

.canvas-badge { position: absolute; top: 14px; left: 14px; z-index: 5; display: inline-flex; align-items: center; gap: 6px; height: 26px; padding: 0 9px; border-radius: 7px; background: rgba(255,253,248,.88); border: 1px solid var(--line); box-shadow: 0 5px 15px -10px rgba(40,30,15,.4); font-family: var(--mono); font-size: 8px; color: var(--muted); pointer-events: none; backdrop-filter: blur(8px); }
.canvas-badge.is-editing { background: var(--ink); border-color: var(--ink); color: #fffaf0; }
.canvas-legend { position: absolute; left: 14px; bottom: 14px; z-index: 5; display: inline-flex; align-items: center; gap: 6px; height: 26px; padding: 0 9px; border-radius: 7px; background: rgba(255,253,248,.78); border: 1px solid rgba(232,223,208,.85); color: var(--muted); font-size: 8.5px; pointer-events: none; backdrop-filter: blur(8px); }
.legend-dot { width: 7px; height: 7px; border-radius: 2px; background: var(--accent); box-shadow: 0 0 0 2px var(--accent-soft); }
.generating-overlay { position: absolute; inset: 0; z-index: 20; display: grid; place-items: center; background: rgba(247,241,231,.72); backdrop-filter: blur(8px); animation: fadeIn .2s ease; }
.generating-card { text-align: center; padding: 26px 32px; background: rgba(255,253,248,.9); border: 1px solid var(--line); border-radius: 18px; box-shadow: var(--shadow-float); min-width: 230px; }
.generating-card strong { display: block; font-size: 13px; margin-top: 12px; }
.generating-card p { color: var(--faint); font-size: 9.5px; margin-top: 3px; }
.generating-beads { display: flex; align-items: flex-end; justify-content: center; gap: 4px; height: 34px; }
.generating-beads span { width: 14px; height: 14px; border-radius: 50%; background: var(--accent); animation: beadBounce .9s infinite ease-in-out; box-shadow: inset 0 -2px 3px rgba(0,0,0,.12); }
.generating-beads span:nth-child(2) { background: #e7b74f; animation-delay: .08s; }
.generating-beads span:nth-child(3) { background: #87a380; animation-delay: .16s; }
.generating-beads span:nth-child(4) { background: #e8a183; animation-delay: .24s; }
.generating-beads span:nth-child(5) { background: #7f9eae; animation-delay: .32s; }
@keyframes beadBounce { 0%,100% { transform: translateY(0); opacity: .65; } 45% { transform: translateY(-12px); opacity: 1; } }
@keyframes fadeIn { from { opacity: 0; } to { opacity: 1; } }

.workspace-footer { flex: 0 0 27px; display: flex; align-items: flex-end; justify-content: space-between; gap: 12px; padding: 0 3px; }
.footer-status { display: flex; align-items: center; gap: 6px; color: var(--faint); font-size: 9px; }
.status-dot { width: 5px; height: 5px; border-radius: 50%; background: var(--line-strong); transition: .2s; }
.status-dot.is-live { background: var(--green); box-shadow: 0 0 0 3px rgba(60,104,80,.1); }
.footer-hint { display: flex; align-items: center; gap: 13px; color: var(--faint); font-size: 8.5px; }
.footer-hint span { display: inline-flex; align-items: center; gap: 4px; white-space: nowrap; }
kbd { display: inline-flex; align-items: center; justify-content: center; min-width: 15px; height: 15px; padding: 0 4px; border-radius: 4px; border: 1px solid var(--line); background: rgba(255,253,248,.7); color: var(--muted); font-family: var(--mono); font-size: 8px; line-height: 1; }

/* ======================= Right panel ======================= */
.right-empty { padding: 3px 2px 0; }
.empty-palette-card { margin-top: 11px; border: 1px solid var(--line); background: var(--surface); border-radius: 17px; padding: 14px; box-shadow: var(--shadow-sm); }
.empty-palette-head { display: flex; align-items: flex-start; justify-content: space-between; }
.empty-palette-head > div { display: flex; flex-direction: column; gap: 2px; }
.empty-palette-head strong { font-family: var(--mono); font-size: 12px; letter-spacing: -.02em; }
.empty-palette-head span:not(.palette-count) { color: var(--faint); font-size: 9px; }
.palette-count { font-family: var(--mono); font-size: 21px; font-weight: 600; color: var(--ink-soft); line-height: 1; letter-spacing: -.06em; }
.palette-count small { font-size: 8px; color: var(--faint); margin-left: 2px; font-weight: 400; letter-spacing: 0; }
.big-palette-strip { margin-top: 12px; height: 86px; border-radius: 9px; overflow: hidden; display: flex; flex-wrap: wrap; gap: 0; border: 1px solid rgba(33,30,24,.06); }
.big-palette-strip i { width: 12.5%; height: 25%; display: block; }
.big-palette-strip { overflow: hidden; }
.empty-palette-card p { margin-top: 11px; color: var(--muted); font-size: 9.5px; line-height: 1.65; }
.empty-info-list { margin-top: 17px; display: flex; flex-direction: column; gap: 13px; padding: 0 2px; }
.info-line { display: flex; gap: 10px; align-items: flex-start; }
.info-number { font-family: var(--mono); font-size: 8px; color: var(--accent); margin-top: 2px; }
.info-line strong { font-size: 10.5px; font-weight: 700; }
.info-line p { margin-top: 2px; color: var(--faint); font-size: 9px; line-height: 1.55; }
.side-tip { display: flex; gap: 9px; margin-top: 16px; padding: 11px 12px; border-radius: 12px; background: rgba(243,236,223,.7); border: 1px solid var(--line); }
.tip-icon { width: 23px; height: 23px; flex: 0 0 auto; border-radius: 7px; background: var(--surface); display: grid; place-items: center; color: var(--gold); border: 1px solid var(--line); }
.tip-icon .icon { width: 13px; height: 13px; }
.side-tip strong { display: block; font-size: 9.5px; }
.side-tip p { font-size: 8.5px; color: var(--faint); line-height: 1.55; margin-top: 2px; }

.side-card { border: 1px solid var(--line); background: var(--surface); border-radius: 17px; padding: 14px; margin-bottom: 11px; box-shadow: var(--shadow-sm); }
.side-card-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 8px; }
.side-card-head h2 { font-size: 13px; font-weight: 800; letter-spacing: -.02em; margin-top: 3px; }
.mini-action-btn { display: inline-flex; align-items: center; gap: 4px; height: 25px; border-radius: 6px; padding: 0 7px; border: 1px solid var(--line); background: var(--surface-2); color: var(--muted); font-size: 8.5px; transition: .15s; white-space: nowrap; }
.mini-action-btn:hover { color: var(--ink); border-color: var(--line-strong); }
.mini-action-btn .icon { width: 12px; height: 12px; }
.stat-grid { margin-top: 12px; display: grid; grid-template-columns: repeat(3,1fr); gap: 5px; }
.stat-cell { padding: 8px 6px 7px; background: var(--surface-2); border: 1px solid rgba(232,223,208,.7); border-radius: 8px; text-align: center; }
.stat-cell strong { display: block; font-family: var(--mono); font-size: 17px; font-weight: 600; letter-spacing: -.06em; line-height: 1.2; }
.stat-cell span { color: var(--faint); font-size: 8px; }
.board-map-block { margin-top: 12px; padding-top: 11px; border-top: 1px dashed var(--line); }
.mini-heading { display: flex; align-items: center; justify-content: space-between; color: var(--muted); font-size: 8.5px; }
.mini-heading span:last-child { color: var(--faint); font-family: var(--mono); font-size: 7.5px; }
.board-map-wrap { height: 64px; margin-top: 7px; background: var(--surface-2); border-radius: 8px; border: 1px solid rgba(232,223,208,.8); padding: 6px; display: flex; align-items: center; justify-content: center; }
#boardMapCanvas { width: 100%; height: 100%; display: block; }
.board-summary { margin-top: 5px; color: var(--faint); font-size: 8px; line-height: 1.5; }
.soft-tag { display: inline-flex; align-items: center; height: 19px; padding: 0 6px; border-radius: 4px; background: var(--green-soft); color: var(--green); font-size: 7.5px; white-space: nowrap; }
.mirror-wrap { margin-top: 10px; border: 1px solid var(--line); border-radius: 9px; background: var(--surface-2); padding: 7px; height: 126px; display: flex; align-items: center; justify-content: center; overflow: hidden; }
#mirrorCanvas { width: 100%; height: 100%; display: block; }
.small-note { color: var(--faint); font-size: 8px; line-height: 1.5; margin-top: 7px; }
.colors-card { padding-bottom: 11px; }
.used-colors-head { margin-top: 11px; display: flex; justify-content: space-between; color: var(--faint); font-size: 8px; border-bottom: 1px solid var(--line); padding-bottom: 6px; }
.used-color-list { max-height: min(37vh, 320px); overflow-y: auto; overflow-x: hidden; margin: 0 -5px; padding: 2px 5px 1px; }
.color-row { display: flex; align-items: center; gap: 7px; height: 39px; border-bottom: 1px solid rgba(232,223,208,.55); position: relative; }
.color-row:last-child { border-bottom: 0; }
.color-pick { display: flex; align-items: center; gap: 7px; flex: 1; min-width: 0; height: 100%; text-align: left; }
.color-swatch { width: 22px; height: 22px; border-radius: 5px; flex: 0 0 auto; border: 1px solid rgba(33,30,24,.11); box-shadow: inset 0 0 0 1px rgba(255,255,255,.22); position: relative; overflow: hidden; }
.color-swatch.is-light { border-color: rgba(33,30,24,.16); }
.color-code { font-family: var(--mono); font-size: 9.5px; font-weight: 600; color: var(--ink-soft); width: 29px; flex: 0 0 auto; }
.color-usage { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 3px; }
.color-usage-line { display: flex; justify-content: space-between; color: var(--faint); font-size: 7.5px; }
.color-usage-line b { color: var(--muted); font-family: var(--mono); font-weight: 500; }
.usage-bar { height: 2px; background: var(--surface-3); border-radius: 99px; overflow: hidden; }
.usage-bar i { display: block; height: 100%; background: var(--line-strong); border-radius: 99px; }
.color-row.is-active { background: var(--accent-soft); margin: 0 -5px; padding: 0 5px; border-radius: 7px; border-bottom-color: transparent; }
.color-row.is-active .color-code { color: var(--accent-deep); }
.color-swap { width: 23px; height: 23px; flex: 0 0 auto; border-radius: 6px; display: grid; place-items: center; color: var(--faint); }
.color-swap:hover { color: var(--accent); background: var(--surface-2); }
.color-swap .icon { width: 12px; height: 12px; }
.colour-hint { display: flex; align-items: center; gap: 3px; flex-wrap: wrap; color: var(--faint); font-size: 7.5px; border-top: 1px dashed var(--line); padding-top: 8px; margin-top: 5px; }
.colour-hint .icon { width: 10px; height: 10px; }

/* ======================= Modals ======================= */
.modal-backdrop {
  position: fixed; inset: 0; z-index: 100;
  display: grid; place-items: center;
  padding: 22px;
  background: rgba(30, 24, 16, .48);
  backdrop-filter: blur(9px) saturate(.9);
  animation: fadeIn .18s ease;
}
.modal {
  width: min(940px, calc(100vw - 44px));
  max-height: calc(100dvh - 44px);
  background: var(--surface);
  border: 1px solid rgba(255,255,255,.5);
  border-radius: 24px;
  box-shadow: 0 35px 90px -30px rgba(20,14,8,.6);
  display: flex; flex-direction: column; overflow: hidden;
  animation: modalPop .2s cubic-bezier(.2,.8,.2,1);
}
@keyframes modalPop { from { transform: translateY(8px) scale(.985); opacity: 0; } to { transform: none; opacity: 1; } }
.modal-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 20px; padding: 21px 24px 17px; border-bottom: 1px solid var(--line); flex: 0 0 auto; }
.modal-head h2 { font-size: 20px; font-weight: 800; letter-spacing: -.035em; margin-top: 4px; }
.modal-head p { color: var(--muted); font-size: 10.5px; margin-top: 3px; line-height: 1.5; }
.modal-close { width: 32px; height: 32px; border-radius: 50%; display: grid; place-items: center; color: var(--muted); background: var(--surface-2); border: 1px solid var(--line); flex: 0 0 auto; transition: .15s; }
.modal-close:hover { background: var(--ink); border-color: var(--ink); color: #fff; }
.modal-close .icon { width: 16px; height: 16px; }
.modal-close:focus-visible { outline: none; border-color: var(--accent); color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); }
.modal-foot { display: flex; align-items: center; justify-content: space-between; gap: 18px; padding: 14px 24px; border-top: 1px solid var(--line); background: rgba(250,245,234,.65); flex: 0 0 auto; }
.modal-actions { display: flex; align-items: center; gap: 8px; flex: 0 0 auto; }
.modal-actions .btn { height: 37px; font-size: 11px; padding: 0 15px; }
.modal-note { color: var(--faint); font-size: 9px; }

/* Crop */
.crop-modal { width: min(900px, calc(100vw - 44px)); }
.crop-body { display: grid; grid-template-columns: minmax(0, 1fr) 225px; gap: 20px; padding: 20px 24px; min-height: 0; overflow: auto; }
.crop-stage-wrap { display: flex; align-items: center; justify-content: center; min-height: 330px; padding: 16px; border-radius: 16px; background: var(--surface-3); border: 1px solid var(--line); position: relative; overflow: hidden; }
.crop-stage-wrap::before { content: ""; position: absolute; inset: 0; background-image: radial-gradient(circle at 1px 1px, rgba(112,95,70,.1) 1px, transparent 1px); background-size: 14px 14px; }
.crop-frame { position: relative; max-width: 100%; max-height: 52vh; box-shadow: 0 25px 45px -26px rgba(40,30,18,.5); border-radius: 5px; overflow: hidden; background: #222; }
#cropCanvas { display: block; max-width: 100%; max-height: 52vh; cursor: grab; touch-action: none; }
#cropCanvas:active { cursor: grabbing; }
.crop-thirds { position: absolute; inset: 0; pointer-events: none; opacity: .36; }
.crop-thirds i { position: absolute; background: rgba(255,255,255,.6); }
.crop-thirds i:nth-child(1) { left: 33.333%; top: 0; bottom: 0; width: 1px; }
.crop-thirds i:nth-child(2) { left: 66.666%; top: 0; bottom: 0; width: 1px; }
.crop-thirds i:nth-child(3) { top: 33.333%; left: 0; right: 0; height: 1px; }
.crop-thirds i:nth-child(4) { top: 66.666%; left: 0; right: 0; height: 1px; }
.crop-corner { position: absolute; width: 17px; height: 17px; border-color: #fff; border-style: solid; pointer-events: none; filter: drop-shadow(0 1px 2px rgba(0,0,0,.25)); }
.crop-corner.c1 { left: 8px; top: 8px; border-width: 2px 0 0 2px; border-radius: 3px 0 0 0; }
.crop-corner.c2 { right: 8px; top: 8px; border-width: 2px 2px 0 0; border-radius: 0 3px 0 0; }
.crop-corner.c3 { left: 8px; bottom: 8px; border-width: 0 0 2px 2px; border-radius: 0 0 0 3px; }
.crop-corner.c4 { right: 8px; bottom: 8px; border-width: 0 2px 2px 0; border-radius: 0 0 3px 0; }
.crop-side { display: flex; flex-direction: column; gap: 3px; padding: 7px 2px; }
.crop-aspect { display: flex; flex-direction: column; padding: 13px; border-radius: 11px; background: var(--surface-2); border: 1px solid var(--line); }
.crop-aspect span { font-size: 9px; color: var(--faint); }
.crop-aspect strong { font-family: var(--mono); font-size: 19px; font-weight: 600; letter-spacing: -.03em; margin-top: 2px; }
.crop-aspect small { font-size: 8.5px; color: var(--muted); margin-top: 2px; }
.crop-range { margin-top: 15px; }
.crop-tips { display: flex; gap: 7px; margin-top: auto; padding: 11px; border: 1px solid var(--line); border-radius: 10px; background: rgba(250,245,234,.7); }
.crop-tips .icon { width: 13px; height: 13px; color: var(--accent); margin-top: 1px; flex: 0 0 auto; }
.crop-tips p { color: var(--muted); font-size: 8.5px; line-height: 1.6; }
.reset-crop { margin-top: 10px; color: var(--muted); font-size: 9.5px; }
.reset-crop .icon { width: 12px; height: 12px; }

/* Palette */
.palette-modal { width: min(920px, calc(100vw - 44px)); }
.replace-banner { flex: 0 0 auto; display: flex; align-items: center; gap: 13px; padding: 10px 24px; background: var(--accent-soft); border-bottom: 1px solid #f5d7c9; }
.replace-from, .replace-to { display: flex; align-items: center; gap: 7px; }
.replace-from i, .replace-to i { width: 22px; height: 22px; border-radius: 5px; border: 1px solid rgba(33,30,24,.12); background: #eee; }
.replace-from span, .replace-to span { display: flex; flex-direction: column; line-height: 1.15; }
.replace-from small, .replace-to small { font-size: 7px; color: #a17b6e; }
.replace-from strong, .replace-to strong { font-family: var(--mono); font-size: 10px; font-weight: 600; color: var(--accent-deep); }
.replace-arrow { width: 15px; height: 15px; color: #c69b8d; }
.replace-count { margin-left: auto; font-size: 9px; color: #a17b6e; }
.palette-toolbar { flex: 0 0 auto; display: flex; align-items: center; justify-content: space-between; gap: 14px; padding: 13px 24px 11px; border-bottom: 1px solid var(--line); }
.search-field { display: flex; align-items: center; gap: 6px; width: 230px; height: 32px; border: 1px solid var(--line); border-radius: 8px; padding: 0 9px; background: var(--surface-2); transition: .15s; }
.search-field:focus-within { border-color: var(--ink-soft); background: var(--surface); }
.search-field .icon { width: 13px; height: 13px; color: var(--faint); }
.search-field input { border: 0; background: none; outline: none; font-size: 10px; width: 100%; min-width: 0; }
.search-field input::placeholder { color: var(--faint); }
.group-tabs { display: flex; align-items: center; gap: 2px; overflow-x: auto; }
.group-tabs button { min-width: 27px; height: 25px; border-radius: 6px; padding: 0 6px; font-family: var(--mono); font-size: 8.5px; color: var(--faint); }
.group-tabs button:hover { color: var(--ink); background: var(--surface-2); }
.group-tabs button.is-active { background: var(--ink); color: #fff; }
.palette-scroll { flex: 1; min-height: 230px; overflow-y: auto; padding: 14px 24px 17px; }
.palette-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(54px, 1fr)); gap: 6px 4px; }
.palette-chip { display: flex; flex-direction: column; align-items: center; gap: 3px; padding: 4px 2px 3px; border-radius: 7px; border: 1px solid transparent; transition: .12s; }
.palette-chip:hover { background: var(--surface-2); border-color: var(--line); }
.palette-chip i { width: 29px; height: 29px; border-radius: 6px; border: 1px solid rgba(33,30,24,.12); box-shadow: inset 0 0 0 1px rgba(255,255,255,.18); display: block; }
.palette-chip span { font-family: var(--mono); font-size: 7.5px; color: var(--muted); }
.palette-chip.is-selected { background: var(--accent-soft); border-color: #f0bfa9; }
.palette-chip.is-selected i { box-shadow: 0 0 0 2px var(--surface), 0 0 0 3.5px var(--accent); }
.palette-chip.is-selected span { color: var(--accent-deep); font-weight: 600; }
.palette-empty { padding: 55px 0; text-align: center; color: var(--faint); font-size: 11px; }
.palette-foot { flex: 0 0 auto; display: flex; align-items: center; gap: 16px; padding: 12px 24px; border-top: 1px solid var(--line); background: rgba(250,245,234,.6); }
.picked-color { display: flex; align-items: center; gap: 8px; min-width: 150px; }
.picked-swatch { width: 30px; height: 30px; border-radius: 7px; border: 1px solid rgba(33,30,24,.14); background: #FFE44B; }
.picked-color > div { display: flex; align-items: baseline; gap: 6px; }
.picked-color small { display: block; font-size: 7.5px; color: var(--faint); }
.picked-color strong { font-family: var(--mono); font-size: 11px; }
.picked-color span { color: var(--faint); font-family: var(--mono); font-size: 8px; }
.palette-legend-note { margin-left: auto; color: var(--faint); font-size: 8px; }

/* Export */
.export-modal { width: min(1090px, calc(100vw - 44px)); }
.export-head { padding-bottom: 15px; }
.export-body { display: grid; grid-template-columns: minmax(0, 1.08fr) 360px; min-height: 0; flex: 1; overflow: hidden; }
.export-preview-pane { min-height: 0; display: flex; flex-direction: column; background: #ece4d6; border-right: 1px solid var(--line); }
.export-preview-top { flex: 0 0 auto; display: flex; align-items: center; justify-content: space-between; padding: 10px 17px; color: var(--faint); font-size: 8.5px; border-bottom: 1px solid rgba(216,204,184,.6); }
.export-preview-top span:first-child { font-family: var(--mono); letter-spacing: .08em; font-size: 8px; }
.export-preview-scroll { flex: 1; min-height: 0; overflow: auto; display: flex; align-items: flex-start; justify-content: center; padding: 20px; }
#exportPreviewCanvas { display: block; width: 100%; max-width: 760px; height: auto; background: #fffdf8; box-shadow: 0 22px 50px -26px rgba(40,30,18,.48); border-radius: 2px; }
.preview-tip { flex: 0 0 auto; display: flex; align-items: center; gap: 6px; margin: 0 20px 15px; padding: 8px 10px; background: rgba(255,253,248,.55); border: 1px solid rgba(216,204,184,.7); border-radius: 8px; color: var(--muted); font-size: 8px; line-height: 1.5; }
.preview-tip .icon { width: 12px; height: 12px; color: var(--accent); flex: 0 0 auto; }
.export-options { min-height: 0; overflow-y: auto; padding: 17px 20px 18px; }
.export-title-field { display: flex; flex-direction: column; gap: 5px; margin-bottom: 16px; }
.export-title-field span { font-size: 9px; color: var(--faint); }
.export-title-field input { height: 38px; border: 1px solid var(--line); border-radius: 9px; background: var(--surface-2); outline: none; padding: 0 10px; font-size: 12px; font-weight: 650; transition: .15s; }
.export-title-field input:focus { border-color: var(--ink-soft); background: var(--surface); }
.option-group { border-top: 1px dashed var(--line); padding-top: 12px; margin-top: 12px; }
.option-group:first-of-type { border-top: 0; padding-top: 0; margin-top: 0; }
.option-group-title { display: flex; align-items: center; justify-content: space-between; font-size: 9px; font-weight: 700; color: var(--muted); margin-bottom: 7px; }
.auto-tag { font-size: 7px; font-weight: 500; color: var(--faint); background: var(--surface-3); border-radius: 4px; padding: 2px 5px; }
.check-row { display: flex; align-items: flex-start; gap: 8px; padding: 5px 0; cursor: pointer; position: relative; }
.check-row input { position: absolute; opacity: 0; }
.check-row > i { width: 16px; height: 16px; border-radius: 4px; border: 1.5px solid var(--line-strong); background: var(--surface); flex: 0 0 auto; margin-top: 1px; position: relative; transition: .14s; }
.check-row > i::after { content: ""; position: absolute; left: 4px; top: 1.5px; width: 4px; height: 8px; border: solid #fff; border-width: 0 1.5px 1.5px 0; transform: rotate(42deg) scale(0); transition: .14s; }
.check-row input:checked + i { background: var(--ink); border-color: var(--ink); }
.check-row input:checked + i::after { transform: rotate(42deg) scale(1); }
.check-row input:focus-visible + i { outline: 2px solid var(--accent); outline-offset: 2px; }
.check-row > span { display: flex; flex-direction: column; gap: 1px; }
.check-row strong { font-size: 10px; font-weight: 600; color: var(--ink-soft); }
.check-row small { font-size: 8px; color: var(--faint); }
.quality-switch { display: grid; grid-template-columns: 1fr 1fr; gap: 6px; }
.quality-switch button { height: 42px; border: 1px solid var(--line); border-radius: 8px; background: var(--surface-2); display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 1px; font-size: 9.5px; color: var(--muted); }
.quality-switch button small { color: var(--faint); font-size: 7.5px; }
.quality-switch button.is-active { border-color: var(--ink); background: var(--ink); color: #fff; }
.quality-switch button.is-active small { color: rgba(255,255,255,.5); }
.export-meta { margin-top: 14px; padding: 9px 11px; border: 1px solid var(--line); border-radius: 9px; background: var(--surface-2); display: flex; flex-direction: column; gap: 5px; }
.export-meta > div { display: flex; justify-content: space-between; gap: 10px; font-size: 8.5px; color: var(--faint); }
.export-meta strong { font-family: var(--mono); color: var(--ink-soft); font-weight: 500; font-size: 8.5px; }
.export-actions { margin-top: 14px; display: flex; flex-direction: column; gap: 7px; }
.export-actions .btn-primary { height: 43px; }
.export-secondary { display: grid; grid-template-columns: 1fr 1fr; gap: 7px; }
.export-secondary .btn { height: 36px; font-size: 10px; padding: 0 8px; }
.export-footnote { margin-top: 9px; color: var(--faint); font-size: 8px; line-height: 1.5; text-align: center; }

/* Cloud library */
.cloud-modal { width: min(980px, calc(100vw - 44px)); }
.cloud-toolbar { flex: 0 0 auto; display: flex; align-items: center; justify-content: space-between; gap: 14px; padding: 10px 24px; border-bottom: 1px solid var(--line); background: rgba(250,245,234,.55); }
.cloud-connection { display: flex; align-items: center; gap: 6px; color: var(--faint); font-size: 9px; }
.cloud-status-dot { width: 6px; height: 6px; border-radius: 50%; background: #cabfae; }
.cloud-status-dot.is-online { background: #6f9c75; box-shadow: 0 0 0 3px rgba(111,156,117,.12); }
.cloud-status-dot.is-error { background: var(--accent); box-shadow: 0 0 0 3px rgba(240,90,54,.1); }
.cloud-status-dot.is-loading { background: var(--gold); animation: cloudPulse 1.2s infinite; }
.cloud-body { flex: 1; min-height: 0; overflow-y: auto; padding: 17px 24px 20px; }
.cloud-save-panel { display: grid; grid-template-columns: minmax(230px, .8fr) minmax(0, 1.2fr); gap: 18px; align-items: center; padding: 16px 17px; border-radius: 15px; border: 1px solid var(--line); background: linear-gradient(135deg, #fbf5e9, #f5ead8); }
.cloud-save-panel.is-disabled { opacity: .7; }
.cloud-save-copy h3 { font-size: 15px; font-weight: 800; letter-spacing: -.02em; margin-top: 3px; }
.cloud-save-copy p { font-size: 9px; color: var(--faint); line-height: 1.55; margin-top: 4px; }
.cloud-save-form { display: grid; grid-template-columns: minmax(0,1fr) auto; gap: 7px 10px; align-items: center; }
.cloud-title-field { grid-column: 1 / -1; display: flex; flex-direction: column; gap: 4px; }
.cloud-title-field span { font-size: 8px; color: var(--faint); }
.cloud-title-field input { height: 35px; border: 1px solid #dfd3c0; border-radius: 8px; background: var(--surface); padding: 0 10px; outline: none; font-size: 11.5px; font-weight: 650; transition: .15s; }
.cloud-title-field input:focus { border-color: var(--ink-soft); box-shadow: 0 0 0 3px rgba(33,30,24,.05); }
.cloud-title-field input:disabled { background: #f7f0e4; color: var(--faint); opacity: .7; }
.cloud-save-panel.is-disabled .cloud-public-toggle { opacity: .5; pointer-events: none; }
.cloud-public-toggle { display: flex; align-items: center; gap: 6px; cursor: pointer; color: var(--muted); font-size: 9px; min-width: 0; }
.cloud-public-toggle input { position: absolute; opacity: 0; pointer-events: none; }
.cloud-public-toggle i { width: 15px; height: 15px; flex: 0 0 auto; border-radius: 4px; border: 1.5px solid #cfc1ac; background: var(--surface); position: relative; transition: .15s; }
.cloud-public-toggle i::after { content: ""; position: absolute; left: 4px; top: 1.5px; width: 4px; height: 7px; border: solid #fff; border-width: 0 1.5px 1.5px 0; transform: rotate(42deg) scale(0); transition: .15s; }
.cloud-public-toggle input:checked + i { background: var(--green); border-color: var(--green); }
.cloud-public-toggle input:checked + i::after { transform: rotate(42deg) scale(1); }
.cloud-public-toggle input:focus-visible + i { outline: 2px solid var(--accent); outline-offset: 2px; }
.cloud-save-form .btn { height: 35px; padding: 0 12px; font-size: 10px; white-space: nowrap; }
.cloud-save-form .btn .icon { width: 14px; height: 14px; }
.cloud-list-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin: 16px 0 9px; }
.cloud-tabs { display: flex; align-items: center; gap: 3px; padding: 3px; border-radius: 9px; background: var(--surface-3); }
.cloud-tabs button { height: 29px; border-radius: 6px; padding: 0 10px; color: var(--muted); font-size: 10px; transition: .15s; }
.cloud-tabs button span { font-family: var(--mono); font-size: 8px; color: var(--faint); margin-left: 3px; }
.cloud-tabs button.is-active { background: var(--surface); color: var(--ink); box-shadow: var(--shadow-sm); font-weight: 650; }
.cloud-result-note { color: var(--faint); font-size: 8.5px; text-align: right; }
.cloud-list { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 8px; }
.cloud-card { min-width: 0; display: flex; gap: 10px; padding: 8px; border: 1px solid var(--line); border-radius: 12px; background: var(--surface); transition: .15s; }
.cloud-card:hover { border-color: var(--line-strong); box-shadow: 0 8px 20px -18px rgba(40,30,15,.3); }
.cloud-thumb { width: 96px; height: 96px; flex: 0 0 auto; border-radius: 8px; overflow: hidden; background: #f1e9dc; position: relative; }
.cloud-thumb img { width: 100%; height: 100%; object-fit: cover; display: block; }
.cloud-thumb.is-empty { background-image: radial-gradient(circle at 1px 1px, rgba(122,103,77,.13) 1px, transparent 1px); background-size: 10px 10px; display: grid; place-items: center; color: #c5b8a4; }
.cloud-thumb.is-empty .icon { width: 23px; height: 23px; }
.cloud-card-main { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.cloud-card-title-row { display: flex; align-items: center; gap: 5px; min-width: 0; }
.cloud-card-title { font-size: 11px; font-weight: 750; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; min-width: 0; flex: 1; }
.cloud-badge { flex: 0 0 auto; display: inline-flex; align-items: center; gap: 2px; height: 16px; padding: 0 4px; border-radius: 3px; font-size: 7px; white-space: nowrap; }
.cloud-badge.is-public { background: var(--green-soft); color: var(--green); }
.cloud-badge.is-private { background: var(--surface-3); color: var(--faint); }
.cloud-badge .icon { width: 8px; height: 8px; }
.cloud-card-meta { color: var(--faint); font-size: 8px; margin-top: 3px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.cloud-card-actions { display: flex; align-items: center; gap: 4px; flex-wrap: wrap; margin-top: auto; padding-top: 7px; }
.cloud-action { height: 22px; border-radius: 5px; border: 1px solid var(--line); background: var(--surface-2); padding: 0 6px; display: inline-flex; align-items: center; gap: 3px; color: var(--muted); font-size: 8px; transition: .13s; white-space: nowrap; }
.cloud-action:hover { color: var(--ink); border-color: var(--line-strong); background: var(--surface); }
.cloud-action.is-primary { background: var(--ink); border-color: var(--ink); color: #fffaf0; }
.cloud-action.is-primary:hover { background: var(--accent); border-color: var(--accent); color: #fff; }
.cloud-action .icon { width: 9px; height: 9px; }
.cloud-action.is-danger { border-color: transparent; background: transparent; padding: 0 3px; }
.cloud-action.is-danger:hover { color: var(--accent); background: var(--accent-soft); }
.cloud-action:disabled { opacity: .35; cursor: not-allowed; }
.cloud-state { grid-column: 1 / -1; display: flex; flex-direction: column; align-items: center; justify-content: center; text-align: center; min-height: 170px; padding: 20px; border: 1px dashed var(--line-strong); border-radius: 12px; background: rgba(250,245,234,.5); }
.cloud-state .icon { width: 26px; height: 26px; color: #c9bba7; margin-bottom: 8px; }
.cloud-state strong { font-size: 11px; }
.cloud-state p { color: var(--faint); font-size: 8.5px; line-height: 1.6; margin-top: 3px; max-width: 300px; }
.cloud-state.is-error { border-color: #eccdbb; background: #fff8f3; }
.cloud-state.is-error .icon { color: var(--accent); }
.cloud-spinner { width: 18px; height: 18px; border-radius: 50%; border: 2px solid #e5d9c7; border-top-color: var(--accent); animation: cloudSpin .8s linear infinite; margin-bottom: 9px; }
@keyframes cloudSpin { to { transform: rotate(360deg); } }
@keyframes cloudPulse { 0%,100% { opacity: .45; } 50% { opacity: 1; } }
.cloud-skeleton { height: 112px; border-radius: 12px; border: 1px solid var(--line); background: linear-gradient(90deg, #f8f1e5 25%, #fdf8ef 50%, #f8f1e5 75%); background-size: 200% 100%; animation: cloudSkeleton 1.3s infinite; }
@keyframes cloudSkeleton { 0% { background-position: 100% 0; } 100% { background-position: -100% 0; } }
.cloud-foot { padding-top: 11px; padding-bottom: 11px; }
.cloud-foot .modal-note { max-width: 630px; line-height: 1.5; }
@media (max-width: 860px) {
  .cloud-save-panel { grid-template-columns: 1fr; gap: 11px; }
  .cloud-list { grid-template-columns: 1fr; }
  .cloud-list-head { align-items: flex-start; flex-direction: column; gap: 5px; }
  .cloud-result-note { text-align: left; }
  .cloud-body { padding: 14px 16px 18px; }
  .cloud-toolbar { padding: 9px 16px; }
  .cloud-modal .modal-head p { max-width: 560px; }
  .cloud-card { padding: 7px; }
  .cloud-thumb { width: 82px; height: 82px; }
}
@media (max-width: 560px) {
  .cloud-save-form { grid-template-columns: 1fr; }
  .cloud-title-field { grid-column: 1; }
  .cloud-public-toggle { grid-column: 1; }
  .cloud-save-form .btn { grid-column: 1; width: 100%; }
  .cloud-foot { flex-wrap: wrap; }
  .cloud-foot .modal-note { display: block; font-size: 8px; max-width: 100%; }
  .cloud-entry span { display: none; }
  .cloud-entry { padding: 0 7px; }
}

.help-body { padding: 20px 24px; overflow-y: auto; }
.help-steps { display: grid; grid-template-columns: repeat(4, 1fr); gap: 7px; }
.help-steps > div { padding: 12px 11px; border-radius: 10px; border: 1px solid var(--line); background: var(--surface-2); }
.help-steps span { font-family: var(--mono); font-size: 8px; color: var(--accent); }
.help-steps strong { display: block; font-size: 10.5px; margin-top: 5px; }
.help-steps p { margin-top: 4px; color: var(--faint); font-size: 8px; line-height: 1.55; }
.help-two-col { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; margin-top: 14px; }
.shortcuts-box, .tips-box { padding: 14px; border-radius: 11px; border: 1px solid var(--line); }
.shortcuts-box h3, .tips-box h3 { font-size: 11px; margin-bottom: 9px; }
.shortcuts-box > div { display: flex; align-items: center; justify-content: space-between; gap: 10px; padding: 4px 0; font-size: 8.5px; color: var(--muted); border-bottom: 1px dashed rgba(232,223,208,.7); }
.shortcuts-box > div:last-child { border-bottom: 0; }
.shortcuts-box > div > span:last-child { display: flex; gap: 3px; flex-wrap: wrap; justify-content: flex-end; }
.tips-box { background: var(--surface-2); }
.tips-box li { position: relative; padding-left: 11px; color: var(--muted); font-size: 8.5px; line-height: 1.5; margin-top: 5px; }
.tips-box li::before { content: ""; position: absolute; left: 0; top: 5px; width: 4px; height: 4px; border-radius: 50%; background: var(--accent); }
.palette-credit { display: flex; align-items: center; gap: 7px; flex-wrap: wrap; margin-top: 13px; color: var(--faint); font-size: 8px; }
.palette-credit a { color: var(--muted); text-decoration: underline; text-underline-offset: 2px; }
.palette-credit span:first-child { font-weight: 650; }
.palette-credit span:last-child { margin-left: auto; }

/* Confirm */
.confirm-modal { width: min(390px, calc(100vw - 44px)); padding: 25px; display: block; text-align: center; }
.confirm-icon { width: 40px; height: 40px; border-radius: 12px; background: var(--accent-soft); color: var(--accent); display: grid; place-items: center; margin: 0 auto 11px; }
.confirm-icon .icon { width: 21px; height: 21px; }
.confirm-modal h2 { font-size: 17px; letter-spacing: -.02em; }
.confirm-modal p { color: var(--muted); font-size: 10px; line-height: 1.6; margin-top: 7px; }
.confirm-modal .modal-actions { justify-content: center; margin-top: 18px; }
.confirm-modal .modal-actions .btn { flex: 1; }

/* Toasts */
.toast-stack { position: fixed; right: 22px; bottom: 22px; z-index: 300; display: flex; flex-direction: column; align-items: flex-end; gap: 7px; pointer-events: none; }
.toast { display: flex; align-items: center; gap: 8px; max-width: 320px; padding: 10px 13px; background: rgba(33,30,24,.95); color: #fffaf0; border-radius: 10px; box-shadow: 0 13px 30px -12px rgba(30,20,10,.55); font-size: 10px; line-height: 1.4; animation: toastIn .25s cubic-bezier(.2,.8,.2,1); }
.toast .icon { width: 14px; height: 14px; color: #bcd3b4; }
.toast.is-warn .icon { color: #f1bb7a; }
.toast.is-accent .icon { color: #ff9878; }
.toast.is-leaving { animation: toastOut .2s ease forwards; }
@keyframes toastIn { from { transform: translateY(8px); opacity: 0; } to { transform: none; opacity: 1; } }
@keyframes toastOut { to { transform: translateY(5px); opacity: 0; } }

.shortcut-hint { position: fixed; left: 50%; bottom: 15px; transform: translateX(-50%); z-index: 30; display: flex; gap: 12px; padding: 6px 13px; border-radius: 99px; background: rgba(33,30,24,.85); color: rgba(255,250,240,.6); font-size: 8px; backdrop-filter: blur(6px); pointer-events: none; }
.shortcut-hint span { position: relative; }
.shortcut-hint span + span::before { content: "·"; position: absolute; left: -7px; color: rgba(255,255,255,.25); }

/* ======================= Responsive ======================= */
@media (max-width: 1440px) {
  .app-grid { grid-template-columns: 286px minmax(400px, 1fr) 300px; gap: 14px; padding: 0 14px 14px; }
  .panel-scroll { padding-left: 15px; padding-right: 15px; }
  .left-panel .panel-scroll { padding-left: 15px; padding-right: 15px; }
  .left-panel > .generate-zone { padding-left: 15px; padding-right: 15px; }
  .hero-copy h2 { font-size: 32px; }
  .export-body { grid-template-columns: minmax(0,1fr) 340px; }
}
@media (max-width: 1320px) {
  .tool-toggle span { display: none; }
  .tool-toggle { padding: 0 6px; }
  .toolbar-sep { margin: 0 3px; }
  .edit-tool span { display: none; }
  .edit-tool { padding: 0 7px; }
}
@media (max-width: 1220px) {
  .app-grid { grid-template-columns: 264px minmax(380px, 1fr) 280px; gap: 12px; }
  .panel-intro h1 { font-size: 21px; }
  .dim-field input { font-size: 16px; }
  .hero-art-wrap { transform: scale(.9); }
  .hero-copy h2 { font-size: 29px; }
  .footer-hint span:not(#coordsDisplay) { display: none; }
  .active-meta { display: none; }
  .active-color-btn { padding: 0 5px; }
  .edit-toolbar .mirror-sync span { display: none; }
  .edit-toolbar .mirror-sync { padding: 0 7px; }
  .text-pill { padding: 0 6px; font-size: 0; gap: 0; }
  .export-body { grid-template-columns: minmax(0,1fr) 320px; }
}
@media (max-width: 1080px) {
  body { overflow: auto; height: auto; }
  .app-shell { height: auto; min-height: 100dvh; }
  .app-grid { grid-template-columns: 280px minmax(0, 1fr); height: auto; padding-bottom: 20px; }
  .right-panel { grid-column: 1 / -1; min-height: auto; }
  .right-panel .panel-scroll { display: grid; grid-template-columns: repeat(3, 1fr); gap: 12px; height: auto; padding: 14px; align-items: start; }
  .right-panel .side-card { margin-bottom: 0; }
  .right-panel .side-tip { grid-column: 1 / -1; margin-top: 0; }
  .right-empty { grid-column: 1 / -1; display: grid; grid-template-columns: 1.2fr 1fr; gap: 15px; padding: 4px; }
  .right-empty > .eyebrow { grid-column: 1 / -1; }
  .empty-palette-card { margin-top: 0; }
  .empty-info-list { margin-top: 0; }
  .right-content { display: contents; }
  .workspace { min-height: 720px; }
  .shortcut-hint { display: none; }
}
@media (max-width: 860px) {
  .topbar { height: 62px; flex-basis: 62px; padding: 0 14px; }
  .brand-copy p, .brand-latin, .topbar-center { display: none; }
  .top-export { width: 38px; padding: 0; }
  .top-export span { display: none; }
  .icon-text-btn span { display: none; }
  .icon-text-btn { padding: 0 8px; }
  .app-grid { grid-template-columns: 1fr; padding: 0 10px 16px; gap: 12px; }
  .left-panel { order: 1; }
  .workspace { order: 2; min-height: 640px; }
  .right-panel { order: 3; }
  .left-panel .panel-scroll { padding: 16px; }
  .right-panel .panel-scroll { grid-template-columns: 1fr; }
  .right-empty { grid-template-columns: 1fr; }
  .workspace-head { align-items: flex-start; }
  .document-title > p { display: none; }
  .head-controls .mini-icon-btn { display: none; }
  .canvas-toolbar { flex-wrap: nowrap; overflow-x: auto; }
  .tool-toggle span { display: none; }
  .empty-state { grid-template-columns: 1fr; padding: 28px; }
  .hero-art-wrap { display: none; }
  .hero-copy { max-width: 100%; }
  .canvas-shell { min-height: 480px; }
  .workspace-footer { padding: 0 4px; }
  .crop-body { grid-template-columns: 1fr; }
  .crop-side { padding-top: 0; }
  .crop-tips { margin-top: 13px; }
  .export-body { grid-template-columns: 1fr; overflow-y: auto; }
  .export-preview-pane { min-height: 300px; border-right: 0; border-bottom: 1px solid var(--line); }
  .export-preview-scroll { max-height: 300px; }
  .export-options { overflow: visible; }
  .help-steps { grid-template-columns: 1fr 1fr; }
  .help-two-col { grid-template-columns: 1fr; }
  .palette-foot { flex-wrap: wrap; }
  .palette-legend-note { order: 3; margin-left: 0; }
  .palette-toolbar { align-items: flex-start; flex-direction: column; }
  .search-field { width: 100%; }
  .group-tabs { width: 100%; }
  .modal-backdrop { padding: 10px; }
  .modal { width: calc(100vw - 20px); max-height: calc(100dvh - 20px); border-radius: 18px; }
  .crop-modal, .palette-modal, .export-modal, .help-modal { width: calc(100vw - 20px); }
  .topbar-actions { gap: 2px; }
  .edit-toolbar { flex-wrap: nowrap; }
}
@media (max-width: 560px) {
  .hero-copy h2 { font-size: 28px; }
  .hero-features { gap: 7px; }
  .canvas-shell { min-height: 430px; }
  .display-switch button { padding: 0 7px; }
  .zoom-readout { width: 33px; }
  .workspace { min-height: 560px; }
  .crop-body { padding: 14px; }
  .modal-head { padding: 17px 16px 14px; }
  .modal-foot { padding: 12px 16px; }
  .export-options { padding: 14px 16px; }
  .palette-scroll { padding: 12px 16px; }
  .palette-grid { grid-template-columns: repeat(auto-fill, minmax(46px, 1fr)); }
  .palette-chip i { width: 26px; height: 26px; }
  .help-steps { grid-template-columns: 1fr; }
  .modal-note { display: none; }
  .footer-hint { display: none; }
  .workspace-footer { justify-content: center; }
  .doc-badge { display: none; }
  .mode-switch button { padding: 0 7px; }
  .mode-switch button span { display: none; }
  .photo-stage-content { bottom: 75px; }
  .photo-meta-strip { left: 15px; right: 15px; }
  .photo-stage-content h2 { font-size: 25px; }
}

/* =========================================================
   Mobile workspace: one page at a time + persistent side rail
   ========================================================= */
.mobile-rail, .mobile-page-title { display: none; }
.rail-dot {
  position: absolute;
  top: 8px;
  right: 8px;
  width: 5px;
  height: 5px;
  border-radius: 50%;
  background: #c9bdab;
  box-shadow: 0 0 0 2px rgba(255,253,248,.8);
  transition: .2s ease;
}
.rail-dot.is-online { background: #6d9771; }
.rail-dot.is-error { background: var(--accent); }

@media (max-width: 900px) {
  body {
    height: 100dvh;
    overflow: hidden;
  }
  .app-shell {
    height: 100dvh;
    min-height: 0;
    overflow: hidden;
  }
  .topbar {
    height: 58px;
    flex-basis: 58px;
    padding: 0 14px;
    gap: 10px;
  }
  .brand-block { gap: 9px; }
  .logo-mark { width: 34px; height: 34px; padding: 6px; gap: 3px; border-radius: 10px; }
  .brand-name { font-size: 19px; }
  .brand-copy p, .brand-latin, .topbar-center, .topbar-actions { display: none; }
  .mobile-page-title {
    display: block;
    margin-left: auto;
    max-width: 46%;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    font-family: var(--mono);
    font-size: 10px;
    letter-spacing: .04em;
    color: var(--muted);
  }

  .app-grid {
    flex: 1;
    min-height: 0;
    height: auto;
    display: grid;
    grid-template-columns: 56px minmax(0, 1fr);
    grid-template-rows: minmax(0, 1fr);
    gap: 8px;
    padding: 0 8px 8px;
  }
  .mobile-rail {
    grid-column: 1;
    grid-row: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 4px;
    height: 100%;
    min-height: 0;
    padding: 7px 5px 8px;
    border: 1px solid var(--line);
    border-radius: 18px;
    background: rgba(255,253,248,.82);
    box-shadow: var(--shadow-panel);
    backdrop-filter: blur(12px);
    overflow: hidden;
  }
  .rail-group {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 4px;
    width: 100%;
  }
  .rail-btn {
    position: relative;
    width: 46px;
    min-height: 46px;
    padding: 5px 0 3px;
    border-radius: 11px;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 1px;
    color: var(--muted);
    font-size: 8.5px;
    line-height: 1.2;
    transition: background .16s ease, color .16s ease, transform .16s ease;
  }
  .rail-btn .icon { width: 18px; height: 18px; }
  .rail-btn:hover { background: var(--surface-3); color: var(--ink); }
  .rail-btn:active { transform: scale(.96); }
  .rail-btn.is-active {
    background: var(--ink);
    color: #fff8ec;
    box-shadow: 0 7px 14px -9px rgba(30,24,16,.8);
  }
  .rail-btn.is-active .icon { color: var(--gold); }
  .rail-line { width: 27px; height: 1px; flex: 0 0 1px; background: var(--line); margin: 4px 0; }
  .rail-actions .rail-btn { color: var(--muted); }
  .rail-actions .rail-btn .icon { color: var(--ink-soft); }
  .rail-actions .rail-btn:disabled { opacity: .3; color: var(--faint); pointer-events: none; }
  .rail-actions .rail-btn:disabled .icon { color: var(--faint); }
  .rail-spacer { flex: 1; min-height: 4px; }
  .rail-foot {
    font-family: var(--mono);
    font-size: 7.5px;
    letter-spacing: .06em;
    color: var(--faint);
    padding-bottom: 1px;
  }

  /* Only one workspace page is mounted in the viewport. */
  .left-panel, .workspace, .right-panel {
    grid-column: 2;
    grid-row: 1;
    width: 100%;
    min-width: 0;
    min-height: 0;
    height: 100%;
    display: none;
    overflow: hidden;
  }
  body[data-mobile-view="setup"] .left-panel { display: flex; flex-direction: column; }
  body[data-mobile-view="canvas"] .workspace { display: flex; flex-direction: column; }
  body[data-mobile-view="colors"] .right-panel { display: flex; flex-direction: column; }
  body[data-mobile-view] .left-panel,
  body[data-mobile-view] .workspace,
  body[data-mobile-view] .right-panel { animation: mobilePageIn .17s ease both; }
  @keyframes mobilePageIn { from { opacity: .35; } to { opacity: 1; } }

  .left-panel .panel-scroll { padding: 14px 12px 8px; }
  .left-panel > .generate-zone {
    padding: 9px 12px calc(10px + env(safe-area-inset-bottom));
  }
  .panel-intro { padding: 2px 2px 12px; }
  .panel-intro h1 { font-size: 21px; }
  .panel-intro p { display: none; }
  .panel-intro .eyebrow { font-size: 8px; }
  .btn-generate { height: 44px; }
  .generate-note { font-size: 8.5px; margin-top: 5px; }
  .setup-card { padding: 12px; }
  .section-heading h2 { font-size: 13px; }
  .section-heading p { font-size: 9.5px; }

  .workspace-head {
    flex: 0 0 auto;
    align-items: center;
    gap: 6px;
    padding: 1px 2px 7px;
  }
  .document-title { min-width: 0; }
  .doc-heading-row { gap: 6px; }
  .document-title h1 { font-size: 17px; }
  .document-title > p { display: none; }
  .head-controls { gap: 2px; }
  .head-controls .mini-icon-btn { display: none; }
  .mode-switch { margin-right: 0; }
  .mode-switch button { height: 26px; padding: 0 7px; font-size: 9px; }
  .canvas-toolbar {
    flex: 0 0 42px;
    height: 42px;
    margin-bottom: 6px;
    padding: 0 6px;
    gap: 4px;
    border-radius: 12px;
    flex-wrap: nowrap;
    overflow-x: auto;
    overflow-y: hidden;
  }
  .canvas-toolbar .toolbar-group { flex: 0 0 auto; }
  .canvas-toolbar .toolbar-sep { display: none; }
  .canvas-toolbar .display-switch button {
    height: 24px;
    padding: 0 6px;
    font-size: 8.5px;
    white-space: nowrap;
  }
  .tool-toggle { height: 27px; padding: 0 5px; }
  .tool-toggle span { display: none; }
  .zoom-readout { width: 31px; font-size: 9px; }
  .mini-icon-btn { width: 27px; height: 27px; }
  .edit-toolbar {
    flex: 0 0 auto;
    height: auto;
    min-height: 78px;
    margin-bottom: 6px;
    border-radius: 12px;
    padding: 5px 6px;
    flex-direction: column;
    align-items: stretch;
    justify-content: center;
    gap: 3px;
    overflow: visible;
  }
  .edit-row {
    display: flex;
    align-items: center;
    gap: 3px;
    width: 100%;
    min-width: 0;
  }
  .edit-row-tools {
    overflow-x: auto;
    overflow-y: hidden;
  }
  .edit-row-color { justify-content: space-between; }
  .edit-toolbar .edit-spacer { display: none; }
  .edit-tool { height: 32px; padding: 0 6px; }
  .brush-sizes button { width: 24px; height: 24px; }
  .active-color-btn { height: 30px; }
  .edit-toolbar .active-meta { display: flex; }
  .edit-toolbar .text-pill { height: 28px; font-size: 8.5px; gap: 4px; padding: 0 8px; }
  .canvas-shell { min-height: 0; flex: 1 1 auto; border-radius: 18px; }
  .workspace-footer { flex: 0 0 22px; padding: 0 3px; }
  .footer-status { font-size: 8.5px; }
  .footer-hint { display: none; }
  .canvas-badge { top: 10px; left: 10px; height: 24px; }
  .canvas-legend { left: 10px; bottom: 10px; height: 24px; }
  .empty-state {
    grid-template-columns: 1fr;
    align-content: center;
    padding: 24px 20px;
    overflow-y: auto;
  }
  .empty-state .hero-art-wrap { display: none; }
  .hero-copy { max-width: 100%; }
  .hero-copy h2 { font-size: clamp(25px, 7vw, 32px); margin-top: 10px; }
  .hero-copy > p { font-size: 10.5px; margin-top: 9px; }
  .hero-actions { margin-top: 16px; }
  .hero-actions .btn { height: 39px; font-size: 11px; }
  .hero-features { display: none; }
  .photo-stage-content { left: 18px; right: 18px; bottom: 72px; }
  .photo-stage-content h2 { font-size: 23px; }
  .photo-stage-content p { font-size: 9.5px; }
  .photo-meta-strip { left: 18px; right: 18px; bottom: 15px; }
  .photo-stage-content .btn { height: 38px; margin-top: 14px; }

  .right-panel { background: rgba(255,253,248,.82); }
  .right-panel .panel-scroll {
    display: block;
    height: 100%;
    overflow-y: auto;
    padding: 12px;
  }
  .right-content {
    display: flex;
    flex-direction: column;
    gap: 10px;
  }
  .right-content .side-card { margin-bottom: 0; order: 2; }
  .right-content .colors-card { order: 1; }
  .right-content .overview-card { order: 2; }
  .right-content .mirror-card { order: 3; }
  .right-empty { display: block; padding: 2px; }
  .right-panel .side-tip { margin-top: 10px; }
  .used-color-list { max-height: none; }
  .side-card { border-radius: 16px; }
  .side-card-head h2 { font-size: 14px; }
  .help-steps { grid-template-columns: 1fr 1fr; }
}

@media (max-width: 380px) {
  .canvas-toolbar { padding: 0 3px; gap: 2px; }
  .canvas-toolbar .display-switch { padding: 2px; }
  .canvas-toolbar .display-switch button { padding: 0 4px; font-size: 8px; }
  .canvas-toolbar .tool-toggle { padding: 0 3px; }
  .canvas-toolbar .mini-icon-btn { width: 25px; height: 25px; }
  .canvas-toolbar .zoom-readout { width: 28px; font-size: 8.5px; }
  .workspace-head { gap: 4px; }
  .mode-switch button { padding: 0 6px; }
}

@media (max-width: 900px) and (max-height: 600px) {
  .rail-btn { min-height: 38px; font-size: 7.5px; }
  .rail-btn .icon { width: 16px; height: 16px; }
  .rail-line { margin: 2px 0; }
  .rail-foot { display: none; }
  .mobile-rail { gap: 2px; padding-top: 5px; }
  .topbar { height: 52px; flex-basis: 52px; }
}
