/* Dirt Wain house style — matches the portal and PKVW tracker.
   Palette lifted verbatim from dirt-wain-portal/css/portal.css so the
   internal tools stay consistent with one another. */
:root {
  --brown: #1F3A2B;
  --brown-light: #3D7373;
  --tan: #F1EAD9;
  --tan-dark: #E4DBC5;
  --accent: #4E8E5A;
  --accent-dark: #3B7145;
  --red: #E26D2C;
  --gold: #D3A646;
  --warm-gray: #978C80;
  --gray: #3F3F41;
  --gray-light: #D9D3C7;
  --bg: #FAF6ED;
}

* { box-sizing: border-box; margin: 0; padding: 0; }

/* The hidden attribute must always win. Without this, any element that also
   has a display rule (the full-screen .centered overlays do) stays painted
   even when hidden — and the last overlay in the page covers everything. */
[hidden] { display: none !important; }

body {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  background: var(--bg);
  color: var(--gray);
  line-height: 1.5;
}

h1 { font-size: 20px; font-weight: 700; letter-spacing: .5px; }
h2 { font-size: 18px; color: var(--brown); margin-bottom: 4px; }
h3 { font-size: 15px; color: var(--brown); }
.muted { color: var(--warm-gray); font-size: 13px; margin-bottom: 16px; }
.hint { color: var(--warm-gray); font-weight: 400; font-size: 12px; }
.spacer { flex: 1; }

/* ---------- controls ---------- */

button {
  font-family: inherit;
  font-size: 14px;
  font-weight: 600;
  padding: 10px 20px;
  border: none;
  border-radius: 6px;
  background: var(--accent);
  color: #fff;
  cursor: pointer;
  transition: background .15s;
}
button:hover { background: var(--accent-dark); }

button.ghost {
  background: #fff;
  color: var(--brown);
  border: 1px solid var(--brown);
  padding: 8px 16px;
  font-weight: 500;
}
button.ghost:hover { background: var(--tan); }

button.danger {
  background: var(--red);
  color: #fff;
  border: none;
  padding: 8px 16px;
  font-size: 13px;
}
button.danger:hover { opacity: .85; }

button.icon {
  background: #fff;
  color: var(--brown);
  border: 1px solid var(--gray-light);
  padding: 7px 13px;
}
button.icon:hover { background: var(--tan); }

label {
  display: block;
  font-size: 13px;
  font-weight: 600;
  color: var(--gray);
  margin-bottom: 16px;
}
label.inline { display: flex; align-items: center; gap: 8px; font-weight: 500; }
label.inline input { width: auto; margin: 0; }

input, textarea, select {
  width: 100%;
  margin-top: 4px;
  padding: 10px 12px;
  border: 1px solid var(--gray-light);
  border-radius: 6px;
  font-size: 15px;
  font-family: inherit;
  background: #fff;
  color: var(--gray);
}
input:focus, textarea:focus, select:focus {
  outline: none;
  border-color: var(--brown-light);
  box-shadow: 0 0 0 3px rgba(31, 58, 43, .1);
}
textarea { resize: vertical; }

.error { color: var(--red); font-size: 13px; font-weight: 600; margin-bottom: 12px; }
.error.banner {
  margin: 16px 24px 0;
  padding: 10px 14px;
  background: #fff;
  border: 1px solid var(--red);
  border-left: 4px solid var(--red);
  border-radius: 6px;
}

/* ---------- sign in / first run ---------- */

