:root {
  --paper: #FBFAF7;
  --ink: #1F1C18;
  --ink-soft: #4A453E;
  --stone: #857F75;
  --line: #E4DFD5;
  --gold: #A8894F;
  --gold-deep: #8C703C;
  --panel: rgba(255, 254, 251, 0.66);
  --panel-hover: rgba(255, 254, 251, 0.82);
  --glow: rgba(168, 137, 79, 0.16);
  --trail-1: 168, 137, 79;
  --trail-2: 133, 127, 117;
  --wash: radial-gradient(120% 80% at 0% 0%, #FFFFFF 0%, rgba(255,255,255,0) 60%),
          radial-gradient(90% 70% at 100% 100%, rgba(168,137,79,0.07) 0%, rgba(168,137,79,0) 70%);
  --logo-filter: none;
  --focus: 0 0 0 2px var(--paper), 0 0 0 4px var(--gold-deep);
  color-scheme: light;
}
:root[data-theme="dark"] {
  --paper: #15130F;
  --ink: #F2EDE3;
  --ink-soft: #CFC8BB;
  --stone: #A39C90;
  --line: rgba(242, 237, 227, 0.12);
  --gold: #C9A86A;
  --gold-deep: #E0C48C;
  --panel: rgba(30, 27, 22, 0.5);
  --panel-hover: rgba(38, 34, 28, 0.66);
  --glow: rgba(201, 168, 106, 0.2);
  --trail-1: 201, 168, 106;
  --trail-2: 236, 226, 205;
  --wash: radial-gradient(90% 70% at 100% 100%, rgba(201,168,106,0.12) 0%, rgba(201,168,106,0) 65%),
          radial-gradient(80% 60% at 0% 0%, rgba(255,240,210,0.04) 0%, rgba(255,240,210,0) 70%);
  --logo-filter: invert(1) brightness(0.96);
  color-scheme: dark;
}

* { box-sizing: border-box; }
html, body { margin: 0; min-height: 100%; }
body {
  background: var(--wash), var(--paper);
  background-attachment: fixed;
  color: var(--ink);
  font: 400 17px/1.55 "Barlow", system-ui, sans-serif;
  -webkit-font-smoothing: antialiased;
  transition: background-color .5s ease, color .5s ease;
  overflow-x: hidden;
}
body.holding { cursor: grabbing; user-select: none; -webkit-user-select: none; }

#cursor-glow {
  position: fixed; left: 0; top: 0; z-index: 1; pointer-events: none; opacity: 0; transition: opacity .6s ease;
  width: 620px; height: 620px; margin: -310px 0 0 -310px; border-radius: 50%;
  background: radial-gradient(circle, rgba(var(--trail-1), .34) 0%, rgba(var(--trail-1), .12) 35%, transparent 68%);
  will-change: transform;
}
[data-theme="dark"] #cursor-glow { mix-blend-mode: screen; background: radial-gradient(circle, rgba(var(--trail-1), .26) 0%, rgba(var(--trail-1), .09) 38%, transparent 70%); }
@media (pointer: coarse) { #cursor-glow { display: none; } }
#flow { position: fixed; inset: 0; width: 100%; height: 100%; z-index: 0; pointer-events: none; }
.grain {
  position: fixed; inset: -50%; z-index: 1; pointer-events: none; opacity: .05;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='160' height='160'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='.9' numOctaves='2' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23n)'/%3E%3C/svg%3E");
}
[data-theme="dark"] .grain { opacity: .07; }

/* Top bar */
.bar {
  position: relative; z-index: 3;
  display: flex; align-items: center; justify-content: space-between; gap: 16px;
  padding: 28px clamp(16px, 5vw, 72px);
}
.brand { display: inline-flex; border-radius: 4px; }
body.signed-out .brand { visibility: hidden; } /* the big logo is the hero there */

.brand img { height: 36px; width: auto; display: block; filter: var(--logo-filter); transition: filter .5s ease; }
.hero-title { margin: 0; line-height: 0; }
.hero-logo { height: clamp(52px, 6.5vw, 84px); width: auto; filter: var(--logo-filter); transition: filter .5s ease; }
.bar-right { display: flex; align-items: center; gap: 14px; }
.who { display: flex; align-items: center; gap: 14px; font-size: 15px; color: var(--ink-soft); }
.who .name { font-weight: 500; color: var(--ink); }
.who a { color: var(--ink-soft); text-decoration: none; border-bottom: 1px solid var(--line); padding-bottom: 1px; transition: color .2s, border-color .2s; }
.who a:hover { color: var(--gold-deep); border-color: var(--gold); }

