:root {
  --bg: #f6f5f1;
  --surface: #ffffff;
  --text: #1d1f23;
  --muted: #646a73;
  --line: #e2e0d8;
  --accent: #23466e;
  --accent-ink: #ffffff;
  --accent-soft: #e5ecf5;
  --danger: #a3261b;
  --flash: #e9f3e6;
  --flash-ink: #24522a;
  --speaker: #1f5fa8;
  --panel: #6b3fa0;
  --research: #2e7d4f;
  --theme: #a8601a;
  --radius: 10px;
  --shadow: 0 1px 2px rgba(20, 20, 30, .05), 0 4px 16px rgba(20, 20, 30, .04);
  color-scheme: light;
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #15171a;
    --surface: #1d2024;
    --text: #e8e6e1;
    --muted: #9aa0a8;
    --line: #2e3238;
    --accent: #8db4e2;
    --accent-ink: #10161d;
    --accent-soft: #23303f;
    --danger: #f08a7e;
    --flash: #1f3324;
    --flash-ink: #b7e0bd;
    --speaker: #7fb0eb;
    --panel: #b99be0;
    --research: #7ccb9b;
    --theme: #e5a964;
    --shadow: none;
    color-scheme: dark;
  }
}

* { box-sizing: border-box; }

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

a { color: var(--accent); text-underline-offset: 2px; }
h1, h2 { line-height: 1.25; font-family: ui-serif, Georgia, "Times New Roman", serif; font-weight: 600; }
h1 { font-size: 1.9rem; margin: .2em 0 .5em; }
h2 { font-size: 1.2rem; margin: 1.6em 0 .6em; }
code.secret { font-size: 1.15rem; padding: .25em .5em; background: var(--accent-soft); border-radius: 6px; user-select: all; }

.wrap { max-width: 1080px; margin: 0 auto; padding: 0 16px; }
main.wrap { padding-top: 24px; padding-bottom: 64px; }
.muted { color: var(--muted); }
.inline { display: inline; margin: 0; }

/* ---------------------------------------------------------------- header */

.top { background: var(--surface); border-bottom: 1px solid var(--line); }
.top-inner { display: flex; align-items: center; gap: 24px; min-height: 58px; flex-wrap: wrap; }
.brand { font-family: ui-serif, Georgia, serif; font-weight: 700; font-size: 1.2rem; color: var(--text); text-decoration: none; }
nav.main { display: flex; gap: 4px; flex: 1; flex-wrap: wrap; }
nav.main a { padding: 6px 12px; border-radius: 8px; color: var(--muted); text-decoration: none; font-weight: 500; }
nav.main a:hover { color: var(--text); background: var(--bg); }
nav.main a[aria-current] { color: var(--text); background: var(--accent-soft); }
.me { display: flex; gap: 12px; align-items: center; font-size: .95rem; }
.me a { color: var(--text); text-decoration: none; font-weight: 500; }

/* ---------------------------------------------------------------- controls */

.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  font: inherit; font-size: .95rem; font-weight: 500;
  padding: 8px 14px; border-radius: 8px; border: 1px solid var(--line);
  background: var(--surface); color: var(--text); cursor: pointer; text-decoration: none;
}
.btn:hover { border-color: var(--muted); }
.btn.primary { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); }
.btn.primary:hover { filter: brightness(1.08); }
.btn.danger { color: var(--danger); }
button.link {
  font: inherit; font-size: .95rem; background: none; border: 0; padding: 0;
  color: var(--accent); cursor: pointer; text-decoration: underline; text-underline-offset: 2px;
}
button.link.danger { color: var(--danger); }

label { display: block; font-weight: 500; margin: 0 0 16px; }
.hint { font-weight: 400; color: var(--muted); font-size: .9rem; }
input:not([type=radio]), textarea, select {
  display: block; width: 100%; margin-top: 6px;
  font: inherit; font-weight: 400; color: var(--text);
  padding: 9px 11px; border: 1px solid var(--line); border-radius: 8px; background: var(--bg);
}
input:focus, textarea:focus, select:focus, .btn:focus-visible, a:focus-visible {
  outline: 2px solid var(--accent); outline-offset: 1px;
}
textarea { resize: vertical; }
.row { display: grid; grid-template-columns: repeat(3, 1fr); gap: 12px; }
fieldset.kinds { border: 0; padding: 0; margin: 0 0 16px; }
fieldset.kinds legend { font-weight: 500; margin-bottom: 8px; padding: 0; }
.pill {
  display: inline-flex; align-items: center; gap: 6px; margin: 0 6px 6px 0;
  padding: 7px 12px; border: 1px solid var(--line); border-radius: 999px; cursor: pointer; font-weight: 400;
}
.pill:has(input:checked) { border-color: var(--accent); background: var(--accent-soft); font-weight: 500; }

