/* Nscale brand: Nscale Blue, Midnight, Chalk, Frost, Slate. Square corners, DM Sans + DM Mono. */
:root {
  --blue: #0F41F3;
  --blue-dark: #092792;
  --blue-light: #4B71F6;
  --midnight: #040E27;
  --chalk: #FDFFF8;
  --frost: #E1EAF9;
  --frost-dark: #B4BBC7;
  --slate: #3B404D;
  --grey: #828793;
  --grey-light: #C0C3C9;
  --sans: "DM Sans", -apple-system, "Helvetica Neue", "Segoe UI", sans-serif;
  --mono: "DM Mono", ui-monospace, "SF Mono", Menlo, Consolas, monospace;
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body { margin: 0; background: var(--chalk); color: var(--midnight); font-family: var(--sans); font-size: 16px; line-height: 1.5; }
.mono { font-family: var(--mono); }
:focus-visible { outline: 2px solid var(--blue); outline-offset: 2px; }
.on-dark :focus-visible, .site-header :focus-visible { outline-color: var(--chalk); }
[hidden] { display: none !important; }

.site-header { background: var(--midnight); color: var(--chalk); padding: 18px 32px; display: flex; flex-wrap: wrap; gap: 16px; align-items: center; justify-content: space-between; }
.wordmark { font-size: 18px; font-weight: 700; color: var(--chalk); text-decoration: none; }
.header-meta { display: flex; flex-wrap: wrap; gap: 16px; align-items: center; font-size: 14px; color: var(--frost); }
.link-button { background: none; border: 0; padding: 8px 0; font: inherit; color: inherit; text-decoration: underline; cursor: pointer; min-height: 44px; }

main { max-width: 1180px; margin: 0 auto; padding: 48px 32px 80px; display: flex; flex-direction: column; gap: 40px; }
.intro { display: flex; flex-direction: column; gap: 12px; max-width: 720px; }
.eyebrow { font-size: 14px; font-weight: 500; color: var(--blue); }
h1 { margin: 0; font-size: 44px; line-height: 1.1; font-weight: 700; }
h2 { margin: 0; font-size: 24px; font-weight: 700; line-height: 1.2; }
h3 { margin: 0; font-size: 20px; font-weight: 700; }
.lede { margin: 0; font-size: 18px; color: var(--slate); }
.muted { color: var(--slate); }
.small { font-size: 14px; }

.btn { font: inherit; font-size: 16px; font-weight: 500; border: 0; border-radius: 0; padding: 0 24px; min-height: 48px; cursor: pointer; background: var(--blue); color: var(--chalk); display: inline-flex; align-items: center; justify-content: center; text-decoration: none; }
.btn:hover { background: var(--blue-dark); }
.btn:disabled { background: var(--slate); color: var(--grey-light); cursor: not-allowed; }
.btn-outline { background: transparent; color: var(--midnight); border: 1px solid var(--midnight); }
.btn-outline:hover { background: var(--frost); }

.panel { background: var(--frost); padding: 32px; display: flex; flex-direction: column; gap: 16px; }
.panel-outline { border: 1px solid var(--blue); padding: 24px; display: flex; flex-direction: column; gap: 16px; }
.notice { background: var(--frost); padding: 14px 16px; }
.alert { border: 1px solid var(--midnight); background: var(--chalk); padding: 10px 12px; font-size: 15px; }
.status { background: var(--midnight); color: var(--chalk); padding: 12px 16px; font-size: 15px; }

label { font-size: 14px; font-weight: 500; }
.field { display: flex; flex-direction: column; gap: 6px; }
input[type=text], input[type=email], input[type=number], input[type=date], input[type=time], input[type=search], select {
  font: inherit; font-size: 16px; padding: 0 12px; min-height: 48px; border: 1px solid var(--slate); border-radius: 0; background: var(--chalk); color: var(--midnight);
}

/* Selection bar */
.select-bar { background: var(--midnight); color: var(--chalk); padding: 20px 24px; display: flex; flex-wrap: wrap; gap: 16px; align-items: center; justify-content: space-between; }
.select-bar .who { font-size: 14px; color: var(--frost); }
.select-bar .what { font-size: 18px; font-weight: 500; }

/* Time zone switch */
.tz-row { display: flex; flex-wrap: wrap; gap: 16px; align-items: center; justify-content: space-between; }
.tz-switch { display: flex; flex-wrap: wrap; border: 1px solid var(--blue); }
.tz-switch button { font: inherit; font-size: 15px; font-weight: 500; border: 0; border-radius: 0; padding: 0 18px; min-height: 44px; cursor: pointer; background: transparent; color: var(--blue); }
.tz-switch button[aria-pressed=true] { background: var(--blue); color: var(--chalk); }

/* Week grid */
.week { display: flex; flex-direction: column; gap: 16px; }
.week-head { display: flex; flex-wrap: wrap; gap: 12px; align-items: baseline; justify-content: space-between; border-bottom: 1px solid var(--blue); padding-bottom: 12px; }
.days { display: flex; flex-wrap: wrap; gap: 16px; }
.day { flex: 1 1 180px; min-width: 0; display: flex; flex-direction: column; gap: 8px; }
.day-head { display: flex; gap: 8px; align-items: baseline; padding: 4px 0 8px; }
.day-head strong { font-size: 16px; }

.slot { font: inherit; text-align: left; display: flex; flex-direction: column; gap: 6px; width: 100%; padding: 12px 14px; min-height: 92px; border-radius: 0; cursor: pointer; background: var(--frost); color: var(--midnight); border: 1px solid var(--frost); }
.slot:hover:not(:disabled) { border-color: var(--blue); }
.slot .top { display: flex; justify-content: space-between; align-items: baseline; gap: 8px; }
.slot .time { font-family: var(--mono); font-size: 20px; }
.slot .state { font-size: 13px; font-weight: 500; }
.slot .sub, .slot .id, .slot .count { font-size: 13px; }
.slot .id { font-family: var(--mono); font-size: 12px; }
.bar { display: block; width: 100%; height: 4px; background: var(--frost-dark); }
.bar > span { display: block; height: 4px; background: var(--blue); }
.slot.selected { background: var(--blue); color: var(--chalk); border-color: var(--blue); }
.slot.selected .bar { background: var(--blue-light); }
.slot.selected .bar > span { background: var(--chalk); }
.slot:disabled { background: var(--chalk); color: var(--slate); border-color: var(--grey); cursor: not-allowed; }
.slot:disabled .bar { background: var(--grey-light); }
.slot:disabled .bar > span { background: var(--slate); }

.legend { display: flex; flex-wrap: wrap; gap: 24px; font-size: 14px; color: var(--slate); }
.legend span { display: inline-flex; gap: 8px; align-items: center; }
.swatch { width: 16px; height: 16px; display: inline-block; }

/* Confirmation */
.confirm-card { background: var(--blue); color: var(--chalk); padding: 32px; display: flex; flex-direction: column; gap: 10px; }
.confirm-card .label { font-size: 14px; color: var(--frost); }
.confirm-card .big { font-size: 32px; font-weight: 700; line-height: 1.15; }
.confirm-card .time { font-family: var(--mono); font-size: 28px; }
.invite-note { background: var(--frost); padding: 24px; display: flex; gap: 16px; align-items: flex-start; }
.actions { display: flex; flex-wrap: wrap; gap: 12px; }

/* Organiser view */
.stats { display: grid; grid-template-columns: repeat(auto-fit, minmax(180px, 1fr)); gap: 16px; }
.stat { background: var(--frost); padding: 20px; display: flex; flex-direction: column; gap: 8px; }
.stat .k { font-size: 14px; color: var(--slate); }
.stat .v { font-family: var(--mono); font-size: 36px; line-height: 1.1; }
.stat.highlight { background: var(--blue); color: var(--chalk); }
.stat.highlight .k { color: var(--frost); }
.two-col { display: flex; flex-wrap: wrap; gap: 16px; }
.two-col > * { flex: 1 1 420px; min-width: 0; }
.form-row { display: flex; flex-wrap: wrap; gap: 12px; align-items: flex-end; }
.form-row .field { flex: 1 1 140px; }
.stepper { display: flex; }
.stepper button { font: inherit; font-size: 20px; width: 48px; min-height: 48px; border: 1px solid var(--slate); border-radius: 0; background: var(--chalk); color: var(--midnight); cursor: pointer; }
.stepper input { width: 88px; text-align: center; border-left: 0; border-right: 0; font-family: var(--mono); }
.cell { font: inherit; text-align: left; display: flex; flex-direction: column; gap: 6px; width: 100%; padding: 10px 12px; border-radius: 0; cursor: pointer; background: var(--frost); color: var(--midnight); border: 1px solid var(--frost); }
.cell .top { display: flex; justify-content: space-between; gap: 8px; font-family: var(--mono); }
.cell .zones { font-size: 12px; }
.cell .id { font-family: var(--mono); font-size: 12px; }
.cell.full { background: var(--midnight); color: var(--chalk); border-color: var(--midnight); }
.cell.full .bar { background: var(--slate); }
.cell.full .bar > span { background: var(--chalk); }
.cell[aria-pressed=true] { background: var(--blue); color: var(--chalk); border-color: var(--blue); }
.cell[aria-pressed=true] .bar { background: var(--blue-light); }
.cell[aria-pressed=true] .bar > span { background: var(--chalk); }
.table-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; font-size: 15px; min-width: 640px; }
th { text-align: left; font-weight: 500; padding: 10px 12px; border-bottom: 1px solid var(--midnight); }
td { padding: 10px 12px; border-bottom: 1px solid var(--frost-dark); }
.file-input:focus-visible + label { outline: 2px solid var(--blue); outline-offset: 2px; }
.visually-hidden { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }

