:root {
  color-scheme: dark;
  --bg: #071a36;
  --surface: #0b2447;
  --surface-raised: #102f59;
  --surface-soft: #163962;
  --line: #2b4d75;
  --text: #f5f8ff;
  --muted: #b8c9df;
  --accent: #67a8ff;
  --accent-strong: #86bcff;
  --danger: #ff8f9b;
  --success: #70d6a1;
  --warning: #ffd17a;
  --radius: 6px;
  --shadow: 0 18px 45px rgba(0, 8, 25, 0.3);
  font-family: "Segoe UI Variable", "Segoe UI", "Microsoft YaHei UI", sans-serif;
  font-synthesis: none;
}

* { box-sizing: border-box; }

html { min-width: 320px; background: var(--bg); }

body {
  min-height: 100vh;
  margin: 0;
  background: var(--bg);
  color: var(--text);
  line-height: 1.5;
}

button, input, textarea, select { font: inherit; }
button, a, input, textarea, select { -webkit-tap-highlight-color: transparent; }
button { color: inherit; }
[x-cloak] { display: none !important; }

::selection { background: var(--accent); color: #031329; }
* { scrollbar-color: var(--surface-soft) var(--bg); scrollbar-width: thin; }
*::-webkit-scrollbar { width: 10px; height: 10px; }
*::-webkit-scrollbar-track { background: var(--bg); }
*::-webkit-scrollbar-thumb { background: var(--surface-soft); border: 2px solid var(--bg); border-radius: 4px; }

:focus-visible { outline: 3px solid var(--accent); outline-offset: 3px; }

.shell { width: min(1120px, calc(100% - 40px)); margin: 0 auto; }

.topbar {
  height: 76px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  border-bottom: 1px solid rgba(103, 168, 255, 0.16);
}

.brand { display: inline-flex; align-items: center; gap: 11px; color: var(--text); text-decoration: none; font-weight: 700; letter-spacing: -0.02em; }
.brand-mark { width: 28px; height: 28px; border: 7px solid var(--accent); border-radius: 5px; transform: rotate(12deg); }
.brand-banner {
  min-height: 132px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-bottom: 1px solid rgba(103, 168, 255, 0.1);
}
.brand-image {
  width: clamp(72px, 8vw, 100px);
  max-width: 100px;
  height: auto;
  display: block;
  object-fit: contain;
  border-radius: 8px;
}
.topbar-title { margin: 0; font-size: 1rem; font-weight: 650; color: var(--muted); }

main { padding: 54px 0 72px; }
.page-head { display: flex; align-items: end; justify-content: space-between; gap: 24px; margin-bottom: 28px; }
h1 { margin: 0; font-size: clamp(2rem, 5vw, 3.5rem); line-height: 1.05; letter-spacing: -0.035em; }
.user-main { padding-top: 46px; }
.user-title { margin-bottom: 28px; }
.primary-tabs {
  align-self: stretch;
  display: grid;
  grid-template-columns: repeat(3, minmax(100px, 1fr));
}
.primary-tab {
  min-height: 100%;
  border: 0;
  border-bottom: 2px solid transparent;
  padding: 10px 24px;
  background: transparent;
  color: var(--muted);
  font-size: 1rem;
  font-weight: 750;
  cursor: pointer;
}
.primary-tab:hover { color: var(--text); background: rgba(103, 168, 255, .06); }
.primary-tab.active { border-bottom-color: var(--accent); background: rgba(103, 168, 255, .09); color: var(--text); }
.faq-content { width: min(760px, 100%); margin: 0 auto; overflow-wrap: anywhere; color: var(--muted); line-height: 1.75; }
.faq-content h2, .faq-content h3 { margin: 28px 0 12px; color: var(--text); }
.faq-content h2:first-child, .faq-content h3:first-child { margin-top: 0; }
.faq-content p, .faq-content ul, .faq-content ol { margin: 0 0 16px; }
.faq-content a { color: var(--accent-strong); }
.faq-content pre { overflow-x: auto; padding: 16px; border-radius: var(--radius); background: var(--surface); }
.faq-content code { overflow-wrap: anywhere; }
.showcase-search { width: min(620px, 100%); display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: 10px; margin-bottom: 28px; }
.showcase-grid { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); grid-auto-rows: 1fr; gap: 18px; }
.showcase-card { min-width: 0; overflow: hidden; border: 1px solid rgba(43, 77, 117, .8); border-radius: var(--radius); padding: 0; background: var(--surface); color: var(--text); text-align: left; cursor: pointer; transition: border-color 160ms ease, transform 160ms cubic-bezier(.2,.8,.2,1); }
.showcase-card:hover { border-color: var(--accent); transform: translateY(-2px); }
.showcase-card > img { width: 100%; aspect-ratio: 1; display: block; object-fit: cover; background: #07182f; }
.showcase-copy { display: block; padding: 17px; }
.showcase-name { display: block; margin-bottom: 7px; overflow: hidden; font-size: 1.15rem; font-weight: 700; letter-spacing: -0.015em; text-overflow: ellipsis; white-space: nowrap; }
.showcase-description { display: -webkit-box; overflow: hidden; color: var(--muted); font-size: .88rem; -webkit-line-clamp: 3; -webkit-box-orient: vertical; }
.pagination { min-height: 46px; display: flex; align-items: center; justify-content: center; gap: 18px; margin-top: 30px; color: var(--muted); font-size: .9rem; }
.pagination strong { color: var(--text); font-variant-numeric: tabular-nums; }
.preview-backdrop { position: fixed; inset: 0; z-index: 100; display: grid; place-items: center; padding: 28px; background: rgba(2, 12, 28, .82); }
.preview-dialog { width: min(1320px, 100%); max-height: calc(100vh - 56px); overflow: hidden; border-radius: 10px; background: var(--surface); box-shadow: 0 28px 80px rgba(0, 5, 18, .58); }
.preview-head { min-height: 68px; display: flex; align-items: center; justify-content: space-between; gap: 20px; padding: 14px 18px 14px 24px; border-bottom: 1px solid var(--line); }
.preview-head h2 { margin: 0; font-size: 1.35rem; }
.preview-close { width: 42px; height: 42px; display: grid; place-items: center; border: 0; border-radius: 5px; background: transparent; color: var(--muted); cursor: pointer; }
.preview-close:hover { background: var(--surface-soft); color: var(--text); }
.preview-close svg, .rotation-control svg { width: 22px; height: 22px; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }
.preview-content { min-height: 0; height: min(72vh, 760px); display: grid; grid-template-columns: minmax(0, 3fr) minmax(260px, 1fr); overflow: hidden; }
.preview-stage { position: relative; width: 100%; height: 100%; min-width: 0; min-height: 0; max-width: 100%; max-height: 100%; display: grid; place-items: center; contain: strict; isolation: isolate; overflow: clip; padding: 24px; background: #05162e; }
.preview-state { color: var(--muted); font-size: 1.05rem; font-weight: 700; }
.preview-loader { width: min(320px, 78%); display: grid; justify-items: center; gap: 12px; color: var(--text); text-align: center; }
.preview-loader-spinner { width: 42px; height: 42px; border: 3px solid rgba(105, 183, 255, .22); border-top-color: var(--accent); border-radius: 50%; animation: spin .8s linear infinite; }
.preview-loader p { font-size: 1rem; font-weight: 750; }
.preview-loader-count { color: var(--muted); font-size: .84rem; font-variant-numeric: tabular-nums; }
.preview-loader-track { width: 100%; height: 5px; overflow: hidden; border-radius: 3px; background: rgba(105, 183, 255, .16); }
.preview-loader-track > span { width: 100%; height: 100%; display: block; border-radius: inherit; background: var(--accent); transform: scaleX(0); transform-origin: left; transition: transform 160ms ease-out; }
.rotation-viewer { position: relative; width: 100%; height: 100%; min-width: 0; min-height: 0; max-width: 100%; max-height: 100%; display: block; contain: strict; overflow: clip; }
.rotation-viewer > img { position: absolute; inset: 0; width: 100%; height: 100%; max-width: 100%; max-height: 100%; display: block; object-fit: contain; }
.rotation-control { position: absolute; top: 50%; width: 64px; height: 96px; display: grid; place-items: center; border: 0; border-radius: 6px; background: rgba(4, 18, 38, .58); color: var(--text); cursor: pointer; transform: translateY(-50%); transition: background-color 160ms ease; }
.rotation-control:hover { background: rgba(22, 57, 98, .82); }
.rotation-left { left: 14px; }
.rotation-right { right: 14px; }
.rotation-angle { position: absolute; right: 14px; bottom: 14px; padding: 5px 9px; border-radius: 4px; background: rgba(4, 18, 38, .68); color: var(--muted); font-size: .82rem; font-variant-numeric: tabular-nums; }
.preview-sidebar { min-width: 0; min-height: 0; display: grid; grid-template-rows: minmax(0, 1fr) minmax(132px, .38fr); border-left: 1px solid var(--line); background: var(--surface); }
.preview-menu { min-height: 0; display: grid; grid-template-rows: auto minmax(0, 1fr); contain: layout paint; overflow: hidden; background: var(--surface); }
.preview-menu-title { padding: 22px 20px 0; color: var(--text); font-size: 1.3rem; font-weight: 750; letter-spacing: -.015em; }
.preview-menu-viewer { width: 100%; height: 100%; min-height: 0; container-type: size; }
.preview-description { min-height: 0; overflow-y: auto; padding: 22px 20px 24px; border-top: 1px solid var(--line); overscroll-behavior: contain; }
.preview-description h3 { margin-bottom: 10px; color: var(--text); font-size: 1rem; }
.preview-description p { color: var(--muted); font-size: .9rem; line-height: 1.65; white-space: pre-wrap; overflow-wrap: anywhere; }
.upload-workflow { width: min(760px, 100%); margin: 0 auto; }
h2 { margin: 0 0 18px; font-size: 1.15rem; letter-spacing: -0.015em; }
h3 { margin: 0; font-size: 1rem; }
p { margin: 0; }
.muted { color: var(--muted); }

.panel {
  background: var(--surface);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
}
.panel-pad { padding: 28px; }
.upload-main { width: min(760px, 100%); margin: 0 auto; padding-top: 52px; }
.step-tabs {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  margin: 0;
  padding: 0;
  border-bottom: 1px solid var(--line);
  list-style: none;
}
.step-tabs li { min-width: 0; }
.step-tabs button {
  width: 100%;
  min-height: 58px;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 9px;
  margin-bottom: -1px;
  border: 0;
  border-bottom: 2px solid transparent;
  background: transparent;
  color: #7992b2;
  font-weight: 650;
  cursor: default;
}
.step-tabs button.done { color: var(--muted); cursor: pointer; }
.step-tabs button.done:hover { color: var(--text); }
.step-tabs button.active { border-bottom-color: var(--accent); color: var(--text); }
.step-tabs button span {
  width: 24px;
  height: 24px;
  display: grid;
  place-items: center;
  border: 1px solid currentColor;
  border-radius: 50%;
  font-size: .78rem;
  font-variant-numeric: tabular-nums;
}
.step-tabs button.done span { border-color: var(--accent); background: var(--accent); color: #06172f; }
.step-tabs button:disabled { opacity: 1; }
.flow-content { min-height: 420px; padding: 54px 0 24px; }
.flow-narrow { width: min(430px, 100%); margin: 0 auto; }
.flow-actions { display: flex; justify-content: flex-end; margin-top: 28px; }


.models { display: grid; grid-auto-rows: 1fr; border-top: 1px solid var(--line); }
.model {
  width: 100%;
  min-height: 100px;
  display: grid;
  grid-template-columns: 72px minmax(0, 1fr) 24px;
  gap: 16px;
  align-items: center;
  padding: 14px 6px;
  border: 0;
  border-bottom: 1px solid var(--line);
  background: transparent;
  text-align: left;
  cursor: pointer;
  transition: background-color 180ms ease;
}
.model:hover { background: rgba(103, 168, 255, .06); }
.model.active { background: rgba(103, 168, 255, .1); }
.model img { width: 72px; height: 72px; object-fit: cover; border-radius: 6px; background: #07182f; }
.model-copy { min-width: 0; }
.model-name { display: block; font-weight: 700; color: var(--text); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.model-description { display: -webkit-box; margin-top: 4px; overflow: hidden; color: var(--muted); font-size: .88rem; -webkit-line-clamp: 2; -webkit-box-orient: vertical; }
.check { width: 20px; height: 20px; border: 2px solid var(--line); border-radius: 50%; display: grid; place-items: center; }
.active .check { border-color: var(--accent); }
.active .check::after { content: ""; width: 8px; height: 8px; border-radius: 50%; background: var(--accent); }

.form-stack { display: grid; gap: 16px; }
.field { display: grid; gap: 7px; }
label { color: var(--muted); font-size: .86rem; font-weight: 600; }
.checkbox-option { display: grid; grid-template-columns: 18px minmax(0, 1fr); gap: 10px; align-items: start; cursor: pointer; }
.checkbox-option input[type="checkbox"] { width: 18px; height: 18px; min-height: 18px; margin: 2px 0 0; padding: 0; accent-color: var(--accent); cursor: pointer; }
.checkbox-option strong { display: block; color: var(--text); font-size: .9rem; }
.checkbox-option small { display: block; margin-top: 3px; color: var(--muted); font-size: .8rem; font-weight: 500; line-height: 1.45; }
input, textarea, select {
  width: 100%;
  min-height: 46px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: #071c39;
  color: var(--text);
  padding: 10px 12px;
  caret-color: var(--accent);
  transition: border-color 160ms ease, background-color 160ms ease;
}
textarea { min-height: 92px; resize: vertical; }
input::placeholder, textarea::placeholder { color: #87a0bf; }
input:hover, textarea:hover, select:hover { border-color: #446992; }
input:focus, textarea:focus, select:focus { border-color: var(--accent); background: #092243; outline: none; }

.actions { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; }
.btn {
  min-height: 44px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  border: 0;
  border-radius: 6px;
  padding: 10px 17px;
  background: var(--accent);
  color: #06172f;
  font-weight: 750;
  cursor: pointer;
  transition: background-color 160ms ease, transform 160ms cubic-bezier(.2,.8,.2,1);
}
.btn:hover { background: var(--accent-strong); transform: translateY(-1px); }
.btn:active { transform: translateY(0); }
.btn:disabled { cursor: not-allowed; opacity: .52; transform: none; }
.btn-secondary { background: var(--surface-soft); color: var(--text); }
.btn-secondary:hover { background: #1e4774; }
.btn-danger { background: transparent; color: var(--danger); }
.btn-danger:hover { background: rgba(255, 143, 155, .1); }
.btn-block { width: 100%; margin-top: 4px; }
.btn-compact { min-height: 36px; padding: 7px 11px; font-size: .84rem; }
.icon-btn { width: 40px; min-height: 40px; padding: 0; }
.btn svg, .icon-btn svg { width: 18px; height: 18px; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }

.notice { padding: 12px 14px; border-radius: 6px; background: rgba(255, 143, 155, .11); color: #ffd7dc; font-size: .9rem; }
.notice-success { background: rgba(112, 214, 161, .11); color: #b8f4d2; }
.empty { padding: 42px 20px; text-align: center; color: var(--muted); }

.progress-view { min-height: 330px; display: grid; align-content: center; text-align: center; }
.completion-message { max-width: 65ch; margin: 12px auto 0; color: #b8f4d2; line-height: 1.7; white-space: pre-wrap; overflow-wrap: anywhere; }
.status-mark { width: 66px; height: 66px; margin: 0 auto 22px; display: grid; place-items: center; border-radius: 8px; background: var(--surface-soft); color: var(--accent); }
.status-mark svg { width: 32px; height: 32px; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }
.status-mark.loading svg { animation: spin 1.1s linear infinite; }
.status-mark.success { color: var(--success); }
.status-mark.failed { color: var(--danger); }
@keyframes spin { to { transform: rotate(360deg); } }
.progress-view h2 { font-size: 1.55rem; margin-bottom: 10px; }
.progress-track { width: min(360px, 100%); height: 7px; margin: 28px auto 24px; overflow: hidden; border-radius: 3px; background: #06172f; }
.progress-bar { width: 100%; height: 100%; border-radius: inherit; background: var(--accent); transform-origin: left; transition: transform 500ms cubic-bezier(.2,.8,.2,1); }

.tabs { display: inline-flex; gap: 4px; padding: 4px; border-radius: 6px; background: var(--surface); }
.tab { min-height: 38px; border: 0; border-radius: 4px; padding: 7px 18px; background: transparent; color: var(--muted); font-weight: 700; cursor: pointer; }
.tab.active { background: var(--surface-soft); color: var(--text); }

.admin-layout { display: block; }
.compression-status { margin-bottom: 24px; padding: 20px 22px; border: 1px solid var(--line); border-radius: var(--radius); background: var(--surface); overflow-wrap: anywhere; }
.compression-heading { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 12px; margin-bottom: 16px; }
.compression-heading h2 { margin: 0; }
.compression-details { display: grid; gap: 12px; font-size: .9rem; }
.compression-progress-label { display: flex; justify-content: space-between; gap: 16px; margin-bottom: 6px; font-variant-numeric: tabular-nums; }
.compression-progress-label span { min-width: 0; }
.compression-progress-label strong { flex-shrink: 0; }
.compression-progress { display: block; width: 100%; height: 10px; margin: 0 0 8px; appearance: none; border: 0; border-radius: 3px; overflow: hidden; background: var(--surface-soft); accent-color: var(--accent); }
.compression-progress::-webkit-progress-bar { background: var(--surface-soft); }
.compression-progress::-webkit-progress-value { background: var(--accent); }
.compression-progress::-moz-progress-bar { background: var(--accent); }
.compression-failures { color: #ffd7dc; }
.compression-failures ul { margin: 6px 0 0; padding-left: 22px; }
.compression-status > .notice { margin-top: 12px; }
.list-panel { overflow: visible; }
.list-head { min-height: 66px; display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 12px 18px 12px 22px; border-bottom: 1px solid var(--line); }
.list-head > h2 { flex-shrink: 0; }
.list-actions { display: flex; flex-wrap: wrap; align-items: center; justify-content: flex-end; gap: 6px; }
.rows { display: grid; }
.row { min-width: 0; display: grid; grid-template-columns: minmax(0, 1fr) auto; align-items: center; gap: 18px; padding: 16px 18px 16px 22px; border-bottom: 1px solid rgba(43, 77, 117, .65); }
.row:last-child { border-bottom: 0; }
.row-main { min-width: 0; }
.row-title { display: block; overflow: hidden; font-weight: 700; text-overflow: ellipsis; white-space: nowrap; }
.row-meta { display: flex; gap: 10px; margin-top: 4px; color: var(--muted); font-size: .83rem; }
.row-meta span { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.row-actions { display: flex; align-items: center; gap: 2px; }
.row-actions button, .row-actions a { border: 0; background: transparent; color: var(--muted); cursor: pointer; }
.row-actions a { display: flex; align-items: center; justify-content: center; }
.row-actions button:hover, .row-actions a:hover { color: var(--text); background: var(--surface-soft); }
.row-actions .delete:hover { color: var(--danger); }
.row-actions button:disabled { cursor: not-allowed; opacity: .42; }
.sessions-panel .list-head { min-height: 72px; }
.session-count { font-variant-numeric: tabular-nums; }
.session-check { min-height: 40px; gap: 7px; padding: 8px 12px; font-variant-numeric: tabular-nums; }
.sessions-panel > .notice { margin: 16px 22px; }
.session-feedback { padding: 14px 22px; font-size: .86rem; }
.session-list { margin: 0; padding: 0; list-style: none; }
.session-copy { min-width: 0; }
.session-meta { display: flex; flex-wrap: wrap; gap: 4px 18px; margin-top: 5px; font-size: .8rem; font-variant-numeric: tabular-nums; }
.session-meta code { font-size: .8rem; }
.session-expiry { display: inline-flex; align-items: center; gap: 6px; }
.session-expiry svg { width: 14px; height: 14px; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }
.session-status { width: 28px; display: grid; place-items: center; color: var(--muted); }
.session-status svg { width: 20px; height: 20px; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }
.session-status.valid { color: var(--success); }
.session-status.warning, .session-issue { color: var(--warning); }
.session-issue { margin-top: 6px; font-size: .82rem; overflow-wrap: anywhere; }
.session-actions { gap: 8px; }
.session-confirm-actions { display: flex; gap: 2px; }
.session-actions .session-confirm { color: var(--danger); }
.model-row { position: relative; z-index: 0; }
.model-row.menu-open { z-index: 2; }
.model-action-dropdown { position: relative; }
.model-action-trigger[aria-expanded="true"] { background: var(--surface-soft); color: var(--text); }
.model-action-menu {
  position: absolute;
  top: calc(100% + 6px);
  right: 0;
  z-index: 3;
  width: min(258px, calc(100vw - 32px));
  overflow-y: auto;
  padding: 5px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--surface-raised);
  box-shadow: var(--shadow);
}
.model-action-menu.above { top: auto; bottom: calc(100% + 6px); }
.row-actions .model-action-menu button, .row-actions .model-action-menu a {
  width: 100%;
  min-height: 40px;
  display: flex;
  align-items: center;
  justify-content: flex-start;
  padding: 8px 11px;
  border-radius: 4px;
  font-size: .88rem;
  text-align: left;
  text-decoration: none;
  white-space: normal;
}
.row-actions .model-action-menu .delete { color: var(--danger); }
.row-actions .model-action-menu .delete:hover { background: rgba(255, 143, 155, .1); }
.admin-pagination { margin: 0; padding: 14px 18px; border-top: 1px solid var(--line); }
.editor-backdrop { position: fixed; inset: 0; z-index: 90; display: grid; place-items: center; padding: 20px; background: rgba(2, 12, 28, .82); }
.form-panel { width: min(600px, 100%); max-height: calc(100dvh - 40px); overflow-y: auto; overscroll-behavior: contain; }
#card-value { flex: 1 1 0; min-width: 0; }
#card-value + .btn { flex: none; white-space: nowrap; }
.form-title { display: flex; align-items: center; justify-content: space-between; margin-bottom: 20px; }
.form-title .icon-btn { border: 0; background: transparent; color: var(--muted); cursor: pointer; }
.cover-input { display: grid; grid-template-columns: 70px 1fr; gap: 12px; align-items: center; }
.cover-preview { width: 70px; height: 70px; border-radius: 6px; object-fit: cover; background: #07182f; }
.file-button { min-height: 44px; display: flex; align-items: center; justify-content: center; border: 1px dashed #5579a2; border-radius: 6px; color: var(--muted); cursor: pointer; }
.file-button:hover { color: var(--text); border-color: var(--accent); }
.file-button input { position: absolute; width: 1px; height: 1px; opacity: 0; pointer-events: none; }
.toggle { display: grid; grid-template-columns: repeat(2, 1fr); gap: 4px; padding: 4px; border-radius: 6px; background: #071c39; }
.toggle button { min-height: 38px; border: 0; border-radius: 4px; background: transparent; color: var(--muted); cursor: pointer; }
.toggle button.active { background: var(--surface-soft); color: var(--text); font-weight: 700; }


.backup-settings { min-width: 0; margin-bottom: 24px; }
.backup-settings h2 { margin: 0 0 10px; }
.backup-settings-form { display: grid; grid-template-columns: minmax(140px, .6fr) minmax(0, 1.4fr); align-items: start; gap: 18px 24px; margin: 22px 0 0; }
.backup-settings-form > * { min-width: 0; }
.backup-settings-form > button { grid-column: 1 / -1; }
.backup-settings .backup-help { overflow-wrap: anywhere; }
.backup-layout { display: grid; grid-template-columns: minmax(300px, .85fr) minmax(0, 1.4fr); align-items: start; gap: 24px; }
.backup-layout > *, .backup-monitor, .backup-setup form { min-width: 0; }
.backup-setup h2, .backup-section-head h2, .backup-section-head h3 { margin: 0; }
.backup-setup > .backup-help { margin: 10px 0 24px; }
.backup-help { margin: 0; font-size: .86rem; line-height: 1.65; }
.backup-fieldset { min-width: 0; display: grid; gap: 14px; margin: 0; padding: 0 0 22px; border: 0; border-bottom: 1px solid var(--line); }
.backup-fieldset legend { margin-bottom: 12px; padding: 0; color: var(--text); font-weight: 700; }
.backup-fieldset .form-stack { gap: 9px; }
.backup-mode-options { display: flex; flex-wrap: wrap; gap: 8px 20px; }
.backup-content-options { display: grid; gap: 4px; }
.backup-choice { min-height: 36px; display: flex; align-items: center; gap: 10px; color: var(--text); cursor: pointer; }
.backup-choice input { flex: 0 0 18px; width: 18px; height: 18px; min-height: 18px; margin: 0; padding: 0; accent-color: var(--accent); cursor: pointer; }
.backup-align-start { justify-self: start; }
.backup-priority { display: grid; gap: 6px; margin: 0; padding-left: 24px; }
.backup-priority li { padding-left: 3px; font-size: .88rem; }
.backup-priority li::marker { color: var(--muted); font-variant-numeric: tabular-nums; }
.backup-priority li > span { display: inline-block; vertical-align: middle; width: calc(100% - 94px); overflow-wrap: anywhere; }
.backup-priority .actions { display: inline-flex; vertical-align: middle; gap: 4px; margin-left: 6px; }
.backup-monitor { display: grid; gap: 24px; }
.backup-panel-notice { margin: 16px; }
.backup-job-list, .backup-audit-list { margin: 0; padding: 0; list-style: none; }
.backup-job-list { max-height: 320px; overflow-y: auto; }
.backup-job-list li + li { border-top: 1px solid var(--line); }
.backup-job-button { width: 100%; min-height: 78px; display: flex; align-items: center; justify-content: space-between; gap: 14px; border: 0; padding: 14px 20px; background: transparent; color: var(--text); text-align: left; cursor: pointer; }
.backup-job-button:hover { background: var(--surface-raised); }
.backup-job-button.active { background: var(--surface-soft); }
.backup-job-button:focus-visible { outline-offset: -3px; }
.backup-job-main { min-width: 0; display: grid; gap: 4px; overflow-wrap: anywhere; }
.backup-job-main .muted { font-size: .8rem; font-variant-numeric: tabular-nums; }
.backup-status { flex-shrink: 0; font-size: .86rem; font-weight: 700; }
.backup-status.running { color: var(--accent-strong); }
.backup-status.completed { color: var(--text); }
.backup-status.failed { color: var(--danger); }
.backup-status.warning, .backup-count-warning { color: var(--warning); }
.backup-counts { padding-top: 16px; border-top: 1px solid var(--line); }
.backup-section-head { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 12px; margin-bottom: 14px; }
.backup-section-head > .muted { font-size: .82rem; }
.backup-section-head a { text-decoration: none; }
.backup-detail { overflow-wrap: anywhere; }
.backup-state-line { display: flex; align-items: baseline; flex-wrap: wrap; gap: 8px 14px; margin: 22px 0 18px; font-size: .88rem; }
.backup-state-line > span:last-child { flex: 1 1 220px; color: var(--muted); }
.backup-metadata { display: grid; grid-template-columns: auto minmax(0, 1fr); gap: 9px 16px; font-size: .84rem; }
.backup-metadata dt { color: var(--muted); }
.backup-metadata dd { min-width: 0; margin: 0; font-variant-numeric: tabular-nums; }
.backup-result { margin-top: 22px; }
.backup-result summary, .backup-audit summary { cursor: pointer; font-size: .88rem; }
.backup-result summary { font-weight: 700; }
.backup-json { max-height: 360px; overflow: auto; margin: 12px 0 0; padding: 14px; border-radius: var(--radius); background: var(--bg); color: var(--muted); font: .78rem/1.7 Consolas, "Cascadia Code", monospace; white-space: pre-wrap; overflow-wrap: anywhere; tab-size: 2; }
.backup-audit { margin-top: 28px; padding-top: 22px; border-top: 1px solid var(--line); }
.backup-audit-list { margin-top: 16px; }
.backup-audit-list li { padding: 13px 0; border-bottom: 1px solid var(--line); }
.backup-audit-list summary { overflow-wrap: anywhere; }
.backup-audit-list summary time { margin-right: 12px; color: var(--muted); font-size: .78rem; font-variant-numeric: tabular-nums; }
.backup-event-warning summary > span { color: var(--warning); }
.backup-audit-pagination { margin-top: 18px; font-size: .84rem; }
.backup-progress { margin-top: 24px; padding-top: 20px; border-top: 1px solid var(--line); }
.backup-progress h3 { margin: 0 0 12px; font-size: .94rem; }
.backup-progress .backup-metadata { margin-bottom: 24px; }
.backup-stop { color: var(--danger); }
.backup-resource-table { width: 100%; table-layout: fixed; border-collapse: collapse; font-size: .8rem; text-align: left; }
.backup-resource-table th, .backup-resource-table td { padding: 10px 8px; vertical-align: top; overflow-wrap: anywhere; border-bottom: 1px solid var(--line); }
.backup-resource-table th { color: var(--muted); font-weight: 600; }
.backup-resource-table th:first-child { width: 46%; }
.backup-resource-table td { font-variant-numeric: tabular-nums; }
.backup-resource-table td > span { display: block; margin-top: 4px; }
.backup-resource-url { font-size: .75rem; }
.spinner { width: 18px; height: 18px; border: 2px solid rgba(6, 23, 47, .28); border-top-color: currentColor; border-radius: 50%; animation: spin .8s linear infinite; }
.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; }

/* Backup import extends the admin list; selection stays visible while browsing. */
.page-head:has(#admin-imports-tab) { flex-wrap: wrap; }
.page-head:has(#admin-imports-tab) .tabs { flex-wrap: wrap; }
.backup-library h2 { margin: 0; }
.backup-library > .notice { margin: 16px 24px; }
.backup-table-scroll { overflow-x: auto; }
.backup-table { width: 100%; border-collapse: collapse; text-align: left; font-size: .92rem; }
.backup-table th, .backup-table td { padding: 18px 24px; border-bottom: 1px solid var(--line); }
.backup-table thead th { color: var(--muted); font-weight: 500; font-size: .82rem; white-space: nowrap; }
.backup-table tbody th { font-weight: 650; overflow-wrap: anywhere; }
.backup-table td { font-variant-numeric: tabular-nums; }
.backup-table td:last-child { white-space: nowrap; color: var(--muted); font-size: .85rem; }
.backup-table-row { cursor: pointer; }
.backup-table-row:hover { background: var(--surface-raised); }
.backup-table-row:focus-visible { outline-offset: -3px; }
.import-backdrop { z-index: 110; padding: 24px; }
.import-dialog { width: min(960px, 100%); max-height: calc(100dvh - 48px); display: flex; flex-direction: column; overflow: hidden; }
.import-heading, .import-footer { display: flex; align-items: center; justify-content: space-between; gap: 16px; padding: 20px 24px; flex-shrink: 0; }
.import-heading { border-bottom: 1px solid var(--line); }
.import-heading h2 { margin: 0; font-size: 1.25rem; }
.import-heading p { margin-top: 4px; font-size: .82rem; }
.import-body { padding: 24px; overflow-y: auto; overscroll-behavior: contain; min-height: 180px; }
.import-body > .notice { margin-bottom: 18px; }
.import-target-bar { display: flex; flex-wrap: wrap; align-items: center; gap: 10px; margin-bottom: 16px; }
.import-target-bar label { flex: none; margin: 0; }
.import-target-bar select { width: min(320px, 100%); min-height: 40px; padding: 8px 30px 8px 10px; }
.import-target-bar .muted { flex: 1 1 220px; font-size: .82rem; }
.import-jobs { margin-top: 26px; padding: 20px 24px 24px; border-top: 1px solid var(--line); }
.import-jobs-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-bottom: 12px; }
.import-jobs-head h3 { margin: 0; font-size: 1rem; }
.import-jobs-list { display: grid; gap: 10px; }
.import-job-card { display: flex; align-items: center; justify-content: space-between; flex-wrap: wrap; gap: 14px; padding: 14px 16px; border: 1px solid var(--line); border-radius: var(--radius); background: var(--surface); }
.import-job-copy { display: grid; gap: 5px; flex: 1 1 260px; min-width: 0; }
.import-job-copy > strong, .import-job-copy > span, .import-job-copy > p { overflow-wrap: anywhere; }
.import-job-copy > span, .import-job-copy > p { font-size: .84rem; }
.import-job-copy .compression-progress { margin: 4px 0 0; }
.import-selection-bar { display: flex; justify-content: space-between; align-items: center; margin-bottom: 20px; gap: 16px; font-size: .88rem; }
.import-grid { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); grid-auto-rows: 1fr; gap: 18px; }
.import-card { position: relative; min-width: 0; display: flex; flex-direction: column; border: 2px solid var(--line); border-radius: var(--radius); background: var(--bg); transition: border-color 140ms ease-out; }
.import-card:hover { border-color: var(--muted); }
.import-card.selected { border-color: var(--accent-strong); }
.import-card:focus-within { outline: 2px solid var(--accent); outline-offset: 3px; }
.import-card.duplicate-open { z-index: 2; }
.import-card-select { position: relative; display: block; flex: 1; cursor: pointer; min-width: 0; }
.import-card-select > input { position: absolute; top: 10px; right: 10px; width: 21px; height: 21px; margin: 0; accent-color: var(--accent); z-index: 1; cursor: pointer; }
.import-card-select > img { display: block; width: 100%; aspect-ratio: 1; object-fit: cover; border-radius: 3px 3px 0 0; background: var(--surface-soft); }
.import-card-copy { display: grid; gap: 7px; padding: 14px; overflow-wrap: anywhere; }
.import-card-copy > strong { display: -webkit-box; min-height: 2.9em; line-height: 1.45; overflow: hidden; -webkit-line-clamp: 2; -webkit-box-orient: vertical; font-size: .96rem; }
.import-card-copy > span { display: -webkit-box; min-height: 4.5em; line-height: 1.5; overflow: hidden; -webkit-line-clamp: 3; -webkit-box-orient: vertical; color: var(--muted); font-size: .8rem; white-space: pre-wrap; }
.import-duplicate { padding: 0 12px 12px; text-align: right; }
.duplicate-trigger { min-height: 32px; padding: 4px 0 4px 8px; background: none; border: 0; color: var(--warning); font-size: .76rem; cursor: pointer; text-decoration: underline; text-underline-offset: 3px; }
.duplicate-popover { position: absolute; right: 8px; bottom: 48px; width: min(320px, 75vw); max-height: 320px; overflow-y: auto; padding: 16px; background: var(--surface-raised); box-shadow: var(--shadow); border-radius: var(--radius); text-align: left; }
.import-card:nth-of-type(4n + 1) .duplicate-popover { left: 8px; right: auto; }
.duplicate-heading { display: flex; justify-content: space-between; align-items: center; gap: 16px; margin-bottom: 12px; font-size: .88rem; }
.duplicate-model { display: grid; grid-template-columns: 58px minmax(0, 1fr); gap: 12px; padding: 10px 0; }
.duplicate-model + .duplicate-model { border-top: 1px solid var(--line); }
.duplicate-model img { width: 58px; aspect-ratio: 1; object-fit: cover; border-radius: 3px; }
.duplicate-model strong { font-size: .85rem; overflow-wrap: anywhere; }
.duplicate-model p { display: -webkit-box; overflow: hidden; -webkit-line-clamp: 2; -webkit-box-orient: vertical; font-size: .76rem; overflow-wrap: anywhere; }
.import-progress { display: grid; gap: 18px; padding: 20px 0; }
.import-progress-label { display: flex; justify-content: space-between; gap: 20px; font-variant-numeric: tabular-nums; }
.import-progress > .compression-progress { margin: 0; }
.import-footer { border-top: 1px solid var(--line); }
.import-footer > .btn { min-width: 100px; margin-left: auto; }
.import-footer .muted { font-size: .82rem; }
@media (max-width: 820px) {
  .import-grid { grid-template-columns: repeat(3, minmax(0, 1fr)); }
  .import-card:nth-of-type(4n + 1) .duplicate-popover { left: auto; right: 8px; }
  .import-card:nth-of-type(3n + 1) .duplicate-popover { left: 8px; right: auto; }
}
@media (max-width: 560px) {
  .page-head:has(#admin-imports-tab) .tabs { width: 100%; gap: 2px; }
  .page-head:has(#admin-imports-tab) .tab { padding: 10px; font-size: .82rem; }
  .session-row { gap: 8px; padding: 14px 12px 14px 16px; }
  .session-actions { gap: 2px; }
  .session-meta { display: grid; gap: 4px; font-size: .75rem; }
  .backup-table th, .backup-table td { padding: 14px 12px; }
  .import-backdrop { padding: 10px; }
  .import-dialog { max-height: calc(100dvh - 20px); }
  .import-heading, .import-footer { padding: 16px; }
  .import-body { padding: 16px; }
  .import-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 12px; }
  .import-card:nth-of-type(3n + 1) .duplicate-popover { left: auto; right: 8px; }
  .import-card:nth-of-type(2n + 1) .duplicate-popover { left: 8px; right: auto; }
  .import-card-copy { padding: 11px; }
  .import-footer { gap: 10px; }
  .import-footer .backup-choice { font-size: .82rem; }
  .import-footer > .btn { min-width: 72px; }
}

@media (max-width: 760px) {
  .preview-dialog { overflow-y: auto; }
  .preview-content { height: auto; display: block; }
  .preview-stage { min-height: 52vh; }
  .preview-sidebar { grid-template-rows: minmax(360px, 55vh) minmax(132px, auto); border-top: 1px solid var(--line); border-left: 0; }
  .preview-description { max-height: 240px; }
}

@media (max-width: 820px) {
  .admin-layout { grid-template-columns: 1fr; }
  .backup-layout { grid-template-columns: minmax(0, 1fr); }
  .form-panel { position: static; }
  .models { grid-template-columns: 1fr; }
  .showcase-grid { grid-template-columns: repeat(3, minmax(0, 1fr)); }
}

@media (max-width: 560px) {
  .shell { width: min(100% - 24px, 1120px); }
  .topbar { min-height: 64px; height: auto; flex-wrap: wrap; }
  main { padding: 34px 0 48px; }
  .upload-main { padding-top: 34px; }
  .flow-content { min-height: 0; padding-top: 38px; }
  .step-tabs button { min-height: 52px; gap: 7px; font-size: .92rem; }
  .page-head { align-items: start; flex-direction: column; margin-bottom: 22px; }
  .user-title { margin-bottom: 22px; }
  .brand { gap: 7px; font-size: .78rem; }
  .brand-mark { width: 22px; height: 22px; border-width: 5px; }
  .primary-tabs { width: 100%; grid-template-columns: repeat(3, minmax(0, 1fr)); margin-left: 0; }
  .primary-tab { padding: 8px; font-size: .82rem; }
  .showcase-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 12px; }
  .showcase-copy { padding: 13px; }
  .preview-backdrop { padding: 0; }
  .preview-dialog { width: 100%; max-height: 100vh; min-height: 100vh; border-radius: 0; }
  .preview-head { min-height: 64px; padding: 11px 12px 11px 18px; }
  .preview-stage { height: calc(100vh - 64px); min-height: 0; padding: 12px; }
  .rotation-control { width: 52px; height: 82px; }
  .rotation-left { left: 8px; }
  .rotation-right { right: 8px; }
  .showcase-search { margin-bottom: 20px; }
  .pagination { justify-content: space-between; gap: 8px; }
  .panel-pad { padding: 20px; }
  .admin-layout { gap: 16px; }
  .backup-layout, .backup-monitor { gap: 16px; }
  .backup-settings { margin-bottom: 16px; }
  .backup-settings-form { grid-template-columns: minmax(0, 1fr); gap: 18px; }
  .backup-job-button { flex-wrap: wrap; }
  .backup-job-main { flex: 1 1 100%; }
  .backup-resource-table, .backup-resource-table tbody, .backup-resource-table tr, .backup-resource-table td { display: block; width: 100%; }
  .backup-resource-table thead { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0,0,0,0); white-space: nowrap; }
  .backup-resource-table tr { padding: 12px 0; border-bottom: 1px solid var(--line); }
  .backup-resource-table td { padding: 4px 0; border: 0; }
  .backup-resource-table td::before { content: attr(data-label); display: block; margin-bottom: 3px; color: var(--muted); font-weight: 600; }
  .backup-section-head { align-items: flex-start; }
  .backup-section-head a { max-width: 100%; white-space: normal; }
  .backup-job-button { padding: 14px 16px; }
  .backup-metadata { grid-template-columns: minmax(0, 1fr); gap: 3px; }
  .backup-metadata dd { margin-bottom: 9px; }
  .backup-audit-list summary time { display: inline-block; }
  .row { padding: 14px; }
  .row-meta { flex-direction: column; gap: 1px; }
  .list-head { padding: 10px 12px 10px 16px; }
  .topbar-title { display: none; }
}

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