/* CardSheet Studio - web UI */

:root, :root[data-theme="dark"] {
  --bg: #0c0f14;
  --surface: #141921;
  --surface-2: #1a212b;
  --surface-3: #232c39;
  --line: #252e3b;
  --line-2: #364356;
  --text: #e7ebf1;
  --muted: #9aa5b5;
  --dim: #6c7889;
  --accent: #5b8cff;
  --accent-2: #8a6bff;
  --accent-ink: #ffffff;
  --accent-soft: rgba(91, 140, 255, .14);
  --ok: #2fc58e;
  --ok-soft: rgba(47, 197, 142, .14);
  --warn: #f0b445;
  --warn-soft: rgba(240, 180, 69, .14);
  --bad: #f0616d;
  --bad-soft: rgba(240, 97, 109, .14);
  --canvas: #07090c;
  --shadow: 0 18px 50px rgba(0, 0, 0, .5);
  --shadow-sm: 0 2px 10px rgba(0, 0, 0, .3);
  --paper-shadow: 0 10px 40px rgba(0, 0, 0, .55);
  color-scheme: dark;
}
:root[data-theme="light"] {
  --bg: #f1f3f7;
  --surface: #ffffff;
  --surface-2: #f5f7fa;
  --surface-3: #e9edf3;
  --line: #e0e5ed;
  --line-2: #c5cedb;
  --text: #16202c;
  --muted: #566274;
  --dim: #8793a4;
  --accent: #2f6bea;
  --accent-2: #6a4cf0;
  --accent-ink: #ffffff;
  --accent-soft: rgba(47, 107, 234, .10);
  --ok: #128f62;
  --ok-soft: rgba(18, 143, 98, .11);
  --warn: #a96d00;
  --warn-soft: rgba(201, 135, 12, .14);
  --bad: #d23b49;
  --bad-soft: rgba(210, 59, 73, .10);
  --canvas: #dfe4ec;
  --shadow: 0 18px 50px rgba(22, 32, 44, .18);
  --shadow-sm: 0 2px 8px rgba(22, 32, 44, .08);
  --paper-shadow: 0 8px 30px rgba(22, 32, 44, .22);
  color-scheme: light;
}

