:root {
  color-scheme: light;
  --page: #f9f9f7;
  --surface: #fcfcfb;
  --ink: #0b0b0b;
  --ink-2: #52514e;
  --muted: #6f6d68;
  --axis: #898781;
  --grid: #e1e0d9;
  --baseline: #c3c2b7;
  --border: rgba(11, 11, 11, 0.10);
  --wash: rgba(11, 11, 11, 0.05);
  --accent: #6250d6;
  --like: #d03b3b;
  --series-ban: #2a78d6;
  --series-timeout: #eb6834;
  --series-delete: #1baf7a;
  --live: #d03b3b;
}

@media (prefers-color-scheme: dark) {
  :root {
    color-scheme: dark;
    --page: #0d0d0d;
    --surface: #1a1a19;
    --ink: #f0efec;
    --ink-2: #c3c2b7;
    --muted: #a3a198;
    --axis: #898781;
    --grid: #2c2c2a;
    --baseline: #383835;
    --border: rgba(255, 255, 255, 0.10);
    --wash: rgba(255, 255, 255, 0.06);
    --accent: #9085e9;
    --like: #e66767;
    --series-ban: #3987e5;
    --series-timeout: #d95926;
    --series-delete: #199e70;
  }
}

* { box-sizing: border-box; }

body {
  margin: 0;
  background: var(--page);
  color: var(--ink);
  font: 15px/1.5 system-ui, -apple-system, "Segoe UI", sans-serif;
}

