:root {
  --bg: #f6f7f9;
  --card: #ffffff;
  --ink: #16181d;
  --muted: #626875;
  --line: #e2e6ed;
  --accent: #1d4ed8;
  --accent-hover: #1e40af;
  --ok: #15803d;
  --ok-bg: #dcfce7;
  --warn: #b45309;
  --warn-bg: #fef3c7;
  --danger: #b91c1c;
  --danger-bg: #fee2e2;
  --radius: 12px;
}

* { box-sizing: border-box; }
body {
  margin: 0;
  font: 14px/1.55 -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC", "Microsoft YaHei", sans-serif;
  color: var(--ink);
  background: var(--bg);
}

[hidden] { display: none !important; }

/* Auth Gate */
.auth-gate {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 24px;
}
.auth-card {
  width: 100%;
  max-width: 420px;
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: 16px;
  padding: 28px;
  box-shadow: 0 12px 36px rgba(15, 23, 42, 0.06);
}
.auth-card h1 { margin: 6px 0 8px; font-size: 22px; }
.auth-sub { margin: 0 0 18px; color: var(--muted); font-size: 13px; }
.auth-tabs {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
  margin-bottom: 16px;
  background: var(--bg);
  padding: 4px;
  border-radius: 10px;
}
.auth-tab {
  border: none;
  background: transparent;
  padding: 8px;
  border-radius: 8px;
  cursor: pointer;
  font-weight: 600;
  color: var(--muted);
}
.auth-tab.active { background: var(--card); color: var(--ink); box-shadow: 0 1px 3px rgba(0,0,0,0.08); }
.auth-msg { color: var(--danger); font-size: 13px; min-height: 18px; margin: 12px 0 0; }

