:root {
  --bg-canvas: #FAF8F5;
  --surface: #FFFFFF;
  --surface-alt: #F4EFEA;
  --surface-subtle: #F8FAFC;
  --border: #D8D1C5;
  --border-focus: #0B6B63;
  --text-main: #0F172A;
  --text-muted: #334155;
  --text-light: #475569;
  --brand: #0B6B63;
  --brand-hover: #08524C;
  --brand-tint: #EEF8F6;
  --brand-tint-strong: #C4ECE5;
  --off-color: #B91C1C;
  --off-tint: #FEF2F2;
  --off-border: #FCA5A5;
  --work-color: #0B6B63;
  --radius-sm: 6px;
  --radius-md: 10px;
  --radius-lg: 14px;
  --font-sans: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
}
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; min-width: 0; }
body {
  font-family: var(--font-sans);
  background: var(--bg-canvas);
  color: var(--text-main);
  line-height: 1.5;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  font-size: 15px;
}
a { color: var(--brand); text-decoration: none; }
a:hover { text-decoration: underline; }
[hidden], .is-hidden { display: none !important; }

/* Header & Nav */
.site-header { background: var(--surface); border-bottom: 1px solid var(--border); padding: 8px 14px; position: sticky; top: 0; z-index: 50; }
.header-inner { max-width: 1280px; margin: 0 auto; display: flex; align-items: center; justify-content: space-between; gap: 8px; flex-wrap: wrap; }
.brand-link { display: flex; align-items: center; gap: 8px; text-decoration: none; color: inherit; }
.brand-logo { width: 32px; height: 32px; flex-shrink: 0; }
.brand-name { display: block; font-size: 1.15rem; font-weight: 800; color: var(--text-main); line-height: 1.1; }
.brand-tagline { font-size: 0.78rem; color: var(--text-light); }
.site-nav { display: flex; align-items: center; gap: 4px; font-size: 0.88rem; flex-wrap: wrap; }
.site-nav a { color: var(--text-muted); font-weight: 600; padding: 6px 8px; border-radius: var(--radius-sm); min-height: 36px; display: inline-flex; align-items: center; justify-content: center; }
.site-nav a:hover, .site-nav a.active { color: var(--brand); text-decoration: none; background: var(--surface-alt); }
.footer-lang { flex-basis: 100%; }
.lang-switch { max-width: 100%; }
.lang-switch summary { display: inline-flex; align-items: center; gap: 8px; padding: 8px 14px; min-height: 40px; color: var(--text-main); background: var(--surface-alt); border: 1px solid var(--border); border-radius: 999px; font-size: 0.85rem; font-weight: 700; cursor: pointer; list-style: none; }
.lang-switch summary::-webkit-details-marker { display: none; }
.lang-switch summary::marker { content: ""; }
.lang-switch ul { display: flex; flex-wrap: wrap; gap: 2px 10px; margin: 12px 0 0; padding: 0; list-style: none; max-width: 100%; }
.lang-switch a { display: inline-block; padding: 7px 9px; min-height: 36px; color: var(--text-muted); font-size: 0.85rem; text-decoration: none; border-radius: var(--radius-sm); }
.lang-switch a:hover { color: var(--brand); background: var(--surface-alt); }
.lang-switch a[aria-current] { color: var(--brand); font-weight: 700; text-decoration: underline; }
/* Header language menu: native <details>; row end of the first header row in LTR and RTL */
.site-nav { flex: 1 1 0; justify-content: flex-end; }
.lang-menu { position: relative; flex: none; }
.lang-menu__btn { list-style: none; display: inline-flex; align-items: center; gap: 6px; min-height: 36px; padding: 5px 10px; background: var(--surface-alt); border: 1px solid var(--border); border-radius: var(--radius-sm); color: var(--brand); font-size: 0.82rem; font-weight: 700; cursor: pointer; white-space: nowrap; }
.lang-menu__btn::-webkit-details-marker { display: none; }
.lang-menu__btn:focus-visible { outline: 2px solid var(--border-focus); outline-offset: 2px; }
.lang-menu__short { display: none; }
.lang-menu__caret { transition: transform 0.15s; }
.lang-menu[open] .lang-menu__caret { transform: rotate(180deg); }
.lang-menu__list { list-style: none; position: absolute; top: calc(100% + 6px); inset-inline-end: 0; z-index: 60; display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 2px; width: max-content; min-width: 300px; padding: 6px; background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius-md); box-shadow: 0 8px 24px rgba(15,23,42,0.12); }
.lang-menu__list a { display: block; padding: 7px 10px; border-radius: var(--radius-sm); color: var(--text-muted); font-size: 0.88rem; font-weight: 600; white-space: nowrap; }
.lang-menu__list a:hover { background: var(--surface-alt); color: var(--brand); text-decoration: none; }
.lang-menu__list a[aria-current="true"] { background: var(--brand-tint); color: var(--brand); font-weight: 800; }

