:root {
    --green-dark: #2d5a27;
    --green: #4a8c3f;
    --green-light: #7bc96f;
    --green-bg: #f0f7ee;
    --text: #1a1a1a;
    --text-muted: #666;
    --border: #ddd;
    --bg: #fafafa;
    --white: #fff;
    --red: #d32f2f;
    --yellow: #f9a825;
    --blue: #1565c0;
    --radius: 8px;
    --shadow: 0 2px 8px rgba(0,0,0,0.08);
    --input-bg: #fff;
    --badge-green-bg: #f0f7ee;
    --badge-green-text: #2d5a27;
    --badge-yellow-bg: #fff8e1;
    --badge-yellow-text: #f57f17;
    --badge-red-bg: #fde7e7;
    --badge-blue-bg: #e3f2fd;
    --badge-gray-bg: #eee;
    --tally-empty: #eee;
    --vote-yes-bg: #e7f5e7;
    --vote-no-bg: #fde7e7;
    --vote-abstain-bg: #eee;
    --alert-error-bg: #fde7e7;
    --alert-success-bg: #e7f5e7;
    --toast-bg: #333;
    --toast-text: #fff;
    --status-draft-bg: #eee;
    --status-draft-text: #666;
    --status-open-bg: #e3f2fd;
    --status-open-text: #1565c0;
    --status-voting-bg: #fff8e1;
    --status-voting-text: #f57f17;
    --status-closed-bg: #e7f5e7;
    --status-closed-text: #2d5a27;
    --status-archived-bg: #eee;
    --status-archived-text: #999;
}

@media (prefers-color-scheme: dark) {
    :root {
        --green-dark: #7bc96f;
        --green: #5ea652;
        --green-light: #3d7a33;
        --green-bg: #1a2e17;
        --text: #e0e0e0;
        --text-muted: #999;
        --border: #333;
        --bg: #121212;
        --white: #1e1e1e;
        --red: #ef5350;
        --yellow: #ffca28;
        --blue: #42a5f5;
        --shadow: 0 2px 8px rgba(0,0,0,0.3);
        --input-bg: #2a2a2a;
        --badge-green-bg: #1a2e17;
        --badge-green-text: #7bc96f;
        --badge-yellow-bg: #2e2a14;
        --badge-yellow-text: #ffca28;
        --badge-red-bg: #2e1717;
        --badge-blue-bg: #172a2e;
        --badge-gray-bg: #2a2a2a;
        --tally-empty: #2a2a2a;
        --vote-yes-bg: #1a2e17;
        --vote-no-bg: #2e1717;
        --vote-abstain-bg: #2a2a2a;
        --alert-error-bg: #2e1717;
        --alert-success-bg: #1a2e17;
        --toast-bg: #e0e0e0;
        --toast-text: #121212;
        --status-draft-bg: #2a2a2a;
        --status-draft-text: #999;
        --status-open-bg: #172a2e;
        --status-open-text: #42a5f5;
        --status-voting-bg: #2e2a14;
        --status-voting-text: #ffca28;
        --status-closed-bg: #1a2e17;
        --status-closed-text: #7bc96f;
        --status-archived-bg: #2a2a2a;
        --status-archived-text: #666;
    }
}

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

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
    background: var(--bg);
    color: var(--text);
    line-height: 1.5;
    min-height: 100vh;
}

#app {
    max-width: 480px;
    margin: 0 auto;
    padding: 0 16px;
    padding-bottom: 80px;
}

/* Nav */
.nav {
    display: flex;
    justify-content: space-around;
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    background: var(--white);
    border-top: 1px solid var(--border);
    padding: 8px 0;
    z-index: 100;
}
.nav a {
    display: flex;
    flex-direction: column;
    align-items: center;
    text-decoration: none;
    color: var(--text-muted);
    font-size: 11px;
    gap: 2px;
    padding: 4px 12px;
}
.nav a.active { color: var(--green); }
.nav a svg { width: 24px; height: 24px; }

/* Header */
.header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 16px 0;
    border-bottom: 1px solid var(--border);
    margin-bottom: 16px;
}
.header h1 { font-size: 20px; color: var(--green-dark); }

/* Cards */
.card {
    background: var(--white);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    padding: 16px;
    margin-bottom: 12px;
}
.card h3 { font-size: 16px; margin-bottom: 8px; }
.card p { color: var(--text-muted); font-size: 14px; }

