:root {
  --bg: #0f1419;
  --surface: #1a2332;
  --surface2: #243044;
  --border: #2d3a4f;
  --text: #e8edf4;
  --muted: #8b9bb0;
  --accent: #3d8bfd;
  --accent-dim: rgba(61, 139, 253, 0.2);
  --ok: #3ecf8e;
  --warn: #f0b429;
  --err: #f87171;
  --radius: 12px;
  --font: "SF Pro Text", "Segoe UI", system-ui, -apple-system, sans-serif;
}

* { box-sizing: border-box; }
body {
  margin: 0;
  min-height: 100vh;
  font-family: var(--font);
  background: linear-gradient(165deg, #0c1018 0%, #151c28 45%, #0f1419 100%);
  color: var(--text);
  line-height: 1.5;
}

.wrap {
  max-width: 1040px;
  margin: 0 auto;
  padding: 24px 16px 32px;
  display: flex;
  flex-direction: column;
  gap: 16px;
  min-height: 100vh;
}

header h1 {
  margin: 0 0 6px;
  font-size: 1.35rem;
  font-weight: 600;
  letter-spacing: -0.02em;
}
header p {
  margin: 0;
  color: var(--muted);
  font-size: 0.9rem;
}

.topbar {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
}

.topbar-actions {
  display: flex;
  gap: 8px;
  margin-top: 4px;
}

.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 18px 20px;
  box-shadow: 0 8px 32px rgba(0, 0, 0, 0.35);
}

.card h3 {
  margin: 0 0 8px;
  font-size: 1rem;
  font-weight: 600;
}

.admin-section {
  border-left: 3px solid rgba(61, 139, 253, 0.45);
}

.section-desc {
  margin: 4px 0 0;
  font-size: 0.82rem;
  color: var(--muted);
}

#login-card {
  max-width: 560px;
  margin: 24px auto 0;
}

#login-card form:not([hidden]) {
  display: grid;
  gap: 12px;
}

#login-card form[hidden] {
  display: none !important;
}

#log-view {
  margin: 0;
  padding: 12px;
  max-height: 300px;
  overflow: auto;
  border-radius: 8px;
  background: #0b111a;
  border: 1px solid var(--border);
  color: #c8d5e8;
  font-size: 12px;
  line-height: 1.5;
}

.form-row {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 12px;
  margin-top: 12px;
}
.form-row:first-child { margin-top: 0; }

input[type="file"] {
  flex: 1;
  min-width: 200px;
  font-size: 0.875rem;
  color: var(--text);
}
input[type="file"]::file-selector-button {
  margin-right: 12px;
  padding: 8px 14px;
  border-radius: 8px;
  border: 1px solid var(--border);
  background: var(--surface2);
  color: var(--text);
  cursor: pointer;
  font-size: 0.85rem;
}
input[type="file"]::file-selector-button:hover {
  background: #2c3a52;
}

button[type="submit"] {
  padding: 10px 20px;
  border-radius: 8px;
  border: none;
  background: var(--accent);
  color: #fff;
  font-weight: 600;
  font-size: 0.9rem;
  cursor: pointer;
  transition: filter 0.15s, transform 0.1s;
}
button[type="submit"]:hover:not(:disabled) {
  filter: brightness(1.08);
}
button[type="submit"]:disabled {
  opacity: 0.55;
  cursor: not-allowed;
}

.ghost-btn {
  padding: 9px 14px;
  border-radius: 8px;
  border: 1px solid var(--border);
  background: transparent;
  color: #d5deeb;
  cursor: pointer;
  font-size: 0.85rem;
}

.ghost-btn:hover {
  background: rgba(255, 255, 255, 0.06);
}

.mode-switch {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 10px;
  width: 100%;
}

.form-band {
  padding: 14px 14px 16px;
  border: 1px solid rgba(255, 255, 255, 0.08);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.025);
  margin-top: 14px;
}

.form-band:first-child {
  margin-top: 0;
}

.form-band-mode {
  background: rgba(61, 139, 253, 0.06);
  border-color: rgba(61, 139, 253, 0.24);
}

