/* The front door.
 *
 * A painted-door palette: deep green, brass hardware, warm off-white walls.
 * Fraunces carries the names, Figtree does the talking. Both are served from
 * this app — nothing loads from anyone else's server.
 */

@font-face {
  font-family: 'Fraunces';
  src: url('/fonts/fraunces.woff2') format('woff2-variations');
  font-weight: 100 900;
  font-style: normal;
  font-display: swap;
}
@font-face {
  font-family: 'Figtree';
  src: url('/fonts/figtree.woff2') format('woff2-variations');
  font-weight: 300 900;
  font-style: normal;
  font-display: swap;
}

:root {
  --paper: #f2f4f0;
  --surface: #ffffff;
  --sunk: #e9ede6;
  --ink: #16211b;
  --text: #24312a;
  --muted: #61736a;
  --line: #dde5d9;
  --green: #1f5d43;
  --green-ink: #ffffff;
  --green-soft: #dcebe1;
  --brass: #8f6416;
  --brass-soft: #f1e6cd;
  --bad: #a63a22;
  --bad-soft: #f7e3dd;
  --shadow: 0 1px 2px rgba(22,33,27,.05), 0 10px 30px rgba(22,33,27,.07);
  --crest: linear-gradient(150deg, #2a7554, #164733);

  --display: 'Fraunces', ui-serif, Georgia, serif;
  --body: 'Figtree', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --paper: #0e1512;
    --surface: #17211c;
    --sunk: #1d2822;
    --ink: #e9efe9;
    --text: #dbe4dd;
    --muted: #93a89b;
    --line: #27342c;
    --green: #57ab80;
    --green-ink: #08130d;
    --green-soft: #172f23;
    --brass: #d3a75d;
    --brass-soft: #2d2413;
    --bad: #e08b6f;
    --bad-soft: #33190f;
    --shadow: 0 1px 2px rgba(0,0,0,.4), 0 12px 32px rgba(0,0,0,.34);
    --crest: linear-gradient(150deg, #2c7a58, #12362a);
  }
}
:root[data-theme="dark"] {
  --paper: #0e1512;
  --surface: #17211c;
  --sunk: #1d2822;
  --ink: #e9efe9;
  --text: #dbe4dd;
  --muted: #93a89b;
  --line: #27342c;
  --green: #57ab80;
  --green-ink: #08130d;
  --green-soft: #172f23;
  --brass: #d3a75d;
  --brass-soft: #2d2413;
  --bad: #e08b6f;
  --bad-soft: #33190f;
  --shadow: 0 1px 2px rgba(0,0,0,.4), 0 12px 32px rgba(0,0,0,.34);
  --crest: linear-gradient(150deg, #2c7a58, #12362a);
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  min-height: 100vh;
  background: var(--paper);
  color: var(--text);
  font-family: var(--body);
  font-size: 16.5px;
  line-height: 1.55;
  -webkit-font-smoothing: antialiased;
}

.wrap {
  max-width: 40rem;
  margin: 0 auto;
  padding: clamp(1.5rem, 6vw, 3rem) clamp(1.1rem, 5vw, 2rem) 4rem;
  display: flex;
  flex-direction: column;
  gap: clamp(1.6rem, 5vw, 2.4rem);
}
.wrap.narrow { max-width: 25rem; }

.icon { width: 1.5rem; height: 1.5rem; display: block; }

/* ---------- the bar above everything ---------- */
.rail { display: flex; align-items: center; justify-content: flex-end; gap: .4rem; margin-bottom: -.6rem; }
.rail .spacer { margin-right: auto; }
.chip {
  display: inline-flex; align-items: center; gap: .4rem;
  border: 1px solid var(--line); background: var(--surface); color: var(--muted);
  border-radius: 999px; padding: .42rem .7rem;
  font: inherit; font-size: .82rem; font-weight: 600;
  cursor: pointer; text-decoration: none;
}
.chip .icon { width: 1.05rem; height: 1.05rem; }
.chip:hover { color: var(--text); border-color: var(--muted); }
.chip:focus-visible { outline: 2px solid var(--green); outline-offset: 2px; }
.theme-toggle .to-light { display: none; }
:root[data-theme="dark"] .theme-toggle .to-light { display: block; }
:root[data-theme="dark"] .theme-toggle .to-dark { display: none; }
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) .theme-toggle .to-light { display: block; }
  :root:not([data-theme="light"]) .theme-toggle .to-dark { display: none; }
}

/* ---------- the menu ---------- */
.menu { position: relative; }
.menu summary { list-style: none; padding: .3rem .7rem .3rem .35rem; }
.menu summary::-webkit-details-marker { display: none; }
.menu summary::marker { content: ''; }
.menu[open] summary { color: var(--text); border-color: var(--muted); }
.avatar.sm { width: 1.55rem; height: 1.55rem; font-size: .72rem; }