/* Buttons */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    padding: 10px 20px;
    border: none;
    border-radius: var(--radius);
    font-size: 14px;
    font-weight: 600;
    cursor: pointer;
    transition: opacity 0.2s;
}
.btn:hover { opacity: 0.85; }
.btn:disabled { opacity: 0.5; cursor: not-allowed; }
.btn-primary { background: var(--green); color: #fff; }
.btn-secondary { background: var(--border); color: var(--text); }
.btn-danger { background: var(--red); color: #fff; }
.btn-sm { padding: 6px 12px; font-size: 12px; }
.btn-block { width: 100%; }

/* Forms */
.form-group { margin-bottom: 16px; }
.form-group label {
    display: block;
    font-size: 13px;
    font-weight: 600;
    margin-bottom: 4px;
    color: var(--text);
}
.form-group input,
.form-group textarea,
.form-group select {
    width: 100%;
    padding: 10px 12px;
    border: 1px solid var(--border);
    border-radius: var(--radius);
    font-size: 14px;
    font-family: inherit;
    background: var(--input-bg);
    color: var(--text);
    transition: border-color 0.2s;
}
.form-group input:focus,
.form-group textarea:focus,
.form-group select:focus {
    outline: none;
    border-color: var(--green);
}
.form-group textarea { resize: vertical; min-height: 100px; }

/* Alert */
.alert {
    padding: 12px 16px;
    border-radius: var(--radius);
    margin-bottom: 16px;
    font-size: 14px;
}
.alert-error { background: var(--alert-error-bg); color: var(--red); }
.alert-success { background: var(--alert-success-bg); color: var(--green-dark); }

/* Badge */
.badge {
    display: inline-block;
    padding: 2px 8px;
    border-radius: 12px;
    font-size: 11px;
    font-weight: 600;
    text-transform: uppercase;
}
.badge-green { background: var(--badge-green-bg); color: var(--badge-green-text); }
.badge-yellow { background: var(--badge-yellow-bg); color: var(--badge-yellow-text); }
.badge-red { background: var(--badge-red-bg); color: var(--red); }
.badge-blue { background: var(--badge-blue-bg); color: var(--blue); }
.badge-gray { background: var(--badge-gray-bg); color: var(--text-muted); }

/* Vote buttons */
.vote-group {
    display: flex;
    gap: 8px;
    margin: 12px 0;
}
.vote-btn {
    flex: 1;
    padding: 12px;
    border: 2px solid var(--border);
    border-radius: var(--radius);
    background: var(--white);
    color: var(--text);
    font-size: 14px;
    font-weight: 600;
    cursor: pointer;
    text-align: center;
    transition: all 0.2s;
}
.vote-btn:hover { border-color: var(--green); }
.vote-btn.selected { border-color: var(--green); background: var(--green-bg); color: var(--green-dark); }
.vote-btn.vote-yes.selected { border-color: var(--green); background: var(--vote-yes-bg); }
.vote-btn.vote-no.selected { border-color: var(--red); background: var(--vote-no-bg); color: var(--red); }
.vote-btn.vote-abstain.selected { border-color: var(--text-muted); background: var(--vote-abstain-bg); }

/* Delegation card */
.delegation-card {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 12px;
    border: 1px solid var(--border);
    border-radius: var(--radius);
    margin-bottom: 8px;
}
.delegation-info { flex: 1; }
.delegation-info .domain { font-weight: 600; font-size: 14px; }
.delegation-info .delegate { font-size: 13px; color: var(--text-muted); }
.delegation-info .expiry { font-size: 12px; color: var(--yellow); }
.delegation-actions { display: flex; gap: 6px; }

/* Tally bar */
.tally-bar {
    height: 24px;
    border-radius: 12px;
    overflow: hidden;
    display: flex;
    margin: 8px 0;
    background: var(--tally-empty);
}
.tally-yes { background: var(--green); }
.tally-no { background: var(--red); }
.tally-abstain { background: var(--text-muted); }
.tally-labels {
    display: flex;
    justify-content: space-between;
    font-size: 12px;
    color: var(--text-muted);
}

/* Comment */
.comment {
    padding: 12px;
    border-left: 3px solid var(--green-light);
    margin-bottom: 8px;
    background: var(--white);
    border-radius: 0 var(--radius) var(--radius) 0;
}
.comment.reply { margin-left: 24px; border-left-color: var(--border); }
.comment-header { display: flex; justify-content: space-between; margin-bottom: 4px; }
.comment-author { font-weight: 600; font-size: 13px; }
.comment-time { font-size: 11px; color: var(--text-muted); }
.comment-body { font-size: 14px; }

/* Profile section */
.profile-header {
    text-align: center;
    padding: 24px 0;
}
.profile-avatar {
    width: 64px;
    height: 64px;
    border-radius: 50%;
    background: var(--green);
    color: #fff;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 24px;
    font-weight: 700;
    margin: 0 auto 12px;
}
.profile-name { font-size: 20px; font-weight: 700; }
.profile-bio { color: var(--text-muted); font-size: 14px; margin-top: 4px; }

/* Reputation sparkline */
.sparkline { display: inline-block; vertical-align: middle; }

/* Section headers */
.section-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin: 20px 0 12px;
}
.section-header h2 { font-size: 16px; color: var(--green-dark); }

/* Filter chips */
.filter-chips {
    display: flex;
    gap: 6px;
    overflow-x: auto;
    padding-bottom: 8px;
    margin-bottom: 12px;
}
.chip {
    padding: 6px 12px;
    border-radius: 16px;
    font-size: 12px;
    border: 1px solid var(--border);
    background: var(--white);
    color: var(--text);
    cursor: pointer;
    white-space: nowrap;
}
.chip.active { background: var(--green); color: #fff; border-color: var(--green); }

/* Invite section */
.invite-link-box {
    background: var(--green-bg);
    border: 1px dashed var(--green);
    border-radius: var(--radius);
    padding: 16px;
    text-align: center;
    word-break: break-all;
    font-size: 13px;
    margin: 12px 0;
}

/* Loading */
.loading {
    text-align: center;
    padding: 40px;
    color: var(--text-muted);
}
.spinner {
    width: 32px;
    height: 32px;
    border: 3px solid var(--border);
    border-top-color: var(--green);
    border-radius: 50%;
    animation: spin 0.8s linear infinite;
    margin: 0 auto 12px;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* Empty state */
.empty {
    text-align: center;
    padding: 40px 20px;
    color: var(--text-muted);
}
.empty-icon { font-size: 48px; margin-bottom: 12px; opacity: 0.3; }

/* Checkin prompt */
.checkin-prompt {
    background: var(--green-bg);
    border: 1px solid var(--green-light);
    border-radius: var(--radius);
    padding: 16px;
    margin-bottom: 16px;
    text-align: center;
}
.checkin-prompt h3 { color: var(--green-dark); margin-bottom: 8px; }

/* Vouch network SVG */
.vouch-network {
    width: 100%;
    height: 400px;
    background: var(--white);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
}

/* Tabs */
.tabs {
    display: flex;
    border-bottom: 2px solid var(--border);
    margin-bottom: 16px;
}
.tab {
    flex: 1;
    padding: 10px;
    text-align: center;
    font-size: 14px;
    font-weight: 600;
    color: var(--text-muted);
    border-bottom: 2px solid transparent;
    margin-bottom: -2px;
    cursor: pointer;
}
.tab.active { color: var(--green); border-bottom-color: var(--green); }

/* Auth screen */
.auth-screen {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    min-height: 100vh;
    padding: 20px;
}
.auth-screen h1 {
    font-size: 28px;
    color: var(--green-dark);
    margin-bottom: 4px;
}
.auth-screen .subtitle {
    color: var(--text-muted);
    margin-bottom: 32px;
    font-size: 14px;
}
.auth-form { width: 100%; max-width: 360px; }

/* Status badge colors */
.status-draft { background: var(--status-draft-bg); color: var(--status-draft-text); }
.status-open { background: var(--status-open-bg); color: var(--status-open-text); }
.status-voting { background: var(--status-voting-bg); color: var(--status-voting-text); }
.status-closed { background: var(--status-closed-bg); color: var(--status-closed-text); }
.status-archived { background: var(--status-archived-bg); color: var(--status-archived-text); }

/* Toast */
.toast {
    position: fixed;
    bottom: 80px;
    left: 50%;
    transform: translateX(-50%);
    background: var(--toast-bg);
    color: var(--toast-text);
    padding: 12px 24px;
    border-radius: var(--radius);
    font-size: 14px;
    z-index: 200;
    animation: fadeInUp 0.3s;
}
@keyframes fadeInUp {
    from { opacity: 0; transform: translateX(-50%) translateY(10px); }
    to { opacity: 1; transform: translateX(-50%) translateY(0); }
}

/* Responsive */
@media (min-width: 768px) {
    #app { max-width: 600px; }
}
