:root {
  --wood-dark: #3f2414;
  --wood-mid: #7c4b25;
  --wood-warm: #b06b32;
  --wood-gold: #d8a15d;
  --parchment: #f8eed9;
  --parchment-deep: #ead7b5;
  --ink: #23170f;
  --muted: #6e553d;
  --line: #7e5a34;
  --danger: #b12121;
  --danger-soft: #ffe0d7;
  --focus: #112b60;
  --shadow: 0 18px 45px rgba(32, 18, 9, 0.28);
  --radius: 18px;
  font-family: Georgia, "Times New Roman", serif;
  color-scheme: light;
}

* {
  box-sizing: border-box;
}

html {
  scroll-behavior: smooth;
}

body {
  margin: 0;
  color: var(--ink);
  background:
    radial-gradient(circle at 18% 10%, rgba(255, 218, 148, 0.2), transparent 28rem),
    linear-gradient(90deg, rgba(80, 42, 18, 0.24), transparent 18%, rgba(42, 20, 8, 0.22) 50%, transparent 80%),
    repeating-linear-gradient(90deg, #5b3219 0 30px, #6e3e1f 30px 64px, #4b2916 64px 96px),
    #5b3219;
  min-height: 100vh;
}

body::before {
  content: "";
  position: fixed;
  inset: 0;
  pointer-events: none;
  background:
    linear-gradient(115deg, transparent 0 18%, rgba(255, 240, 204, 0.08) 18% 19%, transparent 19% 40%, rgba(0, 0, 0, 0.07) 40% 41%, transparent 41%),
    repeating-linear-gradient(0deg, rgba(255,255,255,0.025) 0 1px, transparent 1px 10px);
  mix-blend-mode: soft-light;
}

button,
input,
select,
textarea {
  font: inherit;
}

button {
  border: 2px solid var(--wood-dark);
  border-radius: 999px;
  padding: 0.75rem 1rem;
  color: var(--ink);
  background: linear-gradient(180deg, #ffe4ac, #d69a51);
  cursor: pointer;
  font-weight: 700;
  box-shadow: 0 3px 0 rgba(63, 36, 20, 0.9);
  transition: transform 140ms ease, box-shadow 140ms ease, background 140ms ease;
}

button:hover:not(:disabled) {
  transform: translateY(-1px);
  box-shadow: 0 5px 0 rgba(63, 36, 20, 0.85);
}

button:active:not(:disabled) {
  transform: translateY(1px);
  box-shadow: 0 2px 0 rgba(63, 36, 20, 0.85);
}

button:disabled {
  cursor: not-allowed;
  opacity: 0.55;
}

button.primary {
  color: #fff7df;
  background: linear-gradient(180deg, #7a3f1d, #4a2716);
}

button.danger-ghost {
  color: #5c1717;
  background: linear-gradient(180deg, #fff2e8, #e4c0a8);
  border-color: #7c2c21;
}

input,
select,
textarea {
  width: 100%;
  border: 1.8px solid #9a754a;
  border-radius: 12px;
  background: rgba(255, 252, 239, 0.96);
  color: var(--ink);
  padding: 0.68rem 0.75rem;
  min-height: 2.75rem;
}

textarea {
  resize: vertical;
  line-height: 1.45;
  background-image:
    linear-gradient(rgba(126, 90, 52, 0.11) 1px, transparent 1px),
    linear-gradient(90deg, rgba(126, 90, 52, 0.08) 1px, transparent 1px);
  background-size: 20px 20px;
}

input[type="checkbox"] {
  width: 1.2rem;
  height: 1.2rem;
  min-height: auto;
  accent-color: var(--wood-dark);
  flex: 0 0 auto;
}

input[readonly] {
  background: #efe0bf;
  font-weight: 700;
}

input:disabled,
select:disabled,
textarea:disabled {
  color: #554331;
  border-color: #b69d77;
  background: rgba(225, 211, 184, 0.72);
  cursor: not-allowed;
}

label {
  display: grid;
  gap: 0.35rem;
  font-weight: 700;
}

.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;
}

:focus-visible {
  outline: 4px solid var(--focus);
  outline-offset: 3px;
}

.hero,
.toc,
.sheet-section,
.footer {
  width: min(1500px, calc(100% - 2rem));
  margin-inline: auto;
}

.hero {
  margin-top: 1rem;
  padding: clamp(1rem, 4vw, 2.2rem);
  border: 3px solid rgba(35, 23, 15, 0.95);
  border-radius: calc(var(--radius) + 10px);
  background:
    linear-gradient(145deg, rgba(255, 243, 208, 0.94), rgba(225, 173, 99, 0.95)),
    var(--parchment);
  box-shadow: var(--shadow);
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 1.25rem;
  align-items: start;
}

.hero h1,
.section-title h2,
.toc h2,
.panel h3 {
  margin: 0;
  line-height: 1.1;
}

.hero h1 {
  font-size: clamp(2rem, 5vw, 4.4rem);
  letter-spacing: 0.02em;
}

.hero p {
  max-width: 70ch;
}

.eyebrow {
  margin: 0 0 0.4rem;
  color: #744117;
  font-weight: 800;
  text-transform: uppercase;
  letter-spacing: 0.14em;
  font-size: 0.78rem;
}

.toolbar,
.button-row,
.startup-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 0.7rem;
  align-items: center;
}

.toolbar {
  justify-content: flex-end;
  max-width: 32rem;
}

.switch {
  display: inline-flex;
  align-items: center;
  gap: 0.55rem;
  padding: 0.65rem 0.85rem;
  border: 2px solid var(--wood-dark);
  border-radius: 999px;
  background: rgba(255, 249, 230, 0.8);
  box-shadow: inset 0 0 0 1px rgba(255,255,255,0.55);
}

.switch input {
  margin: 0;
}

.checkbox-field {
  display: flex;
  align-items: center;
  gap: 0.55rem;
  min-height: 2.75rem;
  padding: 0.68rem 0.75rem;
  border: 1.8px solid #9a754a;
  border-radius: 12px;
  background: rgba(255, 252, 239, 0.96);
}

.checkbox-field input[type="checkbox"] {
  margin: 0;
}

.status {
  grid-column: 1 / -1;
  margin: 0;
  padding: 0.7rem 0.9rem;
  border-radius: 12px;
  background: rgba(255, 250, 230, 0.72);
  color: #4f351f;
  font-weight: 700;
}

.toc {
  position: sticky;
  top: 0;
  z-index: 5;
  margin-top: 1rem;
  padding: 1rem;
  border: 2px solid rgba(35, 23, 15, 0.9);
  border-radius: var(--radius);
  background: rgba(248, 238, 217, 0.96);
  box-shadow: 0 10px 25px rgba(28, 14, 7, 0.26);
  backdrop-filter: blur(8px);
}

.toc-heading {
  display: flex;
  gap: 1rem;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 0.8rem;
}

.top-link {
  color: #4b2916;
  font-weight: 700;
}

.toc-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(11rem, 1fr));
  gap: 0.6rem;
}

