:root {
  --bg: #0f1115;
  --panel: #171a21;
  --border: #262b35;
  --text: #e6e8ee;
  --muted: #8b93a5;
  --accent: #4f7cff;
  --accent-hover: #3f68e6;
  --err: #ff5c5c;
  --radius: 12px;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: -apple-system, "Segoe UI", "PingFang SC", "Microsoft YaHei", sans-serif;
  line-height: 1.5;
}

.hidden { display: none !important; }

/* 登录 */
.login-wrap {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
}
.login-card {
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 16px;
  padding: 40px 36px;
  width: 340px;
  display: flex;
  flex-direction: column;
  gap: 14px;
}
.login-card h1 { margin: 0; font-size: 22px; text-align: center; }
.login-card .sub { margin: 0; text-align: center; color: var(--muted); font-size: 14px; }
input, textarea, select {
  width: 100%;
  background: #0d0f14;
  border: 1px solid var(--border);
  border-radius: 8px;
  color: var(--text);
  padding: 11px 12px;
  font-size: 14px;
  font-family: inherit;
  resize: vertical;
}
input:focus, textarea:focus, select:focus {
  outline: none;
  border-color: var(--accent);
}

button, .btn {
  cursor: pointer;
  border: none;
  border-radius: 8px;
  padding: 11px 18px;
  font-size: 14px;
  font-weight: 600;
  color: #fff;
  background: var(--accent);
  text-decoration: none;
  text-align: center;
  display: inline-block;
}
button:hover, .btn:hover { background: var(--accent-hover); }
button:disabled { opacity: .55; cursor: not-allowed; }
.ghost { background: transparent; border: 1px solid var(--border); color: var(--muted); }

/* 主界面 */
.app { max-width: 900px; margin: 0 auto; padding: 0 20px 40px; }
header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 18px 0;
}
.brand { font-size: 18px; font-weight: 700; }

main { display: flex; flex-direction: column; gap: 20px; }
.panel {
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 22px;
}
.panel h2 { margin: 0 0 14px; font-size: 15px; }
label { display: block; margin: 14px 0 6px; font-size: 13px; color: var(--muted); }
.panel > label:first-child { margin-top: 0; }

.note { margin: 6px 0 0; font-size: 12px; color: #d9a441; min-height: 0; }
.note:empty { display: none; }

.meta { margin: 6px 0 0; font-size: 12px; color: var(--muted); min-height: 0; }
.meta:empty { display: none; }

/* 模式切换 */
.modes { display: inline-flex; margin-top: 16px; background: #0d0f14; border: 1px solid var(--border); border-radius: 8px; overflow: hidden; }
.mode-btn {
  background: transparent; border: none; color: var(--muted);
  padding: 9px 18px; font-size: 13px; font-weight: 600; border-radius: 0;
}
.mode-btn + .mode-btn { border-left: 1px solid var(--border); }
.mode-btn.active { background: var(--accent); color: #fff; }
.mode-btn.active:hover { background: var(--accent); }

/* 参考图上传 */
.drop {
  border: 1px dashed var(--border);
  border-radius: 8px;
  min-height: 120px;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  color: var(--muted);
  font-size: 13px;
  overflow: hidden;
  position: relative;
  margin-top: 6px;
}
.drop.drag { border-color: var(--accent); background: rgba(79,124,255,.06); }
.drop img { max-width: 100%; max-height: 220px; display: block; }

.row { display: flex; gap: 12px; align-items: flex-end; margin-top: 14px; }
.col { flex: 1; }
.col:last-child { flex: 0 0 auto; display: flex; align-items: flex-end; }
.col .primary { height: 42px; }
.col label { margin-top: 0; }

.err { color: var(--err); font-size: 13px; min-height: 18px; margin: 10px 0 0; }
.err:empty { display: none; }

/* 结果 */
.result { margin-top: 18px; }
.img-box {
  border: 1px solid var(--border);
  border-radius: 8px;
  overflow: hidden;
  background: #0d0f14;
  display: flex;
  justify-content: center;
}
.img-box img { max-width: 100%; display: block; }
.result .btn { margin-top: 12px; width: 100%; }

/* 历史 */
.history { display: flex; flex-direction: column; gap: 10px; }
.history:empty::after { content: "暂无记录"; color: var(--muted); font-size: 13px; }
.h-item {
  display: flex;
  gap: 12px;
  align-items: center;
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 8px;
}
.h-item img { width: 72px; height: 72px; object-fit: cover; border-radius: 6px; background: #0d0f14; }
.h-meta { flex: 1; min-width: 0; }
.h-meta .p { font-size: 13px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.h-meta .m { font-size: 12px; color: var(--muted); margin-top: 2px; }
.h-item .btn { padding: 7px 12px; font-size: 12px; }

/* loading 态 */
.spinner {
  display: inline-block;
  width: 14px; height: 14px;
  border: 2px solid rgba(255,255,255,.3);
  border-top-color: #fff;
  border-radius: 50%;
  animation: spin .7s linear infinite;
  vertical-align: -2px;
  margin-right: 6px;
}
@keyframes spin { to { transform: rotate(360deg); } }
