/* ---------- Intro ---------- */

.intro {
  display: grid;
  grid-template-columns: minmax(0, 1.28fr) minmax(320px, 0.72fr);
  gap: 48px;
  align-items: end;
  padding-block: 44px 30px;
}

.intro-copy {
  max-width: 660px;
}

.intro h1 {
  margin: 14px 0 14px;
  font-size: clamp(2.55rem, 4.4vw, 3.75rem);
  line-height: 1.02;
  letter-spacing: -0.028em;
}

.intro h1 em {
  font-style: italic;
  font-weight: 500;
  color: var(--brand);
}

.lede {
  max-width: 54ch;
  color: var(--ink-2);
  font-size: 1.01rem;
  line-height: 1.6;
}

.quickstart {
  padding: 18px;
  border: 1px solid var(--line);
  border-radius: var(--radius-md);
  background: var(--surface);
  box-shadow: var(--shadow-sm);
}

.quickstart-head {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 10px;
  margin-bottom: 12px;
}

.quickstart-head h2 {
  font-size: 1.02rem;
}

.quickstart-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 7px;
}

.qs-chip {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  min-height: 42px;
  padding: 7px 10px;
  border: 1px solid var(--line);
  border-radius: var(--radius-xs);
  background: var(--paper);
  color: var(--ink);
  text-align: left;
  cursor: pointer;
  transition: border-color 140ms var(--ease), background-color 140ms var(--ease);
}

.qs-chip:hover {
  border-color: var(--line-strong);
  background: var(--surface-2);
}

.qs-chip span:first-child {
  font-size: 0.8rem;
  font-weight: 650;
  white-space: nowrap;
}

.qs-chip small {
  color: var(--ink-3);
  font-size: 0.65rem;
  white-space: nowrap;
}

.qs-chip.is-active {
  border-color: var(--brand);
  background: var(--brand-soft);
  box-shadow: inset 0 0 0 1px var(--brand);
}

.qs-chip.is-active .qs-check {
  color: var(--brand);
}

.qs-check {
  width: 13px;
  height: 13px;
  color: transparent;
}

.quickstart-note {
  margin-top: 11px;
  color: var(--ink-3);
  font-size: 0.71rem;
  line-height: 1.45;
}

/* ---------- Workspace ---------- */

.workspace {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 392px;
  gap: 22px;
  align-items: start;
  padding-bottom: 36px;
}

.main-col {
  display: grid;
  gap: 16px;
  min-width: 0;
}

.calendar-card {
  min-width: 0;
  padding: 18px 18px 12px;
  border: 1px solid var(--line);
  border-radius: var(--radius-lg);
  background: var(--surface);
  box-shadow: var(--shadow-sm);
}

/* ---------- Calendar ---------- */

.cal-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 10px;
}

.cal-month {
  display: flex;
  align-items: center;
  gap: 1px;
}

.cal-month h2 {
  min-width: 8.5ch;
  padding-inline: 6px;
  font-size: 1.4rem;
  letter-spacing: -0.02em;
  font-variant-numeric: tabular-nums;
}

.cal-month #cal-today {
  margin-left: 6px;
}

.cal-meta {
  display: flex;
  gap: 6px;
  flex-wrap: wrap;
}

.legend {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 6px 14px;
  margin: 12px 0 8px;
  color: var(--ink-2);
  font-size: 0.75rem;
}

.legend-item {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  white-space: nowrap;
}

.legend-swatch {
  width: 11px;
  height: 11px;
  border-radius: 3px;
  background: var(--a-soft);
  border: 1px solid var(--a);
}

.legend-swatch.b {
  background: var(--b-soft);
  border-color: var(--b);
}

.legend-item .icon {
  width: 12px;
  height: 12px;
  color: var(--gold);
}

.legend-note {
  width: 11px;
  height: 11px;
  border-radius: 50%;
  border: 1px dashed var(--ink-3);
  background: transparent;
}

.cal-scroll {
  width: 100%;
}

.cal {
  width: 100%;
  border-collapse: separate;
  border-spacing: 3px;
  table-layout: fixed;
}

.cal thead th {
  padding: 2px 0 4px;
  color: var(--ink-3);
  font-size: 0.66rem;
  font-weight: 680;
  letter-spacing: 0.07em;
  text-align: center;
  text-transform: uppercase;
}

.cal thead th.is-weekend {
  color: var(--gold);
}

