:root {
  --bg: #0b0d12;
  --bg-soft: #11141c;
  --panel: rgba(20, 24, 34, 0.82);
  --panel-border: rgba(255, 255, 255, 0.08);
  --text: #e8ecf4;
  --muted: #8b93a7;
  --accent: #8b5cf6;
  --accent-2: #22d3ee;
  --ok: #34d399;
  --warn: #fbbf24;
  --danger: #f87171;
  --radius: 16px;
  --shadow: 0 18px 50px rgba(0, 0, 0, 0.45);
  color-scheme: dark;
}

* { box-sizing: border-box; }

/* 关键：让 hidden 属性优先于各类 display 规则（弹层/提示都用 hidden 控制） */
[hidden] { display: none !important; }

html, body {
  margin: 0;
  padding: 0;
  min-height: 100%;
}

body {
  background:
    radial-gradient(1100px 600px at 12% -10%, rgba(139, 92, 246, 0.18), transparent 60%),
    radial-gradient(900px 520px at 100% 0%, rgba(34, 211, 238, 0.12), transparent 55%),
    var(--bg);
  color: var(--text);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC", "Hiragino Sans GB",
    "Microsoft YaHei", "Noto Sans SC", sans-serif;
  font-size: 15px;
  line-height: 1.55;
  -webkit-font-smoothing: antialiased;
}

body.no-scroll { overflow: hidden; }

a { color: inherit; }

.muted { color: var(--muted); }
.small { font-size: 12.5px; }

/* ------------------------------ 顶栏 ------------------------------ */

.topbar {
  position: sticky;
  top: 0;
  z-index: 20;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 14px clamp(16px, 3vw, 34px);
  backdrop-filter: blur(14px);
  background: rgba(11, 13, 18, 0.72);
  border-bottom: 1px solid var(--panel-border);
}

.brand {
  display: flex;
  align-items: center;
  gap: 10px;
  min-width: 0;
}

.brand-text {
  font-weight: 700;
  letter-spacing: 0.2px;
  font-size: 16.5px;
  white-space: nowrap;
}

.domain-chip {
  font-size: 11.5px;
  color: var(--muted);
  border: 1px solid var(--panel-border);
  border-radius: 999px;
  padding: 2px 9px;
  white-space: nowrap;
}

.top-actions {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
  justify-content: flex-end;
}

