:root {
  color-scheme: dark;
  --bg: #08090d;
  --panel: rgba(19, 21, 29, 0.86);
  --line: rgba(255, 255, 255, 0.09);
  --text: #f5f6fa;
  --muted: #9a9eae;
  --faint: #686d7e;
  --accent: #b7f36b;
  --accent-strong: #98df49;
  --danger: #ff8c96;
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

* { box-sizing: border-box; }
html, body { margin: 0; background: var(--bg); }
html, body { width: 100%; overflow-x: hidden; }
body { color: var(--text); }
button { color: inherit; font: inherit; }
button:focus-visible { outline: 2px solid var(--accent); outline-offset: 4px; }

.app-shell {
  position: relative;
  display: flex;
  flex-direction: column;
  min-height: 0;
  padding: calc(18px + env(safe-area-inset-top)) 18px calc(18px + env(safe-area-inset-bottom));
  isolation: isolate;
}

.ambient { position: fixed; z-index: -1; width: 280px; height: 280px; border-radius: 50%; filter: blur(80px); opacity: .16; pointer-events: none; }
.ambient-left { top: 4%; left: -190px; background: #638d30; }
.ambient-right { right: -180px; bottom: 4%; background: #2d4b93; }

.topbar, .viewer-page { width: min(100%, 720px); margin-inline: auto; }
.topbar { display: flex; align-items: center; justify-content: flex-end; min-height: 34px; }
.brand-lockup { display: inline-flex; align-items: center; gap: 10px; font-size: 14px; font-weight: 700; letter-spacing: -.02em; }
.brand-mark { display: grid; width: 28px; height: 28px; place-items: center; border: 1px solid rgba(183,243,107,.4); border-radius: 9px; color: var(--accent); font-size: 17px; box-shadow: 0 0 22px rgba(183,243,107,.15); }
.language-toggle, .modal-close { border: 1px solid var(--line); background: rgba(255,255,255,.04); cursor: pointer; }
.language-toggle { display: inline-flex; align-items: center; gap: 7px; min-height: 34px; padding: 0 11px; border-radius: 999px; color: var(--muted); font-size: 11px; font-weight: 700; letter-spacing: .06em; }
.language-toggle span:first-child { color: var(--accent); font-size: 13px; }

.viewer-page { display: flex; flex-direction: column; padding-top: 18px; }
.eyebrow { margin: 0 0 9px; color: var(--accent); font-size: 10px; font-weight: 800; letter-spacing: .17em; }
h1, h2, p { margin-top: 0; }
h1 { margin-bottom: 0; font-size: clamp(30px, 9vw, 52px); line-height: .98; letter-spacing: -.08em; }
h2 { margin: 0 0 12px; font-size: 25px; line-height: 1.1; letter-spacing: -.06em; }

.media-stage { position: relative; display: grid; min-height: clamp(180px, 32vh, 360px); place-items: center; overflow: hidden; border: 1px solid var(--line); border-radius: 26px; background: radial-gradient(circle at 50% 35%, rgba(70,76,96,.16), transparent 58%), var(--panel); box-shadow: 0 24px 80px rgba(0,0,0,.42); }
.media-stage.has-media { min-height: 0; }
.media-stage::after { position: absolute; inset: 0; border: 1px solid rgba(255,255,255,.035); border-radius: inherit; content: ""; pointer-events: none; }
.stage-grid { position: absolute; inset: 0; background-image: linear-gradient(rgba(255,255,255,.025) 1px, transparent 1px), linear-gradient(90deg, rgba(255,255,255,.025) 1px, transparent 1px); background-size: 34px 34px; mask-image: radial-gradient(circle at center, black, transparent 80%); opacity: .7; }
.media-stage img, .media-stage video { position: relative; z-index: 1; display: block; width: 100%; height: auto; max-height: min(65dvh, 600px); object-fit: contain; border-radius: 22px; animation: media-in 450ms ease both; }
.media-stage img { width: auto; max-width: 100%; touch-action: manipulation; user-select: auto; -webkit-user-drag: auto; }
.media-stage video { background: #050609; }

.loading-state, .error-state, .expired-state { position: relative; z-index: 2; display: flex; flex-direction: column; align-items: center; gap: 10px; padding: 26px; color: var(--muted); text-align: center; }
.loading-state { flex-direction: row; font-size: 13px; }
.hidden { display: none !important; }
.spinner { width: 16px; height: 16px; border: 2px solid rgba(183,243,107,.2); border-top-color: var(--accent); border-radius: 50%; animation: spin 800ms linear infinite; }
.error-state strong, .expired-state strong { color: var(--text); font-size: 16px; }
.error-state > span:last-of-type, .expired-state > span:last-of-type { max-width: 250px; color: var(--faint); font-size: 12px; line-height: 1.55; }
.error-icon, .expired-icon { display: grid; width: 38px; height: 38px; place-items: center; border: 1px solid rgba(255,140,150,.3); border-radius: 13px; color: var(--danger); font-weight: 800; }
.expired-icon { border-color: rgba(183,243,107,.28); color: var(--accent); }

.media-meta { display: flex; align-items: center; justify-content: space-between; gap: 14px; padding: 12px 2px 0; }
.meta-copy, .countdown-box { display: flex; flex-direction: column; gap: 5px; }
.meta-label, .countdown-label { color: var(--faint); font-size: 11px; }
.meta-copy strong { font-size: 13px; }
.countdown-box { align-items: flex-end; }
.countdown-box strong { color: var(--accent); font-size: 20px; font-variant-numeric: tabular-nums; letter-spacing: .04em; }
.action-row { padding-top: 13px; }

.download-button, .primary-button, .secondary-button { display: inline-flex; align-items: center; justify-content: center; gap: 9px; min-height: 50px; border: 0; border-radius: 15px; cursor: pointer; font-size: 14px; font-weight: 800; transition: transform 180ms ease, background 180ms ease, opacity 180ms ease; }
.download-button, .primary-button { width: 100%; background: var(--accent); color: #10150b; box-shadow: 0 10px 28px rgba(183,243,107,.15); }
.download-button:hover:not(:disabled), .primary-button:hover, .secondary-button:hover { background: var(--accent-strong); }
.download-button:active:not(:disabled), .primary-button:active, .secondary-button:active, .language-toggle:active, .text-button:active { transform: scale(.98); }
.download-button:disabled { background: #242832; color: #696e80; cursor: not-allowed; box-shadow: none; }
.download-icon { display: inline-grid; width: 23px; height: 23px; place-items: center; border: 1px solid currentColor; border-radius: 8px; font-size: 17px; }
.download-hint { margin: 10px 0 0; color: var(--faint); font-size: 11px; line-height: 1.45; text-align: center; }
.footer-note { display: flex; align-items: center; justify-content: center; gap: 8px; padding-top: 24px; color: var(--faint); font-size: 11px; text-align: center; }
.footer-dot { width: 4px; height: 4px; color: var(--accent); }

.modal-backdrop { position: fixed; z-index: 10; inset: 0; display: grid; place-items: end center; padding: 16px; background: rgba(0,0,0,.68); backdrop-filter: blur(8px); }
.download-modal { position: relative; width: min(100%, 430px); padding: 27px 22px 18px; border: 1px solid var(--line); border-radius: 24px; background: #141720; box-shadow: 0 24px 80px rgba(0,0,0,.42); animation: modal-in 280ms cubic-bezier(.22,1,.36,1) both; }
.modal-close { position: absolute; top: 14px; right: 14px; display: grid; width: 32px; height: 32px; place-items: center; border-radius: 50%; color: var(--muted); font-size: 21px; }
.modal-icon { display: grid; width: 44px; height: 44px; margin-bottom: 17px; place-items: center; border: 1px solid rgba(183,243,107,.32); border-radius: 15px; color: var(--accent); font-size: 22px; }
.modal-description { margin-bottom: 20px; color: var(--muted); font-size: 13px; line-height: 1.65; }
.modal-steps { display: grid; gap: 10px; margin-bottom: 22px; }
.modal-step { display: flex; align-items: center; gap: 11px; font-size: 13px; }
.modal-step span { display: grid; width: 24px; height: 24px; flex: 0 0 auto; place-items: center; border-radius: 8px; background: rgba(183,243,107,.12); color: var(--accent); font-size: 11px; }
.modal-step strong { font-weight: 600; }
.text-button { display: block; width: 100%; margin: 13px 0 0; padding: 0; border: 0; background: transparent; color: var(--muted); cursor: pointer; font-size: 12px; }
.copy-feedback { min-height: 17px; margin: 9px 0 0; color: var(--accent); font-size: 11px; text-align: center; }

@keyframes spin { to { transform: rotate(360deg); } }
@keyframes media-in { from { opacity: 0; transform: scale(.985); } to { opacity: 1; transform: scale(1); } }
@keyframes modal-in { from { opacity: 0; transform: translateY(18px); } to { opacity: 1; transform: translateY(0); } }

@media (min-width: 700px) {
  .app-shell { padding-inline: 32px; }
  .media-stage { min-height: 240px; }
  .media-stage.has-media { min-height: 0; }
  .media-stage img, .media-stage video { max-height: min(68dvh, 680px); }
  .modal-backdrop { place-items: center; }
}

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