/* Main Content Layout */
.main-content { flex: 1; max-width: 1280px; width: 100%; margin: 0 auto; padding: 12px 10px 32px; }
.page-title { font-size: 1.12rem; line-height: 1.3; font-weight: 800; margin: 0 0 8px; }
.tool-layout { display: grid; grid-template-columns: minmax(300px, 380px) minmax(0, 1fr); gap: 18px; align-items: start; }
.card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius-lg); padding: 16px 12px; box-shadow: 0 1px 3px rgba(15,23,42,0.05); }
.home-guide { max-width: 800px; margin: 18px auto 0; background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius-lg); padding: 16px; }
.home-guide h2 { font-size: 1.08rem; margin-bottom: 8px; }
.home-guide h3 { font-size: 0.94rem; margin: 12px 0 5px; }
.home-guide p { color: var(--text-muted); font-size: 0.88rem; margin-bottom: 8px; }

/* Mode Tabs */
.mode-tabs { display: grid; grid-template-columns: 1fr 1fr; gap: 4px; background: var(--surface-alt); border: 1px solid var(--border); padding: 3px; border-radius: var(--radius-md); margin-bottom: 10px; }
.mode-btn { background: transparent; border: none; border-radius: var(--radius-sm); padding: 8px 6px; font-size: 0.86rem; font-weight: 600; color: var(--text-muted); cursor: pointer; min-height: 40px; }
.mode-btn.active { background: var(--surface); color: var(--brand); box-shadow: 0 1px 3px rgba(0,0,0,0.08); font-weight: 700; }
.mode-btn:focus-visible { outline: 2px solid var(--border-focus); outline-offset: 1px; }

