:root {
  --bg: #f7f5f0;
  --panel: #fffefb;
  --ink: #191a1f;
  --muted: #6d7078;
  --line: #e4dfd5;
  --accent: #4f46e5;
  --accent-ink: #ffffff;
  --warn-bg: #fff4e5;
  --warn-ink: #8a4b05;
  --shadow: 0 1px 2px rgba(25, 26, 31, 0.04), 0 10px 30px rgba(25, 26, 31, 0.06);
  --radius: 16px;
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #0f1115;
    --panel: #171a21;
    --ink: #eef0f5;
    --muted: #9aa0ab;
    --line: #2a2f3a;
    --accent: #918cff;
    --accent-ink: #12131a;
    --warn-bg: #2a2113;
    --warn-ink: #f3c37c;
    --shadow: 0 1px 2px rgba(0, 0, 0, 0.5);
  }
}

* {
  box-sizing: border-box;
}

html {
  -webkit-text-size-adjust: 100%;
}

body {
  margin: 0;
  background:
    radial-gradient(900px 500px at 15% -10%, color-mix(in srgb, var(--accent) 9%, transparent), transparent 70%),
    var(--bg);
  color: var(--ink);
  font-family: ui-sans-serif, -apple-system, BlinkMacSystemFont, "Segoe UI", Inter, sans-serif;
  font-size: 15px;
  line-height: 1.5;
  min-height: 100vh;
  overflow-x: hidden;
}

.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

.page {
  width: min(880px, 100%);
  margin: 0 auto;
  padding: 40px 20px 72px;
}

/* Top bar ---------------------------------------------------------------- */

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 28px;
}

.brand {
  display: flex;
  align-items: center;
  gap: 14px;
  min-width: 0;
}

.mark {
  width: 44px;
  height: 44px;
  color: var(--accent);
  flex: none;
}

h1 {
  margin: 0;
  font-family: ui-serif, "Iowan Old Style", "Palatino Linotype", Georgia, serif;
  font-size: 30px;
  font-weight: 600;
  letter-spacing: -0.02em;
  line-height: 1;
}

#tagline {
  margin: 4px 0 0;
  color: var(--muted);
  font-size: 13px;
}

.actions {
  display: flex;
  gap: 8px;
  flex: none;
}

.btn {
  appearance: none;
  border: 1px solid var(--line);
  background: var(--panel);
  color: var(--ink);
  border-radius: 10px;
  padding: 9px 14px;
  font: inherit;
  font-size: 14px;
  font-weight: 550;
  line-height: 1.2;
  cursor: pointer;
  text-decoration: none;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  transition: transform 120ms ease, background 120ms ease, border-color 120ms ease;
}

.btn:hover {
  border-color: color-mix(in srgb, var(--ink) 28%, var(--line));
}

.btn:active {
  transform: translateY(1px);
}

.btn:focus-visible,
.chip:focus-visible,
.link:focus-visible,
.icon-btn:focus-visible,
input:focus-visible,
select:focus-visible,
summary:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

.btn.primary {
  background: var(--accent);
  border-color: var(--accent);
  color: var(--accent-ink);
}

.btn.ghost {
  background: transparent;
}

.btn.wide {
  width: 100%;
}

.btn[disabled] {
  opacity: 0.6;
  cursor: progress;
}

/* Controls --------------------------------------------------------------- */

.controls {
  display: flex;
  gap: 10px;
  margin-bottom: 14px;
}

.search {
  flex: 1;
  display: flex;
  align-items: center;
  gap: 10px;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 0 12px;
  box-shadow: var(--shadow);
  min-width: 0;
}

.search svg {
  width: 18px;
  height: 18px;
  color: var(--muted);
  flex: none;
}

.search input {
  flex: 1;
  min-width: 0;
  border: 0;
  background: transparent;
  color: var(--ink);
  font: inherit;
  padding: 12px 0;
  outline: none;
}

.search input::placeholder {
  color: var(--muted);
}

