:root {
  --bg: #0b1220;
  --bg2: #121a2b;
  --card: rgba(22, 32, 52, 0.88);
  --line: rgba(148, 163, 184, 0.16);
  --text: #e8eef9;
  --muted: #93a4c3;
  --primary: #3b82f6;
  --primary2: #60a5fa;
  --ok: #22c55e;
  --ok-bg: rgba(34, 197, 94, 0.14);
  --bad: #f43f5e;
  --bad-bg: rgba(244, 63, 94, 0.12);
  --warn: #f59e0b;
  --priority: #a3e635;
  --radius: 16px;
  --shadow: 0 18px 50px rgba(0, 0, 0, 0.35);
  --font: "Noto Sans SC", "PingFang SC", "Microsoft YaHei", system-ui, sans-serif;
}

* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
body {
  font-family: var(--font);
  color: var(--text);
  background: var(--bg);
  min-height: 100vh;
  min-height: 100dvh;
  line-height: 1.55;
  -webkit-text-size-adjust: 100%;
  text-size-adjust: 100%;
  padding-left: env(safe-area-inset-left);
  padding-right: env(safe-area-inset-right);
}

.bg-grid {
  position: fixed; inset: 0; pointer-events: none; z-index: 0;
  background-image:
    linear-gradient(rgba(255,255,255,0.03) 1px, transparent 1px),
    linear-gradient(90deg, rgba(255,255,255,0.03) 1px, transparent 1px);
  background-size: 48px 48px;
  mask-image: radial-gradient(ellipse at center, black 30%, transparent 75%);
}
.bg-glow {
  position: fixed; inset: 0; pointer-events: none; z-index: 0;
  background:
    radial-gradient(600px 300px at 15% 10%, rgba(59,130,246,0.22), transparent 60%),
    radial-gradient(500px 280px at 90% 20%, rgba(34,197,94,0.12), transparent 55%),
    radial-gradient(400px 240px at 50% 100%, rgba(168,85,247,0.1), transparent 50%);
}

.topbar, .layout, .footer { position: relative; z-index: 1; }

.topbar {
  display: flex; align-items: center; justify-content: space-between;
  padding: 20px 28px 8px; max-width: 1400px; margin: 0 auto;
}
.brand { display: flex; gap: 14px; align-items: center; }
.logo {
  width: 48px; height: 48px; border-radius: 14px;
  display: grid; place-items: center;
  background: linear-gradient(135deg, #3b82f6, #22c55e);
  font-weight: 700; font-size: 20px; color: #fff;
  box-shadow: 0 8px 24px rgba(59,130,246,0.35);
}
.brand h1 { margin: 0; font-size: 1.25rem; font-weight: 700; letter-spacing: 0.02em; }
.brand p { margin: 2px 0 0; color: var(--muted); font-size: 0.85rem; }
.top-meta {
  font-size: 0.82rem; color: var(--muted);
  padding: 8px 12px; border: 1px solid var(--line); border-radius: 999px;
  background: rgba(255,255,255,0.03);
}

.layout {
  display: grid;
  grid-template-columns: minmax(340px, 460px) 1fr;
  gap: 20px;
  max-width: 1400px;
  margin: 12px auto 40px;
  padding: 0 20px;
}

.panel {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  backdrop-filter: blur(12px);
  padding: 20px;
}
.panel h2 {
  margin: 0 0 12px;
  font-size: 1rem;
  font-weight: 600;
  color: #dbe7ff;
}
.panel-form h2 { margin-top: 18px; }
.panel-form h2:first-child { margin-top: 0; }

.form-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
}
.form-grid-3 { grid-template-columns: 1fr 1fr 1fr; }
.form-grid .span-2 { grid-column: span 2; }

label { display: flex; flex-direction: column; gap: 6px; font-size: 0.85rem; color: var(--muted); }
label em { color: var(--bad); font-style: normal; }
input, textarea {
  width: 100%;
  border: 1px solid var(--line);
  background: rgba(8, 14, 26, 0.7);
  color: var(--text);
  border-radius: 12px;
  padding: 10px 12px;
  font: inherit;
  font-size: 16px; /* 防止 iOS 聚焦自动放大 */
  outline: none;
  transition: border-color .15s, box-shadow .15s;
  -webkit-appearance: none;
  appearance: none;
}
input:focus, textarea:focus {
  border-color: rgba(59,130,246,0.7);
  box-shadow: 0 0 0 3px rgba(59,130,246,0.18);
}
textarea { resize: vertical; min-height: 140px; }

