@font-face {
  font-family: "Manrope";
  src: url("fonts/manrope-400.woff2") format("woff2");
  font-weight: 400;
  font-style: normal;
  font-display: swap;
}

@font-face {
  font-family: "Manrope";
  src: url("fonts/manrope-500.woff2") format("woff2");
  font-weight: 500;
  font-style: normal;
  font-display: swap;
}

@font-face {
  font-family: "Manrope";
  src: url("fonts/manrope-600.woff2") format("woff2");
  font-weight: 600;
  font-style: normal;
  font-display: swap;
}

@font-face {
  font-family: "Geist Mono";
  src: url("fonts/geist-mono-400.woff2") format("woff2");
  font-weight: 400;
  font-style: normal;
  font-display: swap;
}

@font-face {
  font-family: "Geist Mono";
  src: url("fonts/geist-mono-500.woff2") format("woff2");
  font-weight: 500;
  font-style: normal;
  font-display: swap;
}

:root {
  color-scheme: dark;

  --bg: #000000;
  --surface: #181818;
  --surface-2: #1f1f1f;
  --surface-3: #272727;
  --border: #313131;
  --fg: #f4f4f0;
  --muted: #9b9b94;

  --accent: #e8b04a;
  --accent-strong: #f2c266;
  --accent-soft: #2a2113;
  --accent-ink: #000000;
  --danger: #ff7a7a;

  --font-sans: "Manrope", "Noto Sans HK", "Microsoft JhengHei", "PingFang HK", sans-serif;
  --font-mono: "Geist Mono", "SFMono-Regular", Consolas, "Liberation Mono", monospace;
  --ease: cubic-bezier(0.22, 1, 0.36, 1);
}

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

[hidden] {
  display: none !important;
}

html {
  -webkit-text-size-adjust: 100%;
}

body {
  margin: 0;
  min-height: 100dvh;
  background: var(--bg);
  color: var(--fg);
  font: 400 14px/20px var(--font-sans);
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}

body::before {
  content: "";
  position: fixed;
  inset: 0;
  z-index: 0;
  pointer-events: none;
  opacity: 0.035;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='140' height='140'%3E%3Cfilter id='noise'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='.82' numOctaves='2' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='140' height='140' filter='url(%23noise)' opacity='.5'/%3E%3C/svg%3E");
}

.app {
  position: relative;
  z-index: 1;
  width: min(100%, 1400px);
  margin: 0 auto;
  padding: 24px 32px 48px;
}

h1,
h2,
h3,
h4,
p {
  text-wrap: pretty;
}

h1,
h2,
h3,
h4 {
  text-wrap: balance;
}

h1,
h2,
h3,
h4 {
  font-weight: 600;
  letter-spacing: -0.01em;
}

button,
input,
select {
  font: inherit;
}

a {
  color: var(--accent);
  text-underline-offset: 3px;
}

::selection {
  background: var(--accent);
  color: var(--accent-ink);
}

/* ---------- header ---------- */

.topbar {
  display: grid;
  grid-template-columns: auto minmax(0, 1fr);
  align-items: start;
  gap: 24px 32px;
  padding-bottom: 24px;
  border-bottom: 1px solid var(--border);
  margin-bottom: 24px;
}

.brand {
  display: flex;
  align-items: center;
  gap: 12px;
  min-width: 0;
}

.mark {
  width: 44px;
  height: 44px;
  flex: 0 0 auto;
  display: block;
  border-radius: 0;
}

.mark svg {
  display: block;
  width: 100%;
  height: 100%;
}

.brand-text {
  min-width: 0;
}

.brand h1 {
  margin: 0;
  font: 600 20px/28px var(--font-sans);
  letter-spacing: -0.025em;
}

.brand p {
  margin: 4px 0 0;
  color: var(--muted);
  font: 400 12px/16px var(--font-mono);
}

.controls {
  display: flex;
  align-items: flex-end;
  justify-content: flex-end;
  gap: 16px;
  flex-wrap: wrap;
  min-width: 0;
}

.control {
  display: flex;
  flex-direction: column;
  gap: 8px;
  min-width: 0;
}

.control-label {
  color: var(--muted);
  font: 500 12px/16px var(--font-sans);
}

select {
  min-height: 38px;
  padding: 8px 32px 8px 12px;
  border: 1px solid var(--border);
  border-radius: 2px;
  background-color: var(--surface);
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='8' viewBox='0 0 12 8'%3E%3Cpath d='M1 1l5 5 5-5' fill='none' stroke='%23e8b04a' stroke-width='1.5'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 12px center;
  background-size: 12px 8px;
  color: var(--fg);
  font: 500 14px/20px var(--font-sans);
  cursor: pointer;
  appearance: none;
}

