:root {
    --bg: #f5f2ea;
    --card-bg: #fffefb;
    --text: #2c2a22;
    --muted: #8b8371;
    --accent: #5b7a5c;
    --accent-dark: #46603f;
    --accent-soft: #e6ebe1;
    --border: #e4ddcc;
    --danger: #b3403a;
    --done: #7a9c6e;
}

@media (prefers-color-scheme: dark) {
    :root {
        --bg: #1a1815;
        --card-bg: #24221c;
        --text: #f0ece1;
        --muted: #a89f8c;
        --accent: #8fb08a;
        --accent-dark: #b6d1af;
        --accent-soft: #2b3325;
        --border: #383327;
        --danger: #e07a73;
        --done: #93b787;
    }
}

* { box-sizing: border-box; }

body {
    margin: 0;
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
    background: var(--bg);
    color: var(--text);
}

header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 1rem 1.25rem;
    max-width: 640px;
    margin: 0 auto;
}

.brand {
    font-weight: 700;
    font-size: 1.1rem;
    text-decoration: none;
    color: var(--text);
    display: flex;
    align-items: center;
    gap: 0.4rem;
}

.brand .dot {
    width: 0.55rem;
    height: 0.55rem;
    border-radius: 50%;
    background: var(--accent);
    display: inline-block;
}

.header-actions {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    font-size: 0.9rem;
}

.header-actions a, .header-actions button.link {
    color: var(--muted);
    text-decoration: none;
    background: none;
    border: none;
    font-size: 0.9rem;
    cursor: pointer;
    padding: 0;
    font-family: inherit;
}

.header-actions a:hover, .header-actions button.link:hover {
    color: var(--text);
}

main {
    max-width: 640px;
    margin: 0 auto;
    padding: 0.5rem 1.25rem 3rem;
}

.flash {
    background: var(--accent-soft);
    color: var(--accent-dark);
    padding: 0.7rem 1rem;
    border-radius: 10px;
    margin-bottom: 1rem;
    font-size: 0.9rem;
}

.btn {
    display: inline-block;
    background: var(--accent);
    color: #fff;
    border: none;
    padding: 0.6rem 1.1rem;
    border-radius: 999px;
    text-decoration: none;
    font-size: 0.95rem;
    cursor: pointer;
    font-weight: 600;
    font-family: inherit;
}

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

.btn.secondary {
    background: transparent;
    color: var(--text);
    border: 1px solid var(--border);
    font-weight: 500;
}

.btn.small {
    padding: 0.4rem 0.8rem;
    font-size: 0.85rem;
}

.btn.danger { background: var(--danger); }

/* Dashboard */
.page-title {
    font-size: 1.5rem;
    font-weight: 700;
    margin: 1.5rem 0 1.25rem;
}

.agenda-grid {
    display: grid;
    gap: 0.8rem;
}

.agenda-tile {
    display: block;
    background: var(--card-bg);
    border: 1px solid var(--border);
    border-radius: 16px;
    padding: 1.1rem 1.25rem;
    text-decoration: none;
    color: var(--text);
    transition: transform 0.15s ease, box-shadow 0.15s ease;
}

.agenda-tile:hover {
    transform: translateY(-2px);
    box-shadow: 0 8px 20px rgba(0,0,0,0.06);
}

.agenda-tile .name {
    font-size: 1.1rem;
    font-weight: 700;
    margin-bottom: 0.3rem;
}

.agenda-tile .meta {
    color: var(--muted);
    font-size: 0.88rem;
}

.empty {
    color: var(--muted);
    text-align: center;
    padding: 3rem 1rem;
}

/* Agenda page */
.agenda-header {
    margin: 1.5rem 0 1.25rem;
}

.agenda-header h1 {
    font-size: 1.5rem;
    margin: 0 0 0.2rem;
}

.agenda-header .sub {
    color: var(--muted);
    font-size: 0.9rem;
}

.catchup-card {
    background: var(--card-bg);
    border: 1px solid var(--border);
    border-radius: 18px;
    padding: 1.25rem;
    margin-bottom: 1.5rem;
}

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

.date-badge {
    display: inline-flex;
    align-items: center;
    gap: 0.4rem;
    background: var(--accent-soft);
    color: var(--accent-dark);
    padding: 0.35rem 0.8rem;
    border-radius: 999px;
    font-weight: 600;
    font-size: 0.92rem;
}

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

.date-form {
    display: flex;
    gap: 0.4rem;
    align-items: center;
}

.date-form input[type="date"] {
    border: 1px solid var(--border);
    border-radius: 8px;
    padding: 0.35rem 0.5rem;
    background: var(--bg);
    color: var(--text);
    font-family: inherit;
    font-size: 0.88rem;
}

.item-list {
    list-style: none;
    margin: 0;
    padding: 0;
}

.item {
    border-bottom: 1px solid var(--border);
    padding: 0.7rem 0;
}

.item:last-child { border-bottom: none; }

.item-row {
    display: flex;
    align-items: flex-start;
    gap: 0.7rem;
}

.checkbox-btn {
    flex-shrink: 0;
    width: 1.35rem;
    height: 1.35rem;
    border-radius: 50%;
    border: 2px solid var(--border);
    background: var(--card-bg);
    cursor: pointer;
    margin-top: 0.1rem;
    padding: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: background 0.15s ease, border-color 0.15s ease;
}