.tabs {
  display: flex; gap: 6px; margin-bottom: 12px;
  background: rgba(0,0,0,0.22);
  padding: 4px; border-radius: 12px;
}
.tab {
  flex: 1; border: 0; background: transparent; color: var(--muted);
  padding: 9px 8px; border-radius: 10px; cursor: pointer; font: inherit; font-size: 0.88rem;
}
.tab.active {
  background: linear-gradient(180deg, rgba(59,130,246,0.35), rgba(59,130,246,0.18));
  color: #fff; font-weight: 600;
}
.tab-panel { display: none; }
.tab-panel.active { display: block; }

.dropzone {
  border: 1.5px dashed rgba(148,163,184,0.35);
  border-radius: 14px;
  padding: 28px 16px;
  text-align: center;
  cursor: pointer;
  transition: border-color .15s, background .15s;
  background: rgba(0,0,0,0.15);
}
.dropzone:hover, .dropzone.dragover {
  border-color: var(--primary2);
  background: rgba(59,130,246,0.08);
}
.dz-icon { font-size: 28px; margin-bottom: 6px; }
.dropzone p { margin: 4px 0; }
.muted { color: var(--muted); font-size: 0.84rem; }

.info-chip {
  margin-top: 10px;
  padding: 10px 12px;
  border-radius: 12px;
  background: rgba(59,130,246,0.12);
  border: 1px solid rgba(59,130,246,0.25);
  font-size: 0.88rem;
}
.info-chip.ok {
  background: rgba(34,197,94,0.12);
  border-color: rgba(34,197,94,0.35);
  color: #bbf7d0;
}
.info-chip.bad {
  background: rgba(244,63,94,0.12);
  border-color: rgba(244,63,94,0.4);
  color: #fecdd3;
}
.hidden { display: none !important; }