select option {
  background: var(--surface);
  color: var(--fg);
  font: 500 14px/20px var(--font-sans);
}

select:focus-visible,
input:focus-visible,
button:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

.seg {
  display: inline-flex;
  border: 1px solid var(--border);
  border-radius: 2px;
  overflow: hidden;
  background: transparent;
}

.seg button {
  appearance: none;
  padding: 8px 12px;
  border: 0;
  border-radius: 0;
  background: transparent;
  color: var(--muted);
  font: 500 14px/20px var(--font-sans);
  cursor: pointer;
  white-space: nowrap;
  transition:
    background 300ms var(--ease),
    color 300ms var(--ease);
}

.seg button + button {
  border-left: 1px solid var(--border);
}

.seg button:hover {
  background: var(--surface-2);
  color: var(--fg);
}

.seg button.on {
  background: var(--surface-3);
  color: var(--fg);
}

.count {
  margin-left: 4px;
  color: var(--accent);
  font: 500 12px/16px var(--font-mono);
}

.lang-select {
  min-width: 170px;
}

.help-btn {
  align-self: flex-end;
  display: inline-flex;
  align-items: center;
  gap: 8px;
  min-height: 38px;
  padding: 8px 12px;
  border: 1px solid var(--border);
  border-radius: 2px;
  background: transparent;
  color: var(--muted);
  font: 500 14px/20px var(--font-sans);
  cursor: pointer;
  white-space: nowrap;
  transition:
    color 300ms var(--ease),
    border-color 300ms var(--ease);
}

.help-btn:hover {
  color: var(--fg);
  border-color: var(--accent);
}

.help-label {
  display: none;
}

.help-q {
  width: 16px;
  height: 16px;
  display: grid;
  place-items: center;
  border: 1px solid var(--accent);
  color: var(--accent);
  font: 500 12px/16px var(--font-mono);
}

/* ---------- stats ---------- */

.stats {
  display: grid;
  grid-template-columns: 1.2fr 0.8fr 0.8fr 1fr 1fr;
  border-top: 1px solid var(--border);
  border-bottom: 1px solid var(--border);
  margin-bottom: 24px;
}

.stat {
  min-width: 0;
  padding: 16px 24px;
  border-left: 1px solid var(--border);
}

.stat:first-child {
  border-left: 0;
  padding-left: 0;
}

.stat-label {
  display: block;
  margin-bottom: 4px;
  color: var(--muted);
  font: 500 12px/16px var(--font-sans);
}

.stat-value {
  color: var(--fg);
  font: 500 24px/32px var(--font-mono);
  letter-spacing: -0.03em;
  font-variant-numeric: tabular-nums;
}

#used {
  color: var(--fg);
}

#remaining {
  color: var(--accent);
}

#remaining.negative,
.stat-value.negative {
  color: var(--danger);
}

#remaining.zero,
.stat-value.zero {
  color: var(--muted);
}

.stat-sub {
  margin-top: 4px;
  color: var(--muted);
  font: 400 12px/16px var(--font-mono);
  overflow-wrap: anywhere;
}

.balance-wrap {
  display: flex;
  align-items: baseline;
  gap: 8px;
}

.balance-wrap input {
  width: 64px;
  padding: 0 0 2px;
  border: 0;
  border-bottom: 2px solid var(--accent);
  border-radius: 0;
  background: transparent;
  color: var(--accent);
  font: 500 24px/32px var(--font-mono);
  font-variant-numeric: tabular-nums;
  appearance: textfield;
  -moz-appearance: textfield;
}

.balance-wrap input:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 4px;
}

.balance-wrap span {
  color: var(--muted);
  font: 400 12px/16px var(--font-mono);
}

/* ---------- view bar ---------- */

.view-bar {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 16px;
  flex-wrap: wrap;
  border-bottom: 1px solid var(--border);
  margin-bottom: 24px;
}

.view-tabs {
  display: flex;
  gap: 24px;
}

.view-tabs button {
  position: relative;
  appearance: none;
  padding: 0 0 12px;
  border: 0;
  border-radius: 0;
  background: transparent;
  color: var(--muted);
  font: 600 14px/20px var(--font-sans);
  cursor: pointer;
  transition: color 300ms var(--ease);
}

.view-tabs button:hover {
  color: var(--fg);
}

.view-tabs button[aria-selected="true"] {
  color: var(--fg);
}

