/* Comus borrelplanner — colors taken from the Comus crest. */
:root {
  --bg: #170305;
  --bg-glow: #4a0b0f;
  --surface: #26070a;
  --surface-2: #33090d;
  --line: rgba(217, 160, 58, 0.2);
  --line-strong: rgba(217, 160, 58, 0.42);
  --gold: #d9a03a;
  --gold-bright: #f0c565;
  --cream: #f3ead8;
  --muted: rgba(243, 234, 216, 0.66);
  --faint: rgba(243, 234, 216, 0.38);
  --wine: #600204;
  --danger: #ff8f7f;
  --warn-bg: rgba(255, 143, 127, 0.1);
  --radius: 14px;
  --display: 'Cinzel', 'Trajan Pro', Georgia, serif;
  --body: 'Manrope', system-ui, -apple-system, 'Segoe UI', sans-serif;
  color-scheme: dark;
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }

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

body {
  margin: 0;
  min-height: 100vh;
  background:
    radial-gradient(1200px 600px at 50% -200px, var(--bg-glow), transparent 70%),
    var(--bg);
  color: var(--cream);
  font: 400 16px/1.5 var(--body);
  padding: 0 16px calc(32px + env(safe-area-inset-bottom));
}

main, .masthead, .footer { max-width: 960px; margin-inline: auto; }

h1, h2, h3 { font-family: var(--display); font-weight: 700; letter-spacing: 0.02em; margin: 0; }
h1 { font-size: clamp(1.6rem, 5vw, 2.2rem); color: var(--gold-bright); line-height: 1.1; }
h2 { font-size: 1.15rem; color: var(--gold); }
h3 { font-size: 1.05rem; }
p { margin: 0; }
a { color: var(--gold-bright); text-underline-offset: 3px; }

.muted { color: var(--muted); }
.small { font-size: 0.875rem; }
.eyebrow {
  font-size: 0.75rem;
  font-weight: 700;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--gold);
}

.card {
  background: linear-gradient(180deg, var(--surface-2), var(--surface));
  border: 1px solid var(--line);
  border-radius: var(--radius);
}

/* Masthead */
.masthead {
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 24px 0 20px;
}
.crest {
  width: 64px;
  height: 64px;
  border-radius: 50%;
  object-fit: cover;
  border: 2px solid var(--gold);
  box-shadow: 0 0 0 4px rgba(217, 160, 58, 0.12);
  flex: none;
}
.masthead-text { flex: 1; min-width: 0; }
.name-chip {
  flex: none;
  max-width: 40%;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  font: 600 0.8rem var(--body);
  color: var(--muted);
  background: transparent;
  border: 1px solid var(--line);
  border-radius: 999px;
  padding: 6px 12px;
  cursor: pointer;
}
.name-chip:hover { color: var(--cream); border-color: var(--line-strong); }

