:root {
  --bg: #efe4d4;
  --sheet: #fbf7f1;
  --ink: #2a2118;
  --soft: #6d6258;
  --line: #e4d8c8;
  --paprika: #9c3b2e;
  --today: #f6ead2;
  --changed: #f8f1df;
  --changed-ink: #8a5a12;
  --gap: rgba(156, 59, 46, 0.16);
  --shadow: 0 18px 50px rgba(42, 33, 24, 0.08);
  --lane-name: 104px;
  --lane-gap: 8px;
  --serif: Fraunces, "Iowan Old Style", Palatino, Georgia, serif;
  --sans: Outfit, "Segoe UI", sans-serif;
  color-scheme: light;
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }

body {
  margin: 0;
  min-height: 100vh;
  background:
    radial-gradient(1200px 500px at 10% -10%, rgba(156, 59, 46, 0.08), transparent 50%),
    var(--bg);
  color: var(--ink);
  font-family: var(--sans);
  font-size: 16px;
  line-height: 1.4;
}

button, input, textarea { font: inherit; color: inherit; }
button { cursor: pointer; }
button:focus-visible, input:focus-visible, summary:focus-visible, textarea:focus-visible {
  outline: 2px solid #155e59;
  outline-offset: 2px;
}

.lock {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 24px;
}
.lock form {
  width: min(440px, 100%);
  background: var(--sheet);
  border-radius: 22px;
  padding: 32px 28px;
  box-shadow: var(--shadow);
}
.lock h1 {
  font-size: clamp(42px, 8vw, 64px);
}
.lock-field {
  display: grid;
  gap: 6px;
  margin: 18px 0 10px;
  font-size: 13px;
  font-weight: 700;
  color: var(--soft);
}
.lock-field input {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: #fff;
  padding: 12px;
  font-weight: 600;
  color: var(--ink);
}
.lock-remember {
  display: flex;
  align-items: center;
  gap: 8px;
  margin: 0 0 14px;
  font-weight: 600;
}
.lock .errors { margin: 0 0 12px; }
.lock .primary { width: 100%; }

.sheet {
  width: min(1180px, calc(100% - 28px));
  margin: 22px auto 40px;
  background: var(--sheet);
  border: 1px solid rgba(42, 33, 24, 0.08);
  border-radius: 22px;
  box-shadow: var(--shadow);
  padding: 28px 28px 18px;
}

.masthead {
  display: flex;
  justify-content: space-between;
  gap: 24px;
  align-items: flex-end;
  padding-bottom: 18px;
  border-bottom: 1px solid var(--ink);
  box-shadow: 0 3px 0 var(--paprika);
}

.eyebrow {
  margin: 0 0 4px;
  letter-spacing: 0.16em;
  text-transform: uppercase;
  font-size: 12px;
  font-weight: 600;
  color: var(--paprika);
}

h1 {
  margin: 0;
  font-family: var(--serif);
  font-size: clamp(42px, 6vw, 68px);
  font-weight: 560;
  letter-spacing: -0.03em;
  line-height: 0.9;
}

.lede {
  margin: 8px 0 0;
  color: var(--soft);
  font-size: 15px;
}

.mast-side { text-align: right; }

.legend {
  display: flex;
  gap: 14px;
  justify-content: flex-end;
  margin: 0 0 8px;
  padding: 0;
  list-style: none;
}

.legend li {
  display: flex;
  align-items: center;
  gap: 7px;
  font-weight: 600;
}

.legend li::before {
  content: "";
  width: 0.72rem;
  height: 0.72rem;
  border-radius: 50%;
  background: var(--p);
}