.view-tabs button[aria-selected="true"]::after {
  content: "";
  position: absolute;
  left: 0;
  right: 0;
  bottom: -1px;
  height: 2px;
  background: var(--accent);
}

.clear-bookings {
  padding: 0 0 12px;
  border: 0;
  border-radius: 0;
  background: transparent;
  color: var(--muted);
  font: 500 12px/16px var(--font-mono);
}

.clear-bookings:not(:disabled) {
  color: var(--accent);
}

.clear-bookings:not(:disabled):hover {
  background: transparent;
  color: var(--accent-strong);
}

.clear-bookings:disabled {
  opacity: 0.45;
  cursor: not-allowed;
}

.view {
  min-width: 0;
}

/* ---------- panels ---------- */

.card {
  min-width: 0;
  padding: 24px;
  border: 1px solid var(--border);
  border-radius: 0;
  background: var(--surface);
  box-shadow: none;
}

.card-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 16px;
}

.card h2 {
  margin: 0;
  font: 600 16px/24px var(--font-sans);
  letter-spacing: -0.01em;
}

.card-sub {
  margin: 4px 0 0;
  color: var(--muted);
  font: 400 12px/16px var(--font-mono);
}

.filter-card {
  padding: 0;
  border: 0;
  border-radius: 0;
  background: transparent;
  margin-bottom: 24px;
}

.filter-card h2 {
  font: 600 20px/28px var(--font-sans);
}

.filter-row {
  display: flex;
  flex-wrap: wrap;
  align-items: flex-end;
  gap: 16px;
}

.filter-field {
  display: flex;
  flex-direction: column;
  gap: 8px;
  color: var(--muted);
  font: 500 12px/16px var(--font-sans);
}

.filter-field select {
  min-width: 160px;
}

.filter-field input {
  width: 96px;
  min-width: 0;
  padding: 8px 12px;
  border: 1px solid var(--border);
  border-radius: 2px;
  background: var(--surface);
  color: var(--fg);
  font: 500 14px/20px var(--font-mono);
  font-variant-numeric: tabular-nums;
}

.planner-body {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 360px;
  gap: 24px;
  align-items: start;
}

.combo-card {
  position: sticky;
  top: 24px;
  max-height: calc(100vh - 48px);
  overflow-y: auto;
  overflow-x: hidden;
  scrollbar-width: thin;
}

/* ---------- buttons ---------- */

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 8px 12px;
  border: 1px solid var(--border);
  border-radius: 2px;
  background: transparent;
  color: var(--fg);
  font: 600 14px/20px var(--font-sans);
  cursor: pointer;
  white-space: nowrap;
  transition:
    background 300ms var(--ease),
    border-color 300ms var(--ease),
    color 300ms var(--ease),
    transform 300ms var(--ease);
}

.btn:hover {
  background: var(--surface-2);
  border-color: var(--muted);
}

.btn:active {
  transform: translateY(1px);
}

.btn:disabled {
  opacity: 0.45;
  cursor: not-allowed;
}

.btn.ghost {
  border-color: var(--border);
  background: transparent;
}

.btn.primary {
  border-color: var(--accent);
  background: var(--accent);
  color: var(--accent-ink);
}

.btn.primary:hover {
  border-color: var(--accent-strong);
  background: var(--accent-strong);
}

.btn.small {
  min-height: 28px;
  padding: 4px 8px;
  font: 600 12px/16px var(--font-sans);
}

.btn.wide {
  width: 100%;
}

/* ---------- explorer ---------- */

.explorer-actions {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  flex-shrink: 0;
  gap: 16px;
  flex-wrap: nowrap;
}

.pill {
  padding: 4px 8px;
  border: 1px solid var(--border);
  border-radius: 0;
  color: var(--accent);
  font: 500 12px/16px var(--font-mono);
  white-space: nowrap;
}

.break-section {
  margin-top: 24px;
  padding-top: 24px;
  border-top: 1px solid var(--border);
}

.break-section:first-child {
  margin-top: 0;
  padding-top: 0;
  border-top: 0;
}

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

.break-section-title {
  margin: 0;
  color: var(--fg);
  font: 600 14px/20px var(--font-sans);
}

.break-section-actions {
  display: flex;
  align-items: baseline;
  gap: 12px;
  color: var(--muted);
  font: 400 12px/16px var(--font-mono);
  white-space: nowrap;
}

.break-expand {
  appearance: none;
  padding: 0;
  border: 0;
  border-radius: 0;
  background: transparent;
  color: var(--accent);
  font: 500 12px/16px var(--font-mono);
  text-decoration: underline;
  text-underline-offset: 3px;
  cursor: pointer;
}

