:root {
    --bg: #09090b;
    --surface: #141419;
    --surface-2: #1b1b22;
    --border: rgba(255,255,255,.08);
    --text: #f7f7fb;
    --muted: #a7a7b2;
    --accent: #8b5cf6;
    --accent-2: #a78bfa;
    --danger: #fb7185;
    --radius: 22px;
    --shadow: 0 18px 45px rgba(0,0,0,.28);
    --safe-bottom: env(safe-area-inset-bottom, 0px);
}

* { box-sizing: border-box; }
html { color-scheme: dark; }
body {
    margin: 0;
    min-height: 100vh;
    background: var(--bg);
    color: var(--text);
    font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
    line-height: 1.45;
}
a { color: inherit; text-decoration: none; }
button, input, textarea, select { font: inherit; }
button { cursor: pointer; }
h1, h2, h3, p { margin-top: 0; }
.muted { color: var(--muted); }
.eyebrow { color: var(--accent-2); font-weight: 700; font-size: .82rem; text-transform: uppercase; letter-spacing: .12em; }

.auth-shell {
    min-height: 100vh;
    display: grid;
    place-items: center;
    padding: 24px;
}
.auth-card {
    width: min(100%, 430px);
    background: linear-gradient(180deg, var(--surface), #101014);
    border: 1px solid var(--border);
    border-radius: 30px;
    padding: 30px;
    box-shadow: var(--shadow);
}
.brand-mark, .mini-brand {
    display: grid;
    place-items: center;
    background: var(--accent);
    color: white;
    font-weight: 900;
}
.brand-mark {
    width: 58px; height: 58px; border-radius: 18px;
    font-size: 1.6rem; margin-bottom: 20px;
}
.mini-brand {
    width: 34px; height: 34px; border-radius: 11px;
}
.stack { display: grid; gap: 16px; margin-top: 24px; }
label { display: grid; gap: 8px; font-weight: 700; font-size: .92rem; }
input, textarea, select {
    width: 100%;
    border: 1px solid var(--border);
    background: var(--surface-2);
    color: var(--text);
    border-radius: 15px;
    padding: 14px 15px;
    outline: none;
}
input:focus, textarea:focus, select:focus { border-color: var(--accent); box-shadow: 0 0 0 3px rgba(139,92,246,.18); }
.btn {
    border: 0;
    border-radius: 15px;
    padding: 14px 18px;
    font-weight: 800;
}
.btn-primary { background: var(--accent); color: white; }
.auth-links { display: flex; justify-content: space-between; gap: 12px; margin-top: 22px; color: var(--accent-2); font-size: .92rem; }
.back-link { display: block; margin-top: 22px; text-align: center; color: var(--accent-2); }
.alert { border-radius: 14px; padding: 12px 14px; margin: 18px 0; }
.alert-error { background: rgba(251,113,133,.12); color: #fecdd3; border: 1px solid rgba(251,113,133,.28); }

.topbar {
    position: sticky; top: 0; z-index: 20;
    display: flex; align-items: center; justify-content: space-between;
    padding: 14px 18px;
    background: rgba(9,9,11,.86);
    backdrop-filter: blur(16px);
    border-bottom: 1px solid var(--border);
}
.topbar-brand { display: flex; align-items: center; gap: 10px; font-weight: 900; letter-spacing: .04em; }
.topbar-actions { display: flex; gap: 16px; font-size: 1.25rem; }

.app-main {
    width: min(100%, 1100px);
    margin: 0 auto;
    padding: 24px 18px calc(105px + var(--safe-bottom));
}
.welcome-block { margin: 10px 0 28px; }
.welcome-block h1, .page-heading h1 { font-size: clamp(1.8rem, 6vw, 3.1rem); line-height: 1.05; margin-bottom: 10px; }
.dashboard-grid { display: grid; gap: 16px; }
.card {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 20px;
}
.card-heading { display: flex; align-items: center; justify-content: space-between; gap: 16px; }
.card-heading h2 { margin: 0; font-size: 1.1rem; }
.card-heading a { color: var(--accent-2); font-weight: 700; font-size: .9rem; }
.empty-state { color: var(--muted); margin: 20px 0 0; }

.bottom-nav {
    position: fixed; left: 0; right: 0; bottom: 0; z-index: 30;
    display: grid; grid-template-columns: repeat(5, 1fr);
    align-items: end;
    min-height: calc(72px + var(--safe-bottom));
    padding: 8px 10px calc(8px + var(--safe-bottom));
    background: rgba(20,20,25,.94);
    backdrop-filter: blur(20px);
    border-top: 1px solid var(--border);
}
.bottom-nav a { display: grid; justify-items: center; gap: 3px; color: var(--muted); }
.bottom-nav a span { font-size: 1.2rem; }
.bottom-nav small { font-size: .68rem; }
.add-button {
    justify-self: center;
    width: 58px; height: 58px;
    margin-bottom: 13px;
    border: 0;
    border-radius: 19px;
    background: var(--accent);
    color: white;
    font-size: 2rem;
    box-shadow: 0 12px 28px rgba(139,92,246,.34);
}
.sheet-backdrop {
    position: fixed; inset: 0; z-index: 40;
    background: rgba(0,0,0,.58);
}
.add-sheet {
    position: fixed; left: 0; right: 0; bottom: 0; z-index: 41;
    transform: translateY(110%);
    transition: transform .25s ease;
    padding: 10px 18px calc(24px + var(--safe-bottom));
    background: var(--surface);
    border-radius: 28px 28px 0 0;
    border-top: 1px solid var(--border);
}
.add-sheet.is-open { transform: translateY(0); }
.sheet-handle { width: 44px; height: 5px; border-radius: 99px; background: #4b4b55; margin: 0 auto 16px; }
.sheet-heading { display: flex; justify-content: space-between; align-items: center; }
.sheet-heading button { border: 0; background: transparent; color: var(--muted); font-size: 1.8rem; }
.quick-add-grid { display: grid; grid-template-columns: repeat(4,1fr); gap: 12px; }
.quick-add-grid a {
    display: grid; justify-items: center; gap: 8px;
    padding: 16px 6px;
    background: var(--surface-2);
    border: 1px solid var(--border);
    border-radius: 18px;
}
.quick-add-grid span { font-size: .76rem; color: var(--muted); }

@media (min-width: 760px) {
    .dashboard-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
    .dashboard-grid .card:first-child { grid-column: 1 / -1; }
    .bottom-nav { left: 50%; right: auto; width: min(560px, calc(100% - 30px)); transform: translateX(-50%); bottom: 14px; border: 1px solid var(--border); border-radius: 24px; }
    .add-sheet { left: 50%; right: auto; width: 560px; transform: translate(-50%, 110%); border-radius: 28px; bottom: 18px; }
    .add-sheet.is-open { transform: translate(-50%, 0); }
}
