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

:root {
    --bg:       #f5f5f0;
    --surface:  #ffffff;
    --border:   #e2e0d8;
    --text:     #1a1a18;
    --muted:    #6b6b66;
    --primary:  #4f46e5;
    --primary-h:#4338ca;
    --danger:   #dc2626;
    --success:  #16a34a;
    --radius:   10px;
    --shadow:   0 1px 3px rgba(0,0,0,.08), 0 1px 2px rgba(0,0,0,.05);
}

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
    background: var(--bg);
    color: var(--text);
    line-height: 1.6;
    font-size: 15px;
}

a { color: var(--primary); text-decoration: none; }
a:hover { text-decoration: underline; }

/* Layout */
.container { max-width: 860px; margin: 0 auto; padding: 0 1rem; }

nav {
    background: var(--surface);
    border-bottom: 1px solid var(--border);
    padding: .75rem 0;
    position: sticky;
    top: 0;
    z-index: 100;
}
.nav-inner {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 1rem;
}
.nav-brand { font-weight: 600; font-size: 1.1rem; color: var(--text); }
.nav-actions { display: flex; align-items: center; gap: .5rem; }

main { padding: 2rem 0; }

/* Cards */
.card {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 1.25rem;
    box-shadow: var(--shadow);
}

/* Poll card */
.poll-grid {
    display: grid;
    gap: 1rem;
}
.poll-card { cursor: pointer; transition: border-color .15s; }
.poll-card:hover { border-color: var(--primary); }
.poll-card h3 { font-size: 1rem; font-weight: 600; margin-bottom: .25rem; }
.poll-meta { font-size: .8rem; color: var(--muted); margin-bottom: .75rem; }
.poll-badge {
    display: inline-block;
    font-size: .7rem;
    font-weight: 600;
    padding: .15rem .5rem;
    border-radius: 99px;
    background: #dcfce7;
    color: #166534;
}
.poll-badge.closed { background: #fee2e2; color: #991b1b; }

/* Options / results */
.option-list { display: flex; flex-direction: column; gap: .5rem; margin: .75rem 0; }

.option-btn {
    display: flex;
    align-items: center;
    gap: .75rem;
    width: 100%;
    padding: .6rem .85rem;
    border: 1.5px solid var(--border);
    border-radius: 8px;
    background: var(--surface);
    cursor: pointer;
    font-size: .9rem;
    text-align: left;
    transition: border-color .15s, background .15s;
}
.option-btn:hover:not(:disabled) { border-color: var(--primary); background: #eef2ff; }
.option-btn:disabled { cursor: default; }

.result-bar-wrap {
    flex: 1;
    display: flex;
    align-items: center;
    gap: .5rem;
}
.result-bar {
    flex: 1;
    height: 6px;
    background: var(--border);
    border-radius: 99px;
    overflow: hidden;
}
.result-bar-fill {
    height: 100%;
    background: var(--primary);
    border-radius: 99px;
    transition: width .4s ease;
}
.result-pct { font-size: .8rem; color: var(--muted); min-width: 32px; text-align: right; }

.option-label { flex: 1; }
.total-votes { font-size: .8rem; color: var(--muted); margin-top: .25rem; }

/* Form */
.form-group { margin-bottom: 1rem; }
label { display: block; font-size: .85rem; font-weight: 500; margin-bottom: .35rem; }
input[type=text], input[type=email], input[type=password],
input[type=datetime-local], textarea {
    width: 100%;
    padding: .55rem .75rem;
    border: 1.5px solid var(--border);
    border-radius: 8px;
    font-size: .9rem;
    font-family: inherit;
    background: var(--surface);
    color: var(--text);
    transition: border-color .15s;
}
input:focus, textarea:focus { outline: none; border-color: var(--primary); }
textarea { resize: vertical; min-height: 80px; }

.options-builder { display: flex; flex-direction: column; gap: .4rem; }
.option-row { display: flex; gap: .4rem; }
.option-row input { flex: 1; }
.btn-remove {
    background: none; border: none; cursor: pointer;
    color: var(--muted); font-size: 1.1rem; padding: 0 .3rem;
}
.btn-remove:hover { color: var(--danger); }

/* Buttons */
.btn {
    display: inline-flex;
    align-items: center;
    gap: .4rem;
    padding: .55rem 1.1rem;
    border-radius: 8px;
    border: none;
    font-size: .875rem;
    font-weight: 500;
    cursor: pointer;
    transition: background .15s, opacity .15s;
    font-family: inherit;
}
.btn:disabled { opacity: .5; cursor: not-allowed; }
.btn-primary  { background: var(--primary); color: #fff; }
.btn-primary:hover:not(:disabled) { background: var(--primary-h); }
.btn-outline  { background: transparent; border: 1.5px solid var(--border); color: var(--text); }
.btn-outline:hover:not(:disabled) { border-color: var(--primary); color: var(--primary); }
.btn-sm { padding: .35rem .75rem; font-size: .8rem; }
.btn-danger { background: var(--danger); color: #fff; }

/* Modal */
.modal-backdrop {
    display: none;
    position: fixed; inset: 0;
    background: rgba(0,0,0,.45);
    z-index: 200;
    align-items: center;
    justify-content: center;
    padding: 1rem;
}
.modal-backdrop.open { display: flex; }
.modal {
    background: var(--surface);
    border-radius: var(--radius);
    padding: 1.5rem;
    width: 100%;
    max-width: 480px;
    max-height: 90vh;
    overflow-y: auto;
}
.modal-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 1.25rem;
}
.modal-header h2 { font-size: 1.1rem; }
.modal-close { background: none; border: none; font-size: 1.4rem; cursor: pointer; color: var(--muted); }

/* Alert */
.alert {
    padding: .65rem .9rem;
    border-radius: 8px;
    font-size: .85rem;
    margin-bottom: .75rem;
}
.alert-error   { background: #fee2e2; color: #991b1b; }
.alert-success { background: #dcfce7; color: #166534; }

/* Page header */
.page-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 1.5rem;
}
.page-header h1 { font-size: 1.3rem; font-weight: 600; }

/* Tabs */
.tabs { display: flex; gap: .25rem; margin-bottom: 1.25rem; }
.tab-btn {
    padding: .45rem .9rem;
    border-radius: 8px;
    border: none;
    background: transparent;
    cursor: pointer;
    font-size: .85rem;
    font-family: inherit;
    color: var(--muted);
}
.tab-btn.active { background: var(--primary); color: #fff; }

/* Poll detail page */
.poll-detail-title { font-size: 1.4rem; font-weight: 700; margin-bottom: .5rem; }
.voted-notice { font-size: .85rem; color: var(--success); margin-top: .5rem; }

/* Spinner */
.spinner {
    width: 20px; height: 20px;
    border: 2px solid var(--border);
    border-top-color: var(--primary);
    border-radius: 50%;
    animation: spin .6s linear infinite;
    display: inline-block;
}
@keyframes spin { to { transform: rotate(360deg); } }

.empty-state { text-align: center; padding: 3rem 1rem; color: var(--muted); }
.empty-state p { margin-top: .5rem; font-size: .9rem; }

@media (max-width: 600px) {
    .page-header { flex-direction: column; align-items: flex-start; gap: .75rem; }
}
