:root {
    color-scheme: light;
    --bg: #f6f3ee;
    --panel: #ffffff;
    --panel-2: #fdfbf7;
    --ink: #1d2522;
    --muted: #6d746f;
    --line: #d9d4ca;
    --brand: #0f766e;
    --brand-strong: #115e59;
    --accent: #d94625;
    --amber: #b7791f;
    --shadow: 0 14px 45px rgba(29, 37, 34, 0.11);
    --radius: 8px;
    --tap: 44px;
    font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

* {
    box-sizing: border-box;
}

body {
    margin: 0;
    min-height: 100vh;
    background: var(--bg);
    color: var(--ink);
}

button,
input {
    font: inherit;
}

button {
    min-height: var(--tap);
    border: 0;
    border-radius: var(--radius);
    cursor: pointer;
}

button:disabled {
    cursor: not-allowed;
    opacity: 0.45;
}

input {
    width: 100%;
    min-height: var(--tap);
    border: 1px solid var(--line);
    border-radius: var(--radius);
    padding: 0 12px;
    background: #fff;
    color: var(--ink);
}

label {
    display: grid;
    gap: 6px;
    color: var(--muted);
    font-size: 0.88rem;
    font-weight: 650;
}

.hidden {
    display: none !important;
}

.app-shell {
    min-height: 100vh;
}

.auth-view {
    min-height: 100vh;
    display: grid;
    grid-template-columns: minmax(220px, 0.7fr) minmax(320px, 520px);
    align-items: center;
    gap: 48px;
    width: min(1080px, calc(100% - 32px));
    margin: 0 auto;
}

.brand-mark {
    aspect-ratio: 1;
    width: min(360px, 100%);
    border-radius: 28px;
    background:
        linear-gradient(135deg, rgba(15, 118, 110, 0.95), rgba(217, 70, 37, 0.88)),
        repeating-linear-gradient(90deg, transparent 0 28px, rgba(255, 255, 255, 0.2) 28px 30px);
    display: grid;
    place-items: center;
    color: white;
    box-shadow: var(--shadow);
}

.brand-mark span {
    font-size: clamp(4rem, 11vw, 8rem);
    font-weight: 900;
}

.auth-panel {
    background: var(--panel);
    border: 1px solid var(--line);
    border-radius: 8px;
    padding: 32px;
    box-shadow: var(--shadow);
}

.auth-panel h1 {
    margin: 0 0 24px;
    font-size: clamp(2rem, 4vw, 3.25rem);
    line-height: 0.98;
    letter-spacing: 0;
}

.stack {
    display: grid;
    gap: 14px;
}

.eyebrow {
    margin: 0 0 8px;
    color: var(--brand-strong);
    font-size: 0.75rem;
    font-weight: 800;
    letter-spacing: 0;
    text-transform: uppercase;
}

.primary-button {
    background: var(--brand);
    color: #fff;
    padding: 0 18px;
    font-weight: 800;
}

.primary-button:hover,
.primary-button:focus-visible {
    background: var(--brand-strong);
}

.ghost-button,
.text-button,
.mode-button {
    background: transparent;
    color: var(--brand-strong);
    font-weight: 750;
}

.ghost-button {
    margin-top: 12px;
    width: 100%;
    border: 1px solid var(--line);
}

.message {
    min-height: 1.4em;
    margin: 12px 0 0;
    color: var(--accent);
    font-size: 0.92rem;
}

.main-view {
    min-height: 100vh;
    display: grid;
    grid-template-columns: 320px 1fr;
}

.sidebar {
    min-height: 100vh;
    padding: 22px;
    border-right: 1px solid var(--line);
    background: var(--panel-2);
}

.sidebar-header,
.workspace-header,
.bulk-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 16px;
}

.sidebar-header strong {
    display: block;
    max-width: 190px;
    overflow-wrap: anywhere;
}

.list-form {
    display: grid;
    grid-template-columns: 1fr 46px;
    gap: 8px;
    margin: 24px 0;
}

.list-form button {
    grid-column: 1 / -1;
    background: var(--ink);
    color: #fff;
    font-weight: 800;
}

.list-form input[type="color"] {
    padding: 4px;
}

.lists {
    display: grid;
    gap: 8px;
}

.list-card {
    width: 100%;
    display: grid;
    grid-template-columns: 10px 1fr auto;
    align-items: center;
    gap: 10px;
    min-height: 58px;
    padding: 10px;
    border: 1px solid var(--line);
    background: var(--panel);
    color: var(--ink);
    text-align: left;
}

