/*
  Alldoo: arkusz aplikacji.

  PALETA (decyzja: spokojna, budząca zaufanie)
  Głęboka zieleń-turkus "szałwia/morska zieleń" jako kolor główny: kojarzy się ze wzrostem, spokojem i "da się"
  (bez złota marki ddwit i bez granatu). Tło ciepły papier zamiast chłodnej bieli, żeby aplikacja była przyjazna
  właścicielowi małej firmy, a nie "korporacyjna". Jeden kolor główny, reszta neutralna + czerwień błędu i zieleń sukcesu.
  Jedna czcionka: Manrope (woff2 lokalnie, latin + latin-ext).

  KONTRASTY (liczone: scripts/kontrast.py, WCAG 2.2)
  JASNY                                          CIEMNY
  tekst #16201D / tło #F5F3EE        15.05       tekst #E8F0ED / tło #0F1614        15.82
  tekst / karta #FFFFFF              16.69       tekst / karta #18211F              14.20
  tekst pomocniczy #44524D / tło      7.40       tekst pomocniczy #A8B8B2 / tło      8.88
  tekst pomocniczy / karta            8.20       tekst pomocniczy / karta            7.96
  kolor główny #0B6B5B jako tekst/tło 5.79       kolor główny #5CCDB4 jako tekst/tło 9.47
  kolor główny jako tekst/karta       6.43       kolor główny jako tekst/karta       8.50
  biały na przycisku #0B6B5B          6.43       #052019 na przycisku #5CCDB4        8.84
  biały na przycisku (hover) #08574A  8.49       #052019 na hover #7BDAC5           10.33
  obrys pól #66756F / karta (>=3)     4.84       obrys pól #7F9890 / karta           5.33
  obrys pól / tło                     4.36       obrys pól / tło                     5.93
  fokus #174EA6 / tło (>=3)           7.07       fokus #9DC1FF / tło                10.05
  fokus / karta                       7.85       fokus / karta                       9.02
  błąd #B3261E / jego tło #FDECEA     5.72       błąd #FF9E92 / jego tło #3A1D1A     7.70
  sukces #12683A / jego tło #E6F4EA   6.03       sukces #7DD9A0 / jego tło #16301F   8.33
  tekst / jasny pas #E2F0EC          14.23       tekst / pas #1D2D29                12.41
*/

@font-face {
  font-family: "Manrope"; font-style: normal; font-weight: 400 800; font-display: swap;
  src: url("/static/fonts/manrope-latin-ext.woff2") format("woff2");
  unicode-range: U+0100-02BA, U+02BD-02C5, U+02C7-02CC, U+02CE-02D7, U+02DD-02FF, U+0304, U+0308, U+0329, U+1D00-1DBF, U+1E00-1E9F, U+1EF2-1EFF, U+2020, U+20A0-20AB, U+20AD-20C0, U+2113, U+2C60-2C7F, U+A720-A7FF;
}
@font-face {
  font-family: "Manrope"; font-style: normal; font-weight: 400 800; font-display: swap;
  src: url("/static/fonts/manrope-latin.woff2") format("woff2");
  unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+0304, U+0308, U+0329, U+2000-206F, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD;
}

:root {
  color-scheme: light dark;
  --bg: #F5F3EE; --surface: #FFFFFF; --tint: #E2F0EC;
  --text: #16201D; --muted: #44524D;
  --primary: #0B6B5B; --on-primary: #FFFFFF; --primary-hover: #08574A; --primary-text: #0B6B5B;
  --line: #D9DED9; --control: #66756F; --focus: #174EA6;
  --danger: #B3261E; --danger-bg: #FDECEA; --ok: #12683A; --ok-bg: #E6F4EA;
  --shadow: 0 1px 2px rgb(22 32 29 / .08), 0 6px 20px rgb(22 32 29 / .06);
  --r: 16px; --r-sm: 10px;
  --font: "Manrope", system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #0F1614; --surface: #18211F; --tint: #1D2D29;
    --text: #E8F0ED; --muted: #A8B8B2;
    --primary: #5CCDB4; --on-primary: #052019; --primary-hover: #7BDAC5; --primary-text: #6FD9C0;
    --line: #2C3A36; --control: #7F9890; --focus: #9DC1FF;
    --danger: #FF9E92; --danger-bg: #3A1D1A; --ok: #7DD9A0; --ok-bg: #16301F;
    --shadow: 0 1px 2px rgb(0 0 0 / .4), 0 6px 20px rgb(0 0 0 / .3);
  }
}

