:root {
  color-scheme: dark;
  --green: #4ade80;
  --blue: #60a5fa;
  --red: #f87171;
  --maybe: #fcd34d;
  --grey: #2a3140;
  --ink: #e5e7eb;
  --muted: #9ca3af;
  --accent: #818cf8;
  --bg: #0b0e14;
  --card: #151a23;
  --card-sub: #1b212c;
  --border: #2a3140;
  /* Calendar geometry, overridden per screen size and pointer type below. */
  --cal-row: 18px;
  --cal-gutter: 3.5rem;
  --cal-col-min: 2.2rem;
}

* {
  box-sizing: border-box;
}

html {
  background: var(--bg);
}

body {
  margin: 0;
  font-family: system-ui, -apple-system, Segoe UI, Roboto, sans-serif;
  color: var(--ink);
  background: var(--bg);
  line-height: 1.5;
}

#app {
  max-width: 60rem;
  margin: 0 auto;
  padding: 1.5rem 1rem;
}

.site-header {
  border-bottom: 1px solid var(--border);
  background: var(--card);
}

.site-header-inner {
  max-width: 60rem;
  margin: 0 auto;
  padding: 0.85rem 1rem;
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.site-header .brand {
  font-weight: 700;
  font-size: 1.05rem;
  color: var(--ink);
  text-decoration: none;
}

.site-header .brand:hover {
  color: var(--accent);
}

.site-header nav a {
  color: var(--accent);
  font-weight: 600;
  text-decoration: none;
}

.tabs {
  display: flex;
  gap: 0.25rem;
  border-bottom: 1px solid var(--border);
  margin: 0.75rem 0 1rem;
  flex-wrap: wrap;
}

.tabs button {
  background: none;
  border: none;
  border-bottom: 2px solid transparent;
  border-radius: 0;
  padding: 0.5rem 0.9rem;
  color: var(--muted);
}

.tabs button.active {
  color: var(--ink);
  border-bottom-color: var(--accent);
}

.site-footer {
  max-width: 60rem;
  margin: 0 auto;
  padding: 1rem;
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 1rem;
  border-top: 1px solid var(--border);
  color: var(--muted);
  font-size: 0.85rem;
}

.site-footer a {
  color: var(--muted);
  text-decoration: none;
}

.site-footer a:hover {
  color: var(--accent);
}

.site-footer .dev {
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.site-footer .dev img {
  height: 1.5rem;
  width: auto;
  border-radius: 4px;
}

.card {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 0.75rem;
  padding: 1.5rem;
  margin-bottom: 1.25rem;
}

.card.wide {
  max-width: none;
}

.card.sub {
  background: var(--card-sub);
}

h1 {
  font-size: 1.5rem;
  margin: 0 0 0.5rem;
}

h2 {
  font-size: 1.1rem;
  margin: 1.25rem 0 0.5rem;
}

.row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  flex-wrap: wrap;
}

.muted {
  color: var(--muted);
  font-size: 0.9rem;
}

.msg {
  color: var(--muted);
  font-size: 0.9rem;
  min-height: 1.25rem;
}

.msg.error {
  color: var(--red);
}

.hero .tagline {
  font-size: 1.15rem;
  color: var(--accent);
  font-weight: 600;
  margin: 0 0 0.5rem;
}

.hero .free {
  color: var(--green);
  font-weight: 600;
  margin-bottom: 0;
}

.features {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(15rem, 1fr));
  gap: 1.25rem;
  margin-bottom: 1.25rem;
}

.features .card {
  margin-bottom: 0;
}

.feature h2 {
  margin-top: 0;
}

.feature p {
  color: var(--muted);
  font-size: 0.9rem;
  margin-bottom: 0;
}

.tag {
  font-size: 0.75rem;
  color: var(--muted);
}

input,
textarea {
  display: block;
  width: 100%;
  padding: 0.55rem 0.7rem;
  margin: 0.4rem 0;
  border: 1px solid var(--border);
  border-radius: 0.5rem;
  font: inherit;
  background: #0f131b;
  color: var(--ink);
}

input::placeholder,
textarea::placeholder {
  color: #6b7280;
}

textarea {
  min-height: 4rem;
  resize: vertical;
}

button {
  font: inherit;
  cursor: pointer;
  border: 1px solid var(--border);
  background: var(--card-sub);
  color: var(--ink);
  border-radius: 0.5rem;
  padding: 0.5rem 0.9rem;
}

button.primary {
  background: #4f46e5;
  border-color: #4f46e5;
  color: #fff;
  box-shadow: 0 0 14px rgba(99, 102, 241, 0.35);
}

button.link {
  border: none;
  background: none;
  color: var(--accent);
  padding: 0;
  box-shadow: none;
}

a {
  color: var(--accent);
}

ul.events {
  list-style: none;
  padding: 0;
  margin: 0;
}

