:root {
  color-scheme: dark;
  --bg: #151a17;
  --surface: #202823;
  --input: #19201c;
  --line: #3b4940;
  --text: #f6f1e7;
  --muted: #b1bfb4;
  --accent: #f3cb78;
  --accent-ink: #281e0d;
  --good: #a9d7ae;
  --missed: #eea18e;
  --corner: 20px;
  font: 16px/1.45 system-ui, -apple-system, sans-serif;
  background: var(--bg);
  color: var(--text);
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }
body { margin: 0; }
button, input, select, textarea { font: inherit; }
button, summary { cursor: pointer; }
button { color: inherit; }
a { color: inherit; text-decoration: none; }
img { display: block; max-width: 100%; }
p, h1, h2, h3 { margin: 0; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 4px; }
.muted { color: var(--muted); }
.error { color: var(--missed); font-size: .875rem; }
.success { color: var(--good); font-size: .875rem; }
.error:empty, .success:empty { display: none; }

.masthead {
  border-bottom: 1px solid var(--line);
  background: var(--bg);
  padding-top: env(safe-area-inset-top);
}

.masthead-inner {
  max-width: 1160px;
  padding: 0 28px;
  margin: auto;
  min-height: 72px;
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto minmax(0, 1fr);
  gap: 18px;
  align-items: center;
}

.brand {
  display: flex;
  gap: 10px;
  align-items: center;
  width: fit-content;
  max-width: 100%;
  font-size: 1.05rem;
  font-weight: 760;
  letter-spacing: -.035em;
}

.brand img { border-radius: 10px; flex: none; }
.brand-accent { color: var(--accent); }

#navigation {
  display: flex;
  align-items: stretch;
  align-self: stretch;
  gap: 26px;
}

#navigation button {
  background: none;
  border: 0;
  border-bottom: 2px solid transparent;
  padding: 2px 4px 0;
  color: var(--muted);
  display: flex;
  align-items: center;
  gap: 9px;
  font-weight: 650;
}

#navigation [aria-current] { border-color: var(--accent); color: var(--text); }
#navigation button:hover { color: var(--text); }

.icon {
  width: 17px;
  height: 17px;
  display: inline-block;
  border: 1.5px solid currentColor;
  position: relative;
  flex: none;
  border-radius: 4px;
}

.icon-feed::after {
  content: '';
  position: absolute;
  inset: auto 3px 3px;
  height: 4px;
  border-radius: 1px;
  background: currentColor;
}

.icon-calendar::after {
  content: '';
  position: absolute;
  top: 4px;
  left: 0;
  right: 0;
  border-top: 1.5px solid currentColor;
}

.icon-calendar::before {
  content: '';
  position: absolute;
  top: -3px;
  left: 4px;
  width: 5px;
  height: 5px;
  border-inline: 1.5px solid currentColor;
}

.icon-camera { height: 14px; }
.icon-camera::before {
  content: '';
  position: absolute;
  width: 7px;
  height: 3px;
  top: -3px;
  left: 3px;
  border-radius: 2px 2px 0 0;
  background: currentColor;
}
.icon-camera::after {
  content: '';
  position: absolute;
  inset: 2px 4px;
  aspect-ratio: 1;
  border: 1.5px solid currentColor;
  border-radius: 50%;
}

.avatar {
  width: 36px;
  height: 36px;
  display: grid;
  place-items: center;
  border: 1px solid var(--line);
  border-radius: 50%;
  background: #3b4b40;
  color: var(--text);
  font-weight: 700;
  overflow: hidden;
  flex: none;
}
.avatar img { width: 100%; height: 100%; object-fit: cover; }
.avatar-link {
  width: 44px;
  height: 44px;
  justify-self: end;
  grid-column: 3;
  padding: 0;
}
.avatar-link:hover, .avatar-link[aria-current] { border-color: var(--accent); }
.avatar-large { width: 56px; height: 56px; font-size: 1.25rem; }

.frame { max-width: 1160px; padding: 33px 28px 64px; margin: auto; }
#global-error:not(:empty) { margin-bottom: 16px; }

.page-heading { margin-bottom: 23px; }
h1 {
  font: 400 clamp(2rem, 6vw, 3.7rem)/1.06 Georgia, serif;
  letter-spacing: -.05em;
}
.weekday {
  font-size: .72rem;
  letter-spacing: .12em;
  text-transform: uppercase;
  color: var(--muted);
  margin-bottom: 5px;
  font-weight: 680;
}

h2 { font-size: 1.05rem; line-height: 1.25; letter-spacing: -.015em; }
.surface { border: 1px solid var(--line); border-radius: var(--corner); background: var(--surface); }
.today-layout, .calendar-layout {
  display: grid;
  align-items: start;
  gap: 22px;
  grid-template-columns: minmax(0, 1fr) minmax(240px, 30%);
}
.calendar-layout { grid-template-columns: minmax(0, 1fr) minmax(0, .85fr); }
.today-main, .calendar-day { min-width: 0; }

