@import url("https://fonts.googleapis.com/css2?family=Cinzel:wght@400;500;600;700&display=swap");

:root {
  --bg: #130a08;
  --parchment: #efddbb;
  --parchment-light: #fff6e5;
  --ink: #241108;
  --muted: #74583d;
  --line: #b7833e;
  --line-strong: #5f2910;
  --accent: #9d3f14;
  --accent-strong: #421206;
  --accent-soft: #e6c58f;
  --gold: #dbb56a;
  --shadow: 0 34px 120px rgba(11, 6, 4, 0.55);
  --ornament: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 120 120'%3E%3Cg fill='none' stroke='%23622b12' stroke-width='3' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M15 57c15-2 29-14 31-29 7 10 17 16 31 18-12 4-20 12-24 25-5-8-14-12-38-14z'/%3E%3Cpath d='M61 12c3 12 12 20 23 23-11 3-19 11-22 22-3-10-11-19-22-22 10-4 18-12 21-23z'/%3E%3Cpath d='M90 54c4 17 12 26 21 31-11 2-19 8-26 20-1-13-8-22-20-28 12-3 19-10 25-23z'/%3E%3C/g%3E%3C/svg%3E");
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  font-family: "Cinzel", Cambria, Georgia, "Times New Roman", serif;
  color: var(--ink);
  background:
    radial-gradient(circle at 50% 0%, rgba(242, 195, 103, 0.2), transparent 22%),
    radial-gradient(circle at 12% 16%, rgba(150, 58, 23, 0.2), transparent 18%),
    radial-gradient(circle at 88% 14%, rgba(110, 41, 15, 0.25), transparent 16%),
    radial-gradient(circle at center, rgba(255, 224, 169, 0.06), transparent 40%),
    repeating-linear-gradient(90deg, rgba(255,255,255,0.014) 0 1px, transparent 1px 120px),
    linear-gradient(180deg, #31170f 0%, #180d09 35%, #0c0605 100%);
  background-attachment: fixed;
}

body::before {
  content: "";
  position: fixed;
  inset: 0;
  background:
    linear-gradient(90deg, rgba(0, 0, 0, 0.16), transparent 22%, transparent 78%, rgba(0, 0, 0, 0.18)),
    linear-gradient(180deg, rgba(0, 0, 0, 0.06), transparent 22%, transparent 78%, rgba(0, 0, 0, 0.12));
  pointer-events: none;
}

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

input,
textarea,
select {
  width: 100%;
  margin-top: 0.35rem;
  padding: 0.8rem 0.9rem;
  border: 1px solid var(--line);
  border-radius: 14px;
  background: rgba(255, 251, 244, 0.92);
  color: var(--ink);
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.55), 0 1px 0 rgba(99, 52, 20, 0.05);
}

textarea {
  resize: vertical;
}

label {
  display: block;
  font-size: 0.95rem;
  font-weight: 700;
  color: var(--muted);
}

h1,
h2,
h3,
h4 {
  margin: 0;
  font-family: "Cinzel", Cambria, Georgia, "Times New Roman", serif;
  letter-spacing: 0.01em;
}

.page-shell {
  max-width: 1740px;
  margin: 0 auto;
  padding: 2rem;
}

.hero,
.editor-card,
.preview-card {
  background:
    radial-gradient(circle at top, rgba(255,255,255,0.3), transparent 28%),
    linear-gradient(180deg, rgba(255, 247, 229, 0.98), rgba(242, 227, 200, 0.97));
  border: 1px solid rgba(196, 148, 82, 0.52);
  box-shadow: var(--shadow);
}

.hero {
  display: flex;
  justify-content: space-between;
  gap: 1.5rem;
  align-items: flex-start;
  margin-bottom: 1.5rem;
  padding: 2.35rem 2.35rem 2.55rem;
  border-radius: 36px;
  position: relative;
  overflow: hidden;
  background:
    radial-gradient(circle at 18% 0%, rgba(233, 189, 96, 0.2), transparent 30%),
    linear-gradient(135deg, rgba(71, 25, 14, 0.99), rgba(22, 10, 8, 0.99) 58%, rgba(53, 16, 6, 0.99));
}

