/* Ruru crew (CREW01). Mobile first, system fonts, Rurucamp's colours. No inline styles anywhere (the CSP forbids them). */
:root {
  --bg: #f6f1e6; --card: #fffdf8; --ink: #1f2a22; --muted: #56614f; --line: #e2d9c6;
  --green: #1b5e3b; --green-2: #2e7d4f; --on-green: #fff; --amber: #ffb000; --brown: #6b4a2b;
  --soft: #eaf3ec; --err: #b3261e; --top: #1b5e3b; --on-top: #fff; --focus: #0b57d0; --shadow: 0 1px 2px rgb(0 0 0 / 8%), 0 4px 14px rgb(0 0 0 / 6%);
  color-scheme: light dark;
}
@media (prefers-color-scheme: dark) {
  :root { --bg: #11160f; --card: #1a2118; --ink: #eef2ea; --muted: #a9b5a4; --line: #2e3a2b;
    --green: #5fc28a; --green-2: #7fd3a1; --on-green: #0d1a11; --soft: #1f2d22; --top: #173d28; --on-top: #eef2ea; --err: #ff8a80; --focus: #8ab4f8;
    --shadow: 0 1px 2px rgb(0 0 0 / 40%); }
}
* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body { margin: 0; background: var(--bg); color: var(--ink); font: 16px/1.5 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif; }
a { color: var(--green); }
h1 { font-size: 1.5rem; line-height: 1.2; margin: 18px 0 8px; }
h2 { font-size: 1.15rem; line-height: 1.25; margin: 20px 0 8px; }
p { margin: 8px 0; }
.wrap { max-width: 720px; margin: 0 auto; padding: 0 16px; }
.lede { color: var(--muted); }
.muted { color: var(--muted); }
.small { font-size: .875rem; color: var(--muted); }
.note { background: var(--soft); border-radius: 10px; padding: 10px 12px; }
.err { color: var(--err); font-weight: 600; min-height: 0; margin: 6px 0; }
.err:empty { display: none; }
:focus-visible { outline: 3px solid var(--focus); outline-offset: 2px; }
.skip { position: absolute; left: -9999px; top: 8px; background: var(--card); padding: 8px 12px; z-index: 30; }
.skip:focus { left: 8px; }
.hp { position: absolute; left: -9999px; width: 1px; height: 1px; overflow: hidden; }
[hidden] { display: none !important; }

/* header */
.top { background: var(--top); color: var(--on-top); position: sticky; top: 0; z-index: 10; }
.top-in { display: flex; align-items: center; justify-content: space-between; gap: 12px; min-height: 56px; }
.brand { display: flex; align-items: center; gap: 8px; color: inherit; text-decoration: none; font-weight: 700; font-size: 1.1rem; }
.chip { display: flex; align-items: center; gap: 8px; min-width: 0; }
.chip-txt { display: grid; line-height: 1.15; font-size: .8rem; min-width: 0; }
.chip-txt strong { font-size: .9rem; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; max-width: 38vw; }
.chip progress { width: 110px; height: 6px; margin-top: 3px; }
progress { appearance: none; -webkit-appearance: none; border: 0; height: 10px; border-radius: 99px; background: rgb(127 127 127 / 25%); overflow: hidden; width: 100%; }
progress::-webkit-progress-bar { background: rgb(127 127 127 / 25%); border-radius: 99px; }
progress::-webkit-progress-value { background: var(--amber); border-radius: 99px; }
progress::-moz-progress-bar { background: var(--amber); border-radius: 99px; }

/* avatars */
.av { width: 56px; height: 56px; flex: none; }
.av.sm { width: 36px; height: 36px; }
.av.xl { width: 88px; height: 88px; }