.form-band-upload {
  background: rgba(62, 207, 142, 0.045);
  border-color: rgba(62, 207, 142, 0.18);
}

.form-band .field-block:first-child {
  margin-top: 0;
}

.mode-option {
  position: relative;
  display: flex;
  flex-direction: column;
  text-align: left;
  gap: 3px;
  min-height: 70px;
  padding: 12px 14px;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.03);
  cursor: pointer;
  color: var(--text);
  font: inherit;
  transition: border-color 0.15s ease, background 0.15s ease, box-shadow 0.15s ease;
}

.mode-option input {
  position: absolute;
  opacity: 0;
  pointer-events: none;
}

.mode-option:has(input:checked) {
  border-color: rgba(61, 139, 253, 0.72);
  background: rgba(61, 139, 253, 0.14);
  box-shadow: inset 0 0 0 1px rgba(61, 139, 253, 0.22);
}

.mode-option:focus-within {
  outline: 2px solid rgba(61, 139, 253, 0.55);
  outline-offset: 2px;
}

.mode-option-main {
  font-size: 0.95rem;
  font-weight: 700;
  color: #e8edf4;
}

.mode-option-sub {
  font-size: 0.76rem;
  line-height: 1.35;
  color: var(--muted);
}

.mode-option:has(input:checked) .mode-option-sub {
  color: #b9d5ff;
}

.survey-attn-btn {
  position: relative;
  border-color: rgba(240, 180, 41, 0.7);
  animation: surveyPulse 1.8s ease-in-out infinite;
}

.survey-attn-btn::after {
  content: "";
  position: absolute;
  top: 4px;
  right: 4px;
  width: 7px;
  height: 7px;
  border-radius: 999px;
  background: #f0b429;
  box-shadow: 0 0 0 0 rgba(240, 180, 41, 0.55);
  animation: surveyDot 1.8s ease-out infinite;
}

@keyframes surveyPulse {
  0%, 100% { transform: translateY(0); box-shadow: none; }
  50% { transform: translateY(-1px); box-shadow: 0 0 0 3px rgba(240, 180, 41, 0.16); }
}

@keyframes surveyDot {
  0% { box-shadow: 0 0 0 0 rgba(240, 180, 41, 0.45); }
  100% { box-shadow: 0 0 0 8px rgba(240, 180, 41, 0); }
}

.primary-btn {
  padding: 9px 14px;
  border-radius: 8px;
  border: 1px solid transparent;
  background: linear-gradient(180deg, #4b95ff, #2f77ea);
  color: #fff;
  cursor: pointer;
  font-size: 0.85rem;
  font-weight: 600;
}

.primary-btn:hover {
  filter: brightness(1.08);
}

.warn-btn {
  background: linear-gradient(180deg, #f7b34c, #e29322);
}

input[type="text"],
input[type="email"],
input[type="password"],
input[type="number"],
input[type="datetime-local"],
select {
  min-height: 40px;
  padding: 9px 12px;
  border-radius: 8px;
  border: 1px solid var(--border);
  background: var(--surface2);
  color: var(--text);
  font-size: 0.88rem;
  outline: none;
}

input[type="text"]:focus,
input[type="email"]:focus,
input[type="password"]:focus,
input[type="number"]:focus,
textarea:focus {
  border-color: rgba(61, 139, 253, 0.7);
  box-shadow: 0 0 0 3px rgba(61, 139, 253, 0.16);
}

#users-list {
  margin-top: 10px;
}

.setting-row {
  display: grid;
  grid-template-columns: 1fr 220px;
  gap: 12px;
  align-items: center;
  margin-top: 10px;
}

.setting-row label {
  color: #dbe4f1;
  font-size: 0.86rem;
}

.admin-split {
  border: 0;
  border-top: 1px solid var(--border);
  margin: 14px 0;
}

.modal-mask {
  position: fixed;
  inset: 0;
  background: rgba(4, 8, 16, 0.68);
  display: grid;
  place-items: center;
  z-index: 999;
  padding: 16px;
}

.modal-mask[hidden] {
  display: none !important;
}

.modal-card {
  width: min(560px, 100%);
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 12px;
  box-shadow: 0 16px 44px rgba(0, 0, 0, 0.45);
  padding: 16px 18px;
}

.download-preview-dialog {
  width: min(1100px, 96vw);
  height: min(860px, 92vh);
  display: grid;
  grid-template-rows: auto auto 1fr;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 12px;
  box-shadow: 0 16px 44px rgba(0, 0, 0, 0.45);
  overflow: hidden;
}

.download-preview-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 12px 14px;
  border-bottom: 1px solid var(--border);
}