/* Topbar */
.topbar {
  position: sticky;
  top: 0;
  z-index: 20;
  display: flex;
  flex-wrap: wrap;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
  padding: 10px 20px;
  background: var(--card);
  border-bottom: 1px solid var(--line);
}
.topbar-left, .topbar-right { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.logo { font-size: 15px; margin-right: 6px; }
.nav-btn {
  border: 1px solid transparent;
  background: transparent;
  padding: 6px 12px;
  border-radius: 8px;
  cursor: pointer;
  font-weight: 600;
  color: var(--muted);
}
.nav-btn.active { background: #eff6ff; color: var(--accent); border-color: #bfdbfe; }
.user-badge { font-size: 13px; color: var(--muted); }
.btn-link {
  text-decoration: none;
  font-size: 12px;
  font-weight: 600;
  padding: 5px 10px;
  border-radius: 8px;
  background: var(--accent);
  color: #fff;
}

/* Layout */
.container { max-width: 1120px; margin: 0 auto; padding: 20px; }
.page-head { display: flex; justify-content: space-between; align-items: flex-start; gap: 16px; flex-wrap: wrap; margin-bottom: 16px; }
.page-head h1 { margin: 4px 0 0; font-size: 22px; }
.brand { font-size: 11px; letter-spacing: 0.08em; color: var(--muted); font-weight: 700; }
.sub { color: var(--muted); font-size: 12px; }

.panel {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 16px 18px;
  margin-bottom: 14px;
}
.panel h2 { margin: 0 0 8px; font-size: 16px; }
.intro { display: flex; justify-content: space-between; align-items: center; gap: 16px; flex-wrap: wrap; }
.intro p { margin: 0; color: var(--muted); font-size: 13px; }
.notice {
  width: 100%;
  margin-top: 8px;
  padding: 10px 12px;
  background: var(--warn-bg);
  color: var(--warn);
  border-radius: 8px;
  white-space: pre-line;
  font-size: 13px;
}

.project-head { display: flex; justify-content: space-between; align-items: center; gap: 12px; flex-wrap: wrap; margin-bottom: 10px; }
.project-head h2 { margin: 0; font-size: 18px; }
.settings { display: grid; grid-template-columns: repeat(auto-fit, minmax(240px, 1fr)); gap: 10px 16px; }
.settings .wide, .form-row .wide { grid-column: 1 / -1; }
.cards { display: grid; grid-template-columns: repeat(auto-fit, minmax(320px, 1fr)); gap: 14px; }

.platform-head { display: flex; justify-content: space-between; align-items: center; margin-bottom: 6px; }
.media { font-size: 12px; color: var(--muted); word-break: break-all; margin-bottom: 8px; }
.card-status {
  margin: 0 0 10px;
  padding: 8px 10px;
  border-radius: 8px;
  font-size: 13px;
  background: var(--bg);
}
.card-status[data-state="ready"], .card-status[data-state="verified"] { background: var(--ok-bg); color: var(--ok); }
.card-status[data-state="blocked"], .card-status[data-state="submission_unknown"] { background: var(--warn-bg); color: var(--warn); }
.card-status[data-state="working"] { background: #eff6ff; color: var(--accent); }

.edit { margin-bottom: 10px; }
.edit summary { cursor: pointer; font-size: 13px; color: var(--muted); margin-bottom: 6px; }
.warnings { color: var(--warn); font-size: 12px; margin: 6px 0 0; }

/* Form controls */
.stack { display: flex; flex-direction: column; gap: 12px; }
.form-row { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: 10px 12px; }
label { display: flex; flex-direction: column; gap: 4px; font-size: 13px; }
.settings label, .platform-head label, #resume-confirmation, #resume-cover-confirmation, #confirmation label {
  flex-direction: row;
  align-items: center;
  gap: 6px;
}
input[type="text"], input[type="password"], input[type="number"], textarea, select {
  width: 100%;
  padding: 8px 10px;
  border: 1px solid var(--line);
  border-radius: 8px;
  font: inherit;
  background: #fff;
}
.code-area { font-family: ui-monospace, SFMono-Regular, Menlo, monospace; font-size: 12px; margin-bottom: 10px; }

.actions { display: flex; flex-wrap: wrap; gap: 8px; }
button {
  padding: 7px 12px;
  border-radius: 8px;
  border: 1px solid var(--line);
  background: #fff;
  color: var(--ink);
  cursor: pointer;
  font: inherit;
  font-weight: 500;
}
button:hover:not(:disabled) { border-color: #cbd5e1; background: #f8fafc; }
button:disabled { opacity: 0.5; cursor: not-allowed; }
button.primary { background: var(--accent); border-color: var(--accent); color: #fff; }
button.primary:hover:not(:disabled) { background: var(--accent-hover); }
button.danger { background: var(--danger); border-color: var(--danger); color: #fff; }
button.ghost { border-color: transparent; background: transparent; color: var(--muted); }
button.full { width: 100%; padding: 10px; }

.pill {
  font-size: 12px;
  padding: 3px 9px;
  border-radius: 999px;
  background: var(--bg);
  color: var(--muted);
  font-weight: 600;
}
.pill[data-state="ok"] { background: var(--ok-bg); color: var(--ok); }
.pill[data-state="warn"] { background: var(--warn-bg); color: var(--warn); }

.tag { display: inline-block; font-size: 11px; padding: 2px 7px; border-radius: 6px; background: var(--bg); color: var(--muted); }
.tag.ok { background: var(--ok-bg); color: var(--ok); }
.tag.admin { background: #eff6ff; color: var(--accent); }
.tag.danger { background: var(--danger-bg); color: var(--danger); }

/* Admin tables */
.admin-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(360px, 1fr)); gap: 14px; }
.table-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; font-size: 13px; }
th, td { text-align: left; padding: 9px 10px; border-bottom: 1px solid var(--line); vertical-align: middle; }
th { font-size: 12px; color: var(--muted); font-weight: 600; }
.row-actions { display: flex; gap: 6px; flex-wrap: wrap; }
.row-actions button { padding: 4px 8px; font-size: 12px; }

/* Dialogs & Toast */
dialog {
  border: 1px solid var(--line);
  border-radius: 14px;
  padding: 22px;
  max-width: 480px;
  width: 92vw;
  box-shadow: 0 20px 50px rgba(0, 0, 0, 0.18);
}
dialog::backdrop { background: rgba(15, 23, 42, 0.45); }
.toast {
  position: fixed;
  top: 16px;
  right: 16px;
  z-index: 100;
  padding: 10px 16px;
  border-radius: 10px;
  background: #16181d;
  color: #fff;
  font-size: 13px;
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.2);
}
.toast[data-error="1"] { background: var(--danger); }
#live { color: var(--muted); font-size: 13px; min-height: 20px; }

/* Update banner & Guide / Changelog / Privacy page */
.update-banner {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: center;
  gap: 10px;
  padding: 10px 20px;
  background: var(--warn-bg);
  color: var(--warn);
  border-bottom: 1px solid #fde68a;
  font-size: 13px;
  font-weight: 500;
}
.guide-section h2 { margin-bottom: 12px; }
.section-head-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
  flex-wrap: wrap;
  margin-bottom: 12px;
}
.section-head-row h2 { margin: 0; }
.guide-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(300px, 1fr));
  gap: 14px;
}
.guide-step {
  display: flex;
  gap: 12px;
  padding: 14px;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: #fafbfc;
}
.step-num {
  flex: 0 0 28px;
  height: 28px;
  border-radius: 50%;
  background: var(--accent);
  color: #fff;
  display: grid;
  place-items: center;
  font-weight: 700;
  font-size: 13px;
}
.guide-step h3, .privacy-item h3 { margin: 0 0 6px; font-size: 14px; }
.guide-step p, .privacy-item p { margin: 0; font-size: 13px; color: var(--muted); }
.info-callout {
  padding: 12px 14px;
  border-radius: 10px;
  background: #eff6ff;
  border: 1px solid #bfdbfe;
  font-size: 13px;
  margin-bottom: 14px;
}
.info-callout ul { margin: 6px 0 0; padding-left: 18px; }
.info-callout li { margin: 4px 0; }
.changelog-list { display: flex; flex-direction: column; gap: 12px; }
.changelog-item {
  padding: 14px 16px;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: #fafbfc;
}
.changelog-head {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px;
  margin-bottom: 8px;
}
.changelog-item ul { margin: 0; padding-left: 18px; font-size: 13px; color: var(--ink); }
.changelog-item li { margin: 4px 0; }
.privacy-panel { border-color: #bbf7d0; background: #f8fffb; }
.privacy-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
  gap: 12px;
}
.privacy-item {
  padding: 14px;
  border-radius: 10px;
  background: #fff;
  border: 1px solid #dcfce7;
}
code {
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  font-size: 12px;
  padding: 1px 5px;
  border-radius: 4px;
  background: #eef2f6;
}