.notice-box {
  margin: 0 0 16px;
  padding: 12px 14px;
  border-radius: 12px;
  background: rgba(245,158,11,0.1);
  border: 1px solid rgba(245,158,11,0.35);
  font-size: 0.86rem;
  color: #fde68a;
  line-height: 1.55;
}
.notice-box strong { display: block; margin-bottom: 6px; color: #fbbf24; }
.notice-box ol { margin: 0; padding-left: 1.2em; }
.notice-box li { margin: 4px 0; }
.notice-alt { margin: 8px 0 0; color: #93a4c3; font-size: 0.82rem; }

.pdf-block {
  margin-top: 10px;
  padding: 12px;
  border-radius: 12px;
  background: rgba(244,63,94,0.12);
  border: 1px solid rgba(244,63,94,0.45);
  color: #fecdd3;
  font-size: 0.88rem;
  line-height: 1.55;
}
.pdf-block strong { color: #fda4af; }
.pdf-block .actions-inline {
  display: flex; flex-wrap: wrap; gap: 8px; margin-top: 10px;
}
.pdf-block .btn-mini {
  border: 0; border-radius: 10px; padding: 8px 12px;
  font: inherit; font-size: 0.85rem; font-weight: 600; cursor: pointer;
  background: rgba(59,130,246,0.25); color: #dbeafe;
}
.pdf-block .btn-mini.danger {
  background: rgba(244,63,94,0.25); color: #fecdd3;
}

.done-banner.unreliable {
  background: rgba(244,63,94,0.16) !important;
  border-color: rgba(244,63,94,0.45) !important;
  color: #fecdd3;
}
.done-banner.success {
  background: rgba(34,197,94,0.16) !important;
  border-color: rgba(34,197,94,0.4) !important;
  color: #bbf7d0;
}

.ai-panel {
  margin-top: 14px;
  padding: 14px;
  border-radius: 14px;
  border: 1px solid rgba(168,85,247,0.35);
  background: linear-gradient(135deg, rgba(168,85,247,0.12), rgba(59,130,246,0.08));
}
.ai-toolbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  flex-wrap: wrap;
  margin-bottom: 10px;
}
.ai-toolbar strong { color: #e9d5ff; font-size: 1rem; }
.ai-toolbar .muted { display: block; font-size: 0.78rem; color: var(--muted); margin-top: 2px; }
.ai-panel textarea {
  width: 100%;
  min-height: 64px;
  margin-bottom: 10px;
  font-size: 14px;
}
.ai-result {
  padding: 12px 14px;
  border-radius: 12px;
  background: rgba(0,0,0,0.28);
  border: 1px solid var(--line);
  font-size: 0.9rem;
  line-height: 1.65;
  color: #e8eef9;
  max-height: 480px;
  overflow: auto;
  white-space: pre-wrap;
  word-break: break-word;
}
.ai-result h1, .ai-result h2, .ai-result h3 {
  margin: 12px 0 6px;
  font-size: 1rem;
  color: #ddd6fe;
}
.ai-result h1 { font-size: 1.05rem; }
.ai-result p { margin: 6px 0; }
.ai-result ul, .ai-result ol { margin: 6px 0 6px 1.2em; padding: 0; }
.ai-result li { margin: 3px 0; }
.ai-result strong { color: #f5d0fe; }
.ai-result.loading { color: var(--muted); font-style: italic; }

.btn {
  border: 0; border-radius: 12px; padding: 11px 16px;
  font: inherit; font-weight: 600; cursor: pointer;
  transition: transform .12s, opacity .12s, background .12s;
}
.btn:active { transform: scale(0.98); }
.btn:disabled { opacity: 0.45; cursor: not-allowed; transform: none; }
.btn-primary {
  width: 100%;
  background: linear-gradient(135deg, #2563eb, #16a34a);
  color: #fff;
  box-shadow: 0 10px 28px rgba(37,99,235,0.28);
}
.btn-primary:hover:not(:disabled) { filter: brightness(1.06); }
.btn-secondary {
  margin-top: 10px;
  background: rgba(59,130,246,0.18);
  color: #dbeafe;
  border: 1px solid rgba(59,130,246,0.3);
}
.btn-ghost {
  background: transparent;
  color: var(--muted);
  border: 1px solid var(--line);
}
.btn-text {
  background: transparent; border: 0; color: var(--muted);
  cursor: pointer; font: inherit; font-size: 0.85rem;
}
.btn-text:hover { color: var(--bad); }

.vol-toolbar {
  display: flex; align-items: center; justify-content: space-between;
  margin-top: 8px;
}
.vol-toolbar h2 { margin: 0; }
.badge {
  display: inline-grid; place-items: center;
  min-width: 24px; height: 22px; padding: 0 7px;
  border-radius: 999px; font-size: 0.78rem;
  background: rgba(59,130,246,0.25); color: #bfdbfe;
  vertical-align: middle; margin-left: 6px;
}

.vol-list {
  max-height: 220px; overflow: auto;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: rgba(0,0,0,0.18);
  margin-top: 8px;
}
.vol-item {
  display: grid;
  grid-template-columns: 42px 1fr auto;
  gap: 8px;
  align-items: center;
  padding: 8px 10px;
  border-bottom: 1px solid var(--line);
  font-size: 0.86rem;
}
.vol-item:last-child { border-bottom: 0; }
.vol-item .no {
  color: var(--primary2); font-weight: 700; font-variant-numeric: tabular-nums;
}
.vol-item .name { min-width: 0; }
.vol-item .name strong { display: block; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.vol-item .name span { color: var(--muted); font-size: 0.78rem; }
.vol-item .rm {
  border: 0; background: transparent; color: var(--muted); cursor: pointer; font-size: 1rem;
}
.vol-item .rm:hover { color: var(--bad); }

.empty {
  padding: 28px 16px; text-align: center; color: var(--muted); font-size: 0.9rem;
}

.actions {
  display: grid; grid-template-columns: 1fr auto; gap: 10px;
  margin-top: 16px;
}
.hint {
  margin: 12px 0 0;
  font-size: 0.78rem;
  color: var(--muted);
  line-height: 1.6;
}

/* 结果区 */
.panel-result { min-height: 70vh; display: flex; flex-direction: column; }
.result-header {
  display: flex; align-items: center; justify-content: space-between; gap: 12px;
  margin-bottom: 12px;
}
.result-header h2 { margin: 0; }
.progress-wrap {
  display: flex; align-items: center; gap: 10px; min-width: 180px;
  font-size: 0.82rem; color: var(--muted); font-variant-numeric: tabular-nums;
}
.progress-bar {
  flex: 1; height: 8px; border-radius: 999px; background: rgba(255,255,255,0.08); overflow: hidden;
}
.progress-fill {
  height: 100%; width: 0%;
  background: linear-gradient(90deg, #3b82f6, #22c55e);
  transition: width .35s ease;
}

.priority-card {
  display: flex; gap: 14px; align-items: stretch;
  padding: 14px 16px;
  border-radius: 14px;
  margin-bottom: 14px;
  background: linear-gradient(135deg, rgba(34,197,94,0.2), rgba(163,230,53,0.12));
  border: 1px solid rgba(34,197,94,0.4);
  animation: popIn .45s ease;
}
.priority-tag {
  writing-mode: vertical-rl;
  letter-spacing: 0.2em;
  font-weight: 700;
  color: #052e16;
  background: var(--priority);
  border-radius: 10px;
  padding: 8px 6px;
  display: grid; place-items: center;
}
.priority-vol { font-size: 0.85rem; color: #bbf7d0; }
.priority-name { font-size: 1.15rem; font-weight: 700; margin: 4px 0; }
.priority-meta { font-size: 0.85rem; color: #d1fae5; }

.stats {
  display: grid; grid-template-columns: repeat(4, 1fr); gap: 8px;
  margin-bottom: 12px;
}
.stat {
  text-align: center;
  padding: 10px 6px;
  border-radius: 12px;
  background: rgba(255,255,255,0.04);
  border: 1px solid var(--line);
}
.stat .n { display: block; font-size: 1.25rem; font-weight: 700; font-variant-numeric: tabular-nums; }
.stat .l { font-size: 0.75rem; color: var(--muted); }
.stat.yes .n { color: var(--ok); }
.stat.no .n { color: var(--bad); }

.live-query {
  font-size: 0.88rem;
  color: var(--muted);
  margin-bottom: 10px;
  padding: 8px 12px;
  border-radius: 10px;
  background: rgba(59,130,246,0.1);
  border: 1px solid rgba(59,130,246,0.2);
}
.live-query strong { color: var(--primary2); }

.result-list {
  flex: 1;
  overflow: auto;
  max-height: calc(100vh - 320px);
  min-height: 280px;
  padding-right: 4px;
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.result-card {
  border-radius: 14px;
  border: 1px solid var(--line);
  background: rgba(8, 14, 26, 0.55);
  padding: 12px 14px;
  animation: slideIn .4s ease;
  display: grid;
  grid-template-columns: 52px 1fr auto;
  gap: 10px;
  align-items: start;
}
.result-card.yes { border-color: rgba(34,197,94,0.35); background: var(--ok-bg); }
.result-card.no { border-color: rgba(244,63,94,0.25); background: var(--bad-bg); }
.result-card.priority {
  border-color: rgba(163,230,53,0.7);
  box-shadow: 0 0 0 1px rgba(163,230,53,0.35), 0 12px 30px rgba(34,197,94,0.15);
  background: linear-gradient(135deg, rgba(34,197,94,0.22), rgba(163,230,53,0.1));
}
.result-card .num {
  width: 48px; height: 48px; border-radius: 12px;
  display: grid; place-items: center;
  font-weight: 800; font-size: 1rem;
  background: rgba(255,255,255,0.06);
  font-variant-numeric: tabular-nums;
}
.result-card.yes .num { color: #86efac; background: rgba(34,197,94,0.18); }
.result-card.no .num { color: #fda4af; background: rgba(244,63,94,0.15); }
.result-card.priority .num { color: #052e16; background: var(--priority); }
.result-card .title { font-weight: 700; font-size: 0.98rem; }
.result-card .sub { color: var(--muted); font-size: 0.82rem; margin-top: 2px; }
.result-card .meta {
  display: flex; flex-wrap: wrap; gap: 6px 10px;
  margin-top: 8px; font-size: 0.78rem; color: var(--muted);
}
.result-card .meta b { color: #c7d2fe; font-weight: 600; }
.result-card .tag {
  justify-self: end;
  align-self: start;
  font-size: 0.78rem;
  font-weight: 700;
  padding: 5px 10px;
  border-radius: 999px;
  white-space: nowrap;
}
.tag.yes { background: rgba(34,197,94,0.2); color: #86efac; }
.tag.no { background: rgba(244,63,94,0.18); color: #fda4af; }
.tag.priority { background: var(--priority); color: #052e16; }
.tag.other { background: rgba(148,163,184,0.15); color: #cbd5e1; }

.done-banner {
  margin-top: 12px;
  padding: 12px 14px;
  border-radius: 12px;
  background: rgba(59,130,246,0.15);
  border: 1px solid rgba(59,130,246,0.3);
  font-weight: 600;
  animation: popIn .4s ease;
}

.footer {
  text-align: center;
  color: var(--muted);
  font-size: 0.78rem;
  padding: 0 16px 28px;
}

@keyframes slideIn {
  from { opacity: 0; transform: translateY(14px) scale(0.98); }
  to { opacity: 1; transform: none; }
}
@keyframes popIn {
  from { opacity: 0; transform: scale(0.96); }
  to { opacity: 1; transform: none; }
}

/* 滚动条 */
.vol-list::-webkit-scrollbar,
.result-list::-webkit-scrollbar { width: 8px; }
.vol-list::-webkit-scrollbar-thumb,
.result-list::-webkit-scrollbar-thumb {
  background: rgba(148,163,184,0.25); border-radius: 999px;
}

/* 手机底栏默认隐藏，窄屏显示 */
.mobile-bar {
  display: none;
  position: fixed;
  left: 0; right: 0; bottom: 0;
  z-index: 50;
  padding: 10px 12px calc(10px + env(safe-area-inset-bottom));
  background: rgba(11, 18, 32, 0.92);
  border-top: 1px solid var(--line);
  backdrop-filter: blur(14px);
  -webkit-backdrop-filter: blur(14px);
  box-shadow: 0 -10px 30px rgba(0,0,0,0.35);
}
.mobile-bar-info {
  font-size: 0.78rem;
  color: var(--muted);
  margin-bottom: 8px;
  display: flex;
  gap: 6px;
  align-items: center;
  flex-wrap: wrap;
}
.mobile-bar-info .sep { opacity: 0.5; }
.mobile-bar-btns {
  display: grid;
  grid-template-columns: 88px 1fr;
  gap: 8px;
}
.mobile-bar-btns .btn { min-height: 46px; padding: 12px 14px; }
.mobile-bar-btns .btn-primary { width: 100%; }

@media (max-width: 960px) {
  .layout { grid-template-columns: 1fr; padding-bottom: 100px; }
  .panel-result { min-height: auto; }
  .result-list { max-height: none; min-height: 200px; }
  .topbar {
    flex-direction: column;
    align-items: flex-start;
    gap: 10px;
    padding: 14px 16px 4px;
  }
  .brand h1 { font-size: 1.1rem; }
  .top-meta { font-size: 0.75rem; max-width: 100%; }
  .form-grid, .form-grid-3 { grid-template-columns: 1fr 1fr; }
  .form-grid .span-2 { grid-column: span 2; }
  .stats { grid-template-columns: repeat(2, 1fr); }
  .actions-desktop { display: none; }
  .mobile-bar { display: block; }
  .footer { padding-bottom: 100px; }
  .panel { padding: 16px; border-radius: 14px; }
  .tabs { overflow-x: auto; -webkit-overflow-scrolling: touch; }
  .tab { white-space: nowrap; min-width: 0; font-size: 0.82rem; padding: 10px 6px; }
  .dropzone { padding: 22px 12px; }
  .priority-card { flex-direction: column; gap: 10px; }
  .priority-tag {
    writing-mode: horizontal-tb;
    letter-spacing: 0.12em;
    width: fit-content;
    padding: 6px 12px;
  }
  .priority-name { font-size: 1.02rem; word-break: break-word; }
  .result-header { flex-direction: column; align-items: stretch; gap: 8px; }
  .progress-wrap { min-width: 0; width: 100%; }
}

@media (max-width: 560px) {
  .layout { padding: 0 12px 110px; gap: 14px; margin-top: 8px; }
  .form-grid, .form-grid-3 { grid-template-columns: 1fr; }
  .form-grid .span-2 { grid-column: auto; }
  .result-card {
    grid-template-columns: 40px 1fr;
    padding: 12px;
    gap: 8px;
  }
  .result-card .num { width: 40px; height: 40px; font-size: 0.9rem; border-radius: 10px; }
  .result-card .tag {
    grid-column: 1 / -1;
    justify-self: start;
    margin-top: 2px;
  }
  .result-card .title { font-size: 0.92rem; word-break: break-word; }
  .result-card .meta { gap: 4px 8px; }
  .vol-list { max-height: 180px; }
  .btn { min-height: 44px; }
  .logo { width: 42px; height: 42px; border-radius: 12px; font-size: 18px; }
}

/* 横屏小高度手机 */
@media (max-height: 500px) and (orientation: landscape) {
  .mobile-bar { padding: 6px 12px; }
  .mobile-bar-info { display: none; }
  .layout { padding-bottom: 70px; }
}
