:root {
  color-scheme: light;
  /* Light: cream and tan surfaces, brown text, forest-green interactive items, gold accents. */
  --wash-a: 20%;
  --wash-b: 14%;
  --glass-a: .5;
  --glass-b: .14;
  --bg: #e7dabb;
  --card: #f0e5cb;
  --line: #cdba90;
  --edge: #8a7550;
  --fg: #38291b;
  --muted: #65523a;
  --accent: #38572a;
  --on-accent: #f3ead3;
  --gold: #c28d2a;
  --gold-ink: #725010;
  --ok: #37722a;
  --bad: #a03a28;
  --on-bad: #f3ead3;
  --warn-bg: #ecd9a3;
  --warn-fg: #684808;
  --warn-line: #b8923f;
  --shadow: 0 1px 2px rgba(74, 52, 24, .08), 0 10px 28px -14px rgba(74, 52, 24, .3);
  --scrim: rgba(40, 28, 12, .5);
  --serif: "Iowan Old Style", "Palatino Linotype", Palatino, "Book Antiqua", Charter, Georgia, serif;
}
/* Dark: forest-green surfaces, cream and tan text and controls, gold accents. An explicit choice (data-theme, set by theme.js)
   wins; with none, the system setting decides. Keep the two dark blocks identical. */
:root[data-theme="dark"] {
  color-scheme: dark;
  --wash-a: 11%;
  --wash-b: 7%;
  --glass-a: .2;
  --glass-b: .04;
  --bg: #0e1710;
  --card: #15211a;
  --line: #243629;
  --edge: #587460;
  --fg: #eee3c8;
  --muted: #b0a487;
  --accent: #d6c18f;
  --on-accent: #111c14;
  --gold: #dcb04a;
  --gold-ink: #dcb04a;
  --ok: #98cc8c;
  --bad: #f0a28d;
  --on-bad: #2a1410;
  --warn-bg: #352c10;
  --warn-fg: #eccd74;
  --warn-line: #76652a;
  --shadow: 0 1px 2px rgba(0, 0, 0, .3), 0 12px 30px -14px rgba(0, 0, 0, .6);
  --scrim: rgba(4, 10, 6, .62);
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme]) {
    color-scheme: dark;
    --wash-a: 11%;
    --wash-b: 7%;
    --glass-a: .2;
    --glass-b: .04;
    --bg: #0e1710;
    --card: #15211a;
    --line: #243629;
    --edge: #587460;
    --fg: #eee3c8;
    --muted: #b0a487;
    --accent: #d6c18f;
    --on-accent: #111c14;
    --gold: #dcb04a;
    --gold-ink: #dcb04a;
    --ok: #98cc8c;
    --bad: #f0a28d;
    --on-bad: #2a1410;
    --warn-bg: #352c10;
    --warn-fg: #eccd74;
    --warn-line: #76652a;
    --shadow: 0 1px 2px rgba(0, 0, 0, .3), 0 12px 30px -14px rgba(0, 0, 0, .6);
    --scrim: rgba(4, 10, 6, .62);
  }
}
* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--fg);
  font: 17px/1.65 var(--serif);
  font-variant-numeric: lining-nums;
  -webkit-font-smoothing: antialiased;
}
input[type="checkbox"], input[type="radio"], progress { accent-color: var(--accent); }
main { max-width: 42rem; margin: 0 auto; padding: 4rem 1rem 3rem; }
header { margin-bottom: 2.5rem; }
.eyebrow { margin: 0 0 .5rem; color: var(--gold-ink); font-weight: 700; letter-spacing: .12em; text-transform: uppercase; font-size: .78rem; }
h1 { margin: 0; font-size: clamp(2.2rem, 7vw, 3.2rem); line-height: 1.1; letter-spacing: -.015em; font-weight: 600; }
.lede { margin: .8rem 0 0; color: var(--muted); font-size: 1.15rem; }
section {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: 16px;
  padding: 1.25rem 1.4rem;
  margin: 0 0 1.1rem;
  box-shadow: var(--shadow);
}
h2 { margin: 0 0 .5rem; font-size: 1.25rem; font-weight: 600; }
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(--edge); border-radius: 8px;
  background: var(--card); color: var(--fg); cursor: pointer;
  transition: border-color .15s, background .15s, filter .15s;
}
button:hover { border-color: var(--gold-ink); background: color-mix(in srgb, var(--gold) 12%, var(--card)); }
a { color: var(--accent); text-underline-offset: .18em; }
a:hover { color: var(--gold-ink); }
a:focus-visible, button:focus-visible, summary:focus-visible, select:focus-visible { outline: 2px solid var(--gold-ink); outline-offset: 2px; }
@media (prefers-reduced-motion: reduce) { button { transition: none; } }
footer { margin-top: 2rem; color: var(--muted); font-size: .9rem; }

