/* ============================================================
   OCR Studio — Material You (Material 3) Design System
   ============================================================ */

/* ---------- 设计令牌 · 浅色 ---------- */
:root {
  --base-seed: #5b4cd8;       /* 主种子色 (≈ tone 40) */
  --base-seed-2: #5d5c72;     /* 次要色 */

  /* 主色派生 */
  --primary: var(--base-seed);
  --on-primary: #ffffff;
  --primary-container: color-mix(in oklab, var(--base-seed) 15%, #ffffff);
  --on-primary-container: color-mix(in oklab, var(--base-seed) 55%, #1a0040 25%);
  --secondary: var(--base-seed-2);
  --on-secondary: #ffffff;
  --secondary-container: color-mix(in oklab, var(--base-seed-2) 20%, #ffffff);
  --on-secondary-container: color-mix(in oklab, var(--base-seed-2) 45%, #000000 20%);
  --tertiary: #7d5260;
  --on-tertiary: #ffffff;
  --tertiary-container: #ffd8e4;
  --on-tertiary-container: #31101d;
  --error: #ba1a1a;
  --on-error: #ffffff;
  --error-container: #ffdad6;
  --on-error-container: #410002;
  --success: #2e6b3f;

  /* 中性表面 (带种子微染色 → M3 surface tint) */
  --surface: color-mix(in oklab, var(--base-seed) 4%, #fdfbff);
  --on-surface: #1b1b21;
  --surface-variant: color-mix(in oklab, var(--base-seed) 8%, #e6e1ec);
  --on-surface-variant: #47464f;
  --surface-c-lowest: color-mix(in oklab, var(--base-seed) 2%, #ffffff);
  --surface-c-low: color-mix(in oklab, var(--base-seed) 5%, #f7f3fb);
  --surface-c: color-mix(in oklab, var(--base-seed) 7%, #f1ecf5);
  --surface-c-high: color-mix(in oklab, var(--base-seed) 9%, #ebe6f0);
  --surface-c-highest: color-mix(in oklab, var(--base-seed) 11%, #e5e1ea);
  --inverse-surface: #303036;
  --inverse-on-surface: #f2eff7;
  --outline: #787680;
  --outline-variant: #c9c5d0;
  --shadow-c: rgba(28, 18, 60, 0.18);
  --scrim-c: rgba(0, 0, 0, 0.45);

  /* 形状 */
  --r-xs: 8px;
  --r-sm: 12px;
  --r-md: 16px;
  --r-lg: 24px;
  --r-xl: 28px;
  --r-full: 999px;

  /* 海拔 */
  --e1: 0 1px 2px rgba(0,0,0,.04), 0 1px 3px rgba(0,0,0,.08);
  --e2: 0 1px 2px rgba(0,0,0,.06), 0 2px 6px rgba(0,0,0,.10);
  --e3: 0 4px 8px rgba(0,0,0,.08), 0 1px 3px rgba(0,0,0,.06);
  --e4: 0 6px 14px rgba(0,0,0,.12), 0 2px 4px rgba(0,0,0,.06);
  --e5: 0 12px 28px rgba(0,0,0,.16), 0 4px 8px rgba(0,0,0,.08);

  color-scheme: light;
}

/* ---------- 设计令牌 · 深色 ---------- */
[data-theme="dark"] {
  --primary: color-mix(in oklab, var(--base-seed) 55%, #ffffff);
  --on-primary: color-mix(in oklab, var(--base-seed) 70%, #000000 35%);
  --primary-container: color-mix(in oklab, var(--base-seed) 35%, #000000 55%);
  --on-primary-container: color-mix(in oklab, var(--base-seed) 14%, #ffffff);
  --secondary: color-mix(in oklab, var(--base-seed-2) 50%, #ffffff);
  --on-secondary: color-mix(in oklab, var(--base-seed-2) 65%, #000000 30%);
  --secondary-container: color-mix(in oklab, var(--base-seed-2) 32%, #000000 45%);
  --on-secondary-container: color-mix(in oklab, var(--base-seed-2) 14%, #ffffff);
  --tertiary: #e8b9cf;
  --on-tertiary: #46263a;
  --tertiary-container: #5f3c51;
  --on-tertiary-container: #ffd8e4;
  --error: #ffb4ab;
  --on-error: #690005;
  --error-container: #93000a;
  --on-error-container: #ffdad6;
  --success: #7fd99a;

  --surface: color-mix(in oklab, var(--base-seed) 8%, #121317);
  --on-surface: #e5e1e9;
  --surface-variant: color-mix(in oklab, var(--base-seed) 10%, #2a2930);
  --on-surface-variant: #c9c5d0;
  --surface-c-lowest: color-mix(in oklab, var(--base-seed) 5%, #0d0e12);
  --surface-c-low: color-mix(in oklab, var(--base-seed) 8%, #1a1b20);
  --surface-c: color-mix(in oklab, var(--base-seed) 10%, #1f1f25);
  --surface-c-high: color-mix(in oklab, var(--base-seed) 12%, #2a292f);
  --surface-c-highest: color-mix(in oklab, var(--base-seed) 14%, #35343a);
  --inverse-surface: #e5e1e9;
  --inverse-on-surface: #303036;
  --outline: #938f99;
  --outline-variant: #48454e;
  --shadow-c: rgba(0, 0, 0, 0.5);
  --scrim-c: rgba(0, 0, 0, 0.6);

  color-scheme: dark;
}

/* ---------- 重置 ---------- */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
html, body { height: 100%; }
body {
  font-family: "Roboto Flex", system-ui, sans-serif;
  font-variation-settings: "opsz" 14, "wght" 400;
  background: var(--surface);
  color: var(--on-surface);
  min-height: 100vh;
  overflow-x: hidden;
  transition: background .45s ease, color .45s ease;
  -webkit-font-smoothing: antialiased;
}
button, input, textarea { font-family: inherit; color: inherit; }
button { cursor: pointer; border: none; background: none; }
.hidden { display: none !important; }
::selection { background: var(--primary-container); color: var(--on-primary-container); }

/* 统一可见焦点态 (键盘导航) */
:focus { outline: none; }
:focus-visible {
  outline: 2px solid var(--primary);
  outline-offset: 2px;
  border-radius: var(--r-xs);
}
.fab:focus-visible { outline-offset: 4px; }
.seed:focus-visible { outline-offset: 3px; }

/* M3 状态层涟漪 */
.ripple-surface { position: relative; overflow: hidden; }
.ripple {
  position: absolute; border-radius: 50%;
  background: currentColor; opacity: .28;
  transform: scale(0); animation: ripple-anim .55s ease-out forwards;
  pointer-events: none; mix-blend-mode: normal;
}
@keyframes ripple-anim {
  to { transform: scale(1); opacity: 0; }
}

/* 滚动条 */
*::-webkit-scrollbar { width: 10px; height: 10px; }
*::-webkit-scrollbar-track { background: transparent; }
*::-webkit-scrollbar-thumb {
  background: color-mix(in oklab, var(--outline) 50%, transparent);
  border-radius: var(--r-full);
  border: 2px solid transparent;
  background-clip: padding-box;
}
*::-webkit-scrollbar-thumb:hover { background: var(--outline); background-clip: padding-box; }

/* ---------- 大气背景 ---------- */
.atmosphere {
  position: fixed; inset: 0; z-index: 0; overflow: hidden;
  pointer-events: none;
}
.blob {
  position: absolute; border-radius: 50%; filter: blur(90px);
  opacity: .55; mix-blend-mode: normal;
  transition: background .6s ease;
}
.blob-a {
  width: 60vw; height: 60vw; top: -20vw; right: -10vw;
  background: radial-gradient(circle at 30% 30%, var(--primary), transparent 70%);
}
.blob-b {
  width: 50vw; height: 50vw; bottom: -18vw; left: -12vw;
  background: radial-gradient(circle at 60% 40%, var(--tertiary), transparent 70%);
  opacity: .4;
}
[data-theme="dark"] .blob-a { opacity: .32; }
[data-theme="dark"] .blob-b { opacity: .22; }
.grain {
  position: absolute; inset: -50%;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='160' height='160'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='.85' numOctaves='2'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23n)' opacity='.5'/%3E%3C/svg%3E");
  opacity: .035; mix-blend-mode: multiply;
}
[data-theme="dark"] .grain { opacity: .06; mix-blend-mode: screen; }

/* ---------- 顶部应用栏 ---------- */
.top-app-bar {
  position: sticky; top: 0; z-index: 40;
  display: flex; align-items: center; justify-content: space-between;
  gap: 16px; padding: 14px 24px;
  background: color-mix(in oklab, var(--surface) 75%, transparent);
  backdrop-filter: blur(18px) saturate(1.3);
  -webkit-backdrop-filter: blur(18px) saturate(1.3);
  border-bottom: 1px solid var(--outline-variant);
}
.bar-left { display: flex; align-items: center; gap: 8px; }
.bar-right { display: flex; align-items: center; gap: 6px; }
.brand { display: flex; align-items: center; gap: 12px; }
.brand-mark {
  width: 42px; height: 42px; border-radius: var(--r-md);
  display: grid; place-items: center;
  background: linear-gradient(145deg, var(--primary), color-mix(in oklab, var(--primary) 60%, var(--tertiary)));
  color: var(--on-primary);
  box-shadow: var(--e2);
}
.brand-mark .material-symbols-rounded { font-size: 24px; font-variation-settings: 'FILL' 1, 'wght' 500; }
.brand-text h1 {
  font-size: 19px; font-weight: 600; line-height: 1.1;
  font-variation-settings: "opsz" 24, "wght" 600;
  letter-spacing: -0.01em;
}
.brand-sub {
  font-size: 11px; color: var(--on-surface-variant);
  font-variation-settings: "wght" 500; letter-spacing: .04em;
}

.server-pill {
  display: inline-flex; align-items: center; gap: 8px;
  padding: 7px 14px; border-radius: var(--r-full);
  background: var(--surface-c-high); border: 1px solid var(--outline-variant);
  font-size: 12px; font-weight: 500; color: var(--on-surface-variant);
  transition: all .3s;
}
.server-pill .dot {
  width: 8px; height: 8px; border-radius: 50%;
  background: var(--outline); transition: all .3s;
}
.server-pill.ok .dot { background: var(--success); box-shadow: 0 0 0 4px color-mix(in oklab, var(--success) 25%, transparent); }
.server-pill.err .dot { background: var(--error); }
.server-pill.busy .dot { background: #f5a623; animation: pulse 1.2s infinite; }
@keyframes pulse { 50% { opacity: .35; } }

/* ---------- 图标按钮 ---------- */
.icon-btn {
  width: 44px; height: 44px; border-radius: var(--r-full);
  display: grid; place-items: center;
  color: var(--on-surface-variant);
  position: relative; overflow: hidden;
  transition: background .2s, color .2s, transform .15s;
}
.icon-btn .material-symbols-rounded { font-size: 24px; font-variation-settings: 'wght' 400, 'GRAD' 0, 'opsz' 24; transition: font-variation-settings .25s, transform .25s; }
.icon-btn:hover { background: color-mix(in oklab, var(--on-surface) 8%, transparent); }
.icon-btn:active { background: color-mix(in oklab, var(--on-surface) 12%, transparent); transform: scale(.92); }
.icon-btn.sm { width: 36px; height: 36px; }
.icon-btn.sm .material-symbols-rounded { font-size: 20px; }
.icon-btn.success { color: var(--success); }
.icon-btn.success .material-symbols-rounded { font-variation-settings: 'FILL' 1, 'wght' 500; animation: pop-check .4s cubic-bezier(.2,1.4,.4,1); }
@keyframes pop-check { 0% { transform: scale(.6); } 60% { transform: scale(1.25); } 100% { transform: scale(1); } }

/* ---------- 按钮 ---------- */
.btn-filled, .btn-tonal, .btn-text {
  display: inline-flex; align-items: center; gap: 8px;
  height: 44px; padding: 0 24px; border-radius: var(--r-full);
  font-size: 14px; font-weight: 500; letter-spacing: .01em;
  position: relative; overflow: hidden;
  transition: box-shadow .2s, background .2s, transform .1s;
}
.btn-filled .material-symbols-rounded,
.btn-tonal .material-symbols-rounded,
.btn-text .material-symbols-rounded { font-size: 20px; }
.btn-filled {
  background: var(--primary); color: var(--on-primary);
  box-shadow: var(--e1);
}
.btn-filled:hover { box-shadow: var(--e2); background: color-mix(in oklab, var(--primary) 88%, #fff); transform: translateY(-1px); }
.btn-filled:active { transform: scale(.98); }
.btn-tonal {
  background: var(--secondary-container); color: var(--on-secondary-container);
}
.btn-tonal:hover { box-shadow: var(--e1); background: color-mix(in oklab, var(--secondary-container) 85%, var(--secondary)); transform: translateY(-1px); }
.btn-tonal:active { transform: scale(.98); }
.btn-text { color: var(--primary); padding: 0 16px; }
.btn-text:hover { background: color-mix(in oklab, var(--primary) 10%, transparent); }
.btn-text:active { transform: scale(.97); }

/* ---------- 布局 ---------- */
.layout {
  position: relative; z-index: 1;
  display: grid; grid-template-columns: 1fr 1fr;
  gap: 20px; padding: 20px 24px 130px;
  max-width: 1600px; margin: 0 auto;
  align-items: start;
}
.panel {
  background: var(--surface-c-low);
  border: 1px solid var(--outline-variant);
  border-radius: var(--r-xl);
  box-shadow: var(--e1);
  overflow: hidden;
  display: flex; flex-direction: column;
  animation: rise .6s cubic-bezier(.2,.7,.2,1) backwards;
}
.result-panel { animation-delay: .08s; }
@keyframes rise { from { opacity: 0; transform: translateY(14px); } }
.panel-head { padding: 20px 24px 0; position: relative; }
.panel-eyebrow {
  font-size: 11px; font-weight: 600; letter-spacing: .14em; text-transform: uppercase;
  color: var(--primary);
}
.panel-title {
  font-size: 26px; font-weight: 500; margin-top: 4px;
  font-variation-settings: "opsz" 32, "wght" 500; letter-spacing: -0.015em;
}
.add-more {
  position: absolute; top: 18px; right: 22px;
  background: var(--secondary-container); color: var(--on-secondary-container);
}
.add-more:hover { background: color-mix(in oklab, var(--secondary-container) 85%, var(--secondary)); }

/* ---------- 拖放区 / 舞台 ---------- */
.stage { margin: 18px 20px 20px; position: relative; }
.dropzone {
  border: 2px dashed var(--outline);
  border-radius: var(--r-lg);
  padding: 44px 24px; text-align: center;
  background: color-mix(in oklab, var(--primary) 4%, var(--surface-c-lowest));
  transition: all .3s;
  display: flex; flex-direction: column; align-items: center; gap: 6px;
  min-height: 340px; justify-content: center;
}
.dropzone.drag {
  border-color: var(--primary); border-style: solid;
  background: color-mix(in oklab, var(--primary) 12%, var(--surface-c-lowest));
  box-shadow: inset 0 0 0 4px color-mix(in oklab, var(--primary) 18%, transparent);
  transform: scale(1.008);
}
.dropzone.reject {
  border-color: var(--error); border-style: solid;
  background: color-mix(in oklab, var(--error) 10%, var(--surface-c-lowest));
  animation: shake .4s;
}
@keyframes shake {
  10%, 90% { transform: translateX(-1px); }
  20%, 80% { transform: translateX(2px); }
  30%, 50%, 70% { transform: translateX(-4px); }
  40%, 60% { transform: translateX(4px); }
}
.dropzone-icon {
  width: 76px; height: 76px; border-radius: var(--r-xl);
  display: grid; place-items: center;
  background: var(--primary-container); color: var(--on-primary-container);
  margin-bottom: 8px;
  animation: float 4s ease-in-out infinite;
}
@keyframes float { 50% { transform: translateY(-6px); } }
.dropzone-icon .material-symbols-rounded { font-size: 38px; font-variation-settings: 'FILL' 1, 'wght' 400; }
.dz-title { font-size: 20px; font-weight: 500; font-variation-settings: "opsz" 26, "wght" 500; }
.dz-sub { font-size: 13px; color: var(--on-surface-variant); margin-bottom: 14px; }
.dz-actions { display: flex; gap: 10px; flex-wrap: wrap; justify-content: center; }

.image-stage { display: flex; flex-direction: column; gap: 12px; }
.stage.drag { box-shadow: inset 0 0 0 3px color-mix(in oklab, var(--primary) 55%, transparent); border-radius: var(--r-md); }
.stage.reject { box-shadow: inset 0 0 0 3px color-mix(in oklab, var(--error) 55%, transparent); border-radius: var(--r-md); animation: shake .4s; }
.image-scroll {
  border-radius: var(--r-lg); overflow: auto;
  background:
    linear-gradient(45deg, var(--surface-c) 25%, transparent 25%) 0 0/16px 16px,
    linear-gradient(-45deg, var(--surface-c) 25%, transparent 25%) 0 8px/16px 16px,
    linear-gradient(45deg, transparent 75%, var(--surface-c) 75%) 8px -8px/16px 16px,
    linear-gradient(-45deg, transparent 75%, var(--surface-c) 75%) -8px 0/16px 16px,
    var(--surface-c-lowest);
  border: 1px solid var(--outline-variant);
  max-height: 560px; min-height: 320px;
  display: grid; place-items: center; padding: 16px;
}
.image-wrap {
  position: relative; display: inline-block; line-height: 0; max-width: 100%;
  transition: transform .25s cubic-bezier(.2,.8,.2,1);
  transform-origin: center center;
}
.image-wrap img {
  display: block; max-width: 100%; height: auto;
  border-radius: var(--r-sm);
  box-shadow: var(--e3);
}
.overlay {
  position: absolute; inset: 0; pointer-events: none;
  border-radius: var(--r-sm);
}
.bbox {
  position: absolute;
  border: 2px solid var(--primary);
  background: color-mix(in oklab, var(--primary) 22%, transparent);
  border-radius: 4px;
  transition: all .18s;
  pointer-events: auto;
  cursor: pointer;
  animation: bbox-in .3s cubic-bezier(.2,.8,.2,1) backwards;
}
@keyframes bbox-in { from { opacity: 0; transform: scale(.85); } }
.bbox:hover, .bbox.active {
  background: color-mix(in oklab, var(--tertiary) 35%, transparent);
  border-color: var(--tertiary);
  box-shadow: 0 0 0 2px color-mix(in oklab, var(--tertiary) 40%, transparent);
  z-index: 2;
}
.stage-toolbar {
  display: flex; align-items: center; gap: 12px;
  padding: 0 4px; font-size: 13px;
}
.filename { font-weight: 500; color: var(--on-surface); max-width: 220px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.dims { color: var(--on-surface-variant); font-family: "Roboto Mono", monospace; font-size: 12px; }
.region-count { color: var(--primary); font-weight: 500; font-size: 12px; transition: opacity .2s; }
.spacer { flex: 1; }
.zoom-group { display: flex; align-items: center; gap: 2px; }
.zoom-level {
  font-family: "Roboto Mono", monospace; font-size: 11.5px;
  color: var(--on-surface-variant); min-width: 38px; text-align: center;
  user-select: none;
}
.page-badge {
  font-size: 11px; font-weight: 600; padding: 3px 9px; border-radius: var(--r-full);
  background: var(--tertiary-container); color: var(--on-tertiary-container);
  white-space: nowrap;
}

/* ---------- 胶片带（多图 / 多页） ---------- */
.filmstrip {
  display: flex; gap: 8px; padding: 10px 4px 2px;
  overflow-x: auto; scrollbar-width: thin;
}
.filmstrip:empty { display: none; }
.film-item {
  position: relative; flex-shrink: 0;
  width: 56px; height: 56px; border-radius: var(--r-sm);
  overflow: hidden; cursor: pointer;
  border: 2px solid transparent;
  transition: border-color .2s, transform .15s;
  background: var(--surface-c-high);
}
.film-item img { width: 100%; height: 100%; object-fit: cover; display: block; }
.film-item:hover { transform: translateY(-2px); }
.film-item.active { border-color: var(--primary); }
.film-item .film-idx {
  position: absolute; left: 3px; bottom: 3px;
  font-size: 9px; font-weight: 700; line-height: 1;
  padding: 2px 4px; border-radius: 4px;
  background: color-mix(in oklab, black 55%, transparent); color: #fff;
}
.film-item .film-status {
  position: absolute; inset: 0; display: grid; place-items: center;
  background: color-mix(in oklab, var(--scrim-c, #000) 45%, transparent);
  color: #fff; opacity: 0;
  transition: opacity .2s;
}
.film-item .film-status .material-symbols-rounded { font-size: 20px; }
.film-item.pending .film-status { opacity: 1; }
.film-item.running .film-status { opacity: 1; }
.film-item.running .film-status .material-symbols-rounded { animation: spin .9s linear infinite; }
.film-item.done .film-status { opacity: 1; background: color-mix(in oklab, var(--success, #2e7d4f) 55%, transparent); }
.film-item.error .film-status { opacity: 1; background: color-mix(in oklab, var(--error) 55%, transparent); }
.film-remove {
  position: absolute; top: 2px; right: 2px;
  width: 18px; height: 18px; border-radius: 50%;
  background: color-mix(in oklab, black 60%, transparent); color: #fff;
  display: grid; place-items: center; opacity: 0;
  transition: opacity .15s, background .15s;
}
.film-remove .material-symbols-rounded { font-size: 13px; }
.film-item:hover .film-remove { opacity: 1; }
.film-remove:hover { background: var(--error); }
.film-add {
  flex-shrink: 0; width: 56px; height: 56px; border-radius: var(--r-sm);
  display: grid; place-items: center;
  border: 2px dashed color-mix(in oklab, var(--on-surface) 25%, transparent);
  color: var(--on-surface-variant);
  transition: border-color .2s, background .2s, color .2s;
}
.film-add:hover { border-color: var(--primary); color: var(--primary); background: color-mix(in oklab, var(--primary) 6%, transparent); }

/* ---------- 结果面板 ---------- */
.result-head {
  display: flex; align-items: center; justify-content: space-between;
  padding: 12px 12px 0; gap: 8px;
}
.tabs {
  position: relative; display: flex; gap: 4px;
  padding: 4px; border-radius: var(--r-full);
  background: var(--surface-c-high);
}
.tab {
  position: relative; z-index: 1;
  display: inline-flex; align-items: center; gap: 6px;
  padding: 9px 16px; border-radius: var(--r-full);
  font-size: 13px; font-weight: 500; color: var(--on-surface-variant);
  transition: color .25s;
}
.tab .material-symbols-rounded { font-size: 18px; }
.tab.active { color: var(--on-secondary-container); }
.tab-indicator {
  position: absolute; z-index: 0; top: 4px; bottom: 4px;
  background: var(--secondary-container);
  border-radius: var(--r-full);
  transition: left .35s cubic-bezier(.2,.8,.2,1), width .35s cubic-bezier(.2,.8,.2,1);
}
.result-actions { display: flex; gap: 2px; }

.result-body { flex: 1; min-height: 280px; padding: 8px 12px; }

/* 流式增量高亮：仅新追加的文本片段短暂淡入提示，不影响已渲染内容 */
.stream-new {
  animation: stream-fade-in .5s ease-out;
}
@keyframes stream-fade-in {
  from { opacity: 0; background: color-mix(in oklab, var(--primary) 16%, transparent); }
  to { opacity: 1; background: transparent; }
}
.tab-pane { display: none; height: 100%; animation: fade .35s; }
.tab-pane.active { display: block; }
@keyframes fade { from { opacity: 0; transform: translateY(6px); } }

.regions { display: flex; flex-direction: column; gap: 6px; max-height: 520px; overflow-y: auto; padding: 6px 4px; }
.region-item {
  display: flex; align-items: flex-start; gap: 12px;
  padding: 12px 14px; border-radius: var(--r-md);
  background: var(--surface-c); border: 1px solid transparent;
  transition: background .2s, border-color .2s, transform .2s; cursor: pointer;
  animation: item-in .32s cubic-bezier(.2,.8,.2,1) backwards;
}
@keyframes item-in { from { opacity: 0; transform: translateY(6px); } }
.region-item:hover, .region-item.active {
  background: var(--secondary-container);
  border-color: color-mix(in oklab, var(--secondary) 30%, transparent);
  transform: translateX(2px);
}
.region-item:focus-visible { outline-offset: -2px; }

/* 加载骨架屏 */
.skeleton-line {
  height: 14px; border-radius: var(--r-xs);
  background: linear-gradient(90deg,
    var(--surface-c-high) 25%,
    var(--surface-c-highest) 50%,
    var(--surface-c-high) 75%);
  background-size: 200% 100%;
  animation: shimmer 1.6s ease-in-out infinite;
}
@keyframes shimmer { 0% { background-position: 200% 0; } 100% { background-position: -200% 0; } }
.skeleton-item { display: flex; gap: 12px; padding: 12px 14px; align-items: center; }
.skeleton-idx { width: 26px; height: 26px; border-radius: 50%; flex-shrink: 0; }
.skeleton-body { flex: 1; display: flex; flex-direction: column; gap: 8px; }
.region-idx {
  flex-shrink: 0; width: 26px; height: 26px; border-radius: var(--r-full);
  display: grid; place-items: center; font-size: 11px; font-weight: 600;
  background: var(--primary); color: var(--on-primary);
  font-variation-settings: "wght" 600;
}
.region-item.active .region-idx { background: var(--tertiary); color: var(--on-tertiary); }
.region-body { flex: 1; min-width: 0; }
.region-text {
  font-size: 14px; line-height: 1.5; word-break: break-word;
  white-space: pre-wrap;
}
.region-coord {
  font-family: "Roboto Mono", monospace; font-size: 10.5px;
  color: var(--on-surface-variant); margin-top: 3px;
}

.placeholder, .placeholder-text {
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  gap: 8px; height: 100%; min-height: 240px;
  color: var(--on-surface-variant); text-align: center;
  animation: fade .4s ease;
}
.placeholder .material-symbols-rounded {
  font-size: 44px; opacity: .5; font-variation-settings: 'FILL' 1;
  animation: breathe 3s ease-in-out infinite;
}
@keyframes breathe { 50% { opacity: .3; transform: scale(.96); } }
.placeholder p { font-size: 15px; font-weight: 500; color: var(--on-surface); }
.placeholder .hint { font-size: 12px; }
.placeholder-text { color: var(--on-surface-variant); font-style: italic; }

.text-out, .raw-out {
  font-family: "Roboto Mono", monospace; font-size: 13px; line-height: 1.65;
  padding: 14px 16px; border-radius: var(--r-md);
  background: var(--surface-c-lowest); border: 1px solid var(--outline-variant);
  white-space: pre-wrap; word-break: break-word; max-height: 520px; overflow: auto;
  color: var(--on-surface);
}
.raw-out { font-size: 12px; }

.result-foot {
  display: flex; flex-wrap: wrap; gap: 8px;
  padding: 14px 16px; border-top: 1px solid var(--outline-variant);
  background: var(--surface-c-low);
}
.stat {
  display: flex; flex-direction: column; gap: 2px;
  padding: 6px 14px; border-radius: var(--r-sm);
  background: var(--surface-c-high);
  min-width: 84px;
  transition: background .2s;
}
.stat-k { font-size: 10px; font-weight: 600; letter-spacing: .08em; text-transform: uppercase; color: var(--on-surface-variant); }
.stat-v {
  font-size: 14px; font-weight: 500; font-family: "Roboto Mono", monospace; color: var(--on-surface);
  display: inline-block;
}
.stat-v.updated { animation: stat-pop .4s cubic-bezier(.2,1.2,.3,1); }
@keyframes stat-pop {
  0% { transform: translateY(-4px); opacity: 0; }
  100% { transform: translateY(0); opacity: 1; }
}

/* ---------- FAB ---------- */
.fab {
  position: fixed; z-index: 30;
  bottom: 28px; left: 50%; transform: translateX(-50%);
  display: inline-flex; align-items: center; gap: 10px;
  height: 56px; padding: 0 28px 0 22px;
  border-radius: var(--r-xl);
  background: var(--primary); color: var(--on-primary);
  font-size: 15px; font-weight: 500; letter-spacing: .02em;
  box-shadow: var(--e4);
  transition: box-shadow .25s, transform .15s, background .25s;
}
.fab:hover { box-shadow: var(--e5); background: color-mix(in oklab, var(--primary) 88%, #fff); transform: translateX(-50%) translateY(-2px); }
.fab:active { transform: translateX(-50%) scale(.97); }
.fab .material-symbols-rounded { font-size: 26px; font-variation-settings: 'FILL' 1, 'wght' 400; }
.fab.running { background: var(--surface-c-highest); color: var(--on-surface); box-shadow: var(--e3); }
.fab.running:hover { transform: translateX(-50%); }
.fab.disabled { opacity: .5; box-shadow: var(--e1); pointer-events: none; }
.fab-spinner .material-symbols-rounded { font-size: 24px; }
.spin { animation: spin .9s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }

/* ---------- 进度条 ---------- */
.progress-rail {
  position: fixed; top: 0; left: 0; right: 0; height: 3px;
  z-index: 60; background: transparent; overflow: hidden;
}
.progress-bar {
  height: 100%; width: 40%;
  background: linear-gradient(90deg, transparent, var(--primary), transparent);
  animation: indet 1.3s ease-in-out infinite;
}
@keyframes indet {
  0% { transform: translateX(-100%); }
  100% { transform: translateX(350%); }
}

/* ---------- 输入字段 ---------- */
.field { display: flex; flex-direction: column; gap: 7px; flex: 1; }
.field-label { font-size: 12px; font-weight: 500; color: var(--on-surface-variant); letter-spacing: .01em; }
.field-hint { font-size: 11px; color: var(--outline); }
.input {
  width: 100%; padding: 13px 16px;
  border-radius: var(--r-sm);
  border: 1px solid var(--outline-variant);
  background: var(--surface-c-lowest);
  font-size: 14px; color: var(--on-surface);
  transition: border .2s, box-shadow .2s, background .2s;
  outline: none;
}
.input:focus {
  border-color: var(--primary);
  box-shadow: 0 0 0 3px color-mix(in oklab, var(--primary) 22%, transparent);
  background: var(--surface-c-lowest);
}
textarea.input { resize: vertical; min-height: 56px; line-height: 1.5; font-family: "Roboto Mono", monospace; font-size: 12.5px; }
.field-row { display: flex; gap: 14px; }

/* 开关 */
.switch-row {
  display: flex; align-items: center; justify-content: space-between;
  padding: 8px 4px;
}
.switch { position: relative; display: inline-block; }
.switch input { position: absolute; opacity: 0; width: 100%; height: 100%; cursor: pointer; }
.track {
  display: block; width: 52px; height: 32px; border-radius: var(--r-full);
  background: var(--surface-c-highest); border: 2px solid var(--outline);
  transition: all .25s; position: relative;
}
.thumb {
  position: absolute; top: 50%; left: 8px; transform: translateY(-50%);
  width: 16px; height: 16px; border-radius: 50%;
  background: var(--outline); transition: all .25s cubic-bezier(.2,.8,.2,1);
}
.switch input:checked + .track { background: var(--primary); border-color: var(--primary); }
.switch input:checked + .track .thumb { left: 26px; width: 24px; height: 24px; background: var(--on-primary); }

/* ---------- 对话框 / 遮罩 ---------- */
.scrim {
  position: fixed; inset: 0; z-index: 70;
  background: var(--scrim-c);
  backdrop-filter: blur(2px);
  animation: fade-in .25s;
}
.dialog {
  position: fixed; z-index: 80; top: 50%; left: 50%;
  transform: translate(-50%, -50%);
  width: min(520px, calc(100vw - 32px));
  background: var(--surface-c-high);
  border-radius: var(--r-xl);
  box-shadow: var(--e5);
  padding: 24px;
  animation: dialog-in .35s cubic-bezier(.2,.8,.2,1);
}
@keyframes fade-in { from { opacity: 0; } }
@keyframes dialog-in { from { opacity: 0; transform: translate(-50%, -46%) scale(.96); } }
.dialog-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 18px; }
.dialog-title { font-size: 22px; font-weight: 500; font-variation-settings: "opsz" 28, "wght" 500; }
.dialog-body { display: flex; flex-direction: column; gap: 16px; }
.dialog-actions { display: flex; align-items: center; justify-content: flex-end; gap: 8px; margin-top: 22px; }
.dialog-actions .spacer { flex: 1; }

/* ---------- 弹出层 (主题色) ---------- */
.popover {
  position: fixed; z-index: 75; top: 60px; right: 24px;
  width: 280px; padding: 18px;
  background: var(--surface-c-high);
  border: 1px solid var(--outline-variant);
  border-radius: var(--r-lg);
  box-shadow: var(--e4);
  animation: pop-in .25s cubic-bezier(.2,.8,.2,1);
}
@keyframes pop-in { from { opacity: 0; transform: translateY(-8px); } }
.pop-head { margin-bottom: 14px; }
.pop-head h3 { font-size: 16px; font-weight: 600; font-variation-settings: "wght" 600; }
.pop-sub { font-size: 11px; color: var(--on-surface-variant); }
.seeds { display: grid; grid-template-columns: repeat(5, 1fr); gap: 10px; margin-bottom: 14px; }
.seed {
  aspect-ratio: 1; border-radius: var(--r-full);
  cursor: pointer; position: relative;
  border: 3px solid transparent;
  transition: transform .15s, border-color .2s;
  box-shadow: var(--e1);
}
.seed:hover { transform: scale(1.1); }
.seed.active { border-color: var(--on-surface); }
.seed.active::after {
  content: 'check';
  font-family: 'Material Symbols Rounded';
  position: absolute; inset: 0; display: grid; place-items: center;
  color: #fff; font-size: 18px; font-variation-settings: 'FILL' 1, 'wght' 600;
}
.custom-seed {
  display: flex; align-items: center; justify-content: space-between;
  padding-top: 12px; border-top: 1px solid var(--outline-variant);
  font-size: 13px; font-weight: 500;
}
.custom-seed input[type=color] {
  width: 40px; height: 40px; border: none; border-radius: var(--r-full);
  background: none; cursor: pointer; padding: 0;
}
.custom-seed input[type=color]::-webkit-color-swatch-wrapper { padding: 0; }
.custom-seed input[type=color]::-webkit-color-swatch { border: 2px solid var(--outline-variant); border-radius: var(--r-full); }

/* ---------- 通知条 ---------- */
.snackbar {
  position: fixed; z-index: 90; bottom: 100px; left: 50%;
  transform: translateX(-50%) translateY(20px);
  padding: 13px 20px; border-radius: var(--r-sm);
  background: var(--inverse-surface); color: var(--inverse-on-surface);
  font-size: 13.5px; font-weight: 500;
  box-shadow: var(--e4); opacity: 0;
  pointer-events: none; transition: all .35s cubic-bezier(.2,.8,.2,1);
  max-width: 90vw;
}
.snackbar.show { opacity: 1; transform: translateX(-50%) translateY(0); }

/* ---------- 响应式 ---------- */
@media (max-width: 960px) {
  .layout { grid-template-columns: 1fr; padding: 16px 14px 140px; }
  .top-app-bar { padding: 12px 14px; }
  .brand-sub { display: none; }
  .server-pill .label { display: none; }
  .server-pill { padding: 7px; }
  .fab { padding: 0 22px 0 18px; height: 52px; }
  .panel-title { font-size: 22px; }
  .image-scroll { max-height: 420px; }
}
@media (max-width: 560px) {
  .brand-text h1 { font-size: 16px; }
  .tab { padding: 8px 12px; font-size: 12px; }
  .tab .material-symbols-rounded { font-size: 16px; }
  .fab-label { display: none; }
  .fab { padding: 0; width: 56px; justify-content: center; border-radius: var(--r-full); }
  .result-foot { gap: 6px; }
  .stat { min-width: 70px; padding: 5px 10px; }
}

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