/* ---------------------------------------------------------------- blocks */

.card { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 24px; box-shadow: var(--shadow); margin-bottom: 20px; }
.card > h1:first-child, .card > h2:first-child { margin-top: 0; }
.narrow { max-width: 640px; }
.auth { max-width: 420px; margin: 40px auto; }
.flash { background: var(--flash); color: var(--flash-ink); padding: 10px 14px; border-radius: 8px; margin: 0 0 20px; }
.errors { border-left: 3px solid var(--danger); padding: 4px 14px; margin-bottom: 16px; color: var(--danger); }
.errors ul { margin: 6px 0; padding-left: 18px; }
.note { background: var(--accent-soft); padding: 10px 14px; border-radius: 8px; }
.empty { color: var(--muted); padding: 18px 0; }
.page-head, .hero { display: flex; justify-content: space-between; align-items: center; gap: 16px; flex-wrap: wrap; margin-bottom: 8px; }
.actions { display: flex; gap: 8px; flex-wrap: wrap; }
.crumbs { margin: 0 0 12px; color: var(--muted); }
.danger-row { display: flex; gap: 8px; margin-top: 24px; padding-top: 16px; border-top: 1px solid var(--line); }
.prose p { margin: 0 0 1em; }
.when { font-size: 1.05rem; }

.stats { list-style: none; padding: 0; margin: 16px 0 8px; display: grid; grid-template-columns: repeat(4, 1fr); gap: 12px; }
.stats a { display: block; background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 14px 16px; text-decoration: none; color: var(--muted); }
.stats .n { display: block; font-size: 1.8rem; font-weight: 600; color: var(--text); font-variant-numeric: tabular-nums; line-height: 1.2; }
.cols { display: grid; grid-template-columns: 3fr 2fr; gap: 32px; }

/* ---------------------------------------------------------------- suggestions */

.kind {
  display: inline-block; font-size: .75rem; font-weight: 600; letter-spacing: .03em; text-transform: uppercase;
  padding: 2px 8px; border-radius: 999px; text-decoration: none; border: 1px solid currentColor;
}
.kind-speaker { color: var(--speaker); }
.kind-panel { color: var(--panel); }
.kind-research { color: var(--research); }
.kind-theme { color: var(--theme); }

.items { list-style: none; padding: 0; margin: 0; }
.item { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 14px 16px; margin-bottom: 10px; }
.item-head { display: flex; align-items: baseline; gap: 10px; flex-wrap: wrap; }
.item-title { font-weight: 600; font-size: 1.05rem; color: var(--text); text-decoration: none; }
.item-title:hover { text-decoration: underline; }
.excerpt { margin: 6px 0 0; color: var(--muted); overflow-wrap: anywhere; }
.meta { display: flex; gap: 6px 10px; flex-wrap: wrap; align-items: center; margin-top: 8px; font-size: .88rem; }

.tag {
  display: inline-flex; align-items: center; gap: 4px; font: inherit; font-size: .88rem;
  color: var(--accent); background: var(--accent-soft); border: 0; border-radius: 6px;
  padding: 2px 8px; text-decoration: none; cursor: pointer;
}
.tag span { color: var(--muted); font-size: .8rem; }
.tag.on { background: var(--accent); color: var(--accent-ink); }
.tag.on span { color: inherit; opacity: .8; }
.cloud { display: flex; flex-wrap: wrap; gap: 6px; }
.cloud.big .tag { font-size: 1rem; padding: 5px 11px; }
.suggest-tags { display: flex; flex-wrap: wrap; gap: 6px; align-items: center; color: var(--muted); font-size: .9rem; margin-top: -6px; }
.taglist { list-style: none; padding: 0; margin: 0 0 12px; display: flex; flex-wrap: wrap; gap: 6px; }
.taglist li { display: inline-flex; align-items: center; }
.taglist .tag { border-radius: 6px 0 0 6px; }
.taglist li > .tag:only-child { border-radius: 6px; }
button.untag {
  font: inherit; font-size: .88rem; border: 0; background: var(--accent-soft); color: var(--muted);
  padding: 2px 8px 2px 4px; border-radius: 0 6px 6px 0; cursor: pointer;
}
button.untag:hover { color: var(--danger); }
.addtag { display: flex; gap: 8px; max-width: 460px; }
.addtag input { margin-top: 0; }