*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; text-size-adjust: 100%; }
body {
  margin: 0; min-height: 100dvh; background: var(--bg); color: var(--text);
  font: 400 1.0625rem/1.6 var(--font); -webkit-font-smoothing: antialiased;
  display: flex; flex-direction: column;
}
h1, h2, h3 { line-height: 1.15; margin: 0 0 .5em; text-wrap: balance; letter-spacing: -.01em; }
h1 { font-size: clamp(2rem, 1.2rem + 4vw, 3.25rem); font-weight: 800; }
h2 { font-size: clamp(1.4rem, 1.1rem + 1.4vw, 1.9rem); font-weight: 800; }
h3 { font-size: 1.15rem; font-weight: 700; }
p { margin: 0 0 1em; text-wrap: pretty; }
a { color: var(--primary-text); text-underline-offset: .2em; text-decoration-thickness: .1em; }
a:hover { text-decoration-thickness: .18em; }
img, svg { max-width: 100%; }
[hidden] { display: none !important; }

:where(a, button, input, textarea, select, summary, [tabindex]):focus-visible {
  outline: 3px solid var(--focus); outline-offset: 3px; border-radius: 6px;
}
.sr-only { position: absolute; width: 1px; height: 1px; margin: -1px; padding: 0; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; border: 0; }
.skip { position: absolute; left: 1rem; top: -4rem; background: var(--primary); color: var(--on-primary); padding: .75rem 1rem; border-radius: var(--r-sm); z-index: 100; font-weight: 700; }
.skip:focus { top: 1rem; }

/* Nagłówek aplikacji */
.top { display: flex; align-items: center; justify-content: space-between; gap: 1rem; padding: .75rem 1rem; max-width: 80rem; width: 100%; margin: 0 auto; }
.brand { display: inline-flex; align-items: center; gap: .6rem; color: var(--text); text-decoration: none; font-weight: 800; font-size: 1.3rem; letter-spacing: -.02em; min-height: 48px; }
.brand svg { width: 2.25rem; height: 2.25rem; flex: none; }
.top nav { display: flex; align-items: center; gap: .5rem; flex-wrap: wrap; justify-content: flex-end; }

/* Przyciski: min. 48 px */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: .5rem; min-height: 48px; padding: .7rem 1.4rem;
  border: 2px solid var(--primary); border-radius: 999px; background: var(--primary); color: var(--on-primary);
  font: 700 1.05rem/1.2 var(--font); text-decoration: none; cursor: pointer; transition: background-color .15s, transform .15s, box-shadow .15s;
}
.btn:hover { background: var(--primary-hover); border-color: var(--primary-hover); }
.btn:active { transform: translateY(1px); }
.btn--big { min-height: 56px; padding: .9rem 2rem; font-size: 1.15rem; }
.btn--ghost { background: transparent; color: var(--primary-text); border-color: var(--control); }
.btn--ghost:hover { background: var(--tint); border-color: var(--primary-text); }
.btn--danger { background: transparent; color: var(--danger); border-color: var(--danger); }
.btn--danger:hover { background: var(--danger-bg); }
.btn--small { min-height: 48px; padding: .5rem 1rem; font-size: .95rem; }
.btn[disabled], .btn[aria-disabled="true"] { opacity: .6; cursor: not-allowed; }
.btn svg { width: 1.2em; height: 1.2em; }

/* Powłoka */
main { flex: 1; width: 100%; max-width: 80rem; margin: 0 auto; padding: 1rem 1rem 3rem; }
main:focus { outline: none; }
.view > h1:first-child:focus { outline: none; }
.banner { margin: 0 auto; max-width: 80rem; width: 100%; padding: 0 1rem; }
.note { display: flex; gap: .75rem; align-items: flex-start; padding: .85rem 1rem; border-radius: var(--r-sm); background: var(--tint); border: 1px solid var(--line); margin: 0 0 1rem; }
.note--error { background: var(--danger-bg); border-color: var(--danger); color: var(--danger); font-weight: 600; }
.note--ok { background: var(--ok-bg); border-color: var(--ok); color: var(--ok); font-weight: 600; }
.note--offline { background: var(--danger-bg); border: 2px solid var(--danger); color: var(--danger); font-weight: 700; }
.note > p { margin: 0; }
.note .btn { margin-left: auto; flex: none; }