* { box-sizing: border-box; }
html, body { height: 100%; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font: 13.5px/1.5 Inter, "Segoe UI Variable Text", "Segoe UI", system-ui, -apple-system, Roboto, "Helvetica Neue", Arial, sans-serif;
  -webkit-font-smoothing: antialiased;
  overflow: hidden;
}
h1, h2, h3, p { margin: 0; }
h1 { font-size: 22px; font-weight: 650; letter-spacing: -.01em; }
h2 { font-size: 15px; font-weight: 650; }
h3 { font-size: 11px; font-weight: 650; letter-spacing: .07em; text-transform: uppercase; color: var(--dim); }
a { color: var(--accent); text-decoration: none; }
button, input, select { font: inherit; color: inherit; }
::selection { background: var(--accent); color: #fff; }
.muted { color: var(--muted); }
.dim { color: var(--dim); }
.num { font-variant-numeric: tabular-nums; }
.grow { flex: 1 1 auto; min-width: 0; }
.row { display: flex; align-items: center; gap: 8px; }
.col { display: flex; flex-direction: column; gap: 8px; }
.hide { display: none !important; }
.ic { width: 16px; height: 16px; flex: none; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }
.ic.fill { fill: currentColor; }
.ic.lg { width: 20px; height: 20px; }
.ic.xl { width: 28px; height: 28px; stroke-width: 1.5; }

*::-webkit-scrollbar { width: 10px; height: 10px; }
*::-webkit-scrollbar-thumb { background: var(--line-2); border-radius: 10px; border: 2px solid transparent; background-clip: content-box; }
*::-webkit-scrollbar-track { background: transparent; }
* { scrollbar-width: thin; scrollbar-color: var(--line-2) transparent; }

/* ---------- boot / spinner ---------- */
.boot { height: 100vh; display: grid; place-items: center; }
.spinner { width: 26px; height: 26px; border-radius: 50%; border: 3px solid var(--line-2); border-top-color: var(--accent); animation: spin .8s linear infinite; }
.spinner.sm { width: 14px; height: 14px; border-width: 2px; }
@keyframes spin { to { transform: rotate(360deg); } }

/* ---------- buttons ---------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 7px;
  height: 34px; padding: 0 13px; border-radius: 9px; border: 1px solid var(--line-2);
  background: var(--surface-2); color: var(--text); font-weight: 550; cursor: pointer;
  white-space: nowrap; transition: background .12s, border-color .12s, transform .05s, box-shadow .12s;
  user-select: none;
}
.btn:hover { background: var(--surface-3); }
.btn:active { transform: translateY(1px); }
.btn:focus-visible, .input:focus-visible, .nav-item:focus-visible, .seg button:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
.btn[disabled] { opacity: .45; cursor: not-allowed; pointer-events: none; }
.btn.primary { border-color: transparent; color: var(--accent-ink); background: linear-gradient(135deg, var(--accent), var(--accent-2)); box-shadow: 0 6px 18px -6px var(--accent); }
.btn.primary:hover { filter: brightness(1.08); }
.btn.ghost { background: transparent; border-color: transparent; color: var(--muted); }
.btn.ghost:hover { background: var(--surface-3); color: var(--text); }
.btn.danger { color: var(--bad); }
.btn.danger:hover { background: var(--bad-soft); border-color: var(--bad); }
.btn.sm { height: 28px; padding: 0 9px; border-radius: 7px; font-size: 12.5px; }
.btn.lg { height: 44px; padding: 0 20px; border-radius: 11px; font-size: 14.5px; }
.btn.icon { width: 34px; padding: 0; }
.btn.icon.sm { width: 28px; }
.btn.on { background: var(--accent-soft); border-color: var(--accent); color: var(--accent); }
.btn.block { width: 100%; }

/* ---------- inputs ---------- */
.input, select.input {
  height: 34px; width: 100%; padding: 0 10px; border-radius: 8px; border: 1px solid var(--line-2);
  background: var(--surface-2); color: var(--text); outline: none; transition: border-color .12s, box-shadow .12s;
}
.input:hover { border-color: var(--dim); }
.input:focus { border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); }
select.input { appearance: none; padding-right: 28px; background-image: linear-gradient(45deg, transparent 50%, var(--muted) 50%), linear-gradient(135deg, var(--muted) 50%, transparent 50%); background-position: calc(100% - 15px) 14px, calc(100% - 10px) 14px; background-size: 5px 5px; background-repeat: no-repeat; }
select.input option { background: var(--surface); color: var(--text); }
input[type=number].input { font-variant-numeric: tabular-nums; }
.field { display: flex; flex-direction: column; gap: 5px; min-width: 0; }
.field > label, .label { font-size: 12px; color: var(--muted); font-weight: 500; }
.field .with-unit { position: relative; }
.field .with-unit .input { padding-right: 32px; }
.field .with-unit span { position: absolute; right: 10px; top: 50%; transform: translateY(-50%); font-size: 11.5px; color: var(--dim); pointer-events: none; }
.fields { display: grid; grid-template-columns: 1fr 1fr; gap: 10px 12px; }
.fields.three { grid-template-columns: 1fr 1fr 1fr; }
.fields .wide { grid-column: 1 / -1; }

.seg { display: inline-flex; padding: 3px; gap: 2px; border-radius: 9px; background: var(--surface-2); border: 1px solid var(--line); }
.seg button { height: 26px; padding: 0 11px; border: 0; border-radius: 6px; background: transparent; color: var(--muted); cursor: pointer; font-weight: 550; font-size: 12.5px; }
.seg button:hover { color: var(--text); }
.seg button.on { background: var(--surface); color: var(--text); box-shadow: var(--shadow-sm); }
:root[data-theme="dark"] .seg button.on { background: var(--surface-3); }
.seg.block { display: flex; }
.seg.block button { flex: 1; }