.toc-grid button {
  width: 100%;
  border-radius: 12px;
  padding: 0.65rem 0.75rem;
  text-align: left;
}

main {
  padding-block: 1rem 4rem;
}

.sheet-section {
  scroll-margin-top: 10rem;
  margin-top: 1rem;
  border: 3px solid rgba(35, 23, 15, 0.95);
  border-radius: calc(var(--radius) + 8px);
  background:
    linear-gradient(rgba(255,255,255,0.42), rgba(255,255,255,0.16)),
    var(--parchment);
  box-shadow: var(--shadow);
  padding: clamp(1rem, 3vw, 1.7rem);
}


.section-title {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto minmax(0, 1fr);
  gap: 1rem;
  align-items: end;
  margin-bottom: 1rem;
  border-bottom: 3px double rgba(126, 90, 52, 0.8);
  padding-bottom: 0.75rem;
}

.section-title .eyebrow {
  grid-column: 1;
  justify-self: start;
  align-self: end;
  margin-bottom: 0;
}

.section-title h2 {
  grid-column: 2;
  justify-self: center;
  text-align: center;
}

.section-actions {
  grid-column: 3;
  justify-self: end;
  align-self: end;
}

.section-title h2 {
  font-size: clamp(1.45rem, 3vw, 2.3rem);
}

.section-help,
.microcopy,
.hint {
  color: var(--muted);
  line-height: 1.45;
}

.microcopy,
.hint {
  font-size: 0.95rem;
}

.grid {
  display: grid;
  gap: 1rem;
  align-items: stretch;
}