/* Small buttons, row actions, danger */
.btn-sm { font-size: 14px; min-height: 40px; padding: 0 14px; }
.btn-danger { color: var(--midnight); border-color: var(--midnight); }
.btn-danger:hover { background: var(--midnight); color: var(--chalk); }
.row-actions { display: flex; gap: 8px; flex-wrap: wrap; justify-content: flex-end; }
td:last-child { white-space: nowrap; }

/* Modal dialogs */
.modal { border: 0; padding: 0; border-radius: 0; width: calc(100% - 32px); max-width: 640px; max-height: calc(100vh - 48px); overflow: auto; background: var(--chalk); color: var(--midnight); }
.modal:has(.modal-wide) { max-width: 1040px; }
.modal::backdrop { background: rgba(4, 14, 39, 0.6); }
.modal-body { padding: 32px; display: flex; flex-direction: column; gap: 20px; }
#rows { display: flex; flex-direction: column; gap: 12px; }
.person-row { border: 0; border-bottom: 1px solid var(--frost-dark); margin: 0; padding: 0 0 12px; display: grid; grid-template-columns: 1fr 1.4fr 1fr 1fr auto; gap: 12px; align-items: end; min-width: 0; }
.person-row .field { min-width: 0; }
.person-row .row-error { grid-column: 1 / -1; color: var(--midnight); border-left: 3px solid var(--blue); padding-left: 8px; }
input[aria-invalid=true] { border: 2px solid var(--blue); }

@media (max-width: 760px) {
  .person-row { grid-template-columns: 1fr 1fr; }
  .person-row .remove-row { grid-column: 1 / -1; justify-self: start; }
}

@media (max-width: 640px) {
  main { padding: 32px 20px 64px; }
  h1 { font-size: 34px; }
  .site-header { padding: 16px 20px; }
}
@media (prefers-reduced-motion: reduce) { * { transition: none !important; } }
