@import url('https://fonts.googleapis.com/css2?family=Inter:wght@400;500;600;700;800&display=swap');

:root {
  --bg: #09090b;
  --surface: #111114;
  --surface2: #18181c;
  --surface3: #222228;
  --border: rgba(255,255,255,0.06);
  --border-hover: rgba(255,255,255,0.12);
  --text: #ececef;
  --text-secondary: #a1a1aa;
  --text-muted: #52525b;
  --accent: #a78bfa;
  --accent-bright: #c4b5fd;
  --accent-dim: #7c3aed;
  --accent-glow: rgba(167,139,250,0.08);
  --human: #60a5fa;
  --human-bg: rgba(96,165,250,0.05);
  --human-border: rgba(96,165,250,0.15);
  --assistant: #34d399;
  --assistant-bg: rgba(52,211,153,0.05);
  --assistant-border: rgba(52,211,153,0.15);
  --danger: #f87171;
  --radius: 14px;
  --radius-sm: 10px;
  --shadow: 0 1px 3px rgba(0,0,0,0.3), 0 4px 20px rgba(0,0,0,0.15);
}

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

body {
  font-family: 'Inter', -apple-system, BlinkMacSystemFont, sans-serif;
  background: var(--bg);
  color: var(--text);
  min-height: 100vh;
  -webkit-font-smoothing: antialiased;
}

body::before {
  content: '';
  position: fixed; top: -30%; left: 50%; transform: translateX(-50%);
  width: 140%; height: 60%;
  background: radial-gradient(ellipse, rgba(124,58,237,0.06) 0%, transparent 70%);
  z-index: -1; pointer-events: none;
}

/* ── Topbar ── */
.topbar {
  position: sticky; top: 0; z-index: 100;
  background: rgba(9,9,11,0.82);
  backdrop-filter: blur(20px); -webkit-backdrop-filter: blur(20px);
  border-bottom: 1px solid var(--border);
}
.topbar-inner {
  max-width: 760px; margin: 0 auto;
  padding: 0.85rem 1.5rem;
  display: flex; align-items: center; justify-content: space-between;
}
.brand {
  display: flex; align-items: center; gap: 0.65rem;
  text-decoration: none;
}
.brand-logo { width: 28px; height: 28px; flex-shrink: 0; }
.brand-name {
  font-size: 0.88rem; font-weight: 700; letter-spacing: -0.01em;
  color: var(--text);
}
.topbar-actions { display: flex; align-items: center; gap: 0.6rem; }
.topbar-link {
  color: var(--text-muted); padding: 0.35rem;
  border-radius: 6px; display: flex;
  transition: color 0.15s, background 0.15s;
}
.topbar-link:hover { color: var(--text-secondary); background: var(--surface2); }
.lang-toggle {
  background: var(--surface2); border: 1px solid var(--border);
  border-radius: 6px; padding: 0.3rem 0.65rem;
  cursor: pointer; transition: all 0.15s;
}
.lang-toggle:hover { border-color: var(--border-hover); background: var(--surface3); }
.lang-label {
  font-size: 0.72rem; font-weight: 700; letter-spacing: 0.04em;
  color: var(--text-secondary); font-family: inherit;
}

/* ── Container ── */
.container { max-width: 760px; margin: 0 auto; padding: 0 1.5rem 4rem; }