.two-col {
  grid-template-columns: repeat(2, minmax(0, 1fr));
}

.spell-top-grid {
  grid-template-columns: minmax(17rem, 0.7fr) minmax(0, 1.3fr);
}

.panel,
.ability-card {
  border: 2px solid var(--line);
  border-radius: var(--radius);
  background:
    linear-gradient(180deg, rgba(255, 252, 238, 0.95), rgba(239, 219, 181, 0.92));
  padding: 1rem;
  box-shadow: inset 0 0 0 1px rgba(255,255,255,0.5);
}

fieldset.panel,
.inline-fieldset {
  margin: 0;
}

legend {
  padding-inline: 0.45rem;
  font-size: 1.02rem;
  font-weight: 800;
}

.form-grid,
.stat-grid,
.hp-grid,
.slot-grid,
.coins,
.checkbox-grid {
  display: grid;
  gap: 0.8rem;
}

.form-grid.two-col,
.stat-grid.compact-stats {
  grid-template-columns: repeat(2, minmax(0, 1fr));
}

.hp-grid {
  grid-template-columns: repeat(5, minmax(0, 1fr));
  margin-top: 1rem;
}

.inline-fieldset {
  border: 1.5px dashed rgba(126, 90, 52, 0.75);
  border-radius: 14px;
  padding: 0.9rem;
  margin-top: 1rem;
}

.checkbox-row,
.inspiration-toggle,
.mini-checks,
.attunement-row {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  flex-wrap: wrap;
}

.checkbox-row span {
  min-width: 7rem;
  font-weight: 800;
}

.inspiration-toggle {
  margin-top: 1rem;
  font-size: 1.1rem;
}

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

.ability-card h3 {
  margin: 0 0 0.75rem;
  text-align: center;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  font-size: 1.1rem;
}

.ability-values {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0.75rem;
  align-items: end;
  margin-bottom: 0.85rem;
}

.ability-values input[data-ability-score] {
  text-align: center;
  font-size: 1.45rem;
  font-weight: 800;
}

.ability-values input[readonly] {
  text-align: center;
  font-size: 1.35rem;
}

.skill-list {
  display: grid;
  gap: 0.45rem;
}

.skill-row {
  grid-template-columns: auto 1fr auto;
  display: grid;
  align-items: center;
  gap: 0.5rem;
  min-height: 2rem;
  border-bottom: 1px solid rgba(126, 90, 52, 0.3);
  padding-bottom: 0.3rem;
}

.skill-row output {
  justify-self: end;
  min-width: 3rem;
  padding: 0.18rem 0.38rem;
  border-radius: 999px;
  background: rgba(126, 90, 52, 0.14);
  text-align: center;
  font-weight: 800;
}

.save-row {
  font-weight: 900;
}

.stack {
  display: grid;
  gap: 1rem;
}

.textarea-panel {
  display: flex;
  flex-direction: column;
  align-items: stretch;
}

.textarea-panel > label:has(textarea),
.textarea-panel.panel:has(> textarea) {
  flex: 1 1 auto;
  display: flex;
  flex-direction: column;
  min-height: 0;
}

.textarea-panel textarea {
  flex: 1 1 auto;
  min-height: 12rem;
}

.table-wrap {
  width: 100%;
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
  overscroll-behavior-x: contain;
  border: 2px solid var(--line);
  border-radius: var(--radius);
  background: rgba(255, 250, 236, 0.92);
}

.responsive-table {
  width: 100%;
  min-width: 730px;
  border-collapse: collapse;
}

