:root {
  --background: #ededeb;
  --foreground: #191919;
  --muted: #6c6c69;
  --line: #9b9b97;
  --content-width: 980px;
  --font: "Courier New", Courier, monospace;
}

* { box-sizing: border-box; }
html { background: var(--background); color: var(--foreground); font-family: var(--font); }
body { margin: 0; }
button, input { color: inherit; font: inherit; }
button { cursor: pointer; }
[hidden] { display: none !important; }

.site-header {
  background: rgba(237, 237, 235, .96);
  border-bottom: 1px solid var(--line);
  position: sticky;
  top: 0;
  z-index: 10;
}

.header-inner,
.dialog-header {
  align-items: center;
  display: grid;
  grid-template-columns: 1fr auto 1fr;
  margin: 0 auto;
  max-width: var(--content-width);
  min-height: 54px;
  padding: 0 18px;
}

.wordmark,
.dialog-header a { color: inherit; justify-self: start; text-decoration: none; }
.header-inner form,
.dialog-header form { justify-self: end; }
.home-button,
.logout,
.dialog-header button {
  background: none;
  border: 0;
  padding: 8px;
  text-decoration: underline;
  text-underline-offset: 3px;
}

main { margin: 0 auto; max-width: var(--content-width); padding: 0 18px 80px; }

.startup {
  margin-top: 16px;
  padding: 48px 18px;
  text-align: center;
}

.startup p {
  font-size: 18px;
  line-height: 1.6;
  margin: 0;
}

.view-selector {
  border-bottom: 1px solid var(--line);
  border-top: 1px solid var(--line);
  display: flex;
  gap: clamp(30px, 12vw, 130px);
  justify-content: center;
  margin: 34px 0 18px;
  padding: 18px;
}

.view-button {
  background: none;
  border: 0;
  color: var(--muted);
  padding: 4px;
}

.view-button:hover,
.view-button.active { color: var(--foreground); font-weight: bold; }

.month { border-bottom: 1px solid var(--line); }
.month:first-child { border-top: 1px solid var(--line); }

.month-heading {
  align-items: center;
  background: var(--background);
  cursor: pointer;
  display: flex;
  font-weight: bold;
  justify-content: space-between;
  list-style: none;
  padding: 15px 10px;
  position: sticky;
  top: 54px;
  z-index: 2;
}

