/*
 * x-timetable-fit.css  -- styles for x-timetable-fit.js. Scoped to table.x-ts-js (set by the script);
 * without JavaScript the existing rendering is kept. ASCII only.
 */
.x-ts-wrap {
  max-width: 100%;
}
.x-ts-wrap.x-ts-scroll {
  overflow-x: auto;
  overflow-y: hidden;
  -webkit-overflow-scrolling: touch;
}

/* ---- natural-width measuring pass (applied and removed within one task, never painted) ---- */
table.x-ts-js.x-ts-measure {
  table-layout: auto !important;
  width: max-content !important;
  max-width: none !important;
  height: auto !important;
}
table.x-ts-js.x-ts-measure.x-ts-minc {
  width: min-content !important;
}
table.x-ts-js.x-ts-measure td,
table.x-ts-js.x-ts-measure th {
  white-space: nowrap;
}
table.x-ts-js.x-ts-measure th.x-ts-c4 {
  white-space: normal;
}

/* ---- trimmed layout: explicit column widths set by the script ---- */
table.x-ts-js.x-ts-fit {
  table-layout: fixed;
  max-width: none;
}
table.x-ts-js.x-ts-fit th,
table.x-ts-js.x-ts-fit td {
  box-sizing: border-box;
}
table.x-ts-js.x-ts-fit td {
  overflow: hidden;
  white-space: nowrap;
}

/* ---- content levels: level n hides every data-cut <= n ---- */
table.x-ts-js td.x-ts-c1 [data-cut="1"],
table.x-ts-js td.x-ts-c2 [data-cut="1"],
table.x-ts-js td.x-ts-c2 [data-cut="2"],
table.x-ts-js td.x-ts-c3 [data-cut="1"],
table.x-ts-js td.x-ts-c3 [data-cut="2"],
table.x-ts-js td.x-ts-c3 [data-cut="3"],
table.x-ts-js td.x-ts-c4 [data-cut="1"],
table.x-ts-js td.x-ts-c4 [data-cut="2"],
table.x-ts-js td.x-ts-c4 [data-cut="3"],
table.x-ts-js td.x-ts-c4 [data-cut="4"] {
  display: none !important;
}
/* most trimmed: headers may wrap at spaces and the app's own
   minimum column width (e.g. min-width:100px on th) is released so columns can shrink to the time text */
table.x-ts-js th.x-ts-c4,
table.x-ts-js th.x-ts-c4 a {
  white-space: normal;
  overflow-wrap: normal;   /* wrap at spaces only: the narrowest column is the longest word, not one character */
  word-break: normal;
}
table.x-ts-js th.x-ts-c4,
table.x-ts-js td.x-ts-c4 {
  min-width: 0;
}
table.x-ts-js.x-ts-fit th.x-ts-c1,
table.x-ts-js.x-ts-fit th.x-ts-c2,
table.x-ts-js.x-ts-fit th.x-ts-c3 {
  white-space: nowrap;
}

/* ---- scroll fallback: date column stays visible ---- */
.x-ts-wrap.x-ts-scroll table.x-ts-js.x-ts-fit tr > :first-child {
  position: sticky;
  left: 0;
  z-index: 3;
}
.x-ts-wrap.x-ts-scroll table.x-ts-js.x-ts-fit thead tr > :first-child {
  background-color: #a5d6a7;
}
.x-ts-wrap.x-ts-scroll table.x-ts-js.x-ts-fit tbody tr > :first-child {
  background-color: #fff;
}
.x-ts-wrap.x-ts-scroll table.x-ts-js.x-ts-fit tr.saturday > :first-child { background-color: #bbdefb; }
.x-ts-wrap.x-ts-scroll table.x-ts-js.x-ts-fit tr.sunday > :first-child { background-color: #ffcccb; }
.x-ts-wrap.x-ts-scroll table.x-ts-js.x-ts-fit tr.holiday > :first-child { background-color: #fff9c4; }
.x-ts-wrap.x-ts-scroll table.x-ts-js.x-ts-fit tr.nationalHoliday > :first-child { background-color: #ffe0b2; }
.x-ts-wrap.x-ts-scroll table.x-ts-js.x-ts-fit tr.x-schedule-row.today > :first-child { background-color: #ffff88; }

/* ---- status line above the table (what is shown / trimmed) and the switches ---- */
.x-ts-tools {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 4px 14px;
  margin: 4px 0 4px;
  font-size: 12px;
  line-height: 1.6;
  color: #3b4651;
}
.x-ts-status {
  display: inline-flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 3px 6px;
}
.x-ts-st-title {
  font-weight: bold;
}
.x-ts-chip {
  display: inline-block;
  padding: 0 8px;
  border: 1px solid #6aa57a;
  border-radius: 999px;
  background: #e8f5ec;
  color: #1d5a33;
  white-space: nowrap;
}
.x-ts-chip.off {
  border-color: #c3c8cd;
  background: #f1f2f4;
  color: #8a929a;
  text-decoration: line-through;
}
.x-ts-st-note {
  color: #5b6670;
}
.x-ts-opt {
  display: inline-flex;
  align-items: center;
  gap: 3px;
  cursor: pointer;
  user-select: none;
}
.x-ts-opt input {
  margin: 0;
}
.x-ts-sr {
  position: absolute;
  width: 1px;
  height: 1px;
  overflow: hidden;
  clip: rect(0 0 0 0);
  white-space: nowrap;
}
body.dark-mode .x-ts-tools { color: #cfd6dc; }
body.dark-mode .x-ts-chip { background: #1f3a2a; border-color: #4f8a64; color: #bfe6cc; }
body.dark-mode .x-ts-chip.off { background: #2b2f33; border-color: #50565c; color: #8a929a; }
body.dark-mode .x-ts-st-note { color: #aab3bb; }