.cal td {
  padding: 0;
  height: 100px;
  vertical-align: top;
}

.cal-day {
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  width: 100%;
  height: 100%;
  min-height: 100px;
  padding: 7px 7px 8px;
  border: 1px solid transparent;
  border-radius: var(--radius-sm);
  background: transparent;
  color: var(--ink);
  text-align: left;
  cursor: pointer;
  transition: box-shadow 140ms var(--ease), filter 140ms var(--ease);
}

.cal-day.owner-a {
  background: var(--a-soft);
}

.cal-day.owner-b {
  background: var(--b-soft);
}

.cal-day:hover {
  box-shadow: inset 0 0 0 1.5px var(--a);
}

.cal-day.owner-b:hover {
  box-shadow: inset 0 0 0 1.5px var(--b);
}

.cal-day.is-outside {
  opacity: 0.36;
}

.cal-day.is-outside:hover,
.cal-day.is-outside:focus-visible {
  opacity: 0.8;
}

.cal-day.is-changed {
  border-color: var(--ink-3);
  border-style: dashed;
}

.cal-day.is-today {
  box-shadow: inset 0 0 0 1.5px var(--ink);
}

.cal-top {
  display: flex;
  flex-wrap: wrap;
  align-items: flex-start;
  justify-content: space-between;
  gap: 4px;
  width: 100%;
}

.cal-bottom {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 4px;
  width: 100%;
}

.cal-daynum {
  font-size: 0.83rem;
  font-weight: 650;
  font-variant-numeric: tabular-nums;
  line-height: 1.4;
  color: var(--ink);
}

.is-today .cal-daynum {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 21px;
  height: 20px;
  padding-inline: 5px;
  border-radius: var(--radius-pill);
  background: var(--ink);
  color: var(--paper);
}

.cal-flag {
  display: inline-flex;
  flex: 0 0 100%;
  align-items: center;
  justify-content: flex-start;
  gap: 3px;
  min-width: 0;
  margin-top: 1px;
  color: var(--gold);
}

.cal-flag .icon {
  width: 12px;
  height: 12px;
  fill: currentColor;
  stroke-width: 1;
}

.cal-holiday {
  display: -webkit-box;
  max-width: 100%;
  overflow: hidden;
  color: var(--gold);
  font-size: 0.58rem;
  font-weight: 700;
  letter-spacing: 0.01em;
  line-height: 1.25;
  text-overflow: ellipsis;
  white-space: normal;
  -webkit-box-orient: vertical;
  -webkit-line-clamp: 2;
}

.cal-monogram {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 19px;
  height: 19px;
  padding-inline: 4px;
  border-radius: 6px;
  background: var(--a);
  color: var(--a-chip-text);
  font-size: 0.6rem;
  font-weight: 750;
  letter-spacing: 0.01em;
}

.owner-b .cal-monogram {
  background: var(--b);
  color: var(--b-chip-text);
}

.cal-note-dot {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: var(--ink-2);
  opacity: 0.7;
  margin-bottom: 3px;
}

.cal-foot {
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 6px;
  margin-top: 6px;
  padding-top: 8px;
  border-top: 1px solid var(--line);
}

.cal-hint {
  display: flex;
  align-items: center;
  gap: 5px;
  color: var(--ink-3);
  font-size: 0.71rem;
}

.cal-hint .icon {
  width: 13px;
  height: 13px;
}

.cal-window {
  color: var(--ink-3);
  font-size: 0.69rem;
  font-weight: 600;
  font-variant-numeric: tabular-nums;
}

/* ---------- Sidebar ---------- */

.sidebar {
  display: grid;
  gap: 14px;
  min-width: 0;
}

.panel {
  padding: 16px;
  border: 1px solid var(--line);
  border-radius: var(--radius-md);
  background: var(--surface);
  box-shadow: var(--shadow-sm);
}

.panel-summary {
  padding: 18px 20px;
  background: linear-gradient(180deg, var(--surface) 0%, var(--paper) 100%);
}

.panel-summary .fineprint {
  max-width: 78ch;
}

.panel-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 10px;
}

.panel-head h2 {
  font-size: 1.1rem;
  letter-spacing: -0.01em;
}

.panel-sub {
  margin-top: 2px;
  color: var(--ink-3);
  font-size: 0.71rem;
  line-height: 1.4;
}

.panel-actions {
  display: flex;
  gap: 6px;
  flex-wrap: wrap;
  margin-top: 11px;
}