.checkbox-btn svg {
    width: 0.8rem;
    height: 0.8rem;
    opacity: 0;
    transition: opacity 0.15s ease;
}

.checkbox-btn.checked {
    background: var(--done);
    border-color: var(--done);
}

.checkbox-btn.checked svg { opacity: 1; }

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

.item-text {
    font-size: 1rem;
    line-height: 1.4;
    transition: color 0.2s ease;
}

.item.done .item-text {
    text-decoration: line-through;
    color: var(--muted);
}

.item-meta {
    display: flex;
    align-items: center;
    gap: 0.6rem;
    margin-top: 0.25rem;
    font-size: 0.78rem;
    color: var(--muted);
}

.item-meta button.link, .item-meta a.link {
    background: none;
    border: none;
    color: var(--muted);
    text-decoration: underline;
    cursor: pointer;
    font-size: 0.78rem;
    padding: 0;
    font-family: inherit;
}

.item-notes {
    margin-top: 0.5rem;
}

.item-notes textarea {
    width: 100%;
    min-height: 3rem;
    border: 1px solid var(--border);
    border-radius: 8px;
    padding: 0.5rem 0.6rem;
    background: var(--bg);
    color: var(--text);
    font-family: inherit;
    font-size: 0.9rem;
    resize: vertical;
}

.item-notes-text {
    font-size: 0.88rem;
    color: var(--muted);
    background: var(--bg);
    border-radius: 8px;
    padding: 0.5rem 0.6rem;
    margin-top: 0.4rem;
    white-space: pre-wrap;
}

.add-item-form {
    display: flex;
    gap: 0.5rem;
    margin-top: 1rem;
}

.add-item-form input[type="text"] {
    flex: 1;
    border: 1px solid var(--border);
    border-radius: 10px;
    padding: 0.6rem 0.8rem;
    background: var(--bg);
    color: var(--text);
    font-family: inherit;
    font-size: 0.95rem;
}

.catchup-footer {
    margin-top: 1.1rem;
    text-align: right;
}

.history-toggle {
    background: none;
    border: none;
    color: var(--muted);
    font-size: 0.9rem;
    cursor: pointer;
    font-family: inherit;
    padding: 0.5rem 0;
    display: flex;
    align-items: center;
    gap: 0.4rem;
}

.history-list {
    display: none;
}

.history-list.open { display: block; }

.history-catchup {
    background: var(--card-bg);
    border: 1px solid var(--border);
    border-radius: 14px;
    padding: 1rem 1.1rem;
    margin-bottom: 0.75rem;
}

.history-catchup .date {
    font-weight: 700;
    margin-bottom: 0.5rem;
}

.history-catchup .item {
    padding: 0.4rem 0;
    font-size: 0.92rem;
}

.history-catchup .item.done .item-text {
    text-decoration: line-through;
    color: var(--muted);
}

/* Auth pages */
.auth-wrap {
    max-width: 380px;
    margin: 4rem auto;
    padding: 0 1.25rem;
}

.auth-card {
    background: var(--card-bg);
    border: 1px solid var(--border);
    border-radius: 18px;
    padding: 2rem 1.75rem;
}

.auth-card h1 {
    font-size: 1.3rem;
    margin: 0 0 0.3rem;
    text-align: center;
}

.auth-card .sub {
    text-align: center;
    color: var(--muted);
    font-size: 0.88rem;
    margin-bottom: 1.5rem;
}

.field {
    margin-bottom: 1rem;
}

.field label {
    display: block;
    font-size: 0.85rem;
    color: var(--muted);
    margin-bottom: 0.3rem;
}

.field input {
    width: 100%;
    padding: 0.6rem 0.7rem;
    border-radius: 9px;
    border: 1px solid var(--border);
    background: var(--bg);
    color: var(--text);
    font-size: 1rem;
    font-family: inherit;
}

.auth-card .btn { width: 100%; text-align: center; margin-top: 0.5rem; }

.error {
    background: #fbe4e2;
    color: var(--danger);
    padding: 0.6rem 0.8rem;
    border-radius: 8px;
    font-size: 0.88rem;
    margin-bottom: 1rem;
}

@media (prefers-color-scheme: dark) {
    .error { background: #3a1f1d; }
}

/* Admin */
.temp-password-box {
    background: var(--accent-soft);
    border-radius: 14px;
    padding: 1.1rem 1.25rem;
    margin-bottom: 1.25rem;
}

.temp-password-box .label {
    font-size: 0.85rem;
    color: var(--accent-dark);
    margin-bottom: 0.3rem;
}

.temp-password-box .value {
    font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
    font-size: 1.2rem;
    font-weight: 700;
    letter-spacing: 0.02em;
}

.user-row {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 0.75rem 0;
    border-bottom: 1px solid var(--border);
}

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

.user-row .name { font-weight: 600; }
.user-row .username { color: var(--muted); font-size: 0.85rem; }

form.record-form {
    background: var(--card-bg);
    border: 1px solid var(--border);
    border-radius: 16px;
    padding: 1.25rem;
    margin-top: 1.5rem;
}

form.record-form h2 {
    font-size: 1.05rem;
    margin: 0 0 1rem;
}