.download-preview-files {
  display: flex;
  gap: 8px;
  overflow-x: auto;
  padding: 10px 14px;
  border-bottom: 1px solid var(--border);
  background: rgba(255,255,255,0.03);
}

.download-preview-file-btn {
  flex: 0 0 auto;
  padding: 7px 10px;
  border-radius: 8px;
  border: 1px solid var(--border);
  background: var(--surface2);
  color: var(--text);
  cursor: pointer;
  font-size: 0.8rem;
}

.download-preview-file-btn.is-active {
  border-color: rgba(61,139,253,.75);
  background: rgba(61,139,253,.18);
}

.download-preview-frame {
  width: 100%;
  height: 100%;
  border: 0;
  background: #fff;
}

.history-actions,
.download-actions {
  display: inline-flex;
  align-items: center;
  gap: 8px;
}

.link-btn {
  border: 0;
  padding: 0;
  background: transparent;
  color: #9ec5ff;
  cursor: pointer;
  font: inherit;
  text-decoration: underline;
}

.picked-files-list {
  margin-top: 10px;
}

.picked-files-scroll {
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
  max-height: 380px;
  overflow-y: auto;
  overflow-x: hidden;
  padding: 2px 6px 4px 2px;
  scrollbar-gutter: stable;
}

.picked-files-scroll::-webkit-scrollbar {
  width: 8px;
}

.picked-files-scroll::-webkit-scrollbar-track {
  background: rgba(255, 255, 255, 0.04);
  border-radius: 4px;
}

.picked-files-scroll::-webkit-scrollbar-thumb {
  background: var(--border);
  border-radius: 4px;
}

.picked-files-scroll::-webkit-scrollbar-thumb:hover {
  background: var(--muted);
}

.picked-file-item {
  display: flex;
  flex-direction: column;
  gap: 6px;
  width: 108px;
  position: relative;
}

.picked-file-card-wrap {
  position: relative;
}

.picked-file-remove {
  position: absolute;
  top: 4px;
  right: 4px;
  z-index: 2;
  width: 24px;
  height: 24px;
  padding: 0;
  border: 1px solid var(--border);
  border-radius: 50%;
  background: rgba(15, 20, 28, 0.88);
  color: var(--text);
  font-size: 1.1rem;
  line-height: 1;
  cursor: pointer;
  display: grid;
  place-items: center;
}

.picked-file-remove:hover {
  background: var(--err);
  border-color: var(--err);
  color: #fff;
}

.picked-file-remove:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 1px;
}

.picked-files-list[hidden] {
  display: none !important;
}

.picked-files-global-cache {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 10px 16px;
  margin-top: 10px;
  padding: 10px 12px;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.03);
}

.picked-files-global-cache[hidden] {
  display: none !important;
}

.picked-files-global-cache-label {
  font-size: 0.8rem;
  font-weight: 600;
  color: var(--text);
}

.picked-files-global-cache-hint {
  flex: 1 1 200px;
  font-size: 0.72rem;
  line-height: 1.35;
}

.picked-file-cache-label {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 0.72rem;
  color: var(--muted);
  cursor: pointer;
  user-select: none;
  line-height: 1.3;
}

.picked-file-cache-label input {
  margin: 0;
  accent-color: var(--accent);
  flex-shrink: 0;
}

.picked-file-card {
  display: flex;
  flex-direction: column;
  gap: 6px;
  width: 100%;
  padding: 0;
  border: 0;
  background: transparent;
  cursor: pointer;
  text-align: left;
  color: inherit;
  font: inherit;
}

.picked-file-card:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
  border-radius: 8px;
}