/* ── Hero ── */
.hero {
  display: flex; flex-direction: column; align-items: center;
  text-align: center;
  padding: 5rem 0 2rem;
  min-height: calc(100vh - 52px - 4rem);
  justify-content: center;
}
.hero-title {
  font-size: 2.5rem; font-weight: 800; letter-spacing: -0.04em;
  line-height: 1.1; margin-bottom: 0.85rem;
  background: linear-gradient(160deg, #fff 30%, var(--accent-bright) 100%);
  -webkit-background-clip: text; -webkit-text-fill-color: transparent;
}
.hero-desc {
  font-size: 1.05rem; line-height: 1.65;
  color: var(--text-muted); max-width: 460px;
  margin-bottom: 3rem;
}

/* Hero collapses after upload */
.hero.hidden .hero-title,
.hero.hidden .hero-desc,
.hero.hidden .trust-strip { display: none; }
.hero.hidden {
  padding: 1.5rem 0 0;
  min-height: auto; justify-content: flex-start;
}

/* ── Upload Zone ── */
.upload-wrap { width: 100%; max-width: 480px; margin-bottom: 2rem; }

.upload-zone {
  border: 2px dashed rgba(255,255,255,0.08);
  border-radius: 16px;
  padding: 3rem 2rem;
  display: flex; flex-direction: column; align-items: center;
  gap: 1rem;
  cursor: pointer;
  transition: all 0.3s cubic-bezier(0.4,0,0.2,1);
  background: var(--surface);
  position: relative; overflow: hidden;
}
.upload-zone::before {
  content: '';
  position: absolute; inset: 0;
  background: radial-gradient(circle at 50% 40%, rgba(167,139,250,0.06), transparent 70%);
  opacity: 0; transition: opacity 0.35s;
}
.upload-zone:hover::before, .upload-zone.dragover::before { opacity: 1; }
.upload-zone:hover, .upload-zone.dragover {
  border-color: rgba(167,139,250,0.35);
  background: var(--surface2);
  transform: translateY(-2px);
  box-shadow: 0 0 0 1px rgba(167,139,250,0.08), 0 12px 40px rgba(0,0,0,0.35);
}
.upload-zone.dragover { border-color: var(--accent); }
.upload-zone input { display: none; }

.upload-icon-large {
  width: 72px; height: 72px; border-radius: 18px;
  background: linear-gradient(135deg, rgba(124,58,237,0.12), rgba(167,139,250,0.06));
  border: 1px solid rgba(167,139,250,0.1);
  display: flex; align-items: center; justify-content: center;
  position: relative;
}
.upload-main-text {
  font-size: 1rem; color: var(--text-secondary); font-weight: 500;
  position: relative;
}
.upload-main-text strong {
  color: var(--accent-bright);
  border-bottom: 1px dashed rgba(167,139,250,0.4);
  padding-bottom: 1px;
}
.upload-hint {
  font-size: 0.78rem; color: var(--text-muted); position: relative;
  margin-top: -0.4rem;
}

/* Compact mode after results */
.upload-wrap.has-results { max-width: 100%; margin-bottom: 0; }
.upload-wrap.has-results .upload-zone {
  padding: 0.8rem 1.5rem;
  flex-direction: row; gap: 0.8rem;
  border-radius: var(--radius-sm);
  border-style: solid; border-width: 1px;
}
.upload-wrap.has-results .upload-icon-large {
  width: 36px; height: 36px; border-radius: 9px;
}
.upload-wrap.has-results .upload-icon-large svg { width: 18px; height: 18px; }
.upload-wrap.has-results .upload-main-text { font-size: 0.84rem; }
.upload-wrap.has-results .upload-hint { display: none; }

/* ── Trust strip (replaces feature cards) ── */
.trust-strip {
  display: flex; align-items: center; justify-content: center;
  gap: 0.6rem;
  color: var(--text-muted);
  font-size: 0.75rem; font-weight: 500;
}
.trust-item {
  display: flex; align-items: center; gap: 0.3rem;
}
.trust-item svg {
  width: 13px; height: 13px;
  stroke: currentColor; fill: none; stroke-width: 1.8;
  stroke-linecap: round; stroke-linejoin: round;
  opacity: 0.5;
}
.trust-dot {
  width: 3px; height: 3px; border-radius: 50%;
  background: var(--text-muted); opacity: 0.3;
}

/* ── Processing ── */
.processing {
  display: none; text-align: center; padding: 3rem 2rem;
  background: var(--surface); border-radius: var(--radius);
  border: 1px solid var(--border); margin-top: 1.5rem;
}
.processing.active { display: block; animation: fadeIn 0.3s; }
@keyframes fadeIn { from { opacity:0; transform:translateY(8px) } to { opacity:1; transform:translateY(0) } }
.proc-spinner {
  width: 36px; height: 36px;
  border: 2.5px solid var(--surface3);
  border-top-color: var(--accent);
  border-radius: 50%;
  animation: spin 0.7s linear infinite;
  margin: 0 auto 1rem;
}
@keyframes spin { to { transform: rotate(360deg) } }
.proc-text { color: var(--text-secondary); font-size: 0.9rem; font-weight: 500; }

/* ── Error ── */
.error-msg {
  background: rgba(248,113,113,0.06);
  border: 1px solid rgba(248,113,113,0.2);
  border-radius: var(--radius-sm);
  padding: 0.85rem 1.15rem; color: var(--danger);
  margin-top: 1rem; display: none;
  font-size: 0.85rem; font-weight: 500;
  animation: fadeIn 0.3s;
}
.error-msg.active { display: flex; align-items: center; gap: 0.5rem; }

/* ── Results ── */
.results { display: none; margin-top: 1.75rem; }
.results.active { display: block; animation: fadeIn 0.4s; }

/* ── Session Card ── */
.session-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
  margin-bottom: 1rem;
  box-shadow: var(--shadow);
  transition: border-color 0.2s;
}
.session-card:hover { border-color: var(--border-hover); }

