:root {
    --bg: #faf8f4;
    --surface: #ffffff;
    --border: #e8e2d8;
    --muted: #9e9487;
    --text: #2c2720;
    --accent: #c0392b;
    --accent-lt: #f9ecea;
    --green: #2d6a4f;
    --green-lt: #e8f5ee;
    --shadow: 0 2px 12px rgba(44, 39, 32, 0.08);
    --radius: 10px;
}

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

body {
    font-family: "DM Sans", sans-serif;
    background: var(--bg);
    color: var(--text);
    min-height: 100vh;
}

/* ── AUTH SCREEN ── */
#auth-screen {
    /* visibility handled by .active class above */
}

.auth-card {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: 16px;
    box-shadow: var(--shadow);
    padding: 48px 40px 40px;
    width: 100%;
    max-width: 420px;
}

.auth-card h1 {
    font-family: "Lora", serif;
    font-size: 2rem;
    font-weight: 600;
    line-height: 1.2;
    margin-bottom: 6px;
}

.auth-card .tagline {
    color: var(--muted);
    font-size: 0.9rem;
    margin-bottom: 32px;
}

.tab-row {
    display: flex;
    gap: 0;
    margin-bottom: 24px;
    border-bottom: 2px solid var(--border);
}

.tab-btn {
    flex: 1;
    background: none;
    border: none;
    padding: 10px;
    font-family: inherit;
    font-size: 0.9rem;
    font-weight: 500;
    color: var(--muted);
    cursor: pointer;
    border-bottom: 2px solid transparent;
    margin-bottom: -2px;
    transition:
        color 0.15s,
        border-color 0.15s;
}

.tab-btn.active {
    color: var(--accent);
    border-bottom-color: var(--accent);
}

label {
    display: block;
    font-size: 0.82rem;
    font-weight: 500;
    margin-bottom: 5px;
    color: var(--muted);
    letter-spacing: 0.04em;
    text-transform: uppercase;
}

input[type="text"],
input[type="password"] {
    width: 100%;
    padding: 10px 14px;
    border: 1px solid var(--border);
    border-radius: var(--radius);
    font-family: inherit;
    font-size: 0.95rem;
    background: var(--bg);
    color: var(--text);
    outline: none;
    transition: border-color 0.15s;
    margin-bottom: 16px;
}

input:focus {
    border-color: var(--accent);
}

.btn {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 10px 20px;
    border: none;
    border-radius: var(--radius);
    font-family: inherit;
    font-size: 0.9rem;
    font-weight: 500;
    cursor: pointer;
    transition:
        opacity 0.15s,
        transform 0.1s;
}

.btn:active {
    transform: scale(0.97);
}

.btn:disabled {
    opacity: 0.5;
    cursor: default;
}

.btn-primary {
    background: var(--accent);
    color: #fff;
    width: 100%;
    justify-content: center;
    padding: 12px;
    font-size: 1rem;
}

.btn-primary:hover {
    opacity: 0.88;
}

.btn-ghost {
    background: var(--bg);
    border: 1px solid var(--border);
    color: var(--text);
}

.btn-ghost:hover {
    border-color: var(--muted);
}

.ack-btn {
    display: inline-grid;
    grid-template: 1fr / 1fr;
    place-items: center;
}

.ack-btn > span {
    grid-area: 1 / 1;
}

.ack-btn .ack-hover {
    visibility: hidden;
}

.ack-btn:hover .ack-default {
    visibility: hidden;
}

.ack-btn:hover .ack-hover {
    visibility: visible;
}

.ack-toast {
    position: fixed;
    pointer-events: none;
    font-size: .82rem;
    font-weight: 500;
    color: var(--green);
    z-index: 100;
    animation: ack-float 0.8s ease-out forwards;
}

@keyframes ack-float {
    0% {
        opacity: 1;
        transform: translateY(0);
    }
    100% {
        opacity: 0;
        transform: translateY(-24px);
    }
}

.btn-danger {
    background: var(--accent-lt);
    color: var(--accent);
    border: 1px solid #e8c5c2;
}

.btn-sm {
    padding: 6px 14px;
    font-size: 0.82rem;
}