.responsive-table caption {
  caption-side: top;
  padding: 0.8rem;
  font-weight: 900;
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

.responsive-table th,
.responsive-table td {
  border: 1px solid rgba(126, 90, 52, 0.55);
  padding: 0.45rem;
  vertical-align: middle;
}

.responsive-table th {
  background: rgba(126, 90, 52, 0.16);
  text-align: left;
  overflow-wrap: anywhere;
}

.responsive-table input,
.responsive-table select {
  border: 1px solid rgba(126, 90, 52, 0.52);
  min-height: 2.3rem;
  padding: 0.42rem 0.5rem;
}

.spell-table {
  min-width: 920px;
  table-layout: fixed;
}

.spell-table th:nth-child(1),
.spell-table td:nth-child(1) {
  width: 4.2rem;
}

.spell-table th:nth-child(2),
.spell-table td:nth-child(2) {
  width: 25%;
}

.spell-table th:nth-child(3),
.spell-table td:nth-child(3) {
  width: 7.2rem;
}

.spell-table th:nth-child(4),
.spell-table td:nth-child(4) {
  width: 7rem;
}

.spell-table th:nth-child(5),
.spell-table td:nth-child(5) {
  width: 10rem;
  min-width: 10rem;
}

.spell-table th:nth-child(6),
.spell-table td:nth-child(6) {
  width: auto;
}

.spell-table th:nth-child(7),
.spell-table td:nth-child(7),
.responsive-table th:last-child,
.responsive-table td.row-action-cell {
  width: 6.6rem;
}

.mini-checks {
  flex-wrap: nowrap;
  justify-content: center;
}

.mini-checks label {
  display: inline-flex;
  align-items: center;
  gap: 0.22rem;
}

.row-action-cell {
  white-space: nowrap;
}

.row-actions {
  display: inline-flex;
  gap: 0.35rem;
  align-items: center;
  justify-content: center;
  width: 100%;
}

.row-action-button {
  min-width: 2.2rem;
  min-height: 2.2rem;
  padding: 0.25rem 0.45rem;
  border-radius: 10px;
  line-height: 1;
}

.slot-grid {
  grid-template-columns: repeat(6, minmax(0, 1fr));
}

.checkbox-grid {
  grid-template-columns: repeat(2, minmax(0, 1fr));
}

.checkbox-grid label,
.coins label {
  display: flex;
  align-items: center;
  gap: 0.55rem;
}

.attunement-row {
  display: grid;
  grid-template-columns: auto minmax(0, 1fr) auto;
  gap: 0.55rem;
  align-items: center;
  margin-block: 0.55rem;
}

.attunement-check {
  display: inline-flex;
  align-items: center;
  justify-content: center;
}

.coins {
  grid-template-columns: repeat(5, minmax(0, 1fr));
}

.footer {
  margin-bottom: 2rem;
  padding: 1rem;
  border-radius: var(--radius);
  background: rgba(248, 238, 217, 0.92);
  color: #4a2c19;
  border: 2px solid rgba(35, 23, 15, 0.8);
}

.startup-dialog {
  width: min(42rem, calc(100% - 2rem));
  padding: 0;
  border: none;
  border-radius: calc(var(--radius) + 8px);
  background: transparent;
}

.startup-dialog::backdrop {
  background: rgba(28, 13, 5, 0.76);
  backdrop-filter: blur(4px);
}

.startup-card {
  border: 3px solid var(--wood-dark);
  border-radius: calc(var(--radius) + 8px);
  background:
    linear-gradient(145deg, rgba(255, 247, 221, 0.98), rgba(223, 174, 103, 0.98));
  box-shadow: var(--shadow);
  padding: clamp(1.2rem, 4vw, 2rem);
}

.startup-card h1 {
  margin: 0;
  font-size: clamp(1.8rem, 5vw, 3rem);
}

.locked-note {
  border-color: var(--danger);
}

[data-lockable].is-locked {
  box-shadow: inset 0 0 0 2px rgba(177, 33, 33, 0.25);
}

@media (max-width: 980px) {
  .hero,
  .two-col,
  .spell-top-grid,
  .attribute-grid {
    grid-template-columns: 1fr;
  }

  .toolbar {
    justify-content: flex-start;
    max-width: unset;
  }

  .hp-grid,
  .slot-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
}

@media (max-width: 620px) {
  .hero,
  .toc,
  .sheet-section,
  .footer {
    width: min(100% - 0.75rem, 1500px);
  }

  .toc {
    position: static;
  }

  .toc-heading {
    align-items: start;
    flex-direction: column;
  }

  .section-title {
    grid-template-columns: 1fr;
    justify-items: center;
    text-align: center;
  }

  .section-title .eyebrow,
  .section-title h2,
  .section-actions {
    grid-column: 1;
    justify-self: center;
  }

  .section-actions {
    width: 100%;
  }

  .section-actions button {
    width: 100%;
  }

  .form-grid.two-col,
  .stat-grid.compact-stats,
  .hp-grid,
  .slot-grid,
  .coins,
  .checkbox-grid {
    grid-template-columns: 1fr;
  }

  .ability-values {
    grid-template-columns: 1fr;
  }
}

@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    scroll-behavior: auto !important;
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
  }
}