.picked-file-thumb {
  width: 108px;
  height: 108px;
  object-fit: contain;
  border-radius: 8px;
  border: 1px solid var(--border);
  background: rgba(255, 255, 255, 0.04);
}

.picked-file-cache-row {
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.picked-file-meta {
  font-size: 0.72rem;
  color: var(--muted);
  line-height: 1.35;
  word-break: break-all;
}

.image-preview-mask {
  z-index: 1000;
}

.image-preview-dialog {
  position: relative;
  width: min(92vw, 960px);
  max-height: 92vh;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 10px;
}

.image-preview-stage {
  position: relative;
  width: min(92vw, 960px);
  height: min(72vh, 720px);
  overflow: hidden;
  touch-action: none;
  cursor: grab;
  border-radius: 8px;
  border: 1px solid var(--border);
  background: #0b111a;
}

.image-preview-stage.is-dragging {
  cursor: grabbing;
}

.image-preview-img {
  position: absolute;
  left: 50%;
  top: 50%;
  max-width: none;
  max-height: none;
  width: auto;
  height: auto;
  object-fit: contain;
  border-radius: 4px;
  transform-origin: center center;
  user-select: none;
  -webkit-user-drag: none;
  will-change: transform;
}

.image-preview-hint {
  margin: 0;
  text-align: center;
  font-size: 0.75rem;
}

.image-preview-toolbar {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  justify-content: center;
}

.image-preview-tool-btn {
  font-size: 0.82rem;
  padding: 6px 12px;
}

.image-preview-caption {
  margin: 0;
  text-align: center;
  max-width: 100%;
  word-break: break-all;
}

.image-preview-close {
  position: absolute;
  top: -8px;
  right: -8px;
  width: 36px;
  height: 36px;
  border: 1px solid var(--border);
  border-radius: 50%;
  background: var(--surface2);
  color: var(--text);
  font-size: 1.4rem;
  line-height: 1;
  cursor: pointer;
  z-index: 2;
}

.image-preview-nav {
  position: absolute;
  top: 50%;
  transform: translateY(-50%);
  width: 40px;
  height: 56px;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: rgba(26, 35, 50, 0.92);
  color: var(--text);
  font-size: 1.6rem;
  line-height: 1;
  cursor: pointer;
  z-index: 2;
}

.image-preview-nav--prev {
  left: -52px;
}

.image-preview-nav--next {
  right: -52px;
}

.image-preview-nav:disabled,
.image-preview-nav[hidden] {
  display: none !important;
}

@media (max-width: 720px) {
  .image-preview-nav--prev {
    left: 4px;
  }
  .image-preview-nav--next {
    right: 4px;
  }
  .image-preview-close {
    top: 4px;
    right: 4px;
  }
}

.section-title {
  font-size: 0.75rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--muted);
  margin-bottom: 8px;
}

.progress-block {
  margin-top: 14px;
}
.progress-block[hidden] { display: none !important; }

.progress-label {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  font-size: 0.85rem;
  margin-bottom: 6px;
  gap: 12px;
}
.progress-label span:last-child {
  font-variant-numeric: tabular-nums;
  color: var(--muted);
  font-size: 0.8rem;
}

