/* Układ i klocki wspólne. Barwy, promienie i układ nawigacji ustawia wariant wyglądu w skins.css przez zmienne. */
*, *::before, *::after { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html { -webkit-text-size-adjust: 100%; }
body { margin: 0; background: var(--bg); color: var(--text); font: 400 16px/1.45 var(--font); min-height: 100dvh; overflow-wrap: anywhere; }
h1, h2, h3, p, ul { margin: 0; }
h1, h2, .num { font-family: var(--font-num); }
button, input, select, textarea { font: inherit; color: inherit; }
button { cursor: pointer; }
[hidden] { display: none !important; }
:focus-visible { outline: 3px solid var(--focus); outline-offset: 2px; }
.icon { flex: none; }
.muted { color: var(--muted); font-size: 14px; }
.center { text-align: center; }
.kicker { display: block; font: 700 12px/1.2 var(--font); letter-spacing: .06em; text-transform: uppercase; color: var(--kicker); }

.app { max-width: 640px; margin: 0 auto; min-height: 100dvh; display: flex; flex-direction: column; padding-bottom: calc(var(--tabs-space) + env(safe-area-inset-bottom, 0px)); }
.app.is-sub { padding-bottom: 24px; }
.boot { margin: auto; font: 700 22px var(--font-num); color: var(--muted); }
.view { flex: 1; display: flex; flex-direction: column; gap: 14px; padding: 14px; min-width: 0; }

/* górna belka */
.topbar { position: sticky; top: 0; z-index: 30; display: flex; align-items: center; justify-content: space-between; gap: 10px; padding: 10px 14px; padding-top: calc(10px + env(safe-area-inset-top, 0px)); background: var(--topbar-bg); color: var(--topbar-text); border-bottom: var(--topbar-rule); }
.topbar::after { content: ""; position: absolute; left: 0; right: 0; bottom: -4px; height: 4px; background: var(--topbar-strip); }
.app.is-sub .topbar { display: none; }
.brand { display: flex; align-items: center; gap: 10px; min-width: 0; }
.brand img { border-radius: 8px; flex: none; }
.brand div { display: grid; min-width: 0; }
.brand strong { font: 700 19px/1.1 var(--font-num); letter-spacing: .01em; }
.brand span { font-size: 12.5px; color: var(--topbar-muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.badge { flex: none; font-size: 11.5px; font-weight: 600; padding: 3px 9px; border-radius: 999px; border: 1px solid var(--topbar-line); color: var(--topbar-muted); }
.badge-demo { background: var(--warn-bg); color: var(--warn); border-color: transparent; }

/* nawigacja główna */
.tabs { z-index: 40; display: grid; grid-template-columns: repeat(5, minmax(0, 1fr)); background: var(--tabs-bg); border-top: 1px solid var(--tabs-line); position: fixed; left: 0; right: 0; bottom: 0; margin: 0 auto; max-width: 640px; padding: 4px 6px calc(4px + env(safe-area-inset-bottom, 0px)); }
.app.is-sub .tabs { display: none; }
.tab { display: grid; justify-items: center; gap: 2px; padding: 7px 2px 5px; background: none; border: 0; border-radius: var(--radius-sm); color: var(--tabs-text); font-size: 12px; font-weight: 600; min-height: 52px; }
.tab.is-on { color: var(--tabs-on); }
.tab.is-on .tab-icon { background: var(--tabs-on-bg); }
.tab-icon { display: grid; place-items: center; width: 44px; height: 28px; border-radius: 999px; }
.tab-action .tab-icon { background: var(--cta); color: var(--cta-text); }

/* nagłówek podstrony */
.sub-header { display: flex; align-items: center; gap: 8px; margin: -4px -6px 0; position: sticky; top: 0; z-index: 20; background: var(--bg); padding: 8px 0; padding-top: calc(8px + env(safe-area-inset-top, 0px)); }
.sub-header-titles { flex: 1; min-width: 0; }
.sub-header h1 { font-size: 24px; line-height: 1.1; font-weight: 700; }
.sub-header p { font-size: 13px; color: var(--muted); }
.sub-header-actions { display: flex; gap: 4px; }
.icon-btn { display: grid; place-items: center; width: 44px; height: 44px; flex: none; background: none; border: 0; border-radius: var(--radius-sm); color: var(--text); }
.icon-btn:active { background: var(--panel-2); }

/* sekcje, karty, pola */
.section { display: flex; flex-direction: column; gap: 8px; min-width: 0; }
.section-label { font: 700 13px/1.2 var(--font); letter-spacing: .06em; text-transform: uppercase; color: var(--muted); }
.card { background: var(--panel); border: var(--card-border); border-radius: var(--radius); padding: 14px; display: flex; flex-direction: column; gap: 10px; box-shadow: var(--shadow); min-width: 0; }
.card h1 { font-size: 26px; line-height: 1.1; }
.card h2 { font-size: 21px; line-height: 1.15; }
.field { display: flex; flex-direction: column; gap: 5px; min-width: 0; }
.field > label, .field-label { font-size: 13px; font-weight: 600; color: var(--muted); }
.hint { font-size: 12.5px; color: var(--muted); }
.input { width: 100%; min-height: 46px; padding: 10px 12px; background: var(--input-bg); border: 1px solid var(--input-line); border-radius: var(--radius-sm); font-size: 16px; }
.input:focus { outline: none; border-color: var(--focus); box-shadow: 0 0 0 2px var(--focus-ring); }
.textarea { min-height: 120px; resize: vertical; line-height: 1.45; }
select.input { appearance: auto; }
.grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.form-actions { display: flex; gap: 8px; }
.form-actions .btn-block { flex: 1; }
.toolbar { display: flex; align-items: center; justify-content: space-between; gap: 8px; }
.search { flex: 1; display: flex; align-items: center; gap: 8px; padding: 0 12px; background: var(--input-bg); border: 1px solid var(--input-line); border-radius: var(--radius-sm); color: var(--muted); }
.search .input { border: 0; background: none; padding-left: 0; box-shadow: none; color: var(--text); }
.details > summary, .sheet-details > summary { cursor: pointer; padding: 10px 2px; font-weight: 600; color: var(--muted); }
.details[open] > summary, .sheet-details[open] > summary { color: var(--text); }
.details > .card, .details > .list { margin-top: 4px; }

/* przyciski */
.btn { display: inline-flex; align-items: center; justify-content: center; gap: 8px; min-height: 46px; padding: 0 16px; background: var(--btn-bg); color: var(--text); border: 1px solid var(--btn-line); border-radius: var(--radius-sm); font-weight: 600; font-size: 15px; text-align: center; }
.btn:active { transform: translateY(1px); }
.btn:disabled { opacity: .55; cursor: default; }
.btn-block { width: 100%; }
.btn-small { min-height: 38px; padding: 0 12px; font-size: 14px; }
.btn-primary { background: var(--cta); border-color: var(--cta); color: var(--cta-text); }
.btn-secondary { background: var(--accent); border-color: var(--accent); color: var(--accent-text); }
.btn-danger { background: var(--loss); border-color: var(--loss); color: #fff; }
.btn-link { background: none; border-color: transparent; color: var(--muted); text-decoration: underline; min-height: 38px; align-self: flex-start; padding: 0; }
.btn-record { width: 100%; background: var(--panel-2); border-color: var(--line-strong); }
.btn-record.is-rec { background: var(--rec); border-color: var(--rec); color: #fff; animation: pulse 1.4s ease-in-out infinite; }
.rec-time { font: 700 17px var(--font-num); font-variant-numeric: tabular-nums; margin-left: auto; }
@keyframes pulse { 50% { opacity: .78; } }
@media (prefers-reduced-motion: reduce) { .btn-record.is-rec { animation: none; } .btn:active { transform: none; } }

.chips { display: flex; flex-wrap: wrap; gap: 6px; }
.chip { min-height: 40px; padding: 0 13px; background: var(--btn-bg); border: 1px solid var(--btn-line); border-radius: var(--chip-radius); font-size: 14.5px; font-weight: 600; color: var(--text); }
.chip.is-on { background: var(--accent); border-color: var(--accent); color: var(--accent-text); }
.segmented { display: grid; grid-template-columns: repeat(3, 1fr); gap: 4px; padding: 4px; background: var(--panel-2); border-radius: var(--radius-sm); }
.segmented .chip { border-color: transparent; background: none; border-radius: calc(var(--radius-sm) - 2px); }
.segmented .chip.is-on { background: var(--accent); color: var(--accent-text); }

/* listy i wiersze */
.list { display: flex; flex-direction: column; gap: var(--list-gap); min-width: 0; }
.list-row { display: flex; align-items: center; gap: 10px; width: 100%; min-height: 58px; padding: 10px 12px; text-align: left; background: var(--panel); border: var(--card-border); border-left: var(--edge-width) solid var(--edge, var(--line)); border-radius: var(--radius-sm); min-width: 0; }
.list-row:active { background: var(--panel-2); }
.list-row.is-static:active { background: var(--panel); }
.edge-win { --edge: var(--win); }
.edge-loss { --edge: var(--loss); }
.edge-next { --edge: var(--warn); }
.row-main { flex: 1; display: grid; gap: 1px; min-width: 0; text-align: left; }
.row-btn { background: none; border: 0; padding: 0; }
.row-main strong { font-weight: 600; font-size: 16px; }
.row-main small { font-size: 13px; color: var(--muted); }
.row-note { font-size: 13.5px; color: var(--note-text); display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; margin-top: 3px; }
.row-note.is-pinned { font-weight: 600; }
.row-kicker, .row-phase { font: 700 11.5px/1.2 var(--font); letter-spacing: .06em; text-transform: uppercase; color: var(--kicker); }
.row-right { display: flex; flex-direction: column; align-items: flex-end; gap: 4px; flex: none; color: var(--muted); }
.row-right.row-chev { flex-direction: row; }
.row-icon { color: var(--muted); }
.note-count { display: inline-flex; align-items: center; gap: 3px; font-size: 12px; font-weight: 600; }
.chip-status { font-size: 12.5px; font-weight: 600; padding: 3px 9px; border-radius: 999px; background: var(--panel-2); color: var(--muted); white-space: nowrap; }
.chip-status.is-next { background: var(--warn-bg); color: var(--warn); }
.chip-status.is-live { background: var(--rec); color: #fff; }
.score { display: inline-flex; align-items: baseline; gap: 5px; padding: 2px 9px; border-radius: var(--radius-sm); font-family: var(--font-num); font-variant-numeric: tabular-nums; white-space: nowrap; background: var(--panel-2); color: var(--muted); font-size: 13px; }
.score b { font-size: var(--score-size); font-weight: 700; line-height: 1.1; }
.score i { font-style: normal; font-weight: 700; font-size: 14px; }
.score-win { background: var(--win-bg); color: var(--win); }
.score-loss { background: var(--loss-bg); color: var(--loss); }
.h2h-mini { font: 700 17px var(--font-num); font-variant-numeric: tabular-nums; color: var(--text); }
.place { display: grid; justify-items: center; line-height: 1; color: var(--text); }
.place b { font: 700 24px var(--font-num); }
.place small { font-size: 11px; color: var(--muted); }
.list-row.is-hero { padding: 14px; border-left-width: 6px; background: var(--hero-bg); }
.list-row.is-hero .row-main strong { font: 700 24px/1.1 var(--font-num); }
.empty { padding: 22px 14px; text-align: center; color: var(--muted); border: 1px dashed var(--line-strong); border-radius: var(--radius); display: grid; gap: 12px; justify-items: center; font-size: 14.5px; }

/* kafelki statystyk */
.tiles { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.tile { display: grid; gap: 1px; padding: 11px 12px; background: var(--panel); border: var(--card-border); border-radius: var(--radius-sm); min-width: 0; }
.card .tile { background: var(--panel-2); border: 0; }
.tile-label { font-size: 12.5px; color: var(--muted); }
.tile-value { font: 700 22px/1.15 var(--font-num); font-variant-numeric: tabular-nums; }
.tile small { font-size: 12.5px; color: var(--muted); }
.hero-score { display: grid; gap: 8px; }
.hero-score-top { display: flex; align-items: flex-end; justify-content: space-between; gap: 10px; }
.hero-score-top strong { display: block; font: 700 28px/1.05 var(--font-num); font-variant-numeric: tabular-nums; }
.hero-pct { font: 700 34px/1 var(--font-num); font-variant-numeric: tabular-nums; }
.win-bar { width: 100%; height: 8px; appearance: none; border: 0; border-radius: 999px; overflow: hidden; background: var(--loss); }
.win-bar::-webkit-progress-bar { background: var(--loss); }
.win-bar::-webkit-progress-value { background: var(--win); }
.win-bar::-moz-progress-bar { background: var(--win); }

/* ekran zawodów */
.comp-head h1 { font-size: 28px; }
.comp-actions { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.comp-actions .muted { margin-right: auto; }
.final-card { align-items: center; text-align: center; }
.final-place { display: flex; align-items: baseline; gap: 8px; }
.final-place b { font: 700 64px/1 var(--font-num); }
.demo-bar { border-style: dashed; }
.demo-bar-head { display: grid; gap: 2px; }
.demo-bar-head span { font-size: 13.5px; color: var(--muted); }
.cta-card h2 { font-size: 24px; }
.sheet-wrap { overflow-x: auto; -webkit-overflow-scrolling: touch; }
.sheet { border-collapse: collapse; width: 100%; font-size: 13.5px; font-variant-numeric: tabular-nums; background: var(--panel); }
.sheet th, .sheet td { border: 1px solid var(--sheet-line); padding: 6px 7px; text-align: center; min-width: 34px; }
.sheet th { font: 700 14px var(--font-num); background: var(--panel-2); }
.sheet .sheet-name { text-align: left; min-width: 150px; }
.sheet .sheet-name strong { display: block; font-weight: 600; }
.sheet .sheet-name small { color: var(--muted); font-size: 12px; }
.sheet-diag { background: var(--sheet-diag); }
.sheet-v { background: var(--win-bg); color: var(--win); font-weight: 700; }
.sheet-d { background: var(--loss-bg); color: var(--loss); font-weight: 600; }
.sheet tr.is-me .sheet-name, .sheet tr.is-me th { box-shadow: inset 4px 0 0 var(--text); }
.tournament { display: grid; gap: var(--list-gap); margin-bottom: 8px; }
.tournament-head { display: grid; padding: 6px 2px 2px; }
.tournament-head small { color: var(--muted); font-size: 13px; }
.qr-video { width: 100%; border-radius: var(--radius-sm); background: #000; aspect-ratio: 1; object-fit: cover; }

/* notatka przy walce */
.score-card { align-items: center; text-align: center; }
.score-card .score b { font-size: 44px; }
.score-card .score i { font-size: 22px; }
.score-card .score { padding: 6px 18px; }
.score-card .field { align-self: stretch; text-align: left; }
.score-row { display: flex; align-items: flex-end; justify-content: center; gap: 12px; }
.score-side { display: grid; gap: 4px; justify-items: center; font-size: 13px; font-weight: 600; color: var(--muted); }
.score-input { width: 92px; min-height: 64px; text-align: center; font: 700 34px var(--font-num); padding: 4px; }
.score-colon { font: 700 34px var(--font-num); padding-bottom: 12px; color: var(--muted); }
.rival-brief .brief-head { display: flex; justify-content: space-between; align-items: flex-start; gap: 10px; }
.brief-head strong { display: block; font: 700 22px/1.1 var(--font-num); }
.brief-head small { color: var(--muted); font-size: 13px; }
.h2h { display: grid; justify-items: end; line-height: 1.05; flex: none; }
.h2h b { font: 700 28px var(--font-num); font-variant-numeric: tabular-nums; }
.h2h small { font-size: 11.5px; }
.callout { padding: 10px 12px; background: var(--panel-2); border-left: 4px solid var(--line-strong); border-radius: var(--radius-sm); display: grid; gap: 4px; font-size: 14.5px; }
.callout.is-win { border-left-color: var(--win); }
.callout.is-loss { border-left-color: var(--loss); }
.plain-list { padding-left: 18px; display: grid; gap: 5px; }
.editor { display: grid; gap: 10px; }
.editor-controls { display: grid; gap: 8px; }
.editor-controls:empty, .rec-status:empty { display: none; }
.player { width: 100%; }
.notes { display: grid; gap: var(--list-gap); }
.note { background: var(--panel); border: var(--card-border); border-radius: var(--radius-sm); padding: 12px; display: grid; gap: 6px; white-space: pre-wrap; }
.note.is-editing { outline: 2px solid var(--focus); }
.note footer { display: flex; align-items: center; justify-content: space-between; gap: 8px; color: var(--muted); }
.note-actions { display: flex; }
.note-actions .icon-btn { width: 40px; height: 40px; color: var(--muted); }
.picked { display: flex; align-items: center; justify-content: space-between; gap: 10px; padding: 10px 12px; background: var(--panel-2); border-radius: var(--radius-sm); }
.picked small { display: block; color: var(--muted); font-size: 13px; }
.suggest { display: grid; gap: 4px; }
.suggest .list-row { min-height: 48px; padding: 6px 12px; }

/* powitanie, blokada */
.onboarding { display: flex; flex-direction: column; gap: 16px; padding-top: 10px; }
.hero { display: grid; gap: 8px; justify-items: start; }
.hero img { border-radius: 14px; }
.hero h1 { font-size: 38px; line-height: 1; }
.hero p { font-size: 17px; color: var(--muted); max-width: 30ch; }
.promise { list-style: none; padding: 0; display: grid; gap: 8px; font-size: 14.5px; color: var(--muted); }
.promise li { padding-left: 12px; border-left: 4px solid var(--line-strong); }
.promise li:nth-child(1) { border-left-color: var(--side-red); }
.promise li:nth-child(2) { border-left-color: var(--side-green); }
.promise strong { color: var(--text); }
.gate { margin: auto; width: 100%; max-width: 360px; padding: 24px 18px; display: grid; gap: 12px; text-align: center; justify-items: center; }
.gate > * { width: 100%; }
.gate .btn-link { justify-self: center; width: auto; }
.brand-mark { width: 60px !important; height: 60px; display: grid; place-items: center; border-radius: 16px; background: var(--accent); color: var(--accent-text); }
.pin-input { text-align: center; letter-spacing: .4em; font: 700 26px var(--font-num); }

/* komunikaty i okna */
.toast-host { position: fixed; left: 0; right: 0; bottom: calc(var(--tabs-space) + 12px + env(safe-area-inset-bottom, 0px)); display: grid; justify-items: center; padding: 0 12px; z-index: 100; pointer-events: none; }
.toast { pointer-events: auto; display: flex; align-items: center; gap: 12px; max-width: 520px; padding: 11px 14px; background: var(--toast-bg); color: var(--toast-text); border-radius: var(--radius-sm); font-size: 14.5px; box-shadow: 0 6px 20px rgba(0, 0, 0, .28); }
.toast-action { flex: none; background: none; border: 0; color: inherit; font-weight: 700; text-decoration: underline; padding: 6px 2px; }
.dialog { width: min(92vw, 440px); max-height: 86dvh; padding: 18px; background: var(--panel); color: var(--text); border: var(--card-border); border-radius: var(--radius); overflow: auto; }
.dialog::backdrop { background: rgba(10, 12, 15, .6); }
.dialog-title { font-size: 23px; line-height: 1.15; margin-bottom: 8px; }
.dialog-text { color: var(--muted); font-size: 15px; margin-bottom: 12px; }
.dialog-list { display: grid; gap: var(--list-gap); margin-bottom: 12px; }
.dialog-actions { display: flex; gap: 8px; justify-content: flex-end; margin-top: 6px; }

/* wygląd, treści */
.skin-list { display: grid; gap: 12px; }
.skin-card { display: grid; grid-template-columns: 132px 1fr; gap: 12px; align-items: center; padding: 10px; text-align: left; background: var(--panel); border: 2px solid var(--line); border-radius: var(--radius); }
.skin-card.is-on { border-color: var(--text); }
.skin-text { display: grid; gap: 3px; }
.skin-text strong { font: 700 20px var(--font-num); }
.skin-text small { font-size: 13px; color: var(--muted); }
.skin-preview { display: grid; gap: 4px; padding: 0 0 6px; background: var(--bg); color: var(--text); border-radius: 8px; overflow: hidden; border: 1px solid var(--line); font-size: 9px; }
.sp-top { display: flex; align-items: center; gap: 4px; padding: 5px 6px; background: var(--topbar-bg); color: var(--topbar-text); border-bottom: 2px solid var(--side-green); font: 700 10px var(--font-num); }
.sp-top i { width: 9px; height: 9px; border-radius: 2px; background: var(--side-red); }
.sp-row { display: flex; justify-content: space-between; gap: 4px; margin: 0 6px; padding: 4px 5px; background: var(--panel); border: var(--card-border); border-left: 3px solid var(--line); border-radius: calc(var(--radius-sm) / 2); }
.sp-row b { font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.sp-row em { font-style: normal; font-weight: 700; white-space: nowrap; }
.sp-next { border-left-color: var(--warn); } .sp-next em { color: var(--warn); }
.sp-win { border-left-color: var(--win); } .sp-win em { color: var(--win); }
.sp-loss { border-left-color: var(--loss); } .sp-loss em { color: var(--loss); }
.sp-nav { display: flex; justify-content: space-around; align-items: center; margin: 2px 6px 0; padding: 4px; background: var(--tabs-bg); border: 1px solid var(--tabs-line); border-radius: 5px; }
.sp-nav i { width: 9px; height: 5px; border-radius: 2px; background: var(--tabs-text); opacity: .6; }
.sp-nav .sp-act { width: 13px; height: 9px; background: var(--cta); opacity: 1; }
.prose { gap: 14px; }
.prose-block { display: grid; gap: 4px; }
.prose-block h2 { font-size: 19px; }
.prose-block p { font-size: 15px; color: var(--note-text); }

/* przypomnienie o kopii i ścieżka „Zmieniam telefon” */
.reminder { border-left: 5px solid var(--warn); }
.dialog-form { display: grid; gap: 10px; }
.step-head { display: flex; align-items: center; gap: 10px; }
.step-nr { flex: none; width: 32px; height: 32px; display: grid; place-items: center; border-radius: 50%; background: var(--accent); color: var(--accent-text); font: 700 17px var(--font-num); }
.step.is-done .step-nr { background: var(--win); color: #fff; }
ol.plain-list { padding-left: 20px; font-size: 14.5px; color: var(--note-text); }
p.callout { display: block; }