.error-msg {
    color: var(--accent);
    font-size: 0.85rem;
    margin-top: -8px;
    margin-bottom: 12px;
}

/* ── SCREEN VISIBILITY ── */
#auth-screen,
#app-screen {
    display: none;
}

#auth-screen.active {
    display: flex;
    align-items: center;
    justify-content: center;
    min-height: 100vh;
    padding: 24px;
}

#app-screen.active {
    display: block;
    min-height: 100vh;
}

header {
    background: var(--surface);
    border-bottom: 1px solid var(--border);
    padding: 0 24px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    height: 60px;
    position: sticky;
    top: 0;
    z-index: 10;
}

header .logo {
    font-family: "Lora", serif;
    font-size: 1.2rem;
    font-weight: 600;
}

header .logo span {
    color: var(--accent);
}

.header-right {
    display: flex;
    align-items: center;
    gap: 12px;
    font-size: 0.88rem;
    color: var(--muted);
}

.app-body {
    display: grid;
    grid-template-columns: 220px 1fr;
    min-height: calc(100vh - 60px);
}

/* ── SIDEBAR ── */
aside {
    background: var(--surface);
    border-right: 1px solid var(--border);
    padding: 24px 16px;
}

.sidebar-section {
    margin-bottom: 28px;
}

.sidebar-label {
    font-size: 0.72rem;
    font-weight: 500;
    letter-spacing: 0.08em;
    text-transform: uppercase;
    color: var(--muted);
    margin-bottom: 10px;
    padding: 0 8px;
}

.family-list {
    list-style: none;
}

.family-list li button {
    width: 100%;
    text-align: left;
    background: none;
    border: none;
    padding: 8px 10px;
    border-radius: 7px;
    font-family: inherit;
    font-size: 0.9rem;
    cursor: pointer;
    color: var(--text);
    transition: background 0.12s;
    display: flex;
    align-items: center;
    gap: 8px;
}

.family-list li button:hover {
    background: var(--bg);
}

.family-list li button.active {
    background: var(--accent-lt);
    color: var(--accent);
    font-weight: 500;
}

.avatar {
    width: 26px;
    height: 26px;
    border-radius: 50%;
    background: var(--border);
    display: inline-flex;
    align-items: center;
    justify-content: center;
    font-size: 0.75rem;
    font-weight: 600;
    color: var(--muted);
    flex-shrink: 0;
}

.me-tag {
    font-size: 0.7rem;
    background: var(--border);
    color: var(--muted);
    padding: 1px 6px;
    border-radius: 99px;
    margin-left: auto;
}

/* ── MAIN CONTENT ── */
main {
    padding: 32px;
    /* max-width: 760px; */
}

.page-header {
    margin-bottom: 28px;
}

.page-header h2 {
    font-family: "Lora", serif;
    font-size: 1.6rem;
    font-weight: 600;
}

.page-header p {
    color: var(--muted);
    font-size: 0.88rem;
    margin-top: 4px;
}

.notice {
    background: var(--accent-lt);
    border: 1px solid #e8c5c2;
    border-radius: var(--radius);
    padding: 10px 14px;
    font-size: 0.85rem;
    color: #7a1c14;
    margin-bottom: 20px;
    display: flex;
    align-items: center;
    gap: 8px;
    max-width: 760px;
}

/* ── WISH LIST ── */
.wish-list {
    list-style: none;
    display: flex;
    flex-direction: column;
    gap: 10px;
    margin-bottom: 24px;
    max-width: 760px;
}

.wish-item {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 14px 16px;
    display: flex;
    align-items: flex-start;
    gap: 12px;
    transition: box-shadow 0.15s;
}

.wish-item:hover {
    box-shadow: var(--shadow);
}

.wish-item.claimed-by-me {
    border-color: #a8d5ba;
    background: var(--green-lt);
}

.wish-item.claimed-other {
    opacity: 0.6;
}

.wish-item-body {
    flex: 1;
    min-width: 0;
}

.wish-item-title {
    font-weight: 500;
    font-size: 0.95rem;
    margin-bottom: 2px;
}

.wish-item-meta {
    font-size: 0.82rem;
    color: var(--muted);
}

.wish-item-meta a {
    color: var(--accent);
    text-decoration: none;
}

