/* Generator instrukcji - interfejs (styl JAAQOB: granat, koral, Raleway, ostre narożniki). */

:root {
  --navy: #17243E;
  --navy-mid: #2A3A5A;
  --navy-light: #475062;
  --coral: #EC7E6C;
  --coral-pale: #FBC8B6;
  --coral-wash: #FDF2EF;
  --gray-mid: #A7ABB6;
  --cream: #F6F6F6;
  --white: #FFFFFF;
  --rule: rgba(23, 36, 62, 0.12);
  --rule-strong: rgba(23, 36, 62, 0.24);
  --danger: #B42318;
  --bar-h: 60px;
  --editor-w: 500px;
  --font: 'Raleway', system-ui, -apple-system, 'Segoe UI', Roboto, Arial, sans-serif;
}

*, *::before, *::after { box-sizing: border-box; }
html, body { height: 100%; }
body { margin: 0; font-family: var(--font); font-size: 15px; line-height: 1.5; color: var(--navy); background: #E9EAEE; }
button, input, select, textarea { font: inherit; color: inherit; }
:focus-visible { outline: 2px solid var(--navy); outline-offset: 2px; }
.app-bar :focus-visible { outline-color: var(--coral); }
code { font-family: ui-monospace, Consolas, monospace; font-size: 0.86em; }

/* ---------------------------------------------------------------- pasek aplikacji */

.app-bar {
  position: fixed; inset: 0 0 auto 0; height: var(--bar-h); z-index: 20;
  display: flex; align-items: center; gap: 1.5rem; padding: 0 20px;
  background: var(--navy); color: var(--white);
}
.app-brand { display: flex; align-items: center; gap: 1rem; flex: none; }
.app-logo svg { height: 20px; width: auto; display: block; }
.app-logo .st0 { fill: var(--coral); }
.app-logo .st1 { fill: var(--white); }
.app-name { padding-left: 1rem; border-left: 1px solid rgba(255, 255, 255, 0.18); font-weight: 600; letter-spacing: 0.02em; }
.app-status { margin: 0; flex: 1; min-width: 0; font-size: 14px; color: rgba(255, 255, 255, 0.65); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.app-actions { display: flex; gap: 0.5rem; flex: none; }

/* ---------------------------------------------------------------- przyciski */

.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 0.4rem;
  min-height: 38px; padding: 0 1rem; cursor: pointer;
  background: var(--white); border: 1px solid var(--rule-strong); color: var(--navy);
  font-weight: 600; font-size: 14px; letter-spacing: 0.01em;
  transition: background 0.15s, border-color 0.15s, color 0.15s;
}
.btn:hover { border-color: var(--navy); }
.btn--primary { background: var(--coral); border-color: var(--coral); color: var(--navy); }
.btn--primary:hover { background: #F09584; border-color: #F09584; }
.btn--ghost { background: transparent; border-color: rgba(255, 255, 255, 0.22); color: var(--white); }
.btn--ghost:hover { border-color: var(--coral); background: rgba(236, 126, 108, 0.1); }
.btn--ghost-dark { background: transparent; }
.btn--danger { color: var(--danger); border-color: rgba(180, 35, 24, 0.35); }
.btn--danger:hover { border-color: var(--danger); background: #FEF3F2; }
.btn--small { min-height: 32px; padding: 0 0.75rem; font-size: 14px; }
.icon-btn {
  width: 32px; height: 32px; display: inline-grid; place-items: center; cursor: pointer;
  background: var(--white); border: 1px solid var(--rule); font-size: 15px; line-height: 1;
}
.icon-btn:hover:not(:disabled) { border-color: var(--navy); }
.icon-btn:disabled { opacity: 0.35; cursor: default; }
.link, .link-back {
  padding: 0; border: 0; background: none; cursor: pointer; color: var(--navy); font-weight: 600;
  text-decoration: underline; text-decoration-color: var(--coral); text-underline-offset: 3px;
}
.link-back { display: inline-block; margin-bottom: 1rem; text-decoration: none; }
.link-back:hover { color: var(--coral); }
.chip {
  min-height: 32px; padding: 0 0.8rem; cursor: pointer; background: transparent; border: 1px solid var(--rule-strong);
  font-size: 14px; font-weight: 600;
}
.chip.is-active { background: var(--navy); border-color: var(--navy); color: var(--white); }

/* ---------------------------------------------------------------- układ */

.app {
  position: fixed; inset: var(--bar-h) 0 0 0;
  display: grid; grid-template-columns: var(--editor-w) minmax(0, 1fr);
}
.editor { display: flex; flex-direction: column; min-height: 0; background: var(--white); border-right: 1px solid var(--rule-strong); }
.tabs { display: flex; flex-wrap: wrap; gap: 0; padding: 0 12px; border-bottom: 1px solid var(--rule-strong); background: var(--cream); flex: none; }
.tab {
  position: relative; padding: 0.8rem 0.7rem 0.7rem; border: 0; background: none; cursor: pointer;
  font-size: 14px; font-weight: 600; color: var(--navy-light); border-bottom: 2px solid transparent; margin-bottom: -1px;
}
.tab:hover { color: var(--navy); }
.tab[aria-selected='true'] { color: var(--navy); border-bottom-color: var(--coral); }
.tab-badge {
  display: inline-block; margin-left: 0.35rem; padding: 0 0.4rem; min-width: 1.4rem; text-align: center;
  background: var(--coral); color: var(--navy); font-size: 14px; line-height: 1.4; font-weight: 700;
}
.panel { flex: 1; min-height: 0; overflow-y: auto; padding: 1.4rem 1.4rem 4rem; outline: none; }

.preview { display: flex; flex-direction: column; min-width: 0; min-height: 0; }
.preview-bar {
  display: flex; flex-wrap: wrap; align-items: center; gap: 0.6rem 1.2rem; padding: 0.6rem 1rem;
  background: var(--white); border-bottom: 1px solid var(--rule-strong); flex: none;
}
.preview-modes { display: flex; gap: 0.35rem; }
.preview-stats { margin: 0; font-size: 14px; color: var(--navy-light); font-variant-numeric: tabular-nums; }
.preview-stage { flex: 1; min-height: 0; overflow: auto; display: flex; justify-content: center; padding: 0; }
.preview-frame { width: 100%; height: 100%; border: 0; background: var(--white); display: block; }
.preview-frame.is-device { margin: 16px auto; height: calc(100% - 32px); box-shadow: 0 10px 40px -12px rgba(23, 36, 62, 0.4); flex: none; }

/* ---------------------------------------------------------------- panel: treść */

.panel-title { margin: 0 0 0.4rem; font-size: 1.45rem; font-weight: 700; letter-spacing: -0.01em; }
.panel-sub { margin: 1.6rem 0 0.6rem; font-size: 14px; font-weight: 700; letter-spacing: 0.14em; text-transform: uppercase; color: var(--navy-light); }
.panel-intro { margin: 0 0 1.2rem; color: var(--navy-light); }
.panel-actions { display: flex; flex-wrap: wrap; gap: 0.5rem; margin-top: 1.2rem; }
.notice { margin: 0 0 1rem; padding: 0.75rem 0.9rem; background: var(--coral-wash); border-left: 3px solid var(--coral); }
.empty { color: var(--navy-light); font-style: italic; }

fieldset { margin: 0 0 1.4rem; padding: 0; border: 0; }
legend { padding: 0; margin-bottom: 0.7rem; font-size: 14px; font-weight: 700; letter-spacing: 0.14em; text-transform: uppercase; color: var(--navy-light); }
.grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 0 0.8rem; }

.field { margin-bottom: 0.9rem; }
.field-label { display: block; margin-bottom: 0.3rem; font-weight: 600; font-size: 14px; }
.field-help { margin: 0.3rem 0 0; font-size: 14px; color: var(--navy-light); }
.field input, .field select, .field textarea, .repeater input, .labels input {
  width: 100%; padding: 0.5rem 0.65rem; border: 1px solid var(--rule-strong); background: var(--white); border-radius: 0;
}
.field input:focus, .field select:focus, .field textarea:focus, .repeater input:focus, .labels input:focus { border-color: var(--navy); outline: none; box-shadow: 0 0 0 1px var(--navy); }
.field textarea { resize: vertical; line-height: 1.5; }
.field--compact { margin: 0.4rem 0; }

.check { display: flex; gap: 0.65rem; align-items: flex-start; margin: 0 0 0.75rem; cursor: pointer; }
.check input { margin: 0.2rem 0 0; width: 18px; height: 18px; accent-color: var(--navy); flex: none; }
.check-body { display: block; }
.check-label { display: block; font-weight: 600; }
.checks { margin: 0.4rem 0 1rem; }

.features { display: grid; gap: 0.2rem; }
.feature { padding: 0.75rem 0 0.15rem; border-top: 1px solid var(--rule); }
.feature-kids { margin: 0.2rem 0 0.4rem 1.6rem; padding-left: 0.9rem; border-left: 2px solid var(--coral-pale); }

/* lista rozdziałów */
.rows { list-style: none; margin: 0; padding: 0; border-top: 1px solid var(--rule); }
.row { display: grid; grid-template-columns: auto minmax(0, 1fr) auto; align-items: center; gap: 0.7rem; padding: 0.45rem 0; border-bottom: 1px solid var(--rule); }
.row-toggle { width: 18px; height: 18px; accent-color: var(--navy); margin: 0 0 0 0.2rem; }
.row-main { display: block; text-align: left; padding: 0.3rem 0.2rem; border: 0; background: none; cursor: pointer; min-width: 0; }
.row-main:hover .row-title { text-decoration: underline; text-decoration-color: var(--coral); text-underline-offset: 3px; }
.row-title { display: block; font-weight: 600; }
.row-meta { display: block; font-size: 14px; color: var(--navy-light); }
.row.is-off .row-title { color: var(--gray-mid); }
.row-actions { display: inline-flex; gap: 0.3rem; }
.row-actions--end { justify-content: flex-end; align-items: flex-end; padding-bottom: 0.9rem; }

/* edytor Markdown */
.md-head { display: flex; justify-content: space-between; align-items: baseline; gap: 1rem; }
.md-toolbar { display: flex; flex-wrap: wrap; gap: 0; border: 1px solid var(--rule-strong); border-bottom: 0; background: var(--cream); }
.md-toolbar button { padding: 0.4rem 0.65rem; border: 0; border-right: 1px solid var(--rule); background: none; cursor: pointer; font-size: 14px; font-weight: 600; }
.md-toolbar button:hover { background: var(--white); }
textarea.md { font-family: ui-monospace, Consolas, monospace; font-size: 14px; line-height: 1.55; min-height: 340px; tab-size: 2; }
.syntax { margin: 0.4rem 0 1rem; padding: 0.6rem 0.8rem; background: var(--cream); }
.syntax summary { cursor: pointer; font-weight: 600; }
.syntax dl { margin: 0.6rem 0 0; display: grid; gap: 0.3rem 0; }
.syntax dt { font-weight: 600; margin-top: 0.4rem; }
.syntax dd { margin: 0; color: var(--navy-light); font-size: 14px; }

/* zrzuty */
.slots { display: grid; gap: 0.6rem; }
.slot {
  display: grid; grid-template-columns: 96px minmax(0, 1fr); gap: 0.4rem 0.9rem; align-items: start;
  padding: 0.7rem; border: 1px dashed var(--coral); background: var(--coral-wash);
}
.slot.is-filled { border-style: solid; border-color: var(--rule-strong); background: var(--white); }
.slot:focus-visible, .slot:focus-within { outline: 2px solid var(--navy); outline-offset: 1px; }
.slot.is-drop { background: var(--coral-pale); }
.slot-thumb { grid-row: span 2; width: 96px; height: 64px; display: grid; place-items: center; background: var(--cream); border: 1px solid var(--rule); overflow: hidden; font-size: 14px; color: var(--navy-light); }
.slot-thumb img { width: 100%; height: 100%; object-fit: cover; object-position: top left; }
.slot-info { min-width: 0; display: grid; gap: 0.1rem; }
.slot-info strong { font-weight: 600; overflow-wrap: anywhere; }
.slot-info code { color: var(--navy-light); overflow-wrap: anywhere; }
.slot-meta { font-size: 14px; color: var(--navy-light); }
.slot-actions { display: flex; flex-wrap: wrap; gap: 0.4rem; align-items: center; }
.slot--video { grid-template-columns: minmax(0, 1fr); border-color: var(--gray-mid); background: var(--cream); }
.slot--video.is-filled { background: var(--white); }

/* karty: typy treści, bloki */
.card { margin-bottom: 0.8rem; border: 1px solid var(--rule-strong); background: var(--white); }
.card > summary {
  display: flex; justify-content: space-between; gap: 1rem; padding: 0.85rem 1rem; cursor: pointer; font-weight: 700; list-style: none;
}
.card > summary::-webkit-details-marker { display: none; }
.card > summary::before { content: '+'; color: var(--coral); font-weight: 700; margin-right: 0.6rem; }
.card[open] > summary::before { content: '−'; }
.card > summary > span:first-child { flex: 1; }
.card-meta { font-weight: 500; font-size: 14px; color: var(--navy-light); }
.card-body { padding: 0.2rem 1rem 1rem; border-top: 1px solid var(--rule); }
.card--flat { padding: 1rem 1rem 0.8rem; }

.repeater { margin-bottom: 1rem; display: grid; gap: 0.4rem; justify-items: start; }
.rep-row { display: grid; grid-template-columns: minmax(0, 0.8fr) minmax(0, 1.2fr) auto auto; gap: 0.4rem; width: 100%; }

/* nazwy w panelu */
.table-scroll { overflow-x: auto; }
.labels { width: 100%; border-collapse: collapse; }
.labels th, .labels td { padding: 0.35rem 0.4rem; border-bottom: 1px solid var(--rule); text-align: left; vertical-align: middle; }
.labels thead th { font-size: 14px; text-transform: uppercase; letter-spacing: 0.1em; color: var(--navy-light); }
.labels th[scope='row'] { font-weight: 500; width: 40%; }

/* ---------------------------------------------------------------- komunikaty */

.toast {
  position: fixed; left: 50%; bottom: 24px; transform: translateX(-50%); z-index: 50;
  max-width: min(640px, calc(100vw - 32px)); padding: 0.85rem 1.2rem;
  background: var(--navy); color: var(--white); box-shadow: 0 16px 40px -12px rgba(10, 16, 30, 0.5);
  border-left: 3px solid var(--coral);
}
.loading { position: fixed; inset: 0; z-index: 40; display: grid; place-items: center; background: var(--white); padding: 2rem; text-align: center; }
.noscript { padding: 2rem; }

/* ---------------------------------------------------------------- zapis i okno Projekty */

.sr-only { position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip: rect(0, 0, 0, 0); white-space: nowrap; border: 0; }
.app-sep { width: 1px; height: 26px; background: rgba(255, 255, 255, 0.18); margin: 0 0.25rem; align-self: center; }
.btn--save { position: relative; }
.dirty-dot { display: none; width: 8px; height: 8px; border-radius: 50%; background: var(--coral); }
.btn--save.is-dirty .dirty-dot { display: inline-block; }
.btn--save:not(.is-dirty) .dirty-sr { display: none; }

dialog.projects, dialog.ask {
  padding: 0; border: 0; color: var(--navy); background: var(--white);
  box-shadow: 0 30px 80px -20px rgba(10, 16, 30, 0.55);
}
dialog.projects { width: min(1040px, calc(100vw - 32px)); max-height: calc(100vh - 48px); }
dialog.projects::backdrop, dialog.ask::backdrop { background: rgba(23, 36, 62, 0.55); }
.projects-head {
  position: sticky; top: 0; z-index: 1; display: flex; align-items: center; justify-content: space-between; gap: 1rem;
  padding: 1rem 1.4rem; background: var(--navy); color: var(--white);
}
.projects-title { margin: 0; font-size: 18px; font-weight: 700; }
.projects-body { padding: 1.3rem 1.4rem 1.5rem; }
.projects-sub { margin: 0 0 0.6rem; font-size: 17px; outline: none; }
.projects-tools { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 260px); gap: 1rem; margin-bottom: 0.8rem; }
.notice--error { background: #FEF3F2; border-left-color: var(--danger); }
.login { max-width: 420px; }
.offline { margin-top: 1.6rem; border-top: 1px solid var(--rule); padding-top: 1rem; }
.offline summary { cursor: pointer; font-weight: 600; }

.list { width: 100%; border-collapse: collapse; }
.list th, .list td { padding: 0.7rem 0.6rem; border-bottom: 1px solid var(--rule); text-align: left; vertical-align: middle; }
.list thead th { font-size: 13px; text-transform: uppercase; letter-spacing: 0.1em; color: var(--navy-light); font-weight: 700; }
.list tbody th { font-weight: 500; }
.list tr.is-current { background: var(--coral-wash); }
.list-title { font-weight: 700; }
.list-meta { display: block; font-size: 13px; color: var(--navy-light); }
.list-actions { display: flex; flex-wrap: wrap; gap: 0.4rem; justify-content: flex-end; }
.tag { display: inline-block; margin-left: 0.3rem; padding: 0.05rem 0.45rem; font-size: 12px; font-weight: 700; letter-spacing: 0.04em; text-transform: uppercase; background: var(--navy); color: var(--white); vertical-align: 0.1em; }

dialog.ask { width: min(520px, calc(100vw - 32px)); padding: 1.5rem; }
.ask-title { margin: 0 0 0.6rem; font-size: 19px; }
.ask-text { margin: 0 0 1.3rem; color: var(--navy-light); }
.ask-actions { display: flex; flex-wrap: wrap; gap: 0.5rem; }

@media (max-width: 700px) {
  .projects-tools { grid-template-columns: minmax(0, 1fr); }
  .list thead { display: none; }
  .list tr { display: block; padding: 0.6rem 0; border-bottom: 1px solid var(--rule); }
  .list th, .list td { display: block; border: 0; padding: 0.2rem 0; }
  .list-actions { justify-content: flex-start; margin-top: 0.4rem; }
}

@media (max-width: 1100px) {
  :root { --editor-w: 430px; }
  .app-actions .btn--ghost { padding: 0 0.6rem; }
}
@media (max-width: 860px) {
  .app-bar { height: auto; min-height: var(--bar-h); flex-wrap: wrap; padding: 10px 16px; gap: 0.6rem; position: sticky; }
  .app-status { flex-basis: 100%; order: 3; }
  .app { position: static; display: block; }
  .editor { border-right: 0; }
  .panel { overflow: visible; }
  .preview { height: 80vh; }
}