.pill {
  font-size: 12px;
  color: #cfd6e6;
  background: rgba(139, 92, 246, 0.14);
  border: 1px solid rgba(139, 92, 246, 0.35);
  border-radius: 999px;
  padding: 4px 11px;
  max-width: 240px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

/* ------------------------------ 按钮 ------------------------------ */

.btn {
  appearance: none;
  border: 1px solid var(--panel-border);
  background: rgba(255, 255, 255, 0.05);
  color: var(--text);
  border-radius: 11px;
  padding: 9px 15px;
  font-size: 14px;
  font-family: inherit;
  cursor: pointer;
  transition: background 0.18s ease, border-color 0.18s ease, transform 0.12s ease, opacity 0.18s;
  text-decoration: none;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
}

.btn:hover { background: rgba(255, 255, 255, 0.1); }
.btn:active { transform: translateY(1px); }
.btn:disabled { opacity: 0.5; cursor: not-allowed; }
.btn.ghost { background: transparent; }
.btn.ghost:hover { background: rgba(255, 255, 255, 0.07); }
.btn.small { padding: 5px 11px; font-size: 12.5px; border-radius: 9px; }
.btn.block { width: 100%; }

.btn.primary {
  background: linear-gradient(135deg, var(--accent), #6d5ef6 45%, var(--accent-2));
  border: none;
  color: #0b0d12;
  font-weight: 700;
  padding: 12px 18px;
  font-size: 15px;
  box-shadow: 0 10px 26px rgba(109, 94, 246, 0.28);
}
.btn.primary:hover { filter: brightness(1.06); }
.btn.primary:disabled { filter: grayscale(0.5); box-shadow: none; }

.btn.danger {
  color: var(--danger);
  border-color: rgba(248, 113, 113, 0.35);
  background: rgba(248, 113, 113, 0.08);
}
.btn.danger:hover { background: rgba(248, 113, 113, 0.16); }

.icon-btn {
  appearance: none;
  border: 1px solid rgba(255, 255, 255, 0.16);
  background: rgba(9, 11, 16, 0.62);
  color: #fff;
  width: 32px;
  height: 32px;
  border-radius: 9px;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: 14px;
  padding: 0;
  text-decoration: none;
  backdrop-filter: blur(6px);
  transition: background 0.16s ease;
}
.icon-btn:hover { background: rgba(139, 92, 246, 0.55); }
.icon-btn.danger:hover { background: rgba(248, 113, 113, 0.75); }

/* ------------------------------ 布局 ------------------------------ */

.layout {
  display: grid;
  grid-template-columns: minmax(300px, 380px) minmax(0, 1fr);
  gap: clamp(16px, 2.4vw, 30px);
  padding: clamp(16px, 2.6vw, 32px) clamp(16px, 3vw, 36px) 56px;
  max-width: 1500px;
  margin: 0 auto;
  align-items: start;
}

.panel {
  background: var(--panel);
  border: 1px solid var(--panel-border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 20px;
}

.composer {
  position: sticky;
  top: 84px;
  display: flex;
  flex-direction: column;
  gap: 14px;
}

.panel-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
}

.panel-head h2,
.section-head h2 {
  margin: 0;
  font-size: 15.5px;
  font-weight: 650;
  letter-spacing: 0.3px;
}

.warn-chip {
  font-size: 11.5px;
  color: var(--warn);
  border: 1px solid rgba(251, 191, 36, 0.4);
  background: rgba(251, 191, 36, 0.08);
  border-radius: 999px;
  padding: 2px 9px;
}

/* ------------------------------ 表单 ------------------------------ */

.field {
  display: flex;
  flex-direction: column;
  gap: 6px;
  min-width: 0;
}

.field > span {
  font-size: 12.5px;
  color: var(--muted);
  font-weight: 500;
}

.field small { font-size: 11.5px; }

input[type="text"],
input[type="password"],
textarea,
select {
  width: 100%;
  background: rgba(8, 10, 15, 0.72);
  border: 1px solid rgba(255, 255, 255, 0.1);
  border-radius: 10px;
  color: var(--text);
  font-family: inherit;
  font-size: 14px;
  padding: 10px 12px;
  outline: none;
  transition: border-color 0.16s ease, box-shadow 0.16s ease;
}

textarea { resize: vertical; min-height: 120px; line-height: 1.6; }

input:focus,
textarea:focus,
select:focus {
  border-color: rgba(139, 92, 246, 0.7);
  box-shadow: 0 0 0 3px rgba(139, 92, 246, 0.16);
}

select {
  appearance: none;
  background-image: linear-gradient(45deg, transparent 50%, var(--muted) 50%),
    linear-gradient(135deg, var(--muted) 50%, transparent 50%);
  background-position: calc(100% - 17px) 50%, calc(100% - 12px) 50%;
  background-size: 5px 5px, 5px 5px;
  background-repeat: no-repeat;
  padding-right: 32px;
}

.row { display: flex; gap: 12px; }
.row.two > * { flex: 1 1 0; min-width: 0; }

.advanced {
  border: 1px solid var(--panel-border);
  border-radius: 11px;
  padding: 10px 12px;
  background: rgba(255, 255, 255, 0.02);
}

.advanced summary {
  cursor: pointer;
  font-size: 13px;
  color: var(--muted);
  user-select: none;
}

.advanced[open] summary { margin-bottom: 10px; }
.advanced .field + .field { margin-top: 10px; }

/* ------------------------------ 状态 ------------------------------ */

.status {
  margin: 0;
  font-size: 13px;
  color: var(--muted);
  padding: 9px 12px;
  border-radius: 10px;
  background: rgba(255, 255, 255, 0.035);
  border: 1px solid var(--panel-border);
  white-space: pre-line;
  word-break: break-word;
}

.status.ok { color: var(--ok); border-color: rgba(52, 211, 153, 0.3); background: rgba(52, 211, 153, 0.07); }
.status.error { color: var(--danger); border-color: rgba(248, 113, 113, 0.3); background: rgba(248, 113, 113, 0.07); }
.status.warn { color: var(--warn); border-color: rgba(251, 191, 36, 0.3); background: rgba(251, 191, 36, 0.07); }

/* ------------------------------ 工作区 ------------------------------ */

.workspace { min-width: 0; }

.section-head {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 10px;
  margin: 4px 2px 14px;
}

.history-head { margin-top: 38px; }
.history-tools { display: flex; align-items: center; gap: 10px; }

.grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(230px, 1fr));
  gap: 16px;
}