.search kbd {
  border: 1px solid var(--line);
  border-radius: 5px;
  padding: 1px 6px;
  color: var(--muted);
  font-family: inherit;
  font-size: 11px;
}

.select {
  display: flex;
  align-items: center;
  gap: 8px;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 0 10px 0 12px;
  color: var(--muted);
  font-size: 13px;
  box-shadow: var(--shadow);
  flex: none;
}

.select select {
  appearance: none;
  border: 0;
  background: transparent;
  color: var(--ink);
  font: inherit;
  font-size: 14px;
  padding: 12px 4px;
  outline: none;
  cursor: pointer;
}

/* Source chips ----------------------------------------------------------- */

.chips {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-bottom: 18px;
  min-height: 30px;
}

.chip {
  appearance: none;
  display: inline-flex;
  align-items: center;
  gap: 7px;
  border: 1px solid var(--line);
  background: transparent;
  color: var(--muted);
  border-radius: 999px;
  padding: 5px 11px 5px 9px;
  font: inherit;
  font-size: 12.5px;
  cursor: pointer;
  transition: background 120ms ease, color 120ms ease, border-color 120ms ease;
}

.chip[aria-pressed="true"] {
  background: var(--panel);
  border-color: color-mix(in srgb, var(--ink) 22%, var(--line));
  color: var(--ink);
  box-shadow: var(--shadow);
}

.chip[aria-pressed="false"] {
  opacity: 0.6;
}

.dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--dot, var(--muted));
  flex: none;
}

.chip[aria-pressed="false"] .dot {
  filter: grayscale(1);
}

.chip-count {
  color: var(--muted);
  font-variant-numeric: tabular-nums;
}

/* Status + banner -------------------------------------------------------- */

.status {
  margin: 0;
  color: var(--muted);
  font-size: 13px;
}

.viewbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  flex-wrap: wrap;
  margin-bottom: 18px;
}

.segmented {
  display: inline-flex;
  gap: 2px;
  padding: 3px;
  border: 1px solid var(--line);
  border-radius: 11px;
  background: color-mix(in srgb, var(--ink) 4%, transparent);
}

.segment {
  appearance: none;
  border: 0;
  border-radius: 8px;
  padding: 6px 13px;
  background: transparent;
  color: var(--muted);
  font: inherit;
  font-size: 12.5px;
  font-weight: 600;
  cursor: pointer;
  transition: background 120ms ease, color 120ms ease;
}

.segment.is-active {
  background: var(--panel);
  color: var(--ink);
  box-shadow: var(--shadow);
}

.segment:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 1px;
}

.banner {
  margin: 0 0 18px;
  padding: 10px 14px;
  border-radius: 10px;
  background: var(--warn-bg);
  color: var(--warn-ink);
  font-size: 13px;
}

/* Agenda ----------------------------------------------------------------- */

.agenda {
  display: flex;
  flex-direction: column;
  gap: 26px;
}

.day {
  display: grid;
  gap: 10px;
}

.date-title {
  position: sticky;
  top: 0;
  z-index: 1;
  display: flex;
  align-items: baseline;
  gap: 10px;
  margin: 0;
  padding: 10px 2px;
  background: color-mix(in srgb, var(--bg) 88%, transparent);
  backdrop-filter: blur(8px);
  font-family: ui-serif, "Iowan Old Style", Georgia, serif;
  font-size: 17px;
  font-weight: 600;
  letter-spacing: -0.01em;
}

.date-sub {
  font-family: ui-sans-serif, -apple-system, sans-serif;
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--accent);
}

.day-events {
  display: flex;
  flex-direction: column;
  gap: 1px;
  background: var(--line);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  overflow: hidden;
  box-shadow: var(--shadow);
}

.event {
  display: grid;
  grid-template-columns: 92px 1fr;
  gap: 14px;
  background: var(--panel);
  padding: 14px 16px;
  transition: background 120ms ease;
}

.event:hover {
  background: color-mix(in srgb, var(--panel) 88%, var(--accent) 4%);
}

