:root {
  --bg: #f5f4ef;
  --surface: #ffffff;
  --ink: #11110f;
  --muted: #72716b;
  --line: rgba(17,17,15,.10);
  --accent: #6f6bff;
  --today: #6f6bff;
  --radius-xl: 32px;
  --radius-lg: 24px;
  --radius-md: 18px;
  --shadow: 0 18px 50px rgba(17,17,15,.08);
  --safe-bottom: env(safe-area-inset-bottom, 0px);
  font-family: Inter, ui-rounded, "SF Pro Rounded", "SF Pro Display", system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  color: var(--ink);
  background: var(--bg);
}

* { box-sizing: border-box; }
html { background: var(--bg); }
body { margin: 0; min-height: 100dvh; background: var(--bg); color: var(--ink); -webkit-font-smoothing: antialiased; }
button, input, a { font: inherit; }
button { border: 0; }
a { color: inherit; text-decoration: none; }
img, canvas, video { display: block; max-width: 100%; }

.app-shell { min-height: 100dvh; max-width: 520px; margin: 0 auto; padding: 18px 18px calc(24px + var(--safe-bottom)); }
.topbar { display: flex; align-items: center; justify-content: space-between; gap: 14px; margin-bottom: 24px; }
.brand { display: inline-flex; align-items: center; gap: 10px; font-weight: 900; letter-spacing: -.04em; }
.brand-mark { width: 30px; aspect-ratio: 1; border-radius: 11px; background: var(--today); box-shadow: inset 0 0 0 7px rgba(255,255,255,.42); transform: rotate(30deg); }
.icon-btn { width: 44px; height: 44px; display: inline-grid; place-items: center; border-radius: 16px; background: rgba(255,255,255,.72); color: var(--ink); box-shadow: inset 0 0 0 1px var(--line); }

.hero { padding: 8px 0 24px; }
.eyebrow { margin: 0 0 10px; color: var(--muted); text-transform: uppercase; letter-spacing: .16em; font-size: 12px; font-weight: 800; }
h1 { margin: 0; max-width: 440px; font-size: clamp(42px, 12vw, 68px); line-height: .94; letter-spacing: -.07em; }
.hero-copy { margin: 18px 0 0; max-width: 390px; font-size: 16px; line-height: 1.6; color: var(--muted); }

.today-card { position: relative; overflow: hidden; background: var(--surface); border-radius: var(--radius-xl); min-height: 360px; padding: 26px; box-shadow: var(--shadow); }
.today-card::before { content: ""; position: absolute; inset: -18% -18% auto auto; width: 230px; aspect-ratio: 1; background: var(--today); border-radius: 46% 54% 55% 45%; filter: blur(.2px); opacity: .96; transform: rotate(17deg); }
.today-card::after { content: ""; position: absolute; width: 120px; aspect-ratio: 1; border: 26px solid rgba(255,255,255,.28); border-radius: 40%; right: 36px; top: 36px; transform: rotate(29deg); }
.today-meta { position: relative; z-index: 2; display: flex; justify-content: space-between; align-items: flex-start; }
.today-date { font-weight: 800; font-size: 13px; letter-spacing: .02em; }
.today-chip { display: inline-flex; align-items: center; gap: 8px; border-radius: 999px; padding: 9px 12px; background: rgba(245,244,239,.78); backdrop-filter: blur(12px); font-size: 12px; font-weight: 800; }
.swatch { width: 12px; height: 12px; border-radius: 999px; background: var(--today); box-shadow: inset 0 0 0 1px rgba(0,0,0,.08); }
.today-title { position: absolute; z-index: 2; left: 26px; right: 26px; bottom: 28px; }
.today-title small { display: block; margin-bottom: 7px; color: var(--muted); font-weight: 700; }
.today-title strong { display: block; font-size: 34px; line-height: 1.02; letter-spacing: -.05em; }

.primary, .secondary, .ghost { width: 100%; min-height: 58px; border-radius: 20px; display: flex; align-items: center; justify-content: center; gap: 10px; font-weight: 900; cursor: pointer; transition: transform .16s ease, opacity .16s ease, background .16s ease; }
.primary:active, .secondary:active, .ghost:active { transform: scale(.985); }
.primary { background: var(--ink); color: white; }
.secondary { background: var(--surface); color: var(--ink); box-shadow: inset 0 0 0 1px var(--line); }
.ghost { background: transparent; color: var(--muted); min-height: 48px; }
.action-stack { display: grid; gap: 10px; margin-top: 16px; }

.mini-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; margin-top: 18px; }
.mini-card { padding: 18px; border-radius: 22px; background: rgba(255,255,255,.66); box-shadow: inset 0 0 0 1px var(--line); }
.mini-card strong { display: block; font-size: 18px; margin-bottom: 5px; letter-spacing: -.03em; }
.mini-card span { color: var(--muted); font-size: 13px; line-height: 1.45; }

