:root {
  --ground: #f4f5f9;
  --ground-2: #eceef5;
  --card: #ffffff;
  --card-2: #f2f3f8;
  --ink: #14161f;
  --muted: #55575f;
  --faint: #83858e;
  --line: #e3e5ec;
  --line-2: #d3d6e1;
  --accent: #1a73e8;
  --accent-deep: #0b57bd;
  --ok: #188038;
  --warn: #a15c00;
  --font-display: "Bricolage Grotesque", "Instrument Sans", system-ui, sans-serif;
  --font-body: "Instrument Sans", system-ui, -apple-system, "Segoe UI", sans-serif;
  --font-mono: "JetBrains Mono", ui-monospace, "SF Mono", Menlo, Consolas, monospace;
  --r: 14px;
}
* { box-sizing: border-box; }
body {
  margin: 0;
  min-height: 100dvh;
  color: var(--ink);
  font-family: var(--font-body);
  font-size: 15px;
  line-height: 1.5;
  background:
    radial-gradient(1100px 620px at 18% -8%, rgba(26,115,232,0.08), transparent 60%),
    radial-gradient(900px 700px at 85% 105%, rgba(11,87,189,0.06), transparent 55%),
    linear-gradient(180deg, var(--ground) 0%, var(--ground-2) 100%);
  background-attachment: fixed;
  padding: 44px 24px 24px;
}

