:root {
  --bg: #17131a;
  --bg-deep: #100d13;
  --panel: #211c25;
  --panel-raised: #28212d;
  --panel-soft: #2d2632;
  --panel-border: rgba(255, 255, 255, 0.085);
  --panel-border-strong: rgba(255, 255, 255, 0.14);
  --ink: #f4edf2;
  --ink-soft: #d3cbd4;
  --ink-muted: #918792;
  --ink-faint: #665d68;
  --accent: #d65d48;
  --accent-soft: #f3a08a;
  --accent-deep: #8f392f;
  --violet: #9e8bd4;
  --success: #98c69e;
  --shadow: 0 28px 70px rgba(0, 0, 0, 0.32);
  --radius-lg: 18px;
  --radius-md: 12px;
  --sans: 'Manrope', 'Noto Sans SC', 'Microsoft YaHei', sans-serif;
  --mono: 'DM Mono', 'SFMono-Regular', Consolas, monospace;
}

* { box-sizing: border-box; }

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

body {
  margin: 0;
  color: var(--ink);
  background:
    radial-gradient(circle at 48% -20%, rgba(173, 126, 174, 0.14), transparent 36rem),
    radial-gradient(circle at 100% 90%, rgba(214, 93, 72, 0.07), transparent 30rem),
    var(--bg-deep);
  font-family: var(--sans);
  font-size: 13px;
  letter-spacing: 0.005em;
}

button, input, textarea, select { font: inherit; }
button { color: inherit; }
button, select { cursor: pointer; }
button:focus-visible, input:focus-visible, textarea:focus-visible, select:focus-visible {
  outline: 2px solid var(--accent-soft);
  outline-offset: 2px;
}

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

.topbar {
  height: 76px;
  max-width: 1760px;
  margin: 0 auto;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 24px;
}

.brand-lockup, .top-actions, .canvas-actions, .footer-meta, .section-title-row, .library-filter-row,
.field-grid, .color-row, .range-row, .card-topline, .card-type-row, .card-footer-line {
  display: flex;
  align-items: center;
}

