:root {
  --bg: #0f1117;
  --card: #1a1d27;
  --card2: #222634;
  --text: #e8eaf0;
  --dim: #9aa1b3;
  --line: #2c3040;
  --accent: #4f7cff;
  --accent2: #7b5cff;
  --good: #35c98b;
  --warn: #f0a24a;
  --bad: #f0655a;
  --radius: 16px;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "Microsoft YaHei", Roboto, Helvetica, Arial, sans-serif;
}

* { box-sizing: border-box; }
body {
  margin: 0;
  background: radial-gradient(1200px 600px at 50% -10%, #1a2036 0%, var(--bg) 60%);
  color: var(--text);
  min-height: 100vh;
}

.hero { text-align: center; padding: 44px 20px 20px; }
.hero h1 { font-size: 2rem; margin: 0 0 10px; letter-spacing: 1px; }
.hero p { color: var(--dim); max-width: 680px; margin: 0 auto; line-height: 1.7; }
.hero strong { color: var(--text); }

main { max-width: 900px; margin: 0 auto; padding: 10px 20px 60px; }

.card {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 24px;
  margin: 16px 0;
  box-shadow: 0 8px 30px rgba(0,0,0,0.25);
}

.hidden { display: none !important; }

/* Upload */
.dropzone {
  border: 2px dashed var(--line);
  border-radius: var(--radius);
  padding: 40px 20px;
  text-align: center;
  cursor: pointer;
  transition: border-color .2s, background .2s;
  min-height: 220px;
  display: flex;
  align-items: center;
  justify-content: center;
}
.dropzone:hover, .dropzone.dragover { border-color: var(--accent); background: rgba(79,124,255,.06); }
.dz-inner { pointer-events: none; }
.dz-icon { font-size: 3rem; }
.dz-text { font-size: 1.05rem; }
.dz-text .link { color: var(--accent); font-weight: 600; }
.dz-hint { color: var(--dim); font-size: .85rem; }
.preview { max-width: 100%; max-height: 460px; border-radius: 12px; object-fit: contain; }

.actions { display: flex; gap: 12px; margin-top: 18px; flex-wrap: wrap; }
.btn {
  border: none;
  border-radius: 10px;
  padding: 12px 22px;
  font-size: 1rem;
  cursor: pointer;
  transition: transform .1s, opacity .2s, background .2s;
}
.btn.primary { background: linear-gradient(135deg, var(--accent), var(--accent2)); color: #fff; font-weight: 600; }
.btn.primary:disabled { opacity: .45; cursor: not-allowed; }
.btn.primary:not(:disabled):hover { transform: translateY(-1px); }
.btn.ghost { background: transparent; border: 1px solid var(--line); color: var(--dim); }
.btn.ghost:hover { color: var(--text); }

/* Loading */
#loading { text-align: center; }
.spinner {
  width: 46px; height: 46px; margin: 10px auto;
  border: 4px solid var(--line); border-top-color: var(--accent);
  border-radius: 50%; animation: spin .8s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }
.dim { color: var(--dim); font-size: .85rem; }

/* Score card */
.score-head { display: flex; gap: 26px; align-items: center; flex-wrap: wrap; }
.gauge { flex: 0 0 auto; }
.gauge svg { display: block; }
.grade { font-size: 1.8rem; font-weight: 800; }
.grade .label { font-size: 1rem; font-weight: 600; color: var(--dim); margin-left: 8px; }
.summary { color: var(--dim); margin: 8px 0; line-height: 1.6; }
.tags { display: flex; gap: 8px; flex-wrap: wrap; }
.tag { background: var(--card2); border: 1px solid var(--line); border-radius: 999px; padding: 4px 12px; font-size: .85rem; color: var(--text); }
.grade-note { color: var(--dim); margin-top: 16px; padding-top: 14px; border-top: 1px solid var(--line); }

h2 { font-size: 1.05rem; margin: 0 0 16px; }

/* Aspect bars */
.aspect { margin-bottom: 20px; }
.aspect:last-child { margin-bottom: 0; }
.aspect-head { display: flex; justify-content: space-between; align-items: baseline; margin-bottom: 6px; }
.aspect-name { font-weight: 600; }
.aspect-score { color: var(--accent); font-weight: 700; }
.aspect-score span { color: var(--dim); font-weight: 500; font-size: .85rem; }
.bar { height: 9px; background: var(--card2); border-radius: 999px; overflow: hidden; }
.bar-fill { height: 100%; border-radius: 999px; background: linear-gradient(90deg, var(--accent), var(--accent2)); width: 0; transition: width .8s ease; }
.aspect-comment { color: var(--dim); font-size: .88rem; margin-top: 7px; line-height: 1.6; }

/* Lists */
.two-col { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }
@media (max-width: 720px) { .two-col { grid-template-columns: 1fr; } }
.list { margin: 0; padding-left: 20px; line-height: 1.8; }
.list li { margin-bottom: 6px; }
.list.warn li { color: #f3c6a0; }
.mt { margin-top: 22px; }
.suggestions { margin: 0; padding-left: 22px; line-height: 1.8; }
.suggestions li { margin-bottom: 10px; }
.suggestions li::marker { color: var(--accent); font-weight: 700; }

/* Error */
.error { background: rgba(240,101,90,.08); border-color: var(--bad); }
.error p { color: #f3b2aa; }

footer { text-align: center; color: var(--dim); font-size: .82rem; padding: 30px 20px; }

/* ---------- Topbar ---------- */
.topbar {
  display: flex; align-items: center; justify-content: space-between;
  padding: 14px 22px; background: rgba(26,29,39,.85); border-bottom: 1px solid var(--line);
  position: sticky; top: 0; z-index: 10; backdrop-filter: blur(8px);
}
.brand { font-weight: 800; font-size: 1.05rem; }
.top-actions { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.user-label { color: var(--dim); font-size: .9rem; margin-right: 4px; }
.btn.sm { padding: 7px 14px; font-size: .88rem; border-radius: 8px; }
.hero-inline { text-align: center; color: var(--dim); max-width: 760px; margin: 0 auto; padding: 10px 20px; line-height: 1.7; }
.hero-inline strong { color: var(--text); }

/* ---------- Login page ---------- */
.login-page { background: radial-gradient(1200px 600px at 50% -10%, #1a2036 0%, var(--bg) 60%); }
.login-wrap { min-height: 90vh; display: flex; align-items: center; justify-content: center; padding: 20px; }
.login-card { width: 100%; max-width: 360px; padding: 32px 28px; }
.login-card h1 { font-size: 1.4rem; text-align: center; margin: 0 0 4px; }
.login-sub { color: var(--dim); text-align: center; margin: 0 0 22px; }
.field-label { display: block; font-size: .88rem; color: var(--dim); margin: 14px 0 6px; }
.login-card input {
  width: 100%; padding: 11px 12px; border: 1px solid var(--line); border-radius: 10px;
  background: var(--card2); color: var(--text); font-size: 1rem;
}
.login-card input:focus { outline: none; border-color: var(--accent); }
.login-error { color: #f3b2aa; background: rgba(240,101,90,.1); border: 1px solid var(--bad); padding: 9px 12px; border-radius: 8px; margin-top: 14px; font-size: .88rem; }
.btn.full { width: 100%; margin-top: 18px; }

/* ---------- Result ---------- */
.result-image { width: 100%; max-height: 420px; object-fit: contain; border-radius: 12px; margin-bottom: 18px; display: block; }
.saved-note { color: var(--good); text-align: center; margin-top: 14px; }
.panel-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 16px; }
.panel-head h2 { margin: 0; }

/* ---------- History ---------- */
.history-list { display: flex; flex-direction: column; gap: 12px; }
.history-item {
  display: flex; align-items: center; gap: 14px; padding: 10px;
  background: var(--card2); border: 1px solid var(--line); border-radius: 12px;
}
.history-thumb { width: 78px; height: 78px; border-radius: 8px; object-fit: cover; flex: 0 0 auto; background: #000; }
.history-info { flex: 1 1 auto; min-width: 0; }
.history-title { font-weight: 600; }
.history-meta { color: var(--dim); font-size: .85rem; margin-top: 4px; }
.history-actions { display: flex; gap: 8px; flex: 0 0 auto; }

/* ---------- Admin / users ---------- */
.user-form { display: flex; gap: 10px; flex-wrap: wrap; align-items: center; margin-bottom: 16px; }
.user-form input[type="text"], .user-form input[type="password"] {
  padding: 9px 11px; border: 1px solid var(--line); border-radius: 8px; background: var(--card2); color: var(--text);
}
.user-form .inline { display: flex; align-items: center; gap: 5px; color: var(--dim); font-size: .88rem; }
.user-table { width: 100%; border-collapse: collapse; }
.user-table th, .user-table td { text-align: left; padding: 9px 10px; border-bottom: 1px solid var(--line); font-size: .9rem; }
.user-table th { color: var(--dim); font-weight: 600; }
.user-actions { display: flex; gap: 6px; }
.success-msg { color: var(--good); background: rgba(53,201,139,.1); border: 1px solid var(--good); padding: 9px 12px; border-radius: 8px; margin: 12px 0; font-size: .88rem; }

@media (max-width: 640px) {
  .brand { font-size: .95rem; }
  .history-actions { flex-direction: column; }
}