.stepper {
  display: flex;
  gap: 1px;
}

.splitbar {
  position: relative;
  display: flex;
  gap: 3px;
  height: 13px;
  margin-top: 14px;
  border-radius: var(--radius-pill);
  background: var(--surface-2);
  overflow: hidden;
}

.splitbar::after {
  content: "";
  position: absolute;
  top: -2px;
  bottom: -2px;
  left: 50%;
  border-left: 1px dashed var(--ink-3);
  opacity: 0.7;
}

.splitbar .seg {
  height: 100%;
  transition: width 220ms var(--ease);
}

.splitbar .seg-a {
  background: var(--a);
}

.splitbar .seg-b {
  background: var(--b);
}

.splitrows {
  margin-top: 9px;
  display: grid;
  gap: 3px;
}

.splitrow {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 12px;
  font-size: 0.8rem;
  min-width: 0;
}

.splitrow-name {
  display: flex;
  align-items: center;
  gap: 7px;
  min-width: 0;
  overflow: hidden;
  font-weight: 600;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.splitrow-value {
  color: var(--ink-2);
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
}

.splitrow-value strong {
  color: var(--ink);
  font-weight: 700;
}

.statgrid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 8px;
  margin-top: 13px;
  padding-top: 12px;
  border-top: 1px solid var(--line);
}

.stat {
  display: grid;
  gap: 1px;
  min-width: 0;
}

.stat strong {
  font-family: var(--font-display);
  font-size: 1.28rem;
  font-weight: 600;
  font-variant-numeric: tabular-nums;
  line-height: 1.1;
}

.stat span {
  color: var(--ink-3);
  font-size: 0.61rem;
  font-weight: 650;
  letter-spacing: 0.045em;
  line-height: 1.3;
  text-transform: uppercase;
}

.panel-summary .fineprint {
  margin-top: 12px;
}

.panel > .field,
.panel > .field-row {
  margin-top: 12px;
}

.cycle-preview {
  display: flex;
  flex-wrap: wrap;
  gap: 2px;
  margin-top: 8px;
}

.cycle-preview span {
  width: 13px;
  height: 13px;
  border-radius: 3px;
  background: var(--a);
}

.cycle-preview span.owner-b {
  background: var(--b);
}

.cycle-editor {
  margin-top: 8px;
  padding: 10px;
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  background: var(--paper);
}

.cycle-editor[hidden] {
  display: none;
}

.cycle-editor-head {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 8px;
}

.cycle-chips {
  display: grid;
  grid-template-columns: repeat(14, minmax(0, 1fr));
  gap: 3px;
  margin-top: 9px;
}

.cycle-chip {
  display: flex;
  align-items: center;
  justify-content: center;
  aspect-ratio: 1;
  min-width: 0;
  padding: 0;
  border: 1px solid var(--line-strong);
  border-radius: 4px;
  background: var(--a-soft);
  color: var(--a-strong);
  font-size: 0.58rem;
  font-weight: 750;
  cursor: pointer;
}

.cycle-chip[data-owner="b"] {
  background: var(--b-soft);
  color: var(--b-strong);
}

.cycle-chip:hover {
  border-color: var(--ink-2);
}

.inline-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 4px;
  margin-top: 7px;
  margin-inline: -10px;
}

.backup-row {
  display: flex;
  flex-wrap: wrap;
  gap: 14px;
  margin-top: 14px;
  padding-top: 11px;
  border-top: 1px solid var(--line);
}

/* ---------- Rule lists ---------- */

.rule-list {
  list-style: none;
  margin: 4px 0 0;
  padding: 0;
}

.rule {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  align-items: center;
  gap: 8px;
  padding: 9px 0;
  border-top: 1px solid var(--line);
}

.rule-main {
  display: grid;
  gap: 1px;
  min-width: 0;
}

.rule-name {
  display: flex;
  align-items: center;
  gap: 5px;
  font-size: 0.81rem;
  font-weight: 650;
  line-height: 1.35;
}

.rule-name .icon {
  width: 12px;
  height: 12px;
  color: var(--gold);
  fill: currentColor;
  stroke-width: 1;
}

.rule-meta {
  color: var(--ink-3);
  font-size: 0.66rem;
  line-height: 1.45;
}

.rule-actions {
  display: flex;
  gap: 0;
  opacity: 0.55;
  transition: opacity 140ms var(--ease);
}

