/* The iOS Native theme's depth on the web. The sky (NativeSky) is the one thing behind everything;
   Liquid Glass sits only on controls, navigation and sheets, as on iOS. Cards stay opaque. */
:root {
  --glass-tint: rgb(255 255 255 / .58);
  --glass-ink: var(--ink);
  --glass-soft-ink: var(--muted);
  --glass-blur: blur(22px) saturate(190%);
  --glass-edge: inset 0 1px 0 rgb(255 255 255 / .8), inset 0 0 0 .5px rgb(255 255 255 / .4), inset 0 -1px 0 rgb(20 30 60 / .04);
  --glass-lift: 0 10px 30px rgb(20 30 60 / .13), 0 1px 2px rgb(20 30 60 / .06);
  --spring: cubic-bezier(.3, 1.6, .5, 1);
}
:root[data-sky="dark"] {
  /* On a dark sky the header takes light text and dark glass. */
  --on-sky-tint: rgb(20 24 60 / .5);
  --on-sky-ink: #fff;
  --on-sky-soft-ink: #ffffffc7;
  --on-sky-edge: inset 0 1px 0 rgb(255 255 255 / .22), inset 0 0 0 .5px rgb(255 255 255 / .14);
}

/* Small text on the sky takes whichever colour sky.js found more readable there. */
:root[data-sky-text="dark"] { --sky-small-text: #123a63; --sky-small-shadow: none; }
:root[data-sky-text="light"] { --sky-small-text: #fff; --sky-small-shadow: 0 1px 6px rgb(0 10 40 / .45); }

/* The sky. */
#sky {
  display: none;
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  z-index: 0;
  height: 320px;
  overflow: hidden;
  pointer-events: none;
  /* The top colour holds behind the white title, then opens toward the horizon. */
  background: linear-gradient(180deg, var(--sky-top) 0, var(--sky-top) 38%, var(--sky-bottom) 100%);
  transition: height .5s cubic-bezier(.2, .9, .3, 1);
}
body[data-surface] #sky { display: block; }
#app { position: relative; z-index: 1; }
.sky-stars { position: absolute; inset: 0; opacity: var(--sky-night); }
.sky-stars-deep { opacity: var(--sky-deep); }
.sky-glow {
  position: absolute;
  inset: 0;
  opacity: var(--sky-twilight);
  background: radial-gradient(70vw 100% at var(--sky-glow-x) 100%, color-mix(in srgb, var(--sky-glow) 55%, transparent), transparent);
}
.sky-band { position: absolute; top: env(safe-area-inset-top, 0); left: 0; right: 0; height: 100px; }
.sky-body { position: absolute; top: 0; left: 0; display: grid; place-items: center; }
.sky-body[hidden] { display: none; }
.sky-sun { color: var(--sun-color); width: 46px; height: 46px; background: radial-gradient(closest-side, rgb(255 255 255 / .9) 30%, rgb(255 255 255 / 0)); border-radius: 50%; }
.sky-sun-rays { display: grid; animation: sky-turn 60s linear infinite; }
.sky-moon { color: #fffbea; filter: drop-shadow(0 0 8px rgb(255 251 234 / .6)); }
.sky-clouds { position: absolute; inset: 12px 0 0; color: var(--cloud-color); opacity: var(--cloud-opacity); filter: blur(var(--cloud-blur)); }
.sky-cloud { position: absolute; animation: sky-drift 14s ease-in-out infinite alternate; will-change: transform; }
.sky-cloud svg { display: block; width: 100%; height: auto; opacity: .92; filter: drop-shadow(0 2px 4px rgb(0 0 0 / .08)); }
.sky-shooting-star { display: none; position: absolute; top: 34px; left: 42%; width: 90px; height: 2px; border-radius: 1px; background: linear-gradient(90deg, transparent, rgb(255 255 255 / .3), rgb(255 255 255 / .5), #fff); animation: sky-shoot 11.6s linear infinite; }
#sky[data-shooting-star="on"] .sky-shooting-star { display: block; }
.sky-hills { position: absolute; left: 0; bottom: -1px; width: 100%; height: clamp(56px, 6vw, 86px); }
@keyframes sky-turn { to { transform: rotate(360deg); } }
@keyframes sky-drift { from { transform: translateX(var(--from)); } to { transform: translateX(var(--to)); } }
@keyframes sky-shoot {
  0%, 34.4% { opacity: 0; transform: rotate(22deg) translateX(-120px); }
  34.5% { opacity: 1; transform: rotate(22deg) translateX(-120px); }
  48.3%, 100% { opacity: 0; transform: rotate(22deg) translateX(260px); }
}

/* Heading on the sky. */
.app-shell main { padding-top: 34px; }
.app-shell .page-heading { align-items: center; margin-bottom: clamp(70px, 7vw, 100px); }
.page-heading h1, .page-heading h1 .blue-text { color: #fff; text-shadow: 0 1px 12px rgb(0 20 60 / .32); }
.page-heading .date-caption, .page-heading .lead, .page-heading .back-link { color: var(--sky-small-text); text-shadow: var(--sky-small-shadow); }
.date-caption { text-transform: none; }
.date-caption::first-letter { text-transform: uppercase; }

/* Glass. */
.sidebar, .header-actions, .mobile-nav, .page-heading .icon-button, .page-heading .date-field, .plan-pill, .btn-outline, .btn-soft {
  background: var(--glass-tint);
  -webkit-backdrop-filter: var(--glass-blur);
  backdrop-filter: var(--glass-blur);
  box-shadow: var(--glass-edge), var(--glass-lift);
  border: 0;
}

/* Sidebar: a floating pane. The sky passes behind its top, the page behind the rest. */
.sidebar {
  --glass-tint: rgb(255 255 255 / .74);
  inset-block: 12px; inset-inline: 12px auto;
  width: calc(var(--sidebar) - 12px);
  border-radius: 30px;
}
:root[data-sky="dark"] .sidebar { --glass-tint: rgb(255 255 255 / .84); }
.sidebar .nav-item { color: #3a3a40; }
.sidebar .nav-item:hover { background: rgb(255 255 255 / .55); color: var(--ink); }
.nav-item { transition: background .16s, color .16s, transform .35s var(--spring); }
.nav-item:active { transform: scale(.98); }

/* Status and avatar: a capsule that stays over the page while it scrolls. */
.app-header {
  position: sticky;
  top: max(12px, env(safe-area-inset-top));
  z-index: 14;
  height: auto;
  margin-top: 12px;
  padding: 0 16px;
  border: 0;
  background: none;
  justify-content: flex-end;
  pointer-events: none;
}
.header-title { display: none; }
.header-actions { display: flex; align-items: center; gap: 10px; padding: 4px 4px 4px 14px; border-radius: 999px; pointer-events: auto; }
.app-header .avatar { width: 38px; height: 38px; }
.app-header .sync-status { color: var(--glass-soft-ink); font-size: .9375rem; }
:root[data-sky="dark"] .header-actions, :root[data-sky="dark"] .page-heading .icon-button, :root[data-sky="dark"] .page-heading .date-field {
  background: var(--on-sky-tint);
  box-shadow: var(--on-sky-edge), var(--glass-lift);
  color: var(--on-sky-ink);
  color-scheme: dark;
}
:root[data-sky="dark"] .app-header .sync-status { color: var(--on-sky-soft-ink); }
:root[data-sky="dark"] .header-actions { background: rgb(20 24 60 / .72); }

/* Day picker on the sky. */
.page-heading .day-picker { gap: 8px; }
.page-heading .icon-button { width: 44px; height: 44px; border-radius: 50%; }
.page-heading .date-field { min-height: 44px; border-radius: 999px; padding-inline: 14px; }
.page-heading .date-field { position: relative; }
.page-heading .date-field input { color: inherit; background: none; }
/* The browser's own calendar icon stays clickable over the whole capsule, but only our icon shows. */
.page-heading .date-field input::-webkit-calendar-picker-indicator { position: absolute; inset: 0; width: auto; height: auto; margin: 0; opacity: 0; cursor: pointer; }
.page-heading :focus-visible { outline-color: #fff; }

/* Buttons: the main one is tinted glass, the rest clear glass, and all of them answer a press with a spring. */
.btn { transition: transform .35s var(--spring), filter .16s, box-shadow .16s; }
.btn:active:not(:disabled) { transform: scale(.98); }
.btn-yellow, .btn-ink {
  background: linear-gradient(180deg, #1dc066, #14a653);
  box-shadow: inset 0 1px 0 rgb(255 255 255 / .42), inset 0 -1px 0 rgb(0 0 0 / .08), 0 6px 16px rgb(22 176 90 / .3);
}
.btn-yellow:hover, .btn-ink:hover { background: linear-gradient(180deg, #1dc066, #14a653); filter: brightness(.96); }
.btn-outline, .btn-soft { color: var(--accent-ink); }
.btn-outline:hover, .btn-soft:hover { color: var(--accent-ink); background: rgb(255 255 255 / .82); }
.plan-pill { color: var(--muted); transition: transform .35s var(--spring); }
.plan-pill:active { transform: scale(.98); }
.icon-button, .round-button { transition: transform .35s var(--spring), filter .16s; }
.icon-button:active:not(:disabled), .round-button:active:not(:disabled) { transform: scale(1.08); }
.round-button, .btn-tint { box-shadow: inset 0 1px 0 rgb(255 255 255 / .55); }

/* Cards stay opaque; each one casts the colour of its tile, like the iOS float tiles. */
.panel, .friend-card, .together-panel > details, .together-panel .social-self {
  box-shadow: 0 10px 34px color-mix(in srgb, var(--tint, #3a4570) 12%, transparent), 0 1px 2px rgb(0 0 0 / .04);
}
.together-panel { box-shadow: none; }
.social-tabs .btn[aria-current="page"] { box-shadow: inset 0 1px 0 rgb(255 255 255 / .55); }

/* The last yellow from the old theme: selected and highlighted things use the accent, as on iOS. */
.plan-options label:has(input:checked) { background: var(--accent-soft); border-color: var(--accent); }
.user-message { background: var(--accent-soft); }
.club-icon { background: var(--accent-soft); }
.stat-yellow { background: var(--accent-soft); border-color: transparent; }
.is-me { background: var(--accent-soft); }
.report-hero.is-over { background: #ff950022; }

/* Sheets. */
dialog {
  border: 0;
  border-radius: 32px;
  background: rgb(255 255 255 / .8);
  -webkit-backdrop-filter: blur(34px) saturate(190%);
  backdrop-filter: blur(34px) saturate(190%);
  box-shadow: inset 0 1px 0 rgb(255 255 255 / .9), 0 30px 90px rgb(20 30 60 / .28);
}
dialog[open] { animation: sheet-in .42s cubic-bezier(.2, 1.15, .35, 1); }
dialog::backdrop { background: rgb(15 18 40 / .3); -webkit-backdrop-filter: blur(5px); backdrop-filter: blur(5px); }
@keyframes sheet-in { from { opacity: 0; transform: translateY(14px) scale(.97); } }

#toast {
  /* A popover, so it stays above an open dialog; these undo the browser's popover styles. */
  margin: 0;
  border: 0;
  overflow: visible;
  border-radius: 999px;
  background: rgb(28 28 34 / .74);
  -webkit-backdrop-filter: blur(20px) saturate(180%);
  backdrop-filter: blur(20px) saturate(180%);
  box-shadow: inset 0 1px 0 rgb(255 255 255 / .16), 0 10px 30px rgb(20 30 60 / .25);
}

/* Sign-in: the same sky on the left, the form on the page background. */
body[data-surface="auth"] #sky { right: auto; transition: none; }
/* The white wordmark sits where the two left clouds drift. */
body[data-surface="auth"] .sky-cloud:nth-child(-n+2) { display: none; }
.auth-layout { background: none; }
.auth-story { background: none; }
.auth-story h1, .auth-story h1 .blue-text { color: #fff; text-shadow: 0 1px 12px rgb(0 20 60 / .32); }
.auth-story p { color: var(--sky-small-text); text-shadow: var(--sky-small-shadow); }
.auth-story .wordmark { color: #fff; }
.auth-sticker {
  border: 0;
  border-radius: 999px;
  background: var(--glass-tint);
  -webkit-backdrop-filter: var(--glass-blur);
  backdrop-filter: var(--glass-blur);
  box-shadow: var(--glass-edge), var(--glass-lift);
}

/* Phones: a floating tab bar with the AI tab as a filled accent circle. */
@media (max-width: 767px) {
  .app-header { position: static; margin-top: max(10px, env(safe-area-inset-top)); padding: 0 12px; }
  .app-shell main { padding-top: 22px; }
  .app-shell .page-heading { flex-direction: column; align-items: stretch; gap: 16px; margin-bottom: 66px; }
  .page-heading .day-picker { justify-content: flex-start; }
  .mobile-nav {
    inset-inline-start:12px;
    inset-inline-end:12px;
    bottom: max(12px, env(safe-area-inset-bottom));
    padding: 5px;
    border-radius: 34px;
    --glass-tint: rgb(255 255 255 / .62);
  }
  .mobile-nav .nav-item { min-height: 58px; justify-content: center; gap: 3px; border-radius: 28px; font-size: .6875rem; }
  .mobile-nav .nav-item.active { background: rgb(22 176 90 / .13); }
  /* Icons are masks, so the circle has to be a separate layer behind the glyph. */
  .mobile-nav .nav-item[href="#chat"] { position: relative; isolation: isolate; }
  .mobile-nav .nav-item[href="#chat"]::before { content: ""; position: absolute; z-index: -1; top: 5px; left: 50%; width: 32px; height: 32px; margin-left: -16px; border-radius: 50%; background: var(--accent); box-shadow: inset 0 1px 0 rgb(255 255 255 / .4), 0 3px 8px rgb(22 176 90 / .35); }
  .mobile-nav .nav-item[href="#chat"] .icon, .mobile-nav .nav-item[href="#chat"].active .icon { color: #fff; }
  .mobile-nav .nav-item[href="#chat"].active { background: none; color: var(--accent-ink); }
  .app-footer { padding-bottom: calc(var(--mobile-nav-space, 80px) + 34px + env(safe-area-inset-bottom)); }
  .auth-story { padding-bottom: 72px; }
}

/* Without backdrop-filter glass would be see-through: use a solid surface instead. */
@supports not ((backdrop-filter: blur(1px)) or (-webkit-backdrop-filter: blur(1px))) {
  :root { --glass-tint: rgb(255 255 255 / .96); }
  dialog { background: #fff; }
  #toast { background: rgb(28 28 34 / .96); }
}

@media (prefers-reduced-motion: reduce) {
  .sky-sun-rays, .sky-cloud, .sky-shooting-star, dialog[open] { animation: none; }
  .sky-shooting-star { display: none !important; }
  #sky { transition: none; }
  .btn, .nav-item, .plan-pill, .icon-button, .round-button { transition: none; }
  .btn:active:not(:disabled), .nav-item:active, .plan-pill:active, .icon-button:active:not(:disabled), .round-button:active:not(:disabled) { transform: none; }
}

/* Chat reads like a messenger: one comfortable column, not the whole window. */
:has(> .chat-panel) > .page-heading, .chat-panel { width: 100%; max-width: 720px; margin-inline: auto; }
.chat-messages { margin-inline: -14px; padding-inline: 14px; scrollbar-width: thin; }
.chat-compose textarea { scrollbar-width: none; }
.chat-toolbar { padding-inline: 0; align-items: center; }
