/* Shared design tokens — login + chat */
:root {
  --bg: #f7f7f8;
  --surface: #ffffff;
  --text: #1f2937;
  --text-muted: #6b7280;
  --border: #e5e7eb;
  --accent: #0d9488;
  --accent-hover: #0f766e;
  --accent-light: rgba(13, 148, 136, 0.1);
  --danger: #ef4444;
  --danger-bg: #fef2f2;
  --success: #10b981;
  --shadow: 0 1px 3px rgba(0, 0, 0, 0.06), 0 4px 16px rgba(0, 0, 0, 0.04);
  --radius: 12px;
  --font: "Inter", "Noto Sans SC", "PingFang SC", "Microsoft YaHei", system-ui, sans-serif;
}

[data-theme="dark"] {
  --bg: #212121;
  --surface: #2a2a2a;
  --text: #ececec;
  --text-muted: #a1a1aa;
  --border: #333333;
  --accent: #2dd4bf;
  --accent-hover: #14b8a6;
  --accent-light: rgba(45, 212, 191, 0.12);
  --danger: #f87171;
  --danger-bg: rgba(239, 68, 68, 0.1);
  --shadow: 0 1px 3px rgba(0, 0, 0, 0.3), 0 4px 16px rgba(0, 0, 0, 0.2);
}

* { box-sizing: border-box; margin: 0; padding: 0; }

body.auth-page {
  min-height: 100vh;
  font-family: var(--font);
  background: var(--bg);
  color: var(--text);
  display: flex;
  flex-direction: column;
}

.auth-topbar {
  display: flex;
  justify-content: flex-end;
  padding: 1rem 1.5rem;
}

.theme-toggle {
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--text-muted);
  border-radius: 8px;
  padding: .4rem .7rem;
  font-size: .82rem;
  cursor: pointer;
}
.theme-toggle:hover { color: var(--text); border-color: var(--accent); }

.auth-main {
  flex: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 2rem 1.25rem 3rem;
}

.auth-card {
  width: min(420px, 100%);
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 16px;
  padding: 2.25rem 2rem 2rem;
  box-shadow: var(--shadow);
}

.brand {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: .6rem;
  margin-bottom: 1.75rem;
}
.brand-logo {
  width: 36px;
  height: 36px;
  border-radius: 10px;
  object-fit: contain;
}
.brand-icon {
  width: 36px;
  height: 36px;
  border-radius: 10px;
  background: var(--accent-light);
  color: var(--accent);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.1rem;
  font-weight: 700;
}
.brand-name {
  font-size: 1.15rem;
  font-weight: 600;
  letter-spacing: -0.01em;
}

.auth-title {
  font-size: 1.5rem;
  font-weight: 600;
  text-align: center;
  margin-bottom: .35rem;
  letter-spacing: -0.02em;
}
.auth-subtitle {
  text-align: center;
  color: var(--text-muted);
  font-size: .9rem;
  margin-bottom: 1.75rem;
}

.form-group { margin-bottom: 1.1rem; }
.form-group label {
  display: block;
  font-size: .85rem;
  font-weight: 500;
  margin-bottom: .4rem;
  color: var(--text);
}

.input-wrap {
  position: relative;
}
.form-input {
  width: 100%;
  padding: .72rem .85rem;
  border: 1px solid var(--border);
  border-radius: 10px;
  font-size: .95rem;
  background: var(--bg);
  color: var(--text);
  font-family: inherit;
  transition: border-color .15s, box-shadow .15s;
}
.form-input:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-light);
}
.form-input.error { border-color: var(--danger); }
.form-input.error:focus { box-shadow: 0 0 0 3px rgba(239, 68, 68, 0.15); }

.toggle-pw {
  position: absolute;
  right: .65rem;
  top: 50%;
  transform: translateY(-50%);
  border: none;
  background: none;
  color: var(--text-muted);
  cursor: pointer;
  font-size: .8rem;
  padding: .25rem .4rem;
  border-radius: 4px;
}
.toggle-pw:hover { color: var(--text); }

