:root {
    --bg: #0f1116;
    --panel: #161922;
    --panel2: #1c2030;
    --border: #262b3a;
    --text: #e8eaf2;
    --muted: #8a92a8;
    --accent: #7aa7ff;
    --green: #43b581;
    --yellow: #e4b338;
    --red: #d65a5a;
}

* { box-sizing: border-box; }

html, body {
    margin: 0; padding: 0;
    background: var(--bg);
    color: var(--text);
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
    font-size: 14px;
    line-height: 1.5;
}

a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }

.topbar {
    display: flex; align-items: center; justify-content: space-between;
    padding: 12px 24px;
    background: var(--panel);
    border-bottom: 1px solid var(--border);
    position: sticky; top: 0; z-index: 5;
}
.topbar .brand { font-weight: 600; color: var(--text); }
.topbar .user { color: var(--muted); font-size: 12px; }
button.link {
    background: none; border: none; color: var(--accent);
    cursor: pointer; font-size: 12px; padding: 0 0 0 8px;
}

main { padding: 24px; max-width: 1300px; margin: 0 auto; }

h1 { margin: 0 0 4px; font-size: 22px; font-weight: 600; }
h2 { font-size: 16px; margin: 0 0 12px; color: var(--text); }
.muted { color: var(--muted); font-size: 12px; }
.empty { color: var(--muted); padding: 32px 0; text-align: center; }
.error {
    background: rgba(214,90,90,0.15);
    border: 1px solid rgba(214,90,90,0.4);
    color: #ffb4b4;
    padding: 8px 12px; border-radius: 6px; margin-bottom: 12px;
}
.back { display: inline-block; margin-bottom: 12px; color: var(--muted); }

/* ---- login ---- */
.auth-card {
    max-width: 360px; margin: 80px auto 0;
    background: var(--panel); border: 1px solid var(--border);
    border-radius: 12px; padding: 24px;
}
.form { display: flex; flex-direction: column; gap: 12px; margin-top: 16px; }
.form label { display: flex; flex-direction: column; gap: 4px; font-size: 12px; color: var(--muted); }
.form input {
    background: var(--bg); border: 1px solid var(--border);
    color: var(--text); padding: 8px 10px; border-radius: 6px; font-size: 14px;
}
.btn {
    background: var(--accent); color: #0c1322; border: none;
    padding: 10px; border-radius: 6px; font-weight: 600; cursor: pointer;
    font-size: 14px;
}

/* ---- chats list ---- */
table.grid {
    width: 100%; border-collapse: collapse;
    background: var(--panel); border: 1px solid var(--border); border-radius: 8px;
    overflow: hidden;
}
table.grid th, table.grid td {
    padding: 10px 12px; border-bottom: 1px solid var(--border);
    text-align: left; vertical-align: middle;
}
table.grid th {
    background: var(--panel2); color: var(--muted);
    font-size: 11px; text-transform: uppercase; letter-spacing: 0.05em; font-weight: 500;
}
table.grid tbody tr.clickable { cursor: pointer; }
table.grid tbody tr.clickable:hover { background: rgba(122,167,255,0.06); }
table.grid td.num { text-align: right; font-variant-numeric: tabular-nums; }
.score {
    display: inline-block; min-width: 34px; padding: 2px 6px;
    border-radius: 4px; font-weight: 600; text-align: center;
    background: rgba(255,255,255,0.05);
}
.score-9, .score-10 { color: var(--green); background: rgba(67,181,129,0.12); }
.score-7, .score-8 { color: #b8e5a5; background: rgba(67,181,129,0.06); }
.score-5, .score-6 { color: var(--yellow); background: rgba(228,179,56,0.10); }
.score-3, .score-4 { color: #e3a98b; background: rgba(214,90,90,0.08); }
.score-0, .score-1, .score-2 { color: var(--red); background: rgba(214,90,90,0.12); }

/* ---- chat detail ---- */
.layout {
    display: grid; gap: 16px;
    grid-template-columns: minmax(0,1.3fr) minmax(0,1fr);
    margin-top: 12px;
}
@media (max-width: 1000px) { .layout { grid-template-columns: 1fr; } }
.dialog, .analysis {
    background: var(--panel); border: 1px solid var(--border);
    border-radius: 8px; padding: 16px; min-height: 200px;
}
.msg {
    background: var(--panel2); padding: 8px 12px; border-radius: 8px;
    margin-bottom: 8px; max-width: 92%; word-wrap: break-word;
}
.msg-in { background: #1d2335; border-left: 3px solid var(--accent); margin-right: auto; }
.msg-out { background: #1f2a25; border-left: 3px solid var(--green); margin-left: auto; }
.msg header { display: flex; gap: 8px; align-items: baseline; font-size: 11px; color: var(--muted); margin-bottom: 2px; }
.msg .body { white-space: pre-wrap; font-size: 13px; }

.scores {
    display: flex; gap: 12px; margin-bottom: 16px; flex-wrap: wrap;
}
.scores > div {
    flex: 1; min-width: 120px; background: var(--panel2);
    border-radius: 6px; padding: 10px 12px; border: 1px solid var(--border);
}
.scores .label { display: block; font-size: 11px; color: var(--muted); }
.scores .value { display: block; font-size: 18px; font-weight: 600; margin-top: 4px; }

.markdown {
    background: var(--panel2); border: 1px solid var(--border);
    padding: 12px; border-radius: 6px; white-space: pre-wrap;
    font-size: 13px; line-height: 1.55; font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
    max-height: 600px; overflow: auto;
}
