@import url("https://fonts.googleapis.com/css2?family=Nunito:wght@400;600;700;800&display=swap");

@font-face {
  font-family: "Waltograph";
  src: url("fonts/waltograph.otf") format("opentype");
  font-weight: normal; font-style: normal; font-display: swap;
}

:root {
  --bg: #d6ecfb;
  --panel: rgba(255, 255, 255, 0.94);
  --panel-2: #e3f3ff;
  --ink: #1b2b4d;
  --muted: #5b6d90;
  --gold: #ffd23f;
  --gold-2: #f4b400;
  --gold-ink: #1b2b4d;
  --red: #e8412f;
  --blue: #2f8fe8;
  --green: #45b649;
  --coral: #d8342a;
  --line: rgba(27, 43, 77, 0.12);
  --title-font: "Waltograph", Georgia, serif;
  --title-color: #1d4fb8;
  --radius: 16px;
  --header-h: 60px;
}

* { box-sizing: border-box; }
html, body { margin: 0; }
body {
  font-family: Nunito, system-ui, -apple-system, sans-serif;
  color: var(--ink);
  background: linear-gradient(180deg, #b9ddf6 0%, #d6ecfb 50%, #eef7fe 100%);
  background-color: var(--bg);
  background-attachment: fixed;
  min-height: 100vh;
  -webkit-font-smoothing: antialiased;
}
[hidden] { display: none !important; }

/* Bright blue sky with puffy clouds drifting by */
body::before, body::after {
  content: ""; position: fixed; inset: -20% 0; z-index: -1; pointer-events: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='640' height='360'%3E%3Cg fill='white'%3E%3Ccircle cx='70' cy='72' r='34'/%3E%3Ccircle cx='115' cy='50' r='44'/%3E%3Ccircle cx='165' cy='72' r='32'/%3E%3Crect x='40' y='70' width='160' height='36' rx='18'/%3E%3C/g%3E%3Cg transform='translate(380 210) scale(.65)'%3E%3Cg fill='white'%3E%3Ccircle cx='70' cy='72' r='34'/%3E%3Ccircle cx='115' cy='50' r='44'/%3E%3Ccircle cx='165' cy='72' r='32'/%3E%3Crect x='40' y='70' width='160' height='36' rx='18'/%3E%3C/g%3E%3C/g%3E%3C/svg%3E");
  background-repeat: repeat;
}
body::before {
  background-size: 640px 360px;
  background-position: 0 40px;
  opacity: .55;
  animation: drift 120s linear infinite;
}
body::after {
  background-size: 420px 236px;
  background-position: 300px 260px;
  opacity: .3;
  animation: drift-small 180s linear infinite;
}
@keyframes drift { from { background-position: 0 40px; } to { background-position: 640px 40px; } }
@keyframes drift-small { from { background-position: 300px 260px; } to { background-position: 720px 260px; } }
@keyframes bounce { 0%, 100% { transform: translateY(0) rotate(0deg); } 50% { transform: translateY(-3px) rotate(-12deg); } }
@media (prefers-reduced-motion: reduce) {
  body::before, body::after, .brand .sparkle, .gate-art { animation: none !important; }
}

/* Storybook title lettering */
.brand > span:nth-child(2), .gate-card h1, .empty strong {
  color: var(--title-color);
  font-kerning: normal;
  font-feature-settings: "kern", "liga";
  text-shadow: 0 1px 0 rgba(255,255,255,.8), 0 2px 10px rgba(29,79,184,.18);
}

/* Header ------------------------------------------------------------------ */
header.top {
  position: sticky; top: 0; z-index: 20;
  height: var(--header-h);
  display: grid; grid-template-columns: 1fr auto 1fr; align-items: center; gap: 18px;
  padding: 0 20px;
  background: linear-gradient(180deg, #1d4fb8 0%, #163d93 100%);
  box-shadow: 0 4px 14px rgba(10, 40, 100, .25);
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
  border-bottom: 3px solid var(--gold);
}
.brand { display: flex; align-items: center; gap: 8px; font-family: var(--title-font); font-weight: 400; font-size: 30px; white-space: nowrap; }
.brand .sparkle { color: var(--gold-2); font-size: 18px; display: inline-block; animation: bounce 2.4s ease-in-out infinite; }
.brand .sub { font-family: Nunito, sans-serif; font-weight: 700; font-size: 13px; color: #c9dbff; }
header.top .brand > span:nth-child(2) { color: #fff; text-shadow: 0 2px 8px rgba(0, 20, 70, .45); }
header.top .brand .sparkle { color: var(--gold); }
nav { display: flex; gap: 4px; }
nav a { white-space: nowrap; color: var(--muted); text-decoration: none; padding: 8px 14px; border-radius: 999px; font-weight: 800; font-size: 14px; }
nav a { color: #c9dbff; }
nav a:hover { color: #fff; }
nav .short { display: none; }
nav a.active { background: var(--red); color: #fff; box-shadow: 0 3px 0 #a8281b; }
/* Links on the left, title in the middle, you on the right */
header.top nav { grid-column: 1; grid-row: 1; justify-self: start; }
header.top .brand { grid-column: 2; grid-row: 1; justify-self: center; }
header.top .me { grid-column: 3; grid-row: 1; justify-self: end; }
.spacer { display: none; }
.me { display: flex; align-items: center; gap: 10px; font-size: 14px; color: #c9dbff; }
header.top button.ghost { color: #fff; border-color: rgba(255,255,255,.35); }
.avatar { box-shadow: none !important; padding: 0; border: 0; width: 30px; height: 30px; border-radius: 50%; display: inline-grid; place-items: center; font-size: 12px; font-weight: 700; color: #111; flex: none; }

@media (max-width: 900px) { .brand .sub { display: none; } }
@media (max-width: 640px) {
  :root { --header-h: 96px; }
  header.top { gap: 4px 10px; padding: 6px 12px; grid-template-rows: auto auto; }
  header.top .brand { grid-column: 1 / -1; grid-row: 1; }
  header.top nav { grid-row: 2; }
  header.top .me { grid-row: 2; }
  .brand .sub, .me-name, .signout, nav .long { display: none; }
  nav .short { display: inline !important; }
  .brand { font-size: 25px; }
  nav a { padding: 7px 10px; font-size: 13px; }
}

/* Buttons & inputs -------------------------------------------------------- */
button, .btn {
  font: inherit; font-weight: 800; font-size: 14px;
  border: 0; border-radius: 999px; padding: 10px 18px; cursor: pointer;
  background: var(--gold);
  color: var(--gold-ink);
  box-shadow: 0 4px 0 #d99a00;
  display: inline-flex; align-items: center; gap: 8px; text-decoration: none;
  transition: transform .08s ease, filter .15s ease;
}
button:hover, .btn:hover { filter: brightness(1.05); }
button:active { transform: translateY(2px); box-shadow: 0 2px 0 #d99a00; }
button:disabled { opacity: .5; cursor: default; }
button.ghost, .btn.ghost { background: transparent; color: var(--ink); border: 1px solid var(--line); box-shadow: none; }
button.small { padding: 6px 12px; font-size: 13px; }
button.danger { background: transparent; color: var(--coral); border: 1px solid rgba(216,52,42,.35); box-shadow: none; }

input[type=text], textarea {
  font: inherit; color: var(--ink);
  background: #fff;
  border: 2px solid #cfe3f5; border-radius: 12px;
  padding: 10px 14px; width: 100%;
}
input[type=text]:focus, textarea:focus { outline: 3px solid rgba(47,143,232,.45); outline-offset: 1px; }
textarea { resize: none; line-height: 1.4; }

/* Sign-in gate ------------------------------------------------------------ */
.gate { min-height: calc(100vh - var(--header-h)); display: grid; place-items: center; padding: 24px; }
.gate-card {
  max-width: 420px; width: 100%; text-align: center;
  background: var(--panel); border: 1px solid var(--line); border-radius: 24px;
  padding: 40px 32px; box-shadow: 0 8px 0 rgba(27,43,77,.12), 0 30px 60px rgba(20,80,150,.25);
  border: 3px solid var(--gold);
}
.gate-card h1 { font-family: var(--title-font); font-weight: 400; font-size: 54px; line-height: 1.05; margin: 8px 0 14px; }
.gate-card p { color: var(--muted); line-height: 1.55; margin: 0 0 24px; }
.gate-art { font-size: 48px; color: var(--gold-2); display: inline-block; animation: bounce 2.4s ease-in-out infinite; }
button.google { background: #fff; color: #1f1f1f; padding: 12px 22px; border: 2px solid #dbe4ee; box-shadow: 0 3px 0 #dbe4ee; }
button.google .g { font-weight: 800; color: #4285f4; font-size: 16px; }

/* Main -------------------------------------------------------------------- */
main { max-width: 1120px; margin: 0 auto; padding: 24px 20px 80px; }

/* Upload bar */
.upload {
  display: flex; flex-wrap: wrap; gap: 12px; align-items: center;
  background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius);
  padding: 14px; margin-bottom: 18px;
}
.upload input[type=text] { flex: 1 1 240px; }
.upload .status { flex-basis: 100%; font-size: 13px; color: var(--muted); min-height: 0; }
.upload .status:empty { display: none; }

.toolbar { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; margin-bottom: 16px; }
.chip { box-shadow: none; font: inherit; font-size: 13px; font-weight: 800; border-radius: 999px; padding: 6px 12px; background: rgba(255,255,255,.85); color: var(--muted); border: 1px solid var(--line); cursor: pointer; }
.chip.on { background: var(--blue); color: #fff; border-color: var(--blue); }
.count { margin-left: auto; color: var(--ink); font-weight: 700; font-size: 13px; }

/* Grid */
.grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(190px, 1fr)); gap: 10px; }
@media (max-width: 520px) { .grid { grid-template-columns: repeat(3, 1fr); gap: 4px; } .tile { border-radius: 8px !important; } .tile .cap { display: none; } }
.tile {
  position: relative; aspect-ratio: 1; overflow: hidden; padding: 0;
  border-radius: 14px; background: var(--panel-2); cursor: pointer; border: 0; box-shadow: 0 4px 12px rgba(20,80,150,.2);
}
.tile img { width: 100%; height: 100%; object-fit: cover; display: block; transition: transform .3s ease; }
.tile:hover img { transform: scale(1.04); }
.tile .cap {
  position: absolute; inset: auto 0 0 0; padding: 26px 10px 8px;
  background: linear-gradient(transparent, rgba(0,0,0,.7));
  color: #fff; font-size: 12px; text-align: left; font-weight: 500;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.tile:hover { box-shadow: 0 0 0 3px var(--gold), 0 8px 20px rgba(20,80,150,.3); }
.tile .badge {
  position: absolute; top: 8px; right: 8px;
  background: rgba(0,0,0,.6); color: #fff; font-size: 12px; font-weight: 600;
  padding: 3px 8px; border-radius: 999px;
}
.empty { text-align: center; color: var(--muted); background: var(--panel); padding: 60px 20px; border: 3px dashed #9fd0f5; border-radius: var(--radius); }
.empty strong { display: block; font-family: var(--title-font); font-weight: 400; font-size: 34px; margin-bottom: 6px; }

/* Lightbox */
.lightbox {
  position: fixed; inset: 0; z-index: 50;
  background: rgba(12, 30, 60, .97);
  display: grid; grid-template-columns: 1fr 360px;
}
.lb-stage { position: relative; display: grid; place-items: center; min-height: 0; padding: 20px 60px; }
.lb-stage img { max-width: 100%; max-height: calc(100vh - 40px); object-fit: contain; border-radius: 8px; }
.lb-nav { position: absolute; top: 50%; transform: translateY(-50%); background: rgba(255,255,255,.1); color: #fff; width: 44px; height: 44px; padding: 0; justify-content: center; font-size: 22px; }
.lb-prev { left: 10px; } .lb-next { right: 10px; }
.lb-close { position: absolute; top: 12px; left: 12px; background: rgba(255,255,255,.1); color: #fff; width: 40px; height: 40px; padding: 0; justify-content: center; font-size: 20px; z-index: 2; }
.lb-side { background: var(--panel); border-left: 1px solid var(--line); display: flex; flex-direction: column; min-height: 0; }
.lb-head { padding: 18px; border-bottom: 1px solid var(--line); }
.lb-caption { font-size: 16px; font-weight: 600; margin: 0 0 4px; white-space: pre-wrap; }
.lb-meta { font-size: 13px; color: var(--muted); }
.lb-actions { display: flex; gap: 8px; margin-top: 12px; flex-wrap: wrap; }
.comments { flex: 1; overflow-y: auto; padding: 14px 18px; display: flex; flex-direction: column; gap: 14px; }
.comments .none { color: var(--muted); font-size: 14px; }
.comment { display: flex; gap: 10px; }
.comment .who { font-weight: 600; font-size: 13px; }
.comment .when { color: var(--muted); font-size: 12px; margin-left: 6px; font-weight: 400; }
.comment .text { font-size: 14px; line-height: 1.45; white-space: pre-wrap; word-break: break-word; margin-top: 2px; }
.comment .del { background: none; color: var(--muted); padding: 0 4px; font-size: 12px; margin-left: 6px; }
.comment-form { display: flex; gap: 8px; padding: 12px 18px 18px; border-top: 1px solid var(--line); }

@media (max-width: 860px) {
  .lightbox { grid-template-columns: 1fr; grid-template-rows: minmax(0, 55vh) minmax(0, 1fr); }
  .lb-stage { padding: 10px; }
  .lb-stage img { max-height: calc(55vh - 20px); }
  .lb-side { border-left: 0; border-top: 1px solid var(--line); }
}

/* Chat -------------------------------------------------------------------- */
main.chat { display: flex; flex-direction: column; height: calc(100dvh - var(--header-h)); padding-top: 0; padding-bottom: 0; max-width: 820px; }
.online { font-size: 13px; font-weight: 700; color: var(--ink); padding: 12px 0; border-bottom: 1px solid var(--line); display: flex; align-items: center; gap: 8px; }
.online .dot { width: 8px; height: 8px; border-radius: 50%; background: #4ade80; box-shadow: 0 0 8px #4ade80; }
.messages { flex: 1; overflow-y: auto; padding: 16px 2px; display: flex; flex-direction: column; gap: 2px; }
.day { align-self: center; font-size: 12px; font-weight: 800; color: var(--ink); background: rgba(255,255,255,.85); padding: 4px 12px; border-radius: 999px; margin: 14px 0 8px; }
.msg { display: flex; gap: 8px; align-items: flex-end; max-width: 78%; }
.msg.mine { align-self: flex-end; flex-direction: row-reverse; }
.msg .avatar { width: 28px; height: 28px; font-size: 11px; }
.msg .avatar.ghosted { visibility: hidden; }
.bubble { background: #fff; box-shadow: 0 2px 0 rgba(27,43,77,.1); padding: 8px 12px; border-radius: 18px; border-bottom-left-radius: 6px; }
.msg.mine .bubble { background: var(--gold); color: var(--gold-ink); border-bottom-left-radius: 18px; border-bottom-right-radius: 6px; }
.bubble .name { font-size: 13px; font-weight: 800; margin-bottom: 2px; }
.msg.mine .bubble .name { color: #7a5200; }
.bubble .text { white-space: pre-wrap; word-break: break-word; line-height: 1.4; font-size: 15px; }
.bubble .time { font-size: 11px; opacity: .6; margin-top: 3px; text-align: right; }
.msg.first { margin-top: 10px; }
.composer { display: flex; gap: 8px; align-items: flex-end; padding: 12px 0 max(16px, env(safe-area-inset-bottom)); border-top: 1px solid var(--line); }
.composer textarea { max-height: 140px; border-radius: 22px; box-shadow: 0 2px 0 rgba(27,43,77,.08); }
.composer button { height: 44px; }
.loading { color: var(--muted); text-align: center; padding: 40px; font-size: 14px; }

/* Demo banner */
.demo-bar { background: var(--red); color: #fff; text-align: center; font-size: 13px; font-weight: 600; padding: 7px 12px; }
body.demo main.chat { height: calc(100dvh - var(--header-h) - 30px); }

/* Access requests --------------------------------------------------------- */
.nav-badge {
  display: inline-grid; place-items: center; min-width: 19px; height: 19px; padding: 0 5px; margin-left: 6px;
  border-radius: 999px; background: var(--gold); color: var(--gold-ink); font-size: 11px; font-weight: 800; line-height: 1;
}
.gate-note { margin: -6px 0 16px; text-align: left; }
.gate-actions { display: flex; flex-wrap: wrap; gap: 10px; justify-content: center; }
.gate-msg { margin-top: 12px; font-size: 13px; color: var(--muted); min-height: 1em; }
.gate-msg:empty { display: none; }

main.requests { max-width: 720px; }
.page-title { font-family: var(--title-font); font-weight: 400; font-size: 34px; color: var(--title-color); margin: 4px 0 4px; }
.page-intro { color: var(--muted); margin: 0 0 18px; line-height: 1.5; }
.req-status { background: #fff7d6; border: 1px solid #f3d77a; color: var(--gold-ink); border-radius: 12px; padding: 10px 14px; margin-bottom: 14px; font-weight: 700; font-size: 14px; }
.req-status:empty { display: none; }
.req-list { display: flex; flex-direction: column; gap: 10px; }
.req-card {
  display: flex; gap: 12px; align-items: flex-start;
  background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius);
  padding: 14px; box-shadow: 0 4px 12px rgba(20,80,150,.12);
}
.req-card .avatar { width: 38px; height: 38px; font-size: 14px; }
.req-info { flex: 1; min-width: 0; }
.req-name { font-weight: 800; }
.req-email { font-size: 14px; color: var(--muted); word-break: break-all; }
.req-note { margin-top: 6px; font-size: 14px; background: var(--panel-2); border-radius: 10px; padding: 6px 10px; white-space: pre-wrap; word-break: break-word; }
.req-when { margin-top: 6px; font-size: 12px; color: var(--muted); }
.req-actions { display: flex; flex-direction: column; gap: 8px; }
.req-declined { margin-top: 22px; }
.req-declined summary { cursor: pointer; font-weight: 800; color: var(--muted); margin-bottom: 10px; }
@media (max-width: 520px) {
  .req-card { flex-wrap: wrap; }
  .req-actions { flex-direction: row; width: 100%; }
  .req-actions button { flex: 1; justify-content: center; }
}

/* Videos -------------------------------------------------------------------- */
.setup-card {
  background: var(--panel); border: 3px solid var(--gold); border-radius: var(--radius);
  padding: 22px; margin-bottom: 18px; text-align: center;
}
.setup-card strong { display: block; font-family: var(--title-font); font-weight: 400; font-size: 28px; color: var(--title-color); margin-bottom: 6px; }
.setup-card p { color: var(--muted); line-height: 1.5; margin: 0 auto 14px; max-width: 520px; }
.setup-card .setup-error { color: var(--coral); font-weight: 700; margin: 14px auto 0; }
.upload-progress { flex-basis: 100%; height: 8px; border-radius: 999px; background: var(--panel-2); overflow: hidden; }
.upload-progress-bar { height: 100%; width: 0; background: linear-gradient(90deg, var(--gold), var(--gold-2)); transition: width .2s ease; }
.drive-link { flex-basis: 100%; font-size: 13px; font-weight: 700; color: var(--blue); text-decoration: none; }
.drive-link:hover { text-decoration: underline; }
.video-tile video, .video-tile img { width: 100%; height: 100%; object-fit: cover; display: block; }
.video-tile .play {
  position: absolute; top: 50%; left: 50%; transform: translate(-50%, -50%);
  width: 52px; height: 52px; border-radius: 50%; display: grid; place-items: center;
  background: rgba(0, 0, 0, .5); color: #fff; font-size: 20px; padding-left: 4px; pointer-events: none;
}
.video-placeholder {
  position: absolute; inset: 0; display: grid; place-items: center; padding-top: 70px;
  background: linear-gradient(135deg, #1d4fb8, #6cc4ff); color: #fff; font-size: 12px; font-weight: 700;
}
.video-frame { width: 100%; height: 100%; display: grid; place-items: center; }
.video-frame iframe, .video-frame video { width: 100%; height: min(100%, calc(100vh - 40px)); border: 0; border-radius: 8px; background: #000; }
.video-lb .lb-stage { padding: 60px 20px 20px; }
.video-hint { font-size: 12px; color: var(--muted); margin: 12px 0 0; line-height: 1.4; }
@media (max-width: 860px) {
  .video-frame iframe, .video-frame video { height: calc(55vh - 70px); }
}