.form-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 1.25rem;
  font-size: .85rem;
}
.checkbox-label {
  display: flex;
  align-items: center;
  gap: .4rem;
  cursor: pointer;
  color: var(--text-muted);
  user-select: none;
}
.checkbox-label input { accent-color: var(--accent); }
.text-link {
  color: var(--accent);
  text-decoration: none;
  font-weight: 500;
}
.text-link:hover { text-decoration: underline; }

.btn-primary {
  width: 100%;
  padding: .78rem 1rem;
  border: none;
  border-radius: 10px;
  background: var(--accent);
  color: #fff;
  font-size: .95rem;
  font-weight: 600;
  cursor: pointer;
  font-family: inherit;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: .5rem;
  transition: background .15s;
}
.btn-primary:hover:not(:disabled) { background: var(--accent-hover); }
.btn-primary:disabled { opacity: .65; cursor: not-allowed; }

.spinner {
  width: 16px;
  height: 16px;
  border: 2px solid rgba(255,255,255,.3);
  border-top-color: #fff;
  border-radius: 50%;
  animation: spin .7s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

.form-error {
  margin-top: .85rem;
  padding: .65rem .8rem;
  background: var(--danger-bg);
  color: var(--danger);
  border-radius: 8px;
  font-size: .85rem;
  line-height: 1.45;
}
.field-error {
  color: var(--danger);
  font-size: .78rem;
  margin-top: .3rem;
  min-height: 1.1em;
}

.divider {
  display: flex;
  align-items: center;
  gap: .75rem;
  margin: 1.5rem 0;
  color: var(--text-muted);
  font-size: .8rem;
}
.divider::before, .divider::after {
  content: "";
  flex: 1;
  height: 1px;
  background: var(--border);
}

.oauth-btns {
  display: flex;
  flex-direction: column;
  gap: .55rem;
}
.oauth-btn {
  width: 100%;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: .55rem;
  padding: .65rem;
  border: 1px solid var(--border);
  border-radius: 10px;
  background: var(--surface);
  color: var(--text);
  font-size: .88rem;
  font-weight: 500;
  cursor: pointer;
  font-family: inherit;
  transition: background .15s, border-color .15s;
}
.oauth-btn:hover { background: var(--bg); border-color: var(--accent); }
.oauth-btn svg { width: 18px; height: 18px; flex-shrink: 0; }

.auth-footer {
  text-align: center;
  margin-top: 1.5rem;
  font-size: .88rem;
  color: var(--text-muted);
}
.auth-footer a { color: var(--accent); text-decoration: none; font-weight: 500; }
.auth-footer a:hover { text-decoration: underline; }

.legal {
  text-align: center;
  padding: 1.5rem;
  font-size: .75rem;
  color: var(--text-muted);
  line-height: 1.6;
}
.legal a { color: var(--text-muted); text-decoration: underline; }
.legal a:hover { color: var(--accent); }

/* Modal */
.modal-overlay {
  position: fixed; inset: 0; background: rgba(0,0,0,.45);
  display: flex; align-items: center; justify-content: center;
  padding: 1rem; z-index: 100;
}
.modal-overlay.hidden { display: none; }
.modal-box {
  background: var(--surface);
  border-radius: 14px;
  padding: 1.5rem;
  width: min(400px, 100%);
  box-shadow: var(--shadow);
}
.modal-box h3 { font-size: 1.05rem; margin-bottom: .5rem; }
.modal-box p { font-size: .88rem; color: var(--text-muted); line-height: 1.55; margin-bottom: 1rem; }
.modal-actions { display: flex; gap: .5rem; justify-content: flex-end; }
.btn-secondary {
  padding: .55rem 1rem; border: 1px solid var(--border); border-radius: 8px;
  background: var(--bg); color: var(--text); cursor: pointer; font-size: .88rem;
}

@media (max-width: 480px) {
  .auth-card { padding: 1.75rem 1.25rem 1.5rem; }
  .auth-title { font-size: 1.3rem; }
}