/* cards, buttons */
.card { background: var(--card); border: 1px solid var(--line); border-radius: 14px; padding: 14px 16px; margin: 12px 0; box-shadow: var(--shadow); }
.btn { display: inline-flex; align-items: center; justify-content: center; gap: 6px; min-height: 44px; padding: 10px 18px; border: 0; border-radius: 12px;
  background: var(--green); color: var(--on-green); font: inherit; font-weight: 700; text-decoration: none; cursor: pointer; }
.btn:hover { background: var(--green-2); }
.btn:disabled { opacity: .6; cursor: progress; }
.btn.big { width: 100%; font-size: 1.05rem; min-height: 50px; margin-top: 8px; }
.btn.ghost { background: transparent; color: var(--green); border: 2px solid var(--green); }
.btn.danger { background: var(--err); color: #fff; }
.link { background: none; border: 0; padding: 6px 0; color: var(--green); font: inherit; text-decoration: underline; cursor: pointer; text-align: left; }
.row { display: flex; flex-wrap: wrap; gap: 10px; margin-top: 12px; }
.plain { list-style: none; padding: 0; margin: 0; }

/* forms */
label { font-weight: 600; }
input[type=text], input[type=email], input[type=date], textarea, select {
  width: 100%; font: inherit; color: inherit; background: var(--bg); border: 2px solid var(--line); border-radius: 10px; padding: 10px 12px; margin-top: 4px; }
input:focus, textarea:focus, select:focus { border-color: var(--green); }
textarea { resize: vertical; }
.field { margin: 12px 0; }
.field.check { display: flex; gap: 10px; align-items: flex-start; }
.field.check input { width: 22px; height: 22px; margin: 2px 0 0; flex: none; accent-color: var(--green); }
.hint { margin: 2px 0 0; font-size: .875rem; color: var(--muted); }
fieldset { border: 0; padding: 0; margin: 14px 0; min-width: 0; }
legend { font-weight: 600; padding: 0; margin-bottom: 6px; }
.stack > * { margin-top: 0; }

/* chips: radios and checkboxes that look like buttons */
.chips { display: flex; flex-wrap: wrap; gap: 8px; }
.chips legend { width: 100%; }
.chip-o { position: relative; }
.chip-o input, .av-o input { position: absolute; opacity: 0; width: 1px; height: 1px; }
.chip-o label { display: inline-flex; align-items: center; gap: 6px; min-height: 44px; padding: 8px 12px; border: 2px solid var(--line); border-radius: 999px;
  background: var(--card); font-weight: 500; cursor: pointer; }
.chip-o input:checked + label { border-color: var(--green); background: var(--soft); font-weight: 700; }
.chip-o input:checked + label::before { content: "✓"; color: var(--green); }
.chip-o input:focus-visible + label { outline: 3px solid var(--focus); outline-offset: 2px; }
.rating .chip-o label { flex-direction: column; gap: 0; border-radius: 12px; padding: 6px 8px; font-size: .75rem; min-width: 62px; }
.rating .chip-o input:checked + label::before { content: none; }
.rating .emo { font-size: 1.7rem; line-height: 1.1; }
.scale .chip-o label { min-width: 44px; justify-content: center; border-radius: 10px; padding: 8px; }
.scale .chip-o input:checked + label::before { content: none; }

/* join */
.avatars { display: grid; grid-template-columns: repeat(auto-fill, minmax(88px, 1fr)); gap: 8px; }
.avatars legend { grid-column: 1 / -1; }
.av-o { position: relative; }
.av-o label { display: grid; justify-items: center; gap: 4px; padding: 8px 4px; border: 2px solid var(--line); border-radius: 14px; cursor: pointer; font-size: .85rem; font-weight: 600; background: var(--card); }
.av-o input:checked + label { border-color: var(--green); background: var(--soft); }
.av-o input:focus-visible + label { outline: 3px solid var(--focus); outline-offset: 2px; }
details.card summary { cursor: pointer; font-weight: 700; min-height: 32px; }
.privacy p { font-size: .9rem; }

/* tabs */
.tabs { position: sticky; top: 56px; z-index: 9; display: grid; grid-template-columns: repeat(5, 1fr); gap: 2px; background: var(--bg);
  padding: 8px 0 6px; border-bottom: 1px solid var(--line); }
.tabs button { min-height: 48px; border: 0; border-radius: 10px; background: transparent; color: var(--muted); font: inherit; font-size: .78rem; font-weight: 600;
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 1px; cursor: pointer; padding: 4px 2px; }
.tabs button span { font-size: 1.25rem; line-height: 1; }
.tabs button[aria-selected=true] { background: var(--card); color: var(--green); box-shadow: var(--shadow); }
.panel { padding-bottom: 24px; }
.panel:focus { outline: none; }

/* missions */
.grid { list-style: none; padding: 0; margin: 12px 0; display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 10px; }
.mission { width: 100%; height: 100%; min-height: 118px; display: grid; justify-items: start; align-content: start; gap: 4px; text-align: left; padding: 12px;
  background: var(--card); color: var(--ink); border: 2px solid var(--line); border-radius: 14px; font: inherit; cursor: pointer; box-shadow: var(--shadow); }
.mission:hover { border-color: var(--green); }
.mission.done { background: var(--soft); border-color: var(--green); }
.m-emo { font-size: 1.8rem; line-height: 1.1; }
.m-title { font-weight: 700; }
.m-xp { font-size: .8rem; font-weight: 700; color: var(--brown); }
.mission.done .m-xp { color: var(--green); }
@media (prefers-color-scheme: dark) { .m-xp { color: var(--amber); } }
.verdict { display: grid; gap: 2px; width: 100%; text-align: left; font: inherit; color: inherit; cursor: pointer; }
.verdict.open { border: 2px solid var(--amber); }
.verdict.locked { cursor: default; color: var(--muted); }
.verdict span { font-size: .9rem; }
.go { margin: 12px 0 4px; }
.go .small { margin: 6px 0 0; }
.count { font-weight: 600; }
.opts { display: flex; flex-wrap: wrap; gap: 8px; margin: 8px 0; }
.opt { display: inline-flex; align-items: center; gap: 8px; min-height: 52px; padding: 8px 14px; border: 2px solid var(--line); border-radius: 14px;
  background: var(--card); color: var(--ink); font: inherit; font-weight: 600; cursor: pointer; }
.opt:hover { border-color: var(--green); }
.opt.on { border-color: var(--green); background: var(--soft); }
.opt .emo { font-size: 1.5rem; }

/* profile sections */
.section h2 { display: flex; justify-content: space-between; align-items: baseline; gap: 10px; margin-top: 2px; }
.xp { flex: none; font-size: .8rem; font-weight: 700; color: var(--brown); background: var(--soft); padding: 2px 10px; border-radius: 99px; white-space: nowrap; }
.xp.done { color: var(--green); }
@media (prefers-color-scheme: dark) { .xp { color: var(--amber); } .xp.done { color: var(--green); } }

/* polls */
.poll h2 { font-size: 1.3rem; margin-top: 4px; }
.poll h2:focus { outline: none; }

/* leaderboard */
.board { list-style: none; padding: 0; margin: 12px 0; display: grid; gap: 6px; }
.board li { display: flex; align-items: center; gap: 10px; background: var(--card); border: 1px solid var(--line); border-radius: 12px; padding: 8px 12px; }
.board li.me { border: 2px solid var(--amber); }
.board .rank { width: 1.6em; text-align: center; font-weight: 800; color: var(--muted); }
.board li:nth-child(1) .rank { color: #b8860b; }
.board .who { flex: 1; min-width: 0; display: grid; line-height: 1.2; }
.board .who strong { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.board .pts { font-weight: 800; white-space: nowrap; }

/* me */
.me-card { display: flex; gap: 16px; align-items: center; }
.me-card > div { flex: 1; min-width: 0; }
.me-card h1 { margin: 0; overflow-wrap: anywhere; }
.badges { list-style: none; padding: 0; margin: 8px 0; display: grid; grid-template-columns: repeat(auto-fill, minmax(140px, 1fr)); gap: 8px; }
.badges li { display: grid; justify-items: center; text-align: center; gap: 2px; padding: 10px 8px; border: 2px dashed var(--line); border-radius: 14px; opacity: .65; }
.badges li.got { opacity: 1; border-style: solid; border-color: var(--amber); background: var(--card); }
.b-emo { font-size: 2rem; line-height: 1.1; }
.badges li:not(.got) .b-emo { filter: grayscale(1); }
.levels { padding-left: 1.4em; color: var(--muted); }
.levels li.got { color: var(--ink); font-weight: 600; }
.codebox .code { font: 700 1.35rem/1.3 ui-monospace, "Cascadia Mono", Consolas, monospace; background: var(--soft); padding: 10px 12px; border-radius: 10px; overflow-wrap: anywhere; margin: 4px 0; }

/* XP log */
.xplog summary { font-size: 1.05rem; }
.log { margin: 10px 0 0; }
.log li { display: flex; justify-content: space-between; gap: 12px; padding: 6px 0; border-bottom: 1px solid var(--line); }
.log-what { display: grid; min-width: 0; overflow-wrap: anywhere; }
.log-xp { font-weight: 800; white-space: nowrap; color: var(--brown); }
.badge-line .log-xp { font-weight: 600; color: var(--muted); }
.log-total { display: flex; justify-content: space-between; margin: 10px 0 0; font-size: 1.05rem; }
.xp-hint { margin: 4px 0 0; font-size: .85rem; font-weight: 600; color: var(--green); min-height: 1.2em; }
@media (prefers-color-scheme: dark) { .log-xp { color: var(--amber); } }

/* dialog */
dialog { width: min(600px, calc(100vw - 24px)); max-height: calc(100dvh - 32px); padding: 0; border: 0; border-radius: 16px; background: var(--card); color: var(--ink); box-shadow: 0 10px 40px rgb(0 0 0 / 35%); }
dialog::backdrop { background: rgb(10 20 12 / 55%); }
.dlg-head { position: sticky; top: 0; display: flex; align-items: center; justify-content: space-between; gap: 8px; padding: 12px 16px; background: var(--card); border-bottom: 1px solid var(--line); z-index: 1; }
.dlg-head h2 { margin: 0; }
.dlg-body { padding: 4px 16px 18px; }
.x { width: 44px; height: 44px; border: 0; border-radius: 10px; background: var(--soft); color: var(--ink); font-size: 1.1rem; cursor: pointer; flex: none; }
.big-emo { font-size: 3rem; text-align: center; margin: 4px 0; }

/* toasts, confetti, footer */
.toasts { position: fixed; left: 50%; bottom: 16px; transform: translateX(-50%); display: grid; gap: 8px; z-index: 50; width: min(420px, calc(100vw - 32px)); pointer-events: none; }
.toast { background: #1f2a22; color: #fff; padding: 8px 12px; border-radius: 12px; font-size: .9rem; box-shadow: 0 6px 20px rgb(0 0 0 / 30%); font-weight: 600; transition: opacity .5s, transform .5s; }
.toast.xp { background: var(--brown); }
.toast.badge { background: #5b3a8c; }
.toast.err { background: #8c1d18; }
.toast.out { opacity: 0; transform: translateY(8px); }
.confetti { position: fixed; inset: 0; width: 100vw; height: 100vh; pointer-events: none; z-index: 60; }
.foot { padding-top: 8px; padding-bottom: 32px; font-size: .85rem; color: var(--muted); border-top: 1px solid var(--line); margin-top: 24px; }
.notfound { padding-top: 40px; }
@media (prefers-reduced-motion: reduce) { .toast { transition: none; } }
@media (min-width: 700px) {
  h1 { font-size: 1.8rem; }
  .tabs button { flex-direction: row; font-size: .9rem; gap: 6px; }
}