.progress-track {
  height: 8px;
  border-radius: 999px;
  background: rgba(148, 163, 184, 0.2);
  overflow: hidden;
  border: 1px solid rgba(148, 163, 184, 0.28);
}
.progress-fill {
  height: 100%;
  width: 0%;
  border-radius: 999px;
  position: relative;
  background: linear-gradient(90deg, #4f8cff 0%, #7aa2ff 50%, #4f8cff 100%);
  transition: width 0.25s ease;
}
.progress-track.active .progress-fill {
  animation: progressPulse 1.6s ease-in-out infinite;
  box-shadow: 0 0 0 1px rgba(122, 162, 255, 0.25), 0 0 10px rgba(79, 140, 255, 0.25);
}

.progress-track.active .progress-fill::after {
  content: "";
  position: absolute;
  inset: 0;
  transform: translateX(-120%);
  background: linear-gradient(
    100deg,
    rgba(255, 255, 255, 0) 0%,
    rgba(255, 255, 255, 0.35) 45%,
    rgba(255, 255, 255, 0) 100%
  );
  animation: progressSheen 1.8s ease-in-out infinite;
}
.progress-track.indeterminate .progress-fill {
  width: 35%;
  animation: indet 1.4s ease-in-out infinite;
}
@keyframes progressPulse {
  0%, 100% { filter: brightness(1); }
  50% { filter: brightness(1.12); }
}
@keyframes progressSheen {
  0% { transform: translateX(-120%); opacity: 0; }
  20% { opacity: 1; }
  100% { transform: translateX(140%); opacity: 0; }
}
@keyframes indet {
  0% { transform: translateX(-100%); }
  100% { transform: translateX(380%); }
}

.status-line {
  font-size: 0.9rem;
  margin: 0;
  padding: 10px 12px;
  border-radius: 8px;
  background: var(--surface2);
  border: 1px solid var(--border);
}
.status-line.ok { border-color: rgba(62, 207, 142, 0.35); color: #b8f0d4; }
.status-line.err { border-color: rgba(248, 113, 113, 0.4); color: #fecaca; }
.status-line.cancelled {
  border-color: rgba(251, 191, 36, 0.45);
  color: #fde68a;
}
.status-line.run { border-color: rgba(61, 139, 253, 0.35); }

.meta {
  font-size: 0.8rem;
  color: var(--muted);
  margin-top: 10px;
  display: grid;
  gap: 4px;
  overflow-wrap: anywhere;
  word-break: break-word;
}
.meta strong { color: var(--text); font-weight: 500; }

.download-box {
  margin-top: 12px;
  padding: 12px 14px;
  border-radius: 8px;
  background: var(--accent-dim);
  border: 1px solid rgba(61, 139, 253, 0.35);
}
.download-box a {
  color: #9ec5ff;
  font-weight: 600;
}
.download-box a:hover { text-decoration: underline; }

.history-box {
  margin-top: 12px;
  padding: 12px 12px;
  border-radius: 10px;
  border: 1px solid var(--border);
  background: linear-gradient(160deg, rgba(83,140,255,0.10), rgba(255,255,255,0.02));
}
.history-box .title {
  font-size: 0.82rem;
  color: #b9c8dd;
  margin-bottom: 8px;
  font-weight: 600;
}
.history-item {
  display: grid;
  grid-template-columns: 1fr auto auto;
  gap: 8px 12px;
  align-items: center;
  font-size: 0.82rem;
  margin: 8px 0;
  padding: 8px 10px;
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.03);
}
.history-item .meta-left {
  min-width: 0;
  color: #dbe4f1;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.history-item.multiline .meta-left {
  white-space: normal;
  overflow: visible;
  text-overflow: clip;
  line-height: 1.5;
}
.history-item .meta-time {
  color: var(--muted);
  margin-right: 8px;
}
.history-mode-tag {
  display: inline-flex;
  align-items: center;
  min-height: 1.25rem;
  padding: 0 6px;
  margin-right: 8px;
  border-radius: 6px;
  border: 1px solid rgba(158, 197, 255, 0.28);
  color: #b9d5ff;
  font-size: 0.72rem;
  line-height: 1;
}
.history-item .meta-remain {
  color: #b7c8de;
  font-size: 0.78rem;
  white-space: nowrap;
}
.history-item a {
  color: #9ec5ff;
  text-decoration: none;
  border: 1px solid rgba(158,197,255,0.35);
  border-radius: 6px;
  padding: 4px 10px;
  font-size: 0.78rem;
}
.history-item a:hover {
  background: rgba(158,197,255,0.12);
}

.resource-table-wrap {
  margin-top: 10px;
  width: 100%;
  overflow-x: auto;
  border: 1px solid var(--border);
  border-radius: 10px;
  background: rgba(255, 255, 255, 0.02);
}

.resource-table {
  width: 100%;
  min-width: 1180px;
  border-collapse: collapse;
  font-size: 0.8rem;
}

.resource-table th,
.resource-table td {
  border-bottom: 1px solid var(--border);
  padding: 8px 10px;
  text-align: left;
  vertical-align: top;
  white-space: nowrap;
}

.resource-table thead th {
  position: sticky;
  top: 0;
  z-index: 1;
  background: #1e2a3d;
  color: #dce8f7;
  font-weight: 600;
}

.resource-table tbody tr:hover td {
  background: rgba(61, 139, 253, 0.08);
}

.field-block { margin-top: 14px; }
.field-block label {
  display: block;
  font-size: 0.8rem;
  font-weight: 600;
  color: var(--muted);
  margin-bottom: 6px;
}
.field-block textarea,
.field-block input[type="text"],
.field-block input[type="password"] {
  width: 100%;
  padding: 10px 12px;
  border-radius: 8px;
  border: 1px solid var(--border);
  background: var(--surface2);
  color: var(--text);
  font-size: 0.9rem;
  font-family: var(--font);
  resize: vertical;
  min-height: 44px;
}
.field-block textarea {
  min-height: 120px;
  line-height: 1.45;
  overflow-wrap: anywhere;
  word-break: break-word;
}
.field-block .hint { font-size: 0.75rem; color: var(--muted); margin-top: 4px; }

.advanced-stack {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.advanced-mod {
  border: 1px solid rgba(255, 255, 255, 0.1);
  border-radius: 10px;
  background: rgba(0, 0, 0, 0.2);
  padding: 12px 12px 10px;
}

.advanced-mod--accent {
  border-color: rgba(61, 139, 253, 0.35);
  background: rgba(61, 139, 253, 0.06);
}

.advanced-mod-title {
  margin: 0 0 8px;
  padding-bottom: 6px;
  border-bottom: 1px solid rgba(255, 255, 255, 0.08);
  font-size: 0.8rem;
  font-weight: 700;
  color: #dbe4f1;
  letter-spacing: 0.04em;
}

.advanced-mod-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 10px;
  margin-bottom: 2px;
}

.advanced-mod-head .advanced-mod-title {
  flex: 1;
  min-width: 0;
  margin-bottom: 0;
  padding-bottom: 6px;
  border-bottom: 1px solid rgba(255, 255, 255, 0.08);
}

.advanced-mod-head .help-tip-wrap {
  flex-shrink: 0;
  margin-top: 1px;
}

.advanced-mod-head + .advanced-mod-body {
  margin-top: 8px;
}

.advanced-mod-body .field-block:first-child {
  margin-top: 0;
}

.advanced-mod-select {
  width: 100%;
}

.advanced-check-label {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  font-size: 0.86rem;
  color: #dbe4f1;
  line-height: 1.45;
  cursor: pointer;
}

.advanced-check-label input {
  margin-top: 3px;
  flex-shrink: 0;
}

.advanced-mod--actions .advanced-mod-title {
  border-bottom-color: rgba(247, 179, 76, 0.25);
}

.calibration-intro {
  margin-top: 0;
  margin-bottom: 10px;
}

.help-tip-wrap {
  position: relative;
  display: inline-flex;
  align-items: center;
}

.help-tip-btn {
  width: 22px;
  height: 22px;
  padding: 0;
  border-radius: 50%;
  border: 1px solid rgba(158, 197, 255, 0.55);
  background: rgba(61, 139, 253, 0.18);
  color: #9ec5ff;
  font-size: 0.78rem;
  font-weight: 700;
  line-height: 1;
  cursor: help;
  flex-shrink: 0;
}

.help-tip-btn:hover,
.help-tip-btn:focus-visible {
  background: rgba(61, 139, 253, 0.32);
  color: #dbe4f1;
  outline: none;
}

.help-tip-panel {
  position: absolute;
  left: 0;
  top: calc(100% + 8px);
  z-index: 80;
  width: min(22rem, calc(100vw - 2.5rem));
  padding: 10px 12px;
  border-radius: 10px;
  border: 1px solid var(--border);
  background: var(--surface2);
  color: var(--text);
  font-size: 0.78rem;
  line-height: 1.45;
  box-shadow: 0 8px 28px rgba(0, 0, 0, 0.35);
  visibility: hidden;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.12s ease, visibility 0.12s ease;
}

.help-tip-wrap:hover .help-tip-panel,
.help-tip-wrap:focus-within .help-tip-panel,
.help-tip-wrap.is-pinned .help-tip-panel {
  visibility: visible;
  opacity: 1;
  pointer-events: auto;
}

.help-tip-lead {
  margin: 0 0 6px;
  font-weight: 600;
  color: #dbe4f1;
  font-size: 0.8rem;
}

.help-tip-lead--spaced {
  margin-top: 12px;
}

.help-tip-list {
  margin: 0;
  padding-left: 1.1rem;
}

.help-tip-list li {
  margin-bottom: 6px;
}

.help-tip-list li:last-child {
  margin-bottom: 0;
}

.bias-row {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-top: 6px;
}

.bias-row-dual {
  flex-wrap: wrap;
}

.bias-row-dual .bias-slider {
  flex: 1 1 140px;
  min-width: 0;
  height: 8px;
  accent-color: #3d8bfd;
  cursor: pointer;
}

.bias-row-dual .bias-number-input {
  flex: 0 0 auto;
  width: 6.25rem;
  min-width: 5.5rem;
  max-width: 7.5rem;
  padding: 10px 10px;
  border-radius: 8px;
  border: 1px solid var(--border);
  background: var(--surface2);
  color: var(--text);
  font-size: 0.9rem;
  font-family: var(--font);
}

.bias-row .bias-value {
  flex-shrink: 0;
  font-size: 0.82rem;
  font-weight: 600;
  color: #9ec5ff;
  min-width: 7.5rem;
  text-align: right;
}

.advanced-panel {
  margin-top: 14px;
  border: 1px solid var(--border);
  border-radius: 10px;
  background: rgba(255, 255, 255, 0.02);
}

.advanced-toggle-btn {
  width: 100%;
  text-align: left;
  padding: 10px 12px;
  font-size: 0.88rem;
  font-weight: 600;
  color: #dbe4f1;
  background: transparent;
  border: 1px solid rgba(61, 139, 253, 0.35);
  border-radius: 8px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  cursor: pointer;
}

.advanced-toggle-btn::before {
  content: "▸";
  color: #9ec5ff;
  font-size: 0.9rem;
  transform-origin: center;
  transition: transform 0.15s ease;
}

.advanced-toggle-btn::after {
  content: "展开";
  font-size: 0.78rem;
  color: var(--muted);
  margin-left: auto;
}

.advanced-panel.is-open .advanced-toggle-btn::after {
  content: "收起";
}

.advanced-panel.is-open .advanced-toggle-btn::before {
  transform: rotate(90deg);
}

.advanced-toggle-btn:hover {
  background: rgba(61, 139, 253, 0.14);
}

.advanced-body {
  border-top: 1px solid var(--border);
  padding: 10px 10px 12px;
}

#login-msg {
  color: var(--muted);
  font-size: 0.82rem;
}

.inline-form-row {
  align-items: stretch;
  margin-top: 0;
}

.inline-form-row input {
  flex: 1;
  min-width: 140px;
}

.auth-action-row {
  align-items: flex-start;
}

.auth-action-row button[type="submit"] {
  min-width: 132px;
}

.auth-action-row .meta {
  flex: 1;
  min-width: 180px;
  padding-top: 9px;
}

.login-switch-row {
  display: flex;
  justify-content: flex-start;
  gap: 8px;
  margin-top: 12px;
  padding-top: 12px;
  border-top: 1px solid var(--border);
}

/* 管理后台：顶部固定轻提示，操作反馈更易第一时间看到 */
.admin-toast {
  position: fixed;
  top: max(28px, env(safe-area-inset-top, 0px));
  left: 50%;
  transform: translateX(-50%);
  z-index: 10000;
  max-width: min(92vw, 440px);
  padding: 12px 18px;
  border-radius: var(--radius);
  background: var(--surface2);
  border: 1px solid var(--border);
  box-shadow: 0 12px 40px rgba(0, 0, 0, 0.45);
  font-size: 0.9rem;
  color: var(--text);
  line-height: 1.45;
  text-align: center;
  pointer-events: none;
}
.admin-toast-err {
  color: #fecaca;
  border-color: rgba(248, 113, 113, 0.4);
  background: rgba(30, 20, 22, 0.96);
}

@media (max-width: 720px) {
  .topbar {
    flex-direction: column;
  }

  .history-item {
    grid-template-columns: 1fr auto;
  }
  .history-item .meta-remain {
    grid-column: 1 / 2;
  }
}

@media (max-width: 540px) {
  .form-row { flex-direction: column; align-items: stretch; }
  button[type="submit"] { width: 100%; }
  .setting-row { grid-template-columns: 1fr; }
  .mode-switch { grid-template-columns: 1fr; }
}

/* —— 使用说明弹窗 —— */
.user-guide-mask {
  z-index: 1000;
}

body.user-guide-open {
  overflow: hidden;
}

.user-guide-card {
  width: min(720px, 100%);
  max-height: min(88vh, 920px);
  display: flex;
  flex-direction: column;
  padding: 0;
  overflow: hidden;
}

.user-guide-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 16px 18px 12px;
  border-bottom: 1px solid var(--border);
}