.hero::after {
  content: "";
  position: absolute;
  inset: 0;
  background:
    radial-gradient(circle at 78% 18%, rgba(214, 170, 85, 0.18), transparent 22%),
    linear-gradient(90deg, transparent 0%, rgba(255,255,255,0.08) 12%, transparent 24%),
    linear-gradient(180deg, rgba(255,255,255,0.02), rgba(255,255,255,0));
  pointer-events: none;
}

.hero::before {
  content: "";
  position: absolute;
  inset: 14px;
  border: 1px solid rgba(227, 186, 117, 0.28);
  border-radius: 28px;
  pointer-events: none;
}

.hero-copy {
  max-width: 700px;
  position: relative;
  z-index: 1;
  padding-left: 0.5rem;
}

.hero-copy::before {
  content: none;
}

.hero-copy p:last-child {
  color: #e4cfaf;
  font-size: 1.18rem;
  max-width: 760px;
  line-height: 1.34;
}

.eyebrow {
  margin: 0 0 0.3rem;
  font-size: 0.8rem;
  letter-spacing: 0.22em;
  text-transform: uppercase;
  color: #efc56e;
  text-shadow: 0 1px 0 rgba(0, 0, 0, 0.34);
}

.hero-copy h1 {
  font-size: clamp(2.9rem, 4.2vw, 4.35rem);
  line-height: 0.9;
  color: #fff2d6;
  letter-spacing: 0.02em;
  text-shadow: 0 3px 18px rgba(0, 0, 0, 0.3);
  max-width: 8ch;
}

.toolbar {
  display: flex;
  flex-wrap: wrap;
  justify-content: flex-end;
  gap: 0.75rem;
  align-items: center;
  position: relative;
  z-index: 1;
  max-width: 760px;
}

#importFile,
#portraitFile {
  display: none;
}

.button {
  border: 0;
  border-radius: 0;
  padding: 0.88rem 1.1rem;
  cursor: pointer;
  transition: transform 160ms ease, opacity 160ms ease, background 160ms ease, box-shadow 160ms ease;
  box-shadow: inset 0 1px 0 rgba(255,255,255,0.22), 0 6px 16px rgba(54, 27, 12, 0.18);
  font-weight: 700;
  letter-spacing: 0.01em;
}

.button:hover {
  transform: translateY(-2px);
  box-shadow: inset 0 1px 0 rgba(255,255,255,0.18), 0 8px 18px rgba(54, 27, 12, 0.2);
}