.switch { display: flex; align-items: center; gap: 10px; cursor: pointer; user-select: none; }
.switch input { position: absolute; opacity: 0; pointer-events: none; }
.switch i { width: 34px; height: 20px; border-radius: 20px; background: var(--line-2); position: relative; flex: none; transition: background .15s; }
.switch i::after { content: ""; position: absolute; top: 2px; left: 2px; width: 16px; height: 16px; border-radius: 50%; background: #fff; transition: transform .15s; box-shadow: 0 1px 3px rgba(0,0,0,.35); }
.switch input:checked + i { background: var(--accent); }
.switch input:checked + i::after { transform: translateX(14px); }
.switch input:focus-visible + i { outline: 2px solid var(--accent); outline-offset: 2px; }
.switch b { font-weight: 550; }
.switch small { display: block; color: var(--dim); font-size: 12px; font-weight: 400; }

input[type=range] { -webkit-appearance: none; appearance: none; width: 100%; height: 20px; background: transparent; cursor: pointer; }
input[type=range]::-webkit-slider-runnable-track { height: 4px; border-radius: 4px; background: var(--line-2); }
input[type=range]::-moz-range-track { height: 4px; border-radius: 4px; background: var(--line-2); }
input[type=range]::-webkit-slider-thumb { -webkit-appearance: none; width: 16px; height: 16px; margin-top: -6px; border-radius: 50%; background: var(--accent); border: 2px solid var(--surface); box-shadow: 0 1px 4px rgba(0,0,0,.4); }
input[type=range]::-moz-range-thumb { width: 14px; height: 14px; border-radius: 50%; background: var(--accent); border: 2px solid var(--surface); }
.slider-row { display: grid; grid-template-columns: 92px 1fr 44px; align-items: center; gap: 10px; }
.slider-row output { text-align: right; color: var(--muted); font-variant-numeric: tabular-nums; font-size: 12.5px; }

/* ---------- surfaces ---------- */
.card { background: var(--surface); border: 1px solid var(--line); border-radius: 14px; }
.card.pad { padding: 16px; }
.group { padding: 16px; border-bottom: 1px solid var(--line); display: flex; flex-direction: column; gap: 12px; }
.group:last-child { border-bottom: 0; }
.group > header { display: flex; align-items: center; justify-content: space-between; gap: 8px; min-height: 22px; }
.chip { display: inline-flex; align-items: center; gap: 6px; height: 26px; padding: 0 10px; border-radius: 20px; background: var(--surface-2); border: 1px solid var(--line); color: var(--muted); font-size: 12.5px; font-weight: 500; white-space: nowrap; }
.chip.ok { background: var(--ok-soft); border-color: transparent; color: var(--ok); }
.chip.warn { background: var(--warn-soft); border-color: transparent; color: var(--warn); }
.chip.bad { background: var(--bad-soft); border-color: transparent; color: var(--bad); }
.chip.accent { background: var(--accent-soft); border-color: transparent; color: var(--accent); }
.note { display: flex; gap: 10px; padding: 11px 12px; border-radius: 10px; background: var(--accent-soft); color: var(--text); font-size: 12.8px; line-height: 1.45; }
.note .ic { color: var(--accent); margin-top: 2px; }
.note.warn { background: var(--warn-soft); } .note.warn .ic { color: var(--warn); }

/* ---------- login ---------- */
.login { height: 100vh; display: grid; grid-template-columns: minmax(0, 1.1fr) minmax(380px, .9fr); }
.login-art { position: relative; overflow: hidden; background: radial-gradient(1200px 600px at 10% 10%, rgba(91,140,255,.28), transparent 60%), radial-gradient(900px 600px at 90% 90%, rgba(138,107,255,.30), transparent 60%), #090c12; color: #e7ebf1; padding: 56px; display: flex; flex-direction: column; justify-content: space-between; }
.login-art .tag { font-size: 34px; line-height: 1.15; font-weight: 680; letter-spacing: -.02em; max-width: 470px; position: relative; z-index: 1; }
.login-art .tag em { font-style: normal; background: linear-gradient(90deg, #7fa6ff, #b39cff); -webkit-background-clip: text; background-clip: text; color: transparent; }
.login-art ul { list-style: none; padding: 0; margin: 22px 0 0; display: grid; gap: 10px; color: #aeb8c8; font-size: 14.5px; }
.login-art li { display: flex; gap: 10px; align-items: center; }
.login-art li .ic { color: #7fa6ff; }
.fan { position: absolute; right: -190px; top: 50%; width: 420px; height: 300px; transform: translateY(-50%); pointer-events: none; opacity: .9; }
.fan div { position: absolute; inset: 0; border-radius: 22px; border: 1px solid rgba(255,255,255,.14); background: linear-gradient(135deg, rgba(255,255,255,.10), rgba(255,255,255,.02)); backdrop-filter: blur(2px); }
.fan div:nth-child(1) { transform: rotate(-16deg) translate(-30px, 30px); }
.fan div:nth-child(2) { transform: rotate(-6deg); }
.fan div:nth-child(3) { transform: rotate(5deg) translate(30px, -24px); background: linear-gradient(135deg, rgba(91,140,255,.35), rgba(138,107,255,.25)); }
.login-form { display: grid; place-items: center; padding: 32px; background: var(--bg); }
.login-form form { width: min(360px, 100%); display: flex; flex-direction: column; gap: 14px; }
.brand { display: flex; align-items: center; gap: 10px; font-weight: 680; font-size: 15px; letter-spacing: -.01em; }
.brand svg { width: 30px; height: 30px; border-radius: 8px; flex: none; }
.brand small { display: block; font-weight: 500; font-size: 11px; color: var(--dim); letter-spacing: 0; }
.form-error { color: var(--bad); background: var(--bad-soft); padding: 9px 11px; border-radius: 8px; font-size: 13px; }

/* ---------- shell ---------- */
.shell { height: 100vh; display: grid; grid-template-columns: 232px minmax(0, 1fr); }
.side { background: var(--surface); border-right: 1px solid var(--line); display: flex; flex-direction: column; min-height: 0; }
.side .brand { padding: 18px 16px 14px; }
.side nav { padding: 6px 10px; display: flex; flex-direction: column; gap: 2px; overflow: auto; flex: 1; }
.side nav h3 { padding: 14px 8px 6px; }
.nav-item { display: flex; align-items: center; gap: 10px; height: 38px; padding: 0 10px; border-radius: 9px; border: 0; background: transparent; color: var(--muted); cursor: pointer; text-align: left; font-weight: 550; width: 100%; position: relative; }
.nav-item:hover { background: var(--surface-2); color: var(--text); }
.nav-item.on { background: var(--accent-soft); color: var(--text); }
.nav-item.on .ic:first-child { color: var(--accent); }
.nav-item .step-n { width: 22px; height: 22px; border-radius: 50%; display: grid; place-items: center; font-size: 11.5px; font-weight: 650; background: var(--surface-3); color: var(--muted); flex: none; }
.nav-item.on .step-n { background: var(--accent); color: #fff; }
.nav-item.done .step-n { background: var(--ok-soft); color: var(--ok); }
.nav-item .badge { margin-left: auto; font-size: 11.5px; color: var(--dim); font-variant-numeric: tabular-nums; }
.side-foot { padding: 10px; border-top: 1px solid var(--line); display: flex; flex-direction: column; gap: 6px; }
.userchip { display: flex; align-items: center; gap: 10px; padding: 6px 8px; }
.avatar { width: 30px; height: 30px; border-radius: 50%; display: grid; place-items: center; font-weight: 650; color: #fff; background: linear-gradient(135deg, var(--accent), var(--accent-2)); flex: none; text-transform: uppercase; font-size: 12.5px; }
.userchip b { display: block; line-height: 1.2; }
.userchip small { color: var(--dim); font-size: 11.5px; }

.main { display: flex; flex-direction: column; min-width: 0; min-height: 0; height: 100vh; }
.top { height: 58px; flex: none; display: flex; align-items: center; gap: 12px; padding: 0 20px; border-bottom: 1px solid var(--line); background: var(--surface); }
.top .title { font-size: 15.5px; font-weight: 650; letter-spacing: -.01em; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.top .crumb { color: var(--dim); }
.save-state { display: inline-flex; align-items: center; gap: 6px; color: var(--dim); font-size: 12.5px; }
.save-state.ok { color: var(--ok); }
.content { flex: 1; min-height: 0; overflow: auto; }
.page { padding: 26px 28px 40px; max-width: 1240px; margin: 0 auto; display: flex; flex-direction: column; gap: 20px; }
.page-head { display: flex; align-items: flex-end; justify-content: space-between; gap: 16px; flex-wrap: wrap; }
.page-head p { color: var(--muted); margin-top: 3px; }

/* ---------- dashboard ---------- */
.stats { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 12px; }
.stat { padding: 14px 16px; display: flex; align-items: center; gap: 12px; }
.stat .ico { width: 38px; height: 38px; border-radius: 10px; display: grid; place-items: center; background: var(--accent-soft); color: var(--accent); flex: none; }
.stat b { display: block; font-size: 21px; font-weight: 680; line-height: 1.15; font-variant-numeric: tabular-nums; letter-spacing: -.01em; }
.stat span { color: var(--muted); font-size: 12.5px; }
.tiles { display: grid; grid-template-columns: repeat(auto-fill, minmax(230px, 1fr)); gap: 14px; }
.tile { overflow: hidden; cursor: pointer; transition: transform .12s, border-color .12s, box-shadow .12s; display: flex; flex-direction: column; text-align: left; padding: 0; color: inherit; }
.tile:hover { transform: translateY(-2px); border-color: var(--line-2); box-shadow: var(--shadow-sm); }
.tile .thumb { height: 140px; background: var(--canvas); display: grid; place-items: center; overflow: hidden; border-bottom: 1px solid var(--line); color: var(--dim); position: relative; }
.tile .thumb img { height: 124px; max-width: 86%; object-fit: contain; border-radius: 3px; box-shadow: var(--paper-shadow); background: #fff; }
.tile .body { padding: 12px 14px; display: flex; flex-direction: column; gap: 4px; }
.tile .body b { font-size: 14px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.tile .body span { color: var(--dim); font-size: 12px; }
.tile .tools { position: absolute; top: 8px; right: 8px; display: flex; gap: 4px; opacity: 0; transition: opacity .12s; }
.tile:hover .tools, .tile:focus-within .tools { opacity: 1; }
.tile .tools .btn { background: var(--surface); }
.tile.new { border-style: dashed; align-items: center; justify-content: center; gap: 8px; min-height: 212px; color: var(--muted); background: transparent; }
.tile.new:hover { color: var(--accent); border-color: var(--accent); background: var(--accent-soft); }
.empty { padding: 44px 20px; text-align: center; color: var(--muted); display: flex; flex-direction: column; align-items: center; gap: 10px; }
.empty .ico { width: 56px; height: 56px; border-radius: 16px; display: grid; place-items: center; background: var(--accent-soft); color: var(--accent); }

table.table { width: 100%; border-collapse: collapse; }
.table th { text-align: left; font-size: 11px; letter-spacing: .06em; text-transform: uppercase; color: var(--dim); font-weight: 650; padding: 10px 16px; border-bottom: 1px solid var(--line); }
.table td { padding: 11px 16px; border-bottom: 1px solid var(--line); vertical-align: middle; }
.table tr:last-child td { border-bottom: 0; }
.table td.actions { text-align: right; white-space: nowrap; }

/* ---------- dropzone & source grid ---------- */
.dropzone { border: 1.5px dashed var(--line-2); border-radius: 14px; padding: 30px 20px; display: flex; flex-direction: column; align-items: center; gap: 8px; text-align: center; color: var(--muted); cursor: pointer; transition: border-color .12s, background .12s; background: var(--surface); }
.dropzone:hover, .dropzone.over { border-color: var(--accent); background: var(--accent-soft); color: var(--text); }
.dropzone .ico { width: 48px; height: 48px; border-radius: 14px; display: grid; place-items: center; background: var(--accent-soft); color: var(--accent); }
.dropzone b { color: var(--text); font-size: 14.5px; }
.dropzone.compact { padding: 18px; flex-direction: row; justify-content: center; }
.src-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(170px, 1fr)); gap: 12px; }
.src { overflow: hidden; position: relative; }
.src .thumb { height: 150px; display: grid; place-items: center; background: var(--canvas); border-bottom: 1px solid var(--line); }
.src .thumb img { max-height: 132px; max-width: 86%; background: #fff; border-radius: 2px; box-shadow: var(--paper-shadow); }
.src .body { padding: 9px 11px; }
.src .body b { display: block; font-size: 12.8px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.src .body span { font-size: 12px; color: var(--dim); }
.src .rm { position: absolute; top: 6px; right: 6px; opacity: 0; transition: opacity .12s; background: var(--surface); }
.src:hover .rm, .src:focus-within .rm { opacity: 1; }
.src .pos { position: absolute; top: 8px; left: 8px; min-width: 22px; height: 22px; padding: 0 6px; border-radius: 11px; background: var(--accent); color: #fff; font-size: 11.5px; font-weight: 650; display: grid; place-items: center; }
.step-foot { display: flex; justify-content: space-between; align-items: center; gap: 12px; }

/* ---------- workspace (mark / layout) ---------- */
.work { height: 100%; display: flex; flex-direction: column; min-height: 0; }
.toolbar { flex: none; display: flex; align-items: center; gap: 8px; padding: 9px 14px; border-bottom: 1px solid var(--line); background: var(--surface); flex-wrap: wrap; }
.toolbar .sep { width: 1px; height: 22px; background: var(--line); margin: 0 3px; }
.toolbar select.input { width: auto; max-width: 220px; height: 30px; }
.toolbar .pg { min-width: 74px; text-align: center; color: var(--muted); font-variant-numeric: tabular-nums; font-size: 12.5px; }
.work-body { flex: 1; min-height: 0; display: grid; grid-template-columns: minmax(0, 1fr) 280px; }
.work-body.left { grid-template-columns: 372px minmax(0, 1fr); }
.stage { overflow: auto; background: var(--canvas); background-image: radial-gradient(var(--line) 1px, transparent 1px); background-size: 18px 18px; position: relative; min-height: 0; }
.stage-inner { min-width: 100%; min-height: 100%; display: grid; place-items: center; padding: 28px; width: max-content; }
.sheet { position: relative; background: #fff; box-shadow: var(--paper-shadow); line-height: 0; touch-action: none; }
.sheet img { width: 100%; height: 100%; display: block; user-select: none; -webkit-user-drag: none; }
.sheet svg { position: absolute; inset: 0; width: 100%; height: 100%; cursor: crosshair; overflow: visible; }
.mk { fill: rgba(91, 140, 255, .07); stroke: #4a7dff; stroke-width: 1.6; vector-effect: non-scaling-stroke; cursor: move; }
.mk.back { fill: rgba(47, 197, 142, .08); stroke: #17a673; }
.mk.sel { fill: rgba(91, 140, 255, .16); stroke-width: 2.2; }
.mk.draw { fill: rgba(240, 97, 109, .12); stroke: #f0616d; stroke-dasharray: 6 4; }
.mk-badge { fill: #4a7dff; } .mk-badge.back { fill: #17a673; }
.mk-num { fill: #fff; font: 650 11px Inter, "Segoe UI", system-ui, sans-serif; text-anchor: middle; dominant-baseline: central; pointer-events: none; }
.mk-h { fill: #fff; stroke: #4a7dff; stroke-width: 1.5; }
.panel { border-left: 1px solid var(--line); background: var(--surface); display: flex; flex-direction: column; min-height: 0; }
.work-body.left .panel { border-left: 0; border-right: 1px solid var(--line); overflow: auto; }
.panel > header { padding: 14px 16px 10px; display: flex; align-items: center; justify-content: space-between; gap: 8px; flex: none; }
.panel .list { flex: 1; overflow: auto; padding: 0 8px 8px; display: flex; flex-direction: column; gap: 2px; }
.mrow { display: flex; align-items: center; gap: 10px; padding: 6px 8px; border-radius: 8px; cursor: pointer; }
.mrow:hover { background: var(--surface-2); }
.mrow.on { background: var(--accent-soft); }
.mrow .n { width: 22px; height: 22px; border-radius: 50%; background: #4a7dff; color: #fff; font-size: 11px; font-weight: 650; display: grid; place-items: center; flex: none; }
.mrow .n.back { background: #17a673; }
.mrow b { font-weight: 550; font-size: 12.8px; }
.mrow small { color: var(--dim); display: block; font-size: 11.5px; }
.mrow .btn { margin-left: auto; opacity: 0; }
.mrow:hover .btn, .mrow.on .btn { opacity: 1; }
.panel footer { padding: 12px 14px; border-top: 1px solid var(--line); flex: none; display: flex; flex-direction: column; gap: 8px; }
.kbd { display: inline-block; padding: 0 5px; min-width: 18px; height: 18px; line-height: 17px; border-radius: 4px; border: 1px solid var(--line-2); background: var(--surface-2); font-size: 10.5px; color: var(--muted); text-align: center; }
.pop { position: absolute; z-index: 30; top: calc(100% + 6px); left: 0; width: 250px; padding: 14px; background: var(--surface); border: 1px solid var(--line-2); border-radius: 12px; box-shadow: var(--shadow); display: flex; flex-direction: column; gap: 10px; }
.pop-wrap { position: relative; }

/* layout preview */
.pv-top { position: absolute; top: 12px; left: 14px; right: 14px; display: flex; gap: 6px; flex-wrap: wrap; z-index: 5; pointer-events: none; }
.pv-top > * { pointer-events: auto; }
.pv-page { position: relative; background: #fff; box-shadow: var(--paper-shadow); touch-action: none; }
.slot { position: absolute; cursor: move; outline: 1px dashed rgba(74, 125, 255, .55); outline-offset: -1px; overflow: hidden; background: #f2f5fa; }
.slot.image { outline-color: rgba(23, 166, 115, .6); background: #eef7f3; }
.slot .ph { position: absolute; inset: 0; display: grid; place-items: center; color: #7b8799; font: 600 11px Inter, "Segoe UI", system-ui, sans-serif; line-height: 1.2; text-align: center; background-image: repeating-linear-gradient(45deg, transparent 0 7px, rgba(120, 135, 160, .09) 7px 14px); }
.slot .pic { position: absolute; left: 50%; top: 50%; background-position: center; background-repeat: no-repeat; pointer-events: none; }
.slot.sel { outline: 2px solid #4a7dff; overflow: visible; z-index: 3; }
.slot.sel.image { outline-color: #17a673; }
.slot .hd { position: absolute; width: 11px; height: 11px; background: #fff; border: 2px solid #4a7dff; border-radius: 3px; display: none; z-index: 4; }
.slot.sel .hd { display: block; }
.slot .hd.nw { left: -6px; top: -6px; cursor: nwse-resize; } .slot .hd.ne { right: -6px; top: -6px; cursor: nesw-resize; }
.slot .hd.sw { left: -6px; bottom: -6px; cursor: nesw-resize; } .slot .hd.se { right: -6px; bottom: -6px; cursor: nwse-resize; }
.inspector { position: absolute; left: 50%; bottom: 14px; transform: translateX(-50%); z-index: 6; display: flex; align-items: flex-end; gap: 8px; padding: 10px 12px; background: var(--surface); border: 1px solid var(--line-2); border-radius: 12px; box-shadow: var(--shadow); }
.inspector .field { width: 74px; }
.inspector .field label { font-size: 10.5px; }
.inspector .input { height: 30px; }
.inspector.hint { align-items: center; color: var(--muted); white-space: nowrap; font-size: 12.5px; }
.inspector.hint .ic { color: var(--accent); }

/* images step */
.modes { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 12px; }
.mode { padding: 14px; text-align: left; cursor: pointer; display: flex; flex-direction: column; gap: 8px; color: inherit; transition: border-color .12s, background .12s; }
.mode:hover { border-color: var(--line-2); }
.mode.on { border-color: var(--accent); background: var(--accent-soft); box-shadow: 0 0 0 1px var(--accent) inset; }
.mode .diagram { height: 74px; border-radius: 8px; background: var(--canvas); display: flex; flex-direction: column; justify-content: center; gap: 5px; padding: 8px 18px; }
.mode .diagram div { display: flex; gap: 5px; justify-content: center; }
.mode .diagram i { width: 34px; height: 21px; border-radius: 3px; background: #4a7dff; display: block; }
.mode .diagram i.g { background: #17a673; } .mode .diagram i.o { background: transparent; border: 1px dashed var(--dim); }
.mode b { font-size: 13.5px; } .mode span { color: var(--muted); font-size: 12.5px; line-height: 1.4; }
.img-list { display: grid; grid-template-columns: repeat(auto-fill, minmax(190px, 1fr)); gap: 12px; }
.imgc { overflow: hidden; position: relative; }
.imgc .thumb { height: 130px; background: var(--canvas); display: grid; place-items: center; overflow: hidden; border-bottom: 1px solid var(--line); }
.imgc .thumb img { max-width: 88%; max-height: 112px; box-shadow: var(--paper-shadow); transition: transform .15s, filter .1s; }
.imgc .body { padding: 8px 8px 8px 11px; display: flex; align-items: center; gap: 4px; }
.imgc .body b { font-size: 12.5px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; flex: 1; }
.imgc .pos { position: absolute; top: 8px; left: 8px; height: 22px; padding: 0 8px; border-radius: 11px; background: #17a673; color: #fff; font-size: 11.5px; font-weight: 650; display: grid; place-items: center; }
.two { display: grid; grid-template-columns: minmax(0, 1fr) 340px; gap: 16px; align-items: start; }

/* export step */
.exp { display: grid; grid-template-columns: 372px minmax(0, 1fr); gap: 18px; align-items: start; }
.runbox { padding: 18px; display: flex; flex-direction: column; gap: 14px; }
.sum { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 10px; }
.sum div { padding: 10px 12px; border-radius: 10px; background: var(--surface-2); border: 1px solid var(--line); }
.sum b { display: block; font-size: 19px; font-weight: 680; font-variant-numeric: tabular-nums; line-height: 1.2; }
.sum span { color: var(--muted); font-size: 12px; }
.progress { height: 8px; border-radius: 8px; background: var(--surface-3); overflow: hidden; }
.progress i { display: block; height: 100%; width: 0; border-radius: 8px; background: linear-gradient(90deg, var(--accent), var(--accent-2)); transition: width .25s ease; }
.progress.busy i { background-size: 28px 28px; background-image: linear-gradient(45deg, rgba(255,255,255,.18) 25%, transparent 25%, transparent 50%, rgba(255,255,255,.18) 50%, rgba(255,255,255,.18) 75%, transparent 75%), linear-gradient(90deg, var(--accent), var(--accent-2)); animation: stripes 1s linear infinite; }
@keyframes stripes { to { background-position: 28px 0, 0 0; } }
.log { margin: 0; padding: 12px 14px; border-radius: 10px; background: var(--canvas); border: 1px solid var(--line); color: var(--muted); font: 12px/1.55 ui-monospace, "Cascadia Mono", Consolas, "SFMono-Regular", Menlo, monospace; height: 170px; overflow: auto; white-space: pre-wrap; word-break: break-word; }
.out { padding: 14px; display: flex; flex-direction: column; gap: 12px; }
.out header { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.sheets { display: flex; gap: 10px; overflow-x: auto; padding: 4px 2px 8px; }
.sheets a { flex: none; display: flex; flex-direction: column; align-items: center; gap: 5px; color: var(--dim); font-size: 11.5px; }
.sheets img { height: 150px; background: #fff; border-radius: 3px; box-shadow: var(--shadow-sm); border: 1px solid var(--line); display: block; }
.sheets a:hover img { outline: 2px solid var(--accent); }

/* ---------- modal & toast ---------- */
.modal-back { position: fixed; inset: 0; z-index: 100; background: rgba(4, 6, 10, .6); backdrop-filter: blur(3px); display: grid; place-items: center; padding: 20px; animation: fade .12s; }
.modal { width: min(440px, 100%); max-height: 86vh; overflow: auto; background: var(--surface); border: 1px solid var(--line-2); border-radius: 16px; box-shadow: var(--shadow); padding: 20px; display: flex; flex-direction: column; gap: 14px; animation: pop .14s; }
.modal.wide { width: min(600px, 100%); }
.modal .acts { display: flex; justify-content: flex-end; gap: 8px; margin-top: 4px; }
@keyframes fade { from { opacity: 0; } }
@keyframes pop { from { opacity: 0; transform: translateY(8px) scale(.98); } }
#toasts { position: fixed; left: calc(50% + 116px); top: 9px; transform: translateX(-50%); z-index: 200; display: flex; flex-direction: column; gap: 8px; align-items: center; pointer-events: none; }
.toast { display: flex; align-items: center; gap: 9px; max-width: 420px; padding: 10px 14px; border-radius: 11px; background: var(--surface); border: 1px solid var(--line-2); box-shadow: var(--shadow); animation: pop .16s; font-weight: 500; }
.toast.ok .ic { color: var(--ok); } .toast.bad .ic { color: var(--bad); } .toast.info .ic { color: var(--accent); }
.tpl-row { display: flex; align-items: center; gap: 10px; padding: 9px 10px; border-radius: 10px; border: 1px solid var(--line); }
.tpl-row:hover { border-color: var(--line-2); background: var(--surface-2); }

/* ---------- responsive ---------- */
@media (max-width: 1100px) {
  .exp, .two { grid-template-columns: 1fr; }
  .stats { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}
@media (max-width: 860px) {
  body { overflow: auto; }
  #toasts { left: 50%; }
  .shell { grid-template-columns: 1fr; height: auto; min-height: 100vh; }
  .side { border-right: 0; border-bottom: 1px solid var(--line); }
  .side nav { flex-direction: row; overflow-x: auto; padding: 6px 10px 10px; }
  .side nav h3 { display: none; }
  .nav-item { width: auto; flex: none; }
  .nav-item .badge { display: none; }
  .side-foot { flex-direction: row; align-items: center; justify-content: space-between; }
  .main { height: auto; min-height: 70vh; }
  .content { overflow: visible; }
  .work { height: auto; }
  .work-body, .work-body.left { grid-template-columns: 1fr; }
  .stage { height: 70vh; }
  .panel { border-left: 0; border-top: 1px solid var(--line); max-height: 50vh; }
  .login { grid-template-columns: 1fr; }
  .login-art { display: none; }
  .modes { grid-template-columns: 1fr; }
  .page { padding: 18px 14px 30px; }
  .sum { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}
@media (prefers-reduced-motion: reduce) { * { animation: none !important; transition: none !important; } }
