/* === CSS Variables — matches review site (dark default) === */
:root {
    --bg: #0d1117;
    --surface: #161b22;
    --border: #30363d;
    --text: #e6edf3;
    --text-dim: #8b949e;
    --accent: #58a6ff;
    --hover: #1c2128;
    --add-bg: #12261e;
    --add-text: #3fb950;
    --del-bg: #2a1215;
    --del-text: #f85149;
    --hunk-bg: #1a1f35;
    --hunk-text: #79c0ff;
    --warning-bg: #2a2a15;
    --warning-text: #d29922;
    --error-bg: #3d1a1e;
    --error-text: #f85149;
    --success-bg: #1a3a2a;
    --success-text: #3fb950;
}

@media (prefers-color-scheme: light) {
    html:not(.dark):not(.light) {
        --bg: #ffffff;
        --surface: #f6f8fa;
        --border: #d0d7de;
        --text: #1f2328;
        --text-dim: #656d76;
        --accent: #0969da;
        --hover: #eaeef2;
        --add-bg: #dafbe1;
        --add-text: #116329;
        --del-bg: #ffebe9;
        --del-text: #82071e;
        --hunk-bg: #ddf4ff;
        --hunk-text: #0969da;
        --warning-bg: #fff8c5;
        --warning-text: #7a5d00;
        --error-bg: #ffebe9;
        --error-text: #cf222e;
        --success-bg: #dafbe1;
        --success-text: #116329;
    }
}

html.light {
    --bg: #ffffff;
    --surface: #f6f8fa;
    --border: #d0d7de;
    --text: #1f2328;
    --text-dim: #656d76;
    --accent: #0969da;
    --hover: #eaeef2;
    --add-bg: #dafbe1;
    --add-text: #116329;
    --del-bg: #ffebe9;
    --del-text: #82071e;
    --hunk-bg: #ddf4ff;
    --hunk-text: #0969da;
    --warning-bg: #fff8c5;
    --warning-text: #7a5d00;
    --error-bg: #ffebe9;
    --error-text: #cf222e;
    --success-bg: #dafbe1;
    --success-text: #116329;
}

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

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

/* === Anto Header (shared across all pages) === */
.anto-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 10px 24px;
    background: var(--surface);
    border-bottom: 1px solid var(--border);
}

.anto-header-left {
    display: flex;
    align-items: center;
    gap: 12px;
}

.anto-brand {
    font-size: 18px;
    font-weight: 700;
    color: var(--text);
    text-decoration: none;
}

.anto-brand:hover {
    color: var(--accent);
}

.anto-header-right {
    display: flex;
    align-items: center;
    gap: 12px;
}

.anto-user {
    color: var(--text-dim);
    font-size: 13px;
}

.anto-logout {
    color: var(--text-dim);
    text-decoration: none;
    font-size: 13px;
}

.anto-logout:hover {
    color: var(--text);
}

/* Theme toggle */
.theme-toggle {
    background: var(--bg);
    border: 1px solid var(--border);
    color: var(--text);
    padding: 6px 8px;
    border-radius: 6px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: border-color 0.15s;
    line-height: 1;
}
.theme-toggle:hover { border-color: var(--accent); }
.theme-toggle .icon-sun,
.theme-toggle .icon-moon,
.theme-toggle .icon-system { width: 16px; height: 16px; }
.theme-toggle .icon-sun { display: none; }
.theme-toggle .icon-moon { display: none; }
.theme-toggle .icon-system { display: block; }
html.light .theme-toggle .icon-sun { display: block; }
html.light .theme-toggle .icon-moon { display: none; }
html.light .theme-toggle .icon-system { display: none; }
html.dark .theme-toggle .icon-sun { display: none; }
html.dark .theme-toggle .icon-moon { display: block; }
html.dark .theme-toggle .icon-system { display: none; }

/* === Layout === */
.container {
    max-width: 1200px;
    margin: 2rem auto;
    padding: 0 1.5rem;
}

/* === Flash messages === */
.flash-messages {
    margin-bottom: 1.5rem;
}

.flash {
    padding: 0.75rem 1rem;
    background: var(--error-bg);
    border: 1px solid var(--error-text);
    border-radius: 6px;
    color: var(--error-text);
    font-size: 0.875rem;
}

/* === Login === */
.login-wrapper {
    max-width: 360px;
    margin: 4rem auto;
}

.login-wrapper h1 {
    margin-bottom: 1.5rem;
    font-size: 1.5rem;
}

.login-form {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
}

.login-form label {
    font-size: 0.875rem;
    font-weight: 600;
    margin-top: 0.5rem;
    color: var(--text);
}

.login-form input {
    padding: 0.5rem 0.75rem;
    border: 1px solid var(--border);
    border-radius: 6px;
    font-size: 1rem;
    background: var(--bg);
    color: var(--text);
}

.login-form input:focus {
    outline: none;
    border-color: var(--accent);
}

.login-form button {
    margin-top: 1rem;
    padding: 0.625rem;
    background: var(--accent);
    color: var(--bg);
    border: none;
    border-radius: 6px;
    font-size: 1rem;
    cursor: pointer;
}

.login-form button:hover {
    opacity: 0.9;
}

/* === Buttons === */
.btn {
    padding: 0.5rem 1rem;
    border: 1px solid var(--border);
    border-radius: 6px;
    background: var(--surface);
    color: var(--text);
    font-size: 0.875rem;
    cursor: pointer;
    transition: background 0.15s, border-color 0.15s;
}

