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

:root {
    /* Cribl brand colors */
    --cribl-yellow: #F5A500;
    --cribl-yellow-hover: #d48e00;
    --cribl-yellow-glow: rgba(245, 165, 0, 0.2);

    /* Dark surfaces */
    --bg: #0d1117;
    --surface: #161c26;
    --surface-raised: #1e2738;
    --surface-hover: #243044;

    /* Text */
    --text: #e6edf3;
    --text-muted: #7d8fa8;
    --text-dim: #4a5568;

    /* Borders */
    --border: #2a3448;
    --border-light: #1e2a3a;

    /* Semantic */
    --green: #22c55e;
    --green-dim: rgba(34, 197, 94, 0.15);
    --red: #ef4444;
    --red-dim: rgba(239, 68, 68, 0.15);

    --shadow-sm: 0 1px 3px rgba(0,0,0,0.4);
    --shadow-md: 0 4px 16px rgba(0,0,0,0.5);
}

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

/* ─── HEADER ─────────────────────────────────────────────── */

header {
    background: #0a0e16;
    color: white;
    padding: 1.5rem 2rem;
    box-shadow: 0 2px 12px rgba(0,0,0,0.5);
    border-bottom: 3px solid var(--cribl-yellow);
}

.header-inner {
    max-width: 900px;
    margin: 0 auto;
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 1rem;
}

.logo h1 {
    font-size: 2.1rem;
    font-weight: 900;
    letter-spacing: -0.03em;
    color: white;
    line-height: 1.1;
}

.logo h1 .tm {
    font-size: 0.75rem;
    vertical-align: super;
    color: var(--cribl-yellow);
    font-weight: 400;
    margin-left: 1px;
}

.tagline {
    color: var(--text-muted);
    font-size: 0.82rem;
    margin-top: 0.3rem;
    font-style: italic;
    opacity: 0.9;
}

.stat {
    text-align: center;
    background: rgba(245,165,0,0.08);
    border: 1px solid rgba(245,165,0,0.25);
    padding: 0.6rem 1.25rem;
    border-radius: 10px;
}

.stat-num {
    display: block;
    font-size: 2rem;
    font-weight: 900;
    color: var(--cribl-yellow);
    line-height: 1;
}

.stat-label {
    display: block;
    font-size: 0.65rem;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.08em;
    margin-top: 0.2rem;
}

/* ─── MAIN ───────────────────────────────────────────────── */

main {
    max-width: 900px;
    margin: 2rem auto;
    padding: 0 1.5rem;
    flex: 1;
    width: 100%;
}

/* ─── ADD CARD ───────────────────────────────────────────── */

.add-card {
    background: var(--surface);
    border-radius: 14px;
    padding: 1.75rem;
    box-shadow: var(--shadow-sm);
    margin-bottom: 2rem;
    border-top: 4px solid var(--cribl-yellow);
    position: relative;
    overflow: hidden;
}

.add-card::before {
    content: '';
    position: absolute;
    top: 0; right: 0;
    width: 160px; height: 160px;
    background: radial-gradient(circle at top right, var(--cribl-yellow-glow), transparent 70%);
    pointer-events: none;
}

.add-card h2 {
    font-size: 1.2rem;
    font-weight: 800;
    color: var(--text);
    margin-bottom: 0.2rem;
}

.add-subtitle {
    color: var(--text-muted);
    font-size: 0.875rem;
    margin-bottom: 1.25rem;
}

.form-row {
    display: flex;
    gap: 1rem;
    margin-bottom: 0.85rem;
}

.form-group {
    flex: 1;
    display: flex;
    flex-direction: column;
    gap: 0.3rem;
}

.form-group.full {
    flex: 1 1 100%;
}

label {
    font-size: 0.8rem;
    font-weight: 700;
    color: var(--text);
    letter-spacing: 0.01em;
}

.required { color: var(--cribl-yellow); }
.optional { color: var(--text-muted); font-weight: 400; }

input[type="text"] {
    padding: 0.6rem 0.9rem;
    border: 1.5px solid var(--border);
    border-radius: 8px;
    font-size: 0.9rem;
    font-family: inherit;
    color: var(--text);
    background: var(--surface-raised);
    transition: border-color 0.15s, box-shadow 0.15s;
}

input[type="text"]::placeholder { color: var(--text-dim); }

input[type="text"]:focus {
    outline: none;
    border-color: var(--cribl-yellow);
    box-shadow: 0 0 0 3px var(--cribl-yellow-glow);
}

.form-actions {
    display: flex;
    align-items: center;
    gap: 1rem;
    flex-wrap: wrap;
    margin-top: 0.25rem;
}

.btn-submit {
    background: var(--cribl-yellow);
    color: #0a0e16;
    border: none;
    padding: 0.7rem 1.5rem;
    border-radius: 8px;
    font-size: 0.9rem;
    font-weight: 800;
    font-family: inherit;
    cursor: pointer;
    letter-spacing: 0.01em;
    transition: background 0.15s, transform 0.1s, box-shadow 0.15s;
    box-shadow: 0 2px 8px rgba(245,165,0,0.35);
}

.btn-submit:hover {
    background: var(--cribl-yellow-hover);
    box-shadow: 0 4px 14px rgba(245,165,0,0.45);
}

.btn-submit:active { transform: scale(0.97); }
.btn-submit:disabled { background: #2a3448; color: var(--text-muted); box-shadow: none; cursor: not-allowed; }

.form-feedback {
    font-size: 0.85rem;
    font-weight: 600;
    min-height: 1.2em;
}

.form-feedback.error { color: var(--red); }
.form-feedback.success { color: var(--green); }

/* ─── PHRASES SECTION ────────────────────────────────────── */

.section-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 1rem;
    flex-wrap: wrap;
    gap: 0.75rem;
}

