:root {
  --bg: #ffffff;
  --surface: #ffffff;
  --text: #1f2937;
  --muted: #6b7280;
  --line: #e5e7eb;
  --line-strong: #d1d5db;
  --accent: #16a34a;
  --accent-hover: #15803d;
  --accent-press: #166534;
  --shadow: 0 12px 40px rgba(17, 24, 39, 0.08);
  --radius: 14px;
}

* {
  box-sizing: border-box;
}

html,
body {
  height: 100%;
}

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: Arial, ui-sans-serif, system-ui, -apple-system, Segoe UI, Roboto, Helvetica, "Apple Color Emoji",
    "Segoe UI Emoji";
  font-size: 15px;
  line-height: 1.35;
}

@font-face {
  font-family: "Pismo Szkolne";
  src: url("./assets/pismo-szkolne.ttf") format("truetype");
  font-weight: 400;
  font-style: normal;
  font-display: swap;
}

input,
textarea,
button {
  font: inherit;
  font-size: 15px;
}

.topbar {
  position: sticky;
  top: 0;
  z-index: 10;
  background: rgba(255, 255, 255, 0.9);
  backdrop-filter: blur(8px);
  border-bottom: 1px solid var(--line);
}

.topbar__inner {
  max-width: 1440px;
  margin: 0 auto;
  padding: 14px 16px;
}

.topbar__title {
  margin: 0;
  font-size: 18px;
  font-weight: 700;
  letter-spacing: -0.01em;
}

.topbar__subtitle {
  margin: 4px 0 0;
  color: var(--muted);
}

.layout {
  max-width: 1440px;
  margin: 0 auto;
  padding: 16px;
  display: grid;
  gap: 16px;
}

@media (min-width: 920px) {
  .layout {
    grid-template-columns: 320px minmax(0, 1fr);
    align-items: start;
  }
}

.panel {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  overflow: hidden;
}

.panel--preview {
  background: #fbfdff;
}

@media (min-width: 920px) {
  .panel--settings {
    position: sticky;
    top: 76px;
  }
}

.panel__header {
  padding: 14px 16px;
  border-bottom: 1px solid var(--line);
  background: #fbfdff;
}

.panel__headerRow {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.panel__title {
  margin: 0;
  font-size: 16px;
  font-weight: 700;
}

.form {
  padding: 16px;
  display: grid;
  gap: 12px;
}

.field {
  display: grid;
  gap: 6px;
}

.field__label {
  font-weight: 600;
}

.field__control {
  width: 100%;
  padding: 11px 12px;
  border-radius: 12px;
  border: 1px solid var(--line-strong);
  background: #ffffff;
  outline: none;
}

.field__control:focus {
  border-color: #86efac;
  box-shadow: 0 0 0 4px rgba(34, 197, 94, 0.16);
}

.field__help {
  color: var(--muted);
  font-size: 14px;
}

.categories {
  display: grid;
  gap: 10px;
}

.categoryCard {
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 12px;
  background: #ffffff;
  display: grid;
  gap: 10px;
}

.row2 {
  display: grid;
  gap: 10px;
}

@media (min-width: 920px) {
  .row2 {
    grid-template-columns: 1fr;
  }
}

textarea.field__control {
  min-height: 90px;
  resize: vertical;
}

.btn {
  border: 0;
  border-radius: 12px;
  padding: 12px 14px;
  font-weight: 700;
  cursor: pointer;
}

.btn--primary {
  background: var(--accent);
  color: #ffffff;
}

.btn--primary:hover {
  background: var(--accent-hover);
}

.btn--primary:active {
  background: var(--accent-press);
}

.btn--secondary {
  background: #f3f4f6;
  color: var(--text);
}

.btn--secondary:hover {
  background: #e5e7eb;
}

.btn--small {
  padding: 9px 12px;
  border-radius: 10px;
  font-size: 14px;
}

.hint {
  margin: 0;
  color: var(--muted);
}

.previewSheet {
  padding: 22px;
  background: #ffffff;
  min-height: 600px;
  border: 1px solid var(--line);
  border-radius: 12px;
  margin: 14px;
  font-family: var(--preview-font, Arial, sans-serif);
}

.previewSheet__title {
  font-size: 20px;
  font-weight: 800;
  letter-spacing: -0.01em;
  margin-bottom: 10px;
  min-height: 28px;
}

.previewSheet__sectionTitle {
  margin: 12px 0 6px;
  font-weight: 800;
}

.table {
  border: 1px solid var(--line-strong);
  border-radius: 10px;
  overflow: hidden;
  background: #ffffff;
}

.tableGrid {
  display: grid;
}

.cell {
  border-right: 1px solid var(--line-strong);
  border-bottom: 1px solid var(--line-strong);
  padding: 8px 10px;
  min-height: 28px;
  display: flex;
  align-items: center;
}

.cell--header {
  font-weight: 800;
  background: #fbfdff;
}

.cell--empty {
  color: transparent;
}

.watermark {
  margin-top: 12px;
  text-align: center;
  color: #9ca3af;
  font-size: 14px;
}

.status {
  min-height: 18px;
  color: var(--muted);
  font-size: 14px;
}

.modalBackdrop {
  position: fixed;
  inset: 0;
  background: rgba(15, 23, 42, 0.45);
  backdrop-filter: blur(6px);
  z-index: 50;
}

.modal {
  position: fixed;
  inset: 0;
  display: grid;
  justify-items: center;
  align-items: start;
  padding: 50px 16px 16px;
  z-index: 60;
  overflow-y: auto;
}

.modalCard {
  width: min(720px, 100%);
  background: #ffffff;
  border: 1px solid var(--line);
  border-radius: 16px;
  box-shadow: var(--shadow);
  overflow: hidden;
}

.modalHeader {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 14px 16px;
  border-bottom: 1px solid var(--line);
  background: #fbfdff;
}

.modalHeader h3 {
  margin: 0;
  font-size: 16px;
  font-weight: 800;
}

.iconBtn {
  width: 36px;
  height: 36px;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: #ffffff;
  cursor: pointer;
  font-size: 20px;
  line-height: 1;
}

.modalBody {
  padding: 16px;
  display: grid;
  gap: 12px;
}

.modalActions {
  display: flex;
  justify-content: flex-end;
  gap: 10px;
}

.radioGrid {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
}

.radio {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  border: 1px solid var(--line);
  border-radius: 999px;
  padding: 8px 10px;
  background: #ffffff;
  cursor: pointer;
  user-select: none;
}

.radio input {
  width: 16px;
  height: 16px;
  accent-color: var(--accent);
}

.checkbox {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  width: fit-content;
  font-weight: 600;
  cursor: pointer;
  user-select: none;
}

.checkbox input {
  width: 17px;
  height: 17px;
  accent-color: var(--accent);
}

.aiCategoryGrid {
  display: grid;
  gap: 10px;
  grid-template-columns: repeat(3, minmax(0, 1fr));
}

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

.hp {
  position: absolute;
  left: -9999px;
  top: -9999px;
  opacity: 0;
}

/* Ensure HTML `hidden` always wins over component display rules */
[hidden] {
  display: none !important;
}