.user-guide-header h3 {
  margin: 0;
  font-size: 1.15rem;
}

.user-guide-close-x {
  flex-shrink: 0;
  width: 36px;
  height: 36px;
  border: 0;
  border-radius: 8px;
  background: transparent;
  color: var(--muted);
  font-size: 1.5rem;
  line-height: 1;
  cursor: pointer;
}

.user-guide-close-x:hover {
  background: rgba(255, 255, 255, 0.06);
  color: var(--text);
}

.user-guide-body {
  flex: 1;
  overflow-y: auto;
  padding: 14px 18px 8px;
  scrollbar-gutter: stable;
}

.user-guide-section {
  margin-bottom: 18px;
}

.user-guide-section h4 {
  margin: 0 0 8px;
  font-size: 0.95rem;
  color: #c8daf5;
}

.user-guide-section p,
.user-guide-section li,
.user-guide-section dd {
  margin: 0 0 8px;
  font-size: 0.9rem;
  line-height: 1.55;
  color: var(--text);
}

.user-guide-section ul,
.user-guide-section ol {
  margin: 0 0 8px;
  padding-left: 1.25rem;
}

.user-guide-flow {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
  padding: 10px 8px;
  background: rgba(255, 255, 255, 0.03);
  border: 1px solid var(--border);
  border-radius: 10px;
}