ul.events li {
  padding: 0.35rem 0;
  border-bottom: 1px solid var(--border);
  /* Long email addresses would otherwise push the card wider than a phone. */
  overflow-wrap: anywhere;
}

.weeknav {
  display: flex;
  align-items: center;
  gap: 0.75rem;
}

.toggle button.active {
  background: #4f46e5;
  border-color: #4f46e5;
  color: #fff;
}

/* Brushes are coloured like the paint they apply; the active one is outlined. */
.brush.st-available {
  background: var(--green);
  border-color: var(--green);
  color: #0b0e14;
}

.brush.st-maybe {
  background: var(--maybe);
  border-color: var(--maybe);
  color: #0b0e14;
}

.brush.st-unavailable {
  background: #10141c;
  border: 1px dashed var(--muted);
  color: var(--ink);
}

.brush.active {
  outline: 2px solid var(--ink);
  outline-offset: 2px;
}

.cal-hint {
  color: var(--muted);
  font-size: 0.8rem;
  align-self: center;
}

.legend {
  font-size: 0.8rem;
  color: var(--muted);
  margin: 0.75rem 0 0.25rem;
}

.legend .sw {
  display: inline-block;
  width: 0.8rem;
  height: 0.8rem;
  border-radius: 2px;
  vertical-align: middle;
  margin: 0 0.15rem 0 0.6rem;
}

/* calendar */
.cal-brushes {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.5rem;
  margin-bottom: 0.5rem;
}

/* Holds the border and rounding so the grid itself can overflow sideways;
   the sticky time gutter is positioned against this scroller. */
.cal-scroll {
  margin-top: 0.5rem;
  border: 1px solid var(--border);
  border-radius: 0.5rem;
  overflow-x: auto;
  overscroll-behavior-x: contain;
}

.cal-grid {
  display: grid;
  grid-template-columns: var(--cal-gutter) repeat(7, minmax(var(--cal-col-min), 1fr));
  user-select: none;
  -webkit-user-select: none;
}

.cal-corner,
.cal-day-head {
  background: #10141c;
  font-size: 0.75rem;
  font-weight: 600;
  text-align: center;
  padding: 0.35rem 0;
  border-bottom: 1px solid var(--border);
}

.cal-time {
  font-size: 0.65rem;
  color: var(--muted);
  text-align: right;
  padding-right: 0.3rem;
  height: var(--cal-row);
  line-height: var(--cal-row);
}

/* The gutter stays put while the week pans, and is the reliable place to
   start a vertical page scroll when the slots are swallowing touch. */
.cal-corner,
.cal-time {
  position: sticky;
  left: 0;
  z-index: 1;
  background: #10141c;
  touch-action: pan-y;
}

.cal-corner {
  z-index: 2;
}

.cal-slot {
  height: var(--cal-row);
  border-left: 1px solid #1a2030;
  border-top: 1px solid #141926;
}

/* Painting needs the raw gesture, so only edit mode claims touch. In group
   view a drag across the grid scrolls the page as usual. */
.cal-grid.edit .cal-slot {
  cursor: crosshair;
  touch-action: none;
}

/* Skipped on touch, where :hover sticks to the last cell tapped. */
@media (hover: hover) {
  .cal-slot:hover {
    outline: 2px solid var(--accent);
    outline-offset: -2px;
  }
}

/* aggregate colours (view) */
.ag-green { background: var(--green); }
.ag-blue { background: var(--blue); }
.ag-red { background: var(--red); }
.ag-empty { background: #10141c; }

/* own statuses (edit) */
.st-available { background: var(--green); }
.st-maybe { background: var(--maybe); }
.st-unavailable { background: #10141c; }

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

/* A finger needs a bigger target than a mouse pointer. Every row grows, so a
   24-hour day gets taller; that is the honest trade for being able to hit the
   half hour you meant. */
@media (pointer: coarse) {
  :root {
    --cal-row: 24px;
  }

  .brush,
  .tabs button,
  .toggle button {
    min-height: 2.75rem;
  }
}

@media (max-width: 40rem) {
  :root {
    --cal-gutter: 2.6rem;
  }

  #app {
    padding: 1rem 0.75rem;
  }

  /* Reclaimed padding goes to the week grid, which is the widest thing on
     the page and the only one that runs out of room. */
  .card {
    padding: 1rem;
    border-radius: 0.6rem;
  }

  .site-header-inner,
  .site-footer {
    padding-left: 0.75rem;
    padding-right: 0.75rem;
  }

  h1 {
    font-size: 1.3rem;
  }

  .hero .tagline {
    font-size: 1.05rem;
  }

  .tabs button {
    padding: 0.5rem 0.65rem;
  }

  /* The hint reads as a caption under the brushes rather than squeezing in
     beside them. */
  .cal-hint {
    flex-basis: 100%;
  }

  .cal-day-head {
    font-size: 0.7rem;
  }

  .cal-time {
    font-size: 0.6rem;
  }

  .site-footer {
    justify-content: center;
    text-align: center;
  }
}
