:root {
    --bg: #fafaf9;
    --fg: #1c1917;
    --muted: #78716c;
    --line: #e7e5e4;
    --card: #ffffff;
    --accent: #2563eb;
    --success: #16a34a;
    --danger: #b91c1c;
}

@media (prefers-color-scheme: dark) {
    :root {
        --bg: #1c1917;
        --fg: #fafaf9;
        --muted: #a8a29e;
        --line: #44403c;
        --card: #292524;
        --accent: #60a5fa;
        --success: #22c55e;
        --danger: #f87171;
    }
}

* { box-sizing: border-box; }

body {
    margin: 0;
    background: var(--bg);
    color: var(--fg);
    font: 18px/1.5 system-ui, -apple-system, "Segoe UI", sans-serif;
}

a { color: var(--accent); }

.bar {
    position: sticky;
    top: 0;
    z-index: 10;
    display: grid;
    grid-template-columns: 3rem 1fr 3rem;
    align-items: center;
    padding: 0.5rem 0.5rem;
    color: #fff;
    background: #1565c0;
    box-shadow: 0 1px 4px rgba(0, 0, 0, 0.3);
}

.brand {
    grid-column: 2;
    text-align: center;
    font-size: 1.25rem;
    font-weight: 600;
    color: #fff;
    text-decoration: none;
}

.menu-toggle {
    grid-column: 1;
    display: flex;
    flex-direction: column;
    justify-content: center;
    gap: 5px;
    width: 2.75rem;
    height: 2.75rem;
    padding: 0 0.6rem;
    background: none;
    border: 0;
    border-radius: 50%;
    cursor: pointer;
}

.menu-toggle span { display: block; height: 3px; background: #fff; border-radius: 2px; }
.menu-toggle:focus-visible { outline: 2px solid #fff; outline-offset: 2px; }

.scrim { position: fixed; inset: 0; z-index: 20; background: rgba(0, 0, 0, 0.45); }
.scrim[hidden] { display: none; }

.drawer {
    position: fixed;
    top: 0;
    bottom: 0;
    left: 0;
    z-index: 30;
    display: flex;
    flex-direction: column;
    width: min(16rem, 80vw);
    background: var(--card);
    box-shadow: 2px 0 8px rgba(0, 0, 0, 0.3);
}

.drawer[hidden] { display: none; }
.drawer form { margin: 0; }

.drawer-head {
    margin: 0 0 0.5rem;
    padding: 0.9rem 1rem;
    font-size: 1.25rem;
    font-weight: 600;
    color: #fff;
    background: #1565c0;
    overflow-wrap: anywhere;
}

.drawer a,
.drawer button {
    display: block;
    width: 100%;
    padding: 0.8rem 1rem;
    font: inherit;
    color: var(--fg);
    text-align: left;
    text-decoration: none;
    background: none;
    border: 0;
    border-top: 1px solid var(--line);
    cursor: pointer;
}

.drawer a:hover,
.drawer button:hover { background: var(--bg); }

.container {
    max-width: 32rem;
    margin: 0 auto;
    padding: 1rem;
}

h1 { font-size: 1.5rem; margin: 0.5rem 0 1rem; }

.stack { display: grid; gap: 0.75rem; }
.stack label { display: grid; gap: 0.25rem; font-weight: 600; }
.stack .check { display: flex; align-items: center; gap: 0.5rem; font-weight: 400; }

input[type="text"],
input[type="email"],
input[type="password"] {
    width: 100%;
    padding: 0.65rem 0.75rem;
    font: inherit;
    color: inherit;
    background: var(--card);
    border: 1px solid var(--line);
    border-radius: 0.5rem;
}

input[type="checkbox"] { width: 1.1rem; height: 1.1rem; }

.button {
    display: inline-block;
    padding: 0.65rem 1.1rem;
    font: inherit;
    font-weight: 600;
    color: #fff;
    background: var(--accent);
    border: 0;
    border-radius: 0.5rem;
    text-decoration: none;
    cursor: pointer;
}

.button.success { background: var(--success); }
.button.secondary { color: var(--fg); background: transparent; border: 1px solid var(--line); }
.button.small { padding: 0.35rem 0.7rem; font-size: 0.9rem; }

button.link {
    padding: 0;
    font: inherit;
    color: var(--accent);
    background: none;
    border: 0;
    text-decoration: underline;
    cursor: pointer;
}

.add { display: flex; gap: 0.5rem; margin-bottom: 1rem; }
.add input[type="text"] { padding: 0.85rem 0.9rem; font-size: 1.15rem; }
.add .button { padding: 0.85rem 1.75rem; font-size: 1.2rem; }

.items { list-style: none; margin: 0; padding: 0; background: var(--card); border: 1px solid var(--line); border-radius: 0.5rem; }
.items li { display: flex; align-items: center; gap: 0.75rem; padding: 0.6rem 0.9rem; border-bottom: 1px solid var(--line); }
.items li:last-child { border-bottom: 0; }
.items .name { flex: 1; overflow-wrap: anywhere; }
.items .empty { color: var(--muted); }
.items form { margin: 0; }

.error { margin: 0; color: var(--danger); font-size: 0.9rem; }
.toast {
    position: fixed;
    bottom: 1.5rem;
    left: 50%;
    z-index: 40;
    max-width: calc(100vw - 2rem);
    padding: 0.7rem 1.2rem;
    color: #fff;
    background: #323232;
    border-radius: 0.5rem;
    box-shadow: 0 3px 10px rgba(0, 0, 0, 0.4);
    pointer-events: none;
    transform: translateX(-50%);
    animation: toast-life 3s ease forwards;
}

@keyframes toast-life {
    0% { opacity: 0; transform: translate(-50%, 1rem); }
    10%, 80% { opacity: 1; transform: translate(-50%, 0); }
    100% { opacity: 0; transform: translate(-50%, 0); visibility: hidden; }
}
