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

:root {
  --bg: #fafafa;
  --fg: #1a1a1a;
  --muted: #6b6b6b;
  --border: #e0e0e0;
  --accent: #1a1a1a;
  --accent-fg: #fff;
  --danger: #c00;
  --radius: 8px;
  --max-w: 420px;
}

html { font-size: 16px; }
html, body {
  height: 100%;
}
body {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  background: var(--bg);
  color: var(--fg);
  min-height: 100vh;
  min-height: 100dvh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 1.5rem;
}

.container {
  width: 100%;
  max-width: var(--max-w);
  margin: auto;
}

/* ── Logo ─────────────────────────────────────── */
.logo {
  text-align: center;
  margin-bottom: 2.5rem;
}
.logo h1 {
  font-size: 1.6rem;
  font-weight: 600;
  letter-spacing: -0.02em;
  color: var(--fg);
}
.logo p {
  font-size: 0.9rem;
  color: var(--muted);
  margin-top: 0.3rem;
  line-height: 1.5;
}

/* ── Tabs ─────────────────────────────────────── */
.tabs {
  display: flex;
  gap: 0;
  margin-bottom: 1.5rem;
  border-bottom: 1px solid var(--border);
}
.tab {
  flex: 1;
  text-align: center;
  padding: 0.7rem 0;
  font-size: 0.9rem;
  cursor: pointer;
  color: var(--muted);
  border-bottom: 2px solid transparent;
  transition: color 0.15s, border-color 0.15s;
  background: none;
  border-top: none;
  border-left: none;
  border-right: none;
  font-family: inherit;
}
.tab.active {
  color: var(--fg);
  border-bottom-color: var(--fg);
  font-weight: 500;
}

/* ── Forms ─────────────────────────────────────── */
.form { display: none; }
.form.active { display: block; }

.field {
  margin-bottom: 1rem;
}
.field label {
  display: block;
  font-size: 0.8rem;
  font-weight: 500;
  color: var(--muted);
  margin-bottom: 0.35rem;
  text-transform: uppercase;
  letter-spacing: 0.04em;
}
.field input {
  width: 100%;
  padding: 0.65rem 0.85rem;
  font-size: 0.95rem;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: #fff;
  outline: none;
  transition: border-color 0.15s;
  font-family: inherit;
}
.field input:focus {
  border-color: var(--fg);
}
.btn {
  width: 100%;
  padding: 0.7rem;
  font-size: 0.9rem;
  font-weight: 500;
  border: none;
  border-radius: var(--radius);
  cursor: pointer;
  background: var(--accent);
  color: var(--accent-fg);
  font-family: inherit;
  transition: opacity 0.15s;
}
.btn:hover { opacity: 0.88; }
.btn:disabled { opacity: 0.4; cursor: not-allowed; }

.error-msg {
  color: var(--danger);
  font-size: 0.82rem;
  margin-top: 0.75rem;
  text-align: center;
  display: none;
}
.error-msg.visible { display: block; }

/* ── Logged-in state ───────────────────────────── */
.logged-in { display: none; }
.logged-in.active { display: block; }

.user-bar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 1.5rem;
  font-size: 0.85rem;
}
.user-bar .email { color: var(--muted); }
.user-bar .logout { color: var(--muted); cursor: pointer; text-decoration: underline; font-size: 0.82rem; background: none; border: none; font-family: inherit; }
.user-bar .logout:hover { color: var(--danger); }

/* ── Upload zone ───────────────────────────────── */
.upload-zone {
  border: 2px dashed var(--border);
  border-radius: var(--radius);
  padding: 2rem;
  text-align: center;
  cursor: pointer;
  transition: border-color 0.15s, background 0.15s;
  margin-bottom: 1rem;
}
.upload-zone:hover, .upload-zone.drag {
  border-color: var(--fg);
  background: rgba(0,0,0,0.02);
}
.upload-zone p { font-size: 0.88rem; color: var(--muted); }
.upload-zone .filename { font-weight: 500; color: var(--fg); margin-top: 0.3rem; word-break: break-all; }

.progress-wrap { margin: 0.75rem 0; display: none; }
.progress-wrap.active { display: block; }
.progress-bar {
  height: 4px;
  background: var(--border);
  border-radius: 2px;
  overflow: hidden;
}
.progress-fill {
  height: 100%;
  width: 0%;
  background: var(--fg);
  border-radius: 2px;
  transition: width 0.15s;
}
.progress-text { font-size: 0.75rem; color: var(--muted); margin-top: 0.3rem; }

.result { font-size: 0.82rem; margin-top: 0.75rem; text-align: center; display: none; }
.result.visible { display: block; }
.result.success { color: #1a7a1a; }
.result.error { color: var(--danger); }

/* ── Chat link ─────────────────────────────────── */
.chat-link {
  display: block;
  text-align: center;
  margin-top: 1.5rem;
  padding: 0.7rem;
  font-size: 0.88rem;
  color: var(--muted);
  text-decoration: none;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  transition: border-color 0.15s, color 0.15s;
}
.chat-link:hover { border-color: var(--fg); color: var(--fg); }

/* ── Landing: role buttons ────────────────────── */
.role-buttons {
  display: flex;
  flex-direction: column;
  gap: 1rem;
  margin-bottom: 1.5rem;
}
.role-btn {
  display: flex;
  flex-direction: column;
  align-items: center;
  padding: 1.5rem 1rem;
  border: 2px solid var(--border);
  border-radius: var(--radius);
  background: #fff;
  cursor: pointer;
  transition: border-color 0.15s, box-shadow 0.15s;
  font-family: inherit;
  text-align: center;
}
.role-btn:hover {
  border-color: var(--fg);
  box-shadow: 0 2px 8px rgba(0,0,0,0.06);
}
.role-icon {
  font-size: 1.8rem;
  margin-bottom: 0.5rem;
}
.role-label {
  font-size: 0.95rem;
  font-weight: 500;
  color: var(--fg);
}
.role-label-zh {
  font-size: 0.82rem;
  color: var(--muted);
  margin-top: 0.2rem;
}

/* ── Taglines ──────────────────────────────────── */
.tagline {
  font-size: 0.92rem;
  color: var(--muted);
  margin-top: 0.3rem;
  line-height: 1.5;
}
.tagline-zh {
  font-size: 0.85rem;
  color: var(--muted);
  margin-top: 0.15rem;
  line-height: 1.5;
}

/* ── Auth note ──────────────────────────────────── */
.note {
  text-align: center;
  font-size: 0.8rem;
  color: var(--muted);
  margin-top: 1.25rem;
  line-height: 1.6;
  padding: 0.75rem;
  background: rgba(0,0,0,0.02);
  border-radius: var(--radius);
}

/* ── Back link ──────────────────────────────────── */
.back-link {
  text-align: center;
  margin-top: 1rem;
  font-size: 0.82rem;
}
.back-link a {
  color: var(--muted);
  text-decoration: none;
}
.back-link a:hover {
  color: var(--fg);
}

/* ── Footer ────────────────────────────────────── */
.footer {
  text-align: center;
  margin-top: 2rem;
  font-size: 0.72rem;
  color: var(--muted);
  opacity: 0.6;
}