.menu-panel {
  position: absolute; right: 0; top: calc(100% + .45rem); z-index: 20;
  min-width: min(17rem, calc(100vw - 2.4rem));
  background: var(--surface); border: 1px solid var(--line);
  border-radius: 14px; box-shadow: var(--shadow);
  padding: .4rem; display: flex; flex-direction: column; gap: .1rem;
}
.menu-who {
  margin: 0; padding: .55rem .65rem .6rem;
  font-size: .85rem; line-height: 1.35;
  border-bottom: 1px solid var(--line); margin-bottom: .25rem;
}
.menu-who .muted { display: block; font-size: .78rem; }
.menu-item {
  display: flex; align-items: center; gap: .6rem; width: 100%;
  padding: .6rem .65rem; border-radius: 10px;
  border: 0; background: none; text-align: left;
  color: var(--text); text-decoration: none;
  font: inherit; font-size: .92rem; font-weight: 600; cursor: pointer;
}
.menu-item .icon { width: 1.15rem; height: 1.15rem; flex: 0 0 auto; color: var(--muted); }
.menu-item .mi { display: flex; flex-direction: column; min-width: 0; }
.menu-item .muted { font-weight: 400; font-size: .78rem; line-height: 1.3; }
.menu-item:hover { background: var(--sunk); }
.menu-item:focus-visible { outline: 2px solid var(--green); outline-offset: -2px; }
.menu form { display: contents; }

/* ---------- masthead ---------- */
.masthead { display: flex; flex-direction: column; align-items: center; text-align: center; gap: .3rem; }
.masthead.tight { text-align: left; align-items: flex-start; }
.crest {
  width: 3.6rem; height: 3.6rem; border-radius: 20px;
  background: var(--crest); color: #eaf6ef;
  display: grid; place-items: center;
  box-shadow: var(--shadow); margin-bottom: .75rem;
}
.crest .icon { width: 1.9rem; height: 1.9rem; }

h1 {
  margin: 0;
  font-family: var(--display);
  font-weight: 600;
  font-variation-settings: 'SOFT' 24, 'WONK' 1, 'opsz' 60;
  font-size: clamp(2rem, 8vw, 2.9rem);
  line-height: 1.04;
  letter-spacing: -.02em;
  color: var(--ink);
  text-wrap: balance;
}
.greeting { margin: .5rem 0 0; font-size: 1.05rem; color: var(--text); text-wrap: balance; }
.greeting b { font-weight: 700; color: var(--ink); }
.sub { margin: 0; color: var(--muted); font-size: .95rem; text-wrap: balance; }

/* ---------- app cards ---------- */
.apps { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: .85rem; }
.app { border-radius: 20px; background: var(--surface); box-shadow: var(--shadow); }
.app-link {
  display: flex; align-items: flex-start; gap: 1rem;
  padding: 1.15rem 1.15rem;
  color: var(--text); text-decoration: none;
  border-radius: inherit;
  border: 1px solid transparent;
  transition: transform .12s ease, border-color .15s ease;
}
a.app-link:hover { transform: translateY(-2px); }
a.app-link:active { transform: translateY(0); }
a.app-link:focus-visible { outline: 2px solid var(--green); outline-offset: 2px; }

.app-mark {
  width: 3.2rem; height: 3.2rem; flex: 0 0 auto; border-radius: 16px;
  display: grid; place-items: center;
}
.app-mark .icon { width: 1.7rem; height: 1.7rem; }
.app.green .app-mark { background: var(--green-soft); color: var(--green); }
.app.brass .app-mark { background: var(--brass-soft); color: var(--brass); }
a.app-link:hover .app-mark { transform: none; }

.app-text { display: flex; flex-direction: column; min-width: 0; gap: .05rem; }
.app-name {
  font-family: var(--display);
  font-weight: 600;
  font-variation-settings: 'SOFT' 20, 'WONK' 1, 'opsz' 24;
  font-size: 1.32rem; letter-spacing: -.012em; color: var(--ink);
}
.app-tagline { font-size: .8rem; font-weight: 700; letter-spacing: .01em; color: var(--muted); }
.app-desc { font-size: .88rem; color: var(--muted); margin-top: .3rem; }
.app-go { margin-left: auto; color: var(--muted); flex: 0 0 auto; align-self: center; }
a.app-link:hover .app-go { color: var(--green); }

.app.soon { opacity: .7; }
.app.soon .app-link { cursor: default; }
.badge {
  font-size: .6rem; text-transform: uppercase; letter-spacing: .1em; font-weight: 800;
  background: var(--sunk); color: var(--muted);
  padding: .18rem .45rem; border-radius: 999px; vertical-align: .12em; margin-left: .4rem;
  font-family: var(--body);
}