/* Ergänzungen v1.1 */
.toolbar-note {
  margin: 0;
  max-width: 28rem;
  text-align: right;
}

.section-actions {
  display: flex;
  gap: 0.65rem;
  flex-wrap: wrap;
  justify-content: flex-end;
}

.table-actions {
  margin-top: 0.75rem;
}

.skill-row input[type="text"] {
  min-width: 3.7rem;
  width: 4.4rem;
  min-height: 2rem;
  padding: 0.22rem 0.35rem;
  border-radius: 999px;
  background: rgba(126, 90, 52, 0.14);
  text-align: center;
  font-weight: 800;
}

.spell-slot-list {
  display: grid;
  gap: 0.7rem;
}

.spell-slot-row {
  display: grid;
  grid-template-columns: 5rem minmax(9rem, auto) minmax(10rem, 1fr);
  gap: 0.75rem;
  align-items: center;
  padding: 0.6rem;
  border: 1px solid rgba(126, 90, 52, 0.45);
  border-radius: 14px;
  background: rgba(255, 250, 236, 0.64);
}

.spell-slot-label {
  font-weight: 900;
}

.slot-controls {
  display: grid;
  grid-template-columns: 2.4rem 4.4rem 2.4rem;
  gap: 0.35rem;
  align-items: center;
}

.slot-controls button {
  min-width: 2.4rem;
  min-height: 2.4rem;
  padding: 0;
  border-radius: 50%;
  font-size: 1.25rem;
  line-height: 1;
}

.slot-controls input {
  text-align: center;
  min-height: 2.4rem;
  padding-inline: 0.35rem;
}

.slot-checkboxes {
  display: flex;
  flex-wrap: wrap;
  gap: 0.45rem;
  align-items: center;
}

.slot-check {
  display: inline-flex;
  grid-template-columns: none;
  align-items: center;
  gap: 0.25rem;
  padding: 0.22rem 0.45rem;
  border: 1px solid rgba(126, 90, 52, 0.4);
  border-radius: 999px;
  background: rgba(255,255,255,0.45);
}

.appearance-panel h3 {
  margin: 0 0 0.75rem;
}

.image-preview-wrap {
  overflow: hidden;
  border: 2px solid rgba(126, 90, 52, 0.65);
  border-radius: 16px;
  background: rgba(255, 250, 236, 0.72);
  max-height: 24rem;
}

.image-preview-wrap img {
  display: block;
  width: 100%;
  max-height: 24rem;
  object-fit: contain;
}

@media (max-width: 760px) {
  .toolbar-note {
    text-align: left;
  }

  .spell-slot-row {
    grid-template-columns: 1fr;
  }

  .slot-controls {
    grid-template-columns: 2.6rem 5rem 2.6rem;
    justify-content: start;
  }

  button,
  input,
  select,
  textarea {
    font-size: 16px;
  }

  .toc-grid {
    grid-template-columns: 1fr;
  }

  .toc-grid button,
  .toolbar button,
  .button-row button {
    min-height: 2.9rem;
  }

  .toc-grid .toc-lookup-button {
    min-width: 2.65rem;
    min-height: 2.65rem;
    width: auto;
    justify-self: start;
  }

  .responsive-table {
    min-width: 680px;
  }

  .spell-table {
    min-width: 860px;
  }

  .row-action-button {
    min-width: 2.65rem;
    min-height: 2.65rem;
  }

  .attunement-row {
    grid-template-columns: auto minmax(0, 1fr);
  }

  .attunement-row .row-action-cell {
    grid-column: 1 / -1;
  }
}

.attunement-list {
  display: grid;
  gap: 0.65rem;
}


@media (max-width: 480px) {
  .hero,
  .toc,
  .sheet-section,
  .footer {
    width: min(100% - 0.5rem, 1180px);
  }

  .sheet-section {
    padding: 0.8rem;
  }

  .panel,
  .ability-card {
    padding: 0.85rem;
  }

  .hero {
    grid-template-columns: 1fr;
  }

  .toolbar,
  .button-row,
  .startup-actions {
    align-items: stretch;
  }

  .toolbar button,
  .button-row button,
  .startup-actions button {
    width: 100%;
  }
}

