:root {
  --ink: #171311;
  --ink-soft: #342b27;
  --bone: #f2eee5;
  --paper: #fbf8f1;
  --wine: #852b32;
  --wine-dark: #5d171e;
  --gold: #a47a3a;
  --line: #d8cec0;
  --muted: #756b63;
  --success: #315c49;
  --shadow: 0 18px 50px rgba(31, 20, 16, .12);
}

* { box-sizing: border-box; }
html { background: var(--bone); color: var(--ink); font-family: Inter, "Segoe UI", Arial, sans-serif; }
body { margin: 0; min-width: 320px; }
button, input { font: inherit; }
button { cursor: pointer; }
button:focus-visible, input:focus-visible { outline: 3px solid var(--gold); outline-offset: 3px; }
.sr-only { position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip: rect(0,0,0,0); white-space: nowrap; border: 0; }

.app-shell { min-height: 100vh; display: grid; grid-template-columns: 220px minmax(0, 1fr) 330px; }
.rail { position: sticky; top: 0; height: 100vh; padding: 30px 20px; background: var(--ink); color: var(--paper); display: flex; flex-direction: column; z-index: 4; }
.brand { border: 0; background: none; color: inherit; display: flex; align-items: center; gap: 12px; text-align: left; padding: 0 4px 32px; }
.brand-mark { display: grid; place-items: center; width: 44px; height: 44px; border: 1px solid var(--gold); color: var(--gold); font: 700 24px Georgia, serif; transform: rotate(45deg); }
.brand-mark::first-letter { transform: rotate(-45deg); }
.brand-copy { font-size: 11px; letter-spacing: .16em; line-height: 1.45; }
.rail nav { display: grid; gap: 7px; }
.nav-button { width: 100%; border: 0; border-radius: 10px; background: transparent; color: #c8beb4; padding: 13px 14px; text-align: left; display: flex; align-items: center; gap: 12px; }
.nav-button:hover, .nav-button.active { background: #2b2421; color: #fff; }
.nav-icon { width: 22px; text-align: center; color: var(--gold); }
.account-button { margin-top: auto; border: 1px solid #443a35; background: #211b18; color: #fff; border-radius: 12px; padding: 10px; display: flex; align-items: center; gap: 10px; }
.account-button span { display: grid; place-items: center; width: 34px; height: 34px; background: var(--wine); border-radius: 50%; font-weight: 700; }
.account-button small { color: #c8beb4; }

main { min-width: 0; padding: 42px clamp(22px, 4vw, 64px) 90px; background: var(--paper); }
.context-panel { position: sticky; top: 0; height: 100vh; overflow: auto; border-left: 1px solid var(--line); padding: 34px 26px; background: #f7f2e8; }
.bottom-nav { display: none; }

.eyebrow { margin: 0 0 12px; color: var(--wine); font-size: 12px; font-weight: 800; letter-spacing: .18em; text-transform: uppercase; }
h1, h2, h3 { font-family: Georgia, "Times New Roman", serif; }
h1 { margin: 0; font-size: clamp(38px, 5vw, 72px); line-height: .98; letter-spacing: -.045em; }
h2 { font-size: clamp(28px, 3.2vw, 44px); margin: 0; }
h3 { margin: 0 0 8px; font-size: 21px; }
.lede { max-width: 650px; color: var(--muted); font-size: 17px; line-height: 1.7; }
.section-head { display: flex; align-items: end; justify-content: space-between; gap: 20px; margin: 0 0 24px; }
.section-head p { color: var(--muted); margin: 0; }

.hero { min-height: calc(100vh - 84px); display: grid; grid-template-columns: 1fr minmax(280px, .78fr); align-items: center; gap: clamp(28px, 5vw, 72px); }
.hero-copy { position: relative; z-index: 1; }
.hero-copy h1 span { color: var(--wine); font-style: italic; }
.hero-actions, .card-actions { display: flex; flex-wrap: wrap; gap: 10px; margin-top: 26px; }
.button { min-height: 46px; border: 1px solid var(--ink); border-radius: 7px; padding: 0 18px; background: var(--ink); color: #fff; font-weight: 700; }
.button.secondary { background: transparent; color: var(--ink); }
.button.wine { border-color: var(--wine); background: var(--wine); }
.button:disabled { cursor: not-allowed; opacity: .42; }
.hero-art { position: relative; height: min(72vh, 720px); display: grid; place-items: center; }
.hero-art::before { content: ""; position: absolute; inset: 8% 0; border: 1px solid var(--gold); border-radius: 50% 50% 44% 48%; transform: rotate(-5deg); }
.hero-art img { position: relative; width: 100%; height: 100%; object-fit: contain; mix-blend-mode: multiply; filter: contrast(1.05); }
.price-strip { display: grid; grid-template-columns: repeat(3, 1fr); gap: 12px; margin: -36px 0 72px; position: relative; z-index: 2; }
.price-card { border: 1px solid var(--line); background: rgba(255,255,255,.9); border-radius: 12px; padding: 18px; box-shadow: var(--shadow); }
.price-card strong { display: block; font: 700 22px Georgia, serif; }
.price-card span { color: var(--muted); font-size: 13px; }

.toolbar { display: flex; gap: 12px; margin: 26px 0; }
.search { flex: 1; min-height: 46px; border: 1px solid var(--line); border-radius: 8px; padding: 0 15px; background: white; }
.filter-pills { display: flex; flex-wrap: wrap; gap: 8px; margin-bottom: 24px; padding-bottom: 4px; }
.pill { white-space: nowrap; border: 1px solid var(--line); background: transparent; border-radius: 999px; padding: 9px 14px; color: var(--muted); }
.pill.active { color: white; border-color: var(--wine); background: var(--wine); }
.meaning-select { min-height: 38px; border: 1px solid var(--gold); border-radius: 999px; padding: 0 34px 0 13px; background: #fff; color: var(--ink); font-weight: 700; }
.favorite-button.active { border-color: var(--wine); background: #f5e4e5; color: var(--wine); }
.result-count { margin: -12px 0 18px; color: var(--muted); font-size: 13px; }
.pagination { display: flex; justify-content: center; flex-wrap: wrap; gap: 8px; margin: 30px 0 8px; }
.page-button { min-width: 42px; min-height: 42px; border: 1px solid var(--line); border-radius: 8px; background: white; color: var(--ink); font-weight: 700; }
.page-button.active { border-color: var(--wine); background: var(--wine); color: white; }
.page-button:disabled { opacity: .4; cursor: not-allowed; }
.no-results { padding: 64px 20px; border: 1px dashed var(--line); border-radius: 12px; text-align: center; }
.notice { margin: 18px 0; padding: 14px 16px; border-left: 4px solid var(--gold); background: #efe6d6; color: var(--ink-soft); line-height: 1.55; }

.beast-grid { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 18px; }
.beast-card { border: 1px solid var(--line); border-radius: 14px; background: #fff; overflow: hidden; transition: transform .18s ease, box-shadow .18s ease; }
.beast-card:hover { transform: translateY(-3px); box-shadow: var(--shadow); }
.beast-card.selected { border: 2px solid var(--wine); }
.beast-image { aspect-ratio: 4/5; background: var(--bone); overflow: hidden; }
.beast-image img { width: 100%; height: 100%; object-fit: contain; mix-blend-mode: multiply; }
.beast-body { padding: 15px; }
.beast-title { display: flex; justify-content: space-between; gap: 10px; }
.beast-title small { color: var(--muted); }
.symbols { margin: 8px 0 14px; color: var(--muted); font-size: 12px; }
.card-actions { margin-top: 0; }
.card-actions .button { flex: 1; min-height: 38px; padding: 0 9px; font-size: 13px; }
.status-chip { display: inline-block; border-radius: 999px; padding: 5px 9px; color: var(--success); background: #e4eee8; font-size: 11px; font-weight: 800; }

.pack-toggle { display: grid; grid-template-columns: repeat(3, 1fr); gap: 12px; margin: 28px 0; }
.mobile-pack-status { display: none; }
.pack-option { border: 1px solid var(--line); border-radius: 12px; padding: 18px; text-align: left; background: #fff; }
.pack-option.active { border: 2px solid var(--wine); box-shadow: 0 0 0 3px rgba(133,43,50,.08); }
.pack-option strong, .pack-option span { display: block; }
.pack-option strong { font: 700 21px Georgia, serif; }
.pack-option span { margin-top: 5px; color: var(--muted); }

.summary-card { border-top: 4px solid var(--wine); background: #fff; box-shadow: var(--shadow); border-radius: 10px; padding: 22px; }
.summary-count { font: 700 34px Georgia, serif; }
.progress { height: 7px; background: #e5ddd1; border-radius: 9px; overflow: hidden; margin: 10px 0 20px; }
.progress > span { display: block; height: 100%; background: var(--wine); }
.selection-list { list-style: none; padding: 0; margin: 18px 0; display: grid; gap: 10px; }
.selection-list li { display: flex; align-items: center; gap: 10px; font-size: 13px; }
.selection-list img { width: 42px; height: 42px; object-fit: cover; background: var(--bone); border-radius: 6px; }
.summary-card .button { width: 100%; }
.fine-print { color: var(--muted); font-size: 12px; line-height: 1.5; }

.detail { display: grid; grid-template-columns: minmax(260px, .9fr) 1fr; gap: 42px; align-items: start; }
.detail-art { background: var(--bone); min-height: 560px; display: grid; place-items: center; border-radius: 14px; }
.detail-art img { width: 100%; max-height: 700px; object-fit: contain; mix-blend-mode: multiply; }
.preview-switcher { width: 100%; display: grid; grid-template-columns: repeat(4,1fr); gap: 6px; padding: 10px; }
.preview-switcher button { min-height: 40px; border: 1px solid var(--line); border-radius: 7px; background: #fff; color: var(--ink); font-size: 12px; font-weight: 800; }
.preview-switcher button.active { border-color: var(--wine); background: var(--wine); color: #fff; }
.image-dialog { width: min(92vw,900px); max-height: 92vh; padding: 48px 12px 12px; border: 0; border-radius: 14px; background: var(--paper); }
.image-dialog::backdrop { background: rgba(10,8,7,.86); }
.image-dialog img { display: block; max-width: 100%; max-height: 80vh; margin: auto; object-fit: contain; }
.image-dialog button { position: absolute; top: 8px; right: 12px; width: 38px; height: 38px; border: 0; background: transparent; font-size: 30px; }
.network-status,.install-app { position: fixed; z-index: 50; right: 16px; bottom: 88px; border-radius: 999px; box-shadow: 0 8px 30px rgba(10,8,7,.22); }
.network-status { padding: 10px 16px; color: var(--paper); background: var(--ink); }
.install-app { padding: 10px 16px; color: var(--paper); background: var(--wine); border: 0; font: inherit; font-weight: 700; cursor: pointer; }
.button.danger { color: #791f26; border-color: #b7888b; }
.detail-copy { padding-top: 30px; }
.detail-price { font: 700 30px Georgia, serif; color: var(--wine); }
.source-note { margin: 18px 0; border-top: 1px solid var(--line); border-bottom: 1px solid var(--line); padding: 13px 0; color: var(--muted); }
.source-note summary { cursor: pointer; color: var(--ink); font-weight: 800; }
.source-note p { margin: 12px 0 2px; line-height: 1.65; }
.meaning-card { margin: 22px 0; padding: 20px; border: 1px solid #c9b58f; border-radius: 12px; background: linear-gradient(145deg,#f8f1e3,#fff); }
.meaning-label { margin: 0 0 7px; color: var(--wine); font-size: 11px; font-weight: 900; letter-spacing: .16em; text-transform: uppercase; }
.meaning-card h3 { font-size: 20px; line-height: 1.35; }
.meaning-tags { display: flex; flex-wrap: wrap; gap: 7px; margin: 14px 0; }
.meaning-tags span { padding: 6px 9px; border-radius: 999px; background: var(--ink); color: white; font-size: 11px; font-weight: 800; }
.meaning-card dl { display: grid; gap: 10px; margin: 16px 0; }
.meaning-card dl div { display: grid; grid-template-columns: 90px 1fr; gap: 10px; }
.meaning-card dt { color: var(--ink); font-weight: 800; }
.meaning-card dd { margin: 0; color: var(--muted); line-height: 1.5; }
.info-stack { display: grid; gap: 12px; margin-top: 30px; }
.info-row { border-top: 1px solid var(--line); padding-top: 14px; }

.empty-state { min-height: 52vh; display: grid; place-items: center; text-align: center; }
.empty-state > div { max-width: 520px; }
.library-grid { display: grid; grid-template-columns: repeat(2, 1fr); gap: 16px; margin-top: 26px; }
.library-card { border: 1px solid var(--line); border-radius: 12px; padding: 18px; background: white; }
.email-box { display: flex; gap: 8px; margin-top: 20px; }
.email-box input { flex: 1; min-width: 0; border: 1px solid var(--line); border-radius: 7px; padding: 12px; }
.share-link { display: flex; gap: 8px; margin-top: 16px; }
.share-link input { min-width: 0; flex: 1; border: 1px solid var(--line); border-radius: 7px; padding: 12px; background: white; }
.social-share { display: flex; flex-wrap: wrap; justify-content: center; gap: 8px; margin-top: 12px; }
.social-share button { min-height: 40px; border: 1px solid var(--line); border-radius: 999px; padding: 0 13px; background: #fff; color: var(--ink); font-weight: 800; }
.toast { position: fixed; left: 50%; bottom: 84px; transform: translate(-50%, 20px); z-index: 20; background: var(--ink); color: white; padding: 12px 18px; border-radius: 8px; opacity: 0; pointer-events: none; transition: .2s ease; }
.toast.show { opacity: 1; transform: translate(-50%, 0); }
.toast[data-type="error"] { background: var(--wine-dark); }
.text-button { border: 0; background: transparent; color: var(--wine); padding: 5px 0; text-decoration: underline; }
.review { max-width: 960px; margin: 0 auto; }
.review-grid { display: grid; grid-template-columns: 1fr 360px; gap: 28px; margin-top: 25px; }
.review-items { display: grid; gap: 10px; }
.review-items article { display: grid; grid-template-columns: 64px 1fr auto; align-items: center; gap: 14px; border: 1px solid var(--line); border-radius: 10px; padding: 10px; background: #fff; }
.review-items img { width: 64px; height: 64px; object-fit: contain; background: var(--bone); border-radius: 6px; }
.review-items span { display: block; color: var(--muted); }
.checkout-card { position: sticky; top: 30px; display: grid; gap: 14px; border-top: 4px solid var(--wine); background: white; border-radius: 10px; padding: 22px; box-shadow: var(--shadow); }
.checkout-card > div { display: flex; justify-content: space-between; font-size: 18px; }
.checkout-card input[type="email"] { width: 100%; padding: 12px; border: 1px solid var(--line); border-radius: 7px; }
.verified-email { padding: 12px; border: 1px solid var(--line); border-radius: 7px; background: var(--bone); }
.check-row { display: grid; grid-template-columns: auto 1fr; gap: 9px; align-items: start; font-size: 13px; line-height: 1.45; }
.account-page { max-width: 620px; margin: 7vh auto; }
.account-card { display: grid; gap: 13px; margin-top: 24px; padding: 24px; border-top: 4px solid var(--wine); border-radius: 12px; background: white; box-shadow: var(--shadow); }
.account-card input { min-height: 46px; border: 1px solid var(--line); border-radius: 7px; padding: 0 13px; }
.dev-code { padding: 14px; border: 1px dashed var(--gold); background: #f4ecdd; text-align: center; letter-spacing: .06em; }
.success-mark { display: grid; place-items: center; width: 72px; height: 72px; margin: 0 auto 22px; border-radius: 50%; background: var(--success); color: white; font-size: 38px; }
.order-heading { margin-top: 36px; }
.order-list { display: grid; gap: 8px; }
.order-row { display: grid; grid-template-columns: 1fr 1fr auto; gap: 12px; padding: 13px; border: 1px solid var(--line); background: white; border-radius: 8px; }
.legal-links { display: flex; flex-wrap: wrap; gap: 7px 12px; margin-top: 26px; }
.legal-links button { border: 0; padding: 0; color: var(--muted); background: transparent; font-size: 11px; text-decoration: underline; }
.legal-page { max-width: 720px; margin: 60px auto; font-size: 17px; line-height: 1.75; }
.metric-grid { display: grid; grid-template-columns: repeat(4,1fr); gap: 14px; }
.metric-grid div { border: 1px solid var(--line); background: white; border-radius: 10px; padding: 20px; }
.metric-grid strong, .metric-grid span { display: block; }
.metric-grid strong { color: var(--wine); font: 700 36px Georgia,serif; }
.metric-grid span { color: var(--muted); font-size: 13px; }

@media (max-width: 1120px) {
  .app-shell { grid-template-columns: 190px minmax(0, 1fr); }
  .context-panel { display: none; }
  .beast-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}

@media (max-width: 720px) {
  .app-shell { display: block; }
  .rail { display: none; }
  main { padding: 24px 16px 105px; min-height: 100vh; }
  .bottom-nav { position: fixed; display: grid; grid-template-columns: repeat(5, 1fr); left: 0; right: 0; bottom: 0; z-index: 10; background: rgba(23,19,17,.97); padding: 7px 5px max(7px, env(safe-area-inset-bottom)); }
  .bottom-nav .nav-button { display: grid; justify-items: center; gap: 3px; padding: 7px 2px; font-size: 10px; }
  .bottom-nav .nav-icon { font-size: 17px; }
  .hero { min-height: auto; grid-template-columns: 1fr; gap: 10px; }
  .hero-copy { padding-top: 10px; }
  .hero-art { height: min(38vh, 390px); order: -1; margin-bottom: 22px; overflow: hidden; }
  .hero-art::before { inset: 3% 12%; }
  .price-strip { margin: 18px 0 48px; grid-template-columns: 1fr; }
  .price-card { display: flex; align-items: center; justify-content: space-between; padding: 13px 15px; box-shadow: none; }
  .section-head { display: block; }
  .filter-pills { flex-wrap: nowrap; overflow-x: auto; }
  .beast-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; }
  .beast-body { padding: 11px; }
  .beast-title { display: block; }
  .symbols { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
  .card-actions { display: grid; }
  .pack-toggle { grid-template-columns: 1fr; }
  .pack-option { display: flex; justify-content: space-between; align-items: center; }
  .mobile-pack-status { position: sticky; top: 0; z-index: 6; display: flex; align-items: center; justify-content: space-between; gap: 12px; margin: 0 -16px 18px; padding: 11px 16px; color: white; background: rgba(23,19,17,.96); box-shadow: 0 8px 20px rgba(23,19,17,.16); }
  .mobile-pack-status strong, .mobile-pack-status span { display: block; }
  .mobile-pack-status span { color: #d4c8bd; font-size: 12px; }
  .mobile-pack-status .button { min-height: 38px; border-color: var(--gold); background: var(--gold); color: var(--ink); padding: 0 12px; font-size: 12px; }
  .detail { display: block; }
  .detail-art { min-height: 46vh; }
  .library-grid { grid-template-columns: 1fr; }
  .review-grid { grid-template-columns: 1fr; }
  .checkout-card { position: static; }
  .metric-grid { grid-template-columns: repeat(2,1fr); }
  .order-row { grid-template-columns: 1fr; }
}

@media (max-width: 380px) {
  h1 { font-size: 39px; }
  .beast-grid { grid-template-columns: 1fr; }
}

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