.event-time {
  display: flex;
  flex-direction: column;
  gap: 1px;
  color: var(--ink);
  font-size: 13px;
  font-weight: 600;
  font-variant-numeric: tabular-nums;
  padding-top: 2px;
}

.event-time .end {
  color: var(--muted);
  font-weight: 450;
}

.event-body {
  min-width: 0;
}

.event-title {
  margin: 0;
  font-size: 15.5px;
  font-weight: 600;
  line-height: 1.35;
  letter-spacing: -0.005em;
}

.event-title a {
  color: inherit;
  text-decoration: none;
}

.event-title a:hover {
  text-decoration: underline;
  text-underline-offset: 3px;
  text-decoration-color: var(--muted);
}

.event-meta {
  margin: 3px 0 0;
  color: var(--muted);
  font-size: 13px;
  overflow-wrap: anywhere;
}

.event-tags {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-top: 8px;
}

.tag {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  color: var(--muted);
  font-size: 11px;
  border: 1px solid var(--line);
  border-radius: 999px;
  padding: 1px 7px;
}

.tag.lang {
  font-weight: 650;
  letter-spacing: 0.04em;
  color: var(--ink);
  background: color-mix(in srgb, var(--accent) 12%, transparent);
  border-color: transparent;
}

.tag.event-type {
  font-weight: 650;
  color: var(--ink);
  background: color-mix(in srgb, var(--ink) 7%, transparent);
  border-color: transparent;
}

.tag-platform {
  color: var(--muted);
  font-size: 9px;
  font-weight: 650;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  border-left: 1px solid var(--line);
  padding-left: 5px;
  margin-left: 1px;
}

.event-details {
  margin-top: 7px;
  color: var(--muted);
  font-size: 13px;
}

.event-details summary {
  cursor: pointer;
  width: fit-content;
  font-size: 12px;
  color: var(--muted);
}

.event-details p {
  margin: 6px 0 0;
  white-space: pre-wrap;
  overflow-wrap: anywhere;
}

/* Month view ------------------------------------------------------------- */

.month {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.month-head {
  display: flex;
  align-items: center;
  gap: 8px;
}

.month-title {
  flex: 1;
  margin: 0;
  font-family: ui-serif, "Iowan Old Style", Georgia, serif;
  font-size: 21px;
  font-weight: 600;
  letter-spacing: -0.01em;
}

.month-nav {
  display: flex;
  gap: 6px;
}

.month-nav button {
  appearance: none;
  height: 34px;
  min-width: 34px;
  padding: 0 9px;
  border: 1px solid var(--line);
  border-radius: 9px;
  background: var(--panel);
  color: var(--ink);
  font: inherit;
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
}

.month-nav button:hover {
  border-color: color-mix(in srgb, var(--ink) 25%, var(--line));
}

.month-weekdays {
  display: grid;
  grid-template-columns: repeat(7, minmax(0, 1fr));
  gap: 1px;
}

.month-weekdays span {
  padding: 4px 0;
  text-align: center;
  color: var(--muted);
  font-size: 10px;
  font-weight: 650;
  letter-spacing: 0.07em;
  text-transform: uppercase;
}

.month-grid {
  display: grid;
  grid-template-columns: repeat(7, minmax(0, 1fr));
  gap: 1px;
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--line);
  box-shadow: var(--shadow);
}

.day-cell {
  appearance: none;
  display: flex;
  flex-direction: column;
  gap: 4px;
  min-width: 0;
  min-height: 98px;
  padding: 6px;
  border: 0;
  background: var(--panel);
  color: var(--ink);
  font: inherit;
  text-align: left;
  cursor: pointer;
  overflow: hidden;
  transition: background 120ms ease;
}

.day-cell:hover {
  background: color-mix(in srgb, var(--panel) 90%, var(--accent) 5%);
}

.day-cell:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: -2px;
}

.day-cell.is-outside {
  opacity: 0.38;
}

.day-cell.is-selected {
  background: color-mix(in srgb, var(--accent) 8%, var(--panel));
  box-shadow: inset 0 0 0 2px var(--accent);
}

