@import url("https://fonts.googleapis.com/css2?family=Cinzel:wght@500;600;700&family=Libre+Baskerville:wght@400;700&family=Libre+Franklin:wght@400;500;600;700&display=swap");

:root {
  color-scheme: dark;
  font-family: "Libre Franklin", ui-sans-serif, system-ui, sans-serif;
  color: #f2e8d0;
  background: #160f11;
  font-synthesis: none;
  --ink: #f2e8d0; --muted: #b9aa94; --wine: #6f2438; --wine-bright: #973650;
  --gold: #d8ad55; --gold-light: #fff0a5; --stone: #30272a; --stone-light: #493c40;
  --line: rgba(216, 173, 85, .24); --red: #e46c6c;
}
* { box-sizing: border-box; }
html { min-width: 320px; background: #160f11; }
body { margin: 0; min-height: 100vh; background: radial-gradient(circle at 50% 14%, rgba(126, 48, 65, .22), transparent 36rem), linear-gradient(180deg, #211619 0, #160f11 58%, #110b0d 100%); }
button, input, select { font: inherit; }
button, summary, a { -webkit-tap-highlight-color: transparent; }
button { cursor: pointer; }
a { color: var(--gold-light); }
h1, h2, p { margin: 0; }

.topbar { min-height: 76px; padding: 14px clamp(20px, 5vw, 68px); display: flex; align-items: center; justify-content: space-between; gap: 20px; border-bottom: 1px solid var(--line); background: rgba(16, 10, 12, .72); backdrop-filter: blur(12px); }
.brand { max-width: min(620px, 72vw); color: var(--ink); text-decoration: none; display: flex; flex-direction: column; gap: 3px; }
.brand-name { font-family: "Libre Baskerville", Georgia, serif; font-size: 19px; letter-spacing: .015em; }
.brand-name strong { color: var(--gold-light); }
.brand > span:last-child { color: var(--muted); font-size: 11px; }
.status-badge { color: var(--muted); font-size: 12px; font-weight: 600; display: flex; align-items: center; gap: 8px; }
.status-badge::before { content: ""; width: 8px; height: 8px; border-radius: 50%; background: #766b6e; }
.status-badge.live::before { background: var(--gold); box-shadow: 0 0 0 4px rgba(216, 173, 85, .12); }
.status-badge.error { color: #f4b0b0; }
.status-badge.error::before { background: var(--red); }

main { width: min(850px, calc(100% - 32px)); margin: 0 auto; }
.hero { min-height: calc(100vh - 150px); padding: clamp(56px, 9vh, 92px) 0 46px; display: flex; flex-direction: column; align-items: center; text-align: center; }
.eyebrow { color: var(--gold); font-family: Cinzel, Georgia, serif; font-size: 11px; font-weight: 600; letter-spacing: .19em; text-transform: uppercase; }
h1 { font-family: "Libre Baskerville", Georgia, serif; font-size: clamp(40px, 9vw, 68px); font-weight: 700; letter-spacing: .015em; text-shadow: 0 3px 28px rgba(0, 0, 0, .55); }
h2 { font-family: Cinzel, Georgia, serif; font-size: 18px; letter-spacing: .025em; }

.grail { position: relative; width: 160px; height: 190px; margin: 34px 0 22px; opacity: .2; filter: saturate(.25); transition: opacity .45s ease, filter .45s ease, transform .45s ease; }
.grail::before { content: ""; position: absolute; inset: 10px 0 0; border-radius: 50%; background: radial-gradient(circle, rgba(255, 225, 125, .24), transparent 63%); opacity: 0; transform: scale(.65); transition: opacity .45s ease, transform .45s ease; }
.grail-rim, .grail-cup, .grail-stem, .grail-foot, .grail-shine { position: absolute; display: block; }
.grail-rim { left: 20px; top: 25px; width: 120px; height: 24px; border: 4px solid #e0b35a; border-radius: 50%; background: #50351f; box-shadow: inset 0 5px 8px #120d09; z-index: 3; }
.grail-cup { left: 27px; top: 36px; width: 106px; height: 78px; background: linear-gradient(100deg, #8e5c24 0%, #f4cf70 36%, #a86c29 62%, #f2d383 82%, #81511e 100%); clip-path: polygon(0 0, 100% 0, 86% 64%, 70% 88%, 50% 100%, 30% 88%, 14% 64%); border-radius: 0 0 50% 50%; z-index: 2; }
.grail-stem { left: 73px; top: 104px; width: 14px; height: 48px; background: linear-gradient(90deg, #8a581f, #f4d77e 45%, #986326); border-radius: 5px; }
.grail-foot { left: 42px; top: 147px; width: 76px; height: 23px; background: linear-gradient(100deg, #80501c, #f5d379 45%, #89571f); clip-path: polygon(38% 0, 62% 0, 100% 72%, 94% 100%, 6% 100%, 0 72%); border-radius: 0 0 50% 50%; }
.grail-shine { left: 53px; top: 50px; width: 10px; height: 42px; border-radius: 50%; background: linear-gradient(180deg, rgba(255,255,220,.85), rgba(255,255,220,0)); transform: rotate(18deg); z-index: 4; opacity: .7; }
.grail.listening { opacity: .42; filter: saturate(.55); animation: grail-breathe 2.6s ease-in-out infinite; }
.grail.testing { opacity: .68; filter: saturate(.8); }
.grail.detected { opacity: 1; filter: saturate(1.12) drop-shadow(0 0 18px rgba(245, 205, 105, .5)); transform: translateY(-3px) scale(1.035); }
.grail.detected::before { opacity: 1; transform: scale(1.2); }
.grail.error { opacity: .34; filter: grayscale(.4) sepia(.2); }
@keyframes grail-breathe { 0%, 100% { opacity: .34; } 50% { opacity: .5; } }
@media (prefers-reduced-motion: reduce) { .grail.listening { animation: none; } }

.primary-status { min-height: 24px; color: var(--muted); font-size: 15px; }
.primary-action { width: min(100%, 380px); min-height: 64px; margin-top: 24px; border: 1px solid #e1bd71; border-radius: 8px; background: linear-gradient(180deg, var(--wine-bright), var(--wine)); color: #fff8e7; font-family: Cinzel, Georgia, serif; font-size: 17px; font-weight: 700; letter-spacing: .045em; box-shadow: 0 9px 25px rgba(0,0,0,.3), inset 0 1px rgba(255,255,255,.14); }
.primary-action:hover { background: linear-gradient(180deg, #aa4260, #7d2940); transform: translateY(-1px); }
.primary-action:focus-visible, .test-action:focus-visible, .info-links button:focus-visible, summary:focus-visible, .dialog-close:focus-visible { outline: 3px solid var(--gold-light); outline-offset: 4px; }
.test-action { min-height: 40px; margin-top: 11px; padding: 0 18px; border: 0; background: transparent; color: var(--gold-light); font-size: 13px; font-weight: 600; text-decoration: underline; text-decoration-color: rgba(255,240,165,.35); text-underline-offset: 4px; }
.info-links { display: flex; align-items: center; gap: 14px; margin-top: 30px; }
.info-links button { min-height: 36px; padding: 0; border: 0; background: transparent; color: var(--muted); font-size: 13px; }
.info-links button:hover { color: var(--ink); }
.info-links span { color: var(--wine-bright); font-size: 7px; }

.advanced { margin: 0 0 56px; border: 1px solid var(--line); border-radius: 9px; background: rgba(31, 22, 25, .78); overflow: hidden; }
.advanced > summary { min-height: 58px; padding: 0 22px; display: flex; align-items: center; justify-content: center; list-style: none; color: var(--gold-light); font-family: Cinzel, Georgia, serif; font-size: 14px; font-weight: 600; letter-spacing: .07em; cursor: pointer; }
.advanced > summary::-webkit-details-marker { display: none; }
.advanced > summary::after { content: "+"; margin-left: 10px; color: var(--gold); font-family: "Libre Franklin", sans-serif; font-size: 18px; }
.advanced[open] > summary::after { content: "−"; }
.advanced-content { padding: 0 24px 26px; border-top: 1px solid var(--line); }
.advanced-section { padding: 26px 0; border-bottom: 1px solid rgba(216, 173, 85, .14); }
.advanced-section:last-child { border-bottom: 0; padding-bottom: 0; }
.section-heading { display: flex; align-items: flex-end; justify-content: space-between; gap: 20px; }
.section-heading p { margin-top: 5px; color: var(--muted); font-size: 12px; line-height: 1.5; }
.segmented { display: inline-grid; grid-template-columns: 1fr 1fr; margin-top: 20px; border: 1px solid var(--stone-light); border-radius: 6px; overflow: hidden; }
.segment { min-height: 40px; min-width: 160px; padding: 0 14px; border: 0; border-radius: 0; background: #21191b; color: var(--muted); font-size: 12px; font-weight: 600; }
.segment + .segment { border-left: 1px solid var(--stone-light); }
.segment.selected { background: #4d2732; color: #fff1cf; }
.settings-grid { margin-top: 22px; display: grid; grid-template-columns: 1.6fr 1fr 1fr; gap: 18px; }
label { display: flex; flex-direction: column; gap: 8px; color: var(--muted); font-size: 12px; }
select { width: 100%; height: 42px; border: 1px solid var(--stone-light); border-radius: 5px; background: #1d1518; padding: 0 10px; color: var(--ink); }
.quiet { min-height: 36px; padding: 0; border: 0; background: transparent; color: var(--muted); font-size: 12px; text-decoration: underline; text-underline-offset: 3px; }
.metrics { display: grid; grid-template-columns: repeat(4, 1fr); gap: 1px; margin-top: 20px; background: var(--line); border: 1px solid var(--line); }
.metrics div { min-height: 70px; padding: 13px 14px; background: #1c1517; display: flex; flex-direction: column; gap: 8px; }
.metrics span { color: var(--muted); font-size: 10px; text-transform: uppercase; letter-spacing: .06em; }
.metrics strong { font-size: 15px; }
.table-wrap { margin-top: 18px; overflow-x: auto; }
table { width: 100%; border-collapse: collapse; font-size: 12px; background: #1a1315; }
th, td { padding: 11px 12px; border-bottom: 1px solid rgba(216,173,85,.13); text-align: left; white-space: nowrap; }
th { color: var(--muted); font-size: 10px; text-transform: uppercase; letter-spacing: .05em; background: #261c1f; }
.empty-row td { color: var(--muted); text-align: center; padding: 24px; }
.result-strong, .result-reliable { color: var(--gold-light); font-weight: 700; }
.result-marginal { color: #e3a755; font-weight: 700; }
.result-not-detected { color: var(--red); font-weight: 700; }

dialog { width: min(620px, calc(100% - 28px)); max-height: min(760px, calc(100vh - 32px)); overflow-y: auto; border: 1px solid rgba(216,173,85,.48); border-radius: 10px; background: #211719; color: var(--ink); padding: clamp(24px, 5vw, 40px); box-shadow: 0 24px 80px rgba(0,0,0,.65); }
dialog::backdrop { background: rgba(8,5,6,.78); backdrop-filter: blur(5px); }
.dialog-heading { display: flex; align-items: flex-start; justify-content: space-between; gap: 20px; margin-bottom: 24px; }
.dialog-heading h2 { margin-top: 5px; font-size: 24px; }
.dialog-close { width: 42px; height: 42px; flex: 0 0 42px; border: 1px solid var(--stone-light); border-radius: 50%; background: transparent; color: var(--muted); font-size: 24px; line-height: 1; }
dialog > p, .instructions-list { color: #d4c7b5; font-size: 14px; line-height: 1.7; }
dialog > p + p { margin-top: 16px; }
.instructions-list { margin: 0; padding-left: 23px; }
.instructions-list li { padding-left: 6px; }
.instructions-list li + li { margin-top: 14px; }
.coming-soon { display: inline-block; margin-left: 5px; color: var(--gold); font-size: 10px; font-weight: 700; letter-spacing: .08em; text-transform: uppercase; }
.dialog-note { margin-top: 22px !important; padding-top: 18px; border-top: 1px solid var(--line); color: var(--muted) !important; font-size: 12px !important; }
.compatibility-note { margin-top: 14px !important; color: var(--muted) !important; font-size: 12px !important; }
.compatibility-note strong { color: var(--ink); }
.download-status { min-height: 20px; margin-top: 10px !important; color: var(--gold-light) !important; font-size: 12px !important; }
footer { min-height: 58px; padding: 16px clamp(20px, 5vw, 68px); border-top: 1px solid var(--line); color: #887b7e; font-size: 11px; display: flex; justify-content: space-between; align-items: center; gap: 20px; }
footer strong { color: #aa8d55; }

@media (max-width: 700px) {
  .topbar { min-height: 76px; padding: 12px 16px; align-items: flex-start; }
  .brand { max-width: calc(100% - 98px); }
  .brand > span:last-child { font-size: 9px; line-height: 1.35; }
  .status-badge { margin-top: 4px; white-space: nowrap; }
  .hero { min-height: calc(100vh - 126px); padding-top: 48px; }
  .grail { width: 142px; height: 172px; margin-top: 25px; transform: scale(.9); transform-origin: center; }
  .grail.detected { transform: translateY(-3px) scale(.94); }
  .advanced-content { padding-inline: 16px; }
  .section-heading, .activity-heading { align-items: flex-start; }
  .segmented { width: 100%; }
  .segment { min-width: 0; white-space: normal; padding: 7px; }
  .settings-grid { grid-template-columns: 1fr; }
  .metrics { grid-template-columns: 1fr 1fr; }
  footer { padding: 14px 16px; }
}
@media (max-height: 700px) and (min-width: 701px) {
  .hero { min-height: auto; padding-top: 38px; }
  .grail { margin-top: 18px; margin-bottom: 12px; transform: scale(.82); height: 160px; }
  .grail.detected { transform: translateY(-3px) scale(.86); }
}
