/* bitmap2font - ciemny, płaski interfejs: powierzchnie różnicuje wyłącznie
   kolor tła i spacing (bez borderów, gradientów, cieni). */

:root {
  --bg: #14161a;
  --surface: #1d2026;
  --surface-2: #262a32;
  --surface-3: #30353f;
  --text: #e8eaed;
  --muted: #8b919c;
  --accent: #f0b429;
  --accent-ink: #1a1405;
  --danger: #f07178;
  --mono: ui-monospace, "SF Mono", SFMono-Regular, Menlo, Consolas, monospace;
  --sans: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  --radius: 6px;
}

* { margin: 0; padding: 0; box-sizing: border-box; }

html, body { height: 100%; }

body {
  background: var(--bg);
  color: var(--text);
  font: 14px/1.5 var(--sans);
  -webkit-font-smoothing: antialiased;
}

:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }

[hidden] { display: none !important; }

/* --- Layout --- */

.layout {
  display: grid;
  grid-template-columns: 1fr 300px;
  gap: 20px;
  padding: 10px 28px 28px;
  align-items: start;
}

@media (max-width: 860px) {
  .layout { grid-template-columns: 1fr; }
}

/* --- Stage (lewa kolumna) --- */

.stage { display: flex; flex-direction: column; gap: 16px; min-width: 0; }

.dropzone {
  background: var(--surface);
  border-radius: var(--radius);
  padding: 72px 24px;
  text-align: center;
  cursor: pointer;
  color: var(--muted);
  transition: background-color 0.15s;
}
.dropzone:hover, .dropzone.drag { background: var(--surface-2); color: var(--text); }
.dropzone.compact { padding: 14px 24px; display: flex; align-items: center; justify-content: center; gap: 10px; }
.dropzone.compact .icon-lg { width: 18px; height: 18px; margin: 0; }
.dropzone.compact .dz-title { font-size: 13px; font-weight: 500; }
.dropzone.compact .dz-title::after { content: " or click to replace the image"; color: var(--muted); font-weight: 400; }
.dropzone.compact .dz-sub, .dropzone.compact .dz-links { display: none; }
.dropzone .icon-lg { width: 32px; height: 32px; margin-bottom: 12px; }
.dz-title { font-size: 15px; font-weight: 600; color: var(--text); }
.dz-sub { font-size: 13px; margin-top: 4px; }
.dz-links {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 14px;
  margin-top: 14px;
}
.dz-sep {
  width: 1px;
  height: 14px;
  background: var(--muted);
  opacity: 0.4;
}
/* separator znika, gdy nie ma zapisanej sesji */
.dz-sep:has(+ [hidden]) { display: none; }

.linklike {
  background: none;
  border: none;
  color: var(--accent);
  font: 600 13px var(--sans);
  cursor: pointer;
  padding: 4px;
  display: inline-flex;
  align-items: center;
  gap: 6px;
}
.linklike .icon { width: 14px; height: 14px; }
.linklike:hover { text-decoration: underline; }

.canvas-wrap {
  background: var(--surface);
  border-radius: var(--radius);
  padding: 20px;
  overflow: auto;
  display: grid;
  place-items: center;
  min-height: 200px;
}
#canvas { image-rendering: pixelated; display: block; }

.stage-info {
  color: var(--muted);
  font-family: var(--mono);
  font-size: 12px;
  padding: 0 4px;
}

/* --- Preview --- */

.preview-block {
  background: var(--surface);
  border-radius: var(--radius);
  padding: 20px;
  display: flex;
  flex-direction: column;
  gap: 14px;
}

.preview-wrap { position: relative; }

/* nieaktualny podglad (blad budowania) - wygaszony stary font */
.preview-block.stale .preview-wrap { opacity: 0.2; filter: grayscale(1); }
.preview-block.stale .preview-text { pointer-events: none; }

.preview-text {
  background: var(--surface-2);
  border-radius: var(--radius);
  padding: 18px 20px;
  min-height: 60px;
  font-size: 32px;
  line-height: 1.3;
  word-break: break-word;
  image-rendering: pixelated;
}

/* linia bazowa pierwszego wiersza podglądu */
.baseline-guide {
  position: absolute;
  left: 0;
  right: 0;
  height: 1px;
  background: var(--accent);
  opacity: 0.6;
  pointer-events: none;
}

.preview-bitmap { overflow-x: auto; }
.preview-bitmap canvas { display: block; image-rendering: pixelated; }

.preview-note {
  font-size: 12px;
  color: var(--accent);
  display: flex;
  align-items: flex-start;
  gap: 7px;
}
.preview-note .icon { width: 15px; height: 15px; flex: none; margin-top: 1px; }

.preview-controls {
  display: flex;
  align-items: center;
  gap: 20px;
  flex-wrap: wrap;
}
.preview-size { display: flex; align-items: center; gap: 12px; flex: 1; min-width: 200px; }
.preview-size .lbl {
  font-family: var(--mono);
  font-size: 12px;
  color: var(--muted);
  white-space: nowrap;
}
.preview-size b { color: var(--text); font-weight: 600; }
.preview-size input { flex: 1; accent-color: var(--accent); }