.centered {
  position: fixed;
  inset: 0;
  background: var(--red);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 24px;
  overflow-y: auto;
}
.lockup { color: #fff; text-align: center; margin-bottom: 28px; }
.lockup h1 { font-size: 28px; letter-spacing: 1px; margin-bottom: 4px; }
.lockup p { font-size: 14px; opacity: .75; }

.card {
  background: #fff;
  border-radius: 12px;
  padding: 32px 28px;
  width: 100%;
  max-width: 380px;
  box-shadow: 0 8px 32px rgba(0, 0, 0, .25);
}
.card h2 { margin-bottom: 6px; }
.card button[type="submit"] { width: 100%; }

/* ---------- header ---------- */

.topbar {
  background: var(--red);
  color: #fff;
  padding: 14px 24px;
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
  align-items: center;
  justify-content: space-between;
  box-shadow: 0 2px 8px rgba(0, 0, 0, .15);
}
.nav, .who { display: flex; align-items: center; gap: 8px; }
#month-label { min-width: 175px; text-align: center; }

.topbar button {
  background: rgba(255, 255, 255, .15);
  border: 1px solid rgba(255, 255, 255, .3);
  color: #fff;
  padding: 6px 14px;
  font-size: 13px;
  font-weight: 500;
}
.topbar button:hover { background: rgba(255, 255, 255, .25); }

.chip {
  font-size: 13px;
  font-weight: 600;
  padding: 5px 12px;
  border-radius: 12px;
  background: rgba(255, 255, 255, .15);
  border: 1px solid rgba(255, 255, 255, .25);
}

/* ---------- calendar ---------- */

.weekdays {
  display: grid;
  grid-template-columns: repeat(7, 1fr);
  padding: 20px 24px 0;
  font-size: 12px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: .04em;
  color: var(--warm-gray);
}
.weekdays span { text-align: center; padding-bottom: 8px; }

.grid {
  display: grid;
  grid-template-columns: repeat(7, 1fr);
  gap: 1px;
  background: var(--tan-dark);
  border: 1px solid var(--tan-dark);
  border-radius: 10px;
  overflow: hidden;
  margin: 0 24px 24px;
  box-shadow: 0 1px 4px rgba(0, 0, 0, .07);
}

.day {
  background: #fff;
  min-height: 112px;
  padding: 8px;
  display: flex;
  flex-direction: column;
  align-items: stretch;
  gap: 4px;
  border: 0;
  border-radius: 0;
  color: inherit;
  font-weight: 400;
  cursor: pointer;
  transition: background .12s;
}
.day:hover { background: #FAFAF5; }
.day.outside { background: #F7F4EC; color: var(--warm-gray); }
.day.today { background: var(--tan); }

.day .num { font-size: 13px; font-weight: 700; color: var(--gray); text-align: left; }
.day.outside .num { color: var(--warm-gray); font-weight: 600; }
.day.today .num { color: var(--red); }

.event {
  font-size: 12px;
  font-weight: 500;
  line-height: 1.35;
  padding: 4px 7px;
  border: 0;
  border-radius: 4px;
  border-left: 3px solid var(--event-color, var(--accent));
  background: color-mix(in srgb, var(--event-color, var(--accent)) 14%, #fff);
  color: var(--gray);
  text-align: left;
  cursor: pointer;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.event:hover { background: color-mix(in srgb, var(--event-color, var(--accent)) 24%, #fff); }
.event .t { color: var(--warm-gray); font-weight: 600; }

/* Repeating entries: a solid block in their colour with white text, so they
   stand apart from one-off entries at a glance. */
.event.series {
  border-left: 0;
  background: var(--event-color, var(--accent));
  color: #fff;
  font-weight: 600;
  text-shadow: 0 1px 0 rgba(0, 0, 0, .12);
}
.event.series:hover { background: var(--event-color, var(--accent)); filter: brightness(1.1); }
.event.series .t { color: rgba(255, 255, 255, .85); font-weight: 500; }
.event .rep { opacity: .85; margin-right: 2px; }

/* ---------- dialogs ---------- */

dialog {
  margin: auto;                 /* the * reset removed this; it is what centres a modal */
  border: none;
  border-radius: 12px;
  background: #fff;
  color: var(--gray);
  padding: 28px;
  width: min(520px, calc(100vw - 32px));
  max-height: 88vh;
  overflow-y: auto;
  box-shadow: 0 8px 32px rgba(0, 0, 0, .2);
}
dialog::backdrop { background: rgba(0, 0, 0, .4); }
dialog h2 { padding-bottom: 8px; border-bottom: 2px solid var(--tan-dark); margin-bottom: 18px; }
dialog h3 { margin-bottom: 12px; }
dialog .row { display: flex; gap: 16px; }
dialog .row label { flex: 1; }
dialog footer { display: flex; gap: 8px; align-items: center; margin-top: 4px; }

#editor { width: min(440px, calc(100vw - 32px)); }
#password { width: min(400px, calc(100vw - 32px)); }

/* ---------- people manager ---------- */

.people { list-style: none; margin-bottom: 20px; }
.people li {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 12px 0;
  border-bottom: 1px solid var(--tan);
}
.people .person { flex: 1; min-width: 0; }
.people .person b { display: block; font-size: 14px; font-weight: 600; color: var(--brown); }
.people .person span {
  display: block;
  color: var(--warm-gray);
  font-size: 12px;
  overflow: hidden;
  text-overflow: ellipsis;
}
.people .tag {
  padding: 3px 10px;
  border-radius: 12px;
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: .03em;
  background: var(--tan);
  color: var(--brown);
  white-space: nowrap;
}
.people button { padding: 5px 12px; font-size: 12px; border-radius: 4px; }

.add { border-top: 2px solid var(--tan-dark); padding-top: 18px; }

.handoff {
  margin-top: 16px;
  padding: 14px;
  border: 1px solid var(--gold);
  border-left: 4px solid var(--gold);
  border-radius: 6px;
  background: #FDF8EC;
}
.handoff p { margin-bottom: 8px; font-size: 13px; }
.handoff code {
  display: block;
  font-size: 17px;
  font-weight: 700;
  letter-spacing: .05em;
  color: var(--brown);
  padding: 10px 12px;
  border-radius: 6px;
  background: #fff;
  border: 1px solid var(--tan-dark);
  user-select: all;
}

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

@media (max-width: 640px) {
  .day { min-height: 80px; padding: 5px; }
  .weekdays { padding: 14px 10px 0; font-size: 11px; }
  .grid { margin: 0 10px 16px; }
  .error.banner { margin: 12px 10px 0; }
  .topbar { padding: 12px 14px; }
  #month-label { min-width: 130px; font-size: 17px; }
  dialog .row { flex-direction: column; gap: 0; }
}

/* ---------- fatal banner ---------- */

#fatal {
  position: fixed;
  inset: 0 0 auto 0;
  z-index: 9999;
  display: flex;
  gap: 12px;
  align-items: flex-start;
  padding: 14px 18px;
  background: var(--red);
  color: #fff;
  font-size: 13px;
  font-weight: 600;
  line-height: 1.45;
  box-shadow: 0 2px 12px rgba(0, 0, 0, .3);
}
#fatal[hidden] { display: none; }
#fatal span { flex: 1; word-break: break-word; }
#fatal button {
  background: rgba(255, 255, 255, .2);
  border: 1px solid rgba(255, 255, 255, .4);
  color: #fff;
  padding: 5px 12px;
  font-size: 12px;
  flex: none;
}
#fatal button:hover { background: rgba(255, 255, 255, .3); }

.recover { margin-top: 16px; font-size: 12px; color: var(--warm-gray); text-align: center; }
.recover a { color: var(--accent-dark); font-weight: 600; }

/* ---------- header wordmark ---------- */

.wordmark {
  font-size: 15px;
  font-weight: 700;
  letter-spacing: 1px;
  color: #fff;
  opacity: .9;
  margin-right: 4px;
}
#whoami { cursor: pointer; }
#whoami:hover { background: rgba(255, 255, 255, .3); }

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

/* ---------- AM/PM time picker ---------- */

.field { font-size: 13px; font-weight: 600; color: var(--gray); margin-bottom: 16px; flex: 1; min-width: 0; }
.field-label { display: block; margin-bottom: 4px; }
.timepick { display: flex; align-items: center; gap: 6px; flex-wrap: wrap; }
.timepick select { width: auto; margin: 0; padding: 9px 8px; min-width: 62px; }
.tp-colon { font-weight: 700; color: var(--warm-gray); }
.ampm { display: flex; border: 1px solid var(--gray-light); border-radius: 6px; overflow: hidden; }
.ampm-btn {
  background: #fff; color: var(--gray); border: none; border-radius: 0;
  padding: 9px 12px; font-size: 13px; font-weight: 600;
}
.ampm-btn + .ampm-btn { border-left: 1px solid var(--gray-light); }
.ampm-btn:hover:not(.active) { background: var(--tan); }
.ampm-btn.active { background: var(--accent); color: #fff; }
.ampm-btn:disabled { opacity: .6; cursor: not-allowed; }
#editor { width: min(520px, calc(100vw - 32px)); }

.people .tag.warn { background: #FDF0E6; color: var(--red); border: 1px solid var(--red); }

/* ---------- colour swatches ---------- */

.swatches { display: flex; flex-wrap: wrap; gap: 8px; }
.swatch {
  width: 30px; height: 30px; padding: 0; border-radius: 50%;
  border: 2px solid transparent; background: var(--c);
  cursor: pointer; position: relative;
}
.swatch:hover { filter: brightness(1.08); background: var(--c); }
.swatch[aria-checked="true"] { outline: 2px solid var(--gray); outline-offset: 2px; }
.swatch.auto {
  background: repeating-linear-gradient(135deg, #fff 0 4px, var(--gray-light) 4px 8px);
  border-color: var(--gray-light);
}
.swatch:disabled { opacity: .5; cursor: not-allowed; }
.swatch-note { font-size: 12px; color: var(--warm-gray); font-weight: 400; margin-top: 6px; }

/* ---------- location ---------- */

.maplink { margin: -8px 0 16px; font-size: 13px; }
.maplink a { color: var(--accent-dark); font-weight: 600; }

/* ---------- repeating ---------- */

.series-note {
  font-size: 12px; color: var(--brown); background: var(--tan);
  padding: 8px 10px; border-radius: 6px; margin-bottom: 14px;
}