a { color: inherit; text-underline-offset: 2px; }
h1 { margin: 0; font-size: 1.5rem; line-height: 1.2; }
h2 { margin: 2rem 0 0.75rem; font-size: 1.125rem; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
.muted { color: var(--muted); }

.wrap { width: 100%; max-width: 880px; margin-inline: auto; padding-inline: 16px; }
main.wrap { padding-block: 24px; }

/* Nagłówek */
.site-header { background: var(--surface); border-bottom: 1px solid var(--border); }
.site-header-row { display: flex; flex-wrap: wrap; align-items: center; gap: 8px 16px; padding-block: 12px; }
.brand { font-size: 1.25rem; font-weight: 800; letter-spacing: -0.02em; text-decoration: none; }
.brand span { color: var(--accent); }
.stream { display: inline-flex; flex-wrap: wrap; align-items: center; gap: 2px 8px; color: var(--ink-2); font-size: 0.875rem; text-decoration: none; }
.stream:hover { text-decoration: underline; }
.stream-live strong { color: var(--ink); }
.live-dot { width: 8px; height: 8px; border-radius: 50%; background: var(--live); }
.search { margin-left: auto; flex: 0 1 220px; min-width: 150px; }
.search input {
  width: 100%;
  padding: 6px 10px;
  border: 1px solid var(--border);
  border-radius: 6px;
  background: var(--page);
  color: var(--ink);
  font: inherit;
  font-size: 0.875rem;
}
.notice { margin-block: 12px 0; color: var(--ink-2); font-size: 0.875rem; }

/* Sekcje i przełączniki */
.section-head { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 12px; margin-bottom: 12px; }
.segmented { display: inline-flex; flex-wrap: wrap; gap: 2px; padding: 2px; border-radius: 8px; background: var(--wash); }
.segmented a { padding: 4px 10px; border-radius: 6px; color: var(--ink-2); font-size: 0.875rem; text-decoration: none; }
.segmented a:hover { color: var(--ink); }
.segmented a[aria-current] { background: var(--surface); color: var(--ink); font-weight: 600; box-shadow: 0 0 0 1px var(--border); }

.card { background: var(--surface); border: 1px solid var(--border); border-radius: 12px; padding: 16px; }

/* Kafelki z liczbami, jednocześnie legenda wykresu */
.tiles { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 12px; margin: 0; }
.tiles-4 { grid-template-columns: repeat(auto-fit, minmax(130px, 1fr)); }
.tile dt { display: flex; align-items: center; gap: 6px; color: var(--ink-2); font-size: 0.8125rem; line-height: 1.3; }
.tile dd { margin: 2px 0 0; font-size: 1.625rem; font-weight: 650; line-height: 1.2; }
.swatch { flex: none; display: inline-block; width: 10px; height: 10px; border-radius: 3px; }
.s-ban { background: var(--series-ban); }
.s-timeout { background: var(--series-timeout); }
.s-delete { background: var(--series-delete); }

/* Wykres: kolumny układane w CSS, więc skalują się bez rozciągania tekstu */
.chart { position: relative; margin: 20px 0 0; }
.chart-body { display: grid; grid-template-columns: auto minmax(0, 1fr); column-gap: 8px; padding-bottom: 26px; }
.y-axis { position: relative; min-width: 2.5em; height: 220px; color: var(--muted); font-size: 0.75rem; font-variant-numeric: tabular-nums; text-align: right; }
.y-axis span { position: absolute; right: 0; height: 0; line-height: 0; white-space: nowrap; }
.plot { position: relative; height: 220px; border-bottom: 1px solid var(--baseline); margin-right: 12px; }
.gridline { position: absolute; inset-inline: 0; height: 1px; background: var(--grid); }
.columns { position: absolute; inset: 0; display: flex; }
.column { position: relative; flex: 1 1 0; min-width: 0; display: flex; align-items: flex-end; justify-content: center; padding-inline: 1px; }
.column:hover, .column:focus-visible { background: var(--wash); }
.column:focus-visible { outline-offset: -2px; }
.stack { display: flex; flex-direction: column-reverse; gap: 2px; width: 100%; max-width: 24px; min-height: min-content; }
.segment { flex: 1 1 0; min-height: 2px; }
.segment:last-child { border-radius: 4px 4px 0 0; }
.x-label { position: absolute; top: calc(100% + 7px); left: 50%; transform: translateX(-50%); color: var(--muted); font-size: 0.75rem; white-space: nowrap; }
.chart-empty { position: absolute; inset: 0; display: grid; place-items: center; margin: 0; color: var(--muted); pointer-events: none; }
.chart-tip {
  position: absolute;
  z-index: 2;
  min-width: 170px;
  padding: 8px 10px;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--surface);
  box-shadow: 0 4px 16px rgba(0, 0, 0, 0.18);
  font-size: 0.8125rem;
  pointer-events: none;
}
.chart-tip strong { display: block; margin-bottom: 4px; }
.tip-row { display: flex; align-items: center; gap: 6px; color: var(--ink-2); }
.tip-row b { margin-left: auto; padding-left: 12px; color: var(--ink); font-variant-numeric: tabular-nums; }

.data-table { margin-top: 4px; font-size: 0.875rem; }
.data-table summary { color: var(--ink-2); cursor: pointer; }
.data-table table { width: 100%; margin-top: 8px; border-collapse: collapse; font-variant-numeric: tabular-nums; }
.data-table th, .data-table td { padding: 4px 6px; border-bottom: 1px solid var(--grid); text-align: right; font-weight: 400; }
.data-table thead th { color: var(--ink-2); font-weight: 600; }
.data-table th:first-child { text-align: left; }

