/* SPDX-License-Identifier: MIT */

:root {
  --blue: #0078d4;
  --blue-hover: #106ebe;
  --blue-disabled: #bfd6f3;
  --text: #242424;
  --text-2: #666;
  --text-3: #767676;
  --border: #e6e6e6;
  --border-2: #dfe1e5;
  --hover: #f3f3f3;
  --shadow-card: 0 1px 2px rgba(0, 0, 0, .06), 0 4px 16px rgba(0, 0, 0, .07);
  --radius: 16px;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  background: #fff;
  color: var(--text);
  font-family: "Segoe UI", "PingFang SC", "Hiragino Sans GB", "Microsoft YaHei", system-ui, -apple-system, Arial, sans-serif;
  font-size: 14px;
  -webkit-font-smoothing: antialiased;
}
html { scrollbar-gutter: stable; }

.hidden { display: none !important; }

/* ================= 登录闸门 ================= */
.gate {
  position: fixed;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  background: radial-gradient(1200px 600px at 50% -10%, #e8f2fd 0%, #ffffff 55%, #f7f9fc 100%);
  z-index: 50;
}

.gate-card {
  width: 380px;
  max-width: calc(100vw - 32px);
  background: #fff;
  border: 1px solid #ececec;
  border-radius: 20px;
  box-shadow: 0 12px 48px rgba(0, 0, 0, .10);
  padding: 40px 36px 28px;
  text-align: center;
}

.gate-logo { display: flex; justify-content: center; margin-bottom: 14px; }
.gate-title { font-size: 26px; font-weight: 600; margin: 0 0 6px; letter-spacing: -.2px; }
.gate-sub { color: var(--text-2); font-size: 13px; margin: 0 0 24px; line-height: 1.6; }
.gate-input-wrap { margin-bottom: 12px; }

.gate input {
  width: 100%;
  height: 44px;
  border: 1px solid var(--border-2);
  border-radius: 8px;
  padding: 0 14px;
  font-size: 15px;
  outline: none;
  transition: border-color .15s, box-shadow .15s;
  background: #fff;
}
.gate input:focus { border-color: var(--blue); box-shadow: 0 0 0 3px rgba(0, 120, 212, .12); }

.gate-btn {
  width: 100%;
  height: 44px;
  border: none;
  border-radius: 8px;
  background: var(--blue);
  color: #fff;
  font-size: 15px;
  font-weight: 600;
  cursor: pointer;
  transition: background .15s;
}
.gate-btn:hover { background: var(--blue-hover); }
.gate-btn:disabled { background: var(--blue-disabled); cursor: default; }

.gate-error { color: #c42b1c; font-size: 12.5px; min-height: 18px; margin: 10px 0 0; }
.gate-foot { color: #9b9b9b; font-size: 11.5px; margin: 18px 0 0; }

/* ================= 顶栏（极简） ================= */
.appbar {
  height: 56px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 24px;
  border-bottom: 1px solid #ededed;
}
.brand { display: flex; align-items: center; gap: 8px; }
.brand-b { font-size: 26px; font-weight: 700; color: var(--blue); line-height: 1; letter-spacing: -.5px; }
.brand-name { font-size: 15px; font-weight: 600; color: #333; }

.signout {
  height: 32px;
  padding: 0 14px;
  border: 1px solid #d9d9d9;
  border-radius: 6px;
  background: #fff;
  color: var(--text);
  font-size: 13px;
  cursor: pointer;
}
.signout:hover { background: var(--hover); }

/* ================= 主体 ================= */
.main { max-width: 860px; margin: 0 auto; padding: 0 24px 80px; }

.hero {
  font-size: 22px;
  font-weight: 600;
  text-align: center;
  margin: 40px 0 24px;
  letter-spacing: -.2px;
}

/* ================= 输入卡片 ================= */
.composer {
  position: relative;
  background: #fff;
  border: 1px solid #ececec;
  border-radius: var(--radius);
  box-shadow: var(--shadow-card);
  padding: 18px 20px 14px;
  transition: box-shadow .2s;
}
.composer:focus-within { box-shadow: 0 2px 6px rgba(0,0,0,.08), 0 12px 32px rgba(0,0,0,.10); }

.composer-main { display: flex; }

.compose-mode {
  display: inline-flex; gap: 4px; padding: 3px; margin: 0 0 8px;
  border-radius: 8px; background: #f3f4f6;
}
.mode-btn {
  height: 28px; padding: 0 12px; border: 0; border-radius: 6px;
  background: transparent; color: var(--text-2); font: inherit; font-size: 12px; cursor: pointer;
}
.mode-btn.active { background: #fff; color: #0f766e; font-weight: 600; box-shadow: 0 1px 3px rgba(0,0,0,.08); }
.reference-zone { margin: 0 0 10px; padding: 10px 12px; border: 1px solid #e5e7eb; border-radius: 10px; background: #fafbfc; }
.reference-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 12px; }
.reference-head b { display: block; font-size: 12px; color: var(--text); }
.reference-head span { display: block; margin-top: 3px; color: var(--text-2); font-size: 11.5px; line-height: 1.5; }
.reference-list { display: flex; gap: 8px; flex-wrap: wrap; margin-top: 10px; }
.reference-item { position: relative; width: 76px; height: 76px; border-radius: 8px; overflow: hidden; border: 1px solid #e5e7eb; background: #fff; }
.reference-item img { width: 100%; height: 100%; object-fit: cover; display: block; }
.reference-remove { position: absolute; top: 2px; right: 2px; width: 20px; height: 20px; border: 0; border-radius: 50%; background: rgba(0,0,0,.58); color: #fff; font-size: 14px; line-height: 1; cursor: pointer; }
.reference-mask { position: absolute; left: 2px; bottom: 2px; height: 22px; padding: 0 6px; border: 0; border-radius: 4px; background: rgba(255,255,255,.9); color: #0f766e; font-size: 10px; font-weight: 600; cursor: pointer; }
.reference-mask.is-set { background: #0f766e; color: #fff; }
.reference-mask:disabled { color: #9ca3af; cursor: not-allowed; }

.prompt {
  flex: 1;
  border: none;
  outline: none;
  resize: none;
  font-family: inherit;
  font-size: 16px;
  line-height: 1.55;
  color: var(--text);
  padding: 8px 2px 4px;
  min-height: 84px;
  max-height: 260px;
  background: transparent;
}
.prompt::placeholder { color: var(--text-3); }

.composer-foot {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-top: 10px;
}

.ratio-wrap { position: relative; }

.ratio-btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  border: none;
  background: none;
  font-family: inherit;
  font-size: 14px;
  font-weight: 600;
  color: var(--text);
  padding: 7px 10px;
  border-radius: 6px;
  cursor: pointer;
}
.ratio-btn:hover { background: var(--hover); }

.ratio-menu {
  position: absolute;
  left: 0;
  bottom: calc(100% + 8px);
  min-width: 190px;
  background: #fff;
  border: 1px solid #eaeaea;
  border-radius: 8px;
  box-shadow: 0 8px 28px rgba(0, 0, 0, .16);
  padding: 6px;
  z-index: 20;
}
.ratio-item {
  display: flex;
  width: 100%;
  gap: 6px;
  align-items: center;
  border: none;
  background: none;
  font-family: inherit;
  font-size: 13.5px;
  color: var(--text);
  padding: 9px 12px;
  border-radius: 6px;
  cursor: pointer;
  text-align: left;
}
.ratio-item span { color: var(--text-2); }
.ratio-item:hover { background: var(--hover); }
.ratio-item.selected { background: #eef5fd; font-weight: 600; }
.ratio-item.selected::after { content: "✓"; margin-left: auto; color: var(--blue); font-weight: 700; }

.generate {
  min-width: 86px;
  height: 40px;
  border: none;
  border-radius: 6px;
  background: var(--blue);
  color: #fff;
  font-family: inherit;
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
  transition: background .15s;
}
.generate:hover:not(:disabled) { background: var(--blue-hover); }
.generate:disabled { background: var(--blue-disabled); cursor: default; }
.generate.danger { background: #b91c1c; }
.generate.danger:hover:not(:disabled) { background: #991b1b; }

/* ================= 生成等待：粒子波场 ================= */
.generating {
  position: relative;
  overflow: hidden;
  border: 1px solid #eef0e7;
  border-radius: 12px;
  background: #fcfdf9;
  opacity: 1;
  transform: translateY(0);
  transition: opacity .26s ease, transform .26s ease;
}
.generating.is-leaving { opacity: 0; transform: translateY(-4px); }

.particle-stage {
  position: relative;
  height: clamp(238px, 37vw, 310px);
  background:
    radial-gradient(ellipse 58% 66% at 50% 44%, rgba(181, 210, 78, .055), transparent 72%),
    linear-gradient(180deg, #fdfdfa 0%, #fbfcf7 100%);
}
#loadingParticles {
  display: block;
  width: 100%;
  height: 100%;
}

.gen-status {
  position: relative;
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 18px;
  padding: 0 22px 15px;
}
.gen-copy { min-width: 0; }
.gen-stage {
  color: #29331e;
  font-size: 14.5px;
  font-weight: 600;
  letter-spacing: .01em;
}
.gen-stage::after {
  content: "";
  display: inline-block;
  width: 4px;
  height: 4px;
  margin-left: 7px;
  border-radius: 50%;
  background: #adcb47;
  vertical-align: 2px;
  animation: gen-breathe 1.8s ease-in-out infinite;
}
@keyframes gen-breathe { 0%, 100% { opacity: .35; } 50% { opacity: 1; } }
.gen-note {
  margin-top: 4px;
  color: #8b9380;
  font-size: 11.5px;
  letter-spacing: .015em;
}
.gen-actions { display: flex; align-items: center; gap: 14px; flex: none; }
.gen-percent {
  min-width: 58px;
  color: #53622d;
  font-variant-numeric: tabular-nums;
  font-size: 23px;
  font-weight: 600;
  line-height: 1;
  letter-spacing: -.04em;
  text-align: right;
}
.pct-sign { margin-left: 1px; color: #8b966e; font-size: 12px; font-weight: 500; letter-spacing: 0; }
.gen-cancel {
  height: 30px;
  padding: 0 11px;
  border: 1px solid #dfe4d3;
  border-radius: 6px;
  background: rgba(255, 255, 255, .7);
  color: #626a59;
  font-family: inherit;
  font-size: 12px;
  cursor: pointer;
  transition: background .15s, border-color .15s;
}
.gen-cancel:hover { background: #fff; border-color: #c9d2b8; }
.gen-bar { height: 2px; background: #edf0e5; overflow: hidden; }
.gen-bar i {
  display: block;
  width: 0;
  height: 100%;
  border-radius: 0 2px 2px 0;
  background: #aacb43;
  transition: width .35s ease-out;
}

.gen-error {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 18px;
  min-height: 112px;
  padding: 20px 22px;
  border: 1px solid #efdbd7;
  border-radius: 12px;
  background: #fffdfc;
}
.gen-error-main { display: flex; align-items: flex-start; gap: 12px; min-width: 0; }
.gen-error-icon {
  display: grid;
  place-items: center;
  flex: none;
  width: 24px;
  height: 24px;
  margin-top: 1px;
  border-radius: 50%;
  background: #f7e2de;
  color: #a44336;
  font-size: 13px;
  font-weight: 700;
}
.gen-error-title { color: #6d3028; font-size: 14px; font-weight: 600; }
.gen-error-text { margin-top: 4px; color: #81635e; font-size: 12.5px; line-height: 1.55; }
.gen-error-actions { display: flex; gap: 8px; flex: none; }
.gen-retry, .gen-back {
  height: 33px;
  padding: 0 15px;
  border-radius: 6px;
  font-family: inherit;
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
}
.gen-retry { border: none; background: var(--blue); color: #fff; }
.gen-retry:hover { background: var(--blue-hover); }
.gen-back { border: 1px solid #dedede; background: #fff; color: #555; font-weight: 500; }
.gen-back:hover { background: var(--hover); }

/* ================= 结果 ================= */
.results { margin-top: 30px; animation: results-in .3s ease-out both; }
@keyframes results-in {
  from { opacity: 0; transform: translateY(8px); }
  to { opacity: 1; transform: translateY(0); }
}
.results-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 12px; }
.results-title { font-size: 16px; font-weight: 600; }
.results-meta { font-weight: 400; color: var(--text-2); font-size: 12.5px; margin-left: 8px; }

.ghost-btn {
  height: 34px; padding: 0 14px;
  border: 1px solid #d9d9d9; border-radius: 6px;
  background: #fff; font-family: inherit; font-size: 13px; cursor: pointer;
}
.ghost-btn:hover { background: var(--hover); }

.result-grid { display: grid; grid-template-columns: repeat(2, 1fr); gap: 12px; }
.result-tile {
  position: relative; border-radius: 12px; overflow: hidden;
  background: #f3f3f3; aspect-ratio: var(--ar, 3 / 2);
}
.result-tile img { width: 100%; height: 100%; object-fit: cover; display: block; }

.result-actions {
  position: absolute; inset: auto 0 0 0;
  display: flex; gap: 8px; justify-content: flex-end; padding: 10px;
  background: linear-gradient(to top, rgba(0,0,0,.45), rgba(0,0,0,0));
  opacity: 0; transition: opacity .15s;
}
.result-tile:hover .result-actions { opacity: 1; }
.icon-btn {
  width: 34px; height: 34px; border-radius: 50%; border: none;
  background: rgba(255,255,255,.94); display: grid; place-items: center;
  cursor: pointer; box-shadow: 0 2px 6px rgba(0,0,0,.2);
}
.icon-btn:hover { background: #fff; }

.results-prompt { margin-top: 12px; color: var(--text-2); font-size: 13px; line-height: 1.6; word-break: break-word; }

/* ================= Toast ================= */
.toast {
  position: fixed; left: 50%; bottom: 32px; transform: translateX(-50%);
  background: #323232; color: #fff; padding: 12px 18px; border-radius: 8px;
  font-size: 13px; box-shadow: 0 8px 24px rgba(0,0,0,.25);
  z-index: 60; max-width: 80vw;
}

/* ================= 响应式 ================= */
@media (max-width: 720px) {
  .appbar { padding: 0 14px; }
  .main { padding: 0 14px 60px; }
  .hero { font-size: 18px; margin: 24px 0 16px; }
  .composer { padding: 14px 14px 10px; }
  .result-grid { grid-template-columns: 1fr; }

  .particle-stage { height: 238px; }
  .gen-status { padding: 0 15px 14px; gap: 10px; }
  .gen-percent { min-width: 48px; font-size: 20px; }
  .gen-actions { gap: 8px; }
  .gen-cancel { padding: 0 9px; }
  .gen-error { flex-direction: column; align-items: stretch; padding: 16px; gap: 14px; }
  .gen-error-actions { justify-content: flex-end; }
}

@media (max-width: 390px) {
  .gen-note { max-width: 150px; }
  .gen-percent { font-size: 18px; min-width: 44px; }
}

@media (prefers-reduced-motion: reduce) {
  .generating { transition: none; }
  .results { animation: none; }
  .gen-stage::after { animation: none; opacity: .7; }
  .gen-bar i { transition: none; }
  .result-actions, .toast { transition: none; }
  html { scroll-behavior: auto; }
}

/* ================= ChatGPT2API additions ================= */
.appbar-right { display: flex; align-items: center; gap: 10px; }
.account-status {
  height: 28px; display: inline-flex; align-items: center;
  padding: 0 10px; border-radius: 999px;
  background: #ecfdf5; color: #0f766e;
  font-size: 12px; font-weight: 600; white-space: nowrap;
}
.stream-grid {
  --stream-aspect: 1 / 1;
  display: grid; grid-template-columns: repeat(4, 1fr);
  gap: 8px; padding: 0 18px 14px;
}
.stream-slot, .stream-tile {
  border-radius: 10px; aspect-ratio: var(--stream-aspect);
  border: 1px solid #e5e7eb; background: #f3f4f6;
}
.stream-slot {
  background: linear-gradient(100deg, #f3f4f6 20%, #fafafa 40%, #f3f4f6 60%);
  background-size: 220% 100%;
  animation: stream-shimmer 1.6s ease-in-out infinite;
}
@keyframes stream-shimmer { from { background-position: 120% 0; } to { background-position: -120% 0; } }
.stream-tile .result-actions { padding: 6px; gap: 4px; }
.stream-tile .icon-btn { width: 28px; height: 28px; }
.stream-tile .icon-btn svg { width: 14px; height: 14px; }
@media (max-width: 720px) {
  .stream-grid { grid-template-columns: repeat(2, 1fr); padding: 0 14px 12px; }
  .account-status { display: none; }
}

/* ================= Admin / account pool ================= */
.view-tabs { display: flex; align-items: center; gap: 4px; }
.view-tab {
  height: 32px; padding: 0 12px; border: 0; border-radius: 7px;
  background: transparent; color: var(--text-2); font: inherit; font-size: 13px;
  cursor: pointer;
}
.view-tab:hover { background: var(--hover); color: var(--text); }
.view-tab.active { background: #eef2ff; color: #1d4ed8; font-weight: 600; }
.accounts-view { max-width: 1040px; margin: 0 auto; padding: 24px 24px 80px; }
.accounts-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 16px; margin-bottom: 18px; }
.accounts-head h2 { margin: 0 0 6px; font-size: 20px; }
.accounts-head p { margin: 0; color: var(--text-2); font-size: 13px; }
.accounts-actions { display: flex; gap: 8px; flex-wrap: wrap; justify-content: flex-end; }
.account-list { display: grid; gap: 12px; }
.account-card {
  border: 1px solid var(--border); border-radius: 12px; padding: 16px;
  background: #fff; box-shadow: 0 1px 2px rgba(0,0,0,.03);
}
.account-card-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 12px; }
.account-title { font-size: 15px; font-weight: 700; display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.account-sub { margin-top: 6px; color: var(--text-2); font-size: 12px; display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.account-quota { text-align: right; min-width: 110px; }
.account-quota strong { display: block; font-size: 20px; color: #0f766e; }
.account-quota span { color: var(--text-3); font-size: 11px; }
.account-stats { display: flex; flex-wrap: wrap; gap: 8px 16px; margin-top: 12px; color: var(--text-2); font-size: 12px; }
.account-stats b { color: var(--text); font-weight: 600; }
.account-error { margin-top: 8px; color: #b91c1c; font-size: 12px; line-height: 1.5; }
.account-status-reason { margin-top: 8px; padding: 7px 9px; border-radius: 7px; background: #f8fafc; color: #475569; font-size: 12px; line-height: 1.5; }
.account-actions { display: flex; gap: 8px; flex-wrap: wrap; margin-top: 12px; }
.ghost-btn.danger { color: #b91c1c; border-color: #fecaca; }
.badge { display: inline-flex; align-items: center; height: 20px; padding: 0 7px; border-radius: 999px; background: #f3f4f6; color: #4b5563; font-size: 11px; font-weight: 600; }
.badge-active, .badge-ok { background: #ecfdf5; color: #047857; }
.badge-cooldown { background: #fffbeb; color: #b45309; }
.badge-verification { background: #eff6ff; color: #1d4ed8; }
.badge-recovery { background: #f0fdfa; color: #0f766e; }
.badge-invalid, .badge-error { background: #fef2f2; color: #b91c1c; }
.badge-disabled { background: #f3f4f6; color: #6b7280; }
.text-danger { color: #b91c1c !important; }
.empty-state { padding: 48px 20px; text-align: center; color: var(--text-2); border: 1px dashed var(--border); border-radius: 12px; }
.modal { position: fixed; inset: 0; z-index: 70; display: flex; align-items: center; justify-content: center; padding: 20px; background: rgba(15, 23, 42, .38); }
.modal-card { width: min(560px, 100%); max-height: 92vh; overflow: auto; background: #fff; border-radius: 14px; box-shadow: 0 24px 80px rgba(0,0,0,.22); padding: 20px; }
.modal-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 14px; }
.modal-head h3 { margin: 0; font-size: 18px; }
.modal-close { border: 0; background: transparent; font-size: 26px; line-height: 1; color: var(--text-2); cursor: pointer; }
.field { display: block; margin-bottom: 12px; color: var(--text-2); font-size: 12px; }
.field input, .field textarea {
  display: block; width: 100%; margin-top: 6px; padding: 9px 10px;
  border: 1px solid #d9d9d9; border-radius: 8px; font: inherit; font-size: 13px; color: var(--text);
  background: #fff; resize: vertical;
}
.form-row { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.form-hint { color: var(--text-3); font-size: 12px; line-height: 1.6; margin: 4px 0 16px; }
.modal-actions { display: flex; justify-content: flex-end; gap: 8px; }
.mask-dialog { width: min(760px, 100%); }
.mask-help { margin: 0 0 10px; color: var(--text-2); font-size: 12px; line-height: 1.6; }
.mask-canvas-wrap { display: flex; justify-content: center; align-items: center; min-height: 220px; max-height: 58vh; overflow: auto; border-radius: 10px; background: #f3f4f6; }
#maskCanvas { display: block; max-width: 100%; max-height: 56vh; cursor: crosshair; touch-action: none; }
.mask-controls { display: flex; align-items: center; gap: 14px; flex-wrap: wrap; margin-top: 10px; color: var(--text-2); font-size: 12px; }
.mask-controls input[type="range"] { vertical-align: middle; }
.mask-status { color: var(--text-3); }
@media (max-width: 720px) {
  .view-tabs { order: 3; width: 100%; justify-content: center; padding-bottom: 6px; }
  .appbar { flex-wrap: wrap; height: auto; min-height: 56px; padding-top: 8px; }
  .accounts-view { padding: 18px 14px 60px; }
  .accounts-head { flex-direction: column; }
  .accounts-actions { justify-content: flex-start; }
  .account-card-head { flex-direction: column; }
  .account-quota { text-align: left; }
  .form-row { grid-template-columns: 1fr; }
}

/* ================= Settings ================= */
.settings-view { max-width: 1040px; margin: 0 auto; padding: 24px 24px 80px; }
.settings-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 16px; margin-bottom: 18px; }
.settings-head h2 { margin: 0 0 6px; font-size: 20px; }
.settings-head p { margin: 0; color: var(--text-2); font-size: 13px; line-height: 1.65; max-width: 760px; }
.settings-state { flex: none; color: var(--text-3); font-size: 12px; padding-top: 4px; }
.settings-card {
  border: 1px solid var(--border); border-radius: 14px; background: #fff;
  padding: 18px 20px; margin-bottom: 14px; box-shadow: 0 1px 2px rgba(0,0,0,.03);
}
.settings-card-head h3 { margin: 0 0 4px; font-size: 16px; }
.settings-card-head p { margin: 0 0 14px; color: var(--text-2); font-size: 12px; line-height: 1.6; }
.settings-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 0 18px; }
.settings-wide { margin-top: 12px; }
.switch-row {
  display: flex; align-items: center; gap: 14px; justify-content: space-between;
  grid-column: 1 / -1; margin: 2px 0 10px; padding: 12px 14px;
  border: 1px solid #eef0f2; border-radius: 10px; background: #fafbfc; cursor: pointer;
}
.switch-row > span { min-width: 0; display: flex; flex-direction: column; gap: 3px; }
.switch-row b { font-size: 13px; font-weight: 600; color: var(--text); }
.switch-row small { color: var(--text-2); font-size: 12px; line-height: 1.5; }
.switch-row input { position: absolute; opacity: 0; pointer-events: none; }
.switch {
  flex: none; width: 42px; height: 24px; border-radius: 999px; background: #d7dbe0;
  position: relative; transition: background .16s ease;
}
.switch::after {
  content: ""; position: absolute; top: 3px; left: 3px; width: 18px; height: 18px;
  border-radius: 50%; background: #fff; box-shadow: 0 1px 3px rgba(0,0,0,.24);
  transition: transform .16s ease;
}
.switch-row input:checked + .switch { background: #0f766e; }
.switch-row input:checked + .switch::after { transform: translateX(18px); }
.switch-row input:disabled + .switch { background: #e5e7eb; cursor: not-allowed; }
.switch-row:has(input:disabled) { cursor: not-allowed; background: #f6f7f8; }
.switch-row:has(input:disabled) small { color: #8b9199; }
.secret-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px 18px; }
.secret-grid div { display: flex; align-items: center; justify-content: space-between; gap: 10px; padding: 10px 12px; background: #f8f9fa; border-radius: 8px; }
.secret-grid span { color: var(--text-2); font-size: 12px; }
.secret-grid b { font-size: 12px; color: #0f766e; }
.settings-actions { display: flex; justify-content: flex-end; gap: 10px; margin-top: 18px; }
@media (max-width: 720px) {
  .settings-view { padding: 18px 14px 60px; }
  .settings-head { flex-direction: column; }
  .settings-grid, .secret-grid { grid-template-columns: 1fr; }
  .settings-actions { position: sticky; bottom: 0; padding: 12px 0; background: #fff; }
}

/* ================= Gallery ================= */
.gallery-view { max-width: 1100px; margin: 0 auto; padding: 24px 24px 80px; }
.gallery-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 16px; margin-bottom: 18px; }
.gallery-head h2 { margin: 0 0 6px; font-size: 20px; }
.gallery-head p { margin: 0; color: var(--text-2); font-size: 13px; }
.gallery-toolbar {
  display: flex; align-items: center; gap: 9px; flex-wrap: wrap;
  padding: 9px 10px; margin: 0 0 10px; border: 1px solid #eef0f2; border-radius: 10px; background: #fafbfc;
}
.gallery-toolbar .selection-count { margin-left: 2px; }
.gallery-toolbar .danger { margin-left: auto; }
.cache-note {
  margin: 0 0 12px; padding: 9px 11px; border-radius: 8px;
  background: #fffbeb; border: 1px solid #fde68a; color: #92400e; font-size: 12px; line-height: 1.6;
}
.gallery-grid { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 12px; }
.gallery-grid > .empty-state { grid-column: 1 / -1; }
.gallery-card { position: relative; border: 1px solid var(--border); border-radius: 12px; overflow: hidden; background: #fff; }
.gallery-card.is-selected { border-color: #99f6e4; box-shadow: 0 0 0 2px rgba(15, 118, 110, .10); }
.gallery-select { position: absolute; top: 8px; left: 8px; z-index: 2; accent-color: #0f766e; }
.gallery-thumb { display: block; width: 100%; aspect-ratio: 1 / 1; object-fit: cover; background: #f3f4f6; }
.gallery-info { padding: 9px 10px 8px; }
.gallery-meta { color: var(--text-2); font-size: 11px; line-height: 1.5; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.gallery-actions { display: flex; gap: 6px; padding: 0 10px 10px; }
.gallery-actions .ghost-btn { height: 28px; padding: 0 9px; font-size: 12px; }
.gallery-pager { display: flex; justify-content: center; gap: 8px; margin-top: 18px; }
@media (max-width: 900px) { .gallery-grid { grid-template-columns: repeat(3, minmax(0, 1fr)); } }
@media (max-width: 720px) {
  .gallery-view { padding: 18px 14px 60px; }
  .gallery-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}

/* ================= Account page: fixed toolbar + scrolling list ================= */
body.accounts-mode { overflow: hidden; }
body.accounts-mode .main { padding-bottom: 0; max-width: 1120px; }
.accounts-view {
  height: calc(100dvh - var(--appbar-height, 56px));
  max-width: 1120px;
  margin: 0 auto;
  padding: 18px 24px 0;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}
.accounts-fixed { flex: none; }
.account-scroll {
  flex: 1 1 auto;
  min-height: 0;
  overflow-y: auto;
  overscroll-behavior: contain;
  padding: 0 6px 10px 0;
  scrollbar-gutter: stable;
}
.accounts-footer {
  flex: none; display: flex; align-items: center; justify-content: space-between;
  gap: 12px; padding: 10px 0 14px; border-top: 1px solid #eef0f2;
  color: var(--text-2); font-size: 12px;
}
.accounts-summary { display: flex; flex-wrap: wrap; gap: 8px 10px; margin: 0 0 12px; color: var(--text-2); font-size: 12px; }
.accounts-summary b { color: var(--text); }
.accounts-summary .summary-dot { color: #c4c9cf; }
.accounts-toolbar {
  display: flex; align-items: center; gap: 8px; flex-wrap: wrap;
  padding: 9px 10px; margin-bottom: 12px;
  border: 1px solid #eef0f2; border-radius: 10px; background: #fafbfc;
}
.accounts-toolbar .bulk-actions { display: flex; gap: 8px; margin-left: auto; }
.check-label { display: inline-flex; align-items: center; gap: 6px; color: var(--text-2); font-size: 12px; cursor: pointer; }
.check-label input { accent-color: #0f766e; }
.selection-count { color: #0f766e; font-size: 12px; font-weight: 600; }
.ghost-btn.compact { height: 28px; padding: 0 10px; font-size: 12px; }
.ghost-btn:disabled { color: #a3a3a3; border-color: #ececec; cursor: not-allowed; background: #fafafa; }
.pager { display: flex; gap: 8px; }
.account-select { position: absolute; top: 14px; left: 14px; z-index: 2; accent-color: #0f766e; }
.account-card { position: relative; }
.account-card.is-selected { border-color: #99f6e4; box-shadow: 0 0 0 2px rgba(15, 118, 110, .10); }
.account-card .account-card-head { padding-left: 22px; }
.badge-expiring { background: #fffbeb; color: #b45309; }
.badge-expired { background: #fef2f2; color: #b91c1c; }
.badge-quota-zero { background: #fff7ed; color: #c2410c; }
@media (max-width: 720px) {
  body.accounts-mode .main { padding: 0 14px; }
  .accounts-view { padding: 14px 0 0; height: calc(100dvh - var(--appbar-height, 104px)); }
  .accounts-actions { width: 100%; }
  .accounts-toolbar .bulk-actions { width: 100%; margin-left: 0; }
  .accounts-toolbar .bulk-actions .ghost-btn { flex: 1; }
  .account-card .account-card-head { padding-left: 18px; }
}

/* ================= Confirmation / import / progress modals ================= */
.modal-card-small { width: min(440px, 100%); }
.modal-card-wide { width: min(780px, 100%); }
.confirm-message { margin: 4px 0 18px; color: var(--text-2); font-size: 13px; line-height: 1.7; white-space: pre-line; }
.import-preview-list { max-height: 240px; overflow: auto; border: 1px solid #eef0f2; border-radius: 8px; margin-bottom: 14px; }
.import-preview-item { display: flex; gap: 10px; justify-content: space-between; padding: 8px 10px; border-bottom: 1px solid #f2f4f5; font-size: 12px; }
.import-preview-item:last-child { border-bottom: 0; }
.import-preview-item span { color: var(--text-2); }
.import-preview-item b { font-weight: 500; }
.progress-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; color: var(--text-2); font-size: 12px; margin-bottom: 8px; }
.progress-head b { color: var(--text); font-variant-numeric: tabular-nums; }
.progress-bar { height: 6px; border-radius: 999px; background: #eef0f2; overflow: hidden; margin-bottom: 12px; }
.progress-bar i { display: block; width: 0; height: 100%; border-radius: inherit; background: #0f766e; transition: width .18s ease; }
.import-log { max-height: 260px; overflow: auto; border: 1px solid #eef0f2; border-radius: 8px; padding: 8px 10px; margin-bottom: 14px; font-size: 12px; line-height: 1.7; }
.import-log div { display: flex; gap: 8px; }
.import-log .ok { color: #047857; }
.import-log .warn { color: #b45309; }
.import-log .bad { color: #b91c1c; }
.import-log .muted { color: var(--text-3); }



/* ================= Proxy / IP management ================= */
.proxy-global-row { display: flex; align-items: end; gap: 12px; flex-wrap: wrap; margin-bottom: 12px; }
.proxy-global-row .field { min-width: 260px; margin-bottom: 0; }
.proxy-list { display: grid; gap: 8px; margin: 8px 0 14px; }
.proxy-item { border: 1px solid #eef0f2; border-radius: 9px; padding: 9px 10px; background: #fafbfc; display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.proxy-item-main { min-width: 220px; flex: 1; }
.proxy-item-title { font-size: 13px; font-weight: 600; color: var(--text); display: flex; gap: 6px; align-items: center; flex-wrap: wrap; }
.proxy-item-sub { margin-top: 3px; font-size: 12px; color: var(--text-3); }
.proxy-item-actions { display: flex; gap: 6px; flex-wrap: wrap; }
.proxy-add-box { border-top: 1px dashed #e5e7eb; padding-top: 12px; }
.proxy-add-actions { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-top: 2px; }
.proxy-empty { padding: 10px; border: 1px dashed #e5e7eb; border-radius: 8px; color: var(--text-3); font-size: 12px; }
#bulkProxyMode, #bulkProxySelect, #globalProxySelect, #proxyFallbackMode, #proxyBackupSelect { width: 100%; height: 34px; border: 1px solid #e5e7eb; border-radius: 7px; padding: 0 8px; background: #fff; color: var(--text); }
#bulkProxySelectWrap { margin-top: 10px; }
@media (max-width: 720px) { .proxy-global-row .field { min-width: 100%; } .proxy-add-actions { align-items: stretch; flex-direction: column; } }

/* ================= Logs (Workers 5.0) ================= */
.logs-view { max-width: 1280px; margin: 0 auto; padding: 24px 24px 80px; }
body.logs-mode .main { max-width: 1280px; }
.logs-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 16px; margin-bottom: 16px; }
.logs-head h2 { margin: 0 0 6px; font-size: 20px; }
.logs-head p { margin: 0; color: var(--text-2); font-size: 13px; }
.logs-head-actions { display: flex; gap: 8px; flex-wrap: wrap; justify-content: flex-end; }
.logs-stats { display: grid; grid-template-columns: repeat(7, minmax(0, 1fr)); gap: 8px; margin-bottom: 14px; }
.logs-stat { padding: 10px 12px; border: 1px solid var(--border); border-radius: 10px; background: #fff; }
.logs-stat span { display: block; color: var(--text-3); font-size: 11px; }
.logs-stat strong { display: block; margin-top: 3px; font-size: 18px; font-variant-numeric: tabular-nums; }
.logs-stat-ok strong { color: #047857; }
.logs-stat-bad strong { color: #b91c1c; }
.logs-stat-warn strong { color: #b45309; }
.logs-filters {
  display: grid; grid-template-columns: repeat(8, minmax(0, 1fr)); gap: 8px 10px;
  align-items: end; padding: 12px; border: 1px solid #eef0f2; border-radius: 12px; background: #fafbfc; margin-bottom: 12px;
}
.logs-filters .field { margin: 0; min-width: 0; }
.logs-filters .field select, .logs-filters .field input {
  height: 34px; margin-top: 5px; padding: 0 8px; border: 1px solid #d9d9d9; border-radius: 7px;
  background: #fff; color: var(--text); font: inherit; font-size: 12px;
}
.logs-filters .logs-search { grid-column: span 2; }
.logs-filter-actions { display: flex; gap: 6px; align-items: center; white-space: nowrap; }
.logs-filter-actions .generate { height: 34px; padding: 0 14px; white-space: nowrap; }
.logs-filter-actions .ghost-btn { white-space: nowrap; }
.logs-toolbar {
  display: flex; align-items: center; gap: 9px; flex-wrap: wrap;
  padding: 9px 10px; margin-bottom: 10px; border: 1px solid #eef0f2; border-radius: 10px; background: #fafbfc;
}
.logs-storage-note { margin-left: auto; color: var(--text-3); font-size: 11px; }
.logs-table-wrap { border: 1px solid var(--border); border-radius: 12px; overflow: auto; background: #fff; }
.logs-table { width: 100%; min-width: 1080px; border-collapse: collapse; font-size: 12px; }
.logs-table th {
  position: sticky; top: 0; z-index: 1; text-align: left; padding: 9px 10px;
  background: #f8fafc; color: var(--text-2); font-weight: 600; white-space: nowrap; border-bottom: 1px solid var(--border);
}
.logs-table td { padding: 9px 10px; vertical-align: top; border-bottom: 1px solid #f2f4f5; }
.logs-table tr:last-child td { border-bottom: 0; }
.log-row { cursor: pointer; }
.log-row:hover { background: #fbfcfd; }
.log-row.is-selected { background: #f0fdfa; }
.logs-check { width: 30px; text-align: center !important; }
.logs-check input { accent-color: #0f766e; }
.log-time { white-space: nowrap; color: var(--text-2); font-variant-numeric: tabular-nums; }
.log-kind { display: inline-flex; padding: 2px 7px; border-radius: 999px; background: #f1f5f9; color: #475569; white-space: nowrap; }
.log-endpoint { color: var(--text); font-weight: 600; white-space: nowrap; }
.log-excerpt { margin-top: 3px; max-width: 330px; color: var(--text-3); font-size: 11px; line-height: 1.4; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.log-error { max-width: 150px; color: #b91c1c; word-break: break-all; }
.log-status { display: inline-flex; align-items: center; padding: 2px 7px; border-radius: 999px; font-size: 11px; font-weight: 600; white-space: nowrap; }
.log-status-success { background: #ecfdf5; color: #047857; }
.log-status-partial_success { background: #eff6ff; color: #1d4ed8; }
.log-status-failed, .log-status-error { background: #fef2f2; color: #b91c1c; }
.log-status-rate_limited, .log-status-text_review { background: #fffbeb; color: #b45309; }
.log-status-cancelled { background: #f3f4f6; color: #6b7280; }
.logs-pager { display: flex; justify-content: center; align-items: center; gap: 8px; margin-top: 18px; flex-wrap: wrap; }
.log-drawer { position: fixed; inset: 0; z-index: 80; display: flex; justify-content: flex-end; }
.log-drawer-backdrop { position: absolute; inset: 0; background: rgba(15, 23, 42, .38); }
.log-drawer-panel {
  position: relative; z-index: 1; width: min(820px, 100%); height: 100%; overflow-y: auto;
  background: #fff; box-shadow: -16px 0 48px rgba(0,0,0,.16); padding: 18px 22px 40px;
}
.log-drawer-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 16px; padding-bottom: 12px; border-bottom: 1px solid #eef0f2; position: sticky; top: -18px; background: #fff; z-index: 2; padding-top: 18px; }
.log-drawer-head h3 { margin: 0 0 4px; font-size: 18px; }
.log-drawer-head span { color: var(--text-3); font-size: 11px; word-break: break-all; }
.log-detail-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 8px 16px; margin: 14px 0 16px; }
.log-detail-grid div { display: flex; align-items: flex-start; justify-content: space-between; gap: 12px; padding: 7px 9px; border-radius: 7px; background: #f8fafc; }
.log-detail-grid span { color: var(--text-3); font-size: 11px; white-space: nowrap; }
.log-detail-grid b { color: var(--text); font-size: 12px; text-align: right; word-break: break-word; }
.log-detail-section { margin-top: 18px; }
.log-detail-section h4 { margin: 0 0 8px; font-size: 13px; }
.log-prompt { padding: 10px 12px; border-radius: 8px; background: #f8fafc; color: var(--text); font-size: 12px; line-height: 1.7; white-space: pre-wrap; word-break: break-word; }
.log-json-details { margin-top: 8px; }
.log-json-details summary, .log-attempt details summary { cursor: pointer; color: var(--text-2); font-size: 12px; }
.log-json {
  max-height: 300px; overflow: auto; margin: 8px 0 0; padding: 10px; border-radius: 8px;
  background: #0f172a; color: #e2e8f0; font-size: 11px; line-height: 1.55; white-space: pre-wrap; word-break: break-word;
}
.log-empty-line { padding: 10px; border: 1px dashed #e5e7eb; border-radius: 8px; color: var(--text-3); font-size: 12px; }
.log-note { margin: 10px 0; padding: 9px 11px; border: 1px solid #fde68a; border-radius: 8px; background: #fffbeb; color: #92400e; font-size: 12px; }
.log-attempts { display: grid; gap: 8px; }
.log-attempt { padding: 9px 10px; border: 1px solid #eef0f2; border-radius: 8px; background: #fafbfc; }
.log-attempt-head { display: flex; align-items: center; justify-content: space-between; gap: 10px; font-size: 12px; }
.log-attempt-meta { margin-top: 5px; color: var(--text-3); font-size: 11px; line-height: 1.5; }
.log-preview-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 8px; }
.log-preview { width: 100%; aspect-ratio: 1 / 1; object-fit: cover; border-radius: 8px; border: 1px solid #eef0f2; background: #f3f4f6; }
@media (max-width: 900px) {
  .logs-stats { grid-template-columns: repeat(4, minmax(0, 1fr)); }
  .logs-filters { grid-template-columns: repeat(3, minmax(0, 1fr)); }
  .logs-filters .logs-search { grid-column: span 2; }
}
@media (max-width: 720px) {
  .logs-view { padding: 18px 14px 60px; }
  .logs-head { flex-direction: column; }
  .logs-head-actions { width: 100%; justify-content: flex-start; }
  .logs-stats { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .logs-filters { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .logs-filters .logs-search { grid-column: 1 / -1; }
  .logs-filter-actions { grid-column: 1 / -1; }
  .logs-storage-note { width: 100%; margin-left: 0; }
  .log-detail-grid { grid-template-columns: 1fr; }
  .log-drawer-panel { padding: 14px 14px 30px; }
  .log-drawer-head { top: -14px; padding-top: 14px; }
  .view-tabs { overflow-x: auto; max-width: calc(100vw - 150px); scrollbar-width: none; }
  .view-tabs::-webkit-scrollbar { display: none; }
  .view-tab { flex: none; }
}

