:root {
  color-scheme: light dark;
  --bg: #f4f4f5;
  --card: #ffffff;
  --ink: #18181b;
  --muted: #6b7280;
  --line: #d4d4d8;
  --accent: #1f3a5f;
  --accent-ink: #ffffff;
  --error: #b91c1c;
  --ok: #15803d;
  --chevron: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 12 8'%3E%3Cpath d='M1 1.5 6 6.5l5-5' fill='none' stroke='%236b7280' stroke-width='1.6' stroke-linecap='round' stroke-linejoin='round'/%3E%3C/svg%3E");
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #18181b;
    --card: #232327;
    --ink: #f4f4f5;
    --muted: #a1a1aa;
    --line: #3f3f46;
    --accent: #7d9fd0;
    --accent-ink: #10131a;
    --error: #f87171;
    --ok: #4ade80;
    --chevron: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 12 8'%3E%3Cpath d='M1 1.5 6 6.5l5-5' fill='none' stroke='%23a1a1aa' stroke-width='1.6' stroke-linecap='round' stroke-linejoin='round'/%3E%3C/svg%3E");
  }
}

* { box-sizing: border-box; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font: 16px/1.5 -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
}

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

.bar {
  max-width: 720px;
  margin: 0 auto;
  padding: 14px 20px;
  display: flex;
  align-items: center;
  gap: 12px;
}

.bar h1 {
  font-size: 1.1rem;
  margin: 0;
  flex: 1;
  font-weight: 600;
}

main {
  max-width: 720px;
  margin: 0 auto;
  padding: 20px;
}

.card {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 20px;
  margin-bottom: 16px;
}

.card h2 {
  margin: 0 0 4px;
  font-size: 1rem;
}

.hint {
  color: var(--muted);
  font-size: 0.85rem;
  margin: 0 0 16px;
}

label {
  display: block;
  font-size: 0.8rem;
  font-weight: 600;
  color: var(--muted);
  margin-bottom: 4px;
  text-transform: uppercase;
  letter-spacing: 0.03em;
}

input,
select,
textarea {
  width: 100%;
  padding: 10px 12px;
  font: inherit;
  color: var(--ink);
  background: var(--bg);
  border: 1px solid var(--line);
  border-radius: 6px;
}

/* The native arrow sits hard against the border; this one is inset to match
   the text, and leaves room for itself at the end of the line. */
select {
  appearance: none;
  -webkit-appearance: none;
  padding-right: 38px;
  background-image: var(--chevron);
  background-repeat: no-repeat;
  background-position: right 14px center;
  background-size: 12px 8px;
}

/* Height comes from each item's own row count - see fields.js. */
textarea {
  resize: vertical;
}

/* A week either side, without opening the list. */
.stepper {
  display: flex;
  align-items: stretch;
  gap: 6px;
}

.stepper select {
  flex: 1;
  min-width: 0;
}

.stepper button {
  flex: none;
  padding: 0 14px;
  font-size: 1.1rem;
  line-height: 1;
  color: var(--muted);
}

.stepper button:hover:not([disabled]) {
  color: var(--ink);
  border-color: var(--muted);
}

.field { margin-bottom: 14px; }

.row {
  display: flex;
  gap: 12px;
  flex-wrap: wrap;
}

.row > * { flex: 1 1 200px; }

/* The Sunday needs room for a date; AM/PM is happy at its own size. */
.date-field { flex: 1 1 320px; }
.service-field { flex: 0 1 auto; }

button {
  font: inherit;
  font-weight: 600;
  padding: 10px 18px;
  border-radius: 6px;
  border: 1px solid var(--accent);
  background: var(--accent);
  color: var(--accent-ink);
  cursor: pointer;
}

button.secondary {
  background: transparent;
  color: var(--ink);
  border-color: var(--line);
}

button[disabled] {
  opacity: 0.55;
  cursor: default;
}

.segmented {
  display: inline-flex;
  border: 1px solid var(--line);
  border-radius: 6px;
  overflow: hidden;
}

.segmented button {
  border: 0;
  border-radius: 0;
  background: transparent;
  color: var(--ink);
  padding: 10px 22px;
}

.segmented button.active {
  background: var(--accent);
  color: var(--accent-ink);
}

.actions {
  display: flex;
  align-items: center;
  gap: 12px;
  flex-wrap: wrap;
}

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

.status.error { color: var(--error); }
.status.ok { color: var(--ok); }

.hidden { display: none; }

/* Each item can be moved up or down, so the form order is the service order. */
.field-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
}

.field-head label { margin-bottom: 0; }

.move {
  display: flex;
  gap: 4px;
  flex: none;
}

.move button {
  padding: 2px 10px;
  font-size: 0.9rem;
  line-height: 1.4;
  background: transparent;
  color: var(--muted);
  border-color: var(--line);
}

.move button:hover:not([disabled]) {
  color: var(--ink);
  border-color: var(--muted);
}

.move button[disabled] { opacity: 0.3; }

.field-head + input,
.field-head + textarea { margin-top: 4px; }
