:root {
  --bg: #fbfbfa;
  --fg: #1c1d1f;
  --muted: #62666d;
  --accent: #1f6feb;
  --card: #ffffff;
  --line: #e4e5e7;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #121316;
    --fg: #ececee;
    --muted: #9a9ea6;
    --accent: #6aa3ff;
    --card: #1a1b1f;
    --line: #2a2c31;
  }
}
* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--fg);
  font: 17px/1.65 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
}
main { max-width: 42rem; margin: 0 auto; padding: 4rem 1rem 3rem; }
header { margin-bottom: 2.5rem; }
.eyebrow { margin: 0 0 .5rem; color: var(--accent); font-weight: 600; letter-spacing: .04em; font-size: .9rem; }
h1 { margin: 0; font-size: clamp(2.2rem, 7vw, 3.2rem); line-height: 1.1; letter-spacing: -.02em; }
.lede { margin: .8rem 0 0; color: var(--muted); font-size: 1.15rem; }
section {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 1.25rem 1.4rem;
  margin: 0 0 1.1rem;
}
h2 { margin: 0 0 .5rem; font-size: 1.15rem; }
p { margin: .5rem 0; }
code {
  font: 1rem ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  background: var(--bg);
  border: 1px solid var(--line);
  border-radius: 6px;
  padding: .2rem .5rem;
}
button {
  font: inherit; font-size: .9rem;
  margin-left: .4rem; padding: .25rem .7rem;
  border: 1px solid var(--line); border-radius: 6px;
  background: var(--bg); color: var(--fg); cursor: pointer;
}
button:hover { border-color: var(--accent); }
a { color: var(--accent); }
a:focus-visible, button:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
footer { margin-top: 2rem; color: var(--muted); font-size: .9rem; }

