@layer components {
  .seg, .days {
    display: flex; gap: 2px; padding: 3px;
    background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius-md);
  }
  .days {
    flex-wrap: nowrap; min-width: 0; width: 100%;
    overflow-x: auto; overflow-y: hidden; scrollbar-width: thin;
    overscroll-behavior-x: contain; -webkit-overflow-scrolling: touch;
    touch-action: pan-x; scroll-padding-inline: var(--space-2);
  }
  .days[hidden], .seg[hidden] { display: none; }
  .seg button, .days button, .chip, .ghost {
    border: 0; background: transparent; color: var(--text-muted);
    padding: var(--space-2) var(--space-3); border-radius: var(--radius-sm);
    font-weight: 500; line-height: 1.2; min-height: 44px;
  }
  .days button { display: grid; justify-items: start; gap: 2px; min-width: 5.5rem; flex: none; text-align: start; }
  .days .dow { font-size: var(--text-xs); letter-spacing: 0.06em; text-transform: uppercase; }
  .days .dom { font-variant-numeric: tabular-nums; color: var(--text); font-weight: 600; }
  /* today marker */
  .days button.is-today .dom::after {
    content: ""; display: inline-block; width: 6px; height: 6px; border-radius: 99px;
    background: var(--now); margin-inline-start: 5px; vertical-align: middle; position: relative; top: -1px;
  }
  .seg button[aria-pressed="true"],
  .days button[aria-selected="true"],
  .chip[aria-pressed="true"] {
    background: var(--surface-3); color: var(--text);
    box-shadow: inset 0 0 0 1px var(--border-strong);
  }
  .days button[aria-selected="true"] .dom { color: var(--accent); }
  .seg button:hover, .days button:hover, .chip:hover, .ghost:hover {
    color: var(--text); background: var(--surface-2);
  }
  .chip {
    display: inline-flex; align-items: center; gap: var(--space-2); flex: none;
    min-height: 36px; border: 1px solid var(--border); background: var(--surface);
  }
  .chip .dot { width: 0.55rem; height: 0.55rem; border-radius: 99px; background: var(--sec); flex: none; }
  .chip[aria-pressed="false"] { background: transparent; border-color: var(--border); color: var(--text-muted); }
  .chip .cnt { font-size: var(--text-xs); color: var(--text-faint); font-variant-numeric: tabular-nums; }
  .chip .cnt.is-zero { color: var(--text-faint); opacity: 0.7; }
  .toolbar .chip svg, .toolbar .ghost svg { width: 16px; height: 16px; fill: none; stroke: currentColor; stroke-width: 1.75; stroke-linecap: round; stroke-linejoin: round; }
  .toolbar .chip[aria-pressed="true"] { color: var(--accent); }
  .lnk {
    border: 0; background: transparent; color: var(--text-muted); font-size: var(--text-sm); font-weight: 500;
    padding: var(--space-1) var(--space-2); border-radius: var(--radius-sm); min-height: 32px; white-space: nowrap;
  }
  .lnk:hover { color: var(--text); background: var(--surface-2); }
  .ghost { min-height: 36px; }
  .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;
  }
  .lbl { align-self: center; flex: none; white-space: nowrap; font-size: var(--text-xs); letter-spacing: 0.08em; text-transform: uppercase; color: var(--text-faint); font-weight: 600; }

  .search { position: relative; display: flex; align-items: center; min-width: 0; width: min(20rem, 100%); }
  .search svg {
    position: absolute; inset-inline-start: var(--space-3); width: 18px; height: 18px; pointer-events: none;
    fill: none; stroke: var(--text-faint); stroke-width: 1.75; stroke-linecap: round;
  }
  .search input {
    min-height: 44px; min-width: 0; width: 100%;
    border: 1px solid var(--border); background: var(--surface); color: var(--text);
    border-radius: var(--radius-sm); padding: var(--space-2) var(--space-3) var(--space-2) 2.5rem; font: inherit;
  }
  .search input::placeholder { color: var(--text-faint); }

  .icon-btn {
    width: 44px; height: 44px; min-height: 44px; padding: 0;
    display: grid; place-items: center;
    border: 1px solid var(--border); background: var(--surface); border-radius: var(--radius-sm);
    color: var(--text-muted);
  }
  .icon-btn:hover { color: var(--text); background: var(--surface-2); }
  .icon-btn svg { width: 20px; height: 20px; fill: none; stroke: currentColor; stroke-width: 1.75; }
  .now-btn { width: auto; display: inline-flex; align-items: center; gap: var(--space-2); padding-inline: var(--space-3); color: var(--text); font-weight: 600; }
  .now-btn svg { stroke: var(--now); }
  .brand-tools { display: flex; flex-wrap: wrap; align-items: center; gap: var(--space-2); justify-content: flex-end; }
  .filt-btn {
    display: inline-flex; align-items: center; gap: var(--space-2); flex: none;
    min-height: 44px; padding: var(--space-2) var(--space-3);
    border: 1px solid var(--border); border-radius: 99px; background: var(--surface);
    color: var(--text-muted); font-weight: 600;
  }
  .filt-btn:hover { color: var(--text); background: var(--surface-2); }
  .filt-btn svg { width: 18px; height: 18px; fill: none; stroke: currentColor; stroke-width: 1.75; stroke-linejoin: round; }
  .filt-btn[data-on="true"] { color: var(--text); border-color: var(--accent); }
  .badge {
    display: inline-grid; place-items: center; min-width: 1.25rem; height: 1.25rem; padding-inline: 5px;
    border-radius: 99px; background: var(--accent); color: var(--accent-fg);
    font-size: var(--text-xs); font-weight: 700; font-variant-numeric: tabular-nums;
  }
  .filt-body { display: grid; gap: var(--space-3); min-width: 0; }
  #filt-sheet {
    width: 100vw; max-width: 100vw; height: 100dvh; max-height: 100dvh; margin: 0;
    background: var(--bg); color: var(--text);
  }
  #filt-sheet[open] { display: grid; grid-template-rows: auto minmax(0, 1fr) auto; }
  #filt-sheet::backdrop { background: var(--overlay); }
  .fs-head {
    display: flex; align-items: center; gap: var(--space-2);
    padding: var(--space-2) var(--space-3); border-block-end: 1px solid var(--border);
    padding-block-start: calc(var(--space-2) + env(safe-area-inset-top));
  }
  .fs-head h2 { flex: 1 1 auto; font-family: var(--font-display); font-size: var(--text-lg); letter-spacing: -0.02em; }
  .fs-head .icon-btn { border: 0; background: transparent; font-size: 1.5rem; line-height: 1; }
  .fs-body { overflow: auto; padding: var(--space-3); }
  .fs-foot {
    padding: var(--space-3); border-block-start: 1px solid var(--border); background: var(--surface);
    padding-block-end: calc(var(--space-3) + env(safe-area-inset-bottom, 0px));
  }
  .fs-foot .btn { width: 100%; }
  .tab { display: inline-flex; align-items: center; gap: var(--space-2); }
  .check {
    display: flex; align-items: center; gap: var(--space-3);
    min-height: 44px; padding-inline: var(--space-2);
    border-radius: var(--radius-sm);
  }
  .check:hover { background: var(--surface-2); }
  .check input { width: 1.25rem; height: 1.25rem; accent-color: var(--accent); flex: none; }

  /* search results inside the filter sheet */
  .q-hits { display: grid; gap: var(--space-1); }
  .q-hit {
    display: grid; gap: 2px; text-align: start; min-height: 44px; padding: var(--space-2) var(--space-3);
    border: 1px solid var(--border); border-radius: var(--radius-sm); background: var(--surface-2);
    box-shadow: inset 3px 0 0 var(--sec); color: var(--text);
  }
  .q-hit:hover { background: var(--surface-3); }
  .q-hit .n { font-family: var(--font-display); font-weight: 600; line-height: 1.25; }
  .q-hit .sub { font-size: var(--text-xs); color: var(--text-faint); }
}