/* Ekran startowy */
.hero { display: grid; gap: 1.5rem; max-width: 46rem; margin: 1rem auto 0; }
.hero .lead { font-size: 1.2rem; color: var(--muted); }
.card { background: var(--surface); border: 1px solid var(--line); border-radius: var(--r); padding: 1.25rem; box-shadow: var(--shadow); }
.field { display: grid; gap: .4rem; margin: 0 0 1rem; }
.field > label, .legend { font-weight: 700; }
.hint { color: var(--muted); font-size: .95rem; margin: 0; }
input[type="text"], input[type="email"], input[type="tel"], textarea {
  width: 100%; min-height: 48px; padding: .7rem .9rem; font: inherit; color: var(--text); background: var(--surface);
  border: 2px solid var(--control); border-radius: var(--r-sm);
}
textarea { min-height: 9rem; resize: vertical; line-height: 1.5; }
textarea.big { min-height: 11rem; font-size: 1.15rem; }
::placeholder { color: var(--muted); opacity: 1; }
.actions { display: flex; flex-wrap: wrap; gap: .75rem; align-items: center; }
.tip { display: flex; gap: .5rem; flex-wrap: wrap; }
.chip { display: inline-flex; align-items: center; min-height: 48px; padding: .4rem 1rem; border: 2px solid var(--control); border-radius: 999px; background: transparent; color: var(--text); font: 600 .95rem/1.2 var(--font); cursor: pointer; text-align: left; }
.chip:hover { background: var(--tint); }
.install-hint { font-size: .95rem; }

/* Stan budowania */
.building { text-align: center; padding: 2.5rem 1rem; max-width: 36rem; margin: 2rem auto; }
.spinner { width: 3.5rem; height: 3.5rem; margin: 0 auto 1.25rem; border-radius: 50%; border: 5px solid var(--tint); border-top-color: var(--primary); }
@media (prefers-reduced-motion: no-preference) {
  .spinner { animation: obrot 1s linear infinite; }
  @keyframes obrot { to { transform: rotate(360deg); } }
  .view { animation: wejscie .25s ease-out; }
  @keyframes wejscie { from { opacity: 0; transform: translateY(6px); } to { opacity: 1; transform: none; } }
}
.progress-text { font-size: 1.2rem; font-weight: 700; margin: 0 0 .5rem; }

/* Moje strony */
.sites { list-style: none; margin: 0; padding: 0; display: grid; gap: .75rem; }
.site { display: flex; flex-wrap: wrap; gap: .75rem 1rem; align-items: center; justify-content: space-between; }
.site h2 { font-size: 1.2rem; margin: 0; }
.site h2 a { color: var(--text); }
.badge { display: inline-flex; align-items: center; gap: .35rem; padding: .15rem .7rem; border-radius: 999px; font-weight: 700; font-size: .9rem; border: 2px solid var(--control); color: var(--muted); }
.badge--live { border-color: var(--ok); color: var(--ok); background: var(--ok-bg); }
.site-meta { display: flex; gap: .75rem; align-items: center; flex-wrap: wrap; }
.site-meta a { overflow-wrap: anywhere; }