.break-expand:hover {
  color: var(--accent-strong);
}

.break-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(210px, 1fr));
  gap: 8px;
}

.break-item {
  display: flex;
  flex-direction: column;
  gap: 4px;
  padding: 12px;
  border: 1px solid var(--border);
  border-radius: 0;
  background: var(--bg);
  color: var(--fg);
  text-align: left;
  cursor: pointer;
  transition:
    background 300ms var(--ease),
    border-color 300ms var(--ease);
}

.break-item:hover {
  border-color: var(--accent);
  background: var(--surface-2);
}

.break-item.selected {
  border-color: var(--accent);
  background: var(--surface-3);
}

.break-top {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 8px;
}

.break-cost {
  color: var(--muted);
  font: 400 12px/16px var(--font-mono);
}

.break-length {
  color: var(--accent);
  font: 500 12px/16px var(--font-mono);
}

.break-dates {
  color: var(--fg);
  font: 500 14px/20px var(--font-mono);
  overflow-wrap: anywhere;
}

.break-meta {
  color: var(--muted);
  font: 400 12px/16px var(--font-mono);
}

.empty {
  margin: 0;
  padding: 24px 0;
  color: var(--muted);
  font: 400 14px/20px var(--font-sans);
  max-width: 62ch;
}

/* ---------- optimal plan controls ---------- */

.plan-budget {
  padding: 0;
}

.plan-budget-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 12px;
}

.plan-budget-label {
  color: var(--fg);
  font: 400 14px/20px var(--font-sans);
}

.plan-budget-label strong,
#planBudgetMax {
  color: var(--accent);
  font-family: var(--font-mono);
  font-weight: 500;
}

#planBudget {
  width: 100%;
  margin: 8px 0 16px;
  accent-color: var(--accent);
}

#planBudget:disabled {
  opacity: 0.4;
}

.budget-presets {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-bottom: 16px;
}

.budget-presets button {
  appearance: none;
  padding: 4px 8px;
  border: 1px solid var(--border);
  border-radius: 0;
  background: transparent;
  color: var(--muted);
  font: 500 12px/16px var(--font-mono);
  cursor: pointer;
  transition:
    background 300ms var(--ease),
    border-color 300ms var(--ease),
    color 300ms var(--ease);
}

.budget-presets button:hover {
  border-color: var(--accent);
  color: var(--fg);
}

.budget-presets button.on {
  border-color: var(--accent);
  background: var(--accent-soft);
  color: var(--accent);
}

.plan-summary {
  margin: 0;
  color: var(--muted);
  font: 400 12px/16px var(--font-mono);
}

.plan-budget-head .btn:disabled {
  opacity: 0.4;
  cursor: not-allowed;
}

/* ---------- selected / optimal result ---------- */

.combo-badge {
  display: inline-flex;
  align-items: center;
  padding: 4px 8px;
  border: 1px solid var(--accent);
  border-radius: 0;
  color: var(--accent);
  font: 500 12px/16px var(--font-mono);
  white-space: nowrap;
}

.opt-total {
  display: flex;
  align-items: baseline;
  gap: 8px;
  margin: 16px 0 8px;
}

.opt-number {
  color: var(--accent);
  font: 500 36px/40px var(--font-mono);
  letter-spacing: -0.04em;
  font-variant-numeric: tabular-nums;
}

.opt-label {
  color: var(--muted);
  font: 400 12px/16px var(--font-mono);
}

.opt-sub {
  margin: 0 0 16px;
  color: var(--muted);
  font: 400 14px/24px var(--font-sans);
  max-width: 60ch;
}

.plan-list {
  list-style: none;
  margin: 16px 0 24px;
  padding: 0;
  border-top: 1px solid var(--border);
}

.plan-list li {
  padding: 12px 0;
  border-bottom: 1px solid var(--border);
}

.plan-when {
  color: var(--fg);
  font: 500 14px/20px var(--font-mono);
}

.plan-meta {
  margin-top: 4px;
  color: var(--muted);
  font: 400 12px/16px var(--font-mono);
}

.plan-dates {
  display: block;
  margin-top: 4px;
  color: var(--accent);
  font: 400 12px/16px var(--font-mono);
  overflow-wrap: anywhere;
}

/* ---------- year map ---------- */

.year-map-wrap {
  margin: 16px 0;
}

.year-map {
  display: block;
  width: 100%;
  height: 40px;
}

.ym-bg {
  fill: var(--surface-3);
}

.ym-tick {
  stroke: var(--border);
  stroke-width: 1;
}

