:root {
  --bg: #f7f5f2;
  --card: #ffffff;
  --ink: #1c1b1a;
  --ink-dim: #5c5650;
  --line: #e4dfd8;
  --accent: #b8481f;
  --accent-ink: #ffffff;
  --available: #256a35;
  --available-bg: #e4f2e6;
  --maybe: #8a640a;
  --maybe-bg: #faf0dc;
  --unavailable: #952e27;
  --unavailable-bg: #f7e6e4;
  --unset-bg: #f0ede8;
  --badge: #5c3a86;
  --badge-bg: #efe6f7;
  --shadow: 0 2px 10px rgba(28,27,26,0.06);
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #171513;
    --card: #221f1c;
    --ink: #f2ede6;
    --ink-dim: #bdb4a9;
    --line: #38332e;
    --accent: #e07a52;
    --accent-ink: #171513;
    --available: #8fd3a0;
    --available-bg: #1f2e21;
    --maybe: #e6c06a;
    --maybe-bg: #332a17;
    --unavailable: #e6968b;
    --unavailable-bg: #34201d;
    --unset-bg: #2a2723;
    --badge: #c6acea;
    --badge-bg: #2b2233;
    --shadow: 0 2px 14px rgba(0,0,0,0.4);
  }
}
/* Explicit override via the "Aa" display-settings control, regardless
   of the system's own light/dark preference. */
:root[data-theme="dark"] {
  --bg: #171513;
  --card: #221f1c;
  --ink: #f2ede6;
  --ink-dim: #bdb4a9;
  --line: #38332e;
  --accent: #e07a52;
  --accent-ink: #171513;
  --available: #8fd3a0;
  --available-bg: #1f2e21;
  --maybe: #e6c06a;
  --maybe-bg: #332a17;
  --unavailable: #e6968b;
  --unavailable-bg: #34201d;
  --unset-bg: #2a2723;
  --badge: #c6acea;
  --badge-bg: #2b2233;
  --shadow: 0 2px 14px rgba(0,0,0,0.4);
}

/* Accessible base size: scales with the user's own browser text-size
   setting (a %, not a fixed px), while giving everyone a larger,
   more comfortable starting point than the browser default. Can be
   bumped further by the "Aa" display-settings control. */
html { font-size: 112.5%; } /* ~18px when the browser default is 16px */
html[data-text-size="large"] { font-size: 125%; }
html[data-text-size="xlarge"] { font-size: 145%; }

* { box-sizing: border-box; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  -webkit-font-smoothing: antialiased;
  line-height: 1.5;
}
.wrap { max-width: 900px; margin: 0 auto; padding: 20px 16px 60px; }
h1 { font-size: 1.6rem; margin: 0 0 4px; letter-spacing: -0.01em; }
.sub { color: var(--ink-dim); font-size: 1rem; margin: 0 0 20px; }

.card {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: 14px;
  box-shadow: var(--shadow);
  padding: 18px;
  margin-bottom: 18px;
}
.card h2 { font-size: 1.1rem; margin: 0 0 12px; }

.row { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; }
select, input[type=text], input[type=email], input[type=password], input[type=date], input[type=time], textarea {
  font-size: 1rem;
  padding: 10px 12px;
  border-radius: 9px;
  border: 1px solid var(--line);
  background: var(--bg);
  color: var(--ink);
  max-width: 100%;
  width: 100%;
  min-height: 44px;
}
textarea { font-family: inherit; resize: vertical; min-height: 80px; }
label.field {
  display: flex;
  flex-direction: column;
  gap: 5px;
  font-size: 0.9rem;
  color: var(--ink-dim);
}
button {
  font-size: 1rem;
  padding: 11px 16px;
  min-height: 44px;
  border-radius: 9px;
  border: none;
  background: var(--accent);
  color: var(--accent-ink);
  cursor: pointer;
  font-weight: 600;
}
button.ghost {
  background: transparent;
  color: var(--ink);
  border: 1px solid var(--line);
  font-weight: 600;
}
button.danger {
  background: transparent;
  color: var(--unavailable);
  border: 1px solid var(--unavailable);
  font-weight: 600;
}
button.danger:hover { background: var(--unavailable-bg); }
button:disabled { opacity: 0.5; cursor: default; }