/* Edytor: telefon = podgląd u góry; od ~60rem obok panelu (container query) */
.editor-wrap { container: edytor / inline-size; }
.editor { display: grid; gap: 1rem; grid-template-columns: minmax(0, 1fr); }
.editor-head { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: .5rem 1rem; margin-bottom: .75rem; }
.editor-head h1 { font-size: 1.4rem; margin: 0; }
.preview { position: relative; border: 2px solid var(--control); border-radius: var(--r); overflow: hidden; background: #fff; height: min(58svh, 34rem); min-height: 18rem; }
.preview iframe { width: 100%; height: 100%; border: 0; display: block; background: #fff; }
.preview-status { position: absolute; inset: 0; display: grid; place-items: center; background: var(--surface); color: var(--text); font-weight: 700; }
.preview-status[hidden] { display: none; }
.panel { background: var(--surface); border: 1px solid var(--line); border-radius: var(--r); box-shadow: var(--shadow); min-width: 0; }
@container edytor (min-width: 60rem) {
  .editor { grid-template-columns: minmax(0, 1.25fr) minmax(24rem, 1fr); align-items: start; }
  .preview { height: calc(100svh - 11rem); min-height: 28rem; }
  .panel { max-height: calc(100svh - 11rem); min-height: 28rem; display: flex; flex-direction: column; }
  .panel > .tabpanel { overflow-y: auto; }
}
.tabs { display: flex; border-bottom: 1px solid var(--line); }
.tab { flex: 1 1 0; min-height: 52px; padding: .6rem .5rem; background: transparent; border: 0; border-bottom: 4px solid transparent; color: var(--muted); font: 700 .98rem/1.2 var(--font); cursor: pointer; border-radius: var(--r) var(--r) 0 0; }
.tab:hover { background: var(--tint); }
.tab[aria-selected="true"] { color: var(--primary-text); border-bottom-color: var(--primary); }
.tabpanel { padding: 1.1rem; }
.tabpanel:focus { outline: none; }
.tabpanel > :last-child { margin-bottom: 0; }
.change-log { margin-top: 1rem; }

/* Formularz bloków */
.blocks { display: grid; gap: .75rem; }
details.block { border: 1px solid var(--control); border-radius: var(--r-sm); background: var(--bg); }
details.block > summary { cursor: pointer; font-weight: 800; padding: .85rem 1rem; min-height: 48px; display: flex; align-items: center; gap: .5rem; list-style: none; }
details.block > summary::-webkit-details-marker { display: none; }
details.block > summary::before { content: ""; width: .6rem; height: .6rem; border-right: 3px solid currentColor; border-bottom: 3px solid currentColor; transform: rotate(-45deg); transition: transform .15s; flex: none; }
details.block[open] > summary::before { transform: rotate(45deg); }
.block-body { padding: 0 1rem 1rem; }
fieldset { border: 0; margin: 0; padding: 0; min-width: 0; }
.item { border: 1px solid var(--line); border-radius: var(--r-sm); background: var(--surface); padding: .9rem; margin: 0 0 .75rem; }
.item legend { padding: 0 .4rem; font-weight: 700; color: var(--muted); }
.item-head { display: flex; justify-content: space-between; align-items: center; gap: .5rem; margin-bottom: .5rem; font-weight: 700; }
.swatches { display: grid; grid-template-columns: repeat(auto-fill, minmax(9.5rem, 1fr)); gap: .6rem; margin-top: .5rem; }
.swatch { position: relative; display: flex; align-items: center; gap: .6rem; min-height: 48px; padding: .5rem .75rem; border: 2px solid var(--control); border-radius: var(--r-sm); background: var(--surface); cursor: pointer; font-weight: 600; }
.swatch input { position: absolute; opacity: 0; inset: 0; width: 100%; height: 100%; margin: 0; cursor: pointer; }
.swatch .dot { width: 1.5rem; height: 1.5rem; border-radius: 50%; flex: none; border: 2px solid var(--surface); box-shadow: 0 0 0 1px var(--control); }
.swatch:has(:checked) { border-color: var(--primary-text); box-shadow: inset 0 0 0 2px var(--primary-text); background: var(--tint); }
.swatch:has(:checked)::after { content: "\2713"; margin-left: auto; font-weight: 800; color: var(--primary-text); }
.swatch:has(:focus-visible) { outline: 3px solid var(--focus); outline-offset: 3px; }
.savebar { display: flex; flex-wrap: wrap; gap: .75rem; align-items: center; margin-top: 1rem; }
.dirty { color: var(--muted); font-weight: 600; }

/* Publikacja */
.url-box { display: flex; flex-wrap: wrap; gap: .5rem; align-items: center; padding: .75rem 1rem; border: 2px solid var(--ok); border-radius: var(--r-sm); background: var(--ok-bg); }
.url-box a { font-weight: 800; overflow-wrap: anywhere; color: var(--ok); }
dialog { width: min(32rem, calc(100% - 2rem)); padding: 1.5rem; border: 2px solid var(--control); border-radius: var(--r); background: var(--surface); color: var(--text); }
dialog::backdrop { background: rgb(8 14 12 / .65); }
dialog h2 { font-size: 1.4rem; }

footer { padding: 1.5rem 1rem 2rem; text-align: center; color: var(--muted); font-size: .95rem; }
footer p { margin: 0; }

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation: none !important; transition: none !important; scroll-behavior: auto !important; }
}
@media (forced-colors: active) {
  .btn, .chip, .tab, .swatch { border: 2px solid ButtonText; }
  .tab[aria-selected="true"] { border-bottom-color: Highlight; }
}
@media print { .top, .banner, footer { display: none; } }