.grid.compact {
  grid-template-columns: repeat(auto-fill, minmax(150px, 1fr));
  gap: 12px;
}

.card {
  position: relative;
  margin: 0;
  border-radius: 14px;
  overflow: hidden;
  background: rgba(255, 255, 255, 0.04);
  border: 1px solid var(--panel-border);
  box-shadow: 0 8px 26px rgba(0, 0, 0, 0.32);
  animation: card-in 0.32s ease both;
}

@keyframes card-in {
  from { opacity: 0; transform: translateY(10px) scale(0.985); }
  to { opacity: 1; transform: none; }
}

.card img {
  display: block;
  width: 100%;
  height: auto;
  background: #0d1017;
  cursor: zoom-in;
}

.card.compact img { max-height: 220px; object-fit: cover; }

.card-actions {
  position: absolute;
  top: 8px;
  right: 8px;
  display: flex;
  gap: 6px;
  opacity: 0;
  transform: translateY(-3px);
  transition: opacity 0.18s ease, transform 0.18s ease;
}

.card:hover .card-actions,
.card:focus-within .card-actions { opacity: 1; transform: none; }

@media (hover: none) {
  .card-actions { opacity: 1; transform: none; }
}

.card figcaption {
  display: flex;
  flex-direction: column;
  gap: 4px;
  padding: 9px 11px 11px;
  border-top: 1px solid rgba(255, 255, 255, 0.06);
}