/* Lista kar */
#feed { margin-top: 28px; scroll-margin-top: 12px; }
.tabs { display: flex; gap: 4px; border-bottom: 1px solid var(--border); overflow-x: auto; }
.tabs a { padding: 8px 12px; border-bottom: 2px solid transparent; margin-bottom: -1px; color: var(--ink-2); font-weight: 500; text-decoration: none; white-space: nowrap; }
.tabs a:hover { color: var(--ink); }
.tabs a[aria-current] { border-color: var(--accent); color: var(--ink); font-weight: 650; }
.filters { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 12px; }
.chip { display: inline-flex; align-items: center; gap: 6px; padding: 3px 10px; border: 1px solid var(--border); border-radius: 999px; font-size: 0.8125rem; text-decoration: none; }
.chip:hover { background: var(--wash); }
.chip[aria-pressed="false"] { color: var(--muted); }
.chip[aria-pressed="false"] .swatch { background: transparent; box-shadow: inset 0 0 0 1px var(--axis); }
.tab-note { margin: 12px 0 0; color: var(--ink-2); font-size: 0.875rem; }
.feed { display: flex; flex-direction: column; gap: 10px; margin-top: 12px; }
.week-label { margin: 10px 0 -4px; color: var(--ink-2); font-size: 0.875rem; font-weight: 600; }
.empty { margin: 0; padding: 32px 16px; border: 1px dashed var(--baseline); border-radius: 12px; color: var(--ink-2); text-align: center; }

.penalty { min-width: 0; padding: 12px 14px; background: var(--surface); border: 1px solid var(--border); border-radius: 10px; }
.penalty-head { display: flex; flex-wrap: wrap; align-items: center; gap: 4px 10px; }
.who { font-weight: 650; overflow-wrap: anywhere; }
.badge { padding: 0 5px; border: 1px solid var(--border); border-radius: 4px; color: var(--ink-2); font-size: 0.6875rem; font-weight: 600; line-height: 1.5; white-space: nowrap; }
.kind { display: inline-flex; align-items: center; gap: 6px; font-size: 0.875rem; white-space: nowrap; }
.when { color: var(--muted); font-size: 0.8125rem; white-space: nowrap; }
.like {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  min-height: 28px;
  margin-left: auto;
  padding: 2px 8px;
  border: 1px solid var(--border);
  border-radius: 999px;
  background: transparent;
  color: var(--ink-2);
  cursor: pointer;
  font: inherit;
  font-size: 0.8125rem;
  font-variant-numeric: tabular-nums;
}
.like svg { fill: none; stroke: currentColor; stroke-width: 2; }
.like:not(:disabled):hover { background: var(--wash); }
.like[aria-pressed="true"] svg { fill: var(--like); stroke: var(--like); }
.like:disabled { cursor: default; opacity: 0.6; }

.messages { display: flex; flex-direction: column; gap: 3px; margin: 8px 0 0; padding: 0; list-style: none; font-size: 0.875rem; }
.messages li { display: flex; gap: 8px; min-width: 0; }
.messages time { flex: none; color: var(--muted); font-size: 0.8125rem; font-variant-numeric: tabular-nums; line-height: 1.6; }
.messages .text { min-width: 0; overflow-wrap: anywhere; }
.empty-messages { margin: 6px 0 0; font-size: 0.875rem; }
.emote { height: 24px; max-width: 96px; margin-block: -3px; vertical-align: middle; }

.pagination { display: grid; grid-template-columns: 1fr auto 1fr; align-items: center; gap: 12px; margin-top: 16px; font-size: 0.875rem; }
.pagination a[rel="next"] { justify-self: end; }

/* Profil */
.user-head { justify-content: flex-start; }
.user-badges { display: flex; gap: 4px; }
.twitch-link { margin-left: auto; color: var(--ink-2); font-size: 0.875rem; }
.user-seen { margin: 12px 0 0; font-size: 0.875rem; }
.messages-full { gap: 6px; margin-top: 12px; }
.not-found { padding-block: 40px; text-align: center; }

.site-footer { padding-block: 8px 28px; color: var(--muted); font-size: 0.8125rem; }

@media (max-width: 520px) {
  .search { flex: 1 1 100%; margin-left: 0; }
  .segmented { width: 100%; }
  .segmented a { flex: 1 1 auto; padding-inline: 6px; text-align: center; }
  .tile dd { font-size: 1.375rem; }
  .messages-full li { flex-direction: column; gap: 0; }
}

@media (forced-colors: active) {
  .swatch, .segment { background: CanvasText; }
  .s-timeout { background: Highlight; }
  .s-delete { background: GrayText; }
}