.checkin { padding: clamp(16px, 3vw, 24px); }
.checkin[data-state="open"] {
  border-color: #62745b;
  background: linear-gradient(132deg, #29372b 0%, var(--surface) 74%);
}
.checkin[data-state="done"] { border-inline-start: 3px solid var(--good); }
.checkin[data-state="missed"] { border-inline-start: 3px solid var(--missed); }
.checkin-top {
  display: flex;
  align-items: center;
  gap: 12px;
  justify-content: space-between;
}
.checkin-top .muted { font-size: .875rem; margin-top: 3px; }
.countdown {
  padding: 7px 11px;
  border: 1px solid #617854;
  border-radius: 8px;
  color: var(--accent);
  background: #1c281f;
  font-size: .9rem;
  font-weight: 700;
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
}

.actions { display: flex; gap: 9px; flex-wrap: wrap; margin-top: 16px; }
.button, .text-button {
  min-height: 44px;
  padding: 9px 16px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  border: 1px solid transparent;
  border-radius: 11px;
  font-weight: 690;
}
.primary { background: var(--accent); color: var(--accent-ink); }
.primary:hover { background: #ffdc93; }
.secondary { border-color: #65786a; background: #243129; }
.secondary:hover { background: #324135; }
.button:disabled { opacity: .55; cursor: default; }
.text-button { background: transparent; color: var(--accent); }
.text-button:hover { text-decoration: underline; }
.file-button { position: relative; overflow: hidden; cursor: pointer; }
.file-button input { position: absolute; inset: 0; width: 100%; height: 100%; opacity: 0; cursor: pointer; }
.file-button:focus-within { outline: 2px solid var(--accent); outline-offset: 4px; }
.selection { margin-top: 14px; border-radius: 12px; overflow: hidden; background: var(--input); }
.selection img { width: 100%; max-height: 55vh; object-fit: contain; }
#upload-error:not(:empty) { margin-top: 12px; }

.daily-feed { margin-top: 18px; }
.section-heading, .side-heading {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  margin-bottom: 10px;
}
.section-heading { min-height: 34px; }
.icon-button {
  width: 42px;
  height: 42px;
  padding: 0;
  border: 1px solid transparent;
  border-radius: 12px;
  background: transparent;
  color: var(--muted);
  font-size: 1.25rem;
  line-height: 1;
}
.icon-button:hover { border-color: var(--line); color: var(--text); }
.posts { display: grid; gap: 13px; }
.empty {
  padding: 20px;
  border: 1px dashed var(--line);
  border-radius: var(--corner);
  color: var(--muted);
  font-size: .93rem;
}
.post {
  border: 1px solid var(--line);
  border-radius: var(--corner);
  overflow: clip;
  background: var(--surface);
}
.post-media {
  display: block;
  width: 100%;
  aspect-ratio: 4 / 3;
  overflow: hidden;
  padding: 0;
  border: 0;
  background: var(--input);
}
.post-media img { width: 100%; height: 100%; object-fit: cover; }
.post-media:focus-visible { outline-offset: -4px; }
.post-byline { display: flex; align-items: center; gap: 10px; padding: 11px 13px; }
.post-byline strong { overflow-wrap: anywhere; }
.post-byline time {
  margin-left: auto;
  color: var(--muted);
  font-size: .8rem;
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
}

.calendar-side, .calendar-main { padding: clamp(12px, 2.5vw, 22px); }
.side-heading { margin: -4px -4px 8px 0; }
.side-heading h2 { padding-block: 4px; }
.weekdays, .month-grid { display: grid; grid-template-columns: repeat(7, minmax(0, 1fr)); gap: 5px; }
.weekdays {
  text-align: center;
  color: var(--muted);
  font-size: .72rem;
  font-weight: 630;
  margin-bottom: 7px;
}
.day {
  position: relative;
  display: grid;
  place-items: center;
  aspect-ratio: 1;
  min-width: 0;
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 0 0 4px;
  background: var(--input);
  color: var(--text);
  font-size: 1.11rem;
  font-variant-numeric: tabular-nums;
}
.day:hover { background: #324135; }
.day[data-state="future"], .day[data-state="before_join"] { color: var(--muted); }
.day[aria-current="date"] { border-color: #9f8655; }
.day[aria-pressed="true"] { background: var(--accent); color: var(--accent-ink); border-color: var(--accent); font-weight: 720; }
.day::after, .calendar-legend i {
  content: '';
  width: 6px;
  height: 6px;
  border-radius: 50%;
  display: inline-block;
}
.day::after { position: absolute; bottom: 10%; }
.day[data-state="done"]::after, .calendar-legend .done { background: var(--good); }
.day[data-state="open"]::after, .calendar-legend .open { border: 1.5px solid var(--accent); }
.day[data-state="missed"]::after, .calendar-legend .missed {
  width: 7px;
  height: 2px;
  border-radius: 1px;
  background: var(--missed);
}
.day[aria-pressed="true"]::after { filter: brightness(.48) saturate(1.35); }

.calendar-side .day { font-size: .8rem; border-radius: 6px; }
.calendar-legend {
  display: flex;
  flex-wrap: wrap;
  gap: 6px 16px;
  margin-top: 12px;
  color: var(--muted);
  font-size: .76rem;
}
.calendar-legend span { display: flex; align-items: center; gap: 6px; }
.calendar-day .section-heading { margin-top: 4px; }

.form-page { max-width: 440px; margin: clamp(5px, 6vh, 65px) auto 0; }
.form-page h1 { margin-bottom: 19px; }
.form { display: grid; gap: 13px; padding: clamp(15px, 4vw, 25px); }
label:not(.file-button) { display: block; font-weight: 620; font-size: .875rem; }
input:not([type="file"]), textarea, select, .form input[type="file"] {
  width: 100%;
  min-height: 44px;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 8px 10px;
  background: var(--input);
  color: var(--text);
  font-size: 1rem;
}
label :is(input,textarea) { display: block; margin-top: 4px; }
input::file-selector-button {
  margin-right: 8px;
  padding: 4px 8px;
  font: inherit;
  font-size: .85rem;
  border: 0;
  border-radius: 4px;
  color: var(--text);
  background: #384a3f;
}
.profile-heading { display: flex; align-items: center; gap: 12px; overflow-wrap: anywhere; }
.admin-heading { align-items: baseline; margin-bottom: 6px; }
.admin-heading h1 { font-size: clamp(1.8rem, 6vw, 2.9rem); }
.entry { display: flex; align-items: center; gap: 10px; justify-content: space-between; padding: 10px 0; }
.entry + .entry { border-top: 1px solid var(--line); }
.entry > :first-child { min-width: 0; overflow-wrap: anywhere; }
.entry-status { display: flex; align-items: center; gap: 7px; font-size: .8rem; color: var(--muted); }
.entry-status[data-state="done"] { color: var(--good); }
.entry-status[data-state="missed"] { color: var(--missed); }
.thumb { padding: 0; border: 0; border-radius: 6px; overflow: hidden; background: var(--input); }
.thumb img { width: 42px; height: 42px; object-fit: cover; }

.archive { margin-top: 12px; padding: 14px; }
.archive summary { font-weight: 650; }
.archive-controls { display: flex; gap: 8px; margin: 12px 0; }
.archive-controls > * { min-width: 0; }

dialog {
  max-width: min(95vw, 960px);
  max-height: 94vh;
  padding: 0;
  border: 1px solid var(--line);
  border-radius: 14px;
  background: var(--bg);
  color: var(--text);
  overflow: auto;
}
dialog::backdrop { background: #000c; }
.dialog-heading {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding: 2px 7px 2px 13px;
}
.dialog-heading span { overflow-wrap: anywhere; }
#dialog-img { max-width: 100%; max-height: 82vh; object-fit: contain; }

@media (max-width: 720px) {
  .masthead-inner {
    min-height: 61px;
    padding-left: max(14px, env(safe-area-inset-left));
    padding-right: max(14px, env(safe-area-inset-right));
    grid-template-columns: minmax(0, 1fr) auto;
  }
  .avatar-link { grid-column: 2; }
  .frame {
    padding: 20px 14px calc(78px + env(safe-area-inset-bottom));
    padding-left: max(14px, env(safe-area-inset-left));
    padding-right: max(14px, env(safe-area-inset-right));
  }
  #navigation {
    position: fixed;
    inset: auto 0 0;
    z-index: 2;
    justify-content: center;
    gap: 0;
    border-top: 1px solid var(--line);
    background: var(--bg);
    padding-bottom: env(safe-area-inset-bottom);
  }
  #navigation button {
    flex: 1;
    max-width: 230px;
    min-height: 56px;
    justify-content: center;
    border: 0;
    border-top: 2px solid transparent;
    padding: 0 7px 2px;
    font-size: .88rem;
  }
  #navigation [aria-current] { border-color: var(--accent); }
  .today-layout, .calendar-layout { grid-template-columns: minmax(0, 1fr); gap: 14px; }
  #today[data-season="active"] .calendar-side { display: none; }
  .page-heading { margin-bottom: 16px; }
  .day { border-radius: 8px; font-size: 1rem; }
  .calendar-side .day { font-size: 1rem; }
}

@media (max-width: 350px) {
  .brand { font-size: .94rem; gap: 7px; }
  .brand img { width: 30px; height: 30px; }
  .checkin h2 { font-size: .94rem; }
  .countdown { padding-inline: 5px; }
}
