:root {
  --bg: #0b0d12;
  --bg-soft: #12151d;
  --glass: rgba(255, 255, 255, 0.04);
  --glass-border: rgba(255, 255, 255, 0.08);
  --text: #e8eaf0;
  --text-dim: #8a90a0;
  --primary: #ff6b35;
  --primary-2: #ff9f43;
  --danger: #ff3b30;
  --ok: #4ade80;
  --radius: 16px;
  --shadow: 0 12px 40px rgba(0, 0, 0, 0.55);
}

* { box-sizing: border-box; margin: 0; padding: 0; }

/* hidden 属性必须生效：
   否则带有 display:flex/block 的元素（.secure-warning、.toolbar-group 等）
   会覆盖浏览器默认的 [hidden]{display:none}，导致该隐藏的依然显示 */
[hidden] { display: none !important; }

body {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC", "Microsoft YaHei", sans-serif;
  background: var(--bg);
  color: var(--text);
  min-height: 100vh;
  overflow-x: hidden;
}

/* ============ 按钮 ============ */
.btn-primary, .btn-secondary, .btn-ghost {
  border: none; border-radius: 10px; padding: 11px 18px;
  font-size: 14px; cursor: pointer; transition: .2s; font-weight: 600;
}
.btn-primary {
  background: linear-gradient(135deg, var(--primary), var(--primary-2));
  color: #fff; box-shadow: 0 4px 16px rgba(255, 107, 53, .35);
}
.btn-primary:hover { transform: translateY(-1px); box-shadow: 0 6px 22px rgba(255, 107, 53, .5); }
.btn-primary:disabled { opacity: .55; cursor: not-allowed; transform: none; }
.btn-secondary {
  background: rgba(255,255,255,.08); color: var(--text); border: 1px solid var(--glass-border);
}
.btn-secondary:hover { background: rgba(255,255,255,.14); }
.btn-secondary:disabled { opacity: .45; cursor: not-allowed; }
.btn-ghost {
  background: transparent; color: var(--text-dim); border: 1px solid var(--glass-border);
}
.btn-ghost:hover { color: var(--text); border-color: rgba(255,255,255,.25); }
.btn-ghost:disabled { opacity: .5; cursor: not-allowed; }
.btn-block { width: 100%; display: flex; align-items: center; justify-content: center; gap: 8px; }