/* Ergänzungen v1.3 */
.checkbox-only {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0;
}

.checkbox-only input[type="checkbox"] {
  margin: 0;
}

.th-break {
  display: inline-block;
  line-height: 1.05;
  hyphens: manual;
}

.prepared-cell {
  text-align: center;
}

.prepared-cell .checkbox-only {
  width: 100%;
}

/* Zaubertabelle: stabile Spaltenbreiten in Chrome und Firefox */
.spell-table {
  min-width: 1120px;
  table-layout: fixed;
}

.spell-table th:nth-child(1),
.spell-table td:nth-child(1) {
  width: 4rem;
}

.spell-table th:nth-child(2),
.spell-table td:nth-child(2) {
  width: 22%;
}

.spell-table th:nth-child(3),
.spell-table td:nth-child(3) {
  width: 5.5rem;
}

.spell-table th:nth-child(4),
.spell-table td:nth-child(4),
.spell-table th:nth-child(5),
.spell-table td:nth-child(5) {
  width: 5rem;
  min-width: 0;
}

.spell-table th:nth-child(6),
.spell-table td:nth-child(6) {
  width: 10rem;
  min-width: 10rem;
}

.spell-table th:nth-child(7),
.spell-table td:nth-child(7) {
  width: auto;
}

.spell-table th:nth-child(8),
.spell-table td:nth-child(8) {
  width: 10.2rem;
}

.inventory-layout {
  grid-template-columns: 1fr;
}

.inventory-list-panel {
  min-width: 0;
}

.equipment-table {
  min-width: 920px;
  table-layout: fixed;
}

.equipment-table th:nth-child(1),
.equipment-table td:nth-child(1) {
  width: 30%;
}

.equipment-table th:nth-child(2),
.equipment-table td:nth-child(2) {
  width: 7rem;
}

.equipment-table th:nth-child(3),
.equipment-table td:nth-child(3) {
  width: 8rem;
}

.equipment-table th:nth-child(4),
.equipment-table td:nth-child(4) {
  width: auto;
}

.equipment-table th:nth-child(5),
.equipment-table td:nth-child(5) {
  width: 8.2rem;
}

.storage-actions + .storage-actions {
  margin-top: 0.75rem;
}

.settings-stack {
  display: grid;
  gap: 0.75rem;
  align-items: start;
}

.footer {
  text-align: center;
}

.footer p {
  margin: 0;
  line-height: 1.55;
}

@media (max-width: 760px) {
  .spell-table {
    min-width: 980px;
  }

  .equipment-table {
    min-width: 820px;
  }
}

/* Unbesuchte Links und Standardzustand */
a:link, a {
    color: #d49933;
}

/* Bereits besuchte Links */
a:visited {
    color: #d49933;
}