.day-num {
  display: grid;
  place-items: center;
  width: 23px;
  height: 23px;
  border-radius: 50%;
  font-size: 12px;
  font-weight: 650;
  font-variant-numeric: tabular-nums;
}

.day-cell.is-today .day-num {
  background: var(--accent);
  color: var(--accent-ink);
}

.day-mini {
  display: flex;
  flex-direction: column;
  gap: 2px;
  min-width: 0;
}

.mini-event {
  display: flex;
  align-items: center;
  gap: 4px;
  min-width: 0;
  color: var(--muted);
  font-size: 10.5px;
  line-height: 1.35;
}

.mini-event span:last-child {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.mini-event .dot {
  width: 5px;
  height: 5px;
}

.day-more {
  color: var(--muted);
  font-size: 10px;
  font-weight: 600;
}

.day-dots {
  display: none;
}

.day-detail {
  display: flex;
  flex-direction: column;
  gap: 10px;
  margin-top: 6px;
}

.day-detail-head {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 12px;
}

.day-detail-head h3 {
  margin: 0;
  font-family: ui-serif, "Iowan Old Style", Georgia, serif;
  font-size: 18px;
  font-weight: 600;
}

.day-detail-head span {
  color: var(--muted);
  font-size: 12px;
}

/* Empty + loading -------------------------------------------------------- */

.empty {
  border: 1px dashed var(--line);
  border-radius: var(--radius);
  padding: 44px 20px;
  text-align: center;
  color: var(--muted);
  background: color-mix(in srgb, var(--panel) 60%, transparent);
}

.empty strong {
  display: block;
  color: var(--ink);
  margin-bottom: 4px;
}

/* Watchlist -------------------------------------------------------------- */

.watchlist {
  margin-top: 44px;
  border-top: 1px solid var(--line);
  padding-top: 24px;
}

.watchlist h2 {
  margin: 0 0 4px;
  font-family: ui-serif, "Iowan Old Style", Georgia, serif;
  font-size: 18px;
  font-weight: 600;
}

.muted {
  color: var(--muted);
}

.watchlist > .muted {
  margin: 0 0 14px;
  font-size: 13px;
}

.watchlist ul {
  list-style: none;
  margin: 0;
  padding: 0;
  display: grid;
  gap: 8px;
}

.watchlist li {
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 12px 14px;
  background: color-mix(in srgb, var(--panel) 70%, transparent);
}

.watchlist li a {
  color: var(--ink);
  font-weight: 600;
  text-decoration: none;
}

.watchlist li a:hover {
  text-decoration: underline;
}

.watchlist li p {
  margin: 4px 0 0;
  color: var(--muted);
  font-size: 13px;
}

.watchlist .contact {
  display: inline-block;
  margin-top: 4px;
  font-size: 12px;
  color: var(--muted);
}

/* Footer ----------------------------------------------------------------- */

.footer {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-top: 48px;
  padding-top: 18px;
  border-top: 1px solid var(--line);
  color: var(--muted);
  font-size: 12px;
  flex-wrap: wrap;
}

.footer-label {
  text-transform: uppercase;
  letter-spacing: 0.08em;
  font-size: 10px;
  font-weight: 650;
}

.footer code {
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  font-size: 11.5px;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 6px;
  padding: 2px 6px;
  overflow-wrap: anywhere;
}

.link {
  appearance: none;
  border: 0;
  background: none;
  color: var(--accent);
  font: inherit;
  font-size: 12px;
  cursor: pointer;
  padding: 2px 0;
}

/* Dialog ----------------------------------------------------------------- */

.dialog {
  width: min(440px, calc(100vw - 32px));
  border: 1px solid var(--line);
  border-radius: 18px;
  background: var(--panel);
  color: var(--ink);
  padding: 22px;
  box-shadow: 0 24px 80px rgba(0, 0, 0, 0.24);
}

.dialog::backdrop {
  background: rgba(10, 12, 18, 0.45);
  backdrop-filter: blur(2px);
}

.dialog-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.dialog h2 {
  margin: 0;
  font-family: ui-serif, "Iowan Old Style", Georgia, serif;
  font-size: 21px;
  font-weight: 600;
}

.dialog .muted {
  margin: 6px 0 16px;
  font-size: 13px;
}

.icon-btn {
  appearance: none;
  border: 0;
  background: transparent;
  color: var(--muted);
  font-size: 24px;
  line-height: 1;
  cursor: pointer;
  padding: 2px 6px;
  border-radius: 8px;
}

.field {
  display: block;
  margin: 16px 0;
  font-size: 12px;
  color: var(--muted);
}

.field > span {
  display: block;
  margin-bottom: 6px;
  text-transform: uppercase;
  letter-spacing: 0.07em;
  font-size: 10px;
  font-weight: 650;
}

.copy-row {
  display: flex;
  gap: 6px;
}

.copy-row input {
  flex: 1;
  min-width: 0;
  border: 1px solid var(--line);
  background: var(--bg);
  color: var(--ink);
  border-radius: 9px;
  padding: 9px 10px;
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  font-size: 11.5px;
}

.hint {
  margin: 0 0 16px;
  padding: 12px 14px;
  border-radius: 10px;
  background: color-mix(in srgb, var(--accent) 7%, transparent);
  color: var(--muted);
  font-size: 12px;
}

.hint p {
  margin: 0 0 6px;
}

.hint p:last-child {
  margin-bottom: 0;
}

.hint strong {
  color: var(--ink);
}

/* Mobile ----------------------------------------------------------------- */

@media (max-width: 620px) {
  .page {
    padding: 24px 14px 56px;
  }

  .topbar {
    align-items: flex-start;
  }

  h1 {
    font-size: 26px;
  }

  #tagline {
    display: none;
  }

  .actions .btn {
    padding: 8px 11px;
    font-size: 13px;
  }

  .controls {
    flex-wrap: wrap;
  }

  .search {
    flex-basis: 100%;
  }

  .select {
    flex: 1;
    justify-content: space-between;
  }

  .viewbar {
    gap: 8px;
  }

  .viewbar .status {
    flex: 1 1 100%;
    font-size: 12px;
  }

  .segmented {
    flex: none;
  }

  .chips {
    flex-wrap: nowrap;
    overflow-x: auto;
    padding-bottom: 2px;
    scrollbar-width: none;
  }

  .chips::-webkit-scrollbar {
    display: none;
  }

  .chip {
    flex: none;
  }

  .event {
    grid-template-columns: 68px 1fr;
    gap: 10px;
    padding: 13px 13px;
  }

  .event-time {
    font-size: 12px;
  }

  .event-title {
    font-size: 14.5px;
    overflow-wrap: anywhere;
  }

  .date-title {
    font-size: 15.5px;
  }

  .month-title {
    font-size: 17px;
  }

  .month-head {
    gap: 6px;
  }

  .month-nav button {
    height: 30px;
    min-width: 30px;
    padding: 0 7px;
  }

  .month-grid {
    border-radius: 12px;
  }

  .month-weekdays span {
    font-size: 9px;
    letter-spacing: 0.04em;
  }

  .day-cell {
    min-height: 62px;
    padding: 4px;
    align-items: center;
    gap: 3px;
  }

  .day-mini {
    display: none;
  }

  .day-dots {
    display: flex;
    flex-wrap: wrap;
    justify-content: center;
    gap: 3px;
    max-width: 100%;
  }

  .day-dots .dot {
    width: 5px;
    height: 5px;
  }

  .day-num {
    width: 20px;
    height: 20px;
    font-size: 11px;
  }

  .day-detail-head h3 {
    font-size: 16px;
  }
}

@media (max-width: 520px) {
  .controls .select > span {
    display: none;
  }

  .controls .select {
    padding-left: 10px;
  }
}

@media (prefers-reduced-motion: reduce) {
  * {
    transition: none !important;
  }
}
