:root {
    --bg: #1a1412;
    --card: #2b211e;
    --card-alt: #362a26;
    --accent: #d4a373;
    --accent-dim: #a9805a;
    --text: #fdf8f5;
    --text-muted: #b8a99f;
    --danger: #e07a5f;
    --border: #4a3a34;
    --radius: 12px;
}

* { box-sizing: border-box; }

html, body {
    margin: 0;
    padding: 0;
    background: var(--bg);
    color: var(--text);
    font-family: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
    line-height: 1.5;
}

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

.page-container {
    max-width: 640px;
    margin: 0 auto;
    padding: 16px 16px 88px;
    min-height: 100vh;
}

h1, h2, h3 { margin: 0 0 12px; }

.app-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 12px 0 20px;
}

.app-header .brand {
    font-size: 1.4rem;
    font-weight: 700;
    color: var(--accent);
}

.warning-banner {
    background: rgba(224, 122, 95, 0.15);
    border: 1px solid var(--danger);
    color: var(--text);
    padding: 10px 12px;
    border-radius: 8px;
    margin-bottom: 16px;
    font-size: 0.9rem;
}

.warning-banner a { font-weight: 600; }

/* Forms */
.card {
    background: var(--card);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 16px;
    margin-bottom: 16px;
}

.form-group { margin-bottom: 14px; }

label { display: block; margin-bottom: 6px; font-size: 0.9rem; color: var(--text-muted); }

input[type="text"],
input[type="email"],
input[type="password"],
input[type="number"],
select,
textarea {
    width: 100%;
    padding: 10px 12px;
    background: var(--card-alt);
    border: 1px solid var(--border);
    border-radius: 8px;
    color: var(--text);
    font-size: 1rem;
}

textarea { min-height: 90px; resize: vertical; }

input:focus, select:focus, textarea:focus {
    outline: none;
    border-color: var(--accent);
}

.btn {
    display: inline-block;
    width: 100%;
    padding: 12px 16px;
    background: var(--accent);
    color: #1a1412;
    border: none;
    border-radius: 8px;
    font-size: 1rem;
    font-weight: 600;
    text-align: center;
    cursor: pointer;
}

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

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

.error-msg {
    background: rgba(224, 122, 95, 0.15);
    border: 1px solid var(--danger);
    color: var(--danger);
    padding: 10px 12px;
    border-radius: 8px;
    margin-bottom: 14px;
    font-size: 0.9rem;
}

.success-msg {
    background: rgba(212, 163, 115, 0.15);
    border: 1px solid var(--accent);
    color: var(--accent);
    padding: 10px 12px;
    border-radius: 8px;
    margin-bottom: 14px;
    font-size: 0.9rem;
}

.bio-textarea {
    min-height: 48px;
    resize: none;
}

.hint {
    color: var(--text-muted);
    font-size: 0.85rem;
    margin-top: 20px;
    text-align: center;
}

/* Bottom nav */
.bottom-nav {
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    display: flex;
    justify-content: space-around;
    background: var(--card);
    border-top: 1px solid var(--border);
    padding: 8px 0 calc(8px + env(safe-area-inset-bottom));
    z-index: 10;
}

.nav-item {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 2px;
    color: var(--text-muted);
    font-size: 0.7rem;
}

.nav-item svg { width: 22px; height: 22px; }

.nav-item.active { color: var(--accent); }

/* Feed */
.post-card {
    background: var(--card);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    overflow: hidden;
    margin-bottom: 20px;
}

.post-card__author {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 12px;
}

.post-card__author img.avatar {
    width: 36px;
    height: 36px;
    border-radius: 50%;
    object-fit: cover;
    background: var(--card-alt);
}

.post-card__author .meta { display: flex; flex-direction: column; }
.post-card__author .username { font-weight: 600; }
.post-card__author .timestamp { font-size: 0.8rem; color: var(--text-muted); }

.post-card__image {
    width: 100%;
    aspect-ratio: 4 / 3;
    object-fit: cover;
    background: var(--card-alt);
    display: block;
}

.post-card__body { padding: 12px; }

.post-card__coffee {
    display: flex;
    align-items: center;
    gap: 8px;
    font-weight: 600;
    margin-bottom: 6px;
}

.post-card__coffee img { width: 20px; height: 20px; }

.post-card__location { color: var(--text-muted); font-size: 0.85rem; margin-bottom: 6px; }

.stars { color: var(--accent); letter-spacing: 2px; }
.stars .empty { color: var(--border); }

.post-card__notes { margin-top: 8px; font-size: 0.9rem; white-space: pre-line; }

.pagination {
    display: flex;
    justify-content: space-between;
    margin: 20px 0;
}

/* Leaderboard */
.record-card {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 8px;
    flex-wrap: wrap;
    background: linear-gradient(135deg, var(--card-alt), var(--card));
    border: 1px solid var(--accent-dim);
    border-radius: var(--radius);
    padding: 12px 16px;
    margin-bottom: 16px;
}