.month-heading::-webkit-details-marker { display: none; }
.month-heading:hover { background: #e1e1de; }
.month-state::after { content: "[ + ]"; font-weight: normal; }
.month[open] .month-state::after { content: "[ - ]"; }

.memory-grid {
  display: grid;
  gap: 52px 26px;
  grid-template-columns: repeat(auto-fit, minmax(min(100%, 280px), 440px));
  justify-content: center;
  padding: 38px 12px 60px;
}

.memory-card {
  background: none;
  border: 0;
  display: grid;
  padding: 0;
  width: 100%;
}

.memory-card img {
  aspect-ratio: 4 / 3;
  display: block;
  object-fit: cover;
  transition: opacity 120ms linear;
  width: 100%;
}

.memory-card:hover img { opacity: .72; }
.memory-card:focus-visible { outline: 1px dashed var(--foreground); outline-offset: 5px; }
.card-date { font-size: 11px; justify-self: end; padding-top: 7px; }

.random-view { margin: 0 auto; max-width: 780px; padding: 28px 0; }
.random-media { position: relative; }
.random-media > p { font-size: 11px; margin: 0 0 8px; text-align: right; }
.random-image { background: none; border: 0; display: block; padding: 0; width: 100%; }
.random-image img { display: block; height: min(66vh, 650px); object-fit: contain; transition: opacity 120ms linear; width: 100%; }
.random-image:hover img { opacity: .72; }
.random-footer { align-items: center; display: flex; justify-content: space-between; min-height: 48px; }
.random-footer button,
.dialog-nav button { background: none; border: 0; padding: 9px; }
.random-footer button:disabled { color: var(--muted); cursor: default; text-decoration: none; }
.random-footer button:hover,
.dialog-nav button:hover { text-decoration: underline; text-underline-offset: 3px; }

.memory-dialog {
  background: var(--background);
  border: 0;
  height: 100vh;
  max-height: none;
  max-width: none;
  padding: 0;
  width: 100vw;
}

.memory-dialog::backdrop { background: var(--background); }
.dialog-header { border-bottom: 1px solid var(--line); }
.dialog-content { margin: 0 auto; max-width: var(--content-width); padding: 48px 18px 30px; }
.dialog-layout { align-items: center; display: grid; gap: 42px; grid-template-columns: minmax(0, 1.8fr) minmax(220px, 1fr); }
.dialog-visual { min-width: 0; }
.dialog-layout figure { margin: 0; }
.dialog-layout img { display: block; max-height: calc(100vh - 180px); object-fit: contain; width: 100%; }
.dialog-layout article { line-height: 1.6; }
.dialog-layout article p:first-child { color: var(--muted); font-size: 11px; margin: 0 0 28px; }
#dialog-story { margin: 0; white-space: pre-line; }
#dialog-story a { color: inherit; text-decoration: underline; text-underline-offset: 3px; }
.audio-toggle {
  background: none;
  border: 0;
  display: block;
  margin-top: 34px;
  padding: 4px;
}
.audio-toggle svg { fill: var(--foreground); height: 22px; width: 22px; }
.audio-toggle path:not(:first-child) { fill: none; stroke: var(--foreground); stroke-linecap: round; stroke-width: 1.5; }
.audio-toggle .sound-waves { display: none; }
.audio-toggle[aria-pressed="true"] .sound-waves { display: block; }
.audio-toggle[aria-pressed="true"] .sound-muted { display: none; }
.audio-toggle:hover { opacity: .6; }
.dialog-nav { display: flex; justify-content: space-between; margin-top: 8px; }

.login-page { min-height: 100vh; }
.login-shell { display: grid; grid-template-rows: minmax(180px, 38vh) 1fr; min-height: 100vh; }
.login-header { align-items: center; border-bottom: 1px solid var(--line); display: flex; font-size: 18px; justify-content: center; }
.login-panel { align-items: center; display: flex; flex-direction: column; padding: 10vh 18px 50px; }
.login-panel h1 { font-size: 18px; margin: 0 0 42px; }
.login-panel form { display: grid; grid-template-columns: 100px minmax(160px, 260px); }
.login-panel label { align-self: center; font-size: 13px; }
.login-panel input { background: transparent; border: 0; border-bottom: 1px solid var(--foreground); border-radius: 0; outline: 0; padding: 9px 4px; }
.login-panel input:focus { background: #dfdfdc; }
.login-panel form button { background: none; border: 0; grid-column: 2; justify-self: end; margin-top: 28px; padding: 8px 0; }
.login-panel form button:hover { text-decoration: underline; text-underline-offset: 3px; }
.form-error { color: #8e2018; font-size: 11px; grid-column: 1 / -1; line-height: 1.5; margin: 18px 0 0; text-align: center; }

@media (max-width: 680px) {
  .header-inner,
  .dialog-header { padding: 0 12px; }
  main { padding-left: 12px; padding-right: 12px; }
  .startup { padding: 38px 12px; }
  .view-selector { margin-top: 24px; }
  .memory-grid { display: grid; gap: 42px; padding: 28px 4px 46px; }
  .dialog-content { padding: 20px 12px; }
  .dialog-layout { display: block; }
  .dialog-layout figure { align-items: center; display: flex; height: 52vh; justify-content: center; }
  .dialog-layout img { max-height: 100%; }
  .dialog-layout article { border-top: 1px solid var(--line); margin-top: 18px; padding-top: 22px; }
  .dialog-layout article p:first-child { margin-bottom: 18px; }
  .dialog-nav { margin-top: 8px; }
  .login-panel form { grid-template-columns: 85px minmax(150px, 230px); }
}

@media (prefers-reduced-motion: reduce) {
  .memory-card img,
  .random-image img { transition: none; }
}
