/* fituj — baza: reset, typografia, kontrolki wspólne dla strony i aplikacji. */

*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; text-size-adjust: 100%; }
body {
  margin: 0; min-height: 100svh;
  background: var(--paper); color: var(--ink);
  font: 400 var(--fs-body)/1.55 var(--sans);
  font-feature-settings: 'ss01', 'tnum' 0;
  -webkit-font-smoothing: antialiased;
}
img, svg, video, canvas { display: block; max-width: 100%; }
img { height: auto; }
h1, h2, h3, h4, p, figure, blockquote, ul, ol, dl, dd { margin: 0; }
ul[role='list'], ol[role='list'] { list-style: none; padding: 0; }
a { color: inherit; text-underline-offset: .18em; text-decoration-thickness: 1px; }
button, input, select, textarea { font: inherit; color: inherit; }
button { cursor: pointer; }
:where(button, [role='button'], a, input, select, textarea, summary):focus-visible {
  outline: 2px solid var(--accent); outline-offset: 3px; border-radius: 4px;
}
::selection { background: var(--ink); color: var(--paper); }
[hidden] { display: none !important; }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip-path: inset(50%); white-space: nowrap; }
.num { font-variant-numeric: tabular-nums; }
.mono { font-family: var(--mono); font-variant-numeric: tabular-nums; }
.muted { color: var(--muted); }
.serif { font-family: var(--serif); font-weight: 400; }