.wish-item-meta a:hover {
    text-decoration: underline;
}

.wish-item-actions {
    display: flex;
    gap: 6px;
    flex-shrink: 0;
    align-items: center;
}

.badge {
    font-size: 0.72rem;
    padding: 2px 8px;
    border-radius: 99px;
    font-weight: 500;
}

.badge-green {
    background: var(--green-lt);
    color: var(--green);
}

.badge-muted {
    background: var(--bg);
    color: var(--muted);
    border: 1px solid var(--border);
}

/* ── ADD ITEM FORM ── */
.add-item-card {
    background: var(--surface);
    border: 1px dashed var(--border);
    border-radius: var(--radius);
    padding: 20px;
    max-width: 760px;
}

.add-item-card h3 {
    font-size: 0.95rem;
    font-weight: 600;
    margin-bottom: 14px;
}

.form-row {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 12px;
}

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

.add-actions {
    display: flex;
    justify-content: flex-end;
    gap: 8px;
    margin-top: 4px;
}

.empty-state {
    text-align: center;
    padding: 48px 24px;
    color: var(--muted);
    max-width: 768px;
}

.empty-state .icon {
    font-size: 2.5rem;
    margin-bottom: 12px;
}

.empty-state p {
    font-size: 0.9rem;
}

/* ── TWO-COLUMN LAYOUT ── */
.list-and-chat {
    display: grid;
    grid-template-columns: 1fr 380px;
    gap: 24px;
    align-items: start;
}

@media (max-width: 860px) {
    .list-and-chat {
        grid-template-columns: 1fr 300px;
    }
}

@media (max-width: 700px) {
    .list-and-chat {
        grid-template-columns: 1fr;
    }
}

/* ── CHAT ── */
.chat-section {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    overflow: hidden;
}

.chat-section h3 {
    font-size: 0.9rem;
    font-weight: 600;
    padding: 14px 16px 0;
}

.chat-messages {
    padding: 8px 16px 12px;
    max-height: 260px;
    overflow-y: auto;
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.chat-msg strong {
    font-size: 0.85rem;
    margin-right: 6px;
}

.chat-msg .chat-time {
    font-size: 0.75rem;
    color: var(--muted);
}

.chat-msg p {
    font-size: 0.88rem;
    margin-top: 1px;
    line-height: 1.4;
}

.chat-input-row {
    display: flex;
    gap: 8px;
    padding: 8px 16px 14px;
    border-top: 1px solid var(--border);
}

.chat-input-row input {
    flex: 1;
    margin-bottom: 0;
}

.chat-input-row .btn {
    width: auto;
    flex-shrink: 0;
}

/* ── UTILS ── */
.hidden {
    display: none !important;
}

.spinner {
    display: inline-block;
    width: 14px;
    height: 14px;
    border: 2px solid currentColor;
    border-top-color: transparent;
    border-radius: 50%;
    animation: spin 0.6s linear infinite;
}

@keyframes spin {
    to {
        transform: rotate(360deg);
    }
}

/* ── DARK MODE (Catppuccin Mocha) ── */
:root.dark {
    --bg: #1e1e2e;
    --surface: #181825;
    --border: #313244;
    --muted: #6c7086;
    --text: #cdd6f4;
    --accent: #f38ba8;
    --accent-lt: #3a2830;
    --green: #a6e3a1;
    --green-lt: #1a2a1e;
    --shadow: 0 2px 12px rgba(0, 0, 0, 0.4);
}

:root.dark .btn-primary {
    background: #d47a94;
}

:root.dark .notice {
    color: var(--accent);
    border-color: #4a3840;
}

.badge-dot {
    color: var(--accent);
    font-size: 0.6rem;
    margin-left: auto;
    line-height: 1;
}

@media (max-width: 640px) {
    .app-body {
        grid-template-columns: 1fr;
    }

    aside {
        border-right: none;
        border-bottom: 1px solid var(--border);
        padding: 12px;
    }

    .family-list {
        display: flex;
        flex-wrap: wrap;
        gap: 6px;
    }

    .family-list li button {
        width: auto;
    }

    main {
        padding: 20px 16px;
    }

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