.tab-btn {
  background: transparent;
  color: var(--ink-dim);
  border: 1px solid var(--line);
  font-weight: 600;
  font-size: 0.95rem;
}
.tab-btn.active { background: var(--accent); color: var(--accent-ink); border-color: var(--accent); }

.auth-form { display: flex; flex-direction: column; gap: 12px; max-width: 380px; }
.auth-error { color: var(--unavailable); font-size: 0.92rem; min-height: 1.2em; font-weight: 600; }
.auth-success { color: var(--available); font-size: 0.92rem; min-height: 1.2em; font-weight: 600; }
.hint { color: var(--ink-dim); font-size: 0.92rem; margin: 0; }
.tiny-link {
  background: none; border: none; color: var(--ink-dim);
  font-size: 0.88rem; text-decoration: underline; padding: 4px 4px 4px 0;
  cursor: pointer; font-weight: 600; min-height: auto;
}
.tiny-link:hover { color: var(--accent); }

.legend { display: flex; gap: 16px; flex-wrap: wrap; font-size: 0.92rem; color: var(--ink-dim); margin-top: 10px; }
.dot { width: 11px; height: 11px; border-radius: 50%; display: inline-block; margin-right: 6px; vertical-align: middle; }

.week { margin-bottom: 16px; }
.week-label {
  font-size: 0.88rem;
  font-weight: 600;
  letter-spacing: 0.02em;
  color: var(--ink-dim);
  margin: 0 0 8px 2px;
}
/* Seven columns never squeeze below a legible width - on a narrow
   screen the week scrolls horizontally instead of shrinking text. */
.days {
  display: grid;
  grid-template-columns: repeat(7, minmax(96px, 1fr));
  gap: 8px;
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
  padding-bottom: 6px;
}
.day {
  background: var(--unset-bg);
  border-radius: 10px;
  padding: 8px 5px 10px;
  text-align: center;
  border: 2px solid transparent;
  position: relative;
  display: flex;
  flex-direction: column;
  gap: 5px;
  transition: transform 0.08s ease;
}
.day.pad { visibility: hidden; }
.day .dname { font-size: 0.82rem; color: var(--ink-dim); font-weight: 600; }
.day .dnum { font-size: 1.15rem; font-weight: 700; margin-bottom: 2px; }

.slot-row {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 2px;
  border-radius: 6px;
  padding: 6px 4px;
  min-height: 40px;
  cursor: pointer;
  background: var(--card);
  transition: transform 0.08s ease;
}
.slot-row:active { transform: scale(0.96); }
.slot-label {
  font-size: 0.82rem;
  font-weight: 700;
  color: var(--ink-dim);
  line-height: 1.15;
  word-break: break-word;
  hyphens: auto;
}
.slot-count { font-size: 0.8rem; font-weight: 700; color: var(--ink-dim); }
.status-available { background: var(--available-bg); }
.status-available .slot-label, .status-available .slot-count { color: var(--available); }
.status-maybe { background: var(--maybe-bg); }
.status-maybe .slot-label, .status-maybe .slot-count { color: var(--maybe); }
.status-unavailable { background: var(--unavailable-bg); }
.status-unavailable .slot-label, .status-unavailable .slot-count { color: var(--unavailable); }

.best-list { display: flex; flex-direction: column; gap: 10px; }
.best-item {
  display: flex;
  justify-content: space-between;
  align-items: center;
  background: var(--available-bg);
  border-radius: 10px;
  padding: 10px 14px;
  font-size: 0.98rem;
  gap: 10px;
}
.best-item .count { font-weight: 700; color: var(--available); }
.members-list { font-size: 0.95rem; color: var(--ink-dim); margin-top: 10px; line-height: 1.9; }
.members-list b { color: var(--ink); font-weight: 700; }
.member-chip { white-space: nowrap; }
.remove-member {
  background: none; border: none; color: var(--ink-dim);
  font-size: 1rem; line-height: 1; padding: 4px; cursor: pointer; font-weight: 700;
}
.remove-member:hover { color: var(--unavailable); }
.empty { color: var(--ink-dim); font-size: 0.95rem; text-align: center; padding: 12px 0; }

