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

:root {
    --bg: #09090b;
    --bg2: #0f0f12;
    --surface: #18181b;
    --surface2: #1e1e22;
    --surface3: #27272a;
    --border: #2e2e33;
    --border2: #3f3f46;
    --text: #fafafa;
    --text2: #a1a1aa;
    --text3: #71717a;
    --accent: #6366f1;
    --accent2: #818cf8;
    --accent-bg: rgba(99,102,241,.08);
    --green: #22c55e;
    --green-bg: rgba(34,197,94,.1);
    --red: #ef4444;
    --red-bg: rgba(239,68,68,.1);
    --amber: #f59e0b;
    --amber-bg: rgba(245,158,11,.1);
    --blue: #3b82f6;
    --purple: #7c3aed;
    --radius: 14px;
    --radius-sm: 10px;
    --radius-xs: 6px;
    --shadow: 0 1px 3px rgba(0,0,0,.3), 0 1px 2px rgba(0,0,0,.2);
    --shadow-lg: 0 10px 40px rgba(0,0,0,.4);
    --font: 'Inter', -apple-system, BlinkMacSystemFont, sans-serif;
    --mono: 'JetBrains Mono', 'Fira Code', monospace;
    --transition: all .2s ease;
}

html { font-size: 15px; scroll-behavior: smooth; }

body {
    font-family: var(--font);
    background: var(--bg);
    color: var(--text);
    min-height: 100vh;
    line-height: 1.6;
}

/* ── HEADER ─────────────────────────────────── */
.header {
    position: sticky; top: 0; z-index: 100;
    background: rgba(9,9,11,.85);
    backdrop-filter: blur(20px);
    border-bottom: 1px solid var(--border);
    padding: 0 2rem;
}
.header-content {
    max-width: 1400px; margin: 0 auto;
    display: flex; align-items: center; justify-content: space-between;
    height: 64px;
}
.logo { display: flex; align-items: center; gap: .75rem; }
.logo-icon { font-size: 1.8rem; }
.logo h1 { font-size: 1.2rem; font-weight: 700; letter-spacing: -.02em; }
.tagline { font-size: .75rem; color: var(--text3); }
.header-actions { display: flex; align-items: center; gap: .75rem; }

/* ── BUTTONS ────────────────────────────────── */
.btn {
    display: inline-flex; align-items: center; gap: .4rem;
    padding: .55rem 1.1rem; border: none; border-radius: var(--radius-xs);
    font-family: var(--font); font-size: .85rem; font-weight: 500;
    cursor: pointer; transition: var(--transition);
    white-space: nowrap;
}
.btn-primary {
    background: var(--accent); color: #fff;
}
.btn-primary:hover { background: var(--accent2); transform: translateY(-1px); }
.btn-primary:disabled { opacity: .5; cursor: not-allowed; transform: none; }
.btn-ghost {
    background: transparent; color: var(--text2);
    border: 1px solid var(--border);
}
.btn-ghost:hover { background: var(--surface2); color: var(--text); }
.btn-sm { padding: .4rem .8rem; font-size: .8rem; }

/* ── MAIN ───────────────────────────────────── */
.main {
    max-width: 1400px; margin: 0 auto;
    padding: 2rem; display: flex; flex-direction: column; gap: 2rem;
}

/* ── INPUT SECTION ──────────────────────────── */
.input-card {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    overflow: hidden;
}
.input-header {
    display: flex; align-items: center; justify-content: space-between;
    padding: 1rem 1.25rem;
    border-bottom: 1px solid var(--border);
    flex-wrap: wrap; gap: .75rem;
}
.input-header h2 { font-size: 1rem; font-weight: 600; }
.mode-selector { display: flex; gap: .35rem; }
.mode-btn {
    padding: .35rem .75rem; border: 1px solid var(--border);
    border-radius: 20px; background: transparent;
    color: var(--text3); font-size: .78rem; font-weight: 500;
    cursor: pointer; transition: var(--transition);
    font-family: var(--font);
}
.mode-btn:hover { border-color: var(--text3); color: var(--text2); }
.mode-btn.active {
    background: var(--accent-bg); border-color: var(--accent);
    color: var(--accent2);
}

#promptInput {
    width: 100%; min-height: 120px; padding: 1.25rem;
    background: transparent; border: none; outline: none;
    color: var(--text); font-family: var(--font);
    font-size: .95rem; line-height: 1.6; resize: vertical;
}
#promptInput::placeholder { color: var(--text3); }

.input-footer {
    display: flex; align-items: center; justify-content: space-between;
    padding: .85rem 1.25rem;
    border-top: 1px solid var(--border);
}

.context-toggle { display: flex; align-items: center; gap: .5rem; color: var(--text3); font-size: .82rem; }
.toggle { position: relative; display: inline-block; width: 36px; height: 20px; }
.toggle input { opacity: 0; width: 0; height: 0; }
.toggle-slider {
    position: absolute; inset: 0; background: var(--surface3);
    border-radius: 20px; cursor: pointer; transition: var(--transition);
}
.toggle-slider::before {
    content: ''; position: absolute; width: 14px; height: 14px;
    left: 3px; bottom: 3px; background: var(--text3);
    border-radius: 50%; transition: var(--transition);
}
.toggle input:checked + .toggle-slider { background: var(--accent); }
.toggle input:checked + .toggle-slider::before { transform: translateX(16px); background: #fff; }

.context-input {
    width: 100%; padding: 1rem 1.25rem;
    background: var(--bg2); border: none; border-top: 1px solid var(--border);
    outline: none; color: var(--text); font-family: var(--font);
    font-size: .88rem; resize: vertical; min-height: 70px;
}

/* ── SAMPLES ────────────────────────────────── */
.samples-section h3 { font-size: .9rem; color: var(--text2); margin-bottom: .75rem; }
.samples-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(260px, 1fr)); gap: .65rem; }
.sample-card {
    display: flex; align-items: center; gap: .65rem;
    padding: .75rem 1rem; background: var(--surface);
    border: 1px solid var(--border); border-radius: var(--radius-sm);
    cursor: pointer; transition: var(--transition);
    text-align: left; font-family: var(--font);
}
.sample-card:hover { border-color: var(--accent); background: var(--accent-bg); }
.sample-icon { font-size: 1.4rem; flex-shrink: 0; }
.sample-text { font-size: .82rem; color: var(--text2); flex: 1; line-height: 1.4; }
.sample-tag {
    font-size: .65rem; padding: .15rem .45rem;
    background: var(--surface3); color: var(--text3);
    border-radius: 4px; flex-shrink: 0; font-weight: 500;
}