.list-card.active {
    border-color: var(--brand);
    box-shadow: 0 0 0 2px rgba(15, 118, 110, 0.12);
}

.list-color {
    width: 10px;
    align-self: stretch;
    border-radius: 999px;
    background: var(--brand);
}

.list-name {
    display: grid;
    gap: 2px;
    min-width: 0;
}

.list-name strong {
    overflow-wrap: anywhere;
}

.list-name span,
.list-count {
    color: var(--muted);
    font-size: 0.82rem;
}

.workspace {
    width: min(960px, 100%);
    margin: 0 auto;
    padding: 28px;
}

.workspace-header {
    align-items: flex-start;
}

.workspace-header h2 {
    margin: 0;
    font-size: clamp(1.8rem, 4vw, 3rem);
    line-height: 1;
    overflow-wrap: anywhere;
    letter-spacing: 0;
}

.toolbar {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
}

.header-tools {
    display: grid;
    justify-items: end;
    gap: 8px;
}

.view-switch,
.toolbar {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
}

.view-button,
.mode-button {
    min-height: 38px;
    padding: 0 12px;
    border: 1px solid var(--line);
    color: var(--muted);
    background: transparent;
    font-weight: 750;
}

.view-button.active,
.mode-button.active {
    background: var(--brand);
    border-color: var(--brand);
    color: #fff;
}

.active-list-picker {
    display: none;
    margin-top: 10px;
}

.active-list-picker span {
    font-size: 0.75rem;
    text-transform: uppercase;
}

.active-list-picker select {
    width: min(360px, 100%);
    min-height: 42px;
    border: 1px solid var(--line);
    border-radius: var(--radius);
    padding: 0 10px;
    background: var(--panel);
    color: var(--ink);
    font: inherit;
    font-weight: 750;
}

.progress-row {
    display: grid;
    grid-template-columns: 1fr auto;
    align-items: center;
    gap: 12px;
    margin: 24px 0;
}

.progress-track {
    height: 10px;
    overflow: hidden;
    border-radius: 999px;
    background: #e8e1d7;
}

#progress-bar {
    display: block;
    width: 0%;
    height: 100%;
    border-radius: inherit;
    background: linear-gradient(90deg, var(--brand), var(--amber));
    transition: width 160ms ease;
}

#progress-label {
    color: var(--muted);
    font-weight: 800;
    min-width: 64px;
    text-align: right;
}

.item-form {
    display: grid;
    grid-template-columns: minmax(220px, 2fr) minmax(96px, 0.7fr) minmax(130px, 1fr);
    gap: 12px;
    padding: 16px;
    border: 1px solid var(--line);
    border-radius: 8px;
    background: var(--panel);
}

.item-note {
    grid-column: 1 / 3;
}

.item-form button {
    align-self: end;
}

.bulk-row {
    min-height: 56px;
}

.items {
    display: grid;
    gap: 20px;
}

.aisle-group {
    display: grid;
    gap: 8px;
}

.aisle-title {
    margin: 0;
    color: var(--amber);
    font-size: 0.78rem;
    font-weight: 900;
    letter-spacing: 0;
    text-transform: uppercase;
}

.item-card {
    display: grid;
    grid-template-columns: auto 1fr auto;
    align-items: start;
    gap: 12px;
    min-height: 58px;
    padding: 12px;
    border: 1px solid var(--line);
    border-radius: 8px;
    background: var(--panel);
}

.item-card.bought {
    opacity: 0.62;
}

.item-card.bought .item-label {
    text-decoration: line-through;
}

.check-button {
    width: 34px;
    min-width: 34px;
    min-height: 34px;
    border: 2px solid var(--brand);
    border-radius: 50%;
    background: #fff;
    color: var(--brand);
    font-weight: 900;
}

.item-card.bought .check-button {
    background: var(--brand);
    color: #fff;
}

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

.item-main {
    display: flex;
    flex-wrap: wrap;
    align-items: baseline;
    gap: 8px;
}

.item-label {
    font-weight: 850;
    overflow-wrap: anywhere;
}

.quantity {
    border-radius: 999px;
    padding: 3px 8px;
    background: #efe9df;
    color: var(--ink);
    font-size: 0.8rem;
    font-weight: 800;
}