/* login dialog */
button.primary { background: var(--accent); border-color: var(--accent); color: #fff; margin-left: 0; padding: .55rem 1.5rem; font-size: 1rem; font-weight: 600; }
button.primary:hover { filter: brightness(1.08); }
button.primary:disabled { opacity: .6; cursor: wait; }
button.ghost { background: transparent; }
dialog { border: 1px solid var(--line); border-radius: 14px; background: var(--card); color: var(--fg); padding: 1.5rem; width: min(24rem, calc(100vw - 2rem)); }
dialog::backdrop { background: rgba(0, 0, 0, .55); }
dialog h2 { margin-top: 0; }
dialog input { width: 100%; font: inherit; padding: .6rem .7rem; border: 1px solid var(--line); border-radius: 8px; background: var(--bg); color: var(--fg); }
dialog input:focus-visible { outline: 2px solid var(--accent); outline-offset: 1px; }
.row { display: flex; justify-content: flex-end; gap: .6rem; margin-top: 1rem; }
.row button { margin-left: 0; }
.hint { color: var(--muted); margin-top: 0; }
.error { color: #cf222e; margin: .6rem 0 0; font-size: .92rem; }
@media (prefers-color-scheme: dark) { .error { color: #ff7b72; } }
.sr { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }

/* ---- top navigation bar ---- */
.topnav { position: sticky; top: 0; z-index: 10; display: flex; align-items: center; justify-content: space-between; gap: 1.5rem; height: 4rem;
  padding: 0 clamp(1rem, 3vw, 3rem); background: var(--card); border-bottom: 1px solid var(--line); }
.brand { font-size: 1.1rem; font-weight: 700; text-decoration: none; color: var(--fg); letter-spacing: -.01em; }
.nav-right { display: flex; align-items: center; gap: .75rem; }
.account { position: relative; }
.account-btn { display: flex; align-items: center; gap: .5rem; margin: 0; padding: .25rem .6rem .25rem .3rem; border: 1px solid transparent; border-radius: 99px; background: transparent; color: var(--fg); font: inherit; font-size: .92rem; cursor: pointer; }
.account-btn:hover, .account-btn[aria-expanded="true"] { border-color: var(--line); }
.avatar { display: inline-flex; align-items: center; justify-content: center; width: 1.8rem; height: 1.8rem; border-radius: 50%; background: var(--accent); color: #fff; font-weight: 600; font-size: .85rem; }
.menu { position: absolute; right: 0; top: calc(100% + .4rem); min-width: 12rem; padding: .3rem; background: var(--card); border: 1px solid var(--line); border-radius: 10px; box-shadow: 0 8px 24px rgba(0, 0, 0, .2); z-index: 30; }
.menu[hidden] { display: none; }
.menu-who { display: flex; flex-direction: column; padding: .5rem .7rem; border-bottom: 1px solid var(--line); margin-bottom: .3rem; }
.menu-item { display: block; width: 100%; margin: 0; text-align: left; border: 0; background: transparent; padding: .5rem .7rem; border-radius: 6px; font: inherit; cursor: pointer; color: var(--fg); }
.menu-item:hover { background: color-mix(in srgb, var(--accent) 10%, transparent); }
@media (max-width: 30rem) { .account-name { display: none; } }

/* ---- left side nav (signed-in pages) ---- */
.sidenav { position: fixed; top: 4rem; bottom: 0; left: 0; width: 13.5rem; display: flex; flex-direction: column; gap: .2rem; padding: 1rem .75rem;
  background: var(--card); border-right: 1px solid var(--line); overflow-y: auto; }
.sidenav a { display: block; padding: .55rem .8rem; border-radius: 8px; border-left: 3px solid transparent; color: var(--muted); text-decoration: none; font-weight: 500; }
.sidenav a:hover { color: var(--fg); background: color-mix(in srgb, var(--accent) 7%, transparent); }
.sidenav a[aria-current="page"] { color: var(--fg); font-weight: 600; border-left-color: var(--accent); background: color-mix(in srgb, var(--accent) 12%, transparent); }
body.has-side main, body.has-side main.wide { max-width: none; margin: 0 0 0 13.5rem; }
@media (max-width: 48rem) {
  .sidenav { position: static; width: auto; flex-direction: row; flex-wrap: wrap; padding: .5rem 1rem; border-right: 0; border-bottom: 1px solid var(--line); }
  body.has-side main, body.has-side main.wide { margin-left: 0; }
}

/* ---- signed-out home page ---- */
body.home { background:
  radial-gradient(70rem 28rem at 15% -8%, color-mix(in srgb, var(--accent) 15%, transparent), transparent),
  radial-gradient(50rem 24rem at 95% 10%, color-mix(in srgb, var(--accent) 8%, transparent), transparent), var(--bg); background-attachment: fixed; }
.home .topnav { background: color-mix(in srgb, var(--card) 85%, transparent); backdrop-filter: blur(8px); }
.topnav button.primary { margin: 0; padding: .55rem 1.5rem; font-size: .95rem; border-radius: 8px; line-height: 1.2; }
.home main { max-width: none; margin: 0; padding: clamp(2.5rem, 8vh, 6rem) clamp(1rem, 3vw, 3rem) 3rem; }
.home-grid { display: grid; gap: clamp(1.8rem, 4vw, 3rem); }
.hero h1 { font-size: clamp(2.8rem, 6vw, 5rem); }
.hero .lede { font-size: clamp(1.15rem, 1.6vw, 1.4rem); max-width: 34rem; }
.hero .about { max-width: 30rem; color: var(--muted); margin-top: 1.2rem; }
.tiles { display: grid; grid-template-columns: 1fr; gap: 1.1rem; align-content: start; }
@media (min-width: 40rem) { .tiles { grid-template-columns: repeat(2, 1fr); } .tile-wide { grid-column: span 2; } }
@media (min-width: 64rem) {
  .home main { padding-top: clamp(3rem, 10vh, 7rem); }
  .home-grid { grid-template-columns: minmax(20rem, 5fr) 7fr; align-items: center; }
  .hero { position: sticky; top: 6rem; }
}
.tile { margin: 0; padding: 1.4rem 1.5rem 1.5rem; transition: border-color .15s, transform .15s; }
.tile:hover { border-color: color-mix(in srgb, var(--accent) 55%, var(--line)); transform: translateY(-2px); }
.tile .ico { display: inline-flex; width: 2.6rem; height: 2.6rem; align-items: center; justify-content: center; margin-bottom: .8rem; border-radius: 10px;
  color: var(--accent); background: color-mix(in srgb, var(--accent) 12%, transparent); }
.tile h2 { margin: 0 0 .35rem; font-size: 1.1rem; }
.tile p { margin: 0; color: var(--muted); font-size: .95rem; line-height: 1.55; }
.home footer { margin-top: 3rem; }
@media (prefers-reduced-motion: reduce) { .tile { transition: none; } .tile:hover { transform: none; } }

/* ---- login dialog (the shared dialog rules above still style the friends page's create dialog) ---- */
#login { width: min(26rem, calc(100vw - 2rem)); padding: 2.2rem 2rem 1.5rem; border-radius: 18px; box-shadow: 0 24px 64px rgba(0, 0, 0, .45); animation: login-in .18s ease-out; }
#login::backdrop { background: rgba(8, 10, 14, .6); backdrop-filter: blur(5px); }
@keyframes login-in { from { opacity: 0; transform: translateY(10px) scale(.98); } to { opacity: 1; transform: none; } }
@media (prefers-reduced-motion: reduce) { #login { animation: none; } }
#login form { display: flex; flex-direction: column; }
.login-badge { align-self: center; display: flex; align-items: center; justify-content: center; width: 3.4rem; height: 3.4rem; margin-bottom: 1rem; border-radius: 50%;
  color: var(--accent); background: color-mix(in srgb, var(--accent) 13%, transparent); }
#login h2 { margin: 0; text-align: center; font-size: 1.4rem; letter-spacing: -.01em; }
#login .hint { margin: .35rem 0 1.5rem; text-align: center; }
.login-label { margin-bottom: .4rem; font-size: .88rem; font-weight: 600; color: var(--muted); }
#login input { height: 3rem; padding: 0 .95rem; font-size: 1.02rem; border-radius: 10px; }
#login input::placeholder { color: color-mix(in srgb, var(--muted) 65%, transparent); }
#login input:focus-visible { outline: none; border-color: var(--accent); box-shadow: 0 0 0 3px color-mix(in srgb, var(--accent) 25%, transparent); }
.login-error { margin: .7rem 0 0; padding: .55rem .8rem; border-radius: 8px; font-size: .92rem; color: #cf222e; background: color-mix(in srgb, #cf222e 9%, transparent); border: 1px solid color-mix(in srgb, #cf222e 35%, transparent); }
@media (prefers-color-scheme: dark) { .login-error { color: #ff7b72; background: color-mix(in srgb, #ff7b72 10%, transparent); border-color: color-mix(in srgb, #ff7b72 35%, transparent); } }
.login-error[hidden] { display: none; }
#login #submit { width: 100%; height: 3rem; margin: 1.3rem 0 0; padding: 0; border-radius: 10px; font-size: 1rem; }
.login-cancel { align-self: center; margin: .9rem 0 0; padding: .35rem .9rem; border: 0; background: transparent; color: var(--muted); font-size: .92rem; border-radius: 8px; }
.login-cancel:hover { color: var(--fg); border-color: transparent; background: color-mix(in srgb, var(--fg) 7%, transparent); }