.button.primary {
  background: linear-gradient(135deg, #b24d19 0%, #5f1704 100%);
  color: #fff8f0;
}

.button.secondary,
.button.ghost {
  background:
    linear-gradient(180deg, rgba(255, 230, 178, 0.95), rgba(213, 154, 61, 0.95));
  color: #381608;
}

.button.danger {
  background: linear-gradient(180deg, #f2d0c5, #e9b1a4);
  color: #7b2013;
}

.workspace {
  display: grid;
  grid-template-columns: minmax(480px, 1.04fr) minmax(560px, 1.08fr);
  gap: 1.7rem;
  align-items: start;
}

.editor-card,
.preview-card {
  border-radius: 0;
  position: relative;
  overflow: hidden;
}

.editor-card::before,
.preview-card::before {
  content: "";
  position: absolute;
  inset: 14px;
  border: 1px solid rgba(111, 60, 27, 0.26);
  border-radius: 0;
  pointer-events: none;
}

.editor-card::after,
.preview-card::after {
  content: "";
  position: absolute;
  width: 160px;
  height: 160px;
  right: -26px;
  top: -28px;
  background:
    var(--ornament) center/contain no-repeat,
    radial-gradient(circle, rgba(214,170,85,0.14) 0%, transparent 68%);
  opacity: 0.08;
  pointer-events: none;
}

.editor-card {
  padding: 1.8rem;
  background:
    radial-gradient(circle at 14% 0%, rgba(255, 212, 128, 0.15), transparent 22%),
    linear-gradient(180deg, rgba(59, 25, 15, 0.99), rgba(24, 11, 8, 0.99));
  border-color: rgba(180, 125, 62, 0.34);
}

.preview-card {
  position: sticky;
  top: 1rem;
  padding: 1.25rem;
  background:
    radial-gradient(circle at top, rgba(255,255,255,0.18), transparent 24%),
    linear-gradient(180deg, rgba(59, 23, 12, 0.98), rgba(17, 9, 7, 0.99));
  border-color: rgba(185, 128, 64, 0.38);
}

.section-heading,
.section-heading.inline {
  display: flex;
  justify-content: space-between;
  gap: 1rem;
}

.section-heading {
  align-items: end;
}

.section-heading.inline {
  align-items: center;
}

.section-heading p,
.subtle {
  color: var(--muted);
}

.editor-card .section-heading h2,
.editor-card .section-heading h3,
.editor-card .section-heading.inline h3,
.editor-card label {
  color: #fff0cd;
}

.editor-card .section-heading p,
.editor-card .subtle {
  color: #ecd7bb;
}

.editor-section {
  margin-top: 1.35rem;
  padding: 1.3rem;
  border-top: 1px solid rgba(125, 79, 43, 0.18);
  border-radius: 0;
  background:
    radial-gradient(circle at top, rgba(255,255,255,0.24), transparent 36%),
    linear-gradient(180deg, rgba(253,244,225,0.98), rgba(236,216,179,0.95));
  box-shadow: inset 0 0 0 1px rgba(125,79,43,0.16), 0 14px 32px rgba(16, 8, 5, 0.16);
}

.editor-section + .editor-section {
  margin-top: 1rem;
}

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

.library-panel {
  padding: 1.15rem;
  border-radius: 0;
  border: 1px solid rgba(111, 60, 27, 0.28);
  background:
    radial-gradient(circle at top, rgba(255,255,255,0.3), transparent 40%),
    linear-gradient(180deg, rgba(255,251,241,0.9), rgba(243,228,196,0.82));
  box-shadow: inset 0 1px 0 rgba(255,255,255,0.45), 0 10px 22px rgba(29, 15, 9, 0.08);
}

.dm-auth-panel {
  margin-top: 0.9rem;
  padding: 1rem;
  border-radius: 0;
  border: 1px dashed rgba(125, 79, 43, 0.28);
  background:
    linear-gradient(180deg, rgba(255,250,242,0.9), rgba(246,232,205,0.84));
}

.dm-auth-state {
  display: grid;
  gap: 0.85rem;
}

.dm-auth-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 0.75rem;
}

.library-list {
  display: grid;
  gap: 0.75rem;
  margin-top: 0.9rem;
}

.library-card {
  width: 100%;
  text-align: left;
  padding: 1rem 1.05rem;
  border-radius: 0;
  border: 1px solid rgba(111, 60, 27, 0.28);
  background:
    linear-gradient(180deg, rgba(255,255,255,0.96), rgba(245,235,218,0.94));
  color: var(--ink);
  box-shadow: 0 6px 14px rgba(39, 20, 10, 0.08);
}

.library-card strong,
.library-card span,
.library-card small {
  display: block;
}

.library-card span,
.library-card small {
  color: #65462b;
  margin-top: 0.2rem;
}

.library-card.active {
  border-color: var(--accent);
  box-shadow: 0 0 0 2px rgba(162, 75, 27, 0.18), 0 10px 24px rgba(49, 24, 11, 0.12);
}

.empty-state {
  padding: 1rem;
  border-radius: 0;
  border: 1px dashed rgba(125, 79, 43, 0.35);
  color: #5a3c22;
  background: rgba(255, 252, 247, 0.55);
}

.field-help {
  display: block;
  margin-top: 0.45rem;
  font-size: 0.82rem;
  font-weight: 400;
  color: #65462b;
}

.grid {
  display: grid;
  gap: 0.95rem;
}

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

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

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

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

.wide {
  grid-column: 1 / -1;
}

.tab-bar {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 0.85rem;
  position: relative;
  padding: 0.4rem;
  border-radius: 0;
  background: linear-gradient(180deg, rgba(86, 40, 24, 0.75), rgba(52, 23, 14, 0.72));
  box-shadow: inset 0 1px 0 rgba(255,255,255,0.08), 0 14px 30px rgba(11, 6, 4, 0.25);
}

.tab-button {
  border: 1px solid rgba(125, 79, 43, 0.34);
  border-radius: 0;
  padding: 1.05rem 1rem;
  background: linear-gradient(180deg, rgba(211, 184, 132, 0.72), rgba(161, 116, 52, 0.7));
  color: #fff3dd;
  font-family: "Cinzel", Cambria, Georgia, "Times New Roman", serif;
  font-size: 1.08rem;
  cursor: pointer;
  box-shadow: inset 0 1px 0 rgba(255,255,255,0.2), 0 10px 18px rgba(33, 16, 8, 0.2);
  text-shadow: 0 1px 1px rgba(0, 0, 0, 0.28);
}

.tab-button.active {
  background:
    linear-gradient(180deg, rgba(255,247,228,0.98), rgba(234,214,174,0.98));
  color: var(--accent-strong);
  box-shadow: 0 0 0 1px rgba(125, 79, 43, 0.24), 0 14px 28px rgba(50, 25, 11, 0.14);
  text-shadow: none;
}

.tab-button:not(.active):hover {
  color: #fff7e8;
  background: linear-gradient(180deg, rgba(193, 143, 75, 0.86), rgba(140, 89, 37, 0.82));
}

.tab-panel {
  display: none;
}

.tab-panel.active {
  display: block;
}

.portrait-editor {
  display: grid;
  grid-template-columns: 180px 1fr;
  gap: 1rem;
  align-items: center;
}

.portrait-frame {
  position: relative;
  overflow: hidden;
  border-radius: 0;
  border: 4px solid var(--line-strong);
  aspect-ratio: 3 / 4;
  background:
    radial-gradient(circle at top, rgba(255,255,255,0.2), transparent 30%),
    linear-gradient(180deg, #3f2f24, #1d1511);
  box-shadow:
    inset 0 0 0 2px rgba(255, 229, 188, 0.18),
    0 16px 30px rgba(33, 18, 11, 0.16);
}

.portrait-picker {
  cursor: pointer;
}

.portrait-picker:hover,
.portrait-picker:focus-visible {
  transform: translateY(-1px);
  box-shadow:
    inset 0 0 0 2px rgba(255, 229, 188, 0.18),
    0 12px 28px rgba(49, 28, 17, 0.22);
}

.portrait-picker:focus-visible {
  outline: 2px solid rgba(156, 79, 32, 0.65);
  outline-offset: 4px;
}

.portrait-frame::before {
  content: "";
  position: absolute;
  inset: 8px;
  border: 1px solid rgba(244, 234, 214, 0.28);
  border-radius: 6px;
  pointer-events: none;
}

.portrait-frame.small {
  max-width: 220px;
}

.portrait-frame img {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: cover;
  object-position: center top;
  display: none;
}

.portrait-placeholder {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  color: #f4ead6;
  text-transform: uppercase;
  letter-spacing: 0.14em;
  background: linear-gradient(180deg, rgba(36, 23, 15, 0.15), rgba(36, 23, 15, 0.55));
}

.portrait-meta {
  padding: 1rem;
  border: 1px solid rgba(205, 165, 111, 0.45);
  border-radius: 0;
  background: linear-gradient(180deg, rgba(255,255,255,0.82), rgba(247,238,223,0.72));
}

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

.ability-editor-card {
  padding: 0.25rem;
  border-radius: 0;
  background:
    linear-gradient(180deg, rgba(111, 60, 27, 0.18), rgba(111, 60, 27, 0.05));
}

.ability-editor-frame {
  height: 100%;
  padding: 1rem;
  border: 1px solid rgba(125, 79, 43, 0.3);
  border-radius: 0;
  background:
    radial-gradient(circle at top, rgba(255,255,255,0.3), transparent 40%),
    linear-gradient(180deg, rgba(255,255,255,0.94), rgba(247,236,219,0.92));
}

.ability-editor-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 0.8rem;
}

.ability-editor-header span,
.mini-ability-stats span {
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: 0.1em;
  font-size: 0.8rem;
}

.ability-editor-header strong {
  font-size: 2rem;
}

.mini-ability-stats {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 0.7rem;
  margin-top: 0.8rem;
}

.mini-ability-stats div {
  padding: 0.65rem;
  border-radius: 0;
  border: 1px solid rgba(205, 165, 111, 0.45);
  background: rgba(255, 252, 247, 0.72);
}

.mini-ability-stats strong {
  display: block;
  margin-top: 0.25rem;
}

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

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

.save-card {
  padding: 1rem;
  border-radius: 0;
  border: 1px solid rgba(125, 79, 43, 0.3);
  background: linear-gradient(180deg, rgba(255,255,255,0.86), rgba(248,240,226,0.78));
}

.save-fields {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 0.8rem;
  margin-top: 0.8rem;
}

.derived-card {
  padding: 1rem;
  border-radius: 0;
  border: 1px solid rgba(125, 79, 43, 0.3);
  background: linear-gradient(180deg, rgba(255,255,255,0.86), rgba(248,240,226,0.78));
}

.chip-list {
  display: flex;
  flex-wrap: wrap;
  gap: 0.65rem;
  margin-top: 0.9rem;
}

.chip {
  padding: 0.6rem 0.8rem;
  border-radius: 0;
  border: 1px solid rgba(125, 79, 43, 0.28);
  background: linear-gradient(180deg, #f4e0b8, #e1bb79);
  color: #4f2109;
  font-size: 0.92rem;
  box-shadow: inset 0 1px 0 rgba(255,255,255,0.32);
}

.repeat-list {
  display: grid;
  gap: 0.9rem;
}

.repeat-row {
  display: grid;
  gap: 0.8rem;
  padding: 1rem;
  border: 1px solid rgba(125, 79, 43, 0.3);
  border-radius: 8px;
  background: linear-gradient(180deg, rgba(255,255,255,0.84), rgba(249,240,226,0.78));
}

.skill-row {
  grid-template-columns: 1.6fr 0.8fr 0.7fr 0.7fr 1.5fr auto;
  align-items: end;
}

.simple-row {
  grid-template-columns: 1fr 2fr auto;
  align-items: end;
}

.spell-row {
  grid-template-columns: 1fr 1fr 1fr auto;
  align-items: end;
}

.weapon-row {
  grid-template-columns: 1fr 0.7fr 0.8fr 1.5fr auto;
  align-items: end;
}

.skills-table-wrap {
  display: grid;
  gap: 0.7rem;
}

.skills-table-header,
.skill-table-row {
  display: grid;
  grid-template-columns: 0.6fr 2.2fr 0.8fr 0.8fr 0.8fr 0.8fr;
  gap: 0.7rem;
  align-items: center;
}

.skills-table-header {
  padding: 0.85rem 1rem;
  border-radius: 8px;
  background: linear-gradient(180deg, #e8c98e, #d5a557);
  color: #55290f;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  font-size: 0.83rem;
  box-shadow: inset 0 1px 0 rgba(255,255,255,0.28);
}

.skill-table {
  display: grid;
  gap: 0.55rem;
}

.skill-table-row {
  padding: 0.85rem 1rem;
  border-radius: 8px;
  border: 1px solid rgba(125, 79, 43, 0.28);
  background: linear-gradient(180deg, rgba(255,255,255,0.82), rgba(248,240,225,0.74));
}

.skill-name-cell small {
  color: var(--muted);
}

.skill-total-cell {
  color: var(--accent);
  font-weight: 700;
}

.checkbox-cell {
  display: flex;
  justify-content: center;
  margin: 0;
}

.checkbox-cell input {
  width: 1.1rem;
  height: 1.1rem;
  margin: 0;
}

.gear-slot-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 0.9rem;
}

.gear-slot-card {
  padding: 0.9rem;
  border-radius: 0;
  border: 1px solid rgba(125, 79, 43, 0.28);
  background: linear-gradient(180deg, rgba(255,255,255,0.84), rgba(248,240,225,0.76));
}

.gear-slot-card span {
  display: block;
  color: #65462b;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  font-size: 0.8rem;
}

.print-sheet {
  min-height: 1120px;
  padding: 1.5rem;
  border-radius: 0;
  background:
    radial-gradient(circle at top center, rgba(223, 170, 82, 0.28), transparent 20%),
    radial-gradient(circle at bottom right, rgba(162, 75, 27, 0.18), transparent 26%),
    linear-gradient(180deg, #d9b775, #a16b36 12%, #ead7ae 13%, #d9b775 100%);
}

.folio-border {
  position: relative;
  padding: 1.3rem;
  border: 4px double var(--line-strong);
  border-radius: 0;
  background:
    radial-gradient(circle at top, rgba(255,255,255,0.2), transparent 30%),
    linear-gradient(180deg, rgba(255, 249, 238, 0.98), rgba(244,233,207,0.96));
  box-shadow: inset 0 0 0 1px rgba(255, 240, 214, 0.5), inset 0 0 50px rgba(112, 67, 23, 0.06);
}

.folio-border::before,
.folio-border::after {
  content: none;
}

.sheet-header {
  display: grid;
  grid-template-columns: 1.5fr 0.9fr;
  gap: 1rem;
  align-items: start;
  padding: 0.2rem 0 1.2rem;
  border-bottom: 2px solid rgba(196, 148, 82, 0.72);
}

.title-block h2 {
  font-size: clamp(2.4rem, 2.8vw, 3rem);
  color: #31160c;
  letter-spacing: 0.01em;
  font-family: "Cinzel", Cambria, Georgia, "Times New Roman", serif;
}

.title-block .subtle {
  font-size: 1rem;
  color: #5b3f25;
}

.title-block {
  min-width: 0;
}

.crest-line {
  width: 130px;
  height: 5px;
  margin-top: 0.9rem;
  border-radius: 999px;
  background: linear-gradient(90deg, var(--accent), rgba(214, 170, 85, 0.35), transparent);
  box-shadow: 0 0 14px rgba(162, 75, 27, 0.2);
}

.header-stats,
.sheet-grid,
.ability-preview,
.stat-list,
.mini-facts {
  display: grid;
  gap: 0.8rem;
}

.header-stats {
  grid-template-columns: repeat(3, minmax(0, 1fr));
  align-self: start;
}

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

.sheet-grid.first-row {
  grid-template-columns: 0.82fr 1.1fr 1fr;
}

.sheet-section {
  padding: 1.05rem;
  border: 1px solid rgba(147, 91, 36, 0.72);
  border-radius: 0;
  background:
    radial-gradient(circle at top, rgba(255,255,255,0.24), transparent 44%),
    linear-gradient(180deg, rgba(255,253,247,0.93), rgba(243,231,206,0.9));
  box-shadow: inset 0 1px 0 rgba(255,255,255,0.42), 0 10px 20px rgba(72, 36, 12, 0.08);
}

.sheet-section h3,
.attack-box h4 {
  font-size: 2rem;
  line-height: 1;
  color: #35180c;
  margin-bottom: 0.75rem;
  font-family: "Cinzel", Cambria, Georgia, "Times New Roman", serif;
}

.sheet-section.full {
  grid-column: 1 / -1;
}

.portrait-section .portrait-frame {
  width: 100%;
  margin-top: 0.8rem;
}

.mini-facts {
  grid-template-columns: 1fr;
  margin-top: 0.8rem;
}

.header-stats div,
.mini-facts div,
.stat-list div,
.ability-card {
  position: relative;
  padding: 0.85rem;
  border: 1px solid rgba(171, 115, 47, 0.88);
  border-radius: 0;
  background:
    linear-gradient(180deg, rgba(255,255,255,0.97), rgba(244,235,217,0.93));
}

.header-stats div {
  min-height: 108px;
}

.header-stats div::before,
.mini-facts div::before,
.stat-list div::before,
.ability-card::before {
  content: "";
  position: absolute;
  inset: 7px;
  border: 1px solid rgba(125, 79, 43, 0.22);
  border-radius: 0;
  pointer-events: none;
}

.header-stats span,
.mini-facts span,
.stat-list span,
.ability-card span {
  display: block;
  font-size: 0.8rem;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: #624328;
}

.header-stats strong,
.stat-list strong {
  display: block;
  font-size: 1.7rem;
}

.mini-facts strong {
  display: block;
  font-size: 1rem;
  line-height: 1.2;
  overflow-wrap: anywhere;
  color: #241108;
}

.ability-preview {
  grid-template-columns: repeat(2, minmax(0, 1fr));
  margin-top: 0.8rem;
}

.ability-card {
  text-align: center;
  overflow: hidden;
  min-height: 184px;
}

.ability-card strong {
  display: block;
  font-size: 2.2rem;
  line-height: 0.95;
  margin-top: 0.15rem;
  margin-bottom: 0.45rem;
}

.ability-card small {
  display: block;
  margin-top: 0.15rem;
  padding: 0 0.2rem;
  color: var(--muted);
  font-size: 0.78rem;
  line-height: 1.15;
}

.attack-box {
  margin-top: 1rem;
  padding-top: 0.2rem;
}

.table-list,
.bullet-list {
  display: grid;
  gap: 0.5rem;
  margin-top: 0.8rem;
}

.table-row {
  display: grid;
  grid-template-columns: minmax(0, 2fr) repeat(4, minmax(0, 1fr));
  gap: 0.6rem;
  padding: 0.8rem;
  border-radius: 0;
  border: 1px solid rgba(205, 165, 111, 0.5);
  background: rgba(255, 251, 243, 0.82);
}

.compact-table .table-row {
  grid-template-columns: repeat(3, minmax(0, 1fr));
}

.table-row.header {
  font-weight: 700;
  color: #55290f;
  background: linear-gradient(180deg, #ecd2a8, #ddb886);
}

.bullet-item {
  padding: 0.8rem 0.9rem;
  border-radius: 0;
  border: 1px solid rgba(205, 165, 111, 0.5);
  background: rgba(255, 251, 243, 0.82);
}

.preview-card .notes,
.preview-card .bullet-item,
.preview-card .table-row,
.preview-card .mini-facts strong,
.preview-card .stat-list strong,
.preview-card .header-stats strong,
.preview-card .ability-card strong {
  font-family: "Cinzel", Cambria, Georgia, "Times New Roman", serif;
}

.notes {
  white-space: pre-wrap;
  color: #2e170d;
}

.library-panel h3,
.library-panel label,
.library-panel p,
.library-panel .subtle,
.library-panel .field-help,
.dm-auth-panel label,
.dm-auth-panel p,
.dm-auth-state p,
.empty-state,
.library-card strong,
.library-card span,
.library-card small {
  color: #3a2110 !important;
}

.editor-section h3,
.editor-section h4,
.editor-section label,
.editor-section p,
.editor-section .subtle,
.editor-section .field-help,
.editor-section .section-heading p,
.editor-section .section-heading.inline p,
.portrait-meta p,
.save-card h4,
.derived-card h3,
.derived-card p,
.save-card p {
  color: #3a2110 !important;
}

.editor-section input,
.editor-section textarea,
.editor-section select,
.dm-auth-panel input,
.library-panel input,
.library-panel textarea,
.library-panel select {
  color: #2e170d;
  background: rgba(255, 250, 243, 0.98);
  border-radius: 0;
}

.editor-section .button,
.library-panel .button,
.dm-auth-panel .button {
  font-family: "Cinzel", Cambria, Georgia, "Times New Roman", serif;
}

.dm-auth-panel input,
.library-panel input,
.library-panel textarea,
.library-panel select {
  color: #2e170d;
  background: rgba(255, 250, 243, 0.96);
}

.compact-bullets {
  margin-top: 0.75rem;
}

.subtle-spacer {
  margin-top: 0.7rem;
}

@media screen and (max-width: 1380px) {
  .workspace {
    grid-template-columns: 1fr;
  }

  .preview-card {
    position: static;
  }

  .sheet-grid.first-row {
    grid-template-columns: 1fr;
  }
}

@media screen and (max-width: 900px) {
  .page-shell {
    padding: 1rem;
  }

  .hero {
    flex-direction: column;
  }

  .toolbar {
    justify-content: flex-start;
  }

  .grid.two,
  .grid.three,
  .grid.five,
  .panel-grid,
  .save-grid,
  .ability-editor-grid,
  .derived-grid,
  .skill-row,
  .simple-row,
  .spell-row,
  .weapon-row,
  .skills-table-header,
  .skill-table-row,
  .gear-slot-grid,
  .sheet-grid,
  .header-stats,
  .ability-preview,
  .stat-list,
  .mini-facts,
  .table-row,
  .compact-table .table-row,
  .portrait-editor {
    grid-template-columns: 1fr;
  }

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

@media print {
  @page {
    size: letter portrait;
    margin: 0.28in;
  }

  body {
    background: #fff;
    color: #1f140d;
  }

  .no-print {
    display: none !important;
  }

  .page-shell,
  .workspace,
  .preview-card,
  .print-sheet {
    margin: 0;
    padding: 0;
    box-shadow: none;
    border: 0;
    max-width: none;
    width: 100%;
  }

  .workspace {
    display: block;
    grid-template-columns: none;
    gap: 0;
  }

  .preview-card {
    background: #fff;
    position: static;
  }

  .print-sheet {
    min-height: auto;
    border-radius: 0;
    background: #fff;
    display: block;
  }

  .folio-border {
    padding: 0.12in;
    border: 2px solid #9a6a3a;
    border-radius: 0;
    background: #fff;
    width: 100%;
    box-decoration-break: clone;
    -webkit-box-decoration-break: clone;
  }

  .folio-border::before,
  .folio-border::after {
    display: none;
  }

  .sheet-header {
    grid-template-columns: 1.55fr 0.95fr;
    gap: 0.1in;
    padding-bottom: 0.08in;
    margin-bottom: 0.08in;
  }

  .title-block h2 {
    font-size: 24pt;
    line-height: 1.05;
  }

  .eyebrow {
    font-size: 9pt;
    letter-spacing: 0.16em;
  }

  .subtle {
    font-size: 10pt;
  }

  .crest-line {
    width: 1.3in;
    height: 2px;
    margin-top: 0.06in;
  }

  .header-stats {
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 0.07in;
    align-self: start;
  }

  .header-stats div,
  .mini-facts div,
  .stat-list div,
  .ability-card,
  .sheet-section,
  .table-row,
  .bullet-item {
    break-inside: avoid;
    page-break-inside: avoid;
  }

  .header-stats div {
    padding: 0.07in 0.08in;
    border-radius: 10px;
    min-height: 0.62in;
  }

  .header-stats strong {
    font-size: 18pt;
  }

  .sheet-grid,
  .sheet-grid.first-row {
    grid-template-columns: 1.02fr 1.18fr 1fr;
    gap: 0.1in;
    margin-top: 0.1in;
    align-items: start;
  }

  .sheet-section {
    padding: 0.08in;
    border-radius: 12px;
    background: #fff;
  }

  .portrait-section .portrait-frame {
    width: 100%;
    max-height: 2.7in;
    min-height: 0;
    aspect-ratio: 3 / 4;
    margin-top: 0.05in;
  }

  .portrait-frame {
    border-width: 2px;
    border-radius: 12px;
    box-shadow: none;
  }

  .portrait-frame::before {
    inset: 4px;
    border-radius: 8px;
  }

  .portrait-frame img {
    object-position: center 18%;
  }

  .mini-facts {
    grid-template-columns: 1fr;
    gap: 0.06in;
    margin-top: 0.06in;
  }

  .mini-facts div,
  .stat-list div {
    padding: 0.06in 0.07in;
    border-radius: 10px;
  }

  .mini-facts strong {
    font-size: 12pt;
  }

  .ability-preview {
    grid-template-columns: repeat(3, 1fr);
    gap: 0.08in;
    margin-top: 0.06in;
  }

  .ability-card {
    padding: 0.07in 0.05in;
    border-radius: 10px;
  }

  .ability-card::before,
  .header-stats div::before,
  .mini-facts div::before,
  .stat-list div::before {
    inset: 4px;
    border-radius: 7px;
  }

  .ability-card strong {
    font-size: 20pt;
  }

  .ability-card small {
    font-size: 8.5pt;
    line-height: 1.12;
  }

  .stat-list {
    grid-template-columns: repeat(2, 1fr);
    gap: 0.08in;
    margin-top: 0.05in;
  }

  .stat-list strong {
    font-size: 16pt;
  }

  .attack-box {
    margin-top: 0.08in;
    font-size: 9pt;
  }

  .table-list,
  .bullet-list {
    gap: 0.05in;
    margin-top: 0.05in;
  }

  .table-row {
    gap: 0.05in;
    padding: 0.06in 0.07in;
    border-radius: 8px;
    font-size: 8.5pt;
  }

  .bullet-item {
    padding: 0.06in 0.07in;
    border-radius: 8px;
    font-size: 8.7pt;
    line-height: 1.18;
  }

  .notes {
    font-size: 9pt;
    line-height: 1.2;
  }

  .sheet-section h3,
  .attack-box h4 {
    font-size: 13pt;
    line-height: 1.05;
  }

  .sheet-section.full {
    grid-column: 1 / -1;
  }

  .table-row {
    grid-template-columns: 2.2fr 0.8fr 0.8fr 0.8fr 0.8fr;
  }

  .compact-table .table-row {
    grid-template-columns: repeat(3, 1fr);
  }
}