/* ---------- masthead ---------- */
.masthead { position: relative; text-align: center; margin-bottom: 28px; }
.lang-switch {
  position: absolute; top: 2px; right: 0; display: flex; gap: 4px;
}
.lang-switch button {
  padding: 5px 9px; border-radius: 7px; border: 1px solid var(--line-2);
  background: var(--card); color: var(--faint); font: inherit; font-size: 11.5px;
  font-weight: 600; letter-spacing: .03em; cursor: pointer; transition: .12s;
}
.lang-switch button:hover { color: var(--ink); border-color: var(--muted); }
.lang-switch button.on { color: #fff; background: var(--accent); border-color: var(--accent); }
@media (max-width: 560px) {
  .lang-switch { position: static; justify-content: center; margin-bottom: 10px; }
}
.wordmark {
  font-family: var(--font-display);
  font-weight: 700;
  font-size: clamp(38px, 7vw, 58px);
  letter-spacing: -0.03em;
  line-height: 1;
}
.wordmark span { color: var(--c); }
.tagline { margin: 12px auto 0; max-width: 52ch; color: var(--muted); font-size: 14.5px; }

/* ---------- presety ---------- */
.presets {
  display: flex; flex-wrap: wrap; gap: 8px; justify-content: center;
  max-width: 1180px; margin: 0 auto 26px;
}
.preset {
  display: inline-flex; align-items: center; gap: 7px;
  padding: 7px 13px 7px 10px;
  border-radius: 999px;
  border: 1px solid var(--line);
  background: var(--card);
  color: var(--muted);
  font: inherit; font-size: 13px;
  cursor: pointer;
  transition: .14s;
}
.preset:hover { background: var(--card-2); color: var(--ink); border-color: var(--line-2); }
.preset.on { border-color: var(--accent); color: var(--ink); background: rgba(26,115,232,.10); }
.preset .em { font-size: 14px; }

/* ---------- layout ---------- */
.workbench {
  display: grid;
  grid-template-columns: minmax(0,1fr) minmax(0, 430px);
  gap: 22px;
  max-width: 1180px;
  margin: 0 auto;
  align-items: start;
}
.panel {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: var(--r);
}
.output { position: sticky; top: 24px; padding: 20px; }

/* ---------- akordeon ---------- */
.fieldset { border-bottom: 1px solid var(--line); }
.fieldset:last-child { border-bottom: 0; }
.legend {
  width: 100%; display: flex; align-items: center; gap: 10px;
  padding: 16px 20px;
  background: none; border: 0; cursor: pointer;
  color: var(--ink); font: inherit; font-weight: 600; font-size: 15px;
  text-align: left;
}
.legend:hover { background: rgba(20,22,31,.035); }
.legend-num { font-family: var(--font-mono); font-size: 11px; color: var(--faint); letter-spacing: .08em; }
.legend-hint { margin-left: auto; font-weight: 400; font-size: 12.5px; color: var(--faint); }
.legend .chev {
  width: 8px; height: 8px; flex: 0 0 8px;
  border-right: 1.5px solid var(--faint); border-bottom: 1.5px solid var(--faint);
  transform: rotate(45deg) translateY(-2px); transition: .18s;
}
.fieldset.open .chev { transform: rotate(-135deg) translateY(-2px); }
.fieldset.open .legend-hint { color: var(--accent); }
.body { display: none; padding: 2px 20px 22px; }
.fieldset.open .body { display: block; }
.fieldset.touched .legend-num { color: var(--accent); }

/* ---------- pola ---------- */
.field { display: block; margin-bottom: 16px; }
.field:last-child { margin-bottom: 0; }
.lab { display: block; font-size: 13.5px; font-weight: 600; margin-bottom: 6px; }
.lab em { font-style: normal; font-weight: 400; color: var(--faint); }
.help { display: block; margin-top: 6px; font-size: 12.5px; color: var(--faint); line-height: 1.45; }
.help code { font-family: var(--font-mono); font-size: 11.5px; color: var(--muted); background: rgba(20,22,31,.05); padding: 1px 5px; border-radius: 4px; }

input[type=text], input[type=number], input[type=date], select, textarea {
  width: 100%;
  padding: 10px 12px;
  border-radius: 9px;
  border: 1px solid var(--line-2);
  background: var(--ground);
  color: var(--ink);
  font: inherit; font-size: 14px;
}
input::placeholder, textarea::placeholder { color: var(--faint); }
input:focus, select:focus, textarea:focus { outline: 2px solid var(--accent); outline-offset: -1px; border-color: transparent; }
select { appearance: none; background-image: linear-gradient(45deg,transparent 50%,var(--faint) 50%),linear-gradient(135deg,var(--faint) 50%,transparent 50%); background-position: calc(100% - 17px) 18px, calc(100% - 12px) 18px; background-size: 5px 5px; background-repeat: no-repeat; padding-right: 32px; }
input[type=date] { color-scheme: light; }

.row-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.row-3 { display: grid; grid-template-columns: 1fr auto 1fr 1fr; gap: 8px; align-items: center; }
.dots { font-family: var(--font-mono); color: var(--faint); }
.mini { display: block; font-size: 12.5px; color: var(--muted); }
.mini input { margin-top: 4px; }

/* ---------- segmented ---------- */
.segmented { display: flex; gap: 6px; background: var(--ground); padding: 4px; border-radius: 10px; border: 1px solid var(--line-2); }
.segmented.wrap { flex-wrap: wrap; }
.segmented label { flex: 1 1 auto; }
.segmented input { position: absolute; opacity: 0; pointer-events: none; }
.segmented span {
  display: block; text-align: center; padding: 7px 10px; border-radius: 7px;
  font-size: 13px; color: var(--muted); cursor: pointer; white-space: nowrap; transition: .12s;
}
.segmented label:hover span { color: var(--ink); }
.segmented input:checked + span { background: var(--accent); color: #fff; font-weight: 500; }
.segmented input:focus-visible + span { outline: 2px solid var(--accent); outline-offset: 2px; }

/* ---------- kafelki formatów ---------- */
.tiles { display: grid; grid-template-columns: repeat(auto-fill, minmax(112px,1fr)); gap: 8px; }
.tile { position: relative; }
.tile input { position: absolute; opacity: 0; pointer-events: none; }
.tile span {
  display: flex; flex-direction: column; gap: 2px;
  padding: 10px 12px; border-radius: 10px;
  border: 1px solid var(--line-2); background: var(--ground);
  cursor: pointer; transition: .12s;
}
.tile b { font-size: 13px; font-weight: 600; }
.tile i { font-style: normal; font-family: var(--font-mono); font-size: 10.5px; color: var(--faint); }
.tile:hover span { border-color: var(--muted); }
.tile input:checked + span { border-color: var(--accent); background: rgba(26,115,232,.10); }
.tile input:checked + span i { color: var(--accent); }

/* ---------- chipsy podpowiedzi ---------- */
.chips { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 8px; }
.chip {
  padding: 4px 9px; border-radius: 6px; border: 1px dashed var(--line-2);
  background: none; color: var(--faint); font: inherit; font-size: 11.5px;
  font-family: var(--font-mono); cursor: pointer; transition: .12s;
}
.chip:hover { color: var(--accent); border-color: var(--accent); border-style: solid; }

/* ---------- switches ---------- */
.switches { display: flex; flex-direction: column; gap: 10px; margin-top: 16px; }
.switch { display: grid; grid-template-columns: 34px 1fr; grid-template-rows: auto auto; column-gap: 11px; cursor: pointer; align-items: center; }
.switch input { position: absolute; opacity: 0; pointer-events: none; }
.switch > span {
  grid-row: 1 / 3; width: 34px; height: 20px; border-radius: 999px;
  background: var(--line-2); position: relative; transition: .16s;
}
.switch > span::after {
  content: ""; position: absolute; top: 3px; left: 3px; width: 14px; height: 14px;
  border-radius: 50%; background: var(--muted); transition: .16s;
}
.switch input:checked + span { background: var(--accent); }
.switch input:checked + span::after { transform: translateX(14px); background: #fff; }
.switch b { font-size: 13.5px; font-weight: 600; }
.switch i { font-style: normal; font-size: 12px; color: var(--faint); }

/* ---------- output ---------- */
.out-head { display: flex; align-items: baseline; justify-content: space-between; margin-bottom: 12px; }
.out-head h2 { font-family: var(--font-display); font-size: 17px; margin: 0; font-weight: 600; }
.ghost { background: none; border: 0; color: var(--faint); font: inherit; font-size: 12.5px; cursor: pointer; text-decoration: underline; text-underline-offset: 3px; }
.ghost:hover { color: var(--ink); }

#query {
  font-family: var(--font-mono); font-size: 13px; line-height: 1.65;
  min-height: 132px; resize: vertical; word-break: break-word;
}
.edited { margin: 8px 0 0; font-size: 12px; color: var(--warn); }
.linkish { background: none; border: 0; padding: 0; color: var(--accent); font: inherit; font-size: 12px; cursor: pointer; text-decoration: underline; }

.actions { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; margin-top: 14px; }
.btn {
  display: flex; align-items: center; justify-content: center;
  padding: 11px 14px; border-radius: 10px;
  border: 1px solid var(--line-2); background: var(--ground);
  color: var(--ink); font: inherit; font-size: 13.5px; font-weight: 500;
  cursor: pointer; text-decoration: none; transition: .13s;
}
.btn:hover { background: var(--card-2); border-color: var(--muted); }
.btn.primary { grid-column: 1 / -1; background: var(--accent); border-color: var(--accent); color: #fff; font-weight: 600; font-size: 14.5px; padding: 13px; }
.btn.primary:hover { background: var(--accent-deep); border-color: var(--accent-deep); }
.btn.small { padding: 9px 14px; font-size: 13px; }
.btn[aria-disabled=true] { opacity: .4; pointer-events: none; }

.alts { margin-top: 14px; font-size: 12.5px; }
.alts-lab { display: block; margin-bottom: 8px; color: var(--faint); }
.alts-row { display: flex; flex-wrap: wrap; gap: 6px; margin-bottom: 10px; }
.alt-btn {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 6px 11px 6px 8px; border-radius: 999px;
  border: 1px solid var(--line-2); background: var(--ground);
  color: var(--muted); text-decoration: none; font-size: 12px; font-weight: 500;
  transition: .12s;
}
.alt-btn:hover { color: var(--ink); border-color: var(--muted); background: var(--card-2); }
.alt-btn .ico { width: 15px; height: 15px; flex: 0 0 auto; border-radius: 3px; }
.actions .g-ico { width: 15px; height: 15px; margin-left: 6px; vertical-align: -3px; }
.alts[aria-disabled=true] .alt-btn, .alts[aria-disabled=true] .linkish { opacity: .4; pointer-events: none; }

.breakdown, .saved { margin-top: 22px; padding-top: 18px; border-top: 1px solid var(--line); }
.explain-note {
  margin: -4px 0 12px; padding: 8px 11px; border-radius: 8px;
  background: rgba(26,115,232,.06); border: 1px dashed var(--line-2);
  color: var(--muted); font-size: 12px; line-height: 1.5;
}
.breakdown h3, .saved h3 { font-family: var(--font-mono); font-size: 11px; letter-spacing: .12em; text-transform: uppercase; color: var(--faint); margin: 0 0 12px; font-weight: 500; }
#explain { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 9px; }
#explain li { display: grid; grid-template-columns: auto 1fr; gap: 9px; align-items: baseline; font-size: 12.5px; }
#explain code { font-family: var(--font-mono); font-size: 11.5px; color: var(--accent); background: rgba(26,115,232,.08); padding: 2px 6px; border-radius: 5px; white-space: nowrap; max-width: 190px; overflow: hidden; text-overflow: ellipsis; }
#explain .txt { color: var(--muted); }
li.empty { list-style: none; color: var(--faint); font-size: 12.5px; font-style: italic; display: block !important; }

.save-row { display: grid; grid-template-columns: 1fr auto; gap: 8px; margin-bottom: 12px; }
#savedList, #historyList { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 6px; }
#savedList li, #historyList li { display: flex; align-items: center; gap: 8px; font-size: 12.5px; }
#savedList button.name, #historyList button.name {
  flex: 1; text-align: left; background: none; border: 0; padding: 6px 8px; border-radius: 7px;
  color: var(--muted); font: inherit; font-size: 12.5px; cursor: pointer;
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
#savedList button.name:hover, #historyList button.name:hover { background: var(--card-2); color: var(--ink); }
#historyList button.name { font-family: var(--font-mono); font-size: 11.5px; }
.del { background: none; border: 0; color: var(--faint); cursor: pointer; font-size: 15px; line-height: 1; padding: 4px 6px; border-radius: 6px; }
.del:hover { color: #EA4335; background: rgba(234,67,53,.1); }

/* ---------- stopka, toast ---------- */
.imprint {
  max-width: 1180px; margin: 34px auto 0; padding-top: 16px;
  border-top: 1px solid var(--line);
  display: flex; justify-content: space-between; flex-wrap: wrap; gap: 8px;
  font-family: var(--font-mono); font-size: 11px; color: var(--faint);
}
.toast {
  position: fixed; bottom: 22px; left: 50%; transform: translate(-50%, 20px);
  background: var(--ink); color: var(--ground); padding: 10px 18px; border-radius: 999px;
  font-size: 13px; font-weight: 600; opacity: 0; pointer-events: none; transition: .22s; z-index: 50;
}
.toast.show { opacity: 1; transform: translate(-50%, 0); }

/* ---------- responsywność ---------- */
@media (max-width: 980px) {
  body { padding: 28px 16px 16px; }
  .workbench { grid-template-columns: 1fr; }
  .output { position: static; }
  .row-3 { grid-template-columns: 1fr auto 1fr; }
  .row-3 input:last-child { grid-column: 1 / -1; }
}
@media (max-width: 560px) {
  .segmented { flex-wrap: wrap; }
  .segmented label { flex: 1 1 42%; }
  .actions { grid-template-columns: 1fr; }
  .row-2 { grid-template-columns: 1fr; }
  .imprint { flex-direction: column; }
}

/* ---------- pasek nad sekcjami ---------- */
.panel-bar {
  display: flex; align-items: center; justify-content: space-between; gap: 12px;
  padding: 12px 20px; border-bottom: 1px solid var(--line);
  font-size: 12.5px; color: var(--faint);
}
.panel-bar-actions { display: flex; align-items: center; gap: 12px; flex: 0 0 auto; }

/* nagłówek sekcji pokazuje, co w środku jest ustawione */
.legend-hint.filled { color: var(--accent); font-weight: 500; }
.fieldset.open .legend-hint:not(.filled) { color: var(--muted); }

/* ---------- AROUND ---------- */
.row-around { display: grid; grid-template-columns: 1fr 72px 1fr; gap: 8px; align-items: center; }
.row-around input[type=number] { text-align: center; }

/* ---------- opcje grafiki ---------- */
.imgonly {
  margin: 16px 0; padding: 14px; border-radius: 11px;
  border: 1px dashed var(--line-2); background: rgba(26,115,232,.05);
}
.imgonly > .lab { color: var(--accent); font-family: var(--font-mono); font-size: 11px;
  letter-spacing: .1em; text-transform: uppercase; margin-bottom: 10px; }
.lab.small { font-weight: 500; font-size: 12.5px; color: var(--muted); }

/* ---------- skróty klawiszowe ---------- */
.keys {
  margin: 18px 0 0; padding-top: 14px; border-top: 1px solid var(--line);
  font-family: var(--font-mono); font-size: 10.5px; color: var(--faint); line-height: 1.7;
}

/* ---------- licznik słów pod zapytaniem ---------- */
.qmeta {
  display: flex; justify-content: space-between; gap: 12px; margin-top: 7px;
  font-family: var(--font-mono); font-size: 10.5px; color: var(--faint);
}
#qwarn { color: var(--warn); text-align: right; }

/* ---------- kafel własnego produktu ---------- */
#promo {
  margin-top: 18px; padding: 15px 16px; border-radius: 11px;
  border: 1px solid var(--line-2); background: linear-gradient(180deg, rgba(26,115,232,.08), rgba(26,115,232,.02));
}
#promo b { display: block; font-size: 13.5px; margin-bottom: 5px; }
#promo p { margin: 0 0 9px; font-size: 12.5px; color: var(--muted); line-height: 1.5; }
#promo a { font-size: 12.5px; font-weight: 600; color: var(--accent); text-decoration: none; }
#promo a:hover { text-decoration: underline; }

/* ---------- sloty reklamowe ---------- */
.adslot { display: block; margin: 20px 0 0; min-height: 90px; }
.adslot-wide { max-width: 1180px; margin: 32px auto 0; }

/* ---------- baner zgód ---------- */
.consent {
  position: fixed; left: 16px; right: 16px; bottom: 16px; z-index: 60;
  max-width: 660px; margin: 0 auto;
  display: flex; flex-wrap: wrap; align-items: center; gap: 14px;
  padding: 16px 18px; border-radius: 14px;
  background: var(--card); border: 1px solid var(--line-2);
  box-shadow: 0 18px 50px rgba(20,22,31,.18);
}
.consent-txt { flex: 1 1 280px; }
.consent-txt b { display: block; font-size: 13.5px; margin-bottom: 4px; }
.consent-txt p { margin: 0; font-size: 12px; color: var(--muted); line-height: 1.5; }
.consent-txt a { color: var(--accent); }
.consent-btns { display: flex; flex-wrap: wrap; gap: 7px; align-items: center; }
.consent-btns .btn { padding: 8px 13px; font-size: 12.5px; }
.consent-btns .btn.ghost {
  background: none; border-color: transparent; color: var(--muted); padding: 8px 6px;
}
.consent-btns .btn.ghost:hover { color: var(--ink); text-decoration: underline; }
.consent-panel { flex: 1 1 100%; }
.consent-opt {
  display: flex; align-items: flex-start; gap: 9px; margin-top: 10px; cursor: pointer;
}
.consent-opt input { margin-top: 3px; flex: 0 0 auto; }
.consent-opt span { font-size: 12px; color: var(--muted); line-height: 1.5; }
.consent-opt b { color: var(--ink); font-weight: 600; }
.consent-fine { margin: 10px 0 0; font-size: 11.5px; }

/* ---------- ściąga z operatorów ---------- */
.cheat { max-width: 1180px; margin: 46px auto 0; }
.cheat-toggle {
  width: 100%; display: flex; align-items: center; gap: 10px;
  padding: 16px 20px; border-radius: var(--r);
  background: var(--card); border: 1px solid var(--line);
  color: var(--ink); font: inherit; font-weight: 600; font-size: 15px;
  cursor: pointer; text-align: left;
}
.cheat-toggle:hover { background: var(--card-2); }
.cheat-toggle .legend-num { font-size: 13px; }
.cheat-hint { margin-left: auto; font-weight: 400; font-size: 12.5px; color: var(--faint); }
.cheat-toggle .chev {
  width: 8px; height: 8px; flex: 0 0 8px;
  border-right: 1.5px solid var(--faint); border-bottom: 1.5px solid var(--faint);
  transform: rotate(45deg) translateY(-2px); transition: .18s;
}
.cheat-toggle[aria-expanded="true"] .chev { transform: rotate(-135deg) translateY(-2px); }
.cheat-body {
  margin-top: 18px; padding: 24px 26px; border-radius: var(--r);
  background: var(--card); border: 1px solid var(--line);
}
.cheat-body h2:first-child { margin-top: 0; }
@media (max-width: 560px) {
  .cheat-hint { display: none; }
}
.cheat h2 {
  font-family: var(--font-display); font-size: 20px; font-weight: 600;
  margin: 34px 0 8px; letter-spacing: -0.01em;
}
.cheat h2:first-child { margin-top: 0; }
.cheat-lead { margin: 0 0 20px; color: var(--muted); font-size: 14px; max-width: 70ch; }
.cheat-table { width: 100%; border-collapse: collapse; font-size: 13.5px; }
.cheat-table th {
  text-align: left; padding: 9px 12px; border-bottom: 1px solid var(--line-2);
  font-family: var(--font-mono); font-size: 10.5px; letter-spacing: .1em;
  text-transform: uppercase; color: var(--faint); font-weight: 500;
}
.cheat-table td { padding: 11px 12px; border-bottom: 1px solid var(--line); vertical-align: top; color: var(--muted); line-height: 1.5; }
.cheat-table td:first-child, .cheat-table td:nth-child(2) { white-space: nowrap; }
.cheat-table tr:hover td { background: rgba(20,22,31,.02); }
code { font-family: var(--font-mono); font-size: 12px; color: var(--accent); }
.cheat-table td:first-child code { color: var(--ink); font-weight: 500; }

.notes { margin: 0; }
.notes dt { font-weight: 600; font-size: 14px; margin-top: 18px; }
.notes dd { margin: 5px 0 0; color: var(--muted); font-size: 13.5px; line-height: 1.55; max-width: 78ch; }

/* ---------- strona dokumentu (prywatność) ---------- */
body.doc { padding-top: 56px; }
.prose { max-width: 72ch; margin: 0 auto; }
.prose h1 { font-family: var(--font-display); font-size: clamp(28px,5vw,36px); margin: 0 0 14px; letter-spacing: -0.02em; }
.prose h2 { font-family: var(--font-display); font-size: 19px; font-weight: 600; margin: 34px 0 8px; }
.prose p, .prose li { color: var(--muted); font-size: 14.5px; line-height: 1.65; }
.prose .lead { color: var(--ink); font-size: 16px; }
.prose ul { padding-left: 20px; }
.prose li { margin-bottom: 7px; }
.prose a { color: var(--accent); }
.prose table { width: 100%; border-collapse: collapse; margin: 12px 0; font-size: 13px; }
.prose th { text-align: left; padding: 9px 10px; border-bottom: 1px solid var(--line-2); color: var(--faint); font-family: var(--font-mono); font-size: 10.5px; letter-spacing: .09em; text-transform: uppercase; font-weight: 500; }
.prose td { padding: 10px; border-bottom: 1px solid var(--line); color: var(--muted); vertical-align: top; line-height: 1.5; }
.prose .back { font-size: 13px; margin: 0 0 26px; }
.prose .back a { text-decoration: none; }
.prose .todo { padding: 14px 16px; border-radius: 10px; border: 1px dashed var(--warn); background: rgba(161,92,0,.07); }
.prose .todo em { display: block; margin-top: 7px; font-size: 13px; color: var(--warn); }

@media (max-width: 720px) {
  .cheat-table td:first-child, .cheat-table td:nth-child(2) { white-space: normal; }
  .consent { flex-direction: column; align-items: stretch; }
}
