:root {
  --bg: #fbf7f2;
  --surface: #ffffff;
  --text: #2b2420;
  --muted: #7a6e66;
  --border: #ebe2d8;
  --accent: #d9622b;
  --accent-text: #ffffff;
  --accent-soft: #fbe6da;
  --going: #2f8a57;
  --going-soft: #dff2e7;
  --danger: #b3261e;
  --shadow: 0 1px 2px rgb(60 40 20 / 6%), 0 4px 16px rgb(60 40 20 / 6%);
  color-scheme: light;
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #1c1916;
    --surface: #26221e;
    --text: #f1ebe5;
    --muted: #a99d93;
    --border: #3a342e;
    --accent: #f0814c;
    --accent-text: #1c1916;
    --accent-soft: #4a2e20;
    --going: #6fcf97;
    --going-soft: #1f3a2a;
    --danger: #ff8a80;
    --shadow: none;
    color-scheme: dark;
  }
}

* { box-sizing: border-box; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font: 16px/1.5 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
}

.wrap { max-width: 720px; margin: 0 auto; padding: 0 16px; }

.top { background: var(--surface); border-bottom: 1px solid var(--border); }
.top-inner { display: flex; align-items: center; justify-content: space-between; gap: 12px; min-height: 60px; }
.top h1 { margin: 0; font-size: 1.25rem; }
.who {
  border: 1px solid var(--border); background: transparent; color: var(--muted);
  border-radius: 999px; padding: 4px 12px; font: inherit; font-size: .9rem; cursor: pointer;
  max-width: 50%; overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.who:hover { color: var(--text); }

.intro { display: flex; align-items: center; justify-content: space-between; gap: 16px; margin: 24px 0 8px; }
.intro p { margin: 0; color: var(--muted); }

.status { color: var(--muted); }
.status:empty { display: none; }

.month { margin: 28px 0 10px; font-size: .85rem; text-transform: uppercase; letter-spacing: .06em; color: var(--muted); }

.event {
  display: flex; gap: 16px; padding: 16px; margin-bottom: 12px;
  background: var(--surface); border: 1px solid var(--border); border-radius: 14px; box-shadow: var(--shadow);
}
.event.is-going { border-color: var(--going); }

.date {
  flex: 0 0 64px; display: flex; flex-direction: column; align-items: center; justify-content: center;
  background: var(--accent-soft); border-radius: 10px; padding: 8px 4px; align-self: flex-start;
}
.date .wd { font-size: .75rem; color: var(--muted); }
.date .day { font-size: 1.6rem; font-weight: 700; line-height: 1.1; }
.date .mon { font-size: .8rem; }

.body { flex: 1; min-width: 0; }
.body .title { margin: 0; font-size: 1.1rem; overflow-wrap: anywhere; }
.body .time { margin: 2px 0 0; color: var(--muted); font-size: .95rem; }
.body .desc { margin: 8px 0 0; white-space: pre-line; overflow-wrap: anywhere; }
.body .desc:empty { display: none; }
.body .attendees { margin: 10px 0 0; font-size: .9rem; color: var(--muted); }
.body .meta { margin: 8px 0 0; font-size: .8rem; color: var(--muted); }
.body .meta:empty { display: none; }
.body .meta a { color: inherit; }

.actions { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 12px; }

.btn {
  font: inherit; font-size: .95rem; border-radius: 999px; padding: 8px 16px; cursor: pointer;
  border: 1px solid var(--border); background: var(--surface); color: var(--text); white-space: nowrap;
}
.btn:disabled { opacity: .6; cursor: progress; }
.btn.primary { background: var(--accent); border-color: var(--accent); color: var(--accent-text); font-weight: 600; }
.btn.going { background: var(--going-soft); border-color: var(--going); color: var(--going); font-weight: 600; }
.btn.quiet { border-color: transparent; background: transparent; color: var(--muted); }
.btn.quiet.delete:hover { color: var(--danger); }

.empty { text-align: center; padding: 48px 16px; color: var(--muted); }

dialog {
  width: min(520px, calc(100vw - 32px)); border: 1px solid var(--border); border-radius: 16px;
  padding: 24px; background: var(--surface); color: var(--text);
}
dialog::backdrop { background: rgb(0 0 0 / 40%); }
dialog h2 { margin: 0 0 12px; font-size: 1.2rem; }
dialog p { margin: 0 0 12px; color: var(--muted); }
dialog label { display: block; margin-bottom: 12px; font-size: .9rem; font-weight: 600; }
dialog small { font-weight: 400; color: var(--muted); }
dialog input, dialog textarea {
  display: block; width: 100%; margin-top: 4px; padding: 8px 10px; font: inherit; font-weight: 400;
  border: 1px solid var(--border); border-radius: 8px; background: var(--bg); color: var(--text);
}
dialog textarea { resize: vertical; }
dialog .row { display: grid; grid-template-columns: 1.4fr 1fr 1fr; gap: 10px; }
.form-error { color: var(--danger) !important; }
.dialog-actions { display: flex; justify-content: flex-end; gap: 8px; margin-top: 8px; }

@media (max-width: 520px) {
  .intro { flex-direction: column; align-items: stretch; }
  .event { gap: 12px; padding: 14px; }
  .date { flex-basis: 54px; }
  dialog .row { grid-template-columns: 1fr 1fr; }
  dialog .row label:first-child { grid-column: 1 / -1; }
}