.section-header h2 {
    font-size: 1.15rem;
    font-weight: 800;
    color: var(--text);
}

.phrase-count {
    font-size: 0.85rem;
    font-weight: 500;
    color: var(--text-muted);
}

.sort-tabs {
    display: flex;
    gap: 0.4rem;
}

.sort-tab {
    padding: 0.38rem 0.85rem;
    border-radius: 20px;
    font-size: 0.78rem;
    font-weight: 700;
    text-decoration: none;
    color: var(--text-muted);
    background: var(--surface);
    border: 1.5px solid var(--border);
    transition: all 0.15s;
    letter-spacing: 0.01em;
}

.sort-tab:hover {
    border-color: var(--cribl-yellow);
    color: var(--cribl-yellow);
}

.sort-tab.active {
    background: var(--cribl-yellow);
    color: #0a0e16;
    border-color: var(--cribl-yellow);
    font-weight: 900;
}

/* ─── PHRASE CARDS ───────────────────────────────────────── */

.phrase-card {
    background: var(--surface);
    border-radius: 10px;
    padding: 1rem 1.25rem;
    box-shadow: var(--shadow-sm);
    display: flex;
    gap: 1rem;
    margin-bottom: 0.65rem;
    transition: box-shadow 0.2s, transform 0.2s, border-left-color 0.2s;
    border-left: 4px solid transparent;
}

.phrase-card:hover {
    box-shadow: var(--shadow-md);
    transform: translateY(-2px);
    border-left-color: var(--cribl-yellow);
    background: var(--surface-hover);
}

.phrase-card.new-card {
    animation: slideIn 0.35s cubic-bezier(0.22, 1, 0.36, 1);
    border-left-color: var(--cribl-yellow);
}

@keyframes slideIn {
    from { opacity: 0; transform: translateY(-12px); }
    to   { opacity: 1; transform: translateY(0); }
}

/* Vote column */

.vote-column {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 0.2rem;
    min-width: 38px;
    padding-top: 0.1rem;
}

.vote-btn {
    background: none;
    border: none;
    cursor: pointer;
    font-size: 0.95rem;
    color: var(--border);
    transition: color 0.15s, background 0.15s, transform 0.1s;
    padding: 0.15rem 0.35rem;
    border-radius: 4px;
    line-height: 1;
}

.vote-btn.up:hover  { color: var(--green); background: var(--green-dim); }
.vote-btn.down:hover { color: var(--red); background: var(--red-dim); }

.vote-btn.voted {
    animation: popVote 0.35s cubic-bezier(0.22, 1, 0.36, 1);
}

@keyframes popVote {
    0%   { transform: scale(1); }
    40%  { transform: scale(1.6); }
    100% { transform: scale(1); }
}

.score {
    font-size: 1rem;
    font-weight: 900;
    color: var(--cribl-yellow);
    min-width: 28px;
    text-align: center;
    transition: color 0.3s;
}

.score.score-flash {
    animation: flashScore 0.35s ease;
}

@keyframes flashScore {
    0%   { color: var(--cribl-yellow); transform: scale(1); }
    50%  { color: white; transform: scale(1.25); }
    100% { color: var(--cribl-yellow); transform: scale(1); }
}

/* Phrase content */

.phrase-content {
    flex: 1;
    min-width: 0;
}

.phrase-text {
    font-size: 1.05rem;
    font-weight: 700;
    color: var(--text);
    margin-bottom: 0.3rem;
    font-style: italic;
    line-height: 1.4;
}

.phrase-context {
    font-size: 0.82rem;
    color: var(--text-muted);
    background: var(--surface-raised);
    border-left: 3px solid var(--cribl-yellow);
    padding: 0.3rem 0.6rem;
    border-radius: 0 4px 4px 0;
    margin-bottom: 0.5rem;
    display: inline-block;
    max-width: 100%;
    opacity: 0.85;
}

.phrase-meta {
    display: flex;
    gap: 0.5rem;
    flex-wrap: wrap;
    align-items: center;
    font-size: 0.76rem;
    color: var(--text-muted);
}

.phrase-author {
    font-weight: 700;
    color: var(--cribl-yellow);
    opacity: 0.8;
}

.phrase-sep { color: var(--border); }

/* ─── EMPTY STATE ────────────────────────────────────────── */

.empty-state {
    text-align: center;
    padding: 3.5rem 2rem;
    color: var(--text-muted);
    background: var(--surface);
    border-radius: 10px;
    box-shadow: var(--shadow-sm);
}

.empty-icon {
    font-size: 2.5rem;
    margin-bottom: 0.75rem;
    display: block;
}

/* ─── FOOTER ─────────────────────────────────────────────── */

footer {
    background: #0a0e16;
    color: var(--text-muted);
    text-align: center;
    padding: 1.75rem 1.5rem;
    font-size: 0.8rem;
    margin-top: auto;
    border-top: 3px solid var(--border);
}

.footer-inner p { margin-bottom: 0; }

footer em { color: var(--text-muted); }

/* ─── RESPONSIVE ─────────────────────────────────────────── */

@media (max-width: 620px) {
    .header-inner {
        flex-direction: column;
        text-align: center;
    }

    .logo h1 { font-size: 1.7rem; }

    .form-row { flex-direction: column; }

    .section-header { flex-direction: column; align-items: flex-start; }

    .phrase-text { font-size: 0.97rem; }

    main { padding: 0 1rem; margin: 1.25rem auto; }
}