.session-header {
  padding: 1.25rem 1.5rem;
  border-bottom: 1px solid var(--border);
}
.session-title {
  font-size: 1.05rem; font-weight: 700; letter-spacing: -0.01em;
  margin-bottom: 0.35rem;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.session-meta { display: flex; flex-wrap: wrap; gap: 0.25rem 1rem; }
.meta-tag {
  font-size: 0.75rem; color: var(--text-muted); font-weight: 500;
  display: flex; align-items: center; gap: 0.3rem;
}
.meta-tag svg {
  width: 13px; height: 13px; opacity: 0.5;
  stroke: currentColor; fill: none; stroke-width: 2;
}
.meta-tag .meta-val { color: var(--text-secondary); }

/* ── Stats ── */
.session-stats { display: flex; border-bottom: 1px solid var(--border); }
.sstat {
  flex: 1; padding: 0.85rem 1rem; text-align: center;
  border-right: 1px solid var(--border);
  transition: background 0.15s;
}
.sstat:last-child { border-right: none; }
.sstat:hover { background: var(--surface2); }
.sstat-val {
  font-size: 1.35rem; font-weight: 800; letter-spacing: -0.02em;
  background: linear-gradient(135deg, var(--accent-bright), var(--accent));
  -webkit-background-clip: text; -webkit-text-fill-color: transparent;
}
.sstat-val.green {
  background: linear-gradient(135deg, #6ee7b7, #34d399);
  -webkit-background-clip: text; -webkit-text-fill-color: transparent;
}
.sstat-label {
  font-size: 0.7rem; color: var(--text-muted); margin-top: 0.1rem;
  font-weight: 600; text-transform: uppercase; letter-spacing: 0.05em;
}

/* ── Actions ── */
.session-actions {
  padding: 0.85rem 1.5rem;
  display: flex; gap: 0.6rem; align-items: center;
  border-bottom: 1px solid var(--border);
  background: var(--surface2);
}
.btn {
  padding: 0.5rem 1.15rem; border-radius: 8px; border: none;
  font-size: 0.8rem; font-weight: 600; font-family: inherit;
  cursor: pointer; transition: all 0.15s;
  text-decoration: none;
  display: inline-flex; align-items: center; gap: 0.35rem;
  white-space: nowrap;
}
.btn-primary {
  background: var(--accent-dim); color: white;
  box-shadow: 0 0 0 1px rgba(124,58,237,0.3), 0 2px 8px rgba(124,58,237,0.2);
}
.btn-primary:hover {
  background: #8b5cf6;
  box-shadow: 0 0 0 1px rgba(139,92,246,0.5), 0 4px 16px rgba(124,58,237,0.3);
  transform: translateY(-1px);
}
.btn-ghost {
  background: transparent; color: var(--text-secondary);
  border: 1px solid var(--border);
}
.btn-ghost:hover {
  border-color: var(--border-hover); color: var(--text); background: var(--surface3);
}
.btn svg {
  width: 14px; height: 14px;
  stroke: currentColor; fill: none; stroke-width: 2;
}

/* ── Preview ── */
.preview-wrap { display: none; }
.preview-wrap.open { display: block; }
.preview-header {
  padding: 0.75rem 1.5rem;
  font-size: 0.78rem; font-weight: 600;
  color: var(--text-muted); text-transform: uppercase; letter-spacing: 0.06em;
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  display: flex; align-items: center; gap: 0.4rem;
}
.preview-header svg {
  width: 14px; height: 14px;
  stroke: currentColor; fill: none; stroke-width: 2; opacity: 0.5;
}

.msg {
  padding: 1rem 1.5rem;
  border-bottom: 1px solid var(--border);
  transition: background 0.15s;
}
.msg:last-child { border-bottom: none; }
.msg:hover { background: var(--surface2); }
.msg.human { background: var(--human-bg); }
.msg.human:hover { background: rgba(96,165,250,0.09); }
.msg.assistant { background: var(--assistant-bg); }
.msg.assistant:hover { background: rgba(52,211,153,0.09); }

.msg-top { display: flex; align-items: center; gap: 0.5rem; margin-bottom: 0.4rem; }
.msg-role-badge {
  font-size: 0.65rem; font-weight: 700;
  text-transform: uppercase; letter-spacing: 0.08em;
  padding: 0.15rem 0.5rem; border-radius: 4px;
}
.msg.human .msg-role-badge { background: var(--human-border); color: var(--human); }
.msg.assistant .msg-role-badge { background: var(--assistant-border); color: var(--assistant); }
.msg-index { font-size: 0.7rem; color: var(--text-muted); }

.msg-body {
  font-size: 0.84rem; line-height: 1.7;
  color: var(--text-secondary); white-space: pre-wrap; word-break: break-word;
  max-height: 200px; overflow-y: auto;
}
.msg-body::-webkit-scrollbar { width: 4px; }
.msg-body::-webkit-scrollbar-track { background: transparent; }
.msg-body::-webkit-scrollbar-thumb { background: var(--surface3); border-radius: 4px; }

.more-indicator {
  text-align: center; padding: 1rem 1.5rem;
  color: var(--text-muted); font-size: 0.8rem; font-weight: 500;
  background: var(--surface);
}

/* ── Batch bar ── */
.batch-bar {
  background: linear-gradient(135deg, var(--surface2), var(--surface));
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1.25rem 1.5rem;
  margin-bottom: 1.25rem;
  display: flex; align-items: center; justify-content: space-between;
  gap: 1rem; flex-wrap: wrap;
  box-shadow: var(--shadow);
}
.batch-stats { display: flex; gap: 1.5rem; }
.batch-stat-item { text-align: center; }
.batch-stat-val { font-size: 1.5rem; font-weight: 800; color: var(--accent-bright); }
.batch-stat-lbl {
  font-size: 0.7rem; color: var(--text-muted); font-weight: 600;
  text-transform: uppercase; letter-spacing: 0.04em;
}

/* ── Responsive ── */
@media (max-width: 640px) {
  .container { padding: 0 1rem 3rem; }
  .hero { padding: 3rem 0 1.5rem; min-height: auto; }
  .hero-title { font-size: 1.75rem; }
  .upload-zone { padding: 2.25rem 1.5rem; }
  .trust-strip { flex-wrap: wrap; gap: 0.4rem; }
  .session-stats { flex-wrap: wrap; }
  .sstat { min-width: 50%; }
  .batch-bar { flex-direction: column; align-items: stretch; text-align: center; }
  .batch-stats { justify-content: center; }
}