.rule:hover .rule-actions,
.rule:focus-within .rule-actions {
  opacity: 1;
}

.rule-actions .icon-btn {
  width: 26px;
  height: 26px;
}

.rule-actions .icon-btn .icon {
  width: 13px;
  height: 13px;
}

.rule-actions .is-danger:hover {
  color: var(--danger);
  background: var(--danger-soft);
}

.empty {
  margin-top: 8px;
  padding: 11px;
  border: 1px dashed var(--line-strong);
  border-radius: var(--radius-xs);
  color: var(--ink-3);
  font-size: 0.71rem;
  line-height: 1.5;
  text-align: center;
}

.empty[hidden] {
  display: none;
}

/* ---------- Export band ---------- */

.export-band {
  display: grid;
  grid-template-columns: minmax(0, 0.82fr) minmax(0, 1.18fr);
  gap: 32px;
  align-items: center;
  margin-block: 8px 44px;
  padding: 28px;
  border-radius: var(--radius-lg);
  background: var(--band-bg);
  color: var(--band-ink);
  box-shadow: var(--shadow-md);
}

.export-band .eyebrow {
  color: var(--band-muted);
}

.export-copy h2 {
  margin: 7px 0 7px;
  font-size: 1.72rem;
  color: var(--band-ink);
}

.export-copy p {
  max-width: 42ch;
  color: var(--band-muted);
  font-size: 0.82rem;
  line-height: 1.55;
}

.export-actions {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 7px;
}

.export-action {
  display: flex;
  align-items: center;
  gap: 9px;
  padding: 11px 12px;
  border: 1px solid var(--band-line);
  border-radius: var(--radius-sm);
  background: var(--band-fill);
  color: var(--band-ink);
  text-align: left;
  cursor: pointer;
  transition: background-color 140ms var(--ease), border-color 140ms var(--ease);
}

.export-action:hover {
  background: rgba(255, 255, 255, 0.12);
  border-color: rgba(255, 255, 255, 0.32);
}

.export-icon {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 32px;
  height: 32px;
  flex: none;
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.09);
  color: var(--band-ink);
}

.export-icon .icon {
  width: 16px;
  height: 16px;
}

.export-action > span:nth-child(2) {
  display: grid;
  gap: 1px;
  min-width: 0;
}

.export-action strong {
  font-size: 0.785rem;
  font-weight: 650;
  line-height: 1.3;
}

.export-action small {
  color: var(--band-muted);
  font-size: 0.66rem;
  line-height: 1.3;
}

.export-arrow {
  width: 14px;
  height: 14px;
  margin-left: auto;
  opacity: 0.45;
  flex: none;
}

/* ---------- Dialog extras ---------- */

.preset-list {
  display: grid;
  gap: 2px;
  max-height: 280px;
  overflow: auto;
  margin-top: 4px;
  padding-right: 4px;
}

.preset-option span {
  display: grid;
  gap: 1px;
}

.preset-option strong {
  color: var(--ink);
  font-size: 0.79rem;
  font-weight: 650;
}

.preset-option small {
  color: var(--ink-3);
  font-size: 0.68rem;
  line-height: 1.4;
}

body:has(dialog[open]) {
  overflow: hidden;
}

.export-list {
  display: grid;
  gap: 6px;
  margin-top: 12px;
}

.export-row {
  display: flex;
  align-items: center;
  gap: 9px;
  width: 100%;
  padding: 10px 12px;
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  background: var(--surface);
  color: var(--ink);
  text-align: left;
  cursor: pointer;
  transition: border-color 140ms var(--ease), background-color 140ms var(--ease);
}

.export-row:hover {
  border-color: var(--brand);
  background: var(--brand-soft);
}

.export-row .export-row-name {
  display: grid;
  gap: 1px;
  min-width: 0;
}

.export-row strong {
  font-size: 0.82rem;
  font-weight: 650;
}

.export-row small {
  color: var(--ink-3);
  font-size: 0.68rem;
}

.export-row .icon {
  width: 16px;
  height: 16px;
  margin-left: auto;
  color: var(--ink-2);
  flex: none;
}

.export-row.is-both {
  border-style: dashed;
}

.print-root {
  display: none;
}

/* ---------- Responsive ---------- */

@media (max-width: 1120px) {
  .workspace {
    grid-template-columns: minmax(0, 1fr) 352px;
  }

  .quickstart {
    padding: 14px;
  }
}

