:root {
    color-scheme: light;
    --canvas: #3f3f3f;
    --toolbar: #ffffff;
    --ink: #20242a;
    --muted: #71747b;
    --line: #dfe4eb;
    --primary: #4b3d96;
    --sky: #d8f5f7;
    --page: #f4f6ff;
    --sidebar-background: #fff;
    --sidebar-foreground: var(--ink);
    --sidebar-muted: var(--muted);
    --sidebar-border: var(--line);
    --sidebar-accent: #f4f4f5;
    --sidebar-primary: var(--primary);
    --sidebar-primary-foreground: #fff;
}

* { box-sizing: border-box; }
body {
    margin: 0;
    background: var(--canvas);
    color: var(--ink);
    font: 14px/1.4 -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}
button, input { font: inherit; }

.preview-toolbar {
    position: sticky;
    top: 0;
    z-index: 10;
    display: flex;
    align-items: end;
    justify-content: space-between;
    gap: 24px;
    padding: 16px 24px;
    background: var(--toolbar);
    border-bottom: 1px solid var(--line);
}
.preview-toolbar h1 { margin: 2px 0 0; font-size: 22px; }
.preview-toolbar p { margin: 3px 0 0; color: var(--muted); }
.back-link { color: var(--muted); text-decoration: none; font-size: 12px; }
.title-row { display: flex; align-items: center; gap: 9px; }
.toolbar-actions { display: flex; align-items: end; gap: 8px; flex-wrap: wrap; }
.toolbar-actions label { color: var(--muted); font-size: 11px; }
.toolbar-actions input {
    display: block;
    width: 74px;
    margin-top: 3px;
    padding: 7px;
    border: 1px solid var(--line);
    border-radius: 7px;
}
.button {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-height: 36px;
    padding: 7px 13px;
    border: 1px solid var(--primary);
    border-radius: 8px;
    background: var(--primary);
    color: #fff;
    cursor: pointer;
    font-weight: 650;
    text-decoration: none;
}
.button.secondary { border-color: var(--line); background: #fff; color: var(--ink); }

.storefront-edit-link {
    position: fixed;
    top: 18px;
    right: 24px;
    z-index: 10;
    display: grid;
    width: 38px;
    height: 38px;
    align-items: center;
    place-items: center;
    border: 1px solid rgba(95, 107, 130, .16);
    border-radius: 50%;
    background: rgba(255, 255, 255, .92);
    backdrop-filter: blur(14px);
    box-shadow: 0 4px 14px rgba(56, 66, 88, .12);
    color: var(--primary);
}
.storefront-edit-link:hover { background: #fff; box-shadow: 0 5px 18px rgba(56, 66, 88, .18); }
.storefront-edit-link svg {
    width: 18px;
    height: 18px;
    fill: none;
    stroke: currentColor;
    stroke-linecap: round;
    stroke-linejoin: round;
    stroke-width: 1.8;
}
.sr-only {
    position: absolute;
    width: 1px;
    height: 1px;
    overflow: hidden;
    clip: rect(0, 0, 0, 0);
    white-space: nowrap;
    clip-path: inset(50%);
}
.storefront-search {
    display: flex;
    align-items: center;
    width: auto;
    min-height: 34px;
    overflow: hidden;
    border: 1px solid rgba(86, 100, 125, .12);
    border-radius: 999px;
    background: rgba(255, 255, 255, .78);
    box-shadow: 0 3px 10px rgba(66, 78, 102, .08);
    transition: width 160ms ease, background 160ms ease, box-shadow 160ms ease;
}
.storefront-search:focus-within {
    border-color: rgba(75, 61, 150, .55);
    box-shadow: 0 0 0 3px rgba(75, 61, 150, .1);
}
.storefront-search.expanded {
    width: min(300px, 72vw);
    background: #fff;
}
.category-strip.has-active-filter .storefront-search:not(.active-filter) {
    opacity: .4;
    filter: saturate(.35);
}
.storefront-search.active-filter { border-color: rgba(75, 61, 150, .5); }
.storefront-search-toggle {
    display: flex;
    align-items: center;
    gap: 7px;
    min-height: 32px;
    padding: 7px 13px;
    border: 0;
    background: transparent;
    color: var(--ink);
    cursor: pointer;
    font-size: 12px;
}
.storefront-search-toggle svg {
    flex: 0 0 auto;
    width: 17px;
    height: 17px;
    fill: none;
    stroke: var(--muted);
    stroke-linecap: round;
    stroke-width: 1.8;
}
.storefront-search.expanded .storefront-search-toggle {
    padding-right: 5px;
}
.storefront-search.expanded .storefront-search-toggle span { display: none; }
.storefront-search input {
    display: none;
    min-width: 0;
    flex: 1;
    padding: 7px 6px;
    border: 0;
    outline: 0;
    background: transparent;
    color: var(--ink);
}
.storefront-search.expanded input { display: block; }
.storefront-search-submit {
    display: none;
    align-self: stretch;
    padding: 0 12px;
    border: 0;
    border-left: 1px solid var(--line);
    background: transparent;
    color: var(--primary);
    cursor: pointer;
    font-weight: 650;
}
.storefront-search.expanded .storefront-search-submit { display: block; }
.group-filter { display: flex; align-items: center; gap: 7px; color: var(--muted); font-size: 12px; }
.group-filter select {
    min-height: 36px;
    padding: 7px 28px 7px 10px;
    border: 1px solid var(--line);
    border-radius: 8px;
    background: #fff;
    color: var(--ink);
}

.storefront-app { min-width: 0; }

.preview-stage { display: grid; place-items: start center; min-height: calc(100vh - 92px); padding: 32px; }
.storefront-page {
    width: min(100%, 1240px);
    min-height: 760px;
    overflow: hidden;
    border: 1px solid rgba(255, 255, 255, .35);
    border-radius: 22px;
    background: var(--page);
    box-shadow: 0 22px 60px rgba(0, 0, 0, .3);
}
.storefront-home { background: var(--page); }
.storefront-home .preview-stage { min-height: 100vh; padding: 0; }
.storefront-home .storefront-page {
    width: min(100%, 56rem);
    min-height: 100vh;
    border: 0;
    border-radius: 0;
    box-shadow: none;
}
.storefront-header {
    padding: 30px 34px 26px;
    background: linear-gradient(150deg, var(--sky), #e7efff 70%, var(--page));
}
.brand-row { display: flex; align-items: baseline; gap: 12px; padding-bottom: 22px; }
.brand { font: 700 28px Georgia, serif; letter-spacing: -.04em; }
.storefront-label { color: var(--muted); font-size: 13px; }
.category-strip {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
}
.genre-chip.collapsed-genre { display: none; }
.genre-toggle {
    flex: 0 0 100%;
    margin: 2px 0 0;
    padding: 3px 2px;
    border: 0;
    background: transparent;
    color: var(--primary);
    cursor: pointer;
    font-size: 11px;
    font-weight: 650;
    text-align: left;
}
.category-strip[hidden] { display: none; }
.category-chip {
    font: inherit;
    padding: 8px 13px;
    border: 1px solid rgba(86, 100, 125, .12);
    border-radius: 999px;
    background: rgba(255, 255, 255, .78);
    box-shadow: 0 3px 10px rgba(66, 78, 102, .08);
    color: var(--ink);
    cursor: pointer;
    font-size: 12px;
    text-decoration: none;
}
.category-chip.selected { background: var(--primary); color: #fff; }
.category-chip.selected::after {
    margin-left: 7px;
    content: "×";
    font-size: 15px;
    line-height: 0;
}
.category-chip:disabled:not(.selected) {
    opacity: .4;
    filter: saturate(.35);
    cursor: default;
}
.category-strip.has-active-genre-filter .storefront-search,
.category-strip.has-active-genre-filter .category-chip:not(.selected),
.category-strip.has-active-genre-filter .genre-toggle { display: none; }

.storefront-status { padding: 34px 24px; color: var(--muted); text-align: center; }
.storefront-status.error { color: #a12020; }
.storefront-status:empty { display: none; }
.storefront-content { padding: 28px 0 48px; }
.section { margin: 0 0 38px; }
.section-heading { display: flex; align-items: center; justify-content: space-between; padding: 0 34px 14px; }
.section-heading h2 { margin: 0; font-size: 18px; font-weight: 650; }
.section-arrow {
    display: grid;
    place-items: center;
    width: 34px;
    height: 34px;
    border: 1px solid rgba(80, 90, 110, .08);
    border-radius: 50%;
    background: rgba(255, 255, 255, .78);
    box-shadow: 0 3px 11px rgba(56, 66, 88, .12);
    color: var(--ink);
    text-decoration: none;
}
.card-strip {
    display: flex;
    gap: 16px;
    overflow-x: auto;
    overflow-y: hidden;
    padding: 0 34px 4px;
    scroll-padding: 34px;
    scroll-snap-type: x proximity;
    scrollbar-color: rgba(86, 100, 125, .3) transparent;
    scrollbar-width: thin;
}
.card-strip.books .book-card {
    flex: 0 0 clamp(160px, 11vw, 220px);
    scroll-snap-align: start;
}
.card-strip.collections .collection-card {
    flex: 0 0 clamp(280px, 24vw, 420px);
    scroll-snap-align: start;
}
.book-card { min-width: 0; color: var(--ink); text-decoration: none; }
.book-cover, .book-cover-placeholder {
    display: block;
    width: 100%;
    height: auto;
    aspect-ratio: 80 / 118;
    border-radius: 7px;
    background: linear-gradient(145deg, #7468aa, #c7badf);
    box-shadow: 0 4px 9px rgba(25, 31, 45, .2);
    object-fit: cover;
}
.book-cover-placeholder { display: grid; place-items: center; padding: 8px; color: #fff; text-align: center; font: 11px Georgia, serif; }
.book-title { margin: 9px 0 3px; overflow: hidden; font-size: 13px; font-weight: 600; line-height: 1.25; text-overflow: ellipsis; white-space: nowrap; }
.book-author { margin: 0; overflow: hidden; color: var(--muted); font-size: 12px; text-overflow: ellipsis; white-space: nowrap; }
.collection-card {
    position: relative;
    min-width: 0;
    height: 150px;
    overflow: hidden;
    padding: 22px;
    border-radius: 18px;
    background: hsl(var(--collection-hue) 32% 84%);
    color: #25272b;
    text-decoration: none;
}
.collection-card::after {
    position: absolute;
    inset: 0 0 0 48%;
    background: linear-gradient(120deg, transparent, rgba(255, 255, 255, .46));
    content: "";
}
.collection-card.has-cover { background-position: center; background-size: cover; color: #fff; }
.collection-card.has-cover::before { position: absolute; inset: 0; background: linear-gradient(90deg, rgba(0, 0, 0, .62), transparent); content: ""; }
.collection-card strong, .collection-card p { position: relative; z-index: 1; display: block; max-width: 62%; }
.collection-card strong { font-size: 16px; }
.collection-card p { margin: 7px 0 0; font-size: 12px; line-height: 1.35; }
.empty-shelf { padding: 0 34px; color: var(--muted); font-size: 13px; }
.shelf-preview-status {
    display: grid;
    min-height: 220px;
    margin: 0 34px;
    place-items: center;
    border-radius: 12px;
    background: rgba(255, 255, 255, .34);
    color: var(--muted);
    font-size: 13px;
}
.shelf-preview-status.collections { min-height: 150px; }
.shelf-preview-status.error { color: #a12020; }

.list-view { padding: 2px 34px 24px; }
.list-heading { display: flex; align-items: center; gap: 12px; margin-bottom: 20px; }
.list-heading h2 { margin: 0; font-size: 18px; font-weight: 650; }
.list-back {
    display: grid;
    place-items: center;
    width: 36px;
    height: 36px;
    border: 1px solid rgba(80, 90, 110, .08);
    border-radius: 50%;
    background: #fff;
    box-shadow: 0 3px 11px rgba(56, 66, 88, .12);
    color: var(--ink);
    cursor: pointer;
    font-size: 25px;
}
.full-list-grid { display: grid; gap: 24px 16px; }
.full-list-grid.books { grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); }
.full-list-grid.books .book-card { min-width: 0; }
.full-list-grid.books .book-cover,
.full-list-grid.books .book-cover-placeholder { width: 100%; height: auto; aspect-ratio: 80 / 118; }
.full-list-grid.collections { grid-template-columns: repeat(auto-fit, minmax(280px, 1fr)); }
.full-list-grid.collections .collection-card { width: 100%; }
.list-controls { display: grid; place-items: center; padding: 20px 0 58px; }
.list-status { margin: 0; color: var(--muted); font-size: 13px; text-align: center; }
.list-status.error { color: #a12020; }
.list-sentinel { width: 100%; height: 2px; }
.list-sentinel[hidden] { display: none; }

@media (max-width: 700px) {
    .preview-toolbar { position: static; align-items: start; padding: 14px; }
    .preview-toolbar p, .preview-toolbar .back-link { display: none; }
    .preview-toolbar h1 { font-size: 17px; }
    .toolbar-actions label, .toolbar-actions .button.secondary { display: none; }
    .preview-stage { padding: 0; }
    .site-header { padding: 13px 18px; }
    .site-actions .secondary { display: none; }
    .storefront-page { width: 100%; min-height: calc(100vh - 64px); border: 0; border-radius: 0; box-shadow: none; }
    .storefront-header { padding: 22px 18px; }
    .section-heading { padding-right: 18px; padding-left: 18px; }
    .card-strip { padding-right: 18px; padding-left: 18px; scroll-padding: 18px; }
    .card-strip.books .book-card { flex-basis: min(38vw, 150px); }
    .card-strip.collections .collection-card { flex-basis: min(82vw, 320px); }
    .list-view { padding-right: 18px; padding-left: 18px; }
    .full-list-grid.books { grid-template-columns: repeat(3, minmax(0, 1fr)); }
    .full-list-grid.collections { grid-template-columns: minmax(0, 1fr); }
}
