:root {
    color-scheme: light dark;
    font-family: Arial, sans-serif;
    background: #f4f7fb;
    color: #1f2937;
}

body {
    margin: 0;
    padding: 0;
    background: linear-gradient(135deg, #f8fbff 0%, #eef4ff 100%);
    color: #1f2937;
    line-height: 1.5;
}

main {
    max-width: 980px;
    margin: 0 auto;
    padding: 1rem 0.9rem 3rem;
}

header {
    background: #1f4ed8;
    color: white;
    padding: 1rem 0.9rem;
}

nav {
    display: flex;
    justify-content: space-between;
    align-items: center;
    max-width: 980px;
    margin: 0 auto;
    gap: 0.75rem;
    flex-wrap: wrap;
    position: relative;
}

nav a {
    color: white;
    text-decoration: none;
    font-weight: 600;
}

.nav-actions {
    display: flex;
    align-items: center;
    gap: 0.7rem;
    position: relative;
}

.icon-btn {
    background: rgba(255, 255, 255, 0.2);
    color: white;
    border: 1px solid rgba(255, 255, 255, 0.3);
    border-radius: 999px;
    width: 2.5rem;
    height: 2.5rem;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: 0;
}

.list-menu-popup {
    position: absolute;
    top: calc(100% + 0.5rem);
    right: 0;
    background: white;
    color: #1f2937;
    border-radius: 12px;
    box-shadow: 0 10px 25px rgba(15, 23, 42, 0.18);
    min-width: 220px;
    padding: 0.75rem;
    z-index: 20;
}

.list-menu-title {
    font-weight: 700;
    margin-bottom: 0.5rem;
}

.list-menu-item {
    display: block;
    padding: 0.5rem 0.6rem;
    border-radius: 8px;
    color: #1f2937;
    text-decoration: none;
}

.list-menu-item.active,
.list-menu-item:hover {
    background: #eff6ff;
}

.box {
    background: white;
    border-radius: 16px;
    padding: 1rem;
    box-shadow: 0 10px 25px rgba(15, 23, 42, 0.08);
    margin-bottom: 1rem;
}

form {
    display: flex;
    flex-direction: column;
    gap: 0.7rem;
}

input, textarea, button, select {
    font: inherit;
    padding: 0.8rem;
    border-radius: 10px;
    border: 1px solid #d7e0ef;
    width: 100%;
    box-sizing: border-box;
}

button {
    background: #2563eb;
    color: white;
    cursor: pointer;
    border: none;
}

button.secondary {
    background: #64748b;
}

button.vote-up {
    background: #16a34a;
}

button.vote-down {
    background: #dc2626;
}

.grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
    gap: 1rem;
}

@media (max-width: 640px) {
    main {
        padding: 0.8rem 0.75rem 2rem;
    }

    .box {
        padding: 0.9rem;
    }

    nav {
        flex-direction: column;
        align-items: flex-start;
    }

    .grid {
        grid-template-columns: 1fr;
    }

    .item-row {
        flex-direction: column;
        align-items: flex-start;
    }

    .inline-actions {
        width: 100%;
        justify-content: flex-start;
    }
}

.card {
    border: 1px solid #e2e8f0;
    padding: 1rem;
    border-radius: 14px;
    background: #f8fafc;
}

.small {
    font-size: 0.9rem;
    color: #475569;
}

.flash {
    padding: 0.8rem 1rem;
    border-radius: 10px;
    margin-bottom: 1rem;
    background: #dbeafe;
    color: #1d4ed8;
}

.flash.error {
    background: #fee2e2;
    color: #b91c1c;
}

.item-row {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 1rem;
    padding: 0.8rem 0;
    border-bottom: 1px solid #e5e7eb;
}

.item-row:last-child {
    border-bottom: 0;
}

.inline-actions {
    display: flex;
    gap: 0.5rem;
    flex-wrap: wrap;
}

.speech-row {
    display: flex;
    gap: 0.5rem;
    align-items: center;
}

.speech-row input {
    flex: 1;
}

.speech-row button {
    flex: 0 0 auto;
    white-space: nowrap;
}

@media (max-width: 640px) {
    .speech-row {
        flex-direction: column;
        align-items: stretch;
    }
}