.note {
    margin-top: 4px;
    color: var(--muted);
    font-size: 0.9rem;
    overflow-wrap: anywhere;
}

.item-actions {
    display: flex;
    gap: 4px;
}

.small-button {
    min-width: 36px;
    min-height: 36px;
    padding: 0 8px;
    background: transparent;
    color: var(--muted);
    border: 1px solid transparent;
    font-weight: 800;
}

.small-button:hover,
.small-button:focus-visible {
    border-color: var(--line);
    color: var(--accent);
}

.empty-state {
    display: grid;
    gap: 6px;
    margin-top: 24px;
    padding: 22px;
    border: 1px dashed var(--line);
    border-radius: 8px;
    background: rgba(255, 255, 255, 0.55);
    color: var(--muted);
}

.empty-state strong {
    color: var(--ink);
}

.app-shell[data-mode="shop"] .main-view {
    grid-template-columns: 1fr;
}

.app-shell[data-mode="shop"] .sidebar,
.app-shell[data-mode="shop"] .item-form {
    display: none;
}

.app-shell[data-mode="shop"] .active-list-picker {
    display: grid;
}

.app-shell[data-mode="shop"] .workspace {
    width: min(760px, 100%);
    padding: 14px;
}

.app-shell[data-mode="shop"] .workspace-header {
    position: sticky;
    top: 0;
    z-index: 2;
    margin: -14px -14px 0;
    padding: 14px;
    background: color-mix(in srgb, var(--bg) 92%, transparent);
    backdrop-filter: blur(16px);
    border-bottom: 1px solid var(--line);
}

.app-shell[data-mode="shop"] .workspace-header h2 {
    font-size: clamp(1.45rem, 5vw, 2.2rem);
}

.app-shell[data-mode="shop"] .progress-row {
    margin: 16px 0;
}

.app-shell[data-mode="shop"] .bulk-row {
    min-height: 46px;
    justify-content: flex-end;
}

.app-shell[data-mode="shop"] .bulk-row .message {
    display: none;
}

.app-shell[data-mode="shop"] .item-card {
    grid-template-columns: auto 1fr auto;
    min-height: 72px;
    padding: 14px;
}

.app-shell[data-mode="shop"] .check-button {
    width: 48px;
    min-width: 48px;
    min-height: 48px;
    font-size: 0.72rem;
}

.app-shell[data-mode="shop"] .item-actions {
    display: none;
}

.app-shell[data-mode="shop"] .aisle-group {
    gap: 10px;
}

.app-shell[data-mode="shop"] .aisle-title {
    position: sticky;
    top: 94px;
    z-index: 1;
    padding: 8px 0 4px;
    background: var(--bg);
}

@media (prefers-color-scheme: dark) {
    :root {
        color-scheme: dark;
        --bg: #151816;
        --panel: #1f2522;
        --panel-2: #191e1c;
        --ink: #eef3ef;
        --muted: #a9b2ad;
        --line: #36413c;
        --brand: #14b8a6;
        --brand-strong: #5eead4;
        --accent: #fb7b58;
        --amber: #f2b84b;
        --shadow: 0 14px 45px rgba(0, 0, 0, 0.28);
    }

    input,
    .check-button {
        background: #151816;
    }

    .quantity {
        background: #303831;
    }

    .progress-track {
        background: #303831;
    }
}

@media (max-width: 820px) {
    .auth-view {
        grid-template-columns: 1fr;
        gap: 24px;
        padding: 24px 0;
    }

    .brand-mark {
        width: min(180px, 60vw);
        justify-self: center;
        border-radius: 18px;
    }

    .auth-panel {
        padding: 22px;
    }

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

    .sidebar {
        min-height: auto;
        border-right: 0;
        border-bottom: 1px solid var(--line);
    }

    .workspace {
        padding: 20px;
    }

    .workspace-header {
        display: grid;
    }

    .header-tools {
        justify-items: stretch;
    }

    .view-switch,
    .toolbar {
        width: 100%;
    }

    .view-button,
    .mode-button {
        flex: 1;
    }

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

    .item-note {
        grid-column: auto;
    }

    .bulk-row {
        display: grid;
        align-items: start;
    }

    .app-shell[data-mode="shop"] .workspace {
        padding: 12px;
    }

    .app-shell[data-mode="shop"] .workspace-header {
        margin: -12px -12px 0;
        padding: 12px;
    }

    .app-shell[data-mode="shop"] .aisle-title {
        top: 130px;
    }
}