[data-person="alex"] { --p: #155e59; --p-soft: #e5f3f1; }
[data-person="miki"] { --p: #9a4514; --p-soft: #f8ecdf; }
[data-person="seferina"] { --p: #7a3450; --p-soft: #f7e8ee; }

.e-note {
  margin: 0;
  color: var(--soft);
  font-size: 14px;
}

.e-note strong {
  display: inline-grid;
  place-items: center;
  width: 1.35rem;
  height: 1.35rem;
  margin-right: 2px;
  border: 1px dashed var(--ink);
  border-radius: 50%;
  font-size: 12px;
}

.toolbar {
  margin-top: 18px;
  padding: 12px 0 8px;
}

.mode {
  display: inline-flex;
  padding: 3px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: #fff;
}

.mode button {
  border: 0;
  background: transparent;
  border-radius: 999px;
  padding: 7px 14px;
  color: var(--soft);
  font-weight: 600;
}

.mode button[aria-pressed="true"] {
  background: var(--ink);
  color: #f6f0e6;
}

.saved {
  float: right;
  margin: 8px 0 0;
  color: #155e59;
  font-size: 13px;
  font-weight: 700;
}

.weekbar {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-top: 14px;
}

.week-title { min-width: 16rem; }
.week-title p {
  margin: 0;
  color: var(--paprika);
  font-size: 13px;
  font-weight: 700;
  letter-spacing: 0.04em;
  text-transform: uppercase;
}
.week-title h2 {
  margin: 0;
  font-family: var(--serif);
  font-size: clamp(26px, 3vw, 36px);
  font-weight: 560;
  letter-spacing: -0.03em;
  font-variant-numeric: tabular-nums;
}

.nav, .text-btn, .actions > button, .menu button, .primary, .confirm button {
  border-radius: 999px;
}

.nav {
  width: 42px;
  height: 42px;
  border: 1px solid var(--line);
  background: #fff;
  font-size: 20px;
}

.text-btn, .actions > button, .menu button {
  border: 1px solid var(--line);
  background: #fff;
  padding: 8px 14px;
  font-weight: 600;
}

.primary {
  border: 0;
  background: var(--ink);
  color: #f6f0e6;
  padding: 10px 18px;
  font-weight: 700;
}

.banner, .hint, .confirm, .fallback {
  margin-top: 12px;
  padding: 10px 12px;
  border-radius: 12px;
}

.banner {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  align-items: center;
  background: var(--changed);
  border: 1px solid #ead9b4;
}
.banner p { margin: 0; }

.note {
  display: grid;
  gap: 4px;
  margin-top: 12px;
  font-size: 13px;
  font-weight: 600;
  color: var(--soft);
}
.note input, .fallback textarea, .shift-row input[type="time"] {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: #fff;
  padding: 10px 12px;
  font-weight: 500;
  color: var(--ink);
}

.confirm {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  align-items: center;
  background: #fdeeea;
  border: 1px solid #f0cfc8;
}
.confirm p { margin: 0; }
.confirm div { display: flex; gap: 8px; }
#confirm-yes {
  border: 0;
  background: var(--paprika);
  color: white;
  padding: 8px 14px;
  font-weight: 700;
}

.actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  align-items: flex-start;
  margin-top: 12px;
}

details { position: relative; }
summary {
  list-style: none;
  border: 1px solid var(--line);
  background: #fff;
  border-radius: 999px;
  padding: 8px 14px;
  font-weight: 600;
}
summary::-webkit-details-marker { display: none; }
.menu {
  position: absolute;
  z-index: 6;
  display: grid;
  gap: 6px;
  min-width: 250px;
  margin-top: 6px;
  padding: 8px;
  background: #fff;
  border: 1px solid var(--line);
  border-radius: 14px;
  box-shadow: var(--shadow);
}
.menu button { text-align: left; border-radius: 10px; }

.fallback textarea {
  min-height: 180px;
  resize: vertical;
  font-variant-numeric: tabular-nums;
}

.hint {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  align-items: flex-start;
  background: #fff;
  border-left: 4px solid var(--paprika);
}
.hint span { color: var(--soft); }
.hint button {
  border: 0;
  background: transparent;
  font-size: 22px;
  line-height: 1;
  padding: 0 4px;
}

.block { margin-top: 22px; }
.section-head h3 {
  margin: 0;
  font-family: var(--serif);
  font-size: 28px;
  font-weight: 560;
}
.section-head p {
  margin: 4px 0 12px;
  color: var(--soft);
}

.table-scroll { overflow-x: auto; }

table {
  width: 100%;
  min-width: 980px;
  border-collapse: separate;
  border-spacing: 0;
  font-variant-numeric: tabular-nums;
}

thead th {
  padding: 0 6px 8px;
  font-size: 13px;
  font-weight: 700;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  color: var(--soft);
  text-align: left;
}

thead th span {
  display: block;
  margin-top: 2px;
  color: var(--ink);
  font-family: var(--serif);
  font-size: 18px;
  letter-spacing: 0;
  text-transform: none;
  font-weight: 560;
}

tbody th, thead th:first-child {
  position: sticky;
  left: 0;
  z-index: 1;
  background: var(--sheet);
  min-width: 132px;
  text-align: left;
}

tbody th {
  padding: 8px 10px 8px 0;
  vertical-align: top;
}

.who {
  display: block;
  font-size: 18px;
  font-weight: 700;
}
.who::before {
  content: "";
  display: inline-block;
  width: 0.6rem;
  height: 0.6rem;
  margin-right: 6px;
  border-radius: 50%;
  background: var(--p);
}
.load {
  display: block;
  margin-top: 3px;
  color: var(--soft);
  font-size: 12px;
  font-weight: 600;
}

td {
  height: 1px;
  padding: 4px;
  vertical-align: top;
  border-top: 1px solid var(--line);
}

.cell {
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  align-items: flex-start;
  gap: 8px;
  width: 100%;
  height: 100%;
  min-height: 96px;
  padding: 8px;
  border: 1px solid transparent;
  border-radius: 12px;
  background: transparent;
  text-align: left;
}
.cell:hover, .cell:focus-visible {
  border-color: color-mix(in srgb, var(--p) 45%, white);
  background: #fff;
}
td.is-today { background: var(--today); }
thead th.is-today span { color: var(--paprika); }

.pills { display: grid; gap: 4px; width: 100%; }
.pill {
  display: inline-block;
  width: fit-content;
  max-width: 100%;
  padding: 4px 8px;
  border-radius: 999px;
  background: var(--p-soft);
  color: var(--p);
  font-size: 12.5px;
  font-weight: 700;
  white-space: nowrap;
}
.pill.is-open {
  background: transparent;
  border: 1px dashed var(--p);
}
.free {
  color: var(--soft);
  font-style: italic;
}
.leave {
  display: inline-block;
  width: fit-content;
  padding: 4px 8px;
  border-radius: 999px;
  background: #efe4f2;
  color: #6a3d78;
  font-size: 12.5px;
  font-style: normal;
  font-weight: 700;
}
.frei-label.leave {
  padding: 2px 8px;
  font-size: 12px;
}
thead th .day-note-input {
  display: block;
  width: 100%;
  margin-top: 6px;
  border: 1px dashed var(--line);
  border-radius: 8px;
  background: #fff;
  padding: 4px 6px;
  color: var(--ink);
  font-size: 12px;
  font-weight: 600;
  letter-spacing: 0;
  text-transform: none;
}
.day-note-input::placeholder {
  color: var(--soft);
  font-weight: 500;
}
.day-note-field {
  display: flex;
  align-items: center;
  gap: 8px;
  max-width: 460px;
  margin: 0 0 8px;
}
.day-note-field span {
  flex: none;
  color: var(--soft);
  font-size: 12px;
  font-weight: 700;
}
.day-note-field .day-note-input { margin-top: 0; }
.day-note-print { display: none; }
.print-reserve { display: none; }
.edit-hint, .changed-flag {
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.04em;
  text-transform: uppercase;
}
.edit-hint { color: var(--soft); }
.changed-flag { color: var(--changed-ink); }

.day-card {
  padding: 12px 0 14px;
  border-top: 1px solid var(--line);
}
.day-card.is-today { background: linear-gradient(90deg, var(--today), transparent 70%); }
.day-head {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  align-items: baseline;
  margin-bottom: 6px;
}
.day-head h4 {
  margin: 0;
  font-size: 16px;
}
.day-head h4 span {
  margin-left: 8px;
  color: var(--soft);
  font-weight: 500;
  font-variant-numeric: tabular-nums;
}
.today-pill {
  margin-left: 8px;
  padding: 1px 7px;
  border-radius: 999px;
  background: var(--paprika);
  color: white;
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.04em;
  text-transform: uppercase;
}
.gap-label {
  margin: 0;
  color: var(--paprika);
  font-size: 13px;
  font-weight: 700;
}

.axis, .lane {
  display: grid;
  grid-template-columns: var(--lane-name) 1fr;
  gap: var(--lane-gap);
  align-items: center;
}
.axis { height: 18px; color: var(--soft); font-size: 11px; font-weight: 600; }
.axis-scale { position: relative; height: 18px; }
.axis-scale span {
  position: absolute;
  top: 0;
  font-variant-numeric: tabular-nums;
}
.lanes { position: relative; display: grid; gap: 4px; }
.gap-layer {
  position: absolute;
  left: calc(var(--lane-name) + var(--lane-gap));
  right: 0;
  top: 0;
  bottom: 0;
  pointer-events: none;
}
.gap-band {
  position: absolute;
  top: 0;
  bottom: 0;
  background: var(--gap);
  border-radius: 8px;
}

.lane {
  position: relative;
  z-index: 1;
  width: 100%;
  min-height: 36px;
  padding: 0;
  border: 0;
  border-radius: 8px;
  background: transparent;
  text-align: left;
}
.lane-name {
  font-size: 13px;
  font-weight: 700;
  color: var(--p);
}
.lane.is-changed .lane-name::after {
  content: "";
  display: inline-block;
  width: 6px;
  height: 6px;
  margin-left: 5px;
  border-radius: 50%;
  background: var(--changed-ink);
  transform: translateY(-1px);
}
.track {
  position: relative;
  height: 30px;
  border-radius: 8px;
  background: transparent;
  box-shadow: inset 0 0 0 1px rgba(42, 33, 24, 0.06);
}
.lane:hover .track, .lane:focus-visible .track {
  box-shadow: inset 0 0 0 1px color-mix(in srgb, var(--p) 55%, white);
}
.gridline {
  position: absolute;
  top: 0;
  bottom: 0;
  width: 1px;
  background: rgba(42, 33, 24, 0.08);
}
.bar {
  position: absolute;
  top: 3px;
  height: 24px;
  display: flex;
  align-items: center;
  overflow: hidden;
  padding: 0 8px;
  border-radius: 999px;
  background: var(--p-soft);
  color: var(--p);
  box-shadow: inset 3px 0 0 var(--p);
  font-size: 12px;
  font-weight: 700;
  white-space: nowrap;
  container-type: inline-size;
}
.bar span { display: none; }
@container (min-width: 92px) {
  .bar span { display: inline; }
}
.bar.is-open { border: 1px dashed var(--p); }
.frei-label {
  position: absolute;
  left: 8px;
  top: 6px;
  color: var(--soft);
  font-size: 12px;
  font-style: italic;
}

.colophon {
  margin-top: 22px;
  padding-top: 12px;
  border-top: 1px solid var(--line);
  color: var(--soft);
  font-size: 13px;
}

.toast {
  position: fixed;
  left: 50%;
  bottom: 18px;
  transform: translateX(-50%);
  max-width: min(520px, calc(100% - 24px));
  padding: 12px 16px;
  border-radius: 999px;
  background: var(--ink);
  color: #f6f0e6;
  box-shadow: var(--shadow);
  font-weight: 600;
}

dialog {
  width: min(560px, calc(100vw - 24px));
  max-height: calc(100vh - 24px);
  padding: 0;
  border: 0;
  border-radius: 18px;
  background: var(--sheet);
  color: var(--ink);
  box-shadow: var(--shadow);
}
dialog::backdrop { background: rgba(42, 33, 24, 0.48); }
dialog form {
  max-height: calc(100vh - 24px);
  overflow: auto;
  padding: 20px;
}
.editor-head, .editor-foot {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  align-items: flex-start;
}
#editor-kicker {
  margin: 0;
  color: var(--paprika);
  font-size: 13px;
  font-weight: 700;
  letter-spacing: 0.04em;
  text-transform: uppercase;
}
#editor-title {
  margin: 0;
  font-family: var(--serif);
  font-size: 32px;
  font-weight: 560;
}
#editor-context { color: var(--soft); margin: 10px 0; }
.errors {
  margin: 0 0 10px;
  color: var(--paprika);
  font-weight: 700;
}
.shift-row {
  display: grid;
  grid-template-columns: 1fr 1fr auto auto;
  gap: 8px;
  align-items: end;
  margin-bottom: 8px;
}
.shift-row label, .check {
  display: grid;
  gap: 4px;
  font-size: 12px;
  font-weight: 700;
  color: var(--soft);
}
.check {
  grid-auto-flow: column;
  align-items: center;
  justify-content: start;
  min-height: 42px;
  padding-bottom: 2px;
}
.remove {
  border: 0;
  background: transparent;
  color: var(--paprika);
  font-weight: 700;
  padding: 8px 0;
}
.add-shift { margin: 4px 0 12px; }
fieldset {
  margin: 0;
  padding: 12px 0 0;
  border: 0;
  border-top: 1px solid var(--line);
}
legend { padding: 0; font-size: 13px; font-weight: 700; color: var(--soft); }
.presets { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 8px; }
.presets > button,
.preset-chip {
  border: 1px solid var(--line);
  background: #fff;
  border-radius: 999px;
  font-weight: 600;
  font-size: 13px;
}
.presets > button {
  padding: 7px 10px;
}
.presets > button.is-active,
.preset-chip:has(.is-active) {
  border-color: var(--ink);
  background: var(--ink);
  color: #f6f0e6;
}
.preset-chip {
  display: inline-flex;
  align-items: center;
}
.preset-chip button {
  border: 0;
  background: transparent;
  border-radius: 0;
  color: inherit;
  font-weight: 600;
  font-size: 13px;
}
.preset-chip .preset-apply { padding: 7px 4px 7px 10px; }
.preset-chip .preset-delete {
  padding: 7px 10px 7px 4px;
  color: var(--paprika);
  font-size: 16px;
  line-height: 1;
}
.preset-chip:has(.is-active) .preset-delete { color: #f6f0e6; }
.preset-create {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 10px;
}
.preset-create input {
  flex: 1 1 160px;
  min-width: 0;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: #fff;
  padding: 8px 10px;
}
.preset-hint {
  margin: 8px 0 0;
  color: var(--soft);
  font-size: 12px;
}
.editor-save { margin: 14px 0; color: var(--soft); font-size: 13px; }
.empty-day { margin: 0 0 8px; color: var(--soft); font-style: italic; }

@media (max-width: 800px) {
  .sheet { width: min(100% - 12px, 1180px); padding: 16px; border-radius: 16px; }
  .masthead, .banner, .confirm, .weekbar { flex-wrap: wrap; }
  .mast-side, .legend { text-align: left; justify-content: flex-start; }
  .shift-row { grid-template-columns: 1fr 1fr; }
  .saved { float: none; }
}

@media print {
  @page { size: A4 landscape; margin: 8mm; }
  html, body {
    background: white !important;
    height: auto;
  }
  .lock, dialog, .toast, .no-print, .print-skip, .edit-hint, .load, .legend, .changed-flag {
    display: none !important;
  }
  .sheet {
    width: 100%;
    margin: 0;
    padding: 0;
    border: 0;
    border-radius: 0;
    box-shadow: none;
    background: white;
  }
  .masthead {
    align-items: flex-end;
    gap: 12px;
    padding-bottom: 6px;
    margin-bottom: 2px;
  }
  h1 { font-size: 28px; }
  .eyebrow { margin-bottom: 0; }
  .lede { margin-top: 2px; }
  .e-note { font-size: 11px; }
  .toolbar { margin: 0; padding: 0; }
  .weekbar { margin-top: 6px; }
  .week-title h2 { font-size: 20px; }
  .week-title p { font-size: 11px; }
  .print-reserve {
    display: block;
    margin: 2px 0 0;
    color: var(--ink);
    font-size: 12px;
    font-weight: 650;
  }
  .note { margin-top: 4px; }
  .note.is-empty { display: none !important; }
  .note input {
    border: 0;
    padding: 0 0 2px;
    background: transparent;
  }
  .block { margin-top: 10px; }
  .table-scroll { overflow: visible; }
  table {
    min-width: 0;
    width: 100%;
    table-layout: fixed;
    border-collapse: separate;
    border-spacing: 0 12px;
    font-size: 12px;
  }
  thead th:first-child, tbody th {
    position: static;
    min-width: 0;
    width: 24mm;
  }
  thead th {
    padding: 0 6px 8px;
    white-space: normal;
  }
  thead th span { font-size: 14px; }
  td { padding: 8px 6px 10px; }
  .cell {
    min-height: 0;
    gap: 0;
    padding: 0;
  }
  .pills { gap: 10px; }
  .who { font-size: 13px; }
  .pill, .leave {
    max-width: 100%;
    box-sizing: border-box;
    font-size: 10.5px;
    line-height: 1.2;
    padding: 3px 5px;
  }
  .free { font-size: 12px; }
  thead th .day-note-input { display: none !important; }
  thead th .day-note-print {
    display: block;
    max-width: 100%;
    margin-top: 3px;
    color: var(--ink);
    font-family: var(--sans);
    font-size: 10px;
    font-weight: 650;
    line-height: 1.25;
    letter-spacing: 0;
    text-transform: none;
    white-space: normal;
    overflow-wrap: anywhere;
  }
  thead th .day-note-print.is-empty { display: none !important; }
  * { -webkit-print-color-adjust: exact; print-color-adjust: exact; }
}

@media (prefers-reduced-motion: reduce) {
  * { scroll-behavior: auto !important; transition: none !important; }
}