.icon-btn {
  width: 42px; height: 42px; display: grid; place-items: center;
  border: 1px solid var(--line); border-radius: 50%;
  background: var(--panel); color: var(--ink);
  backdrop-filter: blur(10px); -webkit-backdrop-filter: blur(10px);
  cursor: pointer; transition: border-color .2s, color .2s, transform .4s cubic-bezier(.2,.8,.2,1);
}
.icon-btn:hover { border-color: var(--gold); color: var(--gold-deep); transform: rotate(-20deg); }
.icon-btn svg { width: 18px; height: 18px; }

a:focus-visible, button:focus-visible { outline: none; box-shadow: var(--focus); }

/* Shared layout */
.view {
  position: relative; z-index: 2;
  padding: 0 clamp(16px, 5vw, 72px) 64px;
  min-height: calc(100vh - 96px);
  min-height: calc(100svh - 96px);
}
.display {
  font: 600 clamp(52px, 8.6vw, 132px)/0.9 "Barlow Condensed", "Arial Narrow", sans-serif;
  letter-spacing: -0.012em;
  margin: 0;
  max-width: 11ch;
  text-wrap: balance;
}
.lede { max-width: 46ch; margin: 28px 0 0; font-size: clamp(17px, 1.4vw, 20px); color: var(--ink-soft); }

