:root {
  --bg: #07070c;
  --panel: #12121b;
  --line: rgba(255,255,255,.09);
  --text: #f6f5fb;
  --muted: #9a98ad;
  --accent: #ffd34d;
  --accent-2: #ff4e88;
  --radius: 22px;
  --cell: 190px;
  --gap: 14px;
  --display: 'Bricolage Grotesque', system-ui, sans-serif;
  --mono: 'JetBrains Mono', ui-monospace, monospace;
  color-scheme: dark;
}
* { box-sizing: border-box; }
html, body { margin: 0; background: var(--bg); color: var(--text); font-family: var(--display); }
body { min-height: 100vh; background:
  radial-gradient(1200px 600px at 10% -10%, rgba(255,78,136,.12), transparent 60%),
  radial-gradient(900px 500px at 100% 0%, rgba(255,211,77,.08), transparent 60%), var(--bg); }
[hidden] { display: none !important; }
button { font: inherit; color: inherit; cursor: pointer; }
input { font: inherit; }
.muted { color: var(--muted); }
.mono { font-family: var(--mono); font-variant-numeric: tabular-nums; }
.spacer { flex: 1; }

/* ---------- Brand & buttons ---------- */
.brand { font-weight: 800; font-size: 22px; letter-spacing: -.02em; display: flex; align-items: center; gap: 2px; }
.brand.big { font-size: 44px; justify-content: center; }
.logo { background: linear-gradient(135deg, var(--accent), var(--accent-2)); -webkit-background-clip: text; background-clip: text; color: transparent; }
.btn { border: 1px solid var(--line); background: rgba(255,255,255,.05); border-radius: 999px; padding: 9px 16px; font-weight: 600; white-space: nowrap; transition: transform .15s, background .15s; }
.btn:hover { background: rgba(255,255,255,.1); }
.btn:active { transform: scale(.97); }
.btn.primary { background: linear-gradient(135deg, var(--accent), #ff9f43); color: #1a1205; border: 0; }
.btn.danger { color: #ff6b81; border-color: rgba(255,107,129,.4); }
.btn:disabled { opacity: .6; cursor: progress; }
.link { background: none; border: 0; color: var(--muted); padding: 4px; }
.link:hover { color: var(--text); }
.icon-btn { width: 34px; height: 34px; border-radius: 50%; border: 0; background: rgba(0,0,0,.35); backdrop-filter: blur(8px); display: grid; place-items: center; font-size: 15px; }
.icon-btn:hover { background: rgba(0,0,0,.6); }
.icon-btn.star.on { color: var(--accent); }

/* ---------- Auth ---------- */
.auth { min-height: 100vh; display: grid; place-items: center; padding: 24px 16px; position: relative; overflow: hidden; }
.auth-bg span { position: absolute; font-size: 64px; opacity: .22; animation: drift 14s ease-in-out infinite; }
.auth-bg span:nth-child(1) { left: 8%; top: 14%; }
.auth-bg span:nth-child(2) { left: 80%; top: 18%; animation-delay: -3s; }
.auth-bg span:nth-child(3) { left: 16%; top: 72%; animation-delay: -6s; }
.auth-bg span:nth-child(4) { left: 74%; top: 70%; animation-delay: -2s; }
.auth-bg span:nth-child(5) { left: 45%; top: 6%; animation-delay: -8s; }
.auth-bg span:nth-child(6) { left: 46%; top: 86%; animation-delay: -5s; }
.auth-bg span:nth-child(7) { left: 2%; top: 44%; animation-delay: -9s; }
.auth-bg span:nth-child(8) { left: 90%; top: 46%; animation-delay: -4s; }
@keyframes drift { 50% { transform: translateY(-24px) rotate(8deg); } }
.auth-card { position: relative; width: min(420px, 100%); background: rgba(18,18,27,.85); backdrop-filter: blur(20px); border: 1px solid var(--line); border-radius: 28px; padding: 36px 28px 24px; text-align: center; }
.tagline { color: var(--muted); margin: 8px 0 24px; line-height: 1.45; }
#auth-form { display: grid; gap: 14px; text-align: left; }
#auth-form[data-mode="login"] .signup-only { display: none; }
#auth-form .btn { padding: 13px; font-size: 16px; margin-top: 4px; }
label { display: grid; gap: 6px; font-size: 13px; color: var(--muted); font-weight: 600; }
input:not([type=checkbox]) { background: #0b0b12; color: var(--text); border: 1px solid var(--line); border-radius: 12px; padding: 11px 13px; font-size: 15px; outline: none; }
input:focus { border-color: var(--accent); }
.error { color: #ff6b81; min-height: 1em; margin: 0; font-size: 14px; }
#auth-switch { margin-top: 14px; }

/* ---------- Top bar ---------- */
.topbar { position: sticky; top: 0; z-index: 10; display: flex; align-items: center; gap: 12px; flex-wrap: wrap; padding: 14px 24px; background: rgba(7,7,12,.75); backdrop-filter: blur(16px); border-bottom: 1px solid var(--line); }
.user { display: flex; align-items: center; gap: 6px; color: var(--muted); font-size: 14px; }
.toggle { display: flex; flex-direction: row; align-items: center; gap: 6px; font-weight: 500; }
.empty { text-align: center; color: var(--muted); padding: 60px 16px 0; }

/* ---------- Wall (mosaic) ---------- */
.wall { display: grid; grid-template-columns: repeat(auto-fill, minmax(var(--cell), 1fr)); grid-auto-rows: var(--cell); grid-auto-flow: dense; gap: var(--gap); padding: 22px 24px 60px; }
.tile { position: relative; overflow: hidden; border-radius: var(--radius); background: linear-gradient(145deg, var(--c1), var(--c2)); isolation: isolate; box-shadow: 0 10px 30px -12px rgba(0,0,0,.7), inset 0 1px 0 rgba(255,255,255,.15); animation: pop .5s cubic-bezier(.2,.9,.3,1.3) both; transition: transform .25s; }
.tile:hover { transform: translateY(-3px); }
.tile::after { content: ''; position: absolute; inset: 0; z-index: -1; background: radial-gradient(120% 80% at 100% 100%, rgba(0,0,0,.45), transparent 60%); }
@keyframes pop { from { opacity: 0; transform: scale(.92); } }
.size-m { grid-column: span 2; }
.size-l { grid-column: span 2; grid-row: span 2; }

.tile-body { position: relative; z-index: 2; height: 100%; display: flex; flex-direction: column; padding: 16px 18px; text-shadow: 0 2px 10px rgba(0,0,0,.35); }
.tile-head { padding-right: 70px; }
.tile h3 { margin: 0; font-size: 18px; line-height: 1.15; letter-spacing: -.01em; }
.size-l h3 { font-size: 30px; }
.size-s h3 { font-size: 15px; }
.sub { margin: 4px 0 0; font-size: 13px; opacity: .8; }
.size-l .sub { font-size: 16px; }
.cd { margin-top: auto; }
.cd-days { display: flex; align-items: baseline; gap: 6px; }
.cd-days .num { font-size: 52px; font-weight: 800; line-height: .9; letter-spacing: -.04em; }
.size-s .cd-days .num { font-size: 40px; }
.size-l .cd-days .num { font-size: 120px; }
.cd-days .unit { font-weight: 700; opacity: .85; }
.size-l .cd-days .unit { font-size: 26px; }
.cd-clock { display: flex; gap: 14px; margin-top: 6px; }
.size-s .cd-clock { font-size: 14px; opacity: .9; }
.cd-clock span { display: flex; align-items: baseline; gap: 3px; }
.cd-clock b { font-size: 20px; }
.size-l .cd-clock b { font-size: 34px; }
.cd-clock i { font-style: normal; font-size: 11px; opacity: .7; text-transform: uppercase; letter-spacing: .06em; }
.tickanim { display: inline-block; animation: tickin .35s ease-out; }
@keyframes tickin { from { transform: translateY(-40%); opacity: .2; } }
.cd-live { font-size: 22px; font-weight: 800; }
.date { margin: 8px 0 0; font-size: 12px; opacity: .75; }
.size-s .date { display: none; }
.est { background: rgba(0,0,0,.35); padding: 1px 6px; border-radius: 6px; cursor: help; }
.is-past { filter: saturate(.4) brightness(.7); }

.hero-emoji { position: absolute; z-index: 1; right: 14px; bottom: 10px; font-size: 64px; filter: drop-shadow(0 8px 16px rgba(0,0,0,.4)); animation: bob 3.2s ease-in-out infinite; }
.size-s .hero-emoji { font-size: 44px; right: 10px; bottom: 8px; opacity: .9; }
.size-l .hero-emoji { font-size: 150px; right: 26px; bottom: 30px; }
@keyframes bob { 50% { transform: translateY(-8px) rotate(-4deg); } }

.tile-actions { position: absolute; z-index: 3; top: 10px; right: 10px; display: flex; gap: 6px; opacity: 0; transition: opacity .2s; }
.tile:hover .tile-actions, .tile:focus-within .tile-actions { opacity: 1; }
.tile-actions .star.on { opacity: 1; }
.tile:not(:hover) .tile-actions:has(.star.on) { opacity: 1; }
.tile:not(:hover) .tile-actions:has(.star.on) .icon-btn:not(.star) { display: none; }
@media (hover: none) { .tile-actions { opacity: 1; } }

.add-tile { border: 2px dashed var(--line); background: transparent; box-shadow: none; display: grid; place-content: center; gap: 4px; color: var(--muted); font-weight: 600; }
.add-tile span { font-size: 40px; }
.add-tile:hover { color: var(--text); border-color: var(--accent); }

/* ---------- Scene / particles ---------- */
.scene { position: absolute; inset: 0; z-index: 0; overflow: hidden; pointer-events: none; }
.p { position: absolute; top: -10%; }
.snow { width: var(--s); height: var(--s); border-radius: 50%; background: #fff; animation: fall linear infinite; filter: blur(.3px); }
.fall { animation: fall linear infinite; }
@keyframes fall { to { transform: translate(30px, 130vh) rotate(360deg); } }
.tile .fall, .tile .snow, .tile .confetti { animation-name: fallTile; }
@keyframes fallTile { from { top: -10%; } to { top: 110%; transform: translateX(24px) rotate(300deg); } }
.confetti { width: 6px; height: 11px; border-radius: 2px; animation: fallTile linear infinite; }
.rise { top: auto; bottom: -10%; color: rgba(255,255,255,.75); animation: riseTile ease-in infinite; }
@keyframes riseTile { to { bottom: 110%; transform: translateX(-20px) scale(1.3); opacity: 0; } }
.smoke { top: auto; bottom: 10%; width: var(--s); height: var(--s); border-radius: 50%; background: rgba(255,255,255,.18); filter: blur(8px); animation: riseTile ease-out infinite; }
.twinkle { top: auto; color: #fff; font-size: 10px; animation: twinkle ease-in-out infinite; }
@keyframes twinkle { 0%, 100% { opacity: .1; transform: scale(.6); } 50% { opacity: .9; transform: scale(1.2); } }
.bat { left: -15%; top: 20%; font-size: 18px; animation: fly linear infinite; }
@keyframes fly { 0% { left: -15%; transform: translateY(0); } 25% { transform: translateY(-14px); } 50% { transform: translateY(8px); } 100% { left: 115%; transform: translateY(0); } }

.burst { position: absolute; width: 6px; height: 6px; border-radius: 50%; animation: burst 3.6s ease-out infinite;
  box-shadow: 0 -34px var(--c), 24px -24px var(--c), 34px 0 var(--c), 24px 24px var(--c), 0 34px var(--c), -24px 24px var(--c), -34px 0 var(--c), -24px -24px var(--c); }
@keyframes burst { 0% { transform: scale(.1); opacity: 1; } 45% { opacity: 1; } 70%, 100% { transform: scale(1.6); opacity: 0; } }

.rays { position: absolute; width: 200%; height: 200%; left: 30%; top: -60%; background: repeating-conic-gradient(rgba(255,255,255,.12) 0 8deg, transparent 8deg 20deg); animation: spin 40s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }
.wave { position: absolute; left: -50%; width: 200%; height: 40%; bottom: -18%; border-radius: 45%; background: rgba(255,255,255,.12); animation: wave 9s linear infinite; }
.wave.w2 { bottom: -24%; background: rgba(255,255,255,.08); animation-duration: 13s; }
@keyframes wave { to { transform: rotate(360deg); } }
.yardlines { position: absolute; inset: 0; background: repeating-linear-gradient(90deg, transparent 0 46px, rgba(255,255,255,.12) 46px 48px); }
.beam { position: absolute; bottom: -20%; left: 30%; width: 120px; height: 160%; transform-origin: bottom center; background: linear-gradient(to top, rgba(255,230,160,.35), transparent 80%); filter: blur(6px); animation: sweep 6s ease-in-out infinite alternate; }
.beam.b2 { left: 60%; animation-delay: -3s; }
@keyframes sweep { from { transform: rotate(-25deg); } to { transform: rotate(25deg); } }

.sleigh { position: absolute; top: 14%; left: -60%; font-size: 26px; white-space: nowrap; animation: sleigh 9s linear infinite; filter: drop-shadow(0 4px 6px rgba(0,0,0,.4)); }
.size-l .sleigh { font-size: 40px; }
.sleigh .reindeer { display: inline-block; margin-right: 2px; }
.sleigh .santa { font-size: .8em; margin-left: -14px; vertical-align: 6px; }
@keyframes sleigh { 0% { left: 110%; transform: translateY(20px) scaleX(1); } 50% { transform: translateY(-10px); } 100% { left: -60%; transform: translateY(10px); } }
.moon { position: absolute; top: 10%; right: 12%; width: 46px; height: 46px; border-radius: 50%; background: #fff7d6; box-shadow: 0 0 40px 10px rgba(255,247,214,.35); opacity: .9; }
.size-s .moon { width: 28px; height: 28px; }
.ball { position: absolute; font-size: 30px; left: -10%; top: 60%; animation: pass 4.5s cubic-bezier(.4,0,.6,1) infinite; }
@keyframes pass { 0% { left: -10%; top: 70%; transform: rotate(0); } 50% { top: 8%; } 100% { left: 110%; top: 70%; transform: rotate(720deg); } }
.plane { position: absolute; top: 18%; left: -15%; font-size: 26px; animation: planefly 10s linear infinite; }
@keyframes planefly { to { left: 115%; transform: translateY(-20px); } }
.iris { position: absolute; width: 160%; aspect-ratio: 1; left: -30%; top: -60%; border-radius: 50%; background: radial-gradient(circle, transparent 0 18%, rgba(255,255,255,.07) 18% 19%, transparent 19% 30%, rgba(255,255,255,.05) 30% 31%, transparent 31% 44%, rgba(255,255,255,.04) 44% 45%, transparent 45%); animation: spin 30s linear infinite; }
.sun-disc { position: absolute; right: 18%; top: 16%; width: 70px; height: 70px; border-radius: 50%; background: #ffd34d; box-shadow: 0 0 50px 16px rgba(255,211,77,.45); }
.moon-disc { position: absolute; inset: 0; border-radius: 50%; background: #05050a; animation: eclipse 8s ease-in-out infinite alternate; }
@keyframes eclipse { from { transform: translateX(-90%); } to { transform: translateX(0); } }
.fx-eclipse .hero-emoji, .fx-stars.tile .hero-emoji { opacity: .95; }

/* ---------- Sheets ---------- */
dialog.sheet { width: min(560px, calc(100vw - 32px)); max-height: 86vh; background: var(--panel); color: var(--text); border: 1px solid var(--line); border-radius: 24px; padding: 22px; }
dialog::backdrop { background: rgba(0,0,0,.6); backdrop-filter: blur(4px); }
.sheet header { display: flex; align-items: center; justify-content: space-between; }
.sheet h2 { margin: 0; font-size: 22px; }
.sheet h4 { margin: 18px 0 8px; color: var(--muted); font-size: 12px; text-transform: uppercase; letter-spacing: .1em; }
.browse-row { display: flex; align-items: center; gap: 12px; padding: 10px; border-radius: 16px; margin-bottom: 6px; background: linear-gradient(90deg, color-mix(in srgb, var(--c1) 35%, transparent), transparent 75%); }
.b-emoji { width: 44px; height: 44px; border-radius: 12px; display: grid; place-items: center; font-size: 24px; background: linear-gradient(145deg, var(--c1), var(--c2)); flex: none; }
.b-text { flex: 1; display: grid; }
.b-text small { color: var(--muted); }
.pill { border: 1px solid var(--line); background: rgba(255,255,255,.06); border-radius: 999px; padding: 7px 14px; font-weight: 600; font-size: 14px; }
.pill.on { background: rgba(52,211,153,.15); color: #6ee7b7; border-color: rgba(52,211,153,.35); }
#editor-form { display: grid; gap: 14px; }
.row { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.label { margin: 0; font-size: 13px; color: var(--muted); font-weight: 600; }
.theme-picker { display: grid; grid-template-columns: repeat(auto-fill, minmax(44px, 1fr)); gap: 8px; }
.theme-chip { aspect-ratio: 1; border-radius: 12px; border: 2px solid transparent; background: linear-gradient(145deg, var(--c1), var(--c2)); font-size: 22px; }
.theme-chip.on { border-color: #fff; transform: scale(1.08); }
.check { display: flex; flex-direction: row; align-items: center; gap: 8px; color: var(--text); font-weight: 500; font-size: 14px; }
.preview { position: relative; height: 110px; border-radius: 18px; overflow: hidden; background: linear-gradient(145deg, var(--c1), var(--c2)); display: grid; place-items: center; font-size: 56px; }
.preview > span { position: relative; z-index: 1; animation: bob 3s ease-in-out infinite; }
.sheet footer { display: flex; gap: 10px; margin-top: 4px; }

.toast { position: fixed; left: 50%; bottom: 24px; transform: translate(-50%, 30px); opacity: 0; background: #fff; color: #111; padding: 12px 18px; border-radius: 14px; font-weight: 600; transition: .3s; pointer-events: none; z-index: 100; max-width: calc(100vw - 32px); }
.toast.show { opacity: 1; transform: translate(-50%, 0); }

/* ---------- Wall mode (big screens) ---------- */
body.tv .topbar > :not(.brand):not(#tv-btn) { display: none; }
body.tv { --cell: 220px; }
body.tv .tile-actions { display: none; }

@media (max-width: 640px) {
  :root { --cell: 150px; --gap: 10px; }
  .topbar { padding: 12px 16px; gap: 8px; }
  .topbar .toggle, #tv-btn, #count { display: none; }
  .wall { padding: 16px; grid-template-columns: repeat(2, 1fr); }
  .size-l .cd-days .num { font-size: 80px; }
  .size-l .hero-emoji { font-size: 100px; }
  .size-l h3 { font-size: 24px; }
  .size-m .hero-emoji { font-size: 48px; }
  .cd-days .num { font-size: 40px; }
  .size-s .cd-days .num { font-size: 32px; }
  .cd-clock { gap: 8px; }
  .cd-clock b { font-size: 16px; }
  .user span { display: none; }
}
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: 0s !important; animation-iteration-count: 1 !important; }
}