/* ── Znak „fituj” ─────────────────────────────────────────────── */
.wordmark {
  font: italic 400 28px/1 var(--serif); letter-spacing: -.01em; text-decoration: none;
  display: inline-flex; align-items: baseline; color: var(--ink);
}
.wordmark { --btn4: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 100 100'%3E%3Cpath d='M0 50a50 50 0 1 0 100 0a50 50 0 1 0-100 0zM28.1 28.6a8 8 0 1 0 16 0a8 8 0 1 0-16 0zM63.3 36.1a8 8 0 1 0 16 0a8 8 0 1 0-16 0zM20.6 63.8a8 8 0 1 0 16 0a8 8 0 1 0-16 0zM55.8 71.3a8 8 0 1 0 16 0a8 8 0 1 0-16 0z' fill-rule='evenodd'/%3E%3C/svg%3E"); --btn2: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 100 100'%3E%3Cpath d='M0 50a50 50 0 1 0 100 0a50 50 0 1 0-100 0zM24 55.8a8 8 0 1 0 16 0a8 8 0 1 0-16 0zM59.9 44.1a8 8 0 1 0 16 0a8 8 0 1 0-16 0z' fill-rule='evenodd'/%3E%3C/svg%3E"); }
/* Kropki nad „ı” i „ȷ” to guziki (brand/logo.mjs): pomarańczowy z 4 dziurkami, tuszowy z 2. Dziurki = maska, więc prześwituje tło. */
.wordmark .i, .wordmark .j { position: relative; margin-left: .03em; }
.wordmark .i::after, .wordmark .j::after {
  content: ''; position: absolute; top: .18em; left: .21em; width: .145em; height: .145em;
  background: var(--accent); transform: translate(-50%, -50%);
  -webkit-mask: var(--btn4) center / contain no-repeat; mask: var(--btn4) center / contain no-repeat;
}
.wordmark .j::after {
  left: .21em; width: .125em; height: .125em; background: currentColor;
  -webkit-mask-image: var(--btn2); mask-image: var(--btn2);
}
.wordmark .i-stem { color: inherit; }

/* ── Przyciski: pigułki, jeden kolor wypełnienia ──────────────── */
.btn {
  --bg: var(--ink); --fg: var(--paper);
  display: inline-flex; align-items: center; justify-content: center; gap: .5em;
  min-height: 44px; padding: 0 20px; border: 0; border-radius: var(--r-pill);
  background: var(--bg); color: var(--fg); font-weight: 500; font-size: 15px; line-height: 1;
  text-decoration: none; white-space: nowrap;
  transition: transform var(--t-fast) var(--ease-out), background-color var(--t-fast), opacity var(--t-fast);
}
.btn:hover { --bg: color-mix(in oklab, var(--ink) 86%, var(--paper)); }
.btn:active { transform: scale(.97); }
.btn[disabled], .btn[aria-disabled='true'] { opacity: .45; pointer-events: none; }
.btn--ghost { --bg: transparent; --fg: var(--ink); box-shadow: inset 0 0 0 1px var(--line); }
.btn--ghost:hover { --bg: var(--sunk); }
.btn--soft { --bg: var(--sunk); --fg: var(--ink); }
.btn--soft:hover { --bg: var(--line); }
.btn--accent { --bg: var(--accent); --fg: #FBF9F6; }
.btn--accent:hover { --bg: color-mix(in oklab, var(--accent) 88%, black); }
.btn--danger { --bg: transparent; --fg: var(--err); box-shadow: inset 0 0 0 1px color-mix(in oklab, var(--err) 40%, transparent); }
.btn--danger:hover { --bg: color-mix(in oklab, var(--err) 10%, transparent); }
.btn svg { width: 18px; height: 18px; flex: none; }
.btn--small { min-height: 36px; padding: 0 14px; font-size: 14px; }
.btn--block { width: 100%; }
.btn .spin { width: 14px; height: 14px; border-radius: 50%; border: 2px solid currentColor; border-right-color: transparent; animation: spin .7s linear infinite; }
@keyframes spin { to { transform: rotate(1turn); } }

.link-btn { background: none; border: 0; padding: 0; color: var(--ink); text-decoration: underline; text-underline-offset: .2em; text-decoration-color: var(--line); font-size: inherit; }
.link-btn:hover { text-decoration-color: currentColor; }
.icon-btn {
  display: inline-grid; place-items: center; width: 40px; height: 40px; border: 0; border-radius: var(--r-pill);
  background: transparent; color: var(--ink); transition: background-color var(--t-fast);
}
.icon-btn:hover { background: var(--sunk); }
.icon-btn svg { width: 20px; height: 20px; }

/* ── Pola formularzy ──────────────────────────────────────────── */
.field { display: grid; gap: 6px; }
.field > span, .field > label { font-size: var(--fs-small); color: var(--muted); }
.input, .select, .textarea {
  width: 100%; min-height: 46px; padding: 11px 14px; border-radius: var(--r-field);
  background: var(--card); border: 1px solid var(--line); color: var(--ink);
  transition: border-color var(--t-fast), background-color var(--t-fast);
}
.textarea { min-height: 96px; resize: vertical; line-height: 1.5; }
.select { appearance: none; padding-right: 40px; background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='8' fill='none' stroke='%236E6A63' stroke-width='1.6'%3E%3Cpath d='M1 1.5l5 5 5-5'/%3E%3C/svg%3E"); background-repeat: no-repeat; background-position: right 16px center; }
.input:hover, .select:hover, .textarea:hover { border-color: color-mix(in oklab, var(--line) 50%, var(--muted)); }
.input:focus, .select:focus, .textarea:focus { outline: none; border-color: var(--ink); }
.input[aria-invalid='true'] { border-color: var(--err); }
.hint { font-size: var(--fs-small); color: var(--muted); }
.error-text { font-size: var(--fs-small); color: var(--err); }

.switch { display: inline-flex; align-items: center; gap: 12px; cursor: pointer; }
.switch input { appearance: none; width: 44px; height: 26px; border-radius: var(--r-pill); background: var(--line); position: relative; margin: 0; cursor: pointer; transition: background-color var(--t-ui); flex: none; }
.switch input::after { content: ''; position: absolute; top: 3px; left: 3px; width: 20px; height: 20px; border-radius: 50%; background: var(--card); transition: transform var(--t-ui) var(--ease-out); }
.switch input:checked { background: var(--ink); }
.switch input:checked::after { transform: translateX(18px); background: var(--paper); }
.switch input:disabled { opacity: .5; cursor: not-allowed; }

/* ── Chipy (pigułki) ──────────────────────────────────────────── */
.chip {
  display: inline-flex; align-items: center; gap: 8px; min-height: 36px; padding: 0 14px; border-radius: var(--r-pill);
  border: 0; background: var(--sunk); color: var(--ink); font-size: 14px; white-space: nowrap;
  transition: background-color var(--t-fast), color var(--t-fast), transform var(--t-fast);
}
.chip:hover { background: var(--line); }
.chip[aria-pressed='true'], .chip[aria-selected='true'], .chip.is-on { background: var(--ink); color: var(--paper); }
.chip:active { transform: scale(.97); }

/* ── Dialog, toast, popover ───────────────────────────────────── */
dialog.sheet {
  border: 0; padding: 0; border-radius: var(--r-card); background: var(--card); color: var(--ink);
  width: min(560px, calc(100vw - 24px)); max-height: calc(100svh - 32px);
  box-shadow: 0 30px 80px -20px rgb(0 0 0 / .35);
}
dialog.sheet::backdrop { background: rgb(18 17 16 / .45); }
dialog.sheet[open] { animation: rise var(--t-ui) var(--ease-out); }
.sheet__body { padding: 28px; display: grid; gap: 18px; }
.sheet__title { font: 400 30px/1.1 var(--serif); letter-spacing: -.01em; }
.sheet__actions { display: flex; gap: 10px; justify-content: flex-end; flex-wrap: wrap; }
@keyframes rise { from { opacity: 0; transform: translateY(12px); } }

.toasts { position: fixed; z-index: 90; right: 16px; bottom: 16px; display: grid; gap: 8px; width: min(380px, calc(100vw - 32px)); }
.toast {
  display: flex; gap: 12px; align-items: flex-start; padding: 14px 16px; border-radius: var(--r-card);
  background: var(--ink); color: var(--paper); font-size: 15px; line-height: 1.4;
  box-shadow: 0 16px 40px -16px rgb(0 0 0 / .4);
  animation: rise var(--t-ui) var(--ease-out);
}
.toast a { color: inherit; font-weight: 500; }
.toast__dot { width: 8px; height: 8px; border-radius: 50%; background: var(--accent); margin-top: 6px; flex: none; }
.toast--err .toast__dot { background: #F0796C; }
.toast--ok .toast__dot { background: #6FB58A; }
.toast button { margin-left: auto; background: none; border: 0; color: inherit; opacity: .7; padding: 0 0 0 8px; font-size: 18px; line-height: 1; }
.toast .toast__action { display: block; margin: 10px 0 0; padding: 7px 12px; border-radius: 999px; background: var(--paper); color: var(--ink); opacity: 1; font-size: 14px; font-weight: 500; line-height: 1.2; }
.toast.is-out { opacity: 0; transform: translateY(6px); transition: opacity var(--t-ui), transform var(--t-ui); }

/* ── Przejścia widoków ─────────────────────────────────────────── */
@media (prefers-reduced-motion: no-preference) {
  ::view-transition-old(root) { animation: 160ms ease-out both vt-out; }
  ::view-transition-new(root) { animation: 220ms var(--ease-out) both vt-in; }
}
@keyframes vt-out { to { opacity: 0; } }
@keyframes vt-in { from { opacity: 0; transform: translateY(8px); } }

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: 1ms !important; animation-iteration-count: 1 !important; transition-duration: 1ms !important; scroll-behavior: auto !important; }
}
.i18n-wait #landing, .i18n-wait #app { visibility: hidden; }