.tabs { display: flex; gap: 4px; border-bottom: 1px solid var(--line); margin-bottom: 20px; overflow-x: auto; }
.tabs a { padding: 8px 14px; text-decoration: none; color: var(--muted); border-bottom: 2px solid transparent; margin-bottom: -1px; white-space: nowrap; }
.tabs a[aria-current] { color: var(--text); border-bottom-color: var(--accent); font-weight: 500; }
.with-side { display: grid; grid-template-columns: 1fr 260px; gap: 32px; }
.with-side aside h2 { margin-top: 0; }
.search { display: flex; gap: 8px; margin-bottom: 14px; }
.search input { margin-top: 0; }
.filters { color: var(--muted); }
.filters a { text-decoration: none; font-weight: 600; padding: 0 4px; }

/* ---------------------------------------------------------------- calendar */

.month {
  display: grid; grid-template-columns: repeat(7, minmax(0, 1fr));
  border: 1px solid var(--line); border-radius: var(--radius); overflow: hidden; background: var(--line); gap: 1px;
}
.dow { background: var(--surface); padding: 8px; font-size: .8rem; font-weight: 600; color: var(--muted); text-transform: uppercase; letter-spacing: .04em; }
.day { background: var(--surface); min-height: 108px; padding: 6px; display: flex; flex-direction: column; gap: 3px; min-width: 0; }
.day.pad { background: var(--bg); }
.dnum { align-self: flex-start; font-size: .85rem; font-weight: 500; color: var(--muted); text-decoration: none; width: 26px; height: 26px; display: grid; place-items: center; border-radius: 50%; }
.dnum:hover { background: var(--accent-soft); color: var(--accent); }
.today .dnum { background: var(--accent); color: var(--accent-ink); }
.chip {
  display: block; font-size: .8rem; line-height: 1.3; padding: 3px 6px; border-radius: 5px;
  background: var(--accent-soft); color: var(--text); text-decoration: none;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.chip b { color: var(--accent); font-weight: 600; }

.events { list-style: none; padding: 0; margin: 0; }
.events a {
  display: grid; grid-template-columns: 150px 110px 1fr; gap: 2px 12px; align-items: baseline;
  padding: 10px 12px; border-bottom: 1px solid var(--line); color: var(--text); text-decoration: none;
}
.events a:hover { background: var(--surface); }
.events .date { font-weight: 600; }
.events .time { color: var(--muted); font-variant-numeric: tabular-nums; }
.events .muted { grid-column: 3; font-size: .9rem; }
.cols .events a { grid-template-columns: 1fr; }
.cols .events .muted { grid-column: auto; }

/* ---------------------------------------------------------------- admin */

table.users { width: 100%; border-collapse: collapse; }
.users th, .users td { text-align: left; padding: 9px 8px; border-bottom: 1px solid var(--line); vertical-align: top; }
.users th { font-size: .82rem; color: var(--muted); font-weight: 600; text-transform: uppercase; letter-spacing: .04em; }
.users .ops { display: flex; gap: 14px; flex-wrap: wrap; }
.badge { font-size: .72rem; padding: 1px 6px; border-radius: 999px; background: var(--accent-soft); color: var(--accent); font-weight: 600; }
.reveal { border-color: var(--accent); }

/* ---------------------------------------------------------------- small screens */

@media (max-width: 760px) {
  .cols, .with-side { grid-template-columns: 1fr; }
  .stats { grid-template-columns: repeat(2, 1fr); }
  .row { grid-template-columns: 1fr; gap: 0; }
  .top-inner { gap: 8px 16px; padding: 10px 16px; }
  nav.main { order: 3; flex-basis: 100%; }
  .day { min-height: 64px; padding: 3px; }
  .chip { font-size: 0; height: 6px; padding: 0; border-radius: 3px; background: var(--accent); }
  .dow { padding: 6px 2px; text-align: center; font-size: .7rem; }
  .events a { grid-template-columns: 1fr; }
  .events .muted { grid-column: auto; }
  .users thead { display: none; }
  .users tr { display: block; border-bottom: 1px solid var(--line); padding: 8px 0; }
  .users td { display: block; border: 0; padding: 2px 0; }
  .card { padding: 18px; }
  h1 { font-size: 1.6rem; }
}
