:root {
  --paper: #EEF3F1;      /* eucalyptus-tinted white */
  --card: #FFFFFF;
  --ink: #14323A;        /* Great Sandy Strait blue */
  --muted: #587077;
  --line: #D3DEDA;
  --sun: #FFF4DC;        /* summer highlight for the big days */
  --danger: #A3302A;
  --radius-lg: 16px;
  --radius-sm: 8px;
  color-scheme: light;
  box-sizing: border-box;
  padding-top: env(safe-area-inset-top, 0px);
  padding-bottom: env(safe-area-inset-bottom, 0px);
}
@media (prefers-color-scheme: dark) {
  :root {
    --paper: #0F1E22;
    --card: #17292E;
    --ink: #E6F0EE;
    --muted: #9AB2B6;
    --line: #2A4147;
    --sun: #2C2A1B;
    --danger: #F08A80;
    color-scheme: dark;
  }
}
*, *::before, *::after { box-sizing: inherit; }
html { height: 100%; }
body {
  margin: 0;
  min-height: 100%;
  background: var(--paper);
  color: var(--ink);
  font-family: ui-rounded, "SF Pro Rounded", "Nunito", system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  font-size: 16px;
  line-height: 1.45;
}
h1, h2, h3 { margin: 0; line-height: 1.15; }
button, input, select, textarea { font: inherit; color: inherit; }
:focus-visible { outline: 3px solid #2B6CB0; outline-offset: 2px; }
[hidden] { display: none !important; }

.wrap { max-width: 1320px; margin: 0 auto; padding: 20px 20px 80px; }

/* ---------- header */
.top { display: flex; flex-wrap: wrap; justify-content: space-between; align-items: end; gap: 16px; margin-bottom: 22px; }
.top h1 { font-size: clamp(2rem, 4vw, 3rem); font-weight: 800; letter-spacing: -0.02em; }
.sub { margin: 4px 0 0; color: var(--muted); }
.who { display: flex; flex-direction: column; gap: 6px; }
.who-label { font-size: .85rem; color: var(--muted); }
.people { display: flex; flex-wrap: wrap; gap: 6px; }
.person {
  display: inline-flex; align-items: center; gap: 8px;
  padding: 7px 14px 7px 10px; border-radius: 999px;
  border: 2px solid var(--line); background: var(--card); cursor: pointer; font-weight: 600;
}
.person .dot { width: 14px; height: 14px; }
.person[aria-pressed="true"] { border-color: var(--c); background: color-mix(in srgb, var(--c) 16%, var(--card)); }

.dot { display: inline-block; width: 10px; height: 10px; border-radius: 50%; background: var(--c); flex: none; }
.dots { display: inline-flex; gap: 3px; align-items: center; }

/* ---------- buttons */
.primary, .ghost, .danger, .plainbtn {
  border-radius: 999px; padding: 8px 16px; cursor: pointer; font-weight: 600; border: 2px solid transparent;
}
.primary { background: var(--ink); color: var(--paper); }
.ghost, .plainbtn { background: transparent; border-color: var(--line); }
.danger { background: transparent; border-color: var(--danger); color: var(--danger); }
.icon {
  width: 40px; height: 40px; border-radius: 50%; border: 2px solid var(--line);
  background: var(--card); cursor: pointer; font-size: 1.4rem; line-height: 1;
}
.icon:disabled { opacity: .35; cursor: default; }
.linkish { background: none; border: 0; padding: 0; color: inherit; text-decoration: underline; cursor: pointer; text-align: left; }

/* ---------- layout */
.layout { display: grid; grid-template-columns: minmax(0, 1fr) 360px; gap: 28px; align-items: start; }
@media (max-width: 980px) { .layout { grid-template-columns: minmax(0, 1fr); } }

.cal-head { display: flex; align-items: center; gap: 10px; }
.cal-head h2 { font-size: 1.6rem; font-weight: 800; min-width: 9ch; text-align: center; }
.cal-head .ghost { margin-left: auto; white-space: nowrap; }
.key { color: var(--muted); font-size: .88rem; margin: 8px 0 12px; max-width: 70ch; }

.dow, .grid { display: grid; grid-template-columns: repeat(7, minmax(0, 1fr)); gap: 6px; }
.dow span { font-size: .8rem; color: var(--muted); padding: 0 4px 4px; }

/* ---------- day cells */
.day {
  position: relative; min-height: 118px; padding: 7px 7px 8px;
  background: var(--card); border: 1px solid var(--line); border-radius: var(--radius-sm);
  display: flex; flex-direction: column; gap: 4px; cursor: pointer;
}
.day.blank { background: transparent; border-color: transparent; cursor: default; }
.day.big { background: var(--sun); }
.day.today { box-shadow: inset 0 0 0 2px var(--ink); }
.day.dropping { box-shadow: inset 0 0 0 3px #2B6CB0; }
.dhead { display: flex; align-items: baseline; gap: 6px; }
.dnum { font-weight: 800; font-size: 1.05rem; }
.dlabel { font-size: .7rem; color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.chips { display: flex; flex-direction: column; gap: 3px; min-width: 0; }
.chip {
  display: block; width: 100%; text-align: left; font-size: .78rem; line-height: 1.25;
  padding: 3px 6px; border-radius: 5px; cursor: pointer;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.chip.booked { background: var(--ink); color: var(--paper); border: 0; }
.chip.sugg { background: transparent; border: 1.5px dashed var(--muted); color: var(--ink); }
.more { font-size: .75rem; color: var(--muted); }

/* the who-is-around bar */
.here { display: flex; gap: 3px; margin-top: auto; padding-top: 4px; }
.seg { flex: 1; height: 8px; border-radius: 4px; background: var(--c); }
.seg.away { background: transparent; box-shadow: inset 0 0 0 1.5px var(--c); opacity: .6; }

@media (max-width: 640px) {
  .wrap { padding: 14px 10px 80px; }
  .dow, .grid { gap: 3px; }
  .day { min-height: 70px; padding: 4px 4px 5px; }
  .dlabel { display: none; }
  .chip { font-size: 0; height: 6px; padding: 0; }
  .chip.sugg { border-width: 1px; }
  .more { font-size: .65rem; }
  .seg { height: 6px; }
  .cal-head h2 { font-size: 1.15rem; white-space: nowrap; min-width: 0; }
  .cal-head { gap: 6px; }
  .cal-head .ghost { padding: 6px 12px; font-size: .85rem; }
}

/* ---------- ideas */
.ideas { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius-lg); padding: 18px; }
.ideas-head { display: flex; justify-content: space-between; align-items: center; gap: 10px; }
.ideas-head h2 { font-size: 1.3rem; font-weight: 800; }
.idea-list { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 12px; }
.idea { border: 1px solid var(--line); border-radius: 12px; padding: 12px; background: var(--paper); }
.idea[draggable="true"] { cursor: grab; }
.idea-top { display: flex; justify-content: space-between; align-items: start; gap: 10px; }
.idea h3 { font-size: 1.05rem; font-weight: 700; }
.idea .notes { margin: 6px 0 0; font-size: .9rem; white-space: pre-wrap; }
.meta { font-size: .8rem; color: var(--muted); margin-top: 4px; }
.vote {
  display: inline-flex; align-items: center; gap: 6px; flex: none;
  border: 2px solid var(--line); background: var(--card); border-radius: 999px; padding: 4px 12px; cursor: pointer; font-weight: 700;
}
.vote[aria-pressed="true"] { border-color: var(--ink); background: var(--ink); color: var(--paper); }
.opts { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 10px; }
.opt-wrap { display: inline-flex; align-items: stretch; }
.opt {
  display: inline-flex; align-items: center; gap: 6px; font-size: .82rem;
  border: 1.5px solid var(--line); background: var(--card); padding: 4px 8px; border-radius: 999px 0 0 999px; cursor: pointer;
}
.opt[aria-pressed="true"] { border-color: var(--ink); }
.opt.lead { background: var(--sun); }
.opt-x { border: 1.5px solid var(--line); border-left: 0; background: var(--card); border-radius: 0 999px 999px 0; padding: 0 8px; cursor: pointer; color: var(--muted); }
.count { font-weight: 800; }
.idea-actions { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 10px; align-items: center; }
.idea-actions select { max-width: 100%; padding: 5px 8px; border-radius: 8px; border: 1.5px solid var(--line); background: var(--card); font-size: .85rem; }
.idea-actions .plainbtn, .idea-actions .primary { padding: 5px 12px; font-size: .85rem; }
.empty { color: var(--muted); }

/* ---------- dialog */
dialog {
  width: min(540px, calc(100% - 24px)); max-height: calc(100% - 40px);
  border: 0; border-radius: var(--radius-lg); padding: 22px; background: var(--card); color: var(--ink);
}
dialog::backdrop { background: rgba(10, 25, 30, .45); }
dialog h2 { font-size: 1.4rem; font-weight: 800; padding-right: 36px; }
dialog h3 { font-size: 1rem; margin: 18px 0 6px; }
.close { position: absolute; top: 14px; right: 14px; width: 36px; height: 36px; border-radius: 50%; border: 0; background: var(--paper); font-size: 1.3rem; cursor: pointer; }
.muted { color: var(--muted); margin: 4px 0 0; }
.plain { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 6px; }
.plain li { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.form { display: flex; flex-direction: column; gap: 12px; margin-top: 14px; }
.field { display: flex; flex-direction: column; gap: 4px; font-weight: 600; font-size: .9rem; }
.field input, .field select, .field textarea {
  font-weight: 400; font-size: 1rem; padding: 9px 10px; border-radius: 10px; border: 1.5px solid var(--line); background: var(--paper);
}
.field textarea { min-height: 80px; resize: vertical; }
.row { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.actions { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 16px; }
.error { color: var(--danger); font-weight: 600; min-height: 1em; margin: 8px 0 0; }
.pick { display: grid; grid-template-columns: repeat(auto-fill, minmax(140px, 1fr)); gap: 8px; margin-top: 14px; }
.pick .person { justify-content: center; padding: 12px; }

/* ---------- passcode gate */
.gate { min-height: 100vh; display: grid; place-items: center; padding: 20px; }
.gate-card { width: min(400px, 100%); background: var(--card); border: 1px solid var(--line); border-radius: var(--radius-lg); padding: 28px; display: flex; flex-direction: column; gap: 10px; }
.gate-card h1 { font-size: 2rem; font-weight: 800; }
.gate-card p { margin: 0; color: var(--muted); }
.gate-card label { font-weight: 600; margin-top: 8px; }
.gate-card input { padding: 10px; border-radius: 10px; border: 1.5px solid var(--line); background: var(--paper); font-size: 1rem; }

/* ---------- toast */
.toast {
  position: fixed; left: 50%; bottom: calc(18px + env(safe-area-inset-bottom, 0px)); transform: translateX(-50%);
  margin: 0; padding: 10px 16px; border-radius: 999px; background: var(--ink); color: var(--paper);
  font-weight: 600; max-width: calc(100% - 24px); opacity: 0; pointer-events: none; transition: opacity .2s;
}
.toast.show { opacity: 1; }
@media (prefers-reduced-motion: reduce) { .toast { transition: none; } }