.ym-holiday {
  fill: var(--accent);
}

.ym-bar {
  fill: var(--fg);
}

.year-map-labels {
  display: flex;
  justify-content: space-between;
  margin-top: 4px;
  color: var(--muted);
  font: 400 12px/16px var(--font-mono);
}

.year-map-caption {
  margin: 8px 0 0;
  color: var(--muted);
  font: 400 12px/16px var(--font-mono);
}

/* ---------- calendar ---------- */

.calendar-layout {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 320px;
  gap: 24px;
  align-items: start;
}

.calendar-side {
  position: sticky;
  top: 24px;
  display: flex;
  flex-direction: column;
  gap: 24px;
  max-height: calc(100vh - 48px);
  overflow-y: auto;
  scrollbar-width: thin;
}

.months {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 12px;
}

.month {
  min-width: 0;
  padding: 16px;
  border: 1px solid var(--border);
  border-radius: 0;
  background: var(--surface);
}

.month-head {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 8px;
  min-height: 20px;
  margin-bottom: 12px;
}

.month-head h3 {
  margin: 0;
  font: 600 14px/20px var(--font-sans);
  letter-spacing: 0;
}

.month-badge {
  color: var(--accent);
  font: 400 12px/16px var(--font-mono);
  white-space: nowrap;
}

.month-grid {
  display: grid;
  grid-template-columns: repeat(7, minmax(0, 1fr));
  gap: 2px;
}

.dow {
  padding-bottom: 4px;
  color: var(--muted);
  font: 500 12px/16px var(--font-mono);
  text-align: center;
  user-select: none;
}

.day {
  appearance: none;
  aspect-ratio: 1;
  min-height: 28px;
  display: grid;
  place-items: center;
  padding: 0;
  border: 1px solid transparent;
  border-radius: 0;
  background: transparent;
  color: var(--fg);
  font: 400 12px/16px var(--font-mono);
  cursor: pointer;
  transition:
    background 300ms var(--ease),
    border-color 300ms var(--ease),
    color 300ms var(--ease);
}

.day.empty {
  visibility: hidden;
}

.day.weekend {
  background: var(--surface-2);
  color: var(--muted);
}

.day.holiday {
  background: var(--accent);
  color: var(--accent-ink);
  font-weight: 500;
}

.day.booked {
  background: var(--fg);
  color: var(--accent-ink);
  font-weight: 500;
}

.day.makeup:not(.booked) {
  border: 1px dashed var(--muted);
  color: var(--muted);
}

.day.today {
  outline: 1px solid var(--fg);
  outline-offset: -1px;
}

.day:not(:disabled):hover {
  border-color: var(--accent);
  background: var(--surface-3);
  color: var(--fg);
}

.day.booked:not(:disabled):hover {
  background: var(--fg);
  color: var(--accent-ink);
  filter: brightness(0.9);
}

.day:disabled {
  cursor: default;
}

.day:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 1px;
}

.legend {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px 16px;
  margin-top: 16px;
  color: var(--muted);
  font: 400 12px/16px var(--font-mono);
}

.key {
  display: inline-flex;
  align-items: center;
  gap: 8px;
}

.sw {
  width: 10px;
  height: 10px;
  display: inline-block;
  border: 1px solid var(--border);
  border-radius: 0;
  background: transparent;
}

.sw.weekend {
  background: var(--surface-2);
}

.sw.holiday {
  border-color: var(--accent);
  background: var(--accent);
}

.sw.makeup {
  border: 1px dashed var(--muted);
}

.sw.booked {
  border-color: var(--fg);
  background: var(--fg);
}

.sw.today {
  outline: 1px solid var(--fg);
  outline-offset: -1px;
}

.hint {
  margin-left: auto;
}

.tip-text {
  margin: 0 0 16px;
  color: var(--muted);
  font: 400 14px/20px var(--font-sans);
}

/* ---------- booked leave ---------- */

.booked-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 12px 0;
  border-bottom: 1px solid var(--border);
}

.booked-item:last-child {
  border-bottom: 0;
  padding-bottom: 0;
}

.booked-main {
  min-width: 0;
}

.booked-when {
  color: var(--fg);
  font: 500 14px/20px var(--font-mono);
}

.booked-meta {
  margin-top: 4px;
  color: var(--muted);
  font: 400 12px/16px var(--font-mono);
  overflow-wrap: anywhere;
}

.card-actions {
  display: flex;
  justify-content: flex-end;
  margin-top: 16px;
}

/* ---------- notes ---------- */