.record-card__label {
    font-weight: 600;
    color: var(--accent);
}

.record-card__value {
    color: var(--text);
    font-size: 0.95rem;
}

.leaderboard-row {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 10px 0;
    border-bottom: 1px solid var(--border);
}

.leaderboard-row:last-child { border-bottom: none; }

.leaderboard-row .rank {
    width: 28px;
    font-weight: 700;
    color: var(--accent);
    text-align: center;
}

.leaderboard-row img.avatar {
    width: 40px;
    height: 40px;
    border-radius: 50%;
    object-fit: cover;
    background: var(--card-alt);
}

.leaderboard-row .info { flex: 1; }
.leaderboard-row .username { font-weight: 600; }
.leaderboard-row .stats { font-size: 0.8rem; color: var(--text-muted); }

/* Admin panel */
.admin-tabs {
    display: flex;
    gap: 8px;
    margin-bottom: 16px;
}

.admin-tabs a {
    padding: 8px 14px;
    border-radius: 8px;
    background: var(--card);
    color: var(--text-muted);
    font-size: 0.9rem;
    border: 1px solid var(--border);
}

.admin-tabs a.active {
    background: var(--accent);
    color: #1a1412;
    font-weight: 600;
    border-color: var(--accent);
}

.admin-row {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 12px 0;
    border-bottom: 1px solid var(--border);
}

.admin-row:last-child { border-bottom: none; }

.admin-row .info { flex: 1; min-width: 0; }
.admin-row .username { font-weight: 600; }
.admin-row .meta { font-size: 0.8rem; color: var(--text-muted); }

.admin-row .invite-code {
    font-family: monospace;
    word-break: break-all;
}

.admin-row form { width: auto; }

.admin-row .btn,
.admin-row .btn-secondary {
    width: auto;
    padding: 8px 14px;
    font-size: 0.85rem;
    white-space: nowrap;
}

.badge {
    font-size: 0.75rem;
    padding: 4px 10px;
    border-radius: 12px;
    background: var(--card-alt);
    color: var(--accent);
    font-weight: 600;
}

/* Star rating input */
.star-rating {
    display: flex;
    flex-direction: row-reverse;
    justify-content: flex-end;
    gap: 4px;
}

.star-rating input { display: none; }

.star-rating label {
    font-size: 1.8rem;
    color: var(--border);
    cursor: pointer;
    margin: 0;
}

.star-rating input:checked ~ label,
.star-rating label:hover,
.star-rating label:hover ~ label {
    color: var(--accent);
}

/* Coffee picker modal */
.coffee-picker-trigger {
    width: 100%;
    text-align: left;
    padding: 10px 12px;
    background: var(--card-alt);
    border: 1px solid var(--border);
    border-radius: 8px;
    color: var(--text);
    font-size: 1rem;
    cursor: pointer;
}

.modal-overlay {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.6);
    display: none;
    align-items: flex-end;
    justify-content: center;
    z-index: 20;
}

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

.modal-sheet {
    background: var(--card);
    border-radius: 16px 16px 0 0;
    width: 100%;
    max-width: 640px;
    max-height: 80vh;
    display: flex;
    flex-direction: column;
    padding: 16px;
}

.modal-sheet__header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 10px;
}

.coffee-list {
    overflow-y: auto;
    list-style: none;
    margin: 0;
    padding: 0;
}

.coffee-list li {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 10px 6px;
    border-radius: 8px;
    cursor: pointer;
}

.coffee-list li:hover { background: var(--card-alt); }

.coffee-list img { width: 24px; height: 24px; }

.coffee-list .default-vol { margin-left: auto; color: var(--text-muted); font-size: 0.8rem; }

/* Profile */
.profile-header {
    display: flex;
    align-items: center;
    gap: 14px;
    margin-bottom: 16px;
}

.profile-header img.avatar {
    width: 72px;
    height: 72px;
    border-radius: 50%;
    object-fit: cover;
    background: var(--card-alt);
}

.profile-stats {
    display: flex;
    gap: 16px;
    margin: 12px 0;
}

.profile-stats .stat { text-align: center; }
.profile-stats .stat .value { font-size: 1.2rem; font-weight: 700; color: var(--accent); }
.profile-stats .stat .label { font-size: 0.75rem; color: var(--text-muted); }

.profile-grid {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 6px;
}

.profile-grid img {
    width: 100%;
    aspect-ratio: 1;
    object-fit: cover;
    border-radius: 6px;
    background: var(--card-alt);
}

.invite-link-box {
    display: flex;
    gap: 8px;
}

.invite-link-box input {
    flex: 1;
}

.invite-link-box .btn { width: auto; white-space: nowrap; }

@media (min-width: 768px) {
    .page-container { padding-bottom: 32px; }
    .bottom-nav {
        position: sticky;
        top: 0;
        bottom: auto;
        border-top: none;
        border-bottom: 1px solid var(--border);
        margin-bottom: 20px;
    }
}