/* ---------- panels ---------- */
.panel, .who {
  background: var(--surface); border-radius: 18px; box-shadow: var(--shadow);
  padding: 1.15rem 1.2rem; display: flex; flex-direction: column; gap: .85rem;
}
h2 {
  margin: 0;
  font-family: var(--display);
  font-weight: 600;
  font-variation-settings: 'SOFT' 20, 'WONK' 1, 'opsz' 20;
  font-size: 1.12rem; letter-spacing: -.01em; color: var(--ink);
}

.people { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: .6rem; }
.people li { display: flex; align-items: center; gap: .65rem; }
.avatar {
  width: 2.1rem; height: 2.1rem; border-radius: 50%;
  background: var(--green); color: var(--green-ink);
  font-weight: 700; font-size: .9rem; display: grid; place-items: center; flex: 0 0 auto;
}
.avatar.me { box-shadow: 0 0 0 2px var(--surface), 0 0 0 4px var(--green); }
.p-name { flex: 1; font-weight: 600; color: var(--text); }
.p-name .muted { font-weight: 400; font-size: .85rem; }

/* ---------- forms ---------- */
.signin, .stack { display: flex; flex-direction: column; gap: .6rem; }
input[type="text"], input[type="password"] {
  width: 100%; border: 1px solid var(--line); border-radius: 12px;
  padding: .7rem .9rem; font-size: 1rem; font-family: inherit;
  background: var(--surface); color: var(--text);
}
input::placeholder { color: var(--muted); opacity: .85; }
input:focus { outline: 2px solid var(--green); outline-offset: 0; border-color: var(--green); }

.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: .45rem;
  border: 1px solid var(--line); background: var(--surface); color: var(--text);
  padding: .7rem 1.1rem; border-radius: 12px;
  font-family: inherit; font-size: .95rem; font-weight: 650;
  cursor: pointer; text-decoration: none;
}
.btn:hover { border-color: var(--muted); }
.btn:focus-visible { outline: 2px solid var(--green); outline-offset: 2px; }
.btn.primary { background: var(--green); border-color: var(--green); color: var(--green-ink); }
.btn.primary:hover { filter: brightness(1.08); }
.btn.danger { background: transparent; border-color: var(--bad); color: var(--bad); }
.btn .icon { width: 1.1rem; height: 1.1rem; }

.error { color: var(--bad); font-weight: 600; font-size: .9rem; margin: 0; }
.banner { border-radius: 12px; padding: .75rem .95rem; font-weight: 600; font-size: .9rem; margin: 0; }
.banner.ok { background: var(--green-soft); color: var(--green); }
.banner.bad { background: var(--bad-soft); color: var(--bad); }

.back { margin: 0 0 -.4rem; font-size: .9rem; }
.back a { color: var(--muted); text-decoration: none; font-weight: 600; }
.back a:hover { color: var(--text); }

.manage { display: flex; flex-wrap: wrap; align-items: center; gap: .5rem; padding: .7rem 0; border-bottom: 1px solid var(--line); }
.manage:last-child { border-bottom: 0; padding-bottom: 0; }
.manage .p-name { flex: 1 1 100%; }
.row { display: flex; gap: .4rem; flex: 1 1 auto; }
.check { display: flex; align-items: center; gap: .5rem; font-size: .88rem; color: var(--muted); }
.check input { width: auto; }

/* what someone is allowed to do */
.roles { border: 1px solid var(--line); border-radius: 12px; padding: .5rem .75rem .75rem; margin: 0; display: grid; gap: .1rem; }
.roles legend {
  font-family: var(--mono, inherit); font-size: .68rem; letter-spacing: .1em;
  text-transform: uppercase; color: var(--muted); padding: 0 .3rem;
}
.pick { display: flex; gap: .6rem; align-items: flex-start; padding: .45rem .3rem; border-radius: 8px; cursor: pointer; }
.pick:hover { background: var(--sunk); }
.pick input { width: auto; margin-top: .3rem; flex: 0 0 auto; accent-color: var(--green); }
.pick span { font-size: .85rem; color: var(--muted); line-height: 1.4; }
.pick b { display: block; font-size: .95rem; color: var(--text); font-weight: 700; }

select {
  border: 1px solid var(--line); border-radius: 12px; padding: .7rem .9rem;
  font: inherit; font-size: .95rem; background: var(--surface); color: var(--text);
}
select:focus { outline: 2px solid var(--green); border-color: var(--green); }

.badge.admin { background: var(--green); color: var(--green-ink); }
.badge.parent { background: var(--brass-soft); color: var(--brass); }

/* ---------- footer ---------- */
.foot { text-align: center; }
.muted { color: var(--muted); font-size: .85rem; margin: 0; text-wrap: balance; }
.signout, .signed-out { margin: 0; }

@media (prefers-reduced-motion: reduce) {
  * { transition: none !important; }
  a.app-link:hover { transform: none; }
}