.bottom-nav { position: sticky; bottom: max(10px, var(--safe-bottom)); z-index: 30; display: grid; grid-template-columns: repeat(3,1fr); gap: 6px; margin-top: 28px; padding: 6px; background: rgba(255,255,255,.76); backdrop-filter: blur(22px) saturate(150%); border: 1px solid rgba(17,17,15,.07); border-radius: 22px; box-shadow: 0 12px 38px rgba(17,17,15,.09); }
.bottom-nav a { min-height: 50px; display: grid; place-items: center; border-radius: 16px; color: var(--muted); font-size: 12px; font-weight: 800; }
.bottom-nav a[aria-current="page"] { background: var(--ink); color: white; }

/* Camera */
.camera-page { background: #090909; color: #fff; overflow: hidden; }
.camera-shell { min-height: 100dvh; max-width: 520px; margin: 0 auto; position: relative; background: #000; }
.camera-view { position: absolute; inset: 0; overflow: hidden; }
.camera-view video { width: 100%; height: 100%; object-fit: cover; }
.camera-vignette { position: absolute; inset: 0; pointer-events: none; background: linear-gradient(to bottom, rgba(0,0,0,.48), transparent 23%, transparent 66%, rgba(0,0,0,.66)); }
.camera-top { position: absolute; inset: max(16px, env(safe-area-inset-top)) 16px auto; z-index: 4; display: flex; align-items: center; justify-content: space-between; }
.camera-top .icon-btn { background: rgba(20,20,20,.48); color: #fff; border: 1px solid rgba(255,255,255,.12); box-shadow: none; backdrop-filter: blur(14px); }
.camera-prompt { position: absolute; z-index: 4; top: calc(max(16px, env(safe-area-inset-top)) + 68px); left: 16px; right: 16px; text-align: center; }
.camera-prompt span { display: inline-flex; gap: 8px; align-items: center; padding: 9px 13px; border-radius: 999px; background: rgba(18,18,18,.48); border: 1px solid rgba(255,255,255,.12); backdrop-filter: blur(14px); font-size: 12px; font-weight: 800; }
.camera-prompt i { width: 10px; height: 10px; border-radius: 50%; background: var(--today); }
.camera-bottom { position: absolute; z-index: 4; left: 20px; right: 20px; bottom: calc(20px + var(--safe-bottom)); display: grid; grid-template-columns: 56px 1fr 56px; gap: 22px; align-items: center; }
.capture { width: 82px; aspect-ratio: 1; border-radius: 50%; margin: 0 auto; background: white; box-shadow: 0 0 0 6px rgba(255,255,255,.26); position: relative; }
.capture::after { content:""; position:absolute; inset:9px; border-radius:50%; background: var(--today); transition: transform .12s ease; }
.capture:active::after { transform: scale(.84); }
.camera-helper { position: absolute; z-index: 4; left: 24px; right: 24px; bottom: calc(122px + var(--safe-bottom)); text-align: center; font-size: 12px; color: rgba(255,255,255,.72); }
.permission-card { position: absolute; z-index: 8; left: 18px; right: 18px; top: 50%; transform: translateY(-50%); border-radius: 28px; padding: 24px; background: rgba(245,244,239,.95); color: var(--ink); backdrop-filter: blur(20px); }
.permission-card h2 { margin: 0 0 8px; font-size: 28px; letter-spacing: -.05em; }
.permission-card p { margin: 0 0 18px; color: var(--muted); line-height: 1.55; }
.file-fallback { display:none; }

/* Editor / Share */
.stage-shell { min-height: 100dvh; max-width: 520px; margin: 0 auto; padding: max(16px, env(safe-area-inset-top)) 16px calc(18px + var(--safe-bottom)); display: flex; flex-direction: column; }
.stage-top { display: flex; align-items: center; justify-content: space-between; gap: 14px; margin-bottom: 14px; }
.stage-title { font-weight: 900; letter-spacing: -.03em; }
.poster-wrap { position: relative; border-radius: 30px; overflow: hidden; background: #ddd; box-shadow: var(--shadow); aspect-ratio: 4/5; }
.poster-wrap canvas, .poster-wrap img { width: 100%; height: 100%; object-fit: cover; }
.processing { position: absolute; inset: 0; display: grid; place-items: center; background: rgba(245,244,239,.76); backdrop-filter: blur(12px); font-weight: 900; transition: opacity .25s ease; }
.processing.hidden { opacity: 0; pointer-events: none; }
.editor-info { display: flex; justify-content: space-between; align-items: center; gap: 14px; padding: 16px 4px 4px; }
.score { display: flex; align-items: baseline; gap: 7px; }
.score strong { font-size: 32px; letter-spacing: -.05em; }
.score span { color: var(--muted); font-size: 12px; font-weight: 800; }
.filter-badge { display: inline-flex; align-items: center; gap: 8px; border-radius: 999px; padding: 10px 12px; background: var(--surface); box-shadow: inset 0 0 0 1px var(--line); font-size: 12px; font-weight: 800; }
.stage-actions { margin-top: auto; padding-top: 16px; display: grid; gap: 10px; }

.share-card { padding: 22px; border-radius: 30px; background: var(--surface); box-shadow: var(--shadow); }
.share-preview { overflow: hidden; border-radius: 22px; background: #ddd; aspect-ratio: 4/5; }
.share-preview img { width:100%; height:100%; object-fit:cover; }
.share-preview.story-preview { width:min(100%,320px); margin-inline:auto; }
.share-head { display:flex; align-items:center; justify-content:space-between; gap:12px; margin: 18px 0 12px; }
.share-head h1 { font-size: 30px; letter-spacing: -.05em; }
.share-copy { margin:0; color:var(--muted); font-size:14px; line-height:1.55; }
.share-size { display:grid; grid-template-columns:repeat(3,1fr); gap:6px; padding:5px; margin-top:14px; border-radius:16px; background:#efeee9; }
.size-option { min-height:40px; border-radius:12px; font-size:13px; font-weight:900; color:var(--muted); cursor:pointer; transition:background .16s ease,color .16s ease,box-shadow .16s ease,transform .16s ease; }
.size-option:active { transform:scale(.98); }
.size-option.active { background:var(--surface); color:var(--ink); box-shadow:0 2px 10px rgba(17,17,15,.07); }
.quick-share-grid { display:grid; grid-template-columns:1fr 1fr; gap:10px; margin-top:18px; }
.quick-share { min-height:58px; border-radius:18px; display:flex; align-items:center; justify-content:center; gap:8px; font-weight:900; cursor:pointer; transition:transform .16s ease, opacity .16s ease; }
.quick-share:active { transform:scale(.985); }
.quick-share.copy { background:var(--surface); color:var(--ink); box-shadow:inset 0 0 0 1px var(--line); }
.quick-share.share { background:var(--ink); color:#fff; }
.quick-share[disabled] { opacity:.42; cursor:default; }
.share-buttons { display:grid; gap:10px; margin-top:18px; }
.social-btn { min-height: 56px; border-radius: 18px; display:flex; align-items:center; justify-content:center; gap:10px; font-weight:900; }
.social-btn.instagram { background: linear-gradient(120deg,#feda75,#d62976 44%,#4f5bd5); color:#fff; }
.social-btn.x { background:#090909; color:#fff; }
.social-btn.system { background:var(--surface); box-shadow: inset 0 0 0 1px var(--line); }

/* Content pages */
.content { padding-bottom: 30px; }
.content h1 { font-size: clamp(40px, 11vw, 58px); margin-bottom: 24px; }
.content h2 { margin: 30px 0 10px; font-size: 22px; letter-spacing: -.04em; }
.content p, .content li { color: var(--muted); line-height: 1.75; }
.content .lead { font-size: 18px; color: var(--ink); }
.content-card { margin-top: 18px; padding: 22px; background: var(--surface); border-radius: 24px; box-shadow: inset 0 0 0 1px var(--line); }
.feature-list { display:grid; gap:10px; margin-top:16px; }
.feature-row { display:flex; gap:12px; align-items:flex-start; padding:15px; border-radius:18px; background:rgba(255,255,255,.7); }
.feature-row b { display:block; margin-bottom:3px; }
.feature-row span { color:var(--muted); font-size:13px; line-height:1.5; }
.dot { flex:0 0 auto; width:13px; height:13px; margin-top:4px; border-radius:5px; background:var(--today); transform:rotate(30deg); }

.toast { position:fixed; z-index:99; left:50%; bottom:calc(20px + var(--safe-bottom)); transform:translate(-50%,16px); width:min(calc(100% - 32px),440px); padding:14px 16px; border-radius:16px; background:#111; color:#fff; text-align:center; font-size:13px; font-weight:800; opacity:0; pointer-events:none; transition:.2s ease; }
.toast.show { opacity:1; transform:translate(-50%,0); }

@media (min-width: 700px) {
  body:not(.camera-page) { padding: 24px 0; }
  .app-shell, .stage-shell { border-radius: 34px; }
}

/* Quieter copy */
.hero-compact { padding-bottom: 18px; }
.hero-compact h1 { max-width: 410px; }
.compact-features { margin-top: 28px; }
.privacy-lead { margin-bottom: 22px; }
.privacy-list { display: grid; gap: 10px; }
.privacy-list details { border-radius: 18px; background: rgba(255,255,255,.7); box-shadow: inset 0 0 0 1px var(--line); overflow: hidden; }
.privacy-list summary { cursor: pointer; list-style: none; padding: 17px 18px; font-weight: 850; }
.privacy-list summary::-webkit-details-marker { display:none; }
.privacy-list summary::after { content:'+'; float:right; color:var(--muted); font-size:20px; line-height:1; }
.privacy-list details[open] summary::after { content:'−'; }
.privacy-list details p { margin:0; padding:0 18px 18px; font-size:14px; line-height:1.65; }

/* PWA */
.install-button[hidden] { display:none; }
@media (display-mode: standalone) {
  body { overscroll-behavior-y: none; }
  .install-button { display:none !important; }
}