.user-guide-flow-step {
  width: 100%;
  max-width: 280px;
  text-align: center;
  padding: 8px 12px;
  font-size: 0.88rem;
  background: rgba(100, 140, 220, 0.12);
  border: 1px solid rgba(120, 160, 230, 0.25);
  border-radius: 8px;
}

.user-guide-flow-arrow {
  color: var(--muted);
  font-size: 0.85rem;
  line-height: 1;
}

.user-guide-faq dt {
  font-weight: 600;
  color: #b8d4ff;
  margin-top: 10px;
}

.user-guide-faq dt:first-child {
  margin-top: 0;
}

.user-guide-faq dd {
  margin-left: 0;
  padding-left: 0;
  color: var(--muted);
}

.user-guide-checklist {
  list-style: none;
  padding-left: 0;
}

.user-guide-checklist li {
  position: relative;
  padding-left: 1.35rem;
  margin-bottom: 6px;
}

.user-guide-checklist li::before {
  content: "☐";
  position: absolute;
  left: 0;
  color: var(--muted);
}

.user-guide-footer {
  padding: 12px 18px 16px;
  border-top: 1px solid var(--border);
  display: flex;
  justify-content: flex-end;
}

.user-guide-btn-primary {
  min-width: 120px;
  padding: 10px 20px;
  border: 0;
  border-radius: 8px;
  background: linear-gradient(135deg, #3d6cb9, #2a508f);
  color: #fff;
  font-size: 0.95rem;
  cursor: pointer;
}

.user-guide-btn-primary:hover {
  filter: brightness(1.08);
}