@media (max-width: 1020px) {
  .intro {
    grid-template-columns: 1fr;
    gap: 26px;
    padding-block: 32px 24px;
  }

  .intro-copy {
    max-width: 720px;
  }

  .quickstart {
    max-width: 620px;
  }

  .workspace {
    grid-template-columns: 1fr;
    gap: 16px;
  }

  .export-band {
    grid-template-columns: 1fr;
    gap: 20px;
  }

  .export-actions {
    grid-template-columns: 1fr 1fr;
  }
}

@media (max-width: 720px) {
  .intro {
    padding-block: 26px 20px;
  }

  .intro h1 {
    font-size: clamp(2.15rem, 10.5vw, 2.9rem);
    margin-top: 10px;
  }

  .lede {
    font-size: 0.93rem;
  }

  .quickstart-grid {
    grid-template-columns: 1fr 1fr;
  }

  .qs-chip {
    min-height: 40px;
    padding: 6px 8px;
  }

  .qs-chip span:first-child {
    font-size: 0.75rem;
  }

  .qs-chip small {
    font-size: 0.6rem;
  }

  .calendar-card {
    padding: 12px 10px 10px;
    border-radius: var(--radius-md);
  }

  .cal-month h2 {
    font-size: 1.14rem;
    padding-inline: 4px;
  }

  .cal-month .icon-btn {
    width: 32px;
    height: 32px;
  }

  .cal-month #cal-today {
    margin-left: 2px;
  }

  .cal td,
  .cal-day {
    height: 62px;
    min-height: 62px;
  }

  .main-col {
    gap: 12px;
  }

  .cal {
    border-spacing: 2px;
  }

  .cal-day {
    padding: 5px 4px 5px;
    border-radius: 7px;
  }

  .cal-daynum {
    font-size: 0.75rem;
  }

  .is-today .cal-daynum {
    min-width: 18px;
    height: 18px;
    padding-inline: 4px;
  }

  .cal-holiday {
    display: none;
  }

  .cal-flag {
    flex: 0 0 auto;
    justify-content: flex-end;
    margin-top: 0;
  }

  .cal-flag .icon {
    width: 10px;
    height: 10px;
  }

  .cal-monogram {
    min-width: 16px;
    height: 16px;
    padding-inline: 3px;
    border-radius: 5px;
    font-size: 0.55rem;
  }

  .cal-note-dot {
    width: 5px;
    height: 5px;
    margin-bottom: 4px;
  }

  .legend {
    font-size: 0.68rem;
    gap: 4px 10px;
  }

  .cal thead th {
    font-size: 0.58rem;
  }

  .cal-foot {
    flex-direction: column;
    align-items: flex-start;
    gap: 2px;
  }

  .panel {
    padding: 14px;
  }

  .statgrid {
    gap: 6px;
  }

  .stat strong {
    font-size: 1.12rem;
  }

  .cycle-chips {
    grid-template-columns: repeat(7, minmax(0, 1fr));
  }

  .export-band {
    margin-bottom: 26px;
    padding: 20px;
    border-radius: var(--radius-md);
  }

  .export-actions {
    grid-template-columns: 1fr;
  }

  .export-copy h2 {
    font-size: 1.42rem;
  }

  .dialog-head {
    padding: 16px 16px 0;
  }

  .dialog-body {
    padding: 14px 16px 6px;
  }

  .dialog-actions {
    padding: 12px 16px 16px;
  }

  .dialog-head h2 {
    font-size: 1.24rem;
  }

  .toast-region {
    bottom: 12px;
  }

  .dialog-actions {
    justify-content: flex-end;
  }

  .dialog-actions .spacer {
    display: none;
  }

  .dialog-actions .btn-danger {
    margin-right: auto;
  }
}

@media (max-width: 420px) {
  .cal-month h2 {
    min-width: 7.4ch;
    font-size: 1rem;
  }

  .cal-meta .pill-muted {
    display: none;
  }

  .quickstart-grid {
    grid-template-columns: 1fr;
  }

  .qs-chip {
    min-height: 36px;
  }
}

/* Keep calendar and summary cards intact in printed custody schedules. */
@media print {
  .month-card,
  .calendar-month,
  .summary-card {
    break-inside: avoid;
    page-break-inside: avoid;
    -webkit-print-color-adjust: exact;
    print-color-adjust: exact;
  }
}
