:root {
  --paper: #f7f1e7;
  --paper-2: #fffaf1;
  --ink: #453f3a;
  --muted: #857d73;
  --gold: #bd9b55;
  --gold-deep: #8e7137;
  --line: rgba(117, 102, 76, .3);
  --danger: #b85f55;
  --shadow: 0 18px 44px rgba(68, 57, 42, .14);

  /* 主页坐标系象限色配置：只换颜色顺序时，优先调整下面 8 个 --coord-q-* 变量。 */
  --coord-pink-main: 225 157 172;
  --coord-pink-soft: 234 190 197;
  --coord-yellow-main: 234 203 113;
  --coord-yellow-soft: 241 222 164;
  --coord-blue-main: 154 199 205;
  --coord-blue-soft: 193 220 218;
  --coord-green-main: 179 202 149;
  --coord-green-soft: 211 222 186;
  /* 左上：荆棘 × 不忘 */
  --coord-q-ul-main: var(--coord-blue-main);
  --coord-q-ul-soft: var(--coord-blue-soft);
  /* 右上：繁花 × 不忘 */
  --coord-q-ur-main: var(--coord-yellow-main);
  --coord-q-ur-soft: var(--coord-yellow-soft);
  /* 左下：荆棘 × 寻常 */
  --coord-q-ll-main: var(--coord-green-main);
  --coord-q-ll-soft: var(--coord-green-soft);
  /* 右下：繁花 × 寻常 */
  --coord-q-lr-main: var(--coord-pink-main);
  --coord-q-lr-soft: var(--coord-pink-soft);
}

* { box-sizing: border-box; }

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

img {
  -webkit-user-drag: none;
}

body {
  margin: 0;
  color: var(--ink);
  background:
    radial-gradient(circle at 8% 2%, rgba(235, 184, 184, .2), transparent 24rem),
    radial-gradient(circle at 92% 94%, rgba(196, 206, 159, .23), transparent 28rem),
    var(--paper);
  font-family: var(--sans);
  overflow-x: hidden;
  overscroll-behavior: none;
}

button { color: inherit; font: inherit; }
button, [role="button"] { -webkit-tap-highlight-color: transparent; }
.logo-card, .placed-logo, .preview-popover, .drag-ghost,
.logo-card *, .placed-logo *, .preview-popover *, .drag-ghost * {
  user-select: none;
  -webkit-user-select: none;
  -webkit-touch-callout: none;
  -webkit-user-drag: none;
}
.logo-card img, .placed-logo img, .preview-popover img, .drag-ghost img {
  pointer-events: none;
}
button:focus-visible, .logo-card:focus-visible {
  outline: 3px solid rgba(166, 124, 43, .56);
  outline-offset: 3px;
}
button:disabled { cursor: not-allowed; opacity: .36; }

.paper-noise {
  position: fixed;
  inset: 0;
  pointer-events: none;
  opacity: .28;
  z-index: 10000;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='150' height='150' viewBox='0 0 150 150'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='.8' numOctaves='3' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23n)' opacity='.045'/%3E%3C/svg%3E");
}

.app-shell {
  min-height: 100dvh;
  padding: 20px 12px 18px;
  position: relative;
}

.site-header {
  min-height: 58px;
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  max-width: 1440px;
  margin: 0 auto 10px;
}

.section-index {
  margin: 0 0 5px;
  color: var(--gold-deep);
  font: 600 9px/1.2 var(--sans);
  letter-spacing: .22em;
}

.title-block h1 {
  margin: 0;
  font: 500 clamp(28px, 2.4vw, 38px)/1.05 var(--sans);
  letter-spacing: .18em;
}

.subtitle {
  display: inline-block;
  margin: 7px 0 0;
  color: #756c62;
  font-size: 11px;
  letter-spacing: .1em;
}

.title-rule {
  display: block;
  height: 1px;
  width: 100%;
  margin-top: 5px;
  background: linear-gradient(90deg, var(--gold), rgba(189, 155, 85, .15));
}

.mobile-credits, .mobile-only { display: none; }

.workspace {
  max-width: 1480px;
  height: min(780px, calc(100dvh - 108px));
  min-height: 580px;
  margin: 0 auto;
  display: grid;
  grid-template-columns: minmax(255px, 270px) minmax(480px, 1fr) minmax(348px, 360px);
  justify-content: center;
  gap: 12px;
}

.guide-panel, .library-panel, .coordinate-frame, .mobile-instruction {
  --frame-radius: 24px;
  position: relative;
  border: 1.6px solid #b88a3a;
  border-radius: var(--frame-radius);
  background: rgba(255, 251, 244, .63);
  box-shadow: 0 12px 30px rgba(103, 75, 31, .06);
}

.guide-panel::after, .library-panel::after, .coordinate-frame::after, .mobile-instruction::after {
  content: "";
  position: absolute;
  inset: 7px;
  z-index: 30;
  border: 1px solid #e4cc8b;
  border-radius: calc(var(--frame-radius) - 7px);
  pointer-events: none;
}

.guide-panel {
  height: 100%;
  min-height: 0;
  display: flex;
  flex-direction: column;
  padding: 21px 18px 20px;
}

.guide-scroll { overflow: auto; min-height: 0; scrollbar-width: thin; }
.guide-scroll h2, .library-head h2 {
  font: 500 23px/1.38 var(--sans);
  letter-spacing: .1em;
  margin: 0;
}
.guide-intro { margin: 5px 0 0; color: var(--muted); font-size: 10px; white-space: nowrap; }

.steps { list-style: none; padding: 0; margin: 18px 0 8px; counter-reset: step; }
.steps li { position: relative; padding: 0 0 13px 35px; }
.steps li::before {
  counter-increment: step;
  content: "0" counter(step);
  position: absolute;
  left: 0;
  top: 1px;
  color: var(--gold-deep);
  font: 600 10px/1 var(--sans);
  letter-spacing: .05em;
}
.steps li:not(:last-child)::after { content: ""; position: absolute; left: 8px; top: 18px; bottom: 3px; border-left: 1px solid var(--line); }
.steps b { display: block; font: 600 13px/1.3 var(--sans); }
.steps span { display: block; color: var(--muted); font-size: 10px; line-height: 1.5; margin-top: 2px; white-space: nowrap; }