/* --- Sidebar --- */

.sidebar { display: flex; flex-direction: column; gap: 12px; }

.panel {
  background: var(--surface);
  border-radius: var(--radius);
  padding: 16px;
}

.panel-body {
  display: flex;
  flex-direction: column;
  gap: 12px;
  margin-top: 14px;
}

.section-title {
  display: flex;
  align-items: center;
  gap: 8px;
  font-family: var(--mono);
  font-size: 12px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--muted);
}
.section-title .icon { color: var(--accent); }

/* akordeon: summary bez markera, chevron obraca się przy otwarciu */
summary.section-title { cursor: pointer; user-select: none; list-style: none; }
summary.section-title::-webkit-details-marker { display: none; }
summary.section-title:hover { color: var(--text); }
.section-title .chevron {
  margin-left: auto;
  color: var(--muted);
  transition: transform 0.15s;
}
details[open] > .section-title .chevron { transform: rotate(180deg); }

.icon {
  width: 16px;
  height: 16px;
  fill: none;
  stroke: currentColor;
  stroke-width: 2;
  stroke-linecap: round;
  stroke-linejoin: round;
  flex: none;
}

.seg {
  display: flex;
  gap: 4px;
  background: var(--surface-2);
  border-radius: var(--radius);
  padding: 3px;
}
.seg-btn {
  flex: 1;
  background: none;
  border: none;
  border-radius: 4px;
  color: var(--muted);
  font: 500 12px var(--sans);
  padding: 5px 8px;
  cursor: pointer;
}
.seg-btn.active { background: var(--surface-3); color: var(--text); }

.fields {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 10px 12px;
}
.fields label {
  display: flex;
  flex-direction: column;
  gap: 4px;
  font-size: 12px;
  color: var(--muted);
}
.fields label.wide { grid-column: 1 / -1; }

input[type="number"], input[type="text"], textarea {
  background: var(--surface-2);
  color: var(--text);
  border: none;
  border-radius: var(--radius);
  padding: 7px 10px;
  font-family: var(--mono);
  font-size: 13px;
  width: 100%;
}
textarea { resize: vertical; line-height: 1.5; }

.check {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 13px;
  cursor: pointer;
}
.check input { accent-color: var(--accent); width: 15px; height: 15px; }

.hint { font-size: 12px; color: var(--muted); }

/* ikonka "i" z tooltipem */
.info-btn {
  background: none;
  border: none;
  color: var(--muted);
  padding: 2px;
  cursor: help;
  display: inline-flex;
  align-items: center;
}
.info-btn:hover { color: var(--accent); }
.info-btn .icon { width: 14px; height: 14px; }
.check .info-btn { margin-left: 2px; }
.btn .info-btn { color: var(--accent-ink); opacity: 0.75; margin-left: 4px; vertical-align: -2px; }
.btn .info-btn:hover { color: var(--accent-ink); opacity: 1; }
.lbl-row { display: flex; align-items: center; gap: 2px; }
.lbl-row .info-btn .icon { width: 13px; height: 13px; }

/* motyw tippy dopasowany do apki */
.tippy-box[data-theme~='b2f'] {
  background: var(--surface-3);
  color: var(--text);
  font: 12.5px/1.55 var(--sans);
  border-radius: var(--radius);
  padding: 4px 2px;
}
.tippy-box[data-theme~='b2f'] .tippy-arrow { color: var(--surface-3); }

/* --- Export --- */

.status {
  font-family: var(--mono);
  font-size: 12px;
  color: var(--muted);
  display: flex;
  align-items: flex-start;
  gap: 6px;
}
.status.warn { color: var(--accent); }
.status.error { color: var(--danger); }

.actions { display: flex; gap: 8px; flex-wrap: wrap; }
.actions .btn { flex: 1; }
.actions .btn.wide { flex-basis: 100%; }

.btn {
  border: none;
  border-radius: var(--radius);
  padding: 10px 14px;
  font: 600 13px var(--sans);
  cursor: pointer;
  transition: background-color 0.15s;
}
.btn.primary { background: var(--accent); color: var(--accent-ink); }
.btn.primary:hover:not(:disabled) { background: #f7c44d; }
.btn:disabled { background: var(--surface-2); color: var(--muted); cursor: not-allowed; }

/* toast na dole ekranu */
.toast {
  position: fixed;
  bottom: 24px;
  left: 50%;
  transform: translateX(-50%);
  background: var(--surface-3);
  color: var(--text);
  padding: 10px 18px;
  border-radius: 999px;
  font-size: 13px;
  z-index: 10;
  opacity: 1;
  transition: opacity 0.3s;
  max-width: 80vw;
  text-align: center;
}

@media (prefers-reduced-motion: reduce) {
  * { transition: none !important; }
}