.cap-prompt {
  font-size: 12.5px;
  color: #c7cede;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

.cap-meta { font-size: 11px; color: var(--muted); }

.empty {
  border: 1px dashed rgba(255, 255, 255, 0.14);
  border-radius: var(--radius);
  padding: 46px 20px;
  text-align: center;
  color: var(--muted);
  background: rgba(255, 255, 255, 0.015);
}

.empty p { margin: 6px 0; }
.empty-art {
  font-size: 30px;
  background: linear-gradient(135deg, var(--accent), var(--accent-2));
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
}
.small-empty { padding: 22px; }

/* ------------------------------ 弹窗 ------------------------------ */

.dialog {
  border: 1px solid var(--panel-border);
  border-radius: 18px;
  background: #12151d;
  color: var(--text);
  padding: 0;
  width: min(620px, calc(100vw - 28px));
  max-height: calc(100vh - 60px);
  box-shadow: 0 30px 90px rgba(0, 0, 0, 0.6);
}

.dialog::backdrop { background: rgba(4, 5, 8, 0.72); backdrop-filter: blur(4px); }

.dialog-body {
  display: flex;
  flex-direction: column;
  gap: 14px;
  padding: 22px;
  overflow-y: auto;
  max-height: calc(100vh - 60px);
}

.dialog-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.dialog-head h2 { margin: 0; font-size: 17px; }

.dialog-actions {
  display: flex;
  gap: 10px;
  justify-content: flex-end;
  flex-wrap: wrap;
  margin-top: 2px;
}

.sep { border: none; border-top: 1px solid var(--panel-border); width: 100%; margin: 8px 0 2px; }

.sub-title { margin: 0; font-size: 14px; font-weight: 600; }

/* ------------------------------ 大图 ------------------------------ */

.lightbox {
  position: fixed;
  inset: 0;
  z-index: 60;
  background: rgba(4, 5, 8, 0.9);
  backdrop-filter: blur(8px);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 26px 18px;
  gap: 14px;
}

.lightbox img {
  max-width: min(1100px, 94vw);
  max-height: 76vh;
  object-fit: contain;
  border-radius: 12px;
  box-shadow: 0 30px 80px rgba(0, 0, 0, 0.6);
}

.lb-close { position: absolute; top: 18px; right: 20px; width: 38px; height: 38px; }

.lb-bar {
  width: min(1100px, 94vw);
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 18px;
  flex-wrap: wrap;
}

.lb-prompt {
  margin: 0;
  color: #c3cadb;
  font-size: 13px;
  white-space: pre-line;
  max-height: 92px;
  overflow-y: auto;
  flex: 1 1 320px;
}

.lb-actions { display: flex; gap: 8px; flex-wrap: wrap; }

/* ------------------------------ 登录页 ------------------------------ */

.auth-body {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 24px;
}

.auth-shell { width: min(420px, 100%); }

.auth-card {
  background: var(--panel);
  border: 1px solid var(--panel-border);
  border-radius: 22px;
  padding: 34px 30px 26px;
  box-shadow: var(--shadow);
  text-align: center;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.brand-mark { display: flex; justify-content: center; margin-bottom: 2px; }

.auth-card h1 { margin: 0; font-size: 24px; letter-spacing: 0.4px; }
.auth-card > p { margin: 0; }

.auth-card form {
  margin-top: 18px;
  display: flex;
  flex-direction: column;
  gap: 14px;
  text-align: left;
}

.auth-card .btn { margin-top: 4px; }

.hint { font-size: 11.5px; color: var(--muted); margin-top: 12px !important; }

.error {
  margin: 0;
  color: var(--danger);
  font-size: 13px;
  background: rgba(248, 113, 113, 0.08);
  border: 1px solid rgba(248, 113, 113, 0.3);
  border-radius: 9px;
  padding: 8px 11px;
}

/* ------------------------------ Toast ------------------------------ */

.toast {
  position: fixed;
  left: 50%;
  bottom: 28px;
  transform: translateX(-50%);
  z-index: 90;
  background: rgba(22, 26, 36, 0.96);
  border: 1px solid var(--panel-border);
  color: var(--text);
  padding: 11px 18px;
  border-radius: 11px;
  font-size: 13.5px;
  box-shadow: 0 16px 46px rgba(0, 0, 0, 0.5);
  animation: toast-in 0.2s ease both;
  max-width: min(520px, 90vw);
  text-align: center;
}

.toast.ok { border-color: rgba(52, 211, 153, 0.45); }
.toast.error { border-color: rgba(248, 113, 113, 0.5); }

@keyframes toast-in {
  from { opacity: 0; transform: translate(-50%, 8px); }
  to { opacity: 1; transform: translate(-50%, 0); }
}

/* ------------------------------ 响应式 ------------------------------ */

@media (max-width: 900px) {
  .layout { grid-template-columns: 1fr; }
  .composer { position: static; }
  .domain-chip { display: none; }
  .grid { grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); }
  .topbar { padding: 11px 16px; }
  .brand-text { font-size: 15px; }
}

@media (max-width: 560px) {
  .top-actions .pill { display: none; }
  .grid { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; }
  .grid.compact { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .dialog-body { padding: 18px 16px; }
  .row.two { flex-direction: column; }
  .lb-bar { justify-content: center; }
}

/* 尺寸下拉需要比数量更宽，避免选项文字被截断 */
.row.size-row { display: grid; grid-template-columns: 1.55fr 1fr; }

.key-row { display: flex; align-items: center; justify-content: space-between; gap: 10px; }