/* login dialog */
button.primary { background: var(--accent); border-color: var(--accent); color: var(--on-accent); box-shadow: 0 1px 2px rgba(40, 28, 12, .25); margin-left: 0; padding: .55rem 1.5rem; font-size: 1rem; font-weight: 600; }
button.primary:hover { background: var(--accent); border-color: var(--gold-ink); filter: brightness(1.1); }
button.primary:disabled { opacity: .6; cursor: wait; }
button.ghost { background: transparent; }
button.ghost:hover { background: color-mix(in srgb, var(--gold) 12%, transparent); }
dialog { border: 1px solid var(--line); border-radius: 18px; box-shadow: var(--shadow); background: var(--card); color: var(--fg); padding: 1.5rem; width: min(24rem, calc(100vw - 2rem)); }
dialog::backdrop { background: var(--scrim); }
dialog h2 { margin-top: 0; }
dialog input { width: 100%; font: inherit; padding: .6rem .7rem; border: 1px solid var(--edge); border-radius: 8px; background: var(--bg); color: var(--fg); }
dialog input:focus-visible { outline: 2px solid var(--gold-ink); 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: var(--bad); margin: .6rem 0 0; font-size: .92rem; }
.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.3rem; font-weight: 600; text-decoration: none; color: var(--fg); letter-spacing: -.01em; }
.brand:hover { color: var(--fg); }
.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: var(--on-accent); 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: 12px; box-shadow: var(--shadow); 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: 15rem; 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; white-space: nowrap; 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(--gold); background: color-mix(in srgb, var(--gold) 16%, transparent); }
body.has-side main, body.has-side main.wide { max-width: none; margin: 0 0 0 15rem; }
/* ---- phones and small tablets: the side nav becomes a drawer opened from a menu button ---- */
.nav-left { display: flex; align-items: center; gap: .5rem; min-width: 0; }
.nav-right { margin-left: auto; }
.nav-toggle, .drawer-close { align-items: center; justify-content: center; width: 2.7rem; height: 2.7rem; margin: 0; padding: 0; border: 0; border-radius: 10px; background: transparent; color: var(--fg); cursor: pointer; }
.nav-toggle:hover, .drawer-close:hover { background: color-mix(in srgb, var(--gold) 16%, transparent); }
.nav-toggle svg, .drawer-close svg { width: 1.45rem; height: 1.45rem; }
.nav-toggle, .drawer-head, .nav-scrim { display: none; }
@media (max-width: 48rem) {
  .nav-toggle { display: inline-flex; margin-left: -.5rem; }
  .topnav { gap: .75rem; }
  .sidenav { top: 0; bottom: 0; left: 0; width: min(19rem, 86vw); z-index: 40; padding: 0 .75rem 1rem; box-shadow: 0 0 40px rgba(0, 0, 0, .35);
    transform: translateX(-104%); visibility: hidden; transition: transform .28s cubic-bezier(.3, .9, .3, 1), visibility 0s linear .28s; }
  .sidenav.open { transform: none; visibility: visible; transition-delay: 0s, 0s; }
  .drawer-head { display: flex; flex: none; align-items: center; justify-content: space-between; height: 4rem; margin: 0 -.75rem .6rem; padding: 0 .75rem 0 1.15rem; border-bottom: 1px solid var(--line); }
  .drawer-title { font-family: var(--serif); font-size: 1.2rem; font-weight: 600; }
  .sidenav a { padding: .85rem .9rem; font-size: 1.05rem; }
  .nav-scrim { display: block; position: fixed; inset: 0; z-index: 35; background: var(--scrim); opacity: 0; pointer-events: none; transition: opacity .25s; }
  .nav-scrim.open { opacity: 1; pointer-events: auto; }
  body.nav-open { overflow: hidden; }
  body.has-side main, body.has-side main.wide { margin-left: 0; }
}
@media (prefers-reduced-motion: reduce) { .sidenav, .nav-scrim { transition: none; } }