.notes-wrap {
  margin-top: 32px;
  padding-top: 24px;
  border-top: 1px solid var(--border);
}

.notes {
  padding: 0;
  border: 0;
  border-radius: 0;
  background: transparent;
}

.notes h2 {
  margin: 0 0 8px;
  font: 600 20px/28px var(--font-sans);
}

.region-notes p {
  margin: 0 0 8px;
}

.notes details {
  padding: 12px 0;
  border-top: 1px solid var(--border);
}

.notes summary {
  color: var(--fg);
  font: 600 14px/20px var(--font-sans);
  cursor: pointer;
}

.notes p {
  margin: 8px 0 0;
  color: var(--muted);
  font: 400 14px/24px var(--font-sans);
  max-width: 70ch;
}

.notes p strong {
  color: var(--fg);
  font-weight: 600;
}

.notes .fine {
  color: var(--muted);
  font: 400 12px/16px var(--font-mono);
}

.inline {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-top: 12px;
  color: var(--muted);
  font: 400 14px/20px var(--font-sans);
}

.inline select {
  margin-left: 4px;
}

.notes a {
  color: var(--accent);
}

/* ---------- footer + toast ---------- */

.footer {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 8px 16px;
  flex-wrap: wrap;
  margin-top: 32px;
  padding-top: 16px;
  border-top: 1px solid var(--border);
  color: var(--muted);
  font: 400 12px/16px var(--font-mono);
}