/* Buttons */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  min-height: 44px;
  padding: 0 18px;
  font: 700 0.92rem var(--body);
  color: var(--cream);
  background: rgba(243, 234, 216, 0.06);
  border: 1px solid var(--line-strong);
  border-radius: 999px;
  cursor: pointer;
  white-space: nowrap;
  transition: background 0.15s, border-color 0.15s, transform 0.1s;
}
.btn:hover { background: rgba(243, 234, 216, 0.12); }
.btn:active { transform: scale(0.98); }
.btn.primary { background: var(--gold); border-color: var(--gold); color: #2a0507; }
.btn.primary:hover { background: var(--gold-bright); }
.btn.ghost { background: transparent; border-color: transparent; color: var(--muted); }
.btn.ghost:hover { color: var(--cream); background: rgba(243, 234, 216, 0.06); }
.btn.danger { background: transparent; border-color: transparent; color: var(--danger); padding-inline: 8px; }
.btn:disabled { opacity: 0.6; cursor: wait; }
.link {
  font: 600 0.875rem var(--body);
  color: var(--gold-bright);
  background: none;
  border: 0;
  padding: 6px 0;
  cursor: pointer;
  text-decoration: underline;
  text-underline-offset: 3px;
  text-decoration-color: var(--line-strong);
}
.link:hover { text-decoration-color: currentColor; }
:focus-visible { outline: 2px solid var(--gold-bright); outline-offset: 2px; }

/* Hero */
.hero {
  --house: var(--gold);
  position: relative;
  overflow: hidden;
  padding: 24px 22px 22px;
  display: grid;
  gap: 10px;
  border-color: var(--line-strong);
}
.hero::before {
  content: '';
  position: absolute;
  inset: 0 auto 0 0;
  width: 5px;
  background: var(--house);
}
.hero-top { display: flex; align-items: center; justify-content: space-between; gap: 12px; }
.hero-title { font-size: clamp(1.6rem, 6vw, 2.4rem); color: var(--cream); line-height: 1.15; }
.hero-time { color: var(--gold-bright); margin-left: 0.4em; }
.hero-theme { font-size: 1.15rem; font-weight: 600; }
.hero-with { color: var(--muted); }
.hero-with strong { color: var(--cream); }
.hero-place { display: flex; flex-wrap: wrap; align-items: center; gap: 4px 8px; font-size: 1.05rem; }
.hero-place strong { color: var(--house); }
.hero-notes { color: var(--muted); white-space: pre-line; }
.hero-actions { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 8px; }
.dot { width: 10px; height: 10px; border-radius: 50%; background: var(--house); flex: none; }
.mark { width: 20px; height: 20px; object-fit: contain; flex: none; }
.house-head .mark { width: 28px; height: 28px; }

.pill {
  display: inline-block;
  font-size: 0.75rem;
  font-weight: 700;
  padding: 3px 10px;
  border-radius: 999px;
  border: 1px solid var(--line-strong);
  color: var(--muted);
  white-space: nowrap;
}
.pill.bevestigd { border-color: rgba(143, 214, 165, 0.5); color: #9fe0b2; }
.pill.voorstel { border-style: dashed; }

/* Sections */
.section { margin-top: 36px; }
.section-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 8px 16px;
  margin-bottom: 14px;
}

/* Tally */
.tally { padding: 14px 18px; display: grid; gap: 10px; }
.tally-row {
  display: grid;
  grid-template-columns: 12rem 1fr 2.5rem;
  align-items: center;
  gap: 12px;
}
.tally-name { font-weight: 600; display: flex; align-items: center; gap: 8px; min-width: 0; }
.tally-bar { height: 10px; border-radius: 999px; background: rgba(243, 234, 216, 0.07); overflow: hidden; }
.tally-bar span { display: block; height: 100%; background: var(--house); border-radius: inherit; transition: width 0.4s ease; }
.tally-count { text-align: right; font-variant-numeric: tabular-nums; color: var(--muted); }
.tally-row.is-next .tally-name { color: var(--house); }
.tally-badge {
  font-size: 0.68rem;
  font-weight: 700;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: #1d0406;
  background: var(--house);
  border-radius: 999px;
  padding: 1px 7px;
  white-space: nowrap;
}

/* Tabs */
.tabs {
  display: inline-flex;
  padding: 4px;
  gap: 4px;
  margin-bottom: 14px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: var(--surface);
}
.tabs button {
  font: 600 0.875rem var(--body);
  color: var(--muted);
  background: transparent;
  border: 0;
  border-radius: 999px;
  padding: 8px 16px;
  min-height: 36px;
  cursor: pointer;
}
.tabs button[aria-selected='true'] { background: var(--gold); color: #2a0507; }

/* Borrel rows */
.list { display: grid; gap: 8px; }
.row {
  --house: var(--faint);
  display: flex;
  align-items: center;
  gap: 12px;
  padding-right: 16px;
  background: var(--surface);
  border: 1px solid var(--line);
  border-left: 4px solid var(--house);
  border-radius: 12px;
  transition: background 0.15s;
}
.row:hover { background: var(--surface-2); }
.row-open {
  flex: 1;
  min-width: 0;
  display: grid;
  grid-template-columns: 56px 1fr;
  align-items: center;
  gap: 14px;
  padding: 12px 0 12px 12px;
  text-align: left;
  font: inherit;
  color: inherit;
  background: none;
  border: 0;
  border-radius: 12px 0 0 12px;
  cursor: pointer;
}
.row-side { flex: none; display: flex; align-items: center; gap: 10px; }
.btn.small { min-height: 36px; padding: 0 14px; font-size: 0.85rem; }
.row-date { display: grid; justify-items: center; line-height: 1.05; }
.row-day { font-family: var(--display); font-size: 1.5rem; font-weight: 700; color: var(--cream); }
.row-mon { font-size: 0.75rem; text-transform: uppercase; letter-spacing: 0.1em; color: var(--gold); }
.row-main { display: grid; gap: 2px; min-width: 0; }
.row-title { font-weight: 700; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.row-meta { color: var(--muted); font-size: 0.9rem; }
.row-meta strong { color: var(--house); font-weight: 700; }
.row-by { color: var(--faint); font-size: 0.78rem; }
.empty { padding: 28px 20px; text-align: center; color: var(--muted); border: 1px dashed var(--line-strong); border-radius: var(--radius); }

/* Calendar */
.cal { padding: 12px; }
.cal-head { display: flex; align-items: center; gap: 8px; margin-bottom: 10px; }
.cal-head h3 { flex: 1; text-align: center; color: var(--cream); }
.cal-head h3::first-letter { text-transform: uppercase; }
.cal-nav {
  width: 40px;
  height: 40px;
  border-radius: 50%;
  border: 1px solid var(--line);
  background: transparent;
  color: var(--cream);
  font-size: 1.1rem;
  cursor: pointer;
}
.cal-nav:hover { border-color: var(--line-strong); }
.cal-grid { display: grid; grid-template-columns: repeat(7, minmax(0, 1fr)); gap: 4px; }
.cal-dow { text-align: center; font-size: 0.72rem; font-weight: 700; text-transform: uppercase; color: var(--faint); padding: 4px 0; }
.cal-cell {
  min-height: 84px;
  padding: 6px 5px;
  border-radius: 8px;
  background: rgba(243, 234, 216, 0.03);
  border: 1px solid transparent;
  display: flex;
  flex-direction: column;
  gap: 3px;
  cursor: pointer;
  min-width: 0;
}
.cal-cell:hover { border-color: var(--line); }
.cal-cell.out { opacity: 0.35; }
.cal-cell.past .cal-num { color: var(--faint); }
.cal-cell.today { border-color: var(--gold); }
.cal-num { font-size: 0.8rem; font-weight: 700; color: var(--muted); }
.cal-cell.today .cal-num { color: var(--gold-bright); }
.cal-chip, .cal-block {
  display: block;
  font-size: 0.7rem;
  font-weight: 700;
  line-height: 1.3;
  padding: 2px 5px;
  border-radius: 4px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.cal-chip { background: var(--house); color: #1d0406; }
.cal-block { color: var(--faint); text-decoration: line-through; padding-inline: 2px; font-weight: 600; }
.cal-legend { display: flex; flex-wrap: wrap; gap: 6px 14px; margin-top: 12px; font-size: 0.8rem; color: var(--muted); }
.cal-legend span { display: inline-flex; align-items: center; gap: 6px; }

/* Houses */
.houses { display: grid; grid-template-columns: repeat(auto-fill, minmax(min(100%, 280px), 1fr)); gap: 12px; }
.house { --house: var(--gold); padding: 16px 18px; display: grid; gap: 8px; align-content: start; border-top: 3px solid var(--house); }
.house-head { display: flex; align-items: center; gap: 10px; }
.house-head h3 { flex: 1; color: var(--house); }
.house-addr { font-weight: 600; }
.house-stats { color: var(--muted); font-size: 0.9rem; }
.house-notes { font-size: 0.9rem; white-space: pre-line; padding: 8px 10px; background: rgba(243, 234, 216, 0.04); border-radius: 8px; }
.house-blocks { border-top: 1px solid var(--line); padding-top: 8px; margin-top: 4px; }
.label { font-size: 0.72rem; font-weight: 700; letter-spacing: 0.12em; text-transform: uppercase; color: var(--faint); margin-bottom: 4px; }
.house-blocks ul { list-style: none; margin: 0; padding: 0; display: grid; gap: 2px; }
.house-blocks li { display: flex; align-items: center; justify-content: space-between; gap: 8px; font-size: 0.9rem; }
.icon-btn {
  flex: none;
  width: 32px;
  height: 32px;
  border-radius: 50%;
  border: 0;
  background: transparent;
  color: var(--faint);
  cursor: pointer;
}
.icon-btn:hover { color: var(--danger); background: var(--warn-bg); }

/* Trash */
.trash { padding: 14px 18px; }
.trash summary { cursor: pointer; font-weight: 700; color: var(--muted); }
.trash[open] summary { margin-bottom: 8px; }
.trash-item { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 8px 0; border-top: 1px solid var(--line); font-size: 0.9rem; }

/* Footer */
.footer { margin-top: 48px; padding-top: 20px; border-top: 1px solid var(--line); text-align: center; display: grid; gap: 4px; }
.motto { font-family: var(--display); color: var(--gold); letter-spacing: 0.18em; text-transform: uppercase; font-size: 0.85rem; }
.sync.offline { color: var(--danger); }

/* Dialogs */
dialog {
  width: min(520px, calc(100vw - 24px));
  max-height: calc(100dvh - 24px);
  padding: 0;
  border: 1px solid var(--line-strong);
  border-radius: 18px;
  background: var(--surface);
  color: var(--cream);
  box-shadow: 0 30px 80px rgba(0, 0, 0, 0.6);
}
dialog::backdrop { background: rgba(10, 1, 2, 0.72); backdrop-filter: blur(3px); }
.sheet { padding: 22px; display: grid; gap: 14px; }
.sheet h2 { font-size: 1.3rem; color: var(--gold-bright); }
.sheet label { display: grid; gap: 6px; font-size: 0.85rem; font-weight: 600; color: var(--muted); }
.grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
input, select, textarea {
  width: 100%;
  min-height: 44px;
  font: 500 1rem var(--body);
  color: var(--cream);
  background: var(--bg);
  border: 1px solid var(--line-strong);
  border-radius: 10px;
  padding: 10px 12px;
}
textarea { resize: vertical; }
input:focus, select:focus, textarea:focus { outline: none; border-color: var(--gold-bright); box-shadow: 0 0 0 3px rgba(240, 197, 101, 0.18); }
::placeholder { color: var(--faint); }
input[type='date'], input[type='time'] { color-scheme: dark; }
.segmented { border: 0; padding: 0; margin: 0; display: flex; flex-wrap: wrap; gap: 8px; }
.segmented legend { font-size: 0.85rem; font-weight: 600; color: var(--muted); margin-bottom: 6px; padding: 0; }
.segmented label { display: block; }
.segmented input { position: absolute; opacity: 0; width: 1px; height: 1px; min-height: 0; }
.segmented span {
  display: inline-block;
  padding: 9px 14px;
  border: 1px solid var(--line-strong);
  border-radius: 999px;
  color: var(--cream);
  font-weight: 600;
  cursor: pointer;
}
.segmented input:checked + span { background: var(--gold); border-color: var(--gold); color: #2a0507; }
.segmented input:focus-visible + span { outline: 2px solid var(--gold-bright); outline-offset: 2px; }
.extern-fields {
  display: grid;
  gap: 12px;
  padding: 14px;
  border: 1px dashed var(--line-strong);
  border-radius: 12px;
  background: rgba(243, 234, 216, 0.03);
}
.hints { display: grid; gap: 6px; }
.hints:empty { display: none; }
.hint, .warn { font-size: 0.875rem; padding: 8px 12px; border-radius: 10px; }
.hint { background: rgba(217, 160, 58, 0.1); }
.hint .link { padding: 0; margin-left: 4px; }
.warn { background: var(--warn-bg); color: var(--danger); }
.form-error { color: var(--danger); font-size: 0.875rem; font-weight: 600; }
.form-error:empty { display: none; }
.sheet-extra { display: flex; gap: 18px; }
.sheet-actions { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; margin-top: 4px; }
.spacer { flex: 1; }

/* Toast */
.toast {
  position: fixed;
  left: 50%;
  bottom: calc(20px + env(safe-area-inset-bottom));
  transform: translateX(-50%);
  width: max-content;
  max-width: calc(100vw - 32px);
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 12px 18px;
  background: var(--cream);
  color: #2a0507;
  font-weight: 600;
  border-radius: 999px;
  box-shadow: 0 12px 40px rgba(0, 0, 0, 0.5);
  z-index: 10;
}
.toast .link { color: var(--wine); text-decoration-color: currentColor; padding: 0; }
.toast[hidden] { display: none; }

@media (max-width: 560px) {
  .masthead {
    display: grid;
    grid-template-columns: auto 1fr;
    column-gap: 12px;
    row-gap: 6px;
    padding-top: 18px;
  }
  .crest { width: 56px; height: 56px; grid-row: span 2; }
  .name-chip { justify-self: start; max-width: 100%; padding: 4px 10px; }
  .tally-row { grid-template-columns: 9.5rem 1fr 2rem; gap: 10px; }
  .hero { padding: 20px 18px 18px; }
  .hero-actions .btn { flex: 1 1 auto; }
  .cal { padding: 8px 6px; }
  .cal-grid { gap: 2px; }
  .cal-cell { min-height: 64px; padding: 4px 3px; }
  .cal-chip, .cal-block { font-size: 0.62rem; padding-inline: 3px; }
  .row { gap: 8px; padding-right: 10px; }
  .row-open { grid-template-columns: 44px 1fr; gap: 10px; padding-left: 10px; }
  .row-side { flex-direction: column-reverse; align-items: flex-end; gap: 6px; }
  .row-side .btn.small { width: 40px; padding: 0; }
  .row-side .btn.small span { display: none; }
  .sheet { padding: 18px; }
}

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