/* Form Elements */
.form-group { margin-bottom: 10px; }
.form-label { display: block; font-size: 0.86rem; font-weight: 700; color: var(--text-main); margin-bottom: 3px; }
.form-input { width: 100%; padding: 7px 10px; font-size: 0.92rem; font-family: inherit; border: 1px solid var(--border); border-radius: var(--radius-md); background: #FFF; color: var(--text-main); outline: none; min-height: 40px; }
.form-input:focus { border-color: var(--border-focus); box-shadow: 0 0 0 3px rgba(11,107,99,0.18); }
.field-date-helper { font-size: 0.8rem; color: var(--brand); font-weight: 600; margin-top: 2px; min-height: 1.5em; }
.quick-steps-wrap { margin-top: 6px; }
.quick-steps { display: grid; grid-template-columns: repeat(5, 1fr); gap: 4px; }
.btn-step { background: var(--surface-alt); border: 1px solid var(--border); border-radius: var(--radius-sm); padding: 6px 4px; font-size: 0.86rem; font-weight: 700; cursor: pointer; min-height: 40px; display: inline-flex; align-items: center; justify-content: center; }
.btn-step:hover { background: var(--brand-tint); border-color: var(--brand); color: var(--brand); }
.btn-step:focus-visible { outline: 2px solid var(--border-focus); outline-offset: 1px; }
.checkbox-row { display: flex; gap: 12px; flex-wrap: wrap; margin-bottom: 10px; }
.checkbox-label { font-size: 0.86rem; cursor: pointer; display: inline-flex; align-items: center; gap: 6px; color: var(--text-main); font-weight: 600; min-height: 36px; }

/* Weekend Chips */
.weekend-group { margin-bottom: 10px; }
.days-chips { display: grid; grid-template-columns: repeat(7, minmax(0, 1fr)); gap: 2px; }
.day-chip-label { position: relative; display: flex; flex-direction: column; align-items: center; justify-content: center; min-height: 40px; border: 1px solid var(--border); border-radius: var(--radius-sm); font-size: 0.82rem; font-weight: 700; color: var(--text-muted); cursor: pointer; background: var(--surface); user-select: none; }
.day-chip-label input { position: absolute; opacity: 0; pointer-events: none; }
.day-chip-label.checked { background: #FEE2E2; border-color: #F87171; color: #B91C1C; }
.day-chip-label:has(input:focus-visible), .day-chip-label:focus-within { outline: 2px solid var(--border-focus); outline-offset: 1px; }

/* Rules Details Disclosure */
.rules-disclosure { border: 1px solid var(--border); border-radius: var(--radius-md); background: var(--surface-alt); margin-bottom: 10px; overflow: hidden; }
.disclosure-summary { display: flex; align-items: center; justify-content: space-between; padding: 8px 10px; cursor: pointer; font-size: 0.84rem; font-weight: 700; color: var(--text-main); min-height: 40px; user-select: none; }
.disclosure-summary:hover { background: #EFE9E2; }
.disclosure-summary:focus-visible { outline: 2px solid var(--border-focus); outline-offset: -2px; }
.disclosure-badge { font-size: 0.72rem; background: var(--brand); color: #FFF; padding: 2px 6px; border-radius: 10px; font-weight: 700; }
.disclosure-badge:not(.has-items) { display: none; }
.disclosure-content { padding: 10px 10px 12px; border-top: 1px solid var(--border); background: var(--surface); }
.notice-box { background: var(--surface-alt); border-left: 3px solid var(--brand); border-radius: 0 var(--radius-sm) var(--radius-sm) 0; padding: 8px 10px; font-size: 0.82rem; color: var(--text-muted); margin-bottom: 10px; line-height: 1.45; }
.notice-box strong { color: var(--text-main); }
.exceptions-panel { padding-top: 2px; }
.exceptions-header { display: flex; justify-content: space-between; align-items: center; margin-bottom: 6px; }
.exceptions-title { font-size: 0.84rem; font-weight: 700; color: var(--text-main); }
.btn-text-sm { background: none; border: 1px solid transparent; color: var(--text-light); font-size: 0.8rem; font-weight: 600; cursor: pointer; padding: 5px 8px; min-height: 36px; border-radius: var(--radius-sm); display: inline-flex; align-items: center; }
.btn-text-sm:hover { color: var(--off-color); background: var(--surface-alt); border-color: var(--border); }
.exceptions-list { display: flex; flex-wrap: wrap; gap: 5px; max-height: 120px; overflow-y: auto; font-size: 0.8rem; }
.exception-tag { display: inline-flex; align-items: center; gap: 4px; font-size: 0.78rem; font-weight: 600; padding: 3px 6px; border-radius: var(--radius-sm); background: var(--surface-alt); border: 1px solid var(--border); min-height: 26px; }
.exception-tag.off { background: var(--off-tint); border-color: var(--off-border); color: var(--off-color); }
.exception-tag.work { background: var(--brand-tint); border-color: var(--brand-tint-strong); color: var(--work-color); }
.btn-tag-remove { background: none; border: none; cursor: pointer; font-size: 0.95rem; color: inherit; padding: 0 4px; min-width: 24px; min-height: 24px; display: inline-flex; align-items: center; justify-content: center; }

/* Result Header */
.result-header { display: flex; justify-content: space-between; align-items: flex-start; gap: 10px; margin-bottom: 10px; padding-bottom: 10px; border-bottom: 1px solid var(--border); flex-wrap: wrap; }
.result-caption { font-size: 0.78rem; font-weight: 700; text-transform: uppercase; color: var(--text-light); letter-spacing: 0.03em; }
.result-date { font-size: clamp(1.25rem, 4.5vw, 1.55rem); font-weight: 800; color: var(--text-main); line-height: 1.2; white-space: nowrap; }
.result-subline { font-size: 0.9rem; color: var(--brand); font-weight: 700; margin-top: 2px; min-height: 1.5em; }
.day0-note { font-size: 0.8rem; color: var(--text-muted); margin-top: 2px; font-weight: 600; min-height: 1.5em; }
.btn-primary { display: inline-flex; align-items: center; gap: 6px; background: var(--brand); color: #FFF; border: none; border-radius: var(--radius-md); padding: 8px 12px; font-size: 0.88rem; font-weight: 700; cursor: pointer; min-height: 40px; }
.btn-primary:hover:not(:disabled) { background: var(--brand-hover); }
.btn-primary:focus-visible { outline: 2px solid var(--border-focus); outline-offset: 1px; }
.btn-primary:disabled { opacity: 0.45; cursor: not-allowed; }
.copy-feedback { font-size: 0.8rem; color: var(--brand); font-weight: 700; min-height: 16px; margin-top: 2px; }
.breakdown-chips { display: flex; gap: 4px; flex-wrap: wrap; margin-bottom: 10px; min-height: 1.5em; }
.pill { padding: 3px 7px; border-radius: 16px; font-size: 0.78rem; font-weight: 700; background: var(--surface-alt); color: var(--text-muted); }
.pill.primary { background: var(--brand-tint); color: var(--brand); }

/* Calendar Controls & Out-of-View Banner */
.cal-nav { display: flex; justify-content: space-between; align-items: center; margin-bottom: 8px; gap: 6px; flex-wrap: wrap; }
.cal-nav-title { font-size: 1rem; font-weight: 800; color: var(--text-main); }
.cal-nav-actions { display: flex; gap: 4px; }
.btn-icon { background: var(--surface-alt); border: 1px solid var(--border); border-radius: var(--radius-sm); padding: 6px 10px; font-size: 0.9rem; font-weight: 700; cursor: pointer; min-height: 40px; min-width: 40px; display: inline-flex; align-items: center; justify-content: center; }
.btn-icon:hover:not(:disabled) { border-color: var(--brand); color: var(--brand); background: var(--brand-tint); }
.btn-icon:focus-visible { outline: 2px solid var(--border-focus); outline-offset: 1px; }
.btn-icon:disabled { opacity: 0.4; cursor: not-allowed; }
.btn-nav-target { font-size: 0.82rem; padding: 6px 10px; }
.cal-status-banner { display: flex; align-items: center; justify-content: space-between; gap: 8px; flex-wrap: wrap; background: var(--brand-tint); border: 1px solid var(--brand-tint-strong); color: var(--brand); font-size: 0.82rem; font-weight: 700; padding: 6px 10px; border-radius: var(--radius-md); margin-bottom: 8px; }
.btn-banner-jump { background: var(--brand); color: #FFF; border: none; border-radius: var(--radius-sm); padding: 6px 10px; font-size: 0.8rem; font-weight: 700; cursor: pointer; min-height: 36px; white-space: nowrap; display: inline-flex; align-items: center; }
.btn-banner-jump:hover { background: var(--brand-hover); }
.btn-banner-jump:focus-visible { outline: 2px solid var(--border-focus); outline-offset: 1px; }

/* Dual Month Grid Layout */
.cal-months-wrap { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 12px; }
/* Reserve the calendar's first-paint footprint until the local module renders it. */
#calendar-container:empty { min-height: 290px; }
.cal-month-block { min-width: 0; }
.cal-month-heading { font-size: 0.86rem; font-weight: 800; color: var(--text-main); margin: 0 0 5px 0; text-align: center; padding: 3px 6px; background: var(--surface-alt); border-radius: var(--radius-sm); border: 1px solid var(--border); }
.cal-grid { display: grid; grid-template-columns: repeat(7, minmax(0, 1fr)); gap: 3px; }
.cal-day-header { text-align: center; font-size: 0.74rem; font-weight: 700; color: var(--text-light); padding: 2px 0; }
.cal-cell { height: 44px; min-height: 42px; border: 1px solid var(--border); border-radius: var(--radius-sm); padding: 2px 1px; display: flex; flex-direction: column; justify-content: space-between; align-items: center; cursor: pointer; background: var(--surface); text-align: center; box-sizing: border-box; }
.cal-cell:hover { border-color: var(--brand); box-shadow: 0 1px 4px rgba(0,0,0,0.08); }
.cal-cell:focus-visible { outline: 2px solid var(--brand); outline-offset: 1px; z-index: 2; }
.cal-cell.empty { background: transparent; border-color: transparent; cursor: default; }
.cal-cell.empty:hover { box-shadow: none; }
.cal-cell.weekend { background: #FAF9F7; color: var(--text-light); }
.cal-cell.in-range { border-color: var(--brand-tint-strong); background: #F6FCFB; }
.cal-cell.workday { background: var(--brand-tint); border-color: #99E1D8; }
.cal-cell.holiday { background: var(--off-tint); border-color: var(--off-border); }
.cal-cell.makeup { background: #E6F8F5; border-color: #5EEAD4; }
.cal-cell.start-date { box-shadow: inset 0 0 0 2px var(--brand); }
.cal-cell.target-date { box-shadow: inset 0 0 0 2px var(--text-main); background: #FFFBEB; }
.cal-num { font-size: 0.8rem; font-weight: 700; line-height: 1; color: var(--text-main); }
.cal-badge { display: block; max-width: 100%; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; font-size: 0.58rem; font-weight: 700; line-height: 1.1; padding: 1px 2px; border-radius: 3px; text-align: center; box-sizing: border-box; letter-spacing: -0.02em; }
.cal-badge.seq { background: var(--brand); color: #FFF; }
.cal-badge.off-badge { background: var(--off-color); color: #FFF; }
.cal-badge.work-badge { background: #0F766E; color: #FFF; }
.cal-badge.start-badge { background: var(--text-main); color: #FFF; }
.cal-badge.excluded-badge { background: #475569; color: #FFF; }
.cal-badge.target-badge { background: #92400E; color: #FFF; }

/* Legend */
.cal-legend { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 10px; padding-top: 8px; border-top: 1px solid var(--border); font-size: 0.76rem; font-weight: 600; color: var(--text-muted); }
.legend-item { display: flex; align-items: center; gap: 4px; }
.legend-dot { width: 10px; height: 10px; border-radius: 2px; border: 1px solid var(--border); flex-shrink: 0; }
.legend-dot-workday { background: var(--brand-tint); border-color: #99E1D8; }
.legend-dot-weekend { background: #FAF9F7; border-color: var(--border); }
.legend-dot-holiday { background: var(--off-tint); border-color: var(--off-border); }
.legend-dot-makeup { background: #E6F8F5; border-color: #5EEAD4; }
.legend-dot-target { background: #FFFBEB; border-color: var(--text-main); }

/* Other Components */
.copy-fallback-area { margin-top: 8px; width: 100%; font-family: monospace; font-size: 0.8rem; padding: 6px; border: 1px solid var(--border); border-radius: var(--radius-sm); background: var(--surface-alt); display: none; }
.copy-fallback-area.visible { display: block; }
.error-banner { background: var(--off-tint); border: 1px solid var(--off-border); color: var(--off-color); padding: 8px 12px; border-radius: var(--radius-md); font-size: 0.84rem; font-weight: 700; margin-bottom: 10px; }

/* Info Pages */
.article-container { max-width: 800px; margin: 0 auto; background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius-lg); padding: 20px 16px; }
.article-title { font-size: 1.5rem; font-weight: 800; margin-bottom: 6px; }
.article-lead { font-size: 0.94rem; color: var(--text-muted); margin-bottom: 14px; border-bottom: 1px solid var(--border); padding-bottom: 8px; }
.article-body h2 { font-size: 1.1rem; font-weight: 700; margin: 16px 0 6px; }
.article-body p { margin-bottom: 8px; color: var(--text-muted); font-size: 0.88rem; }
.article-body ul { margin: 0 0 10px 16px; color: var(--text-muted); font-size: 0.88rem; }
.article-body li { margin-bottom: 3px; }

/* Footer */
.site-footer { border-top: 1px solid var(--border); background: var(--surface); padding: 14px 12px; margin-top: auto; font-size: 0.8rem; color: var(--text-muted); }
.footer-inner { max-width: 1280px; margin: 0 auto; display: flex; justify-content: space-between; align-items: center; gap: 10px; flex-wrap: wrap; }
.footer-links { display: flex; gap: 10px; flex-wrap: wrap; }
.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 adjustments */
@media (max-width: 880px) {
  .site-header { padding: 6px 10px; }
  .brand-tagline { display: none; }
  .site-nav { gap: 3px; font-size: 0.82rem; }
  .site-nav a { padding: 4px 6px; min-height: 36px; }
  .lang-switch summary { padding: 6px 10px; min-height: 36px; font-size: 0.82rem; }
  .lang-switch a { padding: 6px 7px; font-size: 0.82rem; }
  .main-content { padding: 8px 6px 20px; }
  .tool-layout { grid-template-columns: minmax(0, 1fr); gap: 10px; }
  .card { padding: 12px 8px; }
  .form-group { margin-bottom: 8px; }
  .mode-tabs { margin-bottom: 8px; }
  .cal-months-wrap { grid-template-columns: minmax(0, 1fr); gap: 10px; }
  #calendar-container:empty { min-height: 562px; }
  .cal-grid { gap: 2px; }
  .cal-cell { height: 42px; min-height: 40px; padding: 2px 1px; }
}

/* Narrow header: nav moves to a second row; the menu shows its short label and spans the header */
@media (max-width: 720px) {
  .site-nav { order: 3; flex-basis: 100%; justify-content: flex-start; }
  .lang-menu { position: static; }
  .lang-menu__name { position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip: rect(0,0,0,0); white-space: nowrap; border: 0; }
  .lang-menu__short { display: inline; }
  .lang-menu__list { top: 100%; inset-inline: 0; width: auto; min-width: 0; border-radius: 0; border-inline: 0; }
}