.footer-meta {
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.footer-links {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 6px 16px;
}

.footer-link {
  text-underline-offset: 3px;
}

.footer-link:hover,
.footer-link:focus-visible {
  color: var(--fg);
}

.footer-link-kofi {
  font-weight: 500;
}

.toast {
  position: fixed;
  left: 50%;
  bottom: 24px;
  z-index: 150;
  padding: 12px 16px;
  border: 1px solid var(--accent);
  border-radius: 0;
  background: var(--surface);
  color: var(--fg);
  font: 500 12px/16px var(--font-mono);
  opacity: 0;
  pointer-events: none;
  transform: translate(-50%, 16px);
  transition:
    opacity 300ms var(--ease),
    transform 300ms var(--ease);
}

.toast.show {
  opacity: 1;
  transform: translate(-50%, 0);
}

/* ---------- onboarding ---------- */

.onboarding {
  position: fixed;
  inset: 0;
  z-index: 200;
  display: grid;
  place-items: center;
  padding: 24px;
  overflow-y: auto;
}

.onboarding-backdrop {
  position: absolute;
  inset: 0;
  background: rgba(0, 0, 0, 0.82);
}

.onboarding-card {
  position: relative;
  width: min(560px, 100%);
  max-height: min(92vh, 760px);
  overflow-y: auto;
  border: 1px solid var(--border);
  border-radius: 0;
  background: var(--surface);
  animation: onboarding-in 500ms var(--ease);
}

@keyframes onboarding-in {
  from {
    opacity: 0;
    transform: translateY(12px);
  }
  to {
    opacity: 1;
    transform: none;
  }
}

.onboarding-hero {
  padding: 24px;
  border-top: 3px solid var(--accent);
  border-bottom: 1px solid var(--border);
  background: var(--bg);
}

.onboarding-kicker {
  color: var(--accent);
  font: 500 12px/16px var(--font-mono);
}

.onboarding-hero h2 {
  margin: 8px 0;
  color: var(--fg);
  font: 600 24px/32px var(--font-sans);
  letter-spacing: -0.025em;
}

.onboarding-hero p {
  margin: 0;
  max-width: 42ch;
  color: var(--muted);
  font: 400 14px/20px var(--font-sans);
}

.onboarding-body {
  padding: 24px 24px 8px;
}

.steps {
  display: flex;
  gap: 8px;
  margin-bottom: 24px;
}

.steps .dot {
  width: 32px;
  height: 2px;
  background: var(--border);
}

.steps .dot.on {
  background: var(--accent);
}

.onboard-step h3 {
  margin: 0 0 16px;
  font: 600 16px/24px var(--font-sans);
}

.onboard-step:focus {
  outline: none;
}

.onboard-balance {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 12px;
}

.onboard-balance button {
  width: 40px;
  height: 40px;
  display: grid;
  place-items: center;
  padding: 0;
  border: 1px solid var(--border);
  border-radius: 2px;
  background: transparent;
  color: var(--fg);
  font: 500 16px/24px var(--font-mono);
  cursor: pointer;
}

.onboard-balance button:hover {
  border-color: var(--accent);
  color: var(--accent);
}

.onboard-balance input {
  width: 88px;
  padding: 0;
  border: 0;
  border-bottom: 2px solid var(--accent);
  border-radius: 0;
  background: transparent;
  color: var(--accent);
  font: 500 30px/36px var(--font-mono);
  text-align: center;
  font-variant-numeric: tabular-nums;
  appearance: textfield;
  -moz-appearance: textfield;
}

.onboard-balance span {
  color: var(--muted);
  font: 400 12px/16px var(--font-mono);
}

.chips {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-bottom: 16px;
}

.chips button {
  appearance: none;
  padding: 4px 8px;
  border: 1px solid var(--border);
  border-radius: 2px;
  background: transparent;
  color: var(--muted);
  font: 500 12px/16px var(--font-mono);
  cursor: pointer;
}

.chips button:hover {
  border-color: var(--accent);
  color: var(--fg);
}

.chips button.on {
  border-color: var(--accent);
  background: var(--accent);
  color: var(--accent-ink);
}

.onboard-hint {
  margin: 8px 0 16px;
  color: var(--muted);
  font: 400 12px/16px var(--font-mono);
  max-width: 62ch;
}

.onboard-hint-tight {
  margin-bottom: 0;
}

.onboard-field {
  margin: 0 0 16px;
  padding: 0;
  border: 0;
}

.onboard-field legend {
  margin-bottom: 8px;
  padding: 0;
  color: var(--muted);
  font: 500 12px/16px var(--font-sans);
}

.onboard-field select {
  width: 100%;
}

.onboard-step .seg {
  width: 100%;
}

.onboard-step .seg button {
  flex: 1;
  text-align: center;
}

.tour-title {
  margin: 24px 0 8px;
  font: 600 16px/24px var(--font-sans);
}

.tour {
  list-style: none;
  margin: 0;
  padding: 0;
  border-top: 1px solid var(--border);
}

.tour li {
  display: grid;
  grid-template-columns: 24px 1fr;
  gap: 12px;
  padding: 12px 0;
  border-bottom: 1px solid var(--border);
}

.tour-num {
  color: var(--accent);
  font: 500 12px/16px var(--font-mono);
}

.tour strong {
  display: block;
  font: 600 14px/20px var(--font-sans);
}

.tour p {
  margin: 4px 0 0;
  color: var(--muted);
  font: 400 12px/16px var(--font-mono);
}

.onboarding-actions {
  position: sticky;
  bottom: 0;
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 16px 24px 24px;
  border-top: 1px solid var(--border);
  background: var(--surface);
}

.onboarding-actions .spacer {
  flex: 1;
}

.onboard-lang-select {
  flex: 0 0 auto;
  min-width: 160px;
}

/* ---------- utility ---------- */

.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

/* ---------- responsive ---------- */

@media (max-width: 1080px) {
  .planner-body {
    display: flex;
    flex-direction: column;
    align-items: stretch;
  }

  .combo-card {
    position: relative;
    top: auto;
    max-height: none;
    overflow: visible;
  }

  .calendar-layout {
    grid-template-columns: 1fr;
  }

  .calendar-side {
    position: static;
    max-height: none;
    overflow: visible;
  }

  .stats {
    grid-template-columns: repeat(3, minmax(0, 1fr));
  }

  .stat {
    border-top: 1px solid var(--border);
  }

  .stat:first-child {
    border-top: 0;
    border-left: 0;
    padding-left: 0;
  }

  .stat:nth-child(2),
  .stat:nth-child(3) {
    border-top: 0;
  }

  .stat:nth-child(2) {
    border-left: 1px solid var(--border);
  }

  .stat:nth-child(4) {
    border-left: 0;
  }

  .stat:nth-child(5) {
    grid-column: span 2;
    border-left: 1px solid var(--border);
  }
}

@media (max-width: 860px) {
  .months {
    grid-template-columns: repeat(3, minmax(0, 1fr));
  }
}

@media (max-width: 640px) {
  .app {
    padding: 16px 16px 32px;
  }

  .topbar {
    grid-template-columns: 1fr;
    gap: 16px;
    padding-bottom: 16px;
    margin-bottom: 16px;
  }

  .controls {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    grid-template-areas:
      "region year"
      "holidays holidays"
      "week week"
      "language help";
    gap: 12px;
    width: 100%;
  }

  .control {
    min-width: 0;
  }

  .control:nth-child(1) {
    grid-area: region;
  }

  .control:nth-child(2) {
    grid-area: year;
  }

  .control:nth-child(3) {
    grid-area: holidays;
  }

  .control:nth-child(4) {
    grid-area: week;
  }

  .control:nth-child(5) {
    grid-area: language;
  }

  .help-btn {
    grid-area: help;
    gap: 8px;
    padding: 8px;
    font-size: 12px;
    line-height: 16px;
  }

  .help-label {
    display: inline;
  }

  .control select {
    width: 100%;
  }

  .lang-select {
    min-width: 0;
    padding-right: 26px;
    padding-left: 8px;
    font-size: 12px;
    line-height: 18px;
  }

  .seg {
    width: 100%;
  }

  .seg button {
    flex: 1;
    padding: 8px 4px;
    text-align: center;
  }

  .help-btn {
    align-self: end;
    width: 100%;
  }

  .stats {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .stat {
    padding: 12px 16px;
    border-top: 1px solid var(--border);
    border-left: 1px solid var(--border);
  }

  .stat:first-child {
    grid-column: 1 / -1;
    border-top: 0;
    border-left: 0;
    padding-left: 0;
  }

  .stat:nth-child(2) {
    border-top: 1px solid var(--border);
    border-left: 0;
  }

  .stat:nth-child(3) {
    border-left: 1px solid var(--border);
  }

  .stat:nth-child(4) {
    border-left: 0;
  }

  .stat:nth-child(5) {
    grid-column: auto;
    border-left: 1px solid var(--border);
  }

  .filter-row {
    gap: 12px;
  }

  .filter-field {
    flex: 1 1 100%;
  }

  .filter-field select {
    width: 100%;
    min-width: 0;
  }

  .filter-field input {
    width: 100%;
  }

  .view-tabs {
    width: 100%;
  }

  .view-tabs button {
    flex: 1;
    text-align: center;
  }

  .clear-bookings {
    width: 100%;
    text-align: left;
  }

  .months {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .month {
    padding: 12px;
  }

  .day {
    min-height: 24px;
  }

  .hint {
    margin-left: 0;
    flex-basis: 100%;
  }

  .explorer-card .card-head {
    flex-wrap: wrap;
  }

  .explorer-actions {
    width: 100%;
    justify-content: flex-start;
    flex-wrap: wrap;
  }

  .explorer-actions .seg {
    min-width: 0;
  }

  .mode-seg {
    width: 100%;
  }

  .mode-seg button {
    flex: 1;
  }

  .onboarding {
    padding: 12px;
  }

  .onboarding-hero {
    padding: 16px;
  }

  .onboarding-hero h2 {
    font-size: 24px;
    line-height: 32px;
  }

  .onboarding-body {
    padding: 16px 16px 8px;
  }

  .onboarding-actions {
    padding: 16px;
    flex-wrap: wrap;
  }

  .onboarding-actions .btn {
    min-width: 72px;
  }
}

@media (max-width: 520px) {
  .months {
    grid-template-columns: 1fr;
  }

  .opt-number {
    font-size: 30px;
    line-height: 36px;
  }
}

@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
    scroll-behavior: auto !important;
  }
}

/* Keep the top-bar clear action as a text control despite .btn.small. */
.view-bar .btn.clear-bookings {
  padding: 0 0 12px;
  border: 0;
  background: transparent;
  color: var(--muted);
  font: 500 12px/16px var(--font-mono);
  justify-content: flex-start;
}

.view-bar .btn.clear-bookings:not(:disabled) {
  color: var(--accent);
}

.view-bar .btn.clear-bookings:disabled {
  opacity: 0.45;
  cursor: not-allowed;
}

input[type="number"]::-webkit-inner-spin-button,
input[type="number"]::-webkit-outer-spin-button {
  margin: 0;
  appearance: none;
}

.notes summary:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

.skip-link {
  position: fixed;
  top: 8px;
  left: 8px;
  z-index: 300;
  padding: 8px 12px;
  background: var(--accent);
  color: var(--accent-ink);
  font: 600 12px/16px var(--font-sans);
  text-decoration: none;
  transform: translateY(-160%);
  transition: transform 300ms var(--ease);
}

.skip-link:focus {
  transform: translateY(0);
}

#mainContent:focus {
  outline: none;
}

.day.holiday.today,
.day.booked.today {
  outline-color: var(--accent-ink);
}

@media (max-width: 520px) {
  #onboardSet {
    flex-direction: column;
  }

  #onboardSet button {
    width: 100%;
    text-align: left;
  }

  #onboardSet button + button {
    border-top: 1px solid var(--border);
    border-left: 0;
  }
}

.set-select {
  min-width: 220px;
}

@media (max-width: 900px) {
  .topbar {
    grid-template-columns: 1fr;
  }
}
