@font-face {
    font-family: "Source Sans 3";
    src: url("../fonts/source-sans-3-regular.woff2") format("woff2");
    font-style: normal;
    font-weight: 400;
    font-display: swap;
}

@font-face {
    font-family: "Source Sans 3";
    src: url("../fonts/source-sans-3-semibold.woff2") format("woff2");
    font-style: normal;
    font-weight: 600;
    font-display: swap;
}

@font-face {
    font-family: "Source Serif 4";
    src: url("../fonts/source-serif-4-semibold.woff2") format("woff2");
    font-style: normal;
    font-weight: 600;
    font-display: swap;
}

:root,
[data-bs-theme="light"] {
    --sc-canvas: #f7f5f1;
    --sc-surface: #ffffff;
    --sc-surface-subtle: #f1eee8;
    --sc-surface-raised: #ffffff;
    --sc-ink: #272320;
    --sc-muted: #706963;
    --sc-border: #ddd7cf;
    --sc-border-strong: #c8bfb6;
    --sc-accent: var(--bs-primary, #7a2435);
    --sc-accent-soft: color-mix(in srgb, var(--sc-accent), white 90%);
    --sc-success: #356247;
    --sc-warning: #8a5a18;
    --sc-danger: #a63b3b;
    --sc-radius-sm: .5rem;
    --sc-radius: .75rem;
    --sc-radius-lg: 1rem;
    --sc-shadow: 0 1px 2px rgba(39, 35, 32, .04), 0 8px 24px rgba(39, 35, 32, .045);
    --sc-focus: 0 0 0 .2rem color-mix(in srgb, var(--sc-accent), transparent 78%);
    --bs-body-font-family: "Source Sans 3", system-ui, -apple-system, "Segoe UI", sans-serif;
    --bs-body-bg: var(--sc-canvas);
    --bs-body-color: var(--sc-ink);
    --bs-border-color: var(--sc-border);
    --bs-secondary-color: var(--sc-muted);
    --bs-link-color: var(--sc-accent);
    --bs-link-hover-color: color-mix(in srgb, var(--sc-accent), black 18%);
}

[data-bs-theme="dark"] {
    --sc-canvas: #181615;
    --sc-surface: #211f1d;
    --sc-surface-subtle: #2a2724;
    --sc-surface-raised: #262321;
    --sc-ink: #f0ebe5;
    --sc-muted: #b5ada5;
    --sc-border: #3c3733;
    --sc-border-strong: #514a44;
    --sc-accent-soft: color-mix(in srgb, var(--sc-accent), #211f1d 82%);
    --sc-shadow: 0 1px 2px rgba(0, 0, 0, .2), 0 12px 30px rgba(0, 0, 0, .16);
    --bs-body-bg: var(--sc-canvas);
    --bs-body-color: var(--sc-ink);
    --bs-border-color: var(--sc-border);
    --bs-secondary-color: var(--sc-muted);
}

/* Curated accent colors stay dark enough for white button text. */
:root[data-sc-primary="default"] { --bs-primary: #7a2435; }
:root[data-sc-primary="success"] { --bs-primary: #356247; }
:root[data-sc-primary="info"] { --bs-primary: #315f78; }
:root[data-sc-primary="warning"] { --bs-primary: #79501c; }
:root[data-sc-primary="danger"] { --bs-primary: #923b3b; }
:root[data-sc-primary="secondary"] { --bs-primary: #5f5954; }

html { scroll-behavior: smooth; }

body {
    background: var(--sc-canvas);
    color: var(--sc-ink);
    font-family: var(--bs-body-font-family);
    font-size: 1rem;
    line-height: 1.5;
}

button,
input,
select,
textarea { font: inherit; }

a { text-underline-offset: .16em; }

:focus-visible {
    outline: 2px solid var(--sc-accent);
    outline-offset: 2px;
}

.sc-app-content {
    width: min(100%, 94rem);
    margin-inline: auto;
    padding-inline: clamp(.9rem, 2.2vw, 2rem);
}

#body > .content { padding: 0 0 2.5rem; }

.page-title {
    padding: clamp(1.5rem, 3vw, 2.5rem) 0 1.25rem;
    margin: 0;
}

.page-title h1,
.page-title h2,
.page-title h3,
.sc-editorial-title {
    margin: 0;
    color: var(--sc-ink);
    font-family: "Source Serif 4", Georgia, serif;
    font-weight: 650;
    letter-spacing: -.025em;
    line-height: 1.12;
}

.page-title h3 { font-size: clamp(1.75rem, 3.5vw, 2.45rem); }
.page-pretitle { color: var(--sc-muted); letter-spacing: .08em; }
.text-muted { color: var(--sc-muted) !important; }

.card {
    background: var(--sc-surface);
    border: 1px solid var(--sc-border);
    border-radius: var(--sc-radius-lg);
    box-shadow: none;
    overflow: clip;
}

.card:hover { border-color: var(--sc-border-strong); }

.card-header,
.card-footer {
    background: transparent;
    border-color: var(--sc-border);
    padding: 1rem 1.25rem;
}

.card-body { padding: 1.25rem; }
.card-title { color: var(--sc-ink); font-weight: 650; }

.btn {
    min-height: 2.75rem;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: .45rem;
    border-radius: var(--sc-radius-sm);
    font-weight: 600;
    padding: .55rem .9rem;
    transition: background-color .15s ease, border-color .15s ease, color .15s ease, transform .15s ease;
}

.btn-sm { min-height: 2.75rem; padding: .35rem .7rem; }
.btn:active { transform: translateY(1px); }
.btn-primary { background: var(--sc-accent); border-color: var(--sc-accent); }
.btn-outline-primary { color: var(--sc-accent); border-color: color-mix(in srgb, var(--sc-accent), transparent 35%); }
.btn-outline-secondary { color: var(--sc-ink); border-color: var(--sc-border-strong); }
.btn-outline-secondary:hover { background: var(--sc-surface-subtle); color: var(--sc-ink); border-color: var(--sc-border-strong); }

.form-label { color: var(--sc-ink); font-weight: 600; margin-bottom: .4rem; }
.form-text { color: var(--sc-muted); }
.form-control,
.form-select {
    min-height: 2.75rem;
    color: var(--sc-ink);
    background-color: var(--sc-surface);
    border-color: var(--sc-border-strong);
    border-radius: var(--sc-radius-sm);
}

.form-control:focus,
.form-select:focus {
    border-color: var(--sc-accent);
    box-shadow: var(--sc-focus);
}

.form-check-input:checked { background-color: var(--sc-accent); border-color: var(--sc-accent); }

.table { --bs-table-bg: transparent; --bs-table-hover-bg: var(--sc-surface-subtle); color: var(--sc-ink); }
.table > :not(caption) > * > * { border-bottom-color: var(--sc-border); padding: .75rem .7rem; }
.table thead th {
    color: var(--sc-muted);
    font-size: .78rem;
    font-weight: 650;
    letter-spacing: .055em;
    text-transform: uppercase;
    white-space: nowrap;
}

.badge { border-radius: 999px; font-weight: 600; padding: .38em .65em; }
.alert { border-radius: var(--sc-radius); border-width: 1px; box-shadow: none; }
.alert-info { color: var(--sc-ink); background: var(--sc-surface-subtle); border-color: var(--sc-border); }
.alert-warning { color: var(--sc-ink); background: color-mix(in srgb, #d9972b, var(--sc-surface) 88%); border-color: color-mix(in srgb, #d9972b, var(--sc-border) 55%); }

.accordion-item {
    background: var(--sc-surface);
    border-color: var(--sc-border);
    border-radius: var(--sc-radius) !important;
    overflow: hidden;
}
.accordion-button { min-height: 3.25rem; background: var(--sc-surface); color: var(--sc-ink); font-weight: 650; }
.accordion-button:not(.collapsed) { color: var(--sc-ink); background: var(--sc-surface-subtle); box-shadow: inset 0 -1px 0 var(--sc-border); }
.accordion-button:focus { box-shadow: var(--sc-focus); }

.dropdown-menu {
    padding: .4rem;
    background: var(--sc-surface-raised);
    border-color: var(--sc-border);
    border-radius: var(--sc-radius);
    box-shadow: var(--sc-shadow);
}
.dropdown-item { border-radius: .4rem; padding: .55rem .7rem; }

.pagination { --bs-pagination-bg: var(--sc-surface); --bs-pagination-border-color: var(--sc-border); }
.page-link { min-width: 2.25rem; min-height: 2.25rem; display: grid; place-items: center; }

.sc-topnav {
    min-height: 4rem !important;
    background: var(--sc-surface) !important;
    color: var(--sc-ink) !important;
    border-bottom: 1px solid var(--sc-border) !important;
    position: sticky;
    top: 0;
    z-index: 1025;
}

.sc-topnav .navbar-brand {
    color: var(--sc-ink) !important;
    font-family: "Source Serif 4", Georgia, serif;
    font-size: 1.3rem;
    letter-spacing: -.02em;
}

.sc-topnav .sc-profile-toggle-btn,
.sc-topnav .sc-navbar-item-text { color: var(--sc-ink) !important; }
.sc-topnav .btn-outline-light { color: var(--sc-ink); border-color: var(--sc-border-strong); }
.sc-topnav .btn-outline-light:hover { background: var(--sc-surface-subtle); border-color: var(--sc-border-strong); }
.sc-topnav .sc-navbar-search .form-control { background: var(--sc-surface-subtle) !important; border-color: transparent; }
.sc-topnav .sc-navbar-search .btn { background: var(--sc-surface-subtle); color: var(--sc-muted); border-color: transparent; }
.sc-navbar-row { gap: .65rem !important; }
.sc-desktop-nav { flex: 0 0 auto; }
.sc-nav-link { color: var(--sc-muted); border: 0; }
.sc-nav-link:hover { color: var(--sc-ink); background: var(--sc-surface-subtle); }
.sc-nav-add { color: var(--sc-accent); border: 1px solid var(--sc-border); box-shadow: none; }

.sc-mobile-topbar {
    background: var(--sc-surface) !important;
    color: var(--sc-ink) !important;
    border-color: var(--sc-border) !important;
}
.sc-mobile-topbar-app,
.sc-mobile-topbar-cellar { color: var(--sc-ink) !important; }
.sc-mobile-topbar-app { font-family: "Source Serif 4", Georgia, serif; font-size: 1.1rem; }
.sc-mobile-nav { height: 4.75rem; background: var(--sc-surface) !important; border-color: var(--sc-border) !important; }
.sc-mobile-nav-link {
    height: 4.25rem;
    margin: .2rem;
    flex-direction: column;
    gap: .2rem;
    border-radius: .6rem;
    color: var(--sc-muted);
    font-size: .68rem;
    font-weight: 600;
}
.sc-mobile-nav-link i { font-size: 1rem; }
.sc-mobile-nav-link.active { color: var(--sc-accent); background: var(--sc-accent-soft); }
.sc-mobile-nav-add { transform: translateY(-.65rem); }
.sc-mobile-add-icon {
    width: 2.65rem;
    height: 2.65rem;
    display: grid;
    place-items: center;
    color: #fff;
    background: var(--sc-accent);
    border-radius: 50%;
    box-shadow: 0 5px 14px color-mix(in srgb, var(--sc-accent), transparent 68%);
}
.sc-mobile-nav-add.active { background: transparent; }

.sc-empty-state { padding: clamp(2.5rem, 8vw, 5rem) 1.5rem; text-align: center; color: var(--sc-muted); }
.sc-empty-state-icon { width: 3.5rem; height: 3.5rem; display: grid; place-items: center; margin: 0 auto 1rem; border-radius: 50%; background: var(--sc-surface-subtle); color: var(--sc-accent); font-size: 1.25rem; }
.sc-section-heading { display: flex; justify-content: space-between; align-items: center; gap: 1rem; margin-bottom: 1rem; }
.sc-section-heading h2, .sc-section-heading h3 { margin: 0; font-size: 1.05rem; font-weight: 650; }
.sc-data-toolbar { padding: .9rem; background: var(--sc-surface-subtle); border: 1px solid var(--sc-border); border-radius: var(--sc-radius); }
.sc-metric { padding: 1rem; border-left: 1px solid var(--sc-border); }
.sc-metric:first-child { border-left: 0; }
.sc-metric-value { color: var(--sc-ink); font-size: 1.4rem; font-weight: 650; line-height: 1.1; }
.sc-metric-label { color: var(--sc-muted); font-size: .82rem; margin-top: .25rem; }
.sc-action-bar { display: flex; flex-wrap: wrap; gap: .65rem; align-items: center; }

details { border: 1px solid var(--sc-border); border-radius: var(--sc-radius); padding: .8rem 1rem; background: var(--sc-surface-subtle); }
details > summary { cursor: pointer; color: var(--sc-ink); }

@media (max-width: 991.98px) {
    :root { --sc-mobile-bottombar-height: 76px; }
    #body > .content { padding-top: calc(var(--sc-mobile-topbar-height) + .25rem); padding-bottom: calc(var(--sc-mobile-bottombar-height) + 1rem); }
    .sc-app-content { padding-inline: .85rem; }
    .page-title { padding-top: 1.35rem; }
    .page-title h3 { font-size: 1.85rem; }
    .card-body { padding: 1rem; }
    .sc-action-bar.sc-sticky-mobile {
        position: sticky;
        bottom: calc(var(--sc-mobile-bottombar-height) + .5rem);
        z-index: 10;
        margin: 1rem -.35rem -.35rem;
        padding: .7rem;
        background: var(--sc-surface);
        border: 1px solid var(--sc-border);
        border-radius: var(--sc-radius);
        box-shadow: var(--sc-shadow);
    }
    .sc-action-bar.sc-sticky-mobile .btn-primary { flex: 1 1 auto; }
}

@media (min-width: 992px) {
    .sc-topnav .sc-navbar-cellar { flex-basis: 13%; max-width: 13%; }
    .sc-topnav .sc-navbar-search { flex: 1 1 22rem; max-width: none; }
    .sc-topnav .sc-navbar-user { flex-basis: auto; max-width: 12rem; }
}

@media (prefers-reduced-motion: reduce) {
    *, *::before, *::after { scroll-behavior: auto !important; transition-duration: .01ms !important; animation-duration: .01ms !important; animation-iteration-count: 1 !important; }
}

/* Page-level components */
.sc-cellar-card .card-body { display: flex; flex-direction: column; }
.sc-cellar-card .sc-action-bar { margin-top: auto; }
.sc-cellar-mark,
.sc-method-icon,
.sc-resource-icon,
.search-result-icon {
    flex: 0 0 auto;
    display: grid;
    place-items: center;
    color: var(--sc-accent);
    background: var(--sc-accent-soft);
    border-radius: var(--sc-radius-sm);
}
.sc-cellar-mark { width: 2.75rem; height: 2.75rem; }
.sc-metric-row {
    overflow: hidden;
    background: var(--sc-surface-subtle);
    border: 1px solid var(--sc-border);
    border-radius: var(--sc-radius);
}
.sc-cellar-hero .sc-metric-row { max-width: 50rem; }
.sc-secondary-section > .accordion { background: transparent; }
.sc-inventory-card > .card-header { min-height: 4rem; }
.sc-bottle-mobile-card { border-radius: var(--sc-radius); }
.cellar-wine-cell,
.cellar-wine-cell a,
.cellar-sweetness-cell { white-space: nowrap; }
.cellar-winery-truncate,
.cellar-comment-truncate {
    display: inline-block;
    overflow: hidden;
    text-overflow: ellipsis;
    vertical-align: bottom;
    white-space: nowrap;
}
.cellar-winery-truncate { max-width: clamp(7rem, 16vw, 12rem); }
.cellar-comment-truncate { max-width: clamp(6rem, 14vw, 10rem); }

.sc-resource-list { overflow: hidden; }
.sc-resource-row {
    min-height: 4.75rem;
    display: flex;
    align-items: center;
    gap: .75rem;
    padding: .8rem 1rem;
    background: transparent;
    border-color: var(--sc-border);
}
.sc-resource-row:hover { background: var(--sc-surface-subtle); }
.sc-resource-icon { width: 2.5rem; height: 2.5rem; }

.sc-search-panel { max-width: 64rem; }
.sc-search-input .form-control { min-height: 3rem; font-size: 1.05rem; }
.sc-search-result {
    display: block;
    color: var(--sc-ink);
    background: var(--sc-surface);
    border: 1px solid var(--sc-border);
    border-radius: var(--sc-radius);
    transition: border-color .15s ease, background-color .15s ease;
}
.sc-search-result:hover { color: var(--sc-ink); background: var(--sc-surface-subtle); border-color: var(--sc-border-strong); }
.sc-search-result .badge { color: var(--sc-muted) !important; background: var(--sc-surface-subtle) !important; border: 1px solid var(--sc-border); }
.search-result-icon { width: 2.25rem; height: 2.25rem; }

.sc-method-grid { max-width: 72rem; }
.sc-method-card .card-body { display: flex; flex-direction: column; align-items: flex-start; }
.sc-method-card .btn { margin-top: auto; }
.sc-method-icon { width: 2.75rem; height: 2.75rem; margin-bottom: 1rem; }
.sc-wizard-shell,
.sc-form-shell { max-width: 58rem; }
.sc-wizard-shell .form-control,
.sc-wizard-shell .form-select,
.sc-form-shell .form-control,
.sc-form-shell .form-select { width: 100%; }
.sc-stepper { max-width: 58rem; }
.sc-stepper-track { height: .4rem; background: var(--sc-surface-subtle); }
.sc-stepper .progress-bar { width: var(--sc-progress); background: var(--sc-accent); }
.sc-create-toggle {
    min-height: 2.75rem;
    display: flex;
    align-items: center;
    gap: .65rem;
    margin-top: .35rem;
    padding: .65rem .8rem;
    background: var(--sc-surface-subtle);
    border: 1px solid var(--sc-border);
    border-radius: var(--sc-radius-sm);
}
.sc-create-toggle .form-check-input { float: none; flex: 0 0 auto; margin: 0; }
.sc-review-card th { width: 13rem; color: var(--sc-muted); font-weight: 600; }
.sc-prewrap { white-space: pre-wrap; }

.sc-detail-card { max-width: 64rem; }
.sc-fact-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(12rem, 1fr)); gap: 1rem; }
.sc-fact { margin: 0; padding: 1rem; background: var(--sc-surface-subtle); border-radius: var(--sc-radius); }
.sc-auth-shell { padding-inline: .75rem; }
.sc-auth-brand { font-family: "Source Serif 4", Georgia, serif; font-size: 1.75rem; font-weight: 650; color: var(--sc-ink); }

.progress { background: var(--sc-surface-subtle); }
.progress-bar { background-color: var(--sc-accent); }
.modal-content { color: var(--sc-ink); background: var(--sc-surface); border-color: var(--sc-border); }
.list-group-item { color: var(--sc-ink); background: var(--sc-surface); border-color: var(--sc-border); }
.pwa-install-banner { color: var(--sc-ink); background: var(--sc-surface-raised); border: 1px solid var(--sc-border); box-shadow: var(--sc-shadow); }

@media (max-width: 575.98px) {
    .page-title { align-items: flex-start !important; flex-direction: column; }
    .page-title > div:last-child .btn { width: 100%; }
    .page-title > div:last-child { width: 100%; }
    .sc-resource-row { flex-wrap: wrap; }
    .sc-resource-row .flex-grow-1 { min-width: calc(100% - 3.5rem); }
    .sc-resource-row .btn { flex: 1 1 calc(50% - .4rem); }
    .sc-resource-row .sc-resource-open { flex: 0 0 2.75rem; }
    .sc-review-card th { width: auto; }
}