/* ---- signed-out home page ---- */
body.home { background:
  radial-gradient(70rem 28rem at 15% -8%, color-mix(in srgb, var(--gold) var(--wash-a), transparent), transparent),
  radial-gradient(50rem 24rem at 95% 10%, color-mix(in srgb, var(--accent) var(--wash-b), 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(--gold) 60%, 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(--gold-ink); background: color-mix(in srgb, var(--gold) 20%, 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, .4); animation: login-in .18s ease-out; }
#login::backdrop { background: var(--scrim); 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(--gold-ink); background: color-mix(in srgb, var(--gold) 20%, 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(--gold-ink); box-shadow: 0 0 0 3px color-mix(in srgb, var(--gold) 35%, transparent); }
.login-error { margin: .7rem 0 0; padding: .55rem .8rem; border-radius: 8px; font-size: .92rem; color: var(--bad); background: color-mix(in srgb, var(--bad) 10%, transparent); border: 1px solid color-mix(in srgb, var(--bad) 40%, 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); }

/* ---- light/dark toggle in the top nav (built by theme.js): a slider with a frosted thumb ---- */
.theme-toggle { --tt-w: 4.5rem; --tt-h: 2.3rem; --tt-pad: .2rem; --tt-d: calc(var(--tt-h) - 2 * var(--tt-pad));
  position: relative; display: inline-block; flex: none; width: var(--tt-w); height: var(--tt-h); margin: 0; padding: 0; border: 0; border-radius: 99px;
  background: none; cursor: pointer; -webkit-tap-highlight-color: transparent; }
.theme-toggle:hover { background: none; }
.theme-toggle:focus-visible { outline: 2px solid var(--gold-ink); outline-offset: 3px; }
.tt-track { position: absolute; inset: 0; border-radius: 99px; overflow: hidden;
  background: linear-gradient(180deg, color-mix(in srgb, var(--fg) 14%, var(--bg)), color-mix(in srgb, var(--fg) 7%, var(--bg)));
  box-shadow: inset 0 1px 3px rgba(20, 12, 0, .28), inset 0 0 0 1px var(--edge); transition: background .3s; }
.tt-icon { position: absolute; z-index: 1; top: 50%; width: 1.1rem; height: 1.1rem; margin-top: -.55rem; color: var(--muted); transition: color .3s, opacity .3s; }
.tt-sun { left: .6rem; }
.tt-moon { right: .6rem; }
/* the icon the thumb is not covering is the one you can switch to; the covered one glows gold */
.theme-toggle[aria-checked="false"] .tt-sun, .theme-toggle[aria-checked="true"] .tt-moon { color: var(--gold-ink); }
.tt-thumb { position: absolute; top: var(--tt-pad); left: var(--tt-pad); width: var(--tt-d); height: var(--tt-d); border-radius: 99px;
  background: linear-gradient(160deg, rgba(255, 255, 255, var(--glass-a)), rgba(255, 255, 255, var(--glass-b)));
  -webkit-backdrop-filter: blur(3px) saturate(1.4); backdrop-filter: blur(3px) saturate(1.4);
  border: 1px solid rgba(255, 255, 255, calc(var(--glass-a) + .1));
  box-shadow: 0 2px 6px rgba(20, 12, 0, .3), inset 0 1px 1px rgba(255, 255, 255, .75), inset 0 -2px 4px rgba(255, 255, 255, .14);
  transition: transform .42s cubic-bezier(.3, 1.45, .5, 1), width .22s ease; }
.theme-toggle[aria-checked="true"] .tt-thumb { transform: translateX(calc(var(--tt-w) - var(--tt-d) - 2 * var(--tt-pad))); }
/* pressing stretches the thumb like a drop of liquid, and it settles into place on release */
.theme-toggle:active .tt-thumb { width: calc(var(--tt-d) + .55rem); }
.theme-toggle[aria-checked="true"]:active .tt-thumb { transform: translateX(calc(var(--tt-w) - var(--tt-d) - .55rem - 2 * var(--tt-pad))); }
.theme-toggle:hover .tt-thumb { box-shadow: 0 3px 9px rgba(20, 12, 0, .34), inset 0 1px 1px rgba(255, 255, 255, .8), inset 0 -2px 4px rgba(255, 255, 255, .16); }
@media (prefers-reduced-motion: reduce) { .tt-thumb, .tt-track, .tt-icon { transition: none; } }