.axis-legend { border: 1px solid rgba(196, 163, 91, .5); border-radius: 14px; padding: 9px 12px 8px; background: #fff8e7; }
.axis-legend-head { display: flex; align-items: baseline; justify-content: space-between; gap: 8px; white-space: nowrap; }
.axis-legend-head strong { font: 600 12px var(--sans); }
.axis-legend-head span { color: #a0978e; font-size: 8px; }
.mini-axis { position: relative; height: 54px; margin-top: 4px; color: #796e66; }
.mini-axis-line { position: absolute; display: block; background: #ddd5cd; }
.mini-axis-x { left: 0; right: 0; top: 25px; height: 1px; }
.mini-axis-y { top: 3px; bottom: 3px; left: 50%; width: 1px; }
.mini-axis-origin { position: absolute; left: 50%; top: 25px; width: 7px; height: 7px; border-radius: 50%; background: #b29e8e; transform: translate(-50%, -50%); }
.mini-axis b { position: absolute; font: 600 9px var(--sans); }
.mini-left { left: 0; top: 10px; }.mini-right { right: 0; top: 10px; }
.mini-top { left: calc(50% + 7px); top: 0; }.mini-bottom { left: calc(50% + 7px); bottom: 0; }
.tip-card { margin-top: 8px; padding: 11px 14px 10px; border-radius: 14px; background: #5a4034; color: #fff; }
.tip-card strong { display: flex; align-items: center; gap: 7px; margin-bottom: 7px; font: 600 12px var(--sans); }
.tip-card strong i { width: 16px; height: 16px; display: grid; place-items: center; border-radius: 50%; background: #f4d77e; color: #2d2a27; font: 700 10px var(--symbol); }
.tip-card p { margin: 3px 0; color: #eee8e3; font-size: 8.8px; line-height: 1.45;  }

.guide-footer { margin-top: auto; padding-top: 11px; }
.desktop-progress { display: none; }
.desktop-progress strong { font: 400 12px var(--sans); color: var(--muted); white-space: nowrap; }
.desktop-progress em { color: var(--gold-deep); font: 500 18px var(--sans); font-style: normal; }
.desktop-progress-track { flex: 1; height: 5px; border-radius: 999px; background: rgba(184, 138, 58, .16); overflow: hidden; }
.desktop-progress-fill { width: 0%; height: 100%; border-radius: inherit; background: var(--gold); transition: width .22s ease; }
.credits { padding-top: 11px; font-size: 8px; color: #8a8177; line-height: 1.6; }
.credits > span { display: block; margin-bottom: 5px; color: var(--gold-deep); font: 600 8px var(--sans); letter-spacing: .18em; }
.credits p { margin: 0; }

.coordinate-section { height: 100%; min-height: 0; }
.coordinate-main { position: relative; min-width: 0; height: 100%; display: flex; align-items: center; justify-content: center; }
.coordinate-editor { width: 100%; display: grid; grid-template-columns: 72px minmax(0, 1fr) 72px; align-items: stretch; column-gap: 8px; }
.coordinate-side-tools { grid-column: 3; width: 72px; min-width: 0; display: flex; flex-direction: column; align-items: flex-start; justify-content: flex-end; gap: 8px; }
.coordinate-frame {
  grid-column: 2;
  --frame-radius: 28px;
  position: relative;
  width: min(100%, calc(100dvh - 108px));
  max-width: 780px;
  aspect-ratio: 1;
  align-self: center;
  overflow: hidden;
  cursor: grab;
  touch-action: none;
  background: #f8f4ed;
}
.coordinate-frame.is-panning { cursor: grabbing; }
.coordinate-frame.is-drop-valid { box-shadow: inset 0 0 0 3px rgba(184, 141, 56, .74), 0 0 0 6px rgba(184, 141, 56, .12); }
.coordinate-frame.is-drop-invalid { box-shadow: inset 0 0 0 3px rgba(184, 95, 85, .75); }

.coordinate-world {
  position: absolute;
  inset: 0;
  transform-origin: 50% 50%;
  will-change: transform;
  overflow: visible;
  background:
    /* 左上：荆棘 × 不忘 */
    radial-gradient(ellipse at 24% 24%, rgb(var(--coord-q-ul-main) / .45) 0%, rgb(var(--coord-q-ul-soft) / .28) 23%, rgba(248, 244, 237, 0) 58%),
    /* 右上：繁花 × 不忘 */
    radial-gradient(ellipse at 77% 24%, rgb(var(--coord-q-ur-main) / .45) 0%, rgb(var(--coord-q-ur-soft) / .26) 24%, rgba(248, 244, 237, 0) 58%),
    /* 左下：荆棘 × 寻常 */
    radial-gradient(ellipse at 24% 77%, rgb(var(--coord-q-ll-main) / .42) 0%, rgb(var(--coord-q-ll-soft) / .26) 25%, rgba(248, 244, 237, 0) 59%),
    /* 右下：繁花 × 寻常 */
    radial-gradient(ellipse at 77% 77%, rgb(var(--coord-q-lr-main) / .48) 0%, rgb(var(--coord-q-lr-soft) / .27) 25%, rgba(248, 244, 237, 0) 59%),
    linear-gradient(135deg, #faf7f1, #f5f0e8);
}

.quadrant-glow { position: absolute; inset: 0; box-shadow: inset 0 0 90px rgba(107, 89, 58, .06); pointer-events: none; }
.axis { position: absolute; background: rgba(90, 81, 72, .35); pointer-events: none; }
.axis-x { left: 21%; right: 21%; top: 50%; height: 1px; }
.axis-y { top: 15%; bottom: 15%; left: 50%; width: 1px; }
.origin-mark { position: absolute; width: 7px; height: 7px; left: 50%; top: 50%; border: 1px solid rgba(91, 80, 65, .46); border-radius: 50%; transform: translate(-50%, -50%); background: #f7f1e8; }
.guide-line { display: none; position: absolute; z-index: 4; pointer-events: none; border-color: rgba(139, 106, 42, .58); border-style: dashed; }
.guide-line-x { left: 3%; right: 3%; height: 0; border-width: 1px 0 0; top: 50%; }
.guide-line-y { top: 3%; bottom: 3%; width: 0; border-width: 0 0 0 1px; left: 50%; }
.coordinate-world.guides-on .guide-line { display: block; }

.coordinate-world { --coord-label-gap: 1px; --coord-label-edge: 7%; --coord-bottom-label-top: 85.5%; }
.quadrant-label { position: absolute; z-index: 1; color: rgba(73, 66, 60, .68); line-height: 1.28; pointer-events: none; }
.quadrant-label strong { display: block; font: 500 clamp(11px, 1vw, 14px) var(--sans); letter-spacing: .08em; }
.quadrant-label span { display: block; margin-top: var(--coord-label-gap); font-size: clamp(7px, .7vw, 9px); line-height: 1.28; letter-spacing: .06em; }
.q-ul { left: var(--coord-label-edge); top: var(--coord-label-edge); }.q-ur { right: var(--coord-label-edge); top: var(--coord-label-edge); text-align: right; }
.q-ll { left: var(--coord-label-edge); top: var(--coord-bottom-label-top); }.q-lr { right: var(--coord-label-edge); top: var(--coord-bottom-label-top); text-align: right; }
.axis-copy { position: absolute; z-index: 1; pointer-events: none; color: rgba(68, 61, 56, .74); }
.axis-copy strong { display: block; font: 500 clamp(12px, 1.2vw, 17px) var(--sans); letter-spacing: .12em; }
.axis-copy span { display: block; margin-top: var(--coord-label-gap); font-size: clamp(7px, .65vw, 9px); line-height: 1.28; color: rgba(91, 82, 74, .58); }
.axis-left, .axis-right { top: 50%; width: 24%; height: 0; }
.axis-left { left: var(--coord-label-edge); text-align: left; }
.axis-right { right: var(--coord-label-edge); text-align: right; }
.axis-left strong, .axis-right strong { position: absolute; bottom: calc(var(--coord-label-gap) / 2); width: 100%; }
.axis-left span, .axis-right span { position: absolute; top: calc(var(--coord-label-gap) / 2); width: 100%; }
.axis-top { top: var(--coord-label-edge); left: 50%; transform: translateX(-50%); display: flex; flex-direction: column; align-items: center; text-align: center; gap: 0; }
.axis-bottom { top: var(--coord-bottom-label-top); left: 50%; transform: translateX(-50%); display: flex; flex-direction: column; align-items: center; text-align: center; gap: 0; }

.placed-layer { position: absolute; inset: 0; z-index: 5; pointer-events: none; }
.placed-logo {
  position: absolute;
  width: 54px;
  aspect-ratio: 1;
  border: 0;
  padding: 0;
  background: transparent;
  transform: translate(-50%, -50%);
  cursor: grab;
  touch-action: none;
  pointer-events: auto;
  filter: none;
  user-select: none;
  -webkit-user-select: none;
  -webkit-touch-callout: none;
}
.placed-logo:active { cursor: grabbing; }
.placed-logo img, .placed-logo .placeholder-mark { display: block; width: 100%; height: 100%; object-fit: contain; user-select: none; -webkit-user-select: none; -webkit-user-drag: none; -webkit-touch-callout: none; }
.placed-logo .placeholder-mark { display: grid; place-items: center; color: rgba(255,255,255,.82); font: 600 12px var(--sans); border-radius: 10px; }
.placed-logo.is-selected { filter: none; }
.placed-logo.is-overlap { animation: overlapPulse .7s ease; }
@keyframes overlapPulse { 45% { transform: translate(-50%, -50%) scale(1.08); } }

.coordinate-toolbar {
  position: static;
  z-index: 20;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
  min-width: 42px;
  padding: 5px 7px;
  border: 1px solid rgba(125, 105, 68, .3);
  border-radius: 9px;
  background: rgba(255, 252, 247, .9);
  box-shadow: 0 9px 24px rgba(62, 52, 38, .13);
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
  touch-action: none;
  margin: 0;
}
.coordinate-toolbar button, .zoom-value {
  width: 32px;
  height: 32px;
  border: 0;
  border-radius: 6px;
  background: transparent;
  display: grid;
  place-items: center;
  padding: 0;
  font-size: 16px;
}
.coordinate-toolbar button:hover { background: rgba(181, 151, 94, .12); }
.coordinate-toolbar button[aria-pressed="true"] { color: #6f5521; background: rgba(184, 138, 58, .22); box-shadow: inset 0 0 0 1px rgba(129, 96, 37, .18), 0 2px 6px rgba(103, 75, 31, .08); }
.coordinate-toolbar button[aria-pressed="true"] .guide-icon { opacity: 1; }
.coordinate-toolbar .toolbar-handle { display: none; }
.toolbar-handle i { width: 3px; height: 3px; border-radius: 50%; background: #9b9185; }
.zoom-value { width: 32px; color: var(--muted); font-size: 8px; }
.guide-icon { width: 17px; height: 17px; display: block; background: linear-gradient(90deg, transparent 47%, currentColor 48% 53%, transparent 54%), linear-gradient(transparent 47%, currentColor 48% 53%, transparent 54%); opacity: .72; }
.fullscreen-icon { width: 15px; height: 15px; display: block; border: 1.5px solid currentColor; clip-path: polygon(0 0, 38% 0, 38% 15%, 15% 15%, 15% 38%, 0 38%, 0 0, 100% 0, 100% 38%, 85% 38%, 85% 15%, 62% 15%, 62% 0, 100% 0, 100% 100%, 62% 100%, 62% 85%, 85% 85%, 85% 62%, 100% 62%, 100% 100%, 0 100%, 0 62%, 15% 62%, 15% 85%, 38% 85%, 38% 100%, 0 100%); }

.viewport-minimap {
  position: relative;
  z-index: 19;
  width: 72px;
  height: 72px;
  overflow: hidden;
  border: 1px solid rgba(184, 138, 58, .58);
  border-radius: 15px;
  background:
    /* 左上：荆棘 × 不忘 */
    radial-gradient(circle at 24% 24%, rgb(var(--coord-q-ul-main) / .34), transparent 58%),
    /* 右上：繁花 × 不忘 */
    radial-gradient(circle at 77% 24%, rgb(var(--coord-q-ur-main) / .34), transparent 58%),
    /* 左下：荆棘 × 寻常 */
    radial-gradient(circle at 24% 77%, rgb(var(--coord-q-ll-main) / .31), transparent 59%),
    /* 右下：繁花 × 寻常 */
    radial-gradient(circle at 77% 77%, rgb(var(--coord-q-lr-main) / .35), transparent 59%),
    rgba(255,252,246,.92);
  box-shadow: 0 8px 20px rgba(62,52,38,.12);
  cursor: crosshair;
  touch-action: none;
  user-select: none;
}
.viewport-minimap::after { content: ""; position: absolute; inset: 5px; border: 1px solid rgba(228,204,139,.72); border-radius: 10px; pointer-events: none; }
.minimap-axis { position: absolute; z-index: 1; background: rgba(84,76,69,.3); pointer-events: none; }
.minimap-axis-x { left: 7px; right: 7px; top: 50%; height: 1px; }
.minimap-axis-y { top: 7px; bottom: 7px; left: 50%; width: 1px; }
.minimap-label { position: absolute; z-index: 3; color: #514943; font: 500 6px/1 var(--sans); pointer-events: none; }
.minimap-top { top: 4px; left: 50%; transform: translateX(-50%); }
.minimap-right { right: 3px; top: 50%; transform: translateY(-50%); }
.minimap-bottom { bottom: 4px; left: 50%; transform: translateX(-50%); }
.minimap-left { left: 3px; top: 50%; transform: translateY(-50%); }
.minimap-viewport { position: absolute; z-index: 2; left: 0; top: 0; width: 100%; height: 100%; border: 2px solid #e67670; border-radius: 4px; background: rgba(255,255,255,.08); box-shadow: 0 0 0 1px rgba(255,255,255,.72) inset; pointer-events: none; transition: left .08s linear, top .08s linear, width .08s linear, height .08s linear; }
.viewport-minimap.is-overview .minimap-viewport { border-color: rgba(184,138,58,.42); }

.drop-feedback { position: absolute; inset: 0; z-index: 15; display: grid; place-items: center; opacity: 0; pointer-events: none; transition: opacity .15s; border: 2px solid var(--gold); background: rgba(255, 247, 226, .08); }
.drop-feedback span { background: rgba(72, 62, 49, .84); color: white; border-radius: 18px; padding: 8px 15px; font-size: 11px; }
.coordinate-frame.is-drop-valid .drop-feedback { opacity: 1; }

.library-panel { height: 100%; min-height: 0; display: flex; flex-direction: column; overflow: hidden; }
.library-head { position: relative; padding: 21px 18px 12px; border-bottom: 1px solid var(--line); background: rgba(255, 251, 244, .76); z-index: 2; }
.library-title-row { display: flex; justify-content: space-between; gap: 8px; align-items: flex-start; }
.library-head h2 { font-size: 20px; }
.history-actions { display: flex; gap: 4px; align-items: center; }
.history-actions button {
  border: 1px solid rgba(139, 117, 74, .25);
  background: rgba(255,255,255,.44);
  border-radius: 7px;
  min-width: 36px;
  height: 36px;
  padding: 2px 5px;
  display: grid;
  place-items: center;
  line-height: 1;
}
.history-actions button span { font-size: 15px; }
.history-actions button small { font-size: 7px; color: var(--muted); }
.history-actions .clear-btn { min-width: 52px; border-color: rgba(184,95,85,.27); color: #98524b; }
.history-actions .clear-btn span { font-size: 10px; letter-spacing: .06em; }
.library-help { margin: 11px 0 12px; color: var(--muted); font-size: 8px; line-height: 1.6; }
.filter-row { display: flex; gap: 7px; }
.filter-btn { min-height: 28px; padding: 4px 12px; border-radius: 15px; border: 1px solid rgba(139,117,74,.26); background: transparent; font-size: 9px; }
.filter-btn.is-active { background: #4e4943; color: #fffaf1; border-color: #4e4943; }
.share-trigger { width: 100%; min-height: 34px; margin-top: 10px; border: 1px solid rgba(142,113,55,.42); border-radius: 999px; color: #fffaf1; background: linear-gradient(135deg, #9a7a3b, #7f6634); box-shadow: 0 10px 20px rgba(103,75,31,.12); font: 600 11px var(--sans); letter-spacing: .1em; }
.share-trigger[hidden] { display: none; }

.logo-scroll { min-height: 0; flex: 1; overflow-y: auto; overscroll-behavior: contain; scrollbar-color: rgba(154,126,76,.45) transparent; scrollbar-width: thin; touch-action: pan-y; }
.logo-grid { padding: 15px 8px 26px; display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 13px 5px; }
.logo-card { appearance: none; border: 0; padding: 0; min-width: 0; background: transparent; text-align: center; cursor: grab; touch-action: pan-y; position: relative; user-select: none; -webkit-user-select: none; -webkit-touch-callout: none; }
.logo-card:active { cursor: grabbing; }
.logo-thumb { width: 100%; aspect-ratio: 1; display: grid; place-items: center; position: relative; filter: drop-shadow(0 4px 4px rgba(69,56,41,.12)); }
.logo-thumb img { display: block; width: 100%; height: 100%; object-fit: contain; user-select: none; -webkit-user-select: none; -webkit-user-drag: none; -webkit-touch-callout: none; }
.logo-thumb .placeholder-mark { width: 78%; height: 78%; border-radius: 9px; display: grid; place-items: center; color: rgba(255,255,255,.82); font: 600 10px var(--sans); }
.logo-card > .fragment-name { display: block; overflow: hidden; margin-top: 4px; font: 500 9px/1.2 var(--sans); white-space: nowrap; text-overflow: ellipsis; }
.logo-card > .fragment-name .fragment-name-line1, .logo-card > .fragment-name .fragment-name-line2 { display: block; }
.logo-card > .fragment-name .fragment-name-line2 { margin-top: 1px; }
.logo-card.is-placed { opacity: .5; }
.logo-card.is-placed .logo-thumb::after { content: "已放置"; position: absolute; inset: auto 0 1px; margin: auto; width: max-content; color: white; background: rgba(75,68,61,.78); padding: 2px 5px; border-radius: 6px; font-size: 6px; }
.logo-card.is-focused .logo-thumb { filter: drop-shadow(0 0 5px rgba(166,124,43,.7)); }
.empty-state { color: var(--muted); text-align: center; padding: 50px 16px; font: 13px var(--sans); }

.preview-backdrop {
  display: none;
}

@media (max-width: 1023px) {
  .preview-backdrop {
    display: block;
    position: fixed;
    inset: 0;
    z-index: 199;
    background: rgba(45, 40, 35, .4);
    opacity: 0;
    pointer-events: none;
    transition: opacity .15s ease;
  }
  .preview-backdrop.is-visible {
    opacity: 1;
    pointer-events: auto;
  }
}

.preview-popover {
  position: fixed;
  z-index: 200;
  width: max-content;
  max-width: calc(100vw - 20px);
  pointer-events: none;
  padding: 9px;
  border-radius: 18px;
  background: rgba(255, 253, 249, .96);
  box-shadow: 0 18px 42px rgba(55, 46, 34, .25);
  opacity: 0;
  transform: translateY(7px) scale(.98);
  transition: opacity .15s ease, transform .15s ease;
}
.preview-popover.is-visible { opacity: 1; transform: none; }
.preview-popover > div { width: max-content; max-width: 100%; overflow: hidden; border-radius: 11px; background: #ead9bf; }
.preview-popover img { display: block; width: auto; height: auto; max-width: min(310px, calc(100vw - 38px)); max-height: min(70vh, 520px); object-fit: contain; }
.preview-placeholder { width: min(310px, calc(100vw - 38px)); aspect-ratio: 16 / 10; }
.preview-popover .placeholder-mark { display: block; width: 100%; height: 100%; }

.drag-ghost { position: fixed; z-index: 500; width: 58px; height: 58px; pointer-events: none; transform: translate(-50%,-50%) scale(.96); opacity: 0; filter: drop-shadow(0 8px 10px rgba(49,40,30,.25)); }
.drag-ghost.is-active { opacity: .95; transform: translate(-50%,-50%) scale(1.04); }
.drag-ghost img, .drag-ghost .placeholder-mark { width: 100%; height: 100%; object-fit: contain; display: grid; place-items: center; border-radius: 10px; color: #fff; font: 600 12px var(--sans); }

.toast-stack { position: fixed; left: 50%; top: max(18px, env(safe-area-inset-top)); z-index: 1000; transform: translateX(-50%); display: grid; place-items: center; pointer-events: none; }
.toast { opacity: 0; transform: translateY(-6px); background: rgba(65,58,51,.91); color: #fff; padding: 9px 15px; border-radius: 20px; box-shadow: 0 8px 22px rgba(44,37,30,.16); font-size: 11px; white-space: nowrap; transition: opacity .18s ease, transform .18s ease, background-color .18s ease; }
.toast.is-visible { opacity: 1; transform: translateY(0); }
.toast.is-error { background: rgba(145,72,65,.94); }

.share-dialog { border: 0; padding: 0; background: transparent; width: min(430px, calc(100vw - 24px)); max-width: calc(100vw - 24px); max-height: min(94dvh, 860px); overflow: auto; }
.confirm-dialog, .user-id-dialog { border: 0; padding: 0; background: transparent; max-width: calc(100vw - 32px); }
.user-id-dialog { width: min(440px, calc(100vw - 32px)); overflow: visible; }
.share-dialog::backdrop, .confirm-dialog::backdrop { background: rgba(63,55,47,.32); backdrop-filter: blur(3px); }
.share-dialog.is-fallback-open, .confirm-dialog.is-fallback-open { position: fixed; inset: 0; width: 100%; height: 100%; max-width: none; display: grid; place-items: center; background: rgba(63,55,47,.32); z-index: 1200; }
.user-id-dialog.is-fallback-open { position: fixed; inset: 0; width: 100%; height: 100%; max-width: none; display: grid; place-items: center; z-index: 1200; }
.share-dialog-card { position: relative; width: 100%; padding: 0 0 16px; background: transparent; border: 0; border-radius: 0; box-shadow: none; text-align: center; }
.share-close { position: absolute; top: 10px; right: 10px; z-index: 2; width: 34px; height: 34px; border: 0; border-radius: 50%; background: rgba(255, 250, 241, .86); color: var(--muted); box-shadow: 0 4px 14px rgba(55,46,34,.16); font-size: 22px; line-height: 1; }
.share-preview { min-height: 320px; display: grid; place-items: center; background: transparent; overflow: visible; color: var(--muted); font-size: 12px; }
.share-preview img { display: block; width: 100%; aspect-ratio: 3 / 4; object-fit: contain; border-radius: 0; }
.share-save-guide { position: absolute; inset: 0; z-index: 4; display: grid; place-items: center; padding: 24px; background: rgba(63, 55, 47, .18); backdrop-filter: blur(2px); opacity: 0; transition: opacity .18s ease; }
.share-save-guide[hidden] { display: none; }
.share-save-guide.is-visible { opacity: 1; }
.share-save-guide-card { width: min(280px, calc(100vw - 72px)); padding: 20px 18px 18px; border: 1px solid rgba(184, 138, 58, .36); border-radius: 18px; background: rgba(255, 250, 241, .97); box-shadow: 0 16px 42px rgba(55, 46, 34, .2); color: var(--ink); text-align: center; }
.share-save-guide-card strong { display: block; font: 600 16px var(--sans); letter-spacing: .02em; }
.share-save-guide-card p { margin: 10px 0 16px; color: var(--muted); font-size: 12px; line-height: 1.7; }
.share-save-guide-card button { min-width: 104px; min-height: 36px; border: 0; border-radius: 999px; background: #8e7137; color: #fffaf1; font: 500 12px var(--sans); }
.share-actions { display: grid; grid-template-columns: 1fr 1fr 1fr; gap: 10px; margin-top: 14px; }
.share-actions a, .share-actions button { min-height: 42px; display: grid; place-items: center; border: 1px solid rgba(139,117,74,.28); border-radius: 999px; background: rgba(255,250,241,.92); color: var(--ink); text-decoration: none; font: 500 12px var(--sans); }
.share-actions a:not([aria-disabled="true"]) { color: #fffaf1; background: #8e7137; border-color: #8e7137; }
.share-actions a[aria-disabled="true"] { opacity: .42; pointer-events: none; }
.share-help { margin: 12px 0 0; color: var(--muted); font-size: 10px; line-height: 1.7; }
.dialog-card { position: relative; width: min(360px, calc(100vw - 32px)); padding: 28px; background: var(--paper-2); border: 1px solid rgba(141,112,57,.32); border-radius: 14px; box-shadow: var(--shadow); }
.dialog-card h2 { font: 500 22px var(--sans); margin: 0 0 12px; }
.dialog-card > p:not(.section-index) { color: var(--muted); font-size: 12px; line-height: 1.8; }
.dialog-actions { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; margin-top: 22px; }
.dialog-actions button { min-height: 44px; border: 1px solid var(--line); border-radius: 8px; background: transparent; }
.dialog-actions .danger { background: #8f554e; border-color: #8f554e; color: white; }
/* User ID Dialog - scoped visual polish */
.user-id-dialog::backdrop {
  background: rgba(63, 55, 47, .26);
  backdrop-filter: blur(6px);
  -webkit-backdrop-filter: blur(6px);
}

.user-id-dialog.is-fallback-open {
  background: rgba(63, 55, 47, .26);
  backdrop-filter: blur(6px);
  -webkit-backdrop-filter: blur(6px);
}

.user-id-dialog .dialog-card {
  width: min(440px, calc(100vw - 32px));
  padding: 36px 32px 32px;
  background:
    radial-gradient(circle at 18% 18%, rgb(var(--coord-q-lr-soft) / .16), transparent 44%),
    radial-gradient(circle at 82% 18%, rgb(var(--coord-q-ur-soft) / .18), transparent 43%),
    radial-gradient(circle at 18% 84%, rgb(var(--coord-q-ul-soft) / .14), transparent 45%),
    radial-gradient(circle at 84% 86%, rgb(var(--coord-q-ll-soft) / .15), transparent 45%),
    #fffaf1;
  border: 1px solid rgba(141, 112, 57, .25);
  border-radius: 24px;
  box-shadow: 0 24px 70px rgba(68, 57, 42, .20);
  color: var(--ink);
  overflow: hidden;
  text-align: left;
}

.user-id-dialog .section-index {
  margin: 0 0 14px;
  color: #8E7137;
  font-size: 9px;
  font-weight: 700;
  line-height: 1.2;
  letter-spacing: .28em;
}

.user-id-dialog .user-id-close {
  position: absolute;
  top: 13px;
  right: 13px;
  z-index: 2;
  width: 36px;
  height: 36px;
  border: 1px solid rgba(141, 112, 57, .16);
  border-radius: 50%;
  background: rgba(255, 250, 241, .38);
  color: rgba(69, 63, 58, .62);
  font-size: 21px;
  line-height: 1;
  cursor: pointer;
  display: grid;
  place-items: center;
  box-shadow: 0 6px 16px rgba(68, 57, 42, .06);
  transition: background-color .16s ease, border-color .16s ease, color .16s ease, transform .16s ease, box-shadow .16s ease;
}

.user-id-dialog .user-id-close:hover {
  background: rgba(189, 155, 85, .13);
  border-color: rgba(141, 112, 57, .25);
  color: var(--gold-deep);
  box-shadow: 0 8px 20px rgba(68, 57, 42, .08);
}

.user-id-dialog .user-id-close:active {
  transform: scale(.96);
}

.user-id-dialog .user-id-close:focus-visible {
  outline: 2px solid rgba(189, 155, 85, .56);
  outline-offset: 3px;
  box-shadow: 0 0 0 5px rgba(189, 155, 85, .14);
}

.user-id-dialog .user-id-title {
  display: flex;
  align-items: center;
  gap: 10px;
  color: #453F3A;
  font-size: 24px;
  font-weight: 600;
  line-height: 1.25;
  letter-spacing: .01em;
  margin: 0;
}

.user-id-dialog .title-sparkle {
  flex: 0 0 auto;
  color: #B48A3E;
  font-size: 19px;
  font-weight: 400;
  line-height: 1;
  opacity: .82;
  transform: translateY(-1px);
}

.user-id-dialog p.user-id-subtitle {
  max-width: 100%;
  color: rgba(133, 125, 115, .86);
  font-size: 14px;
  font-weight: 400;
  line-height: 1.65;
  letter-spacing: 0;
  margin: 14px 0 0;
}

.user-id-dialog .user-id-field {
  display: grid;
  gap: 8px;
  width: 100%;
  margin: 24px 0 0;
}

.user-id-dialog .user-id-field label {
  color: rgba(133, 125, 115, .92);
  font-size: 13px;
  font-weight: 500;
  line-height: 1.4;
  letter-spacing: .06em;
  margin: 0;
}

.user-id-dialog .user-id-input {
  width: 100%;
  min-width: 0;
  box-sizing: border-box;
  height: 48px;
  padding: 0 16px;
  border: 1px solid rgba(142, 113, 55, .28);
  border-radius: 14px;
  background: rgba(247, 241, 231, .72);
  color: #453F3A;
  font-size: 15px;
  font-weight: 400;
  line-height: 1.4;
  font-family: var(--sans);
  caret-color: #BD9B55;
  outline: 2px solid transparent;
  outline-offset: 2px;
  box-shadow: none;
  transition: border-color .18s ease, box-shadow .18s ease, background-color .18s ease;
}

.user-id-dialog .user-id-input:hover {
  border-color: rgba(142, 113, 55, .42);
  background: rgba(247, 241, 231, .86);
}

.user-id-dialog .user-id-input:focus,
.user-id-dialog .user-id-input:focus-visible {
  border-color: #BD9B55;
  background: rgba(255, 250, 241, .94);
  outline-color: rgba(189, 155, 85, .26);
  box-shadow: 0 0 0 3px rgba(189, 155, 85, .12), 0 8px 20px rgba(93, 70, 32, .06);
}

.user-id-dialog .user-id-input::placeholder {
  color: rgba(133, 125, 115, .56);
  font-size: 15px;
  font-weight: 400;
  opacity: 1;
}

.user-id-dialog .dialog-actions {
  display: grid;
  grid-template-columns: minmax(0, .92fr) minmax(0, 1.08fr);
  gap: 12px;
  margin-top: 20px;
}

.user-id-dialog .dialog-actions button {
  min-width: 0;
  min-height: 56px;
  border-radius: 16px;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 8px 14px;
  gap: 3px;
  cursor: pointer;
  font-family: var(--sans);
  text-align: center;
  transition: background-color .18s ease, border-color .18s ease, box-shadow .18s ease, transform .12s ease;
}

.user-id-dialog #anonymousBtn {
  border: 1px solid rgba(185, 152, 93, .34);
  background: rgba(255, 249, 240, .72);
  color: #514A44;
  box-shadow: 0 6px 16px rgba(103, 88, 68, .06);
}

.user-id-dialog #anonymousBtn:hover {
  background: rgba(255, 249, 240, .96);
  border-color: rgba(185, 152, 93, .52);
  transform: translateY(-1px);
}

.user-id-dialog #anonymousBtn:active {
  transform: translateY(1px);
  box-shadow: 0 4px 12px rgba(103, 88, 68, .05);
}

.user-id-dialog #confirmUserIdBtn {
  border: 1px solid #745A28;
  background: #8E7137;
  color: #FFF9ED;
  box-shadow: 0 8px 20px rgba(96, 72, 30, .18), inset 0 1px 0 rgba(255, 249, 237, .20);
}

.user-id-dialog #confirmUserIdBtn:hover {
  background: #82662F;
  border-color: #6C5223;
  box-shadow: 0 10px 24px rgba(96, 72, 30, .22), inset 0 1px 0 rgba(255, 249, 237, .22);
  transform: translateY(-1px);
}

.user-id-dialog #confirmUserIdBtn:active {
  background: #795E2B;
  transform: translateY(1px);
  box-shadow: 0 4px 12px rgba(96, 72, 30, .16), inset 0 1px 0 rgba(255, 249, 237, .14);
}

.user-id-dialog #anonymousBtn:focus-visible,
.user-id-dialog #confirmUserIdBtn:focus-visible {
  outline: 3px solid rgba(189, 155, 85, .34);
  outline-offset: 3px;
}

.user-id-dialog .dialog-actions .btn-main {
  font-size: 15px;
  font-weight: 600;
  line-height: 1.3;
  letter-spacing: .02em;
}

.user-id-dialog #anonymousBtn .btn-main {
  color: #514A44;
}

.user-id-dialog #confirmUserIdBtn .btn-main {
  color: #FFF9ED;
}

.user-id-dialog .dialog-actions .btn-sub {
  font-size: 11px;
  font-weight: 400;
  line-height: 1.35;
  margin-top: 2px;
}

.user-id-dialog #anonymousBtn .btn-sub {
  color: #857D73;
}

.user-id-dialog #confirmUserIdBtn .btn-sub {
  color: rgba(255, 249, 237, .74);
}

@media (max-width: 480px) {
  .user-id-dialog {
    width: min(440px, calc(100vw - 24px));
    max-width: calc(100vw - 24px);
  }

  .user-id-dialog .dialog-card {
    width: 100%;
    padding: 32px 24px 28px;
    border-radius: 22px;
  }

  .user-id-dialog .user-id-close {
    top: 12px;
    right: 12px;
  }

  .user-id-dialog .dialog-actions .btn-sub {
    font-size: 10px;
  }
}

@media (max-width: 419px) {
  .user-id-dialog {
    width: calc(100vw - 20px);
    max-width: calc(100vw - 20px);
  }

  .user-id-dialog .dialog-card {
    padding: 28px 18px 24px;
  }

  .user-id-dialog .dialog-actions {
    grid-template-columns: 1fr;
  }

  .user-id-dialog #confirmUserIdBtn {
    order: 1;
  }

  .user-id-dialog #anonymousBtn {
    order: 2;
  }
}

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


body.is-immersive { overflow: hidden; }
body.is-immersive .app-shell { position: fixed; inset: 0; padding: 12px; background: var(--paper); }
body.is-immersive .site-header,
body.is-immersive .guide-panel,
body.is-immersive .mobile-instruction { display: none !important; }
body.is-immersive .workspace { width: min(100%, 1260px); height: calc(100dvh - 24px); min-height: 0; margin: auto; display: grid; grid-template-columns: minmax(0, 1fr) minmax(320px, 360px); gap: 14px; align-items: center; }
body.is-immersive .coordinate-section { width: 100%; height: min(780px, calc(100dvh - 24px)); }
body.is-immersive .coordinate-frame { width: min(100%, calc(100dvh - 24px)); height: auto; max-width: 780px; margin: auto; }
body.is-immersive .library-panel { display: flex !important; width: 100%; height: min(780px, calc(100dvh - 24px)); }

@media (max-width: 1199px) and (min-width: 1024px) {
  .app-shell { padding-inline: 10px; }
  .workspace { grid-template-columns: 250px minmax(0, 1fr) 260px; gap: 8px; }
  .guide-panel { padding-inline: 15px; }
  .library-head { padding-inline: 13px; }
  .history-actions button { min-width: 33px; }
  .tip-card p { font-size: 8px; }
}

@media (max-width: 1023px) {
  body { overflow-y: auto; overscroll-behavior-y: auto; }
  .desktop-only, .desktop-tool { display: none !important; }
  .mobile-only { display: flex; }
  .app-shell { padding: max(20px, env(safe-area-inset-top)) 12px max(12px, env(safe-area-inset-bottom)); min-height: 100vh; min-height: 100dvh; }
  .site-header { min-height: auto; margin: 0 8px 12px; align-items: flex-start; gap: 8px; }
  .title-block h1 { font-size: clamp(19px, 5.2vw, 22px); letter-spacing: .06em; white-space: nowrap; }
  .subtitle { font-size: 8px; letter-spacing: .05em; }
  .mobile-credits { display: flex; flex-direction: column; flex: 0 1 42%; padding-top: 6px; text-align: right; color: var(--muted); font-size: 6px; line-height: 1.7; }
  .mobile-credits .credit-suffix { display: none; }
  .workspace { height: auto; min-height: 0; display: flex; flex-direction: column; gap: 10px; }
  .coordinate-section { position: relative; display: block; order: 1; height: auto; }
  .coordinate-main { height: auto; display: block; }
  .coordinate-editor { display: block; }
  .coordinate-side-tools { display: block; }
  .mobile-instruction[hidden] { display: none !important; }
  .mobile-instruction {
    --frame-radius: 18px;
    width: calc(100% - 24px);
    max-width: 342px;
    height: 40px;
    min-height: 40px;
    margin: 0 auto 8px;
    padding: 4px 8px 4px 12px;
    display: block;
    overflow: hidden;
    background:
      linear-gradient(135deg, rgba(255, 253, 247, .98), rgba(250, 241, 225, .9)),
      rgba(255, 253, 244, .95);
    box-shadow: 0 10px 26px rgba(103, 75, 31, .07);
    opacity: 1;
    transform: translateY(0);
    transition: height .42s ease, min-height .42s ease, margin .42s ease, padding .42s ease, border-width .42s ease, opacity .26s ease, transform .26s ease;
  }
  .mobile-instruction.is-hiding {
    opacity: 0;
    transform: translateY(-4px);
    pointer-events: none;
  }
  .mobile-instruction.is-collapsed {
    height: 0;
    min-height: 0;
    margin-bottom: 0;
    padding-top: 0;
    padding-bottom: 0;
    border-width: 0;
    box-shadow: none;
  }
  .mobile-instruction.is-locked {
    height: 40px;
    min-height: 40px;
    margin-bottom: 8px;
    padding-top: 4px;
    padding-bottom: 4px;
    border-width: 1.6px;
    transition: opacity .18s ease, transform .18s ease;
  }
  .mobile-guide-full {
    min-height: 30px;
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    align-items: center;
    gap: 3px;
  }
  .mobile-guide-step { min-width: 0; min-height: 30px; display: flex; gap: 5px; align-items: center; }
  .mobile-guide-step > span { width: 22px; height: 22px; flex: 0 0 22px; display: grid; place-items: center; border-radius: 50%; font: 700 9px/1 var(--sans); }
  .mobile-guide-step p { min-width: 0; margin: 0; line-height: 1.08; white-space: nowrap; transform: translateY(1px); }
  .mobile-guide-step b { display: block; color: #563d31; font: 700 9px/1.05 var(--sans); }
  .mobile-guide-step small { display: block; margin-top: 2px; color: #a0806c; font: 400 6px/1 var(--sans); }
  .guide-select > span { color: #8e576d; background: #f1d9e4; }
  .guide-place > span { color: #8e6b25; background: #f6e4a8; }
  .guide-adjust > span { color: #52724c; background: #ddebcf; }
  .mobile-guide-compact {
    display: none;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    min-height: 30px;
    color: #624d3f;
  }
  .mobile-guide-compact span {
    min-width: 0;
    padding-left: 4px;
    font: 600 11px/1.2 var(--sans);
    letter-spacing: .06em;
    white-space: nowrap;
  }
  .mobile-guide-compact button {
    flex: 0 0 auto;
    height: 26px;
    padding: 0 11px;
    border: 1px solid rgba(184, 138, 58, .26);
    border-radius: 999px;
    color: #8e7137;
    background: rgba(255, 250, 241, .72);
    font: 600 10px/1 var(--sans);
    letter-spacing: .08em;
  }
  .mobile-instruction[data-mode="compact"] {
    border-color: rgba(184, 138, 58, .5);
  }
  .mobile-instruction[data-mode="compact"] .mobile-guide-full { display: none; }
  .mobile-instruction[data-mode="compact"] .mobile-guide-compact { display: flex; }
  .coordinate-frame { width: calc(100% - 24px); max-width: 342px; aspect-ratio: 1; margin-inline: auto; }
  .quadrant-label strong { font-size: 9px; }.quadrant-label span { font-size: 6px; }
  .axis-copy strong { font-size: 11px; }.axis-copy span { font-size: 6px; }
  .coordinate-toolbar { position: absolute; left: 20px; right: auto; bottom: 8px; width: auto; height: 34px; min-width: 0; min-height: 34px; flex-direction: row; padding: 1px 2px; gap: 0; margin: 0; border-radius: 8px; opacity: .76; transition: opacity .16s ease, box-shadow .16s ease, background-color .16s ease, left .2s ease, bottom .2s ease; }
  .coordinate-toolbar:hover, .coordinate-toolbar:focus-within, .coordinate-toolbar.is-dragging { opacity: 1; background: rgba(255, 252, 247, .96); box-shadow: 0 9px 24px rgba(62, 52, 38, .16); }
  .coordinate-toolbar.is-dragging { transition: opacity .16s ease, box-shadow .16s ease, background-color .16s ease; }
  .coordinate-toolbar.is-snapping { opacity: 1; }
  .coordinate-toolbar button { position: relative; width: 34px; height: 32px; border-radius: 6px; font-size: 15px; }
  .coordinate-toolbar button:active { opacity: 1; }
  .coordinate-toolbar button::after { content: ""; position: absolute; inset: -2px 0; }
  .coordinate-toolbar #fullscreenBtn { display: none; }
  .coordinate-toolbar .toolbar-handle { width: 14px; height: 32px; display: grid; grid-template-columns: repeat(2, 2px); grid-auto-rows: 2px; place-content: center; gap: 3px; cursor: grab; border-right: 1px solid var(--line); border-radius: 0; padding: 0 3px 0 0; }
  .toolbar-handle i { width: 2px; height: 2px; }
  .coordinate-toolbar .guide-icon, .coordinate-toolbar .fullscreen-icon { width: 15px; height: 15px; }
  .library-panel { --frame-radius: 22px; order: 2; width: calc(100% - 24px); max-width: 342px; height: min(340px, 42vh); height: min(340px, 42dvh); min-height: 286px; margin: 0 auto; }
  .library-head { display: grid; grid-template-columns: auto 1fr; grid-template-areas: "title title" "filters history" "share share" "help help"; align-items: center; gap: 5px 6px; padding: 10px 12px 8px; }
  .library-title-row { display: contents; }
  .library-title-row > div:first-child { grid-area: title; }
  .library-head .section-index { margin-bottom: 2px; }
  .library-head h2 { font-size: 18px; line-height: 1.18; }
  .history-actions { grid-area: history; justify-self: end; gap: 3px; }
  .history-actions button { min-width: 0; width: 55px; height: 28px; padding: 0 6px; display: flex; flex-direction: row; align-items: center; justify-content: center; gap: 3px; border-radius: 14px; background: transparent; }
  .history-actions .clear-btn { width: 43px; min-width: 43px; background: transparent; }
  .history-actions .clear-btn span { width: auto; height: auto; margin: 0; display: inline; border-radius: 0; background: transparent; }
  .history-actions button span { font: 400 15px/1 var(--sans); }
  .history-actions button small { font-size: 8px; line-height: 1; }
  .filter-row { grid-area: filters; gap: 3px; }
  .filter-btn { min-height: 28px; height: 28px; padding: 3px 9px; border-radius: 14px; font-size: 8px; }
  .share-trigger { grid-area: share; min-height: 30px; margin-top: 0; font-size: 10px; }
  .library-help { grid-area: help; margin: 0; font-size: 7px; line-height: 1.4; white-space: nowrap; }
  .logo-grid { grid-template-columns: repeat(4, minmax(0,1fr)); padding: 8px 12px 20px; gap: 10px 8px; }
  .logo-card { min-height: 71px; }
  .logo-card > span { font-size: 9px; }
  .mobile-progress { min-height: 40px; flex: 0 0 auto; align-items: center; justify-content: space-between; padding: 7px 16px; border-top: 1px solid var(--line); background: rgba(255,251,244,.85); font-size: 9px; }
  .mobile-progress strong { font-weight: 400; color: var(--muted); }
  .mobile-progress em { font: 500 17px var(--sans); color: var(--gold-deep); font-style: normal; }
  .preview-popover { width: max-content; max-width: calc(100vw - 20px); padding: 7px; border-radius: 14px; pointer-events: none; user-select: none; -webkit-user-select: none; -webkit-touch-callout: none; }
  .preview-popover.is-visible { pointer-events: auto; cursor: pointer; }
  .preview-popover > div { border-radius: 9px; }
  .preview-popover img { max-width: min(64vw, 245px); max-height: min(62vh, 420px); user-select: none; -webkit-user-select: none; -webkit-user-drag: none; -webkit-touch-callout: none; }

  /* 移动端扩大已放置 Logo 的透明点击热区，不改变视觉占位 */
  .placed-logo::after {
    content: "";
    position: absolute;
    inset: -10px;
  }

  .drag-ghost { width: 54px; height: 54px; }
  body.is-immersive .app-shell { padding: max(8px, env(safe-area-inset-top)) 8px max(8px, env(safe-area-inset-bottom)); }
  body.is-immersive .workspace { width: 100%; height: calc(100vh - max(16px, env(safe-area-inset-top) + env(safe-area-inset-bottom))); height: calc(100dvh - max(16px, env(safe-area-inset-top) + env(safe-area-inset-bottom))); display: flex; flex-direction: column; justify-content: center; gap: 8px; }
  body.is-immersive .coordinate-section { flex: 0 0 auto; width: 100%; height: auto; }
  body.is-immersive .coordinate-frame { width: min(calc(100vw - 24px), 342px, calc(100vh - 286px)); width: min(calc(100vw - 24px), 342px, calc(100dvh - 286px)); height: auto; max-width: 342px; }
  body.is-immersive .library-panel { flex: 1 1 286px; width: min(calc(100vw - 24px), 342px); height: auto; min-height: 220px; max-height: 330px; margin: 0 auto; }

  /* 移动端隐藏 FRAGMENTS */
  .library-head .section-index { display: none; }

  /* 长按三段式反馈 */
  .logo-card .logo-thumb {
    transition: transform 140ms ease, filter 140ms ease;
  }
  .logo-card.is-holding .logo-thumb {
    transform: scale(1.02);
  }
  .logo-card.is-holding .logo-thumb::before {
    content: "";
    position: absolute;
    left: 15%;
    bottom: -3px;
    width: 70%;
    height: 2px;
    border-radius: 2px;
    background: #b88a3a;
    transform: scaleX(0);
    transform-origin: left;
    animation: hold-progress 280ms linear forwards;
  }
  .logo-card.is-drag-ready .logo-thumb {
    transform: translateY(-6px) scale(1.08);
    filter: drop-shadow(0 10px 12px rgba(69, 56, 41, 0.22)) drop-shadow(0 0 6px rgba(184, 138, 58, 0.35));
  }
  .drag-ghost { width: 62px; height: 62px; }
  .drag-ghost.is-active { opacity: 1; transform: translate(-50%, -50%) scale(1.08); }

  /* 移动端：去掉操作指引框、待选 LOGO 框的细内框 */
  .mobile-instruction::after,
  .library-panel::after {
    content: none;
  }

  /* 移动端：工具栏始终显示在坐标系框线之上 */
  .coordinate-toolbar {
    z-index: 40;
  }
}

@keyframes hold-progress {
  to { transform: scaleX(1); }
}

/* PC 端左栏四段等距布局 */
@media (min-width: 1024px) {
  .guide-panel {
    --guide-min-gap: 8px;
    height: 100%;
    min-height: 0;
    padding: 21px 18px 20px;
    display: grid;
    grid-template-rows: auto auto auto auto;
    row-gap: var(--guide-min-gap);
    align-content: space-between;
    overflow-y: auto;
    scrollbar-width: thin;
  }
  .guide-scroll { display: contents; }
  .guide-primary { min-width: 0; }
  .steps { margin: 18px 0 0; }
  .axis-legend, .tip-card { margin: 0; }
  .guide-footer { margin: 0; padding: 0; }
  .credits { padding-top: 0; border-top: 1px solid var(--line); }
  .coordinate-frame { padding-bottom: 36px; }
  .axis-y { top: 13%; bottom: 13%; }
  .guide-line-y { top: 13%; bottom: 13%; }
  .axis-top { top: 8%; }
  .axis-bottom { bottom: 8%; }
  .desktop-progress {
    position: absolute;
    left: 22px;
    right: 22px;
    bottom: 16px;
    z-index: 12;
    display: flex;
    align-items: center;
    gap: 12px;
    pointer-events: none;
  }
  .drag-ghost > :not(img) { display: none !important; }
}

@media (max-width: 370px) {
  .site-header { margin-inline: 3px; }
  .mobile-credits { display: flex; flex-basis: 43%; font-size: 5.5px; }
  .mobile-instruction { padding-inline: 9px; }
  .mobile-guide-full { grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 2px; }
  .mobile-guide-step { gap: 4px; }
  .mobile-guide-step > span { width: 20px; height: 20px; flex-basis: 20px; font-size: 8px; }
  .mobile-guide-step b { font-size: 8px; }
  .mobile-guide-step small { font-size: 5.5px; }
  .mobile-guide-compact span { font-size: 10px; letter-spacing: .04em; }
  .mobile-guide-compact button { padding-inline: 9px; }
  .history-actions { gap: 2px; }
  .history-actions button { width: 46px; padding-inline: 3px; }
  .history-actions .clear-btn { width: 36px; min-width: 36px; }
  .filter-btn { padding-inline: 5px; font-size: 7px; }
  .logo-grid { padding-inline: 11px; gap-inline: 7px; }
}

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

/* PC 三栏等高、自适应布局 */
@media (min-width: 1024px) {
  .app-shell {
    /* 两侧面板宽度 */
    --guide-width: clamp(250px, 15vw, 290px);
    --library-width: clamp(260px, 19vw, 390px);

    /* 工具栏和导航框所占宽度 */
    --tool-lane-width: clamp(56px, 4vw, 72px);

    /*
     * 坐标系到左右面板的距离完全相等。
     * 右侧间距内部包含：
     * 8px + 工具区宽度 + 8px
     */
    --panel-gap: calc(var(--tool-lane-width) + 16px);

    /*
     * 坐标系尺寸同时受以下条件限制：
     * 1. 最大不超过 780px
     * 2. 不超过当前屏幕可用高度
     * 3. 不超过扣除两侧面板和间距后的可用宽度
     */
    --stage-size: min(
      780px,
      calc(100dvh - 108px),
      calc(
        100vw
        - 24px
        - var(--guide-width)
        - var(--library-width)
        - var(--panel-gap)
        - var(--panel-gap)
      )
    );

    --layout-width: calc(
      var(--guide-width)
      + var(--stage-size)
      + var(--library-width)
      + var(--panel-gap)
      + var(--panel-gap)
    );
  }

  /* 标题和下方三栏使用相同的整体宽度 */
  .site-header {
    width: var(--layout-width);
    max-width: none;
  }

  .workspace {
    width: var(--layout-width);
    max-width: none;
    height: var(--stage-size);
    min-height: 0;
    margin-inline: auto;

    display: grid;
    grid-template-columns:
      var(--guide-width)
      var(--stage-size)
      var(--library-width);

    column-gap: var(--panel-gap);
    align-items: stretch;
    justify-content: center;
  }

  /* 左右两个面板共同使用坐标系高度 */
  .guide-panel,
  .library-panel {
    width: 100%;
    height: var(--stage-size);
    min-height: 0;
  }

  .coordinate-section,
  .coordinate-main,
  .coordinate-editor {
    width: var(--stage-size);
    height: var(--stage-size);
    min-width: 0;
    min-height: 0;
  }

  .coordinate-main {
    display: block;
  }

  /*
   * 不再使用"坐标系 + 72px 工具栏"的内部 Grid，
   * 否则坐标系会被工具栏挤窄。
   */
  .coordinate-editor {
    position: relative;
    display: block;
  }

  /* 坐标系严格使用共同尺寸，永远保持正方形 */
  .coordinate-frame {
    width: var(--stage-size);
    height: var(--stage-size);
    max-width: none;
    aspect-ratio: 1 / 1;
    margin: 0;
    align-self: auto;
  }

  /*
   * 工具栏放进坐标系和 Logo 栏之间的等距区域。
   * 距离坐标系右边缘固定为 8px。
   */
  .coordinate-side-tools {
    position: absolute;
    left: calc(100% + 8px);
    right: auto;
    top: auto;
    bottom: 0;

    width: var(--tool-lane-width);
    min-width: 0;

    display: flex;
    flex-direction: column;
    align-items: flex-start;
    justify-content: flex-end;
    gap: 8px;
  }

  /* 工具栏和导航框左边缘对齐 */
  .coordinate-toolbar {
    align-self: flex-start;
    margin: 0;
  }

  .viewport-minimap {
    width: var(--tool-lane-width);
    height: var(--tool-lane-width);
    flex: 0 0 var(--tool-lane-width);
  }
}