/* ── COUNCIL GRID ───────────────────────────── */
.section-header {
    display: flex; align-items: center; justify-content: space-between;
    margin-bottom: 1rem; flex-wrap: wrap; gap: .5rem;
}
.section-header h2 { font-size: 1.1rem; font-weight: 600; }
.section-actions { display: flex; gap: .5rem; }

.council-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(300px, 1fr));
    gap: 1rem;
}

.response-card {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    overflow: hidden;
    transition: var(--transition);
}
.response-card:hover { border-color: var(--border2); }
.response-card.loading { animation: card-pulse 2s ease-in-out infinite; }
.response-card.error { border-color: var(--red); }

@keyframes card-pulse {
    0%, 100% { border-color: var(--border); }
    50% { border-color: var(--accent); }
}

.card-top {
    display: flex; align-items: center; justify-content: space-between;
    padding: .75rem 1rem;
    border-bottom: 1px solid var(--border);
}
.card-provider {
    display: flex; align-items: center; gap: .4rem;
    font-weight: 600; font-size: .9rem;
}
.card-model {
    font-size: .7rem; color: var(--text3);
    background: var(--surface3); padding: .15rem .45rem;
    border-radius: 4px; font-family: var(--mono);
}
.card-body {
    padding: 1rem; min-height: 180px;
    font-size: .88rem; line-height: 1.7;
    white-space: pre-wrap; word-wrap: break-word;
    color: var(--text);
}
.card-body.empty {
    display: flex; align-items: center; justify-content: center;
    color: var(--text3); font-style: italic;
}
.card-body .error-msg {
    color: var(--red); background: var(--red-bg);
    padding: .75rem; border-radius: var(--radius-xs);
    font-size: .82rem;
}
.card-footer {
    padding: .6rem 1rem; border-top: 1px solid var(--border);
    display: flex; gap: 1rem; font-size: .72rem; color: var(--text3);
}
.card-footer b { color: var(--text2); font-weight: 600; }

/* ── VERDICT / SUGGESTIONS ─────────────────── */
.verdict-card, .suggestions-card {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    overflow: hidden;
}
.verdict-header, .suggestions-header {
    display: flex; align-items: center; justify-content: space-between;
    padding: 1rem 1.25rem;
    border-bottom: 1px solid var(--border);
}
.verdict-header h2, .suggestions-header h2 { font-size: 1rem; font-weight: 600; }
.verdict-badge, .suggestions-badge {
    font-size: .72rem; padding: .2rem .6rem;
    border-radius: 20px; font-weight: 500;
}
.verdict-badge { background: var(--green-bg); color: var(--green); }
.suggestions-badge { background: var(--amber-bg); color: var(--amber); }

.verdict-content, .suggestions-content {
    padding: 1.25rem; font-size: .9rem; line-height: 1.75;
    white-space: pre-wrap; word-wrap: break-word;
}

/* ── SPINNER ────────────────────────────────── */
.spinner {
    display: inline-block; width: 14px; height: 14px;
    border: 2px solid rgba(255,255,255,.2);
    border-top-color: #fff; border-radius: 50%;
    animation: spin .6s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* ── MODAL ──────────────────────────────────── */
.modal-overlay {
    position: fixed; inset: 0; z-index: 200;
    background: rgba(0,0,0,.7); backdrop-filter: blur(4px);
    display: flex; align-items: center; justify-content: center;
    padding: 2rem;
}
.modal {
    background: var(--surface); border: 1px solid var(--border);
    border-radius: var(--radius); max-width: 700px; width: 100%;
    max-height: 80vh; overflow-y: auto;
}
.modal-header {
    display: flex; align-items: center; justify-content: space-between;
    padding: 1rem 1.25rem; border-bottom: 1px solid var(--border);
}
.modal-header h2 { font-size: 1rem; }
.btn-close {
    background: none; border: none; color: var(--text3);
    font-size: 1.4rem; cursor: pointer; padding: .25rem;
}
.btn-close:hover { color: var(--text); }
.modal-body { padding: 1.25rem; font-size: .85rem; line-height: 1.7; }
.modal-body code {
    background: var(--surface3); padding: .15rem .4rem;
    border-radius: 4px; font-family: var(--mono); font-size: .8rem;
}
.modal-body pre {
    background: var(--bg2); padding: 1rem; border-radius: var(--radius-xs);
    overflow-x: auto; margin: .75rem 0; border: 1px solid var(--border);
}
.modal-body pre code { background: none; padding: 0; }

/* ── RESPONSIVE ─────────────────────────────── */
@media (max-width: 768px) {
    .main { padding: 1rem; }
    .header { padding: 0 1rem; }
    .council-grid { grid-template-columns: 1fr; }
    .samples-grid { grid-template-columns: 1fr; }
    .input-header { flex-direction: column; align-items: flex-start; }
}
