:root {
  color-scheme: light dark;
  --bg: #fbfaf6;
  --surface: #ffffff;
  --text: #1c2331;
  --muted: #5a6373;
  --border: #e5e0d5;
  --leave: #0f766e;
  --leave-text: #ffffff;
  --leave-soft: #d5f5ef;
  --holiday: #c2410c;
  --holiday-text: #ffffff;
  --weekend: #ece7dc;
  --weekend-text: #4c5463;
  --focus: #2563eb;
  --radius: 14px;
  --shadow: 0 1px 2px rgb(28 35 49 / 6%), 0 4px 16px rgb(28 35 49 / 5%);
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #10141b;
    --surface: #181e27;
    --text: #e8ebf0;
    --muted: #9ba4b3;
    --border: #2a323e;
    --leave: #2dd4bf;
    --leave-text: #062a26;
    --leave-soft: #123c38;
    --holiday: #fb923c;
    --holiday-text: #2b1204;
    --weekend: #262d38;
    --weekend-text: #b7bfcc;
    --focus: #60a5fa;
    --shadow: none;
  }
}

*,
*::before,
*::after {
  box-sizing: border-box;
}

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font: 16px/1.5 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  -webkit-text-size-adjust: 100%;
}

.site-header,
main,
.site-footer {
  max-width: 680px;
  margin: 0 auto;
  padding: 0 16px;
}

.site-header {
  padding-top: 24px;
}

.brand {
  margin: 0 0 8px;
  font-weight: 600;
  color: var(--leave);
}

h1 {
  margin: 0;
  font-size: clamp(1.6rem, 6vw, 2.2rem);
  line-height: 1.15;
  letter-spacing: -0.01em;
}

h2 {
  margin: 32px 0 8px;
  font-size: 1.25rem;
}

h3 {
  margin: 0;
  font-size: 1rem;
  line-height: 1.35;
}

.intro,
.section-hint,
.field-hint,
.hero-meta,
.note {
  color: var(--muted);
}

.intro {
  margin: 8px 0 20px;
}

a {
  color: var(--leave);
}

:focus-visible {
  outline: 3px solid var(--focus);
  outline-offset: 2px;
}

/* Form */
.controls {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
  padding: 16px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
}

.field {
  display: grid;
  gap: 4px;
  min-width: 0;
  font-size: 0.875rem;
  font-weight: 600;
}

.field-hint {
  grid-column: 1 / -1;
  margin: -4px 0 0;
  font-size: 0.8125rem;
}

select,
input,
button {
  font: inherit;
  color: inherit;
}

select,
.stepper {
  width: 100%;
  min-height: 44px;
  border: 1px solid var(--border);
  border-radius: 10px;
  background: var(--bg);
}

select {
  padding: 0 10px;
  font-weight: 400;
}

.stepper {
  display: flex;
  overflow: hidden;
}

.stepper input {
  flex: 1;
  min-width: 0;
  width: 100%;
  border: 0;
  background: transparent;
  text-align: center;
  font-size: 1.125rem;
  font-weight: 700;
  appearance: textfield;
  -moz-appearance: textfield;
}

.stepper input::-webkit-inner-spin-button,
.stepper input::-webkit-outer-spin-button {
  appearance: none;
  margin: 0;
}

.stepper button {
  width: 44px;
  border: 0;
  background: transparent;
  font-size: 1.25rem;
  cursor: pointer;
}

.stepper button:hover {
  background: var(--leave-soft);
}

/* Result */
.hero {
  margin-top: 20px;
  padding: 20px 16px;
  border-radius: var(--radius);
  background: var(--leave-soft);
  text-align: center;
}

.headline {
  margin: 0;
  font-size: clamp(1.35rem, 5.5vw, 1.85rem);
  line-height: 1.25;
  font-weight: 700;
}

.headline strong {
  color: var(--leave);
}

.hero-meta {
  margin: 8px 0 16px;
  font-size: 0.9375rem;
}

.share {
  min-height: 44px;
  padding: 0 20px;
  border: 0;
  border-radius: 999px;
  background: var(--leave);
  color: var(--leave-text);
  font-weight: 700;
  cursor: pointer;
}

.share-status {
  min-height: 1.5em;
  margin: 8px 0 0;
  font-size: 0.875rem;
  overflow-wrap: anywhere;
}

.note {
  font-size: 0.875rem;
}

.legend {
  display: flex;
  flex-wrap: wrap;
  gap: 8px 16px;
  margin: 0 0 12px;
  padding: 0;
  list-style: none;
  font-size: 0.875rem;
  color: var(--muted);
}

.legend li {
  display: flex;
  align-items: center;
  gap: 6px;
}

.swatch {
  width: 14px;
  height: 14px;
  border-radius: 4px;
}

.periods,
.bridges {
  margin: 0;
  padding: 0;
  list-style: none;
  display: grid;
  gap: 12px;
}

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

.period-head {
  display: flex;
  gap: 12px;
  margin-bottom: 12px;
}

.period-index {
  flex: none;
  display: grid;
  place-items: center;
  width: 28px;
  height: 28px;
  border-radius: 50%;
  background: var(--leave);
  color: var(--leave-text);
  font-weight: 700;
  font-size: 0.875rem;
}

.period-gain {
  margin: 4px 0 0;
}

.tag {
  display: inline-block;
  padding: 0 8px;
  border-radius: 999px;
  font-size: 0.875rem;
  font-weight: 600;
}

.tag.leave {
  background: var(--leave-soft);
  color: var(--leave);
}

.period-take,
.period-holidays {
  margin: 12px 0 0;
  font-size: 0.875rem;
}

.period-holidays {
  color: var(--muted);
}

/* Calendar */
.cal {
  display: grid;
  grid-template-columns: repeat(7, 1fr);
  gap: 4px;
  max-width: 420px;
}

.cal-head {
  text-align: center;
  font-size: 0.75rem;
  font-weight: 600;
  color: var(--muted);
}

.cal-day {
  display: grid;
  place-content: center;
  aspect-ratio: 1;
  border-radius: 8px;
  font-size: 0.875rem;
  font-weight: 600;
  line-height: 1.1;
  text-align: center;
}

.cal-day small {
  display: block;
  font-size: 0.625rem;
  font-weight: 500;
}

.cal-day.out {
  background: transparent;
}

.leave {
  background: var(--leave);
  color: var(--leave-text);
}

.holiday {
  background: var(--holiday);
  color: var(--holiday-text);
}

.weekend {
  background: var(--weekend);
  color: var(--weekend-text);
}

/* Bridges */
.bridges li {
  display: grid;
  gap: 2px;
  padding: 12px 16px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-left: 4px solid var(--holiday);
  border-radius: 10px;
}

.bridge-dates {
  font-weight: 600;
}

.bridge-holidays {
  font-size: 0.875rem;
  color: var(--muted);
}

/* About and footer */
.about {
  margin-top: 16px;
  font-size: 0.9375rem;
}

.site-footer {
  padding-top: 8px;
  padding-bottom: 32px;
  font-size: 0.875rem;
  color: var(--muted);
}

@media (min-width: 560px) {
  .controls {
    grid-template-columns: repeat(4, 1fr);
  }

  .bridges li {
    grid-template-columns: 1fr auto;
    align-items: baseline;
  }

  .bridge-holidays {
    grid-column: 1 / -1;
  }
}