.event-badge {
  display: inline-block; background: var(--badge-bg); color: var(--badge);
  font-size: 0.82rem; font-weight: 700; padding: 3px 10px; border-radius: 999px;
  letter-spacing: 0.03em;
}
.event-header { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; margin-bottom: 4px; }
.event-title { font-size: 1.2rem; font-weight: 700; }
.event-range { font-size: 0.95rem; color: var(--ink-dim); }
.organizer-note { font-size: 0.92rem; color: var(--ink-dim); margin-top: 8px; }
.confirmed-banner {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
  flex-wrap: wrap;
  background: var(--available-bg);
  color: var(--available);
  border-radius: 10px;
  padding: 10px 14px;
  margin-top: 12px;
  font-weight: 600;
}
.confirmed-banner button { flex-shrink: 0; }

.changelog-list {
  margin: 0;
  padding-left: 22px;
  display: flex;
  flex-direction: column;
  gap: 8px;
  font-size: 0.95rem;
  color: var(--ink-dim);
}
.changelog-list li { line-height: 1.5; }

.notes-list { display: flex; flex-direction: column; gap: 10px; margin-top: 12px; }
.note-item {
  background: var(--unset-bg);
  border-radius: 10px;
  padding: 10px 12px;
  font-size: 0.95rem;
}
.note-item .note-meta {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  gap: 8px;
  font-size: 0.8rem;
  color: var(--ink-dim);
  margin-bottom: 4px;
}
.note-item .note-text { white-space: pre-wrap; word-break: break-word; }
.note-delete {
  background: none; border: none; color: var(--ink-dim);
  font-size: 0.85rem; padding: 0 2px; cursor: pointer; font-weight: 700; flex-shrink: 0;
}
.note-delete:hover { color: var(--unavailable); }

.new-event-form {
  margin-top: 14px; padding-top: 14px; border-top: 1px dashed var(--line);
  display: flex; flex-direction: column; gap: 12px;
}
.field-row { display: flex; gap: 12px; flex-wrap: wrap; }

/* "Aa" display-settings control */
#a11yControl {
  position: fixed;
  top: 14px;
  right: 14px;
  z-index: 1000;
  display: flex;
  flex-direction: column;
  align-items: flex-end;
}
#a11yToggle {
  min-width: 44px;
  min-height: 44px;
  padding: 8px 14px;
  font-size: 1.05rem;
  font-weight: 700;
  border-radius: 10px;
  background: var(--card);
  color: var(--ink);
  border: 1px solid var(--line);
  box-shadow: var(--shadow);
}
#a11yPanel {
  margin-top: 8px;
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: 12px;
  box-shadow: var(--shadow);
  padding: 14px;
  min-width: 230px;
}
.a11y-row { margin-bottom: 12px; }
.a11y-row:last-child { margin-bottom: 0; }
.a11y-label { font-size: 0.85rem; color: var(--ink-dim); display: block; margin-bottom: 6px; font-weight: 700; }
.a11y-btn {
  font-size: 0.88rem;
  padding: 8px 10px;
  min-height: 40px;
  border-radius: 8px;
  border: 1px solid var(--line);
  background: var(--bg);
  color: var(--ink);
  font-weight: 600;
  cursor: pointer;
  flex: 1;
  white-space: nowrap;
}
.a11y-btn.active { background: var(--accent); color: var(--accent-ink); border-color: var(--accent); }
.theme-btn { font-size: 1.15rem; }

#siteFooter {
  margin-top: 24px;
  padding-top: 18px;
  color: var(--ink-dim);
  font-size: 0.88rem;
}
.footer-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  flex-wrap: wrap;
  gap: 8px 16px;
}
#siteFooter p { margin: 4px 0; }
#siteFooter a { color: var(--ink-dim); text-decoration: underline; }
#siteFooter a:hover { color: var(--accent); }

