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

:root {
    --bg: #0d0d0d;
    --surface: #1a1a1a;
    --border: #2e2e2e;
    --accent: #f5a623;
    --text: #f0f0f0;
    --muted: #888;
    --danger: #e05252;
    --success: #4caf50;
    --font: -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

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

/* --- Login page --- */
.login-wrap {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    min-height: 100vh;
    padding: 24px;
}

.login-box {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: 12px;
    padding: 36px 28px;
    width: 100%;
    max-width: 400px;
}

.login-box h1 {
    font-size: 22px;
    font-weight: 700;
    color: var(--accent);
    margin-bottom: 4px;
}

.login-box .subtitle {
    color: var(--muted);
    font-size: 14px;
    margin-bottom: 28px;
}

.login-box .disclaimer {
    font-size: 12px;
    color: var(--muted);
    border-top: 1px solid var(--border);
    margin-top: 24px;
    padding-top: 16px;
    text-align: center;
}

/* --- Main app layout --- */
.app-wrap {
    display: flex;
    flex-direction: column;
    min-height: 100vh;
    max-width: 800px;
    margin: 0 auto;
    padding: 0 16px 120px;
}

header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 16px 0;
    border-bottom: 1px solid var(--border);
    margin-bottom: 20px;
}

header h1 {
    font-size: 18px;
    font-weight: 700;
    color: var(--accent);
}

header .user-info {
    font-size: 13px;
    color: var(--muted);
}

header a {
    color: var(--muted);
    text-decoration: none;
    font-size: 13px;
    margin-left: 12px;
}

.disclaimer-bar {
    background: #1f1500;
    border: 1px solid #3d2a00;
    border-radius: 8px;
    padding: 10px 14px;
    font-size: 13px;
    color: var(--accent);
    margin-bottom: 20px;
    text-align: center;
}

/* --- Answer card --- */
.answer-card {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: 10px;
    padding: 20px;
    margin-bottom: 20px;
    white-space: pre-wrap;
    font-size: 16px;
    line-height: 1.7;
}

.answer-card .q-label {
    font-size: 12px;
    color: var(--muted);
    margin-bottom: 8px;
    text-transform: uppercase;
    letter-spacing: 0.05em;
}

.answer-card .q-text {
    font-weight: 600;
    margin-bottom: 16px;
    padding-bottom: 16px;
    border-bottom: 1px solid var(--border);
}

.answer-card .a-label {
    font-size: 12px;
    color: var(--accent);
    margin-bottom: 8px;
    text-transform: uppercase;
    letter-spacing: 0.05em;
}

.meta-row {
    font-size: 12px;
    color: var(--muted);
    margin-top: 12px;
    padding-top: 12px;
    border-top: 1px solid var(--border);
}

/* --- Fixed bottom bar --- */
.bottom-bar {
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    background: var(--surface);
    border-top: 1px solid var(--border);
    padding: 12px 16px;
}

.bottom-bar-inner {
    max-width: 800px;
    margin: 0 auto;
    display: flex;
    gap: 8px;
    align-items: flex-end;
}

#question-input {
    flex: 1;
    min-width: 0;
}

/* --- Forms and inputs --- */
label {
    display: block;
    font-size: 14px;
    color: var(--muted);
    margin-bottom: 6px;
}

input[type="text"],
input[type="password"],
textarea {
    width: 100%;
    background: var(--bg);
    border: 1px solid var(--border);
    border-radius: 8px;
    color: var(--text);
    font-size: 16px;
    padding: 12px 14px;
    outline: none;
    -webkit-appearance: none;
}

input[type="text"]:focus,
input[type="password"]:focus,
textarea:focus {
    border-color: var(--accent);
}

textarea {
    resize: none;
    min-height: 52px;
    max-height: 120px;
    line-height: 1.5;
}

.input-group {
    margin-bottom: 16px;
}

/* --- Buttons --- */
button, .btn {
    background: var(--accent);
    color: #000;
    border: none;
    border-radius: 8px;
    font-size: 16px;
    font-weight: 600;
    padding: 13px 20px;
    cursor: pointer;
    white-space: nowrap;
    min-height: 48px;
    -webkit-appearance: none;
}

button:active, .btn:active {
    opacity: 0.85;
}

.btn-secondary {
    background: var(--surface);
    color: var(--text);
    border: 1px solid var(--border);
}

.btn-danger {
    background: var(--danger);
    color: #fff;
}

.btn-sm {
    font-size: 14px;
    padding: 10px 16px;
    min-height: 40px;
}

.btn-mic {
    background: var(--surface) !important;
    color: var(--text) !important;
    border: 1px solid var(--border);
    font-size: 18px;
    padding: 10px 12px;
    min-height: 48px;
    min-width: 48px;
    white-space: nowrap;
}

.btn-mic.mic-active {
    background: rgba(220, 50, 50, 0.15);
    border-color: var(--danger);
    color: var(--danger);
    animation: mic-pulse 1.2s ease-in-out infinite;
}

@keyframes mic-pulse {
    0%, 100% { opacity: 1; }
    50% { opacity: 0.6; }
}

/* --- Log modal --- */
.modal-overlay {
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(0,0,0,0.75);
    z-index: 10;
    align-items: flex-end;
}

.modal-overlay.open {
    display: flex;
}

.modal-box {
    background: var(--surface);
    border-top: 1px solid var(--border);
    border-radius: 16px 16px 0 0;
    padding: 24px 20px;
    width: 100%;
    max-width: 800px;
    margin: 0 auto;
}

.modal-box h2 {
    font-size: 17px;
    font-weight: 600;
    margin-bottom: 16px;
}

/* --- Alerts --- */
.alert-error {
    background: #2a1010;
    border: 1px solid var(--danger);
    border-radius: 8px;
    color: #f88;
    padding: 12px 14px;
    margin-bottom: 16px;
    font-size: 15px;
}

.alert-success {
    background: #0d1f10;
    border: 1px solid var(--success);
    border-radius: 8px;
    color: #8f8;
    padding: 12px 14px;
    margin-bottom: 16px;
    font-size: 15px;
}

/* --- Metrics table --- */
.metrics-summary {
    display: flex;
    gap: 16px;
    margin-bottom: 24px;
    flex-wrap: wrap;
}

.metric-card {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: 10px;
    padding: 16px 20px;
    flex: 1;
    min-width: 120px;
    text-align: center;
}

.metric-card .value {
    font-size: 28px;
    font-weight: 700;
    color: var(--accent);
}

.metric-card .label {
    font-size: 12px;
    color: var(--muted);
    margin-top: 4px;
}

table {
    width: 100%;
    border-collapse: collapse;
    font-size: 14px;
}

th {
    text-align: left;
    padding: 10px 12px;
    border-bottom: 1px solid var(--border);
    color: var(--muted);
    font-weight: 500;
}

td {
    padding: 10px 12px;
    border-bottom: 1px solid var(--border);
    vertical-align: top;
}

tr:last-child td {
    border-bottom: none;
}