@media print {
  @page {
    size: A4;
    margin: 10mm;
  }

  *,
  *::before,
  *::after {
    box-shadow: none !important;
    text-shadow: none !important;
    -webkit-print-color-adjust: exact;
    print-color-adjust: exact;
  }

  html,
  body {
    color: #000 !important;
    background: #fff !important;
    min-height: auto;
    font-size: 9.5pt;
  }

  body::before,
  .toc,
  .toolbar,
  .status,
  .section-actions,
  .row-action-cell,
  .startup-dialog,
  .footer {
    display: none !important;
  }

  main {
    padding: 0 !important;
  }

  .hero,
  .sheet-section {
    width: 100% !important;
    margin: 0 0 5mm !important;
    border: 1.2pt solid #000 !important;
    border-radius: 0 !important;
    background: #fff !important;
    color: #000 !important;
    break-inside: avoid-page;
    page-break-inside: avoid;
  }

  .hero {
    display: block !important;
    padding: 5mm !important;
  }

  .hero h1 {
    font-size: 21pt !important;
  }

  .hero p {
    margin: 2mm 0 0 !important;
  }

  .sheet-section {
    padding: 4mm !important;
  }

  .section-title {
    display: block !important;
    margin-bottom: 3mm !important;
    padding-bottom: 2mm !important;
    border-bottom: 1pt solid #000 !important;
  }

  .section-title h2 {
    text-align: left !important;
    font-size: 16pt !important;
  }

  .section-help,
  .microcopy,
  .hint {
    color: #000 !important;
  }

  .grid,
  .two-col,
  .spell-top-grid,
  .attribute-grid,
  .form-grid.two-col,
  .stat-grid.compact-stats,
  .hp-grid,
  .slot-grid,
  .coins,
  .checkbox-grid,
  .inventory-layout {
    display: grid !important;
    grid-template-columns: repeat(2, minmax(0, 1fr)) !important;
    gap: 3mm !important;
  }

  .attribute-grid {
    grid-template-columns: repeat(3, minmax(0, 1fr)) !important;
  }

  .hp-grid,
  .slot-grid,
  .coins {
    grid-template-columns: repeat(5, minmax(0, 1fr)) !important;
  }

  .panel,
  .ability-card,
  .table-wrap,
  .inline-fieldset,
  .checkbox-field,
  .image-preview-wrap {
    border: 0.8pt solid #000 !important;
    border-radius: 0 !important;
    background: #fff !important;
    color: #000 !important;
  }

  .panel,
  .ability-card,
  .inline-fieldset {
    padding: 3mm !important;
    break-inside: avoid-page;
    page-break-inside: avoid;
  }

  label,
  legend,
  .ability-card h3,
  .responsive-table caption,
  .save-row {
    color: #000 !important;
  }

  input,
  select,
  textarea {
    color: #000 !important;
    background: #fff !important;
    border: 0.8pt solid #000 !important;
    border-radius: 0 !important;
    min-height: 6mm !important;
    padding: 1.2mm 1.5mm !important;
  }

  textarea {
    background-image: none !important;
    min-height: 18mm !important;
  }

  input[readonly],
  input:disabled,
  select:disabled,
  textarea:disabled {
    color: #000 !important;
    background: #fff !important;
    border-color: #000 !important;
    opacity: 1 !important;
  }

  input[type="checkbox"] {
    width: 4mm !important;
    height: 4mm !important;
    min-height: 4mm !important;
    accent-color: #000;
  }

  .table-wrap {
    overflow: visible !important;
  }

  .responsive-table,
  .spell-table,
  .equipment-table {
    width: 100% !important;
    min-width: 0 !important;
    table-layout: fixed !important;
    border-collapse: collapse !important;
    font-size: 8.5pt !important;
  }

  .responsive-table th,
  .responsive-table td {
    border: 0.6pt solid #000 !important;
    padding: 1.2mm !important;
    color: #000 !important;
    background: #fff !important;
  }

  .responsive-table input,
  .responsive-table select,
  .responsive-table textarea {
    min-height: 5mm !important;
    padding: 0.8mm 1mm !important;
  }

  .spell-table th:nth-child(8),
  .spell-table td:nth-child(8),
  .equipment-table th:nth-child(5),
  .equipment-table td:nth-child(5),
  .responsive-table th:last-child,
  .responsive-table td:last-child {
    display: none !important;
  }

  button,
  .top-link {
    display: none !important;
  }

  a,
  a:visited {
    color: #000 !important;
    text-decoration: none !important;
  }
}



/* Ergänzungen für CSV-Zauberimport und Online-Quellen */
.spell-import-button.is-available {
  color: #f7ffe8;
  border-color: #23531f;
  background: linear-gradient(180deg, #5fae45, #2f6b2b);
}

.source-button {
  font-weight: 900;
}

/* Anpassungen: Nachschlagen im Inhaltsverzeichnis und flexibles Merkmale-&-Übung-Layout */
.toc-grid .toc-lookup-button {
  width: auto;
  min-width: 2.2rem;
  min-height: 2.2rem;
  justify-self: start;
  align-self: center;
  padding: 0.25rem 0.45rem;
  border-radius: 10px;
  text-align: center;
  line-height: 1;
  font-size: 1rem;
  font-weight: 900;
}

.toc-lookup-button[hidden] {
  display: none !important;
}

#features > .grid.two-col {
  align-items: stretch;
}

#features .stack {
  height: 100%;
  align-content: stretch;
}

#features .stack > .panel,
#features .stack > .textarea-panel {
  min-height: 0;
}

#features .stack > fieldset.panel {
  display: flex;
  flex-direction: column;
}

#features .stack > fieldset.panel > label {
  flex: 1 1 auto;
  display: flex;
  flex-direction: column;
  min-height: 0;
}

#features .stack > fieldset.panel > label textarea {
  flex: 1 1 auto;
  min-height: 8rem;
}