/* Sign-in */
.signin { display: flex; flex-direction: column; justify-content: flex-end; min-height: inherit; padding-bottom: 6vh; }
.signin .display { color: var(--ink); }
.actions { display: flex; flex-wrap: wrap; align-items: center; gap: 14px; margin-top: 40px; }
.btn {
  display: inline-flex; align-items: center; gap: 12px;
  height: 54px; padding: 0 26px; border-radius: 999px;
  font: 500 17px/1 "Barlow", sans-serif; text-decoration: none; cursor: pointer;
  transition: transform .35s cubic-bezier(.2,.8,.2,1), background-color .25s, box-shadow .35s, border-color .25s;
}
.btn-primary { background: var(--ink); color: var(--paper); border: 1px solid var(--ink); box-shadow: 0 10px 30px -12px rgba(31,28,24,.45); }
.btn-primary:hover { transform: translateY(-2px); box-shadow: 0 18px 40px -14px rgba(140,112,60,.55); background: var(--gold-deep); border-color: var(--gold-deep); }
[data-theme="dark"] .btn-primary { color: #15130F; background: var(--gold); border-color: var(--gold); box-shadow: 0 10px 40px -12px rgba(201,168,106,.45); }
[data-theme="dark"] .btn-primary:hover { background: var(--gold-deep); border-color: var(--gold-deep); }
.btn-quiet { background: var(--panel); color: var(--ink); border: 1px solid var(--line); backdrop-filter: blur(10px); -webkit-backdrop-filter: blur(10px); }
.btn-quiet:hover { border-color: var(--gold); transform: translateY(-2px); }
.ms { width: 18px; height: 18px; display: grid; grid-template-columns: 1fr 1fr; gap: 2px; }
.ms i { background: currentColor; display: block; }
.ms i:nth-child(2), .ms i:nth-child(3) { opacity: .72; }
.ms i:nth-child(4) { opacity: .5; }
.fine { margin: 22px 0 0; font-size: 14px; color: var(--stone); max-width: 52ch; }
.notice {
  margin: 0 0 28px; padding: 12px 16px; max-width: 58ch;
  border-left: 2px solid var(--gold); background: var(--panel);
  backdrop-filter: blur(10px); -webkit-backdrop-filter: blur(10px);
  font-size: 15px; color: var(--ink-soft);
}
.notice.problem { border-left-color: #B4533F; }

/* Home */
.home { padding-top: clamp(24px, 7vh, 88px); }
.greet .display { max-width: none; font-size: clamp(48px, 7vw, 108px); }
.today { margin: 14px 0 0; color: var(--stone); font-size: 17px; }

.group-title { margin: clamp(48px, 9vh, 96px) 0 18px; font: 500 16px/1.2 "Barlow", sans-serif; color: var(--stone); }
.group-title + .group-note { margin: -10px 0 18px; font-size: 14px; color: var(--stone); }

.apps { display: grid; grid-template-columns: repeat(auto-fit, minmax(min(100%, 420px), 1fr)); gap: 20px; perspective: 1400px; }
.app {
  --mx: 50%; --my: 50%; --rx: 0deg; --ry: 0deg;
  position: relative; overflow: hidden; isolation: isolate;
  display: grid; grid-template-rows: auto 1fr auto; gap: 10px;
  min-height: 260px; padding: 30px 30px 26px;
  border: 1px solid var(--line); border-radius: 14px;
  background: var(--panel);
  backdrop-filter: blur(18px) saturate(1.1); -webkit-backdrop-filter: blur(18px) saturate(1.1);
  color: var(--ink); text-decoration: none;
  transform: rotateX(var(--rx)) rotateY(var(--ry));
  transition: transform .5s cubic-bezier(.2,.8,.2,1), border-color .3s, background-color .3s;
}
.app::before {
  content: ""; position: absolute; inset: 0; z-index: -1; opacity: 0; transition: opacity .35s;
  background: radial-gradient(520px circle at var(--mx) var(--my), var(--glow), transparent 55%);
}
.app::after {
  content: ""; position: absolute; left: 0; top: 30px; bottom: 30px; width: 2px;
  background: linear-gradient(var(--gold), transparent);
  transform: scaleY(.35); transform-origin: top; transition: transform .6s cubic-bezier(.2,.8,.2,1);
}
.app:hover, .app:focus-visible { border-color: color-mix(in srgb, var(--gold) 55%, var(--line)); background: var(--panel-hover); }
.app:hover::before, .app:focus-visible::before { opacity: 1; }
.app:hover::after, .app:focus-visible::after { transform: scaleY(1); }
.app-icon { width: 30px; height: 30px; color: var(--gold-deep); }
.app-icon svg { width: 100%; height: 100%; }
.app-name {
  align-self: end;
  font: 600 clamp(40px, 4.2vw, 60px)/0.95 "Barlow Condensed", sans-serif; letter-spacing: -0.01em;
}
.app-blurb { color: var(--ink-soft); max-width: 40ch; }
.app-foot { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding-top: 16px; border-top: 1px solid var(--line); font-size: 14px; color: var(--stone); }
.arrow { width: 22px; height: 22px; color: var(--gold-deep); transition: transform .45s cubic-bezier(.2,.8,.2,1); }
.app:hover .arrow { transform: translate(3px, -3px); }

/* Shortcut cards: same card, one size down, so the two GLN apps still lead. */
.apps-sm { grid-template-columns: repeat(auto-fill, minmax(min(100%, 200px), 1fr)); gap: 14px; }
.app-sm { min-height: 200px; padding: 20px 20px 18px; gap: 8px; grid-template-rows: auto auto 1fr; }
.app-sm .app-name { align-self: start; margin-top: 6px; }
.app-sm > span:last-child { display: flex; flex-direction: column; justify-content: space-between; gap: 12px; }
.app-sm .app-icon { width: 24px; height: 24px; }
.app-sm .app-name { font-size: clamp(26px, 2.1vw, 32px); }
.app-sm .app-blurb { font-size: 15px; }
.app-sm .app-foot { padding-top: 12px; font-size: 13px; }
.app-foot em { font-style: normal; color: var(--gold-deep); margin-left: 6px; }

.empty { margin-top: 48px; max-width: 52ch; color: var(--ink-soft); }

.foot { margin-top: clamp(56px, 10vh, 120px); font-size: 14px; color: var(--stone); }

.hint {
  position: fixed; right: clamp(16px, 5vw, 72px); bottom: 24px; z-index: 2; margin: 0;
  font-size: 13px; color: var(--stone); letter-spacing: .02em;
  opacity: 0; transition: opacity 1.2s ease 2.6s;
}
.hint.on { opacity: .85; }
body.holding .hint { opacity: 0; transition-delay: 0s; }

/* The one orchestrated entrance: headline lines rise after the letters release. */
.reveal > * { opacity: 0; transform: translateY(18px); animation: rise .9s cubic-bezier(.2,.8,.2,1) forwards; }
.reveal > :nth-child(1) { animation-delay: 1.25s; }
.reveal > :nth-child(2) { animation-delay: 1.4s; }
.reveal > :nth-child(3) { animation-delay: 1.55s; }
.reveal > :nth-child(4) { animation-delay: 1.7s; }
.reveal > :nth-child(5) { animation-delay: 1.85s; }
@keyframes rise { to { opacity: 1; transform: none; } }

@media (max-width: 640px) {
  .bar { padding-top: 20px; padding-bottom: 20px; }
  .brand img { height: 32px; }
  .who .email, .who .until { display: none; }
  .app { min-height: 220px; padding: 24px 22px 22px; }
  .hint { display: none; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: .01ms !important; animation-delay: 0s !important; transition-duration: .01ms !important; }
  .app { transform: none !important; }
}