.brand-lockup { gap: 12px; min-width: 0; }
.brand-mark {
  width: 35px;
  height: 35px;
  display: grid;
  place-items: center;
  color: var(--accent-soft);
  border: 1px solid rgba(243, 160, 138, 0.34);
  background: linear-gradient(145deg, rgba(214, 93, 72, 0.18), rgba(158, 139, 212, 0.06));
  border-radius: 10px;
}
.brand-mark svg { width: 21px; height: 21px; }
.brand-mark path, .icon path, .icon circle, .search-icon circle, .search-icon path, .select-chevron path {
  vector-effect: non-scaling-stroke;
  stroke: currentColor;
  stroke-width: 1.7;
  stroke-linecap: round;
  stroke-linejoin: round;
}
.eyebrow, .section-kicker {
  color: var(--ink-muted);
  font-family: var(--mono);
  font-size: 9px;
  font-weight: 500;
  letter-spacing: 0.18em;
  text-transform: uppercase;
}
.brand-title { margin-top: 2px; font-size: 15px; font-weight: 800; letter-spacing: 0.11em; }
.connection-pill {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  margin-left: 9px;
  padding: 6px 10px;
  color: #b4a9b6;
  border: 1px solid var(--panel-border);
  border-radius: 999px;
  font-size: 11px;
  white-space: nowrap;
}
.status-dot, .live-dot, .meta-dot {
  display: inline-block;
  width: 6px;
  height: 6px;
  background: var(--success);
  border-radius: 50%;
  box-shadow: 0 0 0 3px rgba(152, 198, 158, 0.1);
}
.top-actions { gap: 7px; }
.button {
  min-height: 36px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 0 13px;
  border: 1px solid transparent;
  border-radius: 9px;
  background: transparent;
  font-size: 12px;
  font-weight: 700;
  transition: background-color 180ms ease, border-color 180ms ease, color 180ms ease, box-shadow 180ms ease;
}
.button:hover { border-color: var(--panel-border-strong); background: rgba(255,255,255,0.06); }
.button-quiet { color: var(--ink-soft); }
.button-primary {
  color: #fff8f5;
  border-color: rgba(243, 160, 138, 0.44);
  background: linear-gradient(135deg, #c95340, #a94337);
  box-shadow: 0 8px 22px rgba(144, 53, 43, 0.24);
}
.button-primary:hover { border-color: rgba(255, 220, 208, 0.7); background: linear-gradient(135deg, #dd674f, #b64b3c); box-shadow: 0 9px 26px rgba(144, 53, 43, 0.36); }
.icon { width: 16px; height: 16px; fill: none; flex: 0 0 auto; }
.shortcut { margin-left: 4px; padding: 3px 5px; color: rgba(255, 247, 242, 0.67); border: 1px solid rgba(255,255,255,0.22); border-radius: 4px; font-family: var(--mono); font-size: 9px; font-weight: 500; }

.workspace {
  max-width: 1760px;
  height: calc(100vh - 100px);
  min-height: calc(100vh - 100px);
  margin: 0 auto;
  display: grid;
  grid-template-columns: 274px minmax(500px, 1fr) 330px;
  gap: 12px;
}
.panel { min-width: 0; border: 1px solid var(--panel-border); background: rgba(33, 28, 37, 0.91); box-shadow: var(--shadow); }
.library-panel, .inspector-panel { display: flex; flex-direction: column; min-height: 0; }
.library-panel { border-radius: var(--radius-lg) 0 0 var(--radius-lg); padding: 24px 16px 16px; }
.canvas-panel { position: relative; display: flex; flex-direction: column; overflow: hidden; border-radius: 0; background: #1c1820; }
.inspector-panel { border-radius: 0 var(--radius-lg) var(--radius-lg) 0; padding: 24px 16px 0; }
.panel-heading, .canvas-heading { display: flex; align-items: flex-start; justify-content: space-between; gap: 12px; }
.panel-heading h1, .canvas-heading h2, .inspector-heading h2 { margin: 5px 0 0; font-size: 17px; letter-spacing: -0.02em; }
.library-total { color: var(--accent-soft); font-family: var(--mono); font-size: 11px; padding-top: 11px; }
.search-field {
  height: 38px;
  margin-top: 22px;
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 0 10px;
  color: var(--ink-muted);
  border: 1px solid var(--panel-border);
  border-radius: 9px;
  background: rgba(14, 11, 16, 0.4);
  transition: border-color 180ms ease, background-color 180ms ease;
}
.search-field:focus-within { border-color: rgba(243, 160, 138, 0.55); background: rgba(14, 11, 16, 0.62); }
.search-icon { width: 15px; height: 15px; fill: none; flex: 0 0 auto; }
.search-field input { width: 100%; min-width: 0; color: var(--ink); border: 0; outline: 0; background: transparent; font-size: 11px; }
.search-field input::placeholder { color: var(--ink-faint); }
.search-key { color: var(--ink-faint); font-family: var(--mono); font-size: 9px; white-space: nowrap; }
.segmented-control { display: grid; grid-template-columns: 1fr 1fr; gap: 3px; margin-top: 13px; padding: 3px; border: 1px solid var(--panel-border); border-radius: 9px; background: rgba(13, 10, 15, 0.3); }
.segment { padding: 7px 4px; color: var(--ink-muted); border: 0; border-radius: 6px; background: transparent; font-size: 11px; transition: color 180ms ease, background-color 180ms ease; }
.segment:hover { color: var(--ink); }
.segment.is-active { color: var(--ink); background: var(--panel-soft); box-shadow: 0 2px 6px rgba(0,0,0,0.16); }
.library-filter-row { justify-content: space-between; gap: 8px; margin: 18px 1px 9px; }
.select-wrap { position: relative; display: block; }
.select-wrap select {
  width: 100%;
  height: 31px;
  appearance: none;
  padding: 0 25px 0 9px;
  color: var(--ink-soft);
  border: 1px solid var(--panel-border);
  border-radius: 7px;
  outline: 0;
  background: rgba(14, 11, 16, 0.35);
  font-size: 11px;
}
.select-wrap select:hover { border-color: var(--panel-border-strong); }
.select-chevron { position: absolute; top: 8px; right: 8px; width: 13px; height: 13px; color: var(--ink-muted); fill: none; pointer-events: none; }
.compact-select { width: 137px; }
.results-count { color: var(--ink-faint); font-family: var(--mono); font-size: 9px; white-space: nowrap; }
.card-list { min-height: 0; flex: 1 1 auto; overflow-y: auto; padding-right: 2px; scrollbar-color: #443947 transparent; scrollbar-width: thin; }
.card-list::-webkit-scrollbar, .inspector-scroll::-webkit-scrollbar { width: 5px; }
.card-list::-webkit-scrollbar-thumb, .inspector-scroll::-webkit-scrollbar-thumb { background: #443947; border-radius: 999px; }
.library-card {
  width: 100%;
  position: relative;
  display: grid;
  grid-template-columns: 29px minmax(0, 1fr) auto;
  align-items: center;
  gap: 9px;
  padding: 10px 8px;
  color: var(--ink-soft);
  border: 1px solid transparent;
  border-radius: 9px;
  background: transparent;
  text-align: left;
  transition: color 180ms ease, background-color 180ms ease, border-color 180ms ease;
}
.library-card:hover { color: var(--ink); border-color: var(--panel-border); background: rgba(255,255,255,0.035); }
.library-card.is-selected { color: var(--ink); border-color: rgba(214, 93, 72, 0.34); background: linear-gradient(90deg, rgba(214, 93, 72, 0.14), rgba(214, 93, 72, 0.035)); }
.library-card.is-selected::before { content: ''; position: absolute; left: -1px; top: 10px; bottom: 10px; width: 2px; border-radius: 2px; background: var(--accent-soft); }
.library-card-mark { width: 28px; height: 28px; display: grid; place-items: center; color: #f8ded6; border: 1px solid rgba(255,255,255,0.12); border-radius: 7px; background: linear-gradient(145deg, rgba(214,93,72,0.55), rgba(108,52,60,0.36)); font-family: var(--mono); font-size: 10px; }
.library-card.is-reaction .library-card-mark { color: #ece6ff; background: linear-gradient(145deg, rgba(129,111,181,0.56), rgba(77,64,109,0.48)); }
.library-card.is-throughout .library-card-mark { color: #5d5b3c; background: linear-gradient(145deg, #ead8a4, #ab985d); }
.library-card-copy { min-width: 0; }
.library-card-title { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-size: 11px; font-weight: 700; }
.library-card-meta { margin-top: 4px; overflow: hidden; color: var(--ink-faint); font-family: var(--mono); font-size: 9px; text-overflow: ellipsis; white-space: nowrap; }
.library-card-arrow { color: var(--ink-faint); opacity: 0; transition: opacity 180ms ease, color 180ms ease; }
.library-card:hover .library-card-arrow, .library-card.is-selected .library-card-arrow { color: var(--accent-soft); opacity: 1; }
.library-card-arrow svg { width: 14px; height: 14px; fill: none; }
.library-empty { padding: 26px 11px; color: var(--ink-muted); text-align: center; font-size: 11px; line-height: 1.7; }
.new-card-button { width: 100%; margin-top: 12px; display: grid; grid-template-columns: 28px 1fr 16px; align-items: center; gap: 10px; padding: 11px 9px; color: var(--ink-soft); border: 1px dashed rgba(243,160,138,0.34); border-radius: 9px; background: rgba(214,93,72,0.055); text-align: left; transition: background-color 180ms ease, border-color 180ms ease; }
.new-card-button:hover { border-color: rgba(243,160,138,0.68); background: rgba(214,93,72,0.11); }
.new-card-icon { width: 27px; height: 27px; display: grid; place-items: center; color: var(--accent-soft); border: 1px solid rgba(243,160,138,0.35); border-radius: 7px; font-size: 18px; line-height: 1; }
.new-card-button strong, .new-card-button small { display: block; }
.new-card-button strong { font-size: 11px; }
.new-card-button small { margin-top: 3px; color: var(--ink-faint); font-size: 9px; }
.arrow-icon { color: var(--ink-muted); }

.canvas-heading { height: 74px; align-items: center; padding: 0 25px; border-bottom: 1px solid rgba(255,255,255,0.06); }
.canvas-heading h2 { font-size: 15px; }
.live-dot { width: 5px; height: 5px; margin-left: 5px; vertical-align: middle; background: var(--accent-soft); box-shadow: 0 0 0 3px rgba(243,160,138,0.1); }
.canvas-actions { gap: 8px; }
.icon-button { width: 30px; height: 30px; display: grid; place-items: center; padding: 0; color: var(--ink-muted); border: 1px solid transparent; border-radius: 7px; background: transparent; transition: color 180ms ease, background-color 180ms ease, border-color 180ms ease; }
.icon-button:hover { color: var(--ink); border-color: var(--panel-border); background: rgba(255,255,255,0.06); }
.small-icon-button { width: 28px; height: 28px; }
.zoom-label { min-width: 38px; color: var(--ink-soft); font-family: var(--mono); font-size: 10px; text-align: center; }
.action-divider { height: 18px; width: 1px; margin: 0 3px; background: var(--panel-border); }
.canvas-stage { position: relative; min-height: 0; flex: 1 1 auto; display: grid; place-items: center; overflow: hidden; background: #19161d; }
.stage-radial { position: absolute; inset: 0; background: radial-gradient(ellipse at center, rgba(126,99,129,0.13), transparent 48%), radial-gradient(ellipse at 20% 80%, rgba(214,93,72,0.055), transparent 28%); pointer-events: none; }
.stage-grid { position: absolute; inset: 0; opacity: 0.5; background-image: linear-gradient(rgba(255,255,255,0.026) 1px, transparent 1px), linear-gradient(90deg, rgba(255,255,255,0.026) 1px, transparent 1px); background-size: 32px 32px; mask-image: linear-gradient(to bottom, transparent 0%, #000 18%, #000 82%, transparent 100%); pointer-events: none; }
.card-preview-wrap { position: relative; z-index: 2; width: 366px; aspect-ratio: 733 / 1024; transform-origin: center; transition: transform 220ms ease; filter: drop-shadow(0 30px 32px rgba(0,0,0,0.36)); }
.card-preview { position: relative; width: 100%; height: 100%; overflow: hidden; color: #2e2730; border-radius: 17px; background: #e9e2e6; font-family: 'Noto Sans SC', 'Microsoft YaHei', sans-serif; isolation: isolate; }
.card-canvas { position: absolute; inset: 0; z-index: 20; display: block; width: 100%; height: 100%; pointer-events: none; }
.card-frame { position: absolute; inset: 0; z-index: -4; width: 100%; height: 100%; object-fit: cover; }
.card-color-wash { position: absolute; inset: 0; z-index: -3; opacity: 0.2; mix-blend-mode: multiply; background: var(--card-accent, #d65d48); }
.card-art-fade { position: absolute; z-index: -2; inset: 34% 0 14%; background: linear-gradient(180deg, rgba(244,239,239,0) 4%, rgba(249,246,243,0.1) 33%, rgba(255,250,245,0.96) 82%, rgba(250,246,241,0.98) 100%); }
.card-sheen { position: absolute; z-index: 6; inset: 0; opacity: 0.28; pointer-events: none; background: linear-gradient(116deg, rgba(255,255,255,0.42), transparent 22%, transparent 75%, rgba(255,255,255,0.2)); mix-blend-mode: screen; }
.card-topline { position: absolute; z-index: 3; top: 5.7%; left: 10%; right: 20%; justify-content: flex-start; gap: 11px; color: rgba(54,42,51,0.68); font-family: var(--mono); font-size: 8px; letter-spacing: 0.12em; }
.card-range-readout { display: inline-flex; align-items: center; gap: 6px; color: #281f2a; font-size: 13px; font-weight: 700; letter-spacing: 0.01em; }
.range-ornament { width: 14px; height: 7px; display: inline-block; transform: skew(-22deg) rotate(-8deg); opacity: 0.82; background: #28232b; clip-path: polygon(0 45%, 18% 15%, 29% 54%, 51% 4%, 61% 57%, 84% 18%, 100% 58%, 80% 85%, 55% 72%, 35% 100%, 15% 73%); }
.card-series { color: rgba(60,50,61,0.48); font-size: 7px; letter-spacing: 0.09em; }
.card-cost-badge { position: absolute; z-index: 5; top: 3.1%; right: 6.5%; width: 43px; height: 43px; display: flex; flex-direction: column; align-items: center; justify-content: center; color: #2d2630; border: 2px solid rgba(42,35,46,0.72); border-radius: 50%; background: rgba(247,244,237,0.74); box-shadow: 0 3px 8px rgba(46,36,39,0.16); }
.card-cost-badge::after { content: ''; position: absolute; inset: -5px; border: 1px solid rgba(42,35,46,0.22); border-radius: 50%; }
.card-cost-badge span { color: rgba(57,45,56,0.62); font-family: var(--mono); font-size: 6px; letter-spacing: 0.12em; }
.card-cost-badge strong { margin-top: 1px; font-size: 17px; line-height: 1; }
.card-mark { min-width: 24px; height: 24px; display: grid; place-items: center; color: #fff9f4; border-radius: 6px; background: var(--card-accent, #d65d48); box-shadow: 0 4px 8px rgba(53,34,33,0.14); font-size: 11px; font-weight: 700; letter-spacing: 0; }
.card-seal { position: absolute; z-index: 5; bottom: 29%; left: 4.5%; width: 45px; height: 33px; transform: rotate(-7deg); border: 1px solid rgba(110,55,42,0.42); border-radius: 4px; background: linear-gradient(145deg, #f3e7d5, #dcbf9f); color: #8f392f; box-shadow: 0 4px 8px rgba(46,36,39,0.16); }
.card-title { position: absolute; z-index: 3; top: 20%; left: 4.5%; width: 10%; height: 43%; overflow: hidden; color: #281f2a; font-size: clamp(17px, 1.8vw, 24px); font-weight: 800; letter-spacing: 0.09em; line-height: 1.18; text-align: center; text-overflow: ellipsis; writing-mode: vertical-rl; text-orientation: mixed; white-space: normal; }
.card-subtitle { position: absolute; z-index: 3; top: 22%; left: 14.2%; width: 4%; height: 29%; overflow: hidden; color: rgba(60,50,61,0.62); font-family: var(--mono); font-size: 6px; letter-spacing: 0.04em; line-height: 1.45; text-overflow: ellipsis; writing-mode: vertical-rl; text-orientation: mixed; white-space: normal; }
.card-art-wrap { position: absolute; z-index: 1; top: 17%; right: 2%; bottom: 25%; left: 17%; overflow: hidden; }
.card-art { position: absolute; right: -3%; bottom: -15%; width: 88%; height: 120%; object-fit: contain; object-position: right bottom; filter: saturate(0.92) contrast(1.04); opacity: 0.72; transition: opacity 220ms ease, filter 220ms ease; }
.card-art-placeholder { position: absolute; inset: 24% 23% auto auto; display: none; flex-direction: column; align-items: center; gap: 5px; color: rgba(59,47,57,0.55); font-family: var(--mono); font-size: 8px; text-align: center; }
.card-art-placeholder img { width: 72px; height: 82px; object-fit: contain; opacity: 0.72; filter: grayscale(0.2); }
.card-text-panel { position: absolute; z-index: 4; right: 8%; bottom: 14.3%; left: 16%; min-height: 21%; padding-top: 8px; border-top: 1px solid rgba(65,47,60,0.2); }
.card-type-row { justify-content: space-between; margin-bottom: 8px; color: rgba(57,45,56,0.65); font-family: var(--mono); font-size: 7px; letter-spacing: 0.08em; text-transform: uppercase; }
.card-type-label { color: var(--card-accent, #a94337); font-weight: 700; }
.card-rule-text { max-height: 73px; overflow: hidden; color: #342b36; font-size: clamp(10px, 1.1vw, 13px); font-weight: 600; line-height: 1.65; white-space: pre-line; }
.card-stats { position: absolute; z-index: 4; right: 8%; bottom: 7.3%; left: 16%; display: grid; grid-template-columns: 1fr 1.3fr 1fr; min-height: 35px; border-top: 1px solid rgba(65,47,60,0.18); border-bottom: 1px solid rgba(65,47,60,0.18); }
.stat-cell { display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 2px; color: rgba(57,45,56,0.68); border-right: 1px solid rgba(65,47,60,0.14); }
.stat-cell:last-child { border-right: 0; }
.stat-cell-highlight { color: var(--card-accent, #a94337); }
.stat-label { font-family: var(--mono); font-size: 6px; letter-spacing: 0.12em; text-transform: uppercase; }
.stat-cell strong { font-size: 12px; line-height: 1; }
.card-footer-line { position: absolute; z-index: 4; right: 8%; bottom: 3.2%; left: 16%; justify-content: space-between; color: rgba(57,45,56,0.48); font-family: var(--mono); font-size: 6px; letter-spacing: 0.08em; }
.footer-gem { width: 6px; height: 6px; transform: rotate(45deg); background: var(--card-accent, #d65d48); }
.preview-ruler { position: absolute; z-index: 1; color: rgba(255,255,255,0.2); font-family: var(--mono); font-size: 8px; pointer-events: none; }
.ruler-top { top: 13px; left: 50%; width: 366px; display: flex; justify-content: space-between; transform: translateX(-50%); }
.ruler-left { top: 50%; left: calc(50% - 207px); height: 510px; display: flex; flex-direction: column; justify-content: space-between; transform: translate(-100%, -50%); writing-mode: vertical-rl; }
.stage-note { position: absolute; z-index: 2; bottom: 26px; display: flex; align-items: center; gap: 9px; color: rgba(255,255,255,0.32); font-family: var(--mono); font-size: 8px; letter-spacing: 0.04em; }
.stage-note-left { left: 23px; }
.stage-note-right { right: 23px; }
.note-line { display: inline-block; width: 22px; height: 1px; background: rgba(255,255,255,0.2); }
.canvas-footer { min-height: 45px; display: flex; align-items: center; justify-content: space-between; gap: 16px; padding: 0 25px; color: var(--ink-faint); border-top: 1px solid rgba(255,255,255,0.06); font-family: var(--mono); font-size: 9px; }
.footer-meta { gap: 8px; }
.footer-meta strong { color: var(--ink-muted); font-weight: 500; }
.meta-dot { width: 5px; height: 5px; background: var(--success); box-shadow: none; }
.meta-separator { display: inline-block; width: 1px; height: 12px; margin: 0 4px; background: var(--panel-border); }

.inspector-heading { padding-bottom: 20px; border-bottom: 1px solid var(--panel-border); }
.inspector-scroll { min-height: 0; flex: 1 1 auto; overflow-y: auto; padding-right: 2px; scrollbar-color: #443947 transparent; scrollbar-width: thin; }
.inspector-section { padding: 20px 1px 18px; border-bottom: 1px solid var(--panel-border); }
.inspector-section-last { border-bottom: 0; }
.section-title-row { justify-content: space-between; margin-bottom: 16px; color: var(--ink-soft); font-size: 11px; font-weight: 700; }
.section-help { color: var(--ink-faint); font-family: var(--mono); font-size: 8px; font-weight: 400; }
.section-index { display: inline-grid; place-items: center; width: 20px; height: 20px; margin-right: 8px; color: var(--accent-soft); border: 1px solid rgba(243,160,138,0.28); border-radius: 5px; font-family: var(--mono); font-size: 8px; font-weight: 500; }
.field-label { display: block; margin-bottom: 8px; color: var(--ink-muted); font-family: var(--mono); font-size: 9px; letter-spacing: 0.02em; }
.text-input, .text-area { width: 100%; color: var(--ink); border: 1px solid var(--panel-border); border-radius: 7px; outline: 0; background: rgba(14, 11, 16, 0.4); transition: border-color 180ms ease, background-color 180ms ease, box-shadow 180ms ease; }
.text-input { height: 35px; padding: 0 10px; font-size: 11px; font-weight: 600; }
.text-area { min-height: 118px; resize: vertical; padding: 10px; font-size: 11px; font-weight: 500; line-height: 1.65; }
.text-input:hover, .text-area:hover { border-color: var(--panel-border-strong); }
.text-input:focus, .text-area:focus { border-color: rgba(243,160,138,0.62); background: rgba(14, 11, 16, 0.58); box-shadow: 0 0 0 3px rgba(214,93,72,0.08); }
.text-input::placeholder, .text-area::placeholder { color: var(--ink-faint); font-weight: 400; }
.field-grid { gap: 9px; align-items: flex-start; }
.field-grid + .field-grid { margin-top: 11px; }
.two-col > * { width: calc(50% - 4.5px); }
.three-col { gap: 7px; }
.three-col > * { width: calc(33.333% - 4.7px); }
.field-with-control { margin: 0; }
.field-with-control > .text-input, .field-with-control > .select-wrap { margin-top: 7px; }
.field-with-control > .select-wrap select { height: 35px; padding-left: 8px; font-size: 10px; }
.color-row { align-items: flex-end; gap: 10px; margin-top: 16px; }
.color-row > .field-with-control { flex: 1; }
.color-input-wrap { height: 35px; margin-top: 7px; display: flex; align-items: center; gap: 7px; padding: 0 7px; border: 1px solid var(--panel-border); border-radius: 7px; background: rgba(14, 11, 16, 0.4); }
.color-input-wrap input { width: 21px; height: 21px; padding: 0; overflow: hidden; border: 0; border-radius: 4px; background: transparent; cursor: pointer; }
.color-input-wrap input::-webkit-color-swatch-wrapper { padding: 0; }
.color-input-wrap input::-webkit-color-swatch { border: 0; border-radius: 3px; }
.color-input-wrap span { color: var(--ink-soft); font-family: var(--mono); font-size: 8px; }
.toggle-row { position: relative; min-height: 35px; display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-top: 15px; cursor: pointer; }
.toggle-row strong, .toggle-row small { display: block; }
.toggle-row strong { color: var(--ink-soft); font-size: 10px; font-weight: 600; }
.toggle-row small { margin-top: 3px; color: var(--ink-faint); font-size: 9px; }
.toggle-row input { position: absolute; width: 1px; height: 1px; opacity: 0; }
.toggle-track { position: relative; flex: 0 0 auto; width: 31px; height: 18px; padding: 2px; border: 1px solid var(--panel-border-strong); border-radius: 999px; background: #312a35; transition: background-color 180ms ease, border-color 180ms ease; }
.toggle-track span { display: block; width: 12px; height: 12px; border-radius: 50%; background: #9a909b; transition: transform 180ms ease, background-color 180ms ease; }
.toggle-row input:checked + .toggle-track { border-color: rgba(214,93,72,0.54); background: rgba(214,93,72,0.38); }
.toggle-row input:checked + .toggle-track span { transform: translateX(12px); background: #ffe3d8; }
.compact-toggle { min-width: 88px; margin: 0 0 8px; }
.compact-toggle .toggle-track { margin-bottom: 1px; }
.textarea-footer { display: flex; justify-content: space-between; margin-top: 7px; color: var(--ink-faint); font-family: var(--mono); font-size: 8px; }
.style-picker { display: grid; grid-template-columns: repeat(3, 1fr); gap: 6px; }
.style-option { min-width: 0; display: grid; grid-template-columns: 21px minmax(0, 1fr); grid-template-rows: auto auto; align-items: center; gap: 2px 6px; padding: 7px; color: var(--ink-muted); border: 1px solid var(--panel-border); border-radius: 7px; background: rgba(14, 11, 16, 0.25); text-align: left; transition: color 180ms ease, border-color 180ms ease, background-color 180ms ease; }
.style-option:hover { color: var(--ink-soft); border-color: var(--panel-border-strong); }
.style-option.is-active { color: var(--ink); border-color: rgba(243,160,138,0.5); background: rgba(214,93,72,0.1); }
.style-option > span:not(.style-swatch) { overflow: hidden; font-family: var(--mono); font-size: 8px; text-overflow: ellipsis; white-space: nowrap; }
.style-option small { grid-column: 2; color: var(--ink-faint); font-family: var(--mono); font-size: 8px; }
.style-swatch { width: 21px; height: 27px; display: block; grid-row: 1 / 3; border: 1px solid rgba(255,255,255,0.28); border-radius: 4px; background-position: center; background-size: cover; }
.swatch-normal { background-image: url('assets/game/frame-normal.png'); }
.swatch-reaction { background-image: url('assets/game/frame-reaction.png'); }
.swatch-throughout { background-image: url('assets/game/frame-throughout.png'); }
.range-row { position: relative; flex-wrap: wrap; justify-content: space-between; gap: 7px; margin-top: 17px; color: var(--ink-muted); font-family: var(--mono); font-size: 9px; }
.range-row output { color: var(--accent-soft); }
.range-row input { width: 100%; appearance: none; height: 3px; border-radius: 99px; outline: 0; background: linear-gradient(90deg, var(--accent) 0%, var(--accent) 72%, #453945 72%, #453945 100%); }
.range-row input::-webkit-slider-thumb { appearance: none; width: 13px; height: 13px; border: 2px solid #f7ded8; border-radius: 50%; background: var(--accent); box-shadow: 0 2px 6px rgba(0,0,0,0.28); cursor: pointer; }
.range-row input::-moz-range-thumb { width: 10px; height: 10px; border: 2px solid #f7ded8; border-radius: 50%; background: var(--accent); box-shadow: 0 2px 6px rgba(0,0,0,0.28); cursor: pointer; }
.art-upload-row { display: flex; align-items: center; justify-content: space-between; gap: 9px; margin-top: 17px; padding-top: 14px; border-top: 1px solid var(--panel-border); }
.upload-label { margin: 0; color: var(--ink-soft); font-size: 10px; font-weight: 600; }
.art-upload-row small { display: block; margin-top: 4px; color: var(--ink-faint); font-size: 9px; }
.art-upload-actions { display: flex; align-items: center; gap: 5px; }
.upload-button, .example-art-button, .clear-art-button { height: 29px; display: inline-flex; align-items: center; justify-content: center; gap: 5px; padding: 0 8px; border: 1px solid var(--panel-border-strong); border-radius: 6px; background: rgba(255,255,255,0.045); font-size: 9px; font-weight: 700; transition: color 180ms ease, border-color 180ms ease, background-color 180ms ease; }
.upload-button { color: var(--accent-soft); }
.upload-button:hover { border-color: rgba(243,160,138,0.58); background: rgba(214,93,72,0.12); }
.upload-button .icon { width: 13px; height: 13px; }
.example-art-button { color: #d4bd83; }
.example-art-button:hover { border-color: rgba(212,189,131,0.6); background: rgba(182,155,84,0.12); }
.clear-art-button { color: var(--ink-muted); }
.clear-art-button:hover:not(:disabled) { color: var(--ink); border-color: var(--panel-border-strong); background: rgba(255,255,255,0.08); }
.clear-art-button:disabled { cursor: not-allowed; opacity: 0.4; }
.sr-only { position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip: rect(0,0,0,0); white-space: nowrap; border: 0; }
.toast { position: fixed; z-index: 20; right: 25px; bottom: 24px; max-width: 300px; padding: 11px 14px; color: var(--ink); border: 1px solid rgba(243,160,138,0.35); border-radius: 9px; background: #2a202c; box-shadow: 0 16px 32px rgba(0,0,0,0.28); font-size: 11px; opacity: 0; pointer-events: none; transform: translateY(8px); transition: opacity 180ms ease, transform 180ms ease; }
.toast.is-visible { opacity: 1; transform: translateY(0); }

@media (max-width: 1320px) {
  .app-shell { padding-right: 14px; padding-left: 14px; }
  .workspace { grid-template-columns: 242px minmax(440px, 1fr) 305px; }
  .connection-pill { display: none; }
  .canvas-heading, .canvas-footer { padding-right: 18px; padding-left: 18px; }
  .ruler-left { display: none; }
  .stage-note-right { display: none; }
}

@media (max-width: 1060px) {
  .workspace { height: auto; }
  .workspace { grid-template-columns: 224px minmax(420px, 1fr); }
  .inspector-panel { grid-column: 1 / -1; min-height: 420px; border-radius: 0 0 var(--radius-lg) var(--radius-lg); padding-bottom: 14px; }
  .inspector-scroll { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); column-gap: 22px; }
  .inspector-section-last { grid-column: 1 / -1; }
  .library-panel { border-radius: var(--radius-lg) 0 0 0; }
  .canvas-panel { border-radius: 0 var(--radius-lg) 0 0; }
  .topbar { height: 68px; }
}

@media (max-width: 760px) {
  .app-shell { padding: 0 8px 8px; }
  .topbar { height: auto; min-height: 68px; align-items: flex-start; flex-direction: column; gap: 10px; padding: 13px 8px; }
  .top-actions { width: 100%; justify-content: flex-end; }
  .button-quiet { display: none; }
  .workspace { display: flex; flex-direction: column; gap: 8px; }
  .library-panel, .canvas-panel, .inspector-panel { border-radius: var(--radius-lg); }
  .library-panel { min-height: 400px; max-height: 52vh; }
  .canvas-panel { min-height: 640px; }
  .inspector-panel { min-height: 0; }
  .inspector-scroll { display: block; }
  .canvas-heading { height: 64px; padding: 0 15px; }
  .canvas-footer { flex-direction: column; align-items: flex-start; padding: 11px 15px; }
  .card-preview-wrap { width: min(74vw, 350px); }
  .preview-ruler, .stage-note { display: none; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { scroll-behavior: auto !important; transition-duration: 0.01ms !important; animation-duration: 0.01ms !important; }
}
/* Native layer editor additions; preserve the existing workspace's visual design. */
.render-feedback { padding: 9px 18px; color: #c3c4b9; background: #211c25; font-size: 12px; line-height: 1.6; border-top: 1px solid var(--panel-border); }
.render-feedback.has-warning { color: #ffcf8b; background: #342823; }
.editor-help { font-size: 11px; line-height: 1.65; color: var(--ink-muted); margin: 10px 0; }
.simple-check { display: flex; align-items: center; gap: 8px; font-size: 11px; color: var(--ink-soft); margin-top: 13px; cursor: pointer; }
.simple-check input { accent-color: var(--accent); }
.rule-tools { display: flex; gap: 5px; flex-wrap: wrap; margin-top: 9px; }
.rule-tools button { border: 1px solid var(--panel-border-strong); border-radius: 5px; padding: 5px 8px; color: var(--ink-soft); background: var(--panel-raised); font-size: 11px; }
.art-transform-controls { border-top: 1px solid var(--panel-border); margin-top: 16px; }
.art-transform-controls > button { margin-top: 14px; }
#exportScaleSelect { background: var(--panel); color: var(--ink); border: 1px solid var(--panel-border-strong); border-radius: 6px; padding: 9px 5px; font-size: 11px; }
#cardCanvas.drag-art-enabled { cursor: grab; touch-action: none; }
#cardCanvas.drag-art-enabled:active { cursor: grabbing; }
.art-upload-row { flex-wrap: wrap; }
.top-actions { flex-wrap: wrap; }
button:focus-visible, input:focus-visible, select:focus-visible, textarea:focus-visible { outline: 2px solid #f3a08a; outline-offset: 2px; }
@media (max-width: 760px) {
  .button-quiet { display: inline-flex; }
  .top-actions { justify-content: flex-start; gap: 6px; }
  .button { padding: 7px 10px; }
  .render-feedback { font-size: 11px; }
}
.legacy-preview-dom { display: none; }
.card-canvas.drag-art-enabled { pointer-events: auto; }
.canvas-heading, .canvas-footer, .render-feedback { flex-shrink: 0; }
@media (min-width: 761px) and (max-width: 1060px) { .canvas-panel { height: 690px; } }
.move-insert { margin: 12px 0; color: var(--ink-soft); font-size: 12px; }
.move-insert summary { cursor: pointer; padding: 8px 0; }
.move-selects { display: grid; grid-template-columns: 1fr 52px 1fr 60px; gap: 4px; margin: 6px 0 10px; }
.move-selects .text-input { padding: 5px; font-size: 11px; min-width: 0; }