/* ============ 登录页 ============ */
.login-page {
  display: none; min-height: 100vh; position: relative;
  align-items: center; justify-content: center; padding: 24px;
}
.login-page.active { display: flex !important; }
.login-bg-orb {
  position: absolute; border-radius: 50%; filter: blur(90px); opacity: .35; z-index: 0;
}
.orb-1 { width: 420px; height: 420px; background: var(--primary); top: -80px; left: -60px; }
.orb-2 { width: 380px; height: 380px; background: #6a5cff; bottom: -60px; right: -40px; }
.login-shell {
  position: relative; z-index: 1; display: flex; width: 860px; max-width: 100%;
  background: var(--glass); border: 1px solid var(--glass-border);
  border-radius: 24px; overflow: hidden; box-shadow: var(--shadow);
  backdrop-filter: blur(20px); -webkit-backdrop-filter: blur(20px);
}
.login-hero {
  flex: 1; padding: 52px 44px;
  background: linear-gradient(160deg, rgba(255,107,53,.18), rgba(255,159,67,.05));
  display: flex; flex-direction: column; justify-content: center;
}
.hero-logo { font-size: 56px; margin-bottom: 12px; }
.hero-title { font-size: 40px; font-weight: 800; letter-spacing: .5px; }
.hero-sub { color: var(--text-dim); font-size: 16px; margin-top: 4px; margin-bottom: 28px; }
.hero-features { list-style: none; margin-bottom: 28px; }
.hero-features li {
  display: flex; align-items: center; gap: 10px; padding: 9px 0; color: var(--text);
  font-size: 15px;
}
.hero-features li span { font-size: 18px; }
.hero-tip { color: var(--text-dim); font-size: 12px; line-height: 1.6; }

.login-card { flex: 1; padding: 52px 44px; display: flex; flex-direction: column; justify-content: center; }
.login-card h2 { font-size: 26px; margin-bottom: 6px; }
.login-sub { color: var(--text-dim); font-size: 14px; margin-bottom: 28px; }
.field { margin-bottom: 16px; position: relative; }
.field input {
  width: 100%; padding: 13px 16px; border-radius: 10px;
  border: 1px solid var(--glass-border); background: rgba(255,255,255,.05);
  color: var(--text); font-size: 15px; outline: none; transition: .2s;
}
.field input:focus {
  border-color: var(--primary); box-shadow: 0 0 0 3px rgba(255,107,53,.18);
}
.code-field { display: flex; gap: 10px; }
.code-field input { flex: 1; }
.code-field .btn-ghost { white-space: nowrap; }
.msg { margin-top: 14px; font-size: 13px; text-align: center; min-height: 18px; }
.msg.error { color: var(--danger); }
.msg.success { color: var(--ok); }

/* ============ 安全提示条 ============ */
.secure-warning {
  position: sticky; top: 0; z-index: 30;
  display: flex; align-items: flex-start; justify-content: center; gap: 8px;
  padding: 10px 16px; background: rgba(255,159,67,.16);
  border-bottom: 1px solid rgba(255,159,67,.4); color: #ffb86b;
  font-size: 13px; text-align: center; backdrop-filter: blur(10px);
  line-height: 1.5;
}
.secure-diag {
  display: block; margin-top: 6px; font-size: 11px;
  color: rgba(255,184,107,.75); word-break: break-all;
}

/* ============ 登录/注册模式切换 ============ */
.auth-tabs {
  display: flex; gap: 4px; background: rgba(255,255,255,.05);
  border: 1px solid var(--glass-border); border-radius: 12px; padding: 4px;
  margin-bottom: 24px;
}
.auth-tab {
  flex: 1; padding: 9px 0; border: none; border-radius: 9px; cursor: pointer;
  background: transparent; color: var(--text-dim); font-size: 14px; font-weight: 600;
  transition: .2s;
}
.auth-tab.active {
  background: linear-gradient(135deg, var(--primary), var(--primary-2));
  color: #fff; box-shadow: 0 4px 12px rgba(255,107,53,.3);
}

/* 密码可见切换 */
.pw-field { position: relative; }
.pw-field input { padding-right: 44px; }
.pw-toggle {
  position: absolute; right: 8px; top: 50%; transform: translateY(-50%);
  background: none; border: none; cursor: pointer; font-size: 16px;
  color: var(--text-dim); padding: 4px; opacity: .7;
}
.pw-toggle:hover { opacity: 1; }

/* 登录方式切换 + 记住我 */
.auth-options {
  display: flex; justify-content: space-between; align-items: center; margin: 2px 0 16px;
}
.remember { display: flex; align-items: center; gap: 7px; cursor: pointer; font-size: 13px; color: var(--text-dim); }
.remember input { accent-color: var(--primary); width: 15px; height: 15px; cursor: pointer; }
.link-btn {
  background: none; border: none; color: var(--primary); cursor: pointer;
  font-size: 13px; padding: 4px;
}
.link-btn:hover { text-decoration: underline; }
.auth-footnote { margin-top: 20px; font-size: 11px; color: var(--text-dim); opacity: .7; text-align: center; line-height: 1.5; }

/* ============ 移动端底部导航 ============ */
.bottom-nav {
  display: none; position: fixed; left: 0; right: 0; bottom: 0; z-index: 20;
  background: rgba(18,21,29,.92); border-top: 1px solid var(--glass-border);
  backdrop-filter: blur(16px); -webkit-backdrop-filter: blur(16px);
  padding-bottom: env(safe-area-inset-bottom, 0);
}
.bn-item {
  flex: 1; display: flex; flex-direction: column; align-items: center; justify-content: center;
  gap: 3px; height: 56px; background: none; border: none; cursor: pointer;
  color: var(--text-dim); transition: .2s; position: relative;
}
.bn-icon { font-size: 20px; transition: .2s; }
.bn-label { font-size: 11px; }
.bn-item.active { color: var(--primary); }
.bn-item.active .bn-icon { transform: translateY(-2px); }
.bn-item.active::before {
  content: ''; position: absolute; top: 0; left: 50%; transform: translateX(-50%);
  width: 24px; height: 3px; border-radius: 3px; background: var(--primary);
}

/* ============ 底部抽屉 ============ */
.drawer-mask {
  position: fixed; inset: 0; z-index: 30; background: rgba(0,0,0,.5);
  animation: fadeIn .25s ease;
}
.drawer {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 31;
  max-height: 70vh; background: var(--bg-soft);
  border-radius: 20px 20px 0 0; border-top: 1px solid var(--glass-border);
  box-shadow: 0 -12px 40px rgba(0,0,0,.5);
  transform: translateY(100%); transition: transform .28s cubic-bezier(.4,0,.2,1);
  display: flex; flex-direction: column;
  padding-bottom: env(safe-area-inset-bottom, 0);
}
.drawer.open { transform: translateY(0); }
.drawer-handle {
  width: 40px; height: 4px; border-radius: 2px; background: rgba(255,255,255,.2);
  margin: 10px auto 4px; flex-shrink: 0;
}
.drawer-body { overflow-y: auto; padding: 12px 16px 20px; }
.drawer-body .panel-card { margin-bottom: 12px; }

@keyframes fadeIn { from { opacity: 0; } to { opacity: 1; } }

/* ============ 快捷键提示 ============ */
.hotkey-hint { position: fixed; right: 20px; bottom: 20px; z-index: 25; }
.hotkey-toggle {
  width: 44px; height: 44px; border-radius: 50%; border: 1px solid var(--glass-border);
  background: rgba(18,21,29,.9); color: var(--text); cursor: pointer; font-size: 18px;
  box-shadow: var(--shadow); backdrop-filter: blur(10px);
}
.hotkey-pop {
  position: absolute; right: 0; bottom: 52px; width: 240px;
  background: rgba(18,21,29,.96); border: 1px solid var(--glass-border);
  border-radius: 12px; padding: 14px; box-shadow: var(--shadow);
}
.hk-row { display: flex; align-items: center; gap: 6px; margin-bottom: 10px; font-size: 12px; color: var(--text-dim); }
.hk-row:last-child { margin-bottom: 0; }
.hk-row span { flex: 1; }
kbd {
  background: rgba(255,255,255,.08); border: 1px solid var(--glass-border);
  border-radius: 5px; padding: 2px 6px; font-size: 11px; color: var(--text);
  font-family: inherit; min-width: 20px; text-align: center;
}

/* ============ 拖拽高亮 ============ */
.stage.drag-over .canvas-holder { outline: 2px dashed var(--primary); outline-offset: -2px; background: rgba(255,107,53,.06); }

/* ============ Toast ============ */
.toast {
  position: fixed; left: 50%; top: 20px; transform: translateX(-50%);
  background: rgba(18,21,29,.96); border: 1px solid var(--glass-border);
  color: var(--text); padding: 11px 20px; border-radius: 12px; font-size: 14px;
  box-shadow: var(--shadow); z-index: 50; animation: fadeIn .25s ease;
  max-width: 86vw;
}
.toast.error { border-color: rgba(255,59,48,.5); color: #ff8a80; }
.toast.success { border-color: rgba(74,222,128,.5); color: #7ae2a5; }

.btn-spinner {
  width: 16px; height: 16px; border: 2px solid rgba(255,255,255,.4);
  border-top-color: #fff; border-radius: 50%; animation: spin .7s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* ============ 主应用 ============ */
.app-page { display: none !important; }
.app-page.active { display: block !important; }

.topbar {
  display: flex; justify-content: space-between; align-items: center;
  padding: 14px 28px; background: rgba(18,21,29,.85);
  border-bottom: 1px solid var(--glass-border); backdrop-filter: blur(16px);
  position: sticky; top: 0; z-index: 10;
}
.brand { display: flex; align-items: center; gap: 10px; font-size: 19px; font-weight: 800; }
.brand-icon { font-size: 22px; }
.topbar-right { display: flex; align-items: center; gap: 14px; }
.model-pill {
  font-size: 12px; padding: 5px 12px; border-radius: 20px;
  background: rgba(255,255,255,.06); color: var(--text-dim); border: 1px solid var(--glass-border);
  max-width: 260px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.model-pill.ok { color: var(--ok); border-color: rgba(74,222,128,.4); background: rgba(74,222,128,.1); }
.model-pill.err { color: var(--danger); border-color: rgba(255,59,48,.4); background: rgba(255,59,48,.1); }

.tabs {
  display: flex; gap: 6px; padding: 12px 28px 0;
  background: var(--bg-soft); border-bottom: 1px solid var(--glass-border);
}
.tab {
  background: none; border: none; color: var(--text-dim); padding: 12px 20px;
  cursor: pointer; font-size: 15px; border-radius: 10px 10px 0 0; transition: .2s;
}
.tab:hover { color: var(--text); }
.tab.active { color: #fff; background: linear-gradient(180deg, rgba(255,107,53,.18), transparent); }
.tab.active::after {
  content: ''; display: block; height: 3px; background: var(--primary);
  border-radius: 3px; margin-top: 10px;
}

.workspace {
  display: flex; gap: 20px; padding: 20px 28px; max-width: 1400px; margin: 0 auto;
}
.stage { flex: 1; min-width: 0; }
.panel { width: 320px; flex-shrink: 0; display: flex; flex-direction: column; gap: 16px; }

.canvas-holder {
  position: relative; background: var(--bg-soft); border: 1px solid var(--glass-border);
  border-radius: var(--radius); overflow: hidden; min-height: 460px;
  display: flex; align-items: center; justify-content: center;
}
#main-canvas { display: block; max-width: 100%; max-height: 70vh; }
.placeholder {
  position: absolute; inset: 0; display: flex; flex-direction: column;
  align-items: center; justify-content: center; color: var(--text-dim); gap: 8px;
  text-align: center; padding: 20px;
}
.placeholder-icon { font-size: 54px; opacity: .6; }
.placeholder p { font-size: 15px; }
.placeholder-sub { font-size: 13px; opacity: .7; }

.alert-banner {
  position: absolute; top: 16px; left: 50%; transform: translateX(-50%);
  background: var(--danger); color: #fff; padding: 10px 22px; border-radius: 30px;
  font-weight: 700; font-size: 15px; box-shadow: 0 6px 24px rgba(255,59,48,.5);
  animation: pulse 1.2s ease-in-out infinite; z-index: 5;
}
@keyframes pulse { 0%,100% { opacity: 1; } 50% { opacity: .65; } }

.toolbar {
  display: flex; gap: 10px; flex-wrap: wrap; margin-top: 16px; align-items: center;
}
.toolbar-group { display: flex; gap: 10px; align-items: center; }

/* ============ 右侧面板 ============ */
.panel-card {
  background: var(--glass); border: 1px solid var(--glass-border);
  border-radius: var(--radius); padding: 18px; backdrop-filter: blur(12px);
}
.panel-card.grow { flex: 1; }
.panel-title { font-size: 14px; color: var(--text-dim); margin-bottom: 14px; font-weight: 700;
  text-transform: uppercase; letter-spacing: .5px; }

.stat-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.stat {
  background: rgba(255,255,255,.03); border: 1px solid var(--glass-border);
  border-radius: 12px; padding: 14px; text-align: center;
}
.stat-value { font-size: 24px; font-weight: 800; color: var(--primary); }
.stat-value.danger { color: var(--danger); }
.stat-label { font-size: 12px; color: var(--text-dim); margin-top: 4px; }

.slider-label { display: block; margin-bottom: 14px; font-size: 13px; color: var(--text-dim); }
.slider-val { color: var(--primary); font-weight: 700; margin-left: 6px; }
input[type="range"] {
  width: 100%; margin-top: 8px; -webkit-appearance: none; appearance: none;
  height: 6px; border-radius: 3px; background: rgba(255,255,255,.1); outline: none;
}
input[type="range"]::-webkit-slider-thumb {
  -webkit-appearance: none; width: 18px; height: 18px; border-radius: 50%;
  background: var(--primary); cursor: pointer; box-shadow: 0 2px 8px rgba(255,107,53,.5);
}

.target-list { display: flex; flex-direction: column; gap: 10px; max-height: 220px; overflow-y: auto; }
.target-item {
  background: rgba(255,255,255,.03); border: 1px solid var(--glass-border);
  border-radius: 10px; padding: 10px 12px;
}
.target-item .t-top { display: flex; justify-content: space-between; margin-bottom: 6px; font-size: 13px; }
.target-item .t-label { color: var(--text); font-weight: 600; }
.target-item .t-score { color: var(--primary); font-weight: 700; }
.target-bar { height: 6px; background: rgba(255,255,255,.08); border-radius: 3px; overflow: hidden; }
.target-bar > div { height: 100%; background: linear-gradient(90deg, var(--primary), var(--primary-2)); border-radius: 3px; }

.history-list { display: flex; flex-wrap: wrap; gap: 8px; }
.history-item { width: 64px; height: 64px; border-radius: 8px; overflow: hidden; border: 1px solid var(--glass-border); cursor: pointer; }
.history-item img { width: 100%; height: 100%; object-fit: cover; }

.model-info { font-size: 13px; color: var(--text-dim); display: flex; flex-direction: column; gap: 6px; }
.model-info span { color: var(--text); }
.empty-hint { color: var(--text-dim); font-size: 13px; text-align: center; padding: 14px 0; }

/* ============ 响应式 ============ */
@media (max-width: 900px) {
  .workspace { flex-direction: column; }
  .panel { width: 100%; }
  .login-shell { flex-direction: column; }
  .login-hero { padding: 32px; }
  .login-card { padding: 32px; }
}