.btn:hover {
    background: var(--hover);
    border-color: var(--accent);
}

.btn:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

.btn-primary {
    background: var(--accent);
    color: var(--bg);
    border-color: var(--accent);
}

.btn-primary:hover {
    opacity: 0.9;
    background: var(--accent);
}

.btn-danger {
    background: none;
    border: none;
    color: var(--del-text);
    cursor: pointer;
    padding: 0.25rem 0.5rem;
    font-size: 1rem;
    line-height: 1;
    border-radius: 4px;
    opacity: 0.6;
}

.btn-danger:hover {
    opacity: 1;
    background: var(--del-bg);
}

.btn-sm {
    padding: 0.2rem 0.4rem;
    font-size: 0.8125rem;
}

/* === Overview === */
.overview h1 {
    margin-bottom: 1rem;
}

.actions {
    display: flex;
    gap: 0.75rem;
    margin-bottom: 1.5rem;
}

/* === Review table === */
.review-table {
    width: 100%;
    border-collapse: collapse;
    background: var(--surface);
    border-radius: 6px;
    overflow: hidden;
    border: 1px solid var(--border);
}

.review-table th,
.review-table td {
    padding: 0.625rem 0.75rem;
    text-align: left;
    font-size: 0.875rem;
}

.review-table th {
    background: var(--hover);
    font-weight: 600;
    border-bottom: 1px solid var(--border);
}

.review-table td {
    border-bottom: 1px solid var(--border);
}

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

.review-table code {
    font-size: 0.8125rem;
}

.review-table a {
    color: var(--accent);
    text-decoration: none;
}

.review-table a:hover {
    text-decoration: underline;
}

/* === Status badges === */
.status {
    display: inline-block;
    padding: 0.125rem 0.5rem;
    border-radius: 999px;
    font-size: 0.75rem;
    font-weight: 600;
    text-transform: uppercase;
}

.status-pending { background: var(--surface); color: var(--text-dim); border: 1px solid var(--border); }
.status-extracting,
.status-analyzing,
.status-reviewing,
.status-rendering { background: var(--warning-bg); color: var(--warning-text); }
.status-done { background: var(--success-bg); color: var(--success-text); }
.status-error { background: var(--error-bg); color: var(--error-text); }

.empty-state {
    color: var(--text-dim);
    font-style: italic;
    padding: 2rem 0;
}

/* === Status messages === */
.status-msg {
    padding: 0.625rem 1rem;
    border-radius: 6px;
    font-size: 0.875rem;
    margin-bottom: 1rem;
}

.status-msg-ok {
    background: var(--success-bg);
    border: 1px solid var(--success-text);
    color: var(--success-text);
}

.status-msg-error {
    background: var(--error-bg);
    border: 1px solid var(--error-text);
    color: var(--error-text);
}

.status-msg-error.status-msg-credits {
    background: var(--warning-bg);
    border: 1px solid var(--warning-text);
    color: var(--warning-text);
}

/* === Modal === */
.modal {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.6);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 100;
}

.modal-content {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: 8px;
    padding: 1.5rem;
    width: 100%;
    max-width: 420px;
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.4);
}

.modal-content h2 {
    margin-bottom: 1rem;
    font-size: 1.25rem;
}

.form-group {
    margin-bottom: 0.75rem;
}

.form-group label {
    display: block;
    font-size: 0.875rem;
    font-weight: 600;
    margin-bottom: 0.25rem;
    color: var(--text);
}

.form-group input {
    width: 100%;
    padding: 0.5rem 0.75rem;
    border: 1px solid var(--border);
    border-radius: 6px;
    font-size: 1rem;
    background: var(--bg);
    color: var(--text);
}

.form-group input:focus {
    outline: none;
    border-color: var(--accent);
}

.modal-actions {
    display: flex;
    justify-content: flex-end;
    gap: 0.5rem;
    margin-top: 1rem;
}

/* === Progress page === */
.progress-page h1 {
    margin-bottom: 0.25rem;
}

.progress-meta {
    color: var(--text-dim);
    font-size: 0.875rem;
    margin-bottom: 1.5rem;
}

.progress-status {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    margin-bottom: 1.5rem;
}

.progress-steps {
    display: flex;
    gap: 0.5rem;
    margin-bottom: 1.5rem;
}

.step {
    flex: 1;
    padding: 0.5rem 0.75rem;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: 6px;
    text-align: center;
    font-size: 0.8125rem;
    color: var(--text-dim);
}

.step-active {
    background: var(--warning-bg);
    border-color: var(--warning-text);
    color: var(--warning-text);
    font-weight: 600;
}

.step-done {
    background: var(--success-bg);
    border-color: var(--success-text);
    color: var(--success-text);
}

.log-output {
    background: var(--bg);
    color: var(--text-dim);
    padding: 1rem;
    border-radius: 6px;
    border: 1px solid var(--border);
    font-family: "SF Mono", "Fira Code", Menlo, monospace;
    font-size: 0.8125rem;
    line-height: 1.6;
    max-height: 400px;
    overflow-y: auto;
    white-space: pre-wrap;
    word-break: break-word;
}

/* === Spinner === */
@keyframes spin { to { transform: rotate(360deg); } }
