:root {
    --gold: #f0c93a;
    --gold-dim: rgba(240,201,58,.1);
    --surface: #0e1117;
    --surface-2: #151920;
    --surface-3: #1c2029;
    --border: #252c3a;
    --border-subtle: #1c2230;
    --text: #e2e8f0;
    --text-muted: #64748b;
    --text-dim: #94a3b8;
    --green: #10b981;
    --green-dim: rgba(16,185,129,.1);
    --red: #f43f5e;
    --red-dim: rgba(244,63,94,.1);
    --blue: #6366f1;
}

* { box-sizing: border-box; }
body { background: #080b10; color: var(--text); font-family: system-ui, sans-serif; min-height: 100vh; display: flex; flex-direction: column; align-items: center; justify-content: center; }

/* ── Top bar ── */
.topbar {
    width: 980px;
    border-radius: 12px 12px 0 0;
    border: 1px solid var(--border);
    border-bottom: none;
    margin-top: 3rem;
    padding: .75rem 1.25rem;
    display: flex;
    align-items: center;
    gap: .75rem;
    background: var(--surface);
}
.topbar-logo {
    width: 32px; height: 32px;
    background: var(--gold);
    border-radius: 8px;
    display: grid; place-items: center;
    flex-shrink: 0;
}
.topbar-logo svg { width: 18px; height: 18px; }
.topbar-title { font-size: .85rem; font-weight: 600; }
.topbar-sub { font-size: .72rem; color: var(--text-muted); }
.ai-badge {
    margin-left: auto;
    display: flex; align-items: center; gap: .4rem;
    background: var(--gold-dim);
    border: 1px solid rgba(232,200,74,.25);
    border-radius: 20px;
    padding: .25rem .75rem;
    font-size: .7rem; font-weight: 600; letter-spacing: .06em;
    color: var(--gold); text-transform: uppercase;
}
.ai-dot { width: 6px; height: 6px; background: var(--gold); border-radius: 50%; animation: pulse 1.8s ease-in-out infinite; }
@keyframes pulse { 0%,100% { opacity:1; } 50% { opacity:.3; } }

/* ── Main ── */
.main { width: 980px; background: var(--surface); border: 1px solid var(--border); border-top: none; border-radius: 0 0 12px 12px; padding: 1.5rem; margin-bottom: 3rem; }

/* ── Section label row ── */
.section-row { display: flex; align-items: center; justify-content: space-between; margin-bottom: .6rem; }
.section-label { font-size: .7rem; font-weight: 700; letter-spacing: .1em; text-transform: uppercase; color: var(--text-muted); }

/* ── Guidelines trigger ── */
.guidelines-btn {
    display: flex; align-items: center; gap: .3rem;
    background: none; border: 1px solid var(--border);
    border-radius: 6px; padding: .2rem .6rem;
    font-size: .7rem; color: var(--text-muted);
    cursor: pointer; transition: border-color .15s, color .15s;
}
.guidelines-btn:hover { border-color: var(--gold); color: var(--gold); }
.guidelines-btn svg { width: 11px; height: 11px; }

/* ── Input card ── */
.input-card { background: var(--surface); border: 1px solid var(--border); border-radius: 12px; overflow: hidden; }
.input-card-header { background: var(--surface-2); border-bottom: 1px solid var(--border); padding: .75rem 1.25rem; display: flex; align-items: center; gap: .5rem; font-size: .78rem; color: var(--text-muted); }
.input-card-header svg { color: var(--gold); }
.input-card-body { padding: 1.25rem; }

textarea.field { width: 100%; background: var(--surface-2); border: 1px solid var(--border); border-radius: 8px; color: var(--text); padding: .85rem 1rem; font-size: .9rem; resize: vertical; outline: none; transition: border-color .15s; }
textarea.field:focus { border-color: var(--gold); box-shadow: 0 0 0 3px rgba(240,201,58,.07); }
textarea.field::placeholder { color: var(--text-muted); }

.char-counter { text-align: right; font-size: .72rem; color: var(--text-muted); margin-top: .4rem; }
.char-counter.warn { color: #f59e0b; }
.char-counter.over  { color: var(--red); }

.input-footer { display: flex; align-items: center; justify-content: space-between; margin-top: 1rem; }
.input-footer-actions { display: flex; align-items: center; gap: .5rem; }
.model-tag { font-size: .7rem; color: var(--text-muted); display: flex; align-items: center; gap: .35rem; }
.model-tag svg { width: 12px; height: 12px; }

.btn-run { background: var(--gold); color: #080b10; border: none; border-radius: 8px; padding: .55rem 1.4rem; font-size: .85rem; font-weight: 700; cursor: pointer; display: flex; align-items: center; gap: .5rem; transition: background .15s; }
.btn-run:hover { background: #dbb82e; }
.btn-run:disabled { opacity: .4; cursor: not-allowed; }
.btn-clear { background: none; border: 1px solid var(--border); border-radius: 8px; color: var(--text-muted); padding: .55rem .9rem; cursor: pointer; display: flex; align-items: center; gap: .35rem; font-size: .85rem; font-weight: 700; transition: border-color .15s, color .15s; }
.btn-clear:hover { border-color: var(--red); color: var(--red); }
.btn-run svg { width: 15px; height: 15px; }

/* ── Loading ── */
#loading { display: none; margin-top: 1.5rem; }
.loading-inner { background: var(--surface); border: 1px solid var(--border); border-radius: 12px; padding: 1.5rem; display: flex; align-items: center; gap: 1rem; }
.spinner-ring { width: 36px; height: 36px; flex-shrink: 0; border: 3px solid var(--border); border-top-color: var(--gold); border-radius: 50%; animation: spin .7s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }
.loading-text { font-size: .85rem; color: var(--text-muted); }
.loading-text strong { display: block; color: var(--text); margin-bottom: .2rem; }

/* ── Verdict ── */
.verdict { margin-top: 1.5rem; border-radius: 12px; border: 1px solid var(--border); overflow: hidden; }
.verdict-header { padding: 1.25rem 1.5rem; display: flex; align-items: center; gap: 1rem; border-bottom: 1px solid var(--border); }
.verdict-approved .verdict-header { background: var(--green-dim); }
.verdict-rejected .verdict-header { background: var(--red-dim); }
.verdict-icon-wrap { width: 44px; height: 44px; border-radius: 10px; display: grid; place-items: center; font-size: 1.3rem; flex-shrink: 0; }
.verdict-approved .verdict-icon-wrap { background: rgba(16,185,129,.15); }
.verdict-rejected .verdict-icon-wrap { background: rgba(244,63,94,.15); }
.verdict-status { font-size: 1.1rem; font-weight: 700; }
.verdict-approved .verdict-status { color: var(--green); }
.verdict-rejected .verdict-status { color: var(--red); }
.verdict-meta { font-size: .72rem; color: var(--text-muted); margin-top: .1rem; }
.verdict-body { padding: 1.25rem 1.5rem; background: var(--surface); }
.verdict-reason-label { font-size: .68rem; font-weight: 700; letter-spacing: .1em; text-transform: uppercase; color: var(--text-muted); margin-bottom: .5rem; }
.verdict-reason-text { font-size: .9rem; color: var(--text-dim); line-height: 1.6; }

/* ── Captcha ── */
.captcha-row { display: flex; align-items: center; gap: .75rem; margin-top: 1rem; padding: .65rem .85rem; background: var(--surface-2); border: 1px solid var(--border-subtle); border-radius: 8px; }
.captcha-shield { width: 28px; height: 28px; flex-shrink: 0; background: var(--gold-dim); border: 1px solid rgba(240,201,58,.18); border-radius: 6px; display: grid; place-items: center; }
.captcha-shield svg { width: 14px; height: 14px; color: var(--gold); }
.captcha-label { flex: 1; }
.captcha-label-title { font-size: .75rem; font-weight: 600; color: var(--text-dim); }
.captcha-label-sub { font-size: .65rem; color: var(--text-muted); margin-top: .1rem; }
.captcha-status { flex-shrink: 0; font-size: .72rem; display: flex; align-items: center; gap: .4rem; color: var(--text-muted); }
.captcha-status.verified { color: var(--green); }
.captcha-status-dot { width: 7px; height: 7px; border-radius: 50%; background: var(--border); flex-shrink: 0; }
.captcha-status.verified .captcha-status-dot { background: var(--green); }

/* ── Error ── */
.error-box { margin-top: 1.5rem; background: var(--red-dim); border: 1px solid rgba(244,63,94,.25); border-radius: 12px; padding: 1rem 1.25rem; font-size: .85rem; color: #fb7185; }

/* ── Modal ── */
.modal-overlay { display: none; position: fixed; inset: 0; background: rgba(0,0,0,.8); backdrop-filter: blur(4px); z-index: 100; align-items: center; justify-content: center; }
.modal-overlay.open { display: flex; }
.modal-box { background: var(--surface); border: 1px solid var(--border); border-radius: 14px; width: 480px; max-width: 95vw; max-height: 80vh; display: flex; flex-direction: column; overflow: hidden; }
.modal-head { padding: 1rem 1.25rem; border-bottom: 1px solid var(--border); display: flex; align-items: center; justify-content: space-between; background: var(--surface-2); }
.modal-head-title { font-size: .85rem; font-weight: 600; display: flex; align-items: center; gap: .5rem; }
.modal-head-title svg { color: var(--gold); }
.modal-close { background: none; border: none; color: var(--text-muted); cursor: pointer; padding: .25rem; border-radius: 4px; display: grid; place-items: center; transition: color .15s; }
.modal-close:hover { color: var(--text); }
.modal-close svg { width: 16px; height: 16px; }
.modal-body { padding: 1.5rem; overflow-y: auto; }

/* ── Rendered markdown ── */
.md h1 { font-size: 1rem; font-weight: 700; color: var(--text); margin: 0 0 1rem; }
.md h2 { font-size: .8rem; font-weight: 700; letter-spacing: .07em; text-transform: uppercase; color: var(--gold); margin: 1.25rem 0 .5rem; }
.md p { font-size: .85rem; color: var(--text-muted); line-height: 1.65; margin: 0 0 .75rem; }
.md ul { padding-left: 1.1rem; margin: 0 0 .75rem; }
.md ul li { font-size: .85rem; color: var(--text-muted); line-height: 1.65; margin-bottom: .2rem; }
.md strong { color: var(--text); font-weight: 600; }

/* ── History ── */
.history { margin-top: 2rem; }
.history-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: .6rem; }
.history-stats { display: flex; align-items: center; gap: .75rem; font-size: .72rem; }
.stat { display: flex; align-items: center; gap: .3rem; color: var(--text-muted); }
.stat-dot { width: 6px; height: 6px; border-radius: 50%; }
.stat-dot-total { background: var(--text-muted); }
.stat-dot-approved { background: var(--green); }
.stat-dot-rejected { background: var(--red); }
.history-table { width: 100%; border-collapse: collapse; font-size: .78rem; }
.history-table th { text-align: left; font-size: .65rem; font-weight: 700; letter-spacing: .08em; text-transform: uppercase; color: var(--text-muted); padding: .5rem .75rem; border-bottom: 1px solid var(--border); white-space: nowrap; }
.history-table td { padding: .6rem .75rem; border-bottom: 1px solid var(--border-subtle); vertical-align: middle; color: var(--text-dim); }
.history-table tr:last-child td { border-bottom: none; }
.history-table tr:hover td { background: var(--surface-2); }
.history-msg { max-width: 260px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; color: var(--text); }
.badge { display: inline-flex; align-items: center; gap: .3rem; padding: .2rem .55rem; border-radius: 20px; font-size: .68rem; font-weight: 700; letter-spacing: .04em; text-transform: uppercase; }
.badge-approved { background: rgba(16,185,129,.12); color: var(--green); }
.badge-rejected { background: rgba(244,63,94,.12); color: var(--red); }
.tag-badge { display: inline-flex; align-items: center; padding: .15rem .5rem; border-radius: 20px; font-size: .65rem; font-weight: 700; letter-spacing: .06em; text-transform: uppercase; background: rgba(99,102,241,.12); color: var(--blue); border: 1px solid rgba(99,102,241,.25); vertical-align: middle; margin-left: .5rem; }
.token-cell { font-variant-numeric: tabular-nums; white-space: nowrap; }
.token-total { color: var(--text); font-weight: 600; }
.reason-toggle { cursor: pointer; color: var(--text-muted); font-size: .72rem; user-select: none; padding: .1rem .35rem; border-radius: 4px; border: 1px solid var(--border); }
.reason-toggle:hover { border-color: var(--gold); color: var(--gold); }
.reason-row { display: none; }
.reason-row.open { display: table-row; }
.reason-row td { padding: .75rem 1rem; background: var(--surface-2); color: var(--text-dim); font-size: .82rem; line-height: 1.6; border-bottom: 1px solid var(--border); }
.pagination { display: flex; align-items: center; gap: .4rem; margin-top: 1rem; justify-content: center; }
.page-btn { background: none; border: 1px solid var(--border); border-radius: 6px; color: var(--text-muted); padding: .3rem .7rem; font-size: .75rem; cursor: pointer; text-decoration: none; transition: border-color .15s, color .15s; }
.page-btn:hover { border-color: var(--gold); color: var(--gold); }
.page-btn.active { border-color: var(--gold); color: var(--gold); background: var(--gold-dim); }
.page-btn.disabled { opacity: .3; pointer-events: none; }
