/* =========================================================
   BREW IT YOURSELF
   styles.css
========================================================= */

:root {
  --bg: #d9dee5;
  --panel: #ffffff;
  --text: #1f2937;
  --muted: #6b7280;
  --border: #c9d0d9;
  --shadow: 0 12px 35px rgba(38, 54, 77, 0.12);

  --toolbar-bg: rgba(255, 255, 255, 0.92);
  --toolbar-text: #1f2937;
  --toolbar-muted: #6b7280;

  --button-bg: #ffffff;
  --button-text: #1f2937;
  --button-border: #b6bcc6;
  --button-hover: #f3f5f8;

  --workspace-bg: #ffffff;
  --preview-bg: #2b3440;

  --editor-bg: #f7f7f8;
  --editor-text: #171717;
  --gutter-bg: #f4f4f4;
  --gutter-text: #888888;

  --resizer-light-1: #d3d7dc;
  --resizer-light-2: #b8bfc7;
  --resizer-dark-1: #2f3743;
  --resizer-dark-2: #4a5563;

  --page-width: 816px;
  --page-height: 1056px;
  --page-margin: 48px;
  --content-width: calc(var(--page-width) - (var(--page-margin) * 2));
  --content-height: calc(var(--page-height) - (var(--page-margin) * 2));

  --paper: #fdf8e5;

  --sb-bg: #ece7d4;
  --sb-border: #646050;
  --sb-text: #2f261b;
  --sb-heading: #2a1f14;
  --sb-subtitle: #4f4030;
  --sb-rule: #646050;
  --sb-table-border: #646050;
  --sb-table-head-bg: #dbd6c3;
}

body.dark {
  --bg: #11161d;
  --panel: #1a1f27;
  --text: #e5e7eb;
  --muted: #9ca3af;
  --border: #3a424f;

  --toolbar-bg: #1b2028;
  --toolbar-text: #f3f4f6;
  --toolbar-muted: #9ca3af;

  --button-bg: #2a313d;
  --button-text: #f3f4f6;
  --button-border: #4b5563;
  --button-hover: #394252;

  --workspace-bg: #161b22;
  --preview-bg: #2b3440;

  --editor-bg: #000000;
  --editor-text: #e5e7eb;
  --gutter-bg: #0b0b0b;
  --gutter-text: #6b7280;
}

* {
  box-sizing: border-box;
}

html,
body {
  margin: 0;
  padding: 0;
  height: 100%;
  font-family: Garamond, "EB Garamond", serif;
  background: var(--bg);
  color: var(--text);
}

body {
  padding: 14px;
}

.app-shell {
  display: flex;
  flex-direction: column;
  gap: 10px;
  height: calc(100vh - 28px);
}

.top-toolbar {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 16px;
  padding: 12px 16px;
  border: 1px solid var(--border);
  border-radius: 18px;
  background: var(--toolbar-bg);
  box-shadow: 0 6px 16px rgba(38, 54, 77, 0.08);
}

.toolbar-left {
  display: flex;
  flex-direction: column;
  gap: 8px;
  min-width: 300px;
}

.toolbar-left-actions {
  display: flex;
  align-items: center;
  gap: 12px;
  flex-wrap: wrap;
}

.brand {
  font-size: 2rem;
  font-weight: bolder;
  font-variant: small-caps;
  text-align: center;
  appearance: none;
  border: 1px solid #1f2937;
  background: #fdf8e5 url("images/ParchmentScanned.png") no-repeat center fixed;
  color: #1f2937;
  padding: 10px 20px;
  border-radius: 999px;
  cursor: pointer;
  transition:
    background 140ms ease,
    transform 140ms ease,
    box-shadow 140ms ease;
}

.brand a, .brand a:visited {
  color: #1b2432;
  text-decoration: none;
}

.brand,
.brand:visited {
  color: #1b2432;
  text-decoration: none;
}

.brand a:hover {
  color: var(--button-text);
}	

.toolbar-right {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 12px;
  flex-wrap: wrap;
  flex: 1;
}


.toolbar-button {
  appearance: none;
  border: 1px solid var(--button-border);
  background: var(--button-bg);
  color: var(--button-text);
  padding: 10px 14px;
  border-radius: 999px;
  font-size: 0.95rem;
  font-weight: 600;
  cursor: pointer;
  transition:
    background 140ms ease,
    transform 140ms ease,
    box-shadow 140ms ease;
}

.toolbar-button-primary {
  background: #9bb8ee;
  color: #1b2432;
  font-weight: 600;
}

.toolbar-button-primary:hover {
  filter: brightness(1.04);
}

.toolbar-button:hover {
  background: var(--button-hover);
  box-shadow: 0 4px 10px rgba(0, 0, 0, 0.18);
}

.toolbar-button:active {
  transform: translateY(1px);
}

.properties-toolbar-button {
  appearance: none;
  max-width: 150px;
  margin: 0 auto;
  border: 1px solid var(--button-border);
  background: var(--button-bg);
  color: var(--button-text);
  padding: 5px 7px;
  border-radius: 12px;
  font-size: 0.75rem;
  font-weight: 600;
  cursor: pointer;
  transition:
    background 140ms ease,
    transform 140ms ease,
    box-shadow 140ms ease;
}

.properties-toolbar-button:hover {
  background: var(--button-hover);
  box-shadow: 0 4px 10px rgba(0, 0, 0, 0.18);
}

.properties-toolbar-button:active {
  transform: translateY(1px);
}

.toolbar-button-wide {
  width: 100%;
}

.toolbar-dropdown {
  position: relative;
}

.dropdown-toggle {
  display: inline-flex;
  align-items: center;
  gap: 8px;
}

.dropdown-caret {
  font-size: 0.8rem;
  line-height: 1;
  opacity: 0.8;
}

.dropdown-menu {
  position: absolute;
  top: calc(100% + 8px);
  left: 0;
  min-width: 220px;
  padding: 8px;
  border: 1px solid var(--border);
  border-radius: 14px;
  background: var(--panel);
  box-shadow: 0 16px 36px rgba(0, 0, 0, 0.2);
  display: none;
  z-index: 1200;
}

.toolbar-dropdown.open .dropdown-menu {
  display: block;
}

.dropdown-item {
  display: block;
  width: 100%;
  appearance: none;
  border: 0;
  background: transparent;
  color: var(--text);
  text-align: left;
  padding: 10px 12px;
  border-radius: 10px;
  font: inherit;
  font-size: 0.97rem;
  cursor: pointer;
  transition: background 140ms ease;
}

.dropdown-item:hover {
  background: var(--button-hover);
}

/*------------------------------------
       GOOOOOOOOOOOGLE
------------------------------------*/
.google-auth-connected {
  display: inline-flex;
  align-items: center;
  gap: 8px;
}

.google-auth-avatar {
  width: 24px;
  height: 24px;
  border-radius: 999px;
  object-fit: cover;
  display: inline-block;
  border: 1px solid var(--button-border);
}

.google-auth-status-dot {
  width: 8px;
  height: 8px;
  border-radius: 999px;
  background: #3cbf30;
  display: inline-block;
}

.zoom-control {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  color: var(--toolbar-text);
  font-size: 0.9rem;
}

.zoom-label,
.zoom-value {
  white-space: nowrap;
}

#previewZoom {
  width: 120px;
  background: transparent;
  cursor: pointer;
  accent-color: #9aa3af;
}

body.dark #previewZoom {
  accent-color: #5a6472;
}

.theme-switch {
  position: relative;
  display: inline-block;
  width: 58px;
  height: 30px;
}

.theme-switch input {
  opacity: 0;
  width: 0;
  height: 0;
}

.slider {
  position: absolute;
  inset: 0;
  cursor: pointer;
  background-color: #bdbdbd;
  border-radius: 999px;
  overflow: hidden;
  transition:
    background-color 0.28s ease,
    box-shadow 0.28s ease,
    transform 0.28s ease;
}

.slider::before {
  content: "";
  position: absolute;
  left: 3px;
  top: 3px;
  width: 24px;
  height: 24px;
  border-radius: 50%;
  background-color: #ffffff;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.28);
  z-index: 3;
  transition:
    transform 0.28s ease,
    box-shadow 0.28s ease,
    background-color 0.28s ease;
}

.toggle-icon {
  position: absolute;
  top: 50%;
  transform: translateY(-50%);
  font-size: 12px;
  line-height: 1;
  pointer-events: none;
  user-select: none;
  z-index: 1;
  transition:
    opacity 0.28s ease,
    transform 0.28s ease,
    filter 0.28s ease;
}

.toggle-moon {
  left: 10px;
  color: #e5e7eb;
  text-shadow:
    0 0 4px rgba(255, 255, 255, 0.6),
    0 0 8px rgba(200, 220, 255, 0.35);
}

.toggle-sun {
  right: 10px;
  color: #facc15;
  text-shadow:
    0 0 4px rgba(255, 200, 0, 0.7),
    0 0 10px rgba(255, 140, 0, 0.45);
}

.theme-switch input:not(:checked) + .slider .toggle-sun {
  opacity: 1;
  transform: translateY(-50%) scale(1.05);
  filter: brightness(1.1);
}

.theme-switch input:not(:checked) + .slider .toggle-moon {
  opacity: 0.45;
  filter: brightness(0.8);
}

.theme-switch input:checked + .slider {
  background-color: #2a303c;
  box-shadow:
    0 0 0 1px rgba(255, 255, 255, 0.04) inset,
    0 0 10px rgba(42, 48, 60, 0.35);
}

.theme-switch input:checked + .slider::before {
  transform: translateX(28px);
  background-color: #f8fafc;
  box-shadow:
    0 1px 3px rgba(0, 0, 0, 0.35),
    0 0 10px rgba(255, 255, 255, 0.08);
}

.theme-switch input:checked + .slider .toggle-moon {
  opacity: 1;
  transform: translateY(-50%) scale(1.05);
  filter: brightness(1.15);
}

.theme-switch input:checked + .slider .toggle-sun {
  opacity: 0.45;
  filter: brightness(0.75);
}

.theme-switch:hover .slider {
  transform: translateY(-1px);
}

.theme-switch:active .slider {
  transform: translateY(0);
}

.workspace {
  display: flex;
  flex: 1;
  min-height: 0;
  border-radius: 24px;
  overflow: hidden;
  box-shadow: var(--shadow);
  border: 1px solid var(--border);
  background: var(--workspace-bg);
}

.pane {
  width: 50%;
  min-width: 260px;
  display: flex;
  flex-direction: column;
  background: var(--panel);
}

.editor-container {
  position: relative;
  display: flex;
  height: 100%;
  width: 100%;
  background: var(--editor-bg);
  font-family: "Cascadia Code", "Fira Code", Consolas, monospace;
}

.editor-active-line {
  position: absolute;
  left: 3.5rem;
  right: 0;
  top: 0;
  height: 21px;
  pointer-events: none;
  z-index: 1;
  background: rgba(255, 255, 255, 0.06);
  border-top: 1px solid rgba(255, 255, 255, 0.04);
  border-bottom: 1px solid rgba(255, 255, 255, 0.04);
}

body:not(.dark) .editor-active-line {
  background: rgba(0, 0, 0, 0.045);
  border-top: 1px solid rgba(0, 0, 0, 0.03);
  border-bottom: 1px solid rgba(0, 0, 0, 0.03);
}

.line-numbers {
  position: relative;
  z-index: 3;
  width: 3.5rem;
  padding: 10px 6px;
  background: var(--gutter-bg);
  color: var(--gutter-text);
  text-align: right;
  user-select: none;
  border-right: 1px solid var(--border);
  overflow: hidden;
  font-family: "Cascadia Code", "Fira Code", Consolas, monospace;
  font-size: 14px;
  line-height: 21px;
}

.line-numbers div {
  height: 21px;
  line-height: 21px;
}

.editor {
  position: relative;
  z-index: 2;
  flex: 1;
  height: 100%;
  border: none;
  padding: 10px 12px;
  outline: none;
  resize: none;
  overflow: auto;
  background: transparent;
  color: var(--editor-text);
  font-family: "Cascadia Code", "Fira Code", Consolas, monospace;
  font-size: 14px;
  line-height: 21px;
  white-space: pre-wrap;
  overflow-wrap: break-word;
  word-break: normal;
  tab-size: 2;
}

#preview {
	  position: relative;
}

.editing-default-badge {
  position: sticky;
  top: 12px;
  z-index: 1000;

  width: fit-content;
  margin: 12px 12px 0 auto;

  padding: 6px 10px;
  border-radius: 999px;

  background: rgba(255, 0, 0, 0.75);
  color: #fff;

  font-size: 14px;
  font-weight: 700;
  line-height: 1;

  pointer-events: none;
}

.preview {
  flex: 1;
  overflow: auto;
  background: var(--preview-bg);
  padding: 18px;
  cursor: auto;
}

.preview.pan-ready,
.preview.pan-ready * {
  cursor: grab;
}

.preview.is-dragging,
.preview.is-dragging * {
  cursor: grabbing !important;
}

.preview.is-dragging {
  user-select: none;
}

.preview.is-dragging * {
  user-select: none;
  pointer-events: none;
}



.page {
  position: relative;
  width: var(--page-width);
  height: var(--page-height);
  min-height: var(--page-height);
  margin: 0 auto 20px;
  background-color: var(--paper);
  border: 1px solid rgba(0, 0, 0, 0.18);
  box-shadow: 0 8px 18px rgba(0, 0, 0, 0.14);
  overflow: hidden;
}

.preview .page {
  transform-origin: top center;
}

.page-content {
  position: absolute;
  top: var(--page-margin);
  left: var(--page-margin);
  width: var(--content-width);
  height: var(--content-height);
  overflow: hidden;
}

.biy-page-number {
  position: absolute;
  bottom: 50px;
  left: 0;
  width: 100%;

  display: block;
  text-align: center;
  line-height: 1;

  font-family: Garamond, "EB Garamond", serif;
  font-size: 12pt;
  font-weight: bold;
  color: #1e293b;

  z-index: 20;
  pointer-events: none;
}

.biy-page-roman {
	font-style: italic;
}

.measure-root {
  position: absolute;
  left: -99999px;
  top: 0;
  width: var(--content-width);
  visibility: hidden;
  pointer-events: none;
}

.resizer {
  width: 8px;
  flex: 0 0 8px;
  cursor: col-resize;
  background: linear-gradient(
    to right,
    var(--resizer-dark-1) 0,
    var(--resizer-dark-1) 2px,
    var(--resizer-dark-2) 2px,
    var(--resizer-dark-2) 6px,
    var(--resizer-dark-1) 6px,
    var(--resizer-dark-1) 8px
  );
}

body:not(.dark) .resizer {
  background: linear-gradient(
    to right,
    var(--resizer-light-1) 0,
    var(--resizer-light-1) 2px,
    var(--resizer-light-2) 2px,
    var(--resizer-light-2) 6px,
    var(--resizer-light-1) 6px,
    var(--resizer-light-1) 8px
  );
}

hr,
.section-divider {
  border: none;
  border-top: 2px solid #1b2d4a;
  margin: 0.75em auto;
  width: 40%;
  display: block;
}

.rendered,
.page-content {
  color: #1e293b;
}

.rendered h1,
.rendered h2,
.rendered h3,
.page-content h1,
.page-content h2,
.page-content h3 {
  margin-top: 0;
  color: #1b2d4a;
  font-weight: bold;
}

.rendered h1,
.page-content h1 {
  font-size: 2.55rem;
  line-height: 1.1;
  margin-bottom: 1rem;
}

.rendered h2,
.page-content h2 {
  font-size: 1.85rem;
  line-height: 1.15;
  margin: 1.2rem 0 0.8rem;
}

.rendered h3,
.page-content h3 {
  font-size: 1.3rem;
  line-height: 1.2;
  margin: 1rem 0 0.6rem;
  border-bottom: 2px solid #1b2d4a;
}

h1.statblock-name,
.statblock-name {
  font-size: 1.6rem !important;
  line-height: 1 !important;
  margin: 0 !important;
  font-variant: small-caps;
  letter-spacing: 0.02em;
  color: var(--sb-heading) !important;
  border: none !important;
}

.page-content > :first-child,
.biy-col-content > :first-child,
.col-pane  > :first-child,
.column-pane > :first-child
 {
  margin-top: 0 !important;
}

.col-pane > h1:first-child,
.col-pane > h2:first-child,
.col-pane > h3:first-child,
.col-pane > h4:first-child {
  margin-top: 0 !important;
}

.page-content > h1:first-child,
.page-content > h2:first-child,
.page-content > h3:first-child,
.page-content > h4:first-child,
.page-content > h5:first-child,
.page-content > h6:first-child {
  margin-top: 0;
}

.page-content h1:first-child,
.page-content h2:first-child,
.page-content h3:first-child,
.page-content h4:first-child,
.page-content h5:first-child,
.page-content h6:first-child {
  margin-top: 0;
}

.rendered p,
.page-content p {
  margin: 0 0 0.65rem;
  line-height: 1.1rem;
}

.rendered ul,
.page-content ul {
  margin: 0 0 1rem 1.3rem;
  padding: 0;
}

.rendered li,
.page-content li {
  margin: 0 0 0.35rem;
  line-height: 1.04 !important;
}

.rendered blockquote,
.page-content blockquote {
  margin: 1rem 0;
  padding: 0.15rem 0 0.15rem 0.85rem;
  border-left: 4px solid rgba(80, 80, 80, 0.3);
  color: rgba(50, 50, 50, 0.8);
  font-style: italic;
}

.block,
.list-block,
.quote-block,
.heading-block {
  break-inside: avoid;
  page-break-inside: avoid;
}

h2.block {
	font-size: 1.3rem;
	font-variant: small-caps;
	border-bottom: 1.5px solid #1e293b;
}

.heading-block,
.note-block,
.quote-block,
.statblock,
.custom-table-wrap,
.code-block,
.col,
.columns,
.statcol,
.statcolumns,
.statblock-section-title {
  clear: both;
}

.note-block {
  margin: 1rem 0 1.15rem;
  padding: 0.85rem 1rem;
  border: 1px solid var(--sb-border);
  border-radius: 8px;
  background: var(--sb-bg);
  box-shadow: inset 0 0 0 1px rgba(255, 255, 255, 0.25);
}

.quote-block {
  margin: 1rem auto 1.15rem;
  padding: 0.85rem 1rem;
  border-top: 1.5px solid var(--sb-border);
  border-bottom: 1.5px solid var(--sb-border);
  text-align: center;
  max-width: 50%
}

.col-pane .quote-block {
	max-width: 100%;
}

.note-block > :last-child,
.quote-block > :last-child {
  margin-bottom: 0 !important;
}

.statblock,
.statcol,
.statcolumns {
  padding: 1rem 1rem 1.1rem;
  border: 1px solid var(--sb-border);
  border-radius: 8px;
  background: var(--sb-bg);
  box-shadow: inset 0 0 0 1px rgba(255, 255, 255, 0.35);
  color: var(--sb-text);
  line-height: 1.45;
  break-inside: avoid;
  page-break-inside: avoid;
}

.statblock {
  margin: 1rem 0 1.2rem;
}

.statcol,
.statcolumns {
  margin: 0 0 1rem;
  overflow: hidden;
  height: auto;
  min-height: 0;
}

.page-content > .statcol,
.page-content > .statcolumns {
  margin: 0 0 1rem;
  height: auto;
  min-height: 0;
}

.statblock > :last-child,
.statcol > :last-child,
.statcolumns > :last-child {
  margin-bottom: 0 !important;
}

.statblock .statblock-section > h1:first-child,
.statblock .statblock-section > h2:first-child,
.statblock .statblock-section > h3:first-child,
.statblock .statblock-section > h4:first-child {
  margin-top: 0 !important;
}

.statblock-section-title:first-child {
  margin-top: 0 !important;
}

.statblock-section-title,
.statcol h3,
.statcolumns h3 {
  margin: 0 0 0.35rem 0 !important;
  line-height: 1 !important;
  padding: 0 !important;
}

.statblock-subtitle,
.statcol .statblock-subtitle,
.statcolumns .statblock-subtitle {
  margin: 0 0 0.5rem !important;
  font-style: italic;
  font-size: 0.95rem;
  color: var(--sb-subtitle);
}

.statblock-rule,
.statcol .statblock-rule,
.statcolumns .statblock-rule {
  display: none;
}

.statblock-label-line,
.statcol .statblock-label-line,
.statcolumns .statblock-label-line {
  margin: 0;
  line-height: 1.05 !important;
}

.statblock-label-line + .statblock-label-line,
.statcol .statblock-label-line + .statblock-label-line,
.statcolumns .statblock-label-line + .statblock-label-line {
  margin-top: 0.1rem;
}

.statblock-label-line strong,
.statcol .statblock-label-line strong,
.statcolumns .statblock-label-line strong {
  font-weight: 700;
}

.statblock-abilities,
.statcol .statblock-abilities,
.statcolumns .statblock-abilities {
  border-collapse: collapse;
  margin: 0.7rem 0 0.9rem;
  table-layout: fixed;
  font-size: 0.95rem;
}

.statblock .statblock-abilities {
  width: 50% !important;
  min-width: 420px;
  clear: both;
}

.statcol .statblock-abilities,
.statcolumns .statblock-abilities {
  width: 100% !important;
  min-width: 0;
}

.statblock-abilities th,
.statblock-abilities td,
.statcol .statblock-abilities th,
.statcol .statblock-abilities td,
.statcolumns .statblock-abilities th,
.statcolumns .statblock-abilities td {
  border: 1px solid var(--sb-table-border);
  text-align: center;
  padding: 0.28rem 0.2rem;
}

.statblock-abilities th,
.statcol .statblock-abilities th,
.statcolumns .statblock-abilities th {
  font-weight: 700;
  background: var(--sb-table-head-bg);
}

.statblock-section {
  margin-top: 0.55rem;
}

.statblock-section-title,
.statcol h3,
.statcolumns h3 {
  margin: 0.8rem 0 0.55rem !important;
  font-size: 1.05rem;
  font-variant: small-caps;
  letter-spacing: 0.02em;
  color: var(--sb-heading);
  font-weight: 900 !important;
  border-bottom: 1px solid var(--sb-border) !important;
}

.statblock .statblock-label-line {
  margin: 0 !important;
  line-height: 1.05 !important;
}

.statblock .statblock-label-line + .statblock-label-line {
  margin-top: 0.08rem !important;
}

.statblock p.statblock-label-line {
  margin: 0 !important;
  line-height: 1.05 !important;
}

.statblock p.statblock-label-line + p.statblock-label-line {
  margin-top: 0.08rem !important;
}

.statblock .statblock-entry,
.statblock .statblock-free-paragraph,
.statblock .statblock-section p:not(.statblock-label-line) {
  margin: 0 0 0.65rem !important;
  line-height: 1.25 !important;
}

.biy-subtitle {
  margin-top: -0.75rem;
  margin-bottom: 0.65rem;
  line-height: 1.25;
}

.biy-subtitle > em:only-child {
  display: block;
  font-style: italic;
}

.biy-subtitle-left {
  text-align: left;
}

.biy-subtitle-center {
  text-align: center;
}

.biy-subtitle-right {
  text-align: right;
}

/* ----------------------
.statcol p,
.statcolumns p {
  margin: 0 0 0.65rem;
  line-height: 1.25 !important;
}
----------------------- */
.statblock-entry strong,
.statblock-free-paragraph strong {
  font-weight: 700;
}

.statblock-entry em,
.statblock-free-paragraph em,
.statblock-label-line em,
.statcol p em,
.statcol .statblock-label-line em,
.statcolumns p em,
.statcolumns .statblock-label-line em {
  font-style: italic;
}

.statblock-list,
.statcol ul,
.statcolumns ul {
  margin: 0.5rem 0 0.8rem 1.2rem !important;
  padding: 0;
}

.statblock-list li,
.statcol li,
.statcolumns li {
  margin: 0 0 0.28rem;
  line-height: 1.15;
}

.statblock .statblock-section:last-child > :last-child {
  margin-bottom: 0 !important;
}

.col,
.columns {
  display: flex;
  gap: 0.3in;
  width: 100%;
  align-items: flex-start;
  margin: 0 0 1rem;
}

.col-pane,
.column-pane {
  width: calc((100% - 0.3in) / 2);
  overflow: hidden;
  min-width: 0;
}

.col-pane > :last-child,
.column-pane > :last-child {
  margin-bottom: 0 !important;
}

.statcol-colbreak,
.statcolumns-colbreak {
  display: block;
  break-before: column !important;
  -webkit-column-break-before: always;
  page-break-before: always;
  width: 100%;
  height: 1px;
  margin: 0;
  padding: 0;
  visibility: hidden;
  background: transparent;
}

.custom-table-wrap {
  margin: 0.8rem 0 1rem;
}

.custom-table-wrap.align-left {
  margin-left: 0;
  margin-right: auto;
}

.custom-table-wrap.align-center {
  margin-left: auto;
  margin-right: auto;
}

.custom-table-wrap.align-right {
  margin-left: auto;
  margin-right: 0;
}

.custom-table {
  width: 100%;
  border-collapse: collapse;
  table-layout: fixed;
  font-size: 0.95rem;
  color: var(--sb-text);
  background: transparent;
  table-layout: fixed;
}

.custom-table th,
.custom-table td {
  border: 1px solid var(--sb-table-border);
  padding: 0.2rem 0.3rem;
  vertical-align: top;
}

.custom-table th {
  background: var(--sb-table-head-bg);
  font-weight: 700;
}

.custom-table th[data-align="left"],
.custom-table td[data-align="left"] {
  text-align: left;
}

.custom-table th[data-align="center"],
.custom-table td[data-align="center"] {
  text-align: center;
}

.custom-table th[data-align="right"],
.custom-table td[data-align="right"] {
  text-align: right;
}

.custom-table td p,
.custom-table th p {
  margin: 0;
}

.code-block {
  margin: 1rem 0 1.15rem;
  padding: 0.85rem 1rem;
  border: 1px solid var(--sb-border);
  border-radius: 8px;
  background: #f3eedb;
  color: #2b241a;
  overflow-x: auto;
  white-space: pre-wrap;
  word-break: break-word;
  font-family: "Cascadia Code", "Fira Code", Consolas, monospace;
  font-size: 0.92rem;
  line-height: 1.45;
}

.code-block code {
  font-family: inherit;
  font-size: inherit;
  color: inherit;
}

.biy-center {
  text-align: center;
}

.biy-right {
  text-align: right;
}

.image-block {
  margin: 0 0 0.75rem;
  position: relative;
}

.image-block img {
  display: block;
  width: 100%;
  height: auto;
}

.image-caption {
  margin-top: 0.3rem;
  font-size: 0.9rem;
  line-height: 1.2;
  color: #4f4030;
  text-align: center;
  font-style: italic;
}

.image-wrap-jump {
  float: none;
  clear: both;
}

.image-wrap-jump.image-center {
  margin-left: auto;
  margin-right: auto;
}

.image-wrap-jump.image-left {
  margin-left: 0;
  margin-right: auto;
}

.image-wrap-jump.image-right {
  margin-left: auto;
  margin-right: 0;
}

.image-wrap-square.image-left {
  float: left;
  margin: 0 0.85rem 0.65rem 0;
}

.image-wrap-square.image-right {
  float: right;
  margin: 0 0 0.65rem 0.85rem;
}

.image-wrap-square.image-center {
  float: none;
  margin-left: auto;
  margin-right: auto;
}

.image-wrap-tight.image-left {
  float: left;
  margin: 0 0.2rem 0.15rem 0;
}

.image-wrap-tight.image-right {
  float: right;
  margin: 0 0 0.15rem 0.2rem;
}

.image-wrap-tight.image-center {
  float: none;
  margin-left: auto;
  margin-right: auto;
}

.image-wrap-edge.image-left {
  float: left;
  margin: 0 0.85rem 0.65rem 0;
  shape-margin: 0.45rem;
}

.image-wrap-edge.image-right {
  float: right;
  margin: 0 0 0.65rem 0.85rem;
  shape-margin: 0.45rem;
}

.image-wrap-edge.image-center {
  float: none;
  margin-left: auto;
  margin-right: auto;
}

.statcol .image-wrap-square,
.statcol .image-wrap-tight,
.statcol .image-wrap-edge,
.statcolumns .image-wrap-square,
.statcolumns .image-wrap-tight,
.statcolumns .image-wrap-edge {
  float: none;
  margin-left: auto;
  margin-right: auto;
}

.custom-table .image-block,
.custom-table .image-wrap-jump,
.custom-table .image-wrap-square,
.custom-table .image-wrap-tight,
.custom-table .image-wrap-edge,
.image-in-table-cell {
  float: none !important;
  position: static !important;
  transform: none !important;
  width: 100% !important;
  max-width: 100% !important;
  margin: 0 auto !important;
}

.custom-table td .image-caption,
.custom-table th .image-caption {
  font-size: 0.8rem;
}

.page-content.rendered::after,
.note-block::after,
.quote-block::after,
.statblock::after,
.statblock-section::after,
.col-pane::after,
.column-pane::after,
.columns::after,
.col::after {
  content: "";
  display: block;
  clear: both;
}

.properties-overlay {
  position: fixed;
  inset: 0;
  z-index: 1300;
  display: flex;
  align-items: flex-start;
  justify-content: center;
  padding: 48px 20px 20px;
  background: rgba(20, 24, 31, 0.5);
}

.properties-overlay.hidden {
  display: none;
}

.properties-panel {
  width: min(900px, 100%);
  max-height: calc(100vh - 80px);
  overflow: auto;
  border: 1px solid var(--border);
  border-radius: 22px;
  background: var(--panel);
  box-shadow: 0 24px 60px rgba(0, 0, 0, 0.28);
}

.properties-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 18px 22px;
  border-bottom: 1px solid var(--border);
}

.properties-header h2 {
  margin: 0;
  font-size: 1.55rem;
  color: var(--text);
}

.properties-close {
  appearance: none;
  border: 1px solid var(--button-border);
  background: var(--button-bg);
  color: var(--button-text);
  width: 40px;
  height: 40px;
  border-radius: 999px;
  font-size: 1.1rem;
  cursor: pointer;
}

.properties-close:hover {
  background: var(--button-hover);
}

.properties-body {
  padding: 22px;
}

.property-field {
  display: block;
  margin-bottom: 20px;
}

.property-label {
  display: block;
  margin-bottom: 8px;
  font-size: 1rem;
  font-weight: 700;
  color: var(--text);
}

.property-input,
.property-textarea {
  width: 100%;
  border: 1px solid var(--border);
  border-radius: 12px;
  background: var(--button-bg);
  color: var(--text);
  padding: 12px 14px;
  font: inherit;
  font-size: 1rem;
}

.property-input:focus,
.property-textarea:focus {
  outline: none;
  border-color: #93a4bd;
  box-shadow: 0 0 0 3px rgba(147, 164, 189, 0.18);
}

.property-textarea {
  resize: vertical;
  min-height: 140px;
}

.toast {
  position: fixed;
  right: 20px;
  bottom: 20px;
  z-index: 1400;
  max-width: 320px;
  padding: 12px 16px;
  border-radius: 12px;
  border: 1px solid var(--border);
  background: var(--panel);
  color: var(--text);
  box-shadow: 0 18px 40px rgba(0, 0, 0, 0.22);
  font-size: 0.95rem;
  line-height: 1.4;
  opacity: 1;
  transform: translateY(0);
  transition: opacity 180ms ease, transform 180ms ease;
}

.toast.hidden {
  opacity: 0;
  transform: translateY(10px);
  pointer-events: none;
}

.toast.success {
  border-color: rgba(60, 191, 48, 0.45);
}

.toast.error {
  border-color: rgba(200, 80, 80, 0.45);
}

@media (max-width: 980px) {
  body {
    padding: 0;
  }

  .app-shell {
    height: auto;
    min-height: 100vh;
    gap: 0;
  }

  .top-toolbar {
    border-radius: 0;
    border-left: none;
    border-right: none;
    border-top: none;
    flex-direction: column;
    align-items: stretch;
  }

  .toolbar-left {
    min-width: 0;
  }

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

  .workspace {
    height: auto;
    min-height: 100vh;
    border-radius: 0;
    flex-direction: column;
  }

  .pane {
    width: 100% !important;
  }

  .resizer {
    display: none;
  }

  .editor,
  .editor-container {
    min-height: 320px;
  }

  .col,
  .columns {
    flex-direction: column;
    gap: 1rem;
  }

  .col-pane,
  .column-pane {
    width: 100%;
    height: auto !important;
  }

  .dropdown-menu {
    left: 0;
    right: auto;
    min-width: 200px;
  }
}

.biy-spacer {
  display: block;
  height: 100px;
  margin: 0 !important;
  padding: 0 !important;
  border: 0 !important;
  background: transparent !important;
  line-height: 0 !important;
  font-size: 0 !important;
}

/* =========================
   PRINT STYLES (iframe-driven)
   ========================= */

@page {
  size: auto;
  margin: 0;
}



@media print {

  html,
  body,
  .page,
  .statblock,
  .statcol,
  .statcolumns,
  .note-block,
  .quote-block,
  .code-block,
  .custom-table-wrap,
  .statblock-abilities th,
  .custom-table th {
    -webkit-print-color-adjust: exact !important;
    print-color-adjust: exact !important;
  }
  
  html,
  body,
  body.print-iframe-body {
    margin: 0 !important;
    padding: 0 !important;
    background: white !important;
    overflow: visible !important;
  }

  /* 🔪 Kill all UI garbage */
  .top-toolbar,
  .resizer,
  #leftPane,
  .toast,
  .properties-overlay,
  #measureRoot,
  #editorActiveLine,
  #lineNumbers,
  #importFileInput {
    display: none !important;
  }

  /* 🧼 Reset layout containers */
  .app-shell,
  .workspace,
  .pane,
  .preview,
  #printPages {
    display: block !important;
    width: auto !important;
    height: auto !important;
    min-height: 0 !important;
    max-height: none !important;
    overflow: visible !important;
    margin: 0 !important;
    padding: 0 !important;
    border: 0 !important;
    box-shadow: none !important;
    background: white !important;
  }

  /* ❗ Kill zoom transform (VERY important) */
  .preview {
    transform: none !important;
  }

  /* 📄 Actual printed pages */
  .page {
    width: var(--page-width) !important;
    height: var(--page-height) !important;
    min-height: var(--page-height) !important;

    margin: 0 auto !important;
    border: none !important;
    box-shadow: none !important;

    background: white !important;

    break-after: page;
    page-break-after: always;
  }

  .page:last-child {
    break-after: auto;
    page-break-after: auto;
  }

  /* 🧱 Ensure no transform weirdness leaks in */
  .preview .page {
    transform: none !important;
    transform-origin: top left !important;
  }

  .page-content {
    overflow: visible !important;
  }

  /* Clean links */
  a,
  a:visited {
    color: inherit !important;
    text-decoration: none !important;
  }
  
  /* =========================
     Selective parchment mode
     ========================= */

  /* White paper */
  .page {
    background: white !important;
  }

  /* Cream fills for structured BIY elements */
  .statblock,
  .statcol,
  .statcolumns,
  .col.columns.statcol.statcolumns,
  .note-block,
  .code-block,
  .custom-table-wrap {
    background-color: #fdf8e5 !important;
    background: #fdf8e5 !important;
  }

  /* Ability table headers */
  .statblock-abilities th,
  .statcol .statblock-abilities th,
  .statcolumns .statblock-abilities th {
    background-color: var(--sb-bg) !important;
    background: var(--sb-bg) !important;
  }

  /* Custom table headers */
  .custom-table th,
  .custom-table-wrap .custom-table th {
    background-color: var(--sb-bg) !important;
    background: var(--sb-bg) !important;
  }


  /* =========================
     Print fixes for col/statcol
     ========================= */

  .col,
  .columns,
  .col.columns.statcol.statcolumns {
    display: flex !important;
    flex-direction: row !important;
    align-items: flex-start !important;
    gap: 0.3in !important;
    width: 100% !important;
    overflow: visible !important;
    break-inside: avoid !important;
    page-break-inside: avoid !important;
  }

  .col-pane,
  .column-pane {
    width: calc((100% - 0.3in) / 2) !important;
    min-width: 0 !important;
    overflow: visible !important;
    break-inside: avoid !important;
    page-break-inside: avoid !important;
  }

  .col-pane > :first-child,
  .column-pane > :first-child {
    margin-top: 0 !important;
  }

  .statcol .statblock-abilities,
  .statcolumns .statblock-abilities {
    width: 100% !important;
    min-width: 0 !important;
  }

  .statcol h1.statblock-name,
  .statcolumns h1.statblock-name {
    margin-top: 0 !important;
  }
}



/* =========================================================
   BIY PANEL (CLEAN + FINAL)
========================================================= */

.biys-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.65);
  z-index: 2000;
  display: flex;
  align-items: center;
  justify-content: center;
}

.biys-overlay.hidden {
  display: none !important;
}

.biys-panel {
  width: 95vw;
  max-width: 1200px;
  height: 85vh;
  background: #1b2432;
  border-radius: 18px;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  box-shadow: 0 20px 60px rgba(0,0,0,0.6);
}

/* ================= HEADER ================= */

.biys-header {
  display: flex !important;
  align-items: center !important;
  justify-content: space-between !important;
  gap: 16px !important;
  padding: 16px 24px !important;
  border-bottom: 1px solid rgba(255,255,255,0.08);
}

.biys-header h2 {
  margin: 0 !important;
  font-size: 2.2rem !important;
  color: #fff !important;
  flex: 0 0 auto;
}

.biys-header-controls {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  flex: 1 1 auto;
}

/* ================= TOGGLES ================= */

.biys-toggle-row {
  display: inline-flex;
  gap: 6px;
}

.biys-toggle-btn {
  border: 1px solid rgba(255,255,255,0.12);
  background: rgba(255,255,255,0.06);
  color: #f2f3f5;
  border-radius: 999px;
  padding: 6px 10px;
  font-size: 0.85rem;
  cursor: pointer;
  transition: all 0.15s ease;
}

.biys-toggle-btn:hover {
  background: rgba(255,255,255,0.1);
  transform: translateY(-1px);
}

.biys-toggle-btn.is-active {
  background: #9bb8ee;
  color: #1b2432;
  border-color: #9bb8ee;
}

/* ================= BODY GRID ================= */

.biys-body {
  padding: 16px 24px 24px !important;
  overflow-y: auto !important;
  display: grid !important;
  grid-template-columns: repeat(3, 1fr);
  column-gap: 16px;
  row-gap: 10px;
  flex: 1;
  align-content: start;
}

/* ================= CARD ================= */

.biy-card {
  background: #2a3444;
  border-radius: 16px;
  padding: 14px;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  height: 168px;
  position: relative;
  transition: transform 0.18s ease, box-shadow 0.18s ease;
}

.biy-card:hover {
  transform: translateY(-3px);
  box-shadow: 0 14px 30px rgba(0,0,0,0.4);
}

/* TOP AREA */

.biy-card-top {
  display: flex;
  justify-content: space-between;
  gap: 10px;
}

.biy-card-main {
  flex: 1;
  min-width: 0;
}

.biy-card-title {
  font-size: 1.05rem;
  font-weight: bold;
  color: #fff;
  margin: 0 0 4px;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

.biy-card-author {
  font-size: 0.75rem;
  color: #9aa3b2;
}

/* RIGHT STAT RAIL */

.biy-card-stats {
  display: flex;
  flex-direction: column;
  gap: 6px;
  align-items: flex-end;
  justify-content: flex-start;
}

.biy-stat {
  font-size: 0.75rem;
  color: #cbd5e1;
  background: rgba(255,255,255,0.06);
  padding: 3px 6px;
  border-radius: 8px;
}

.biy-stat-link {
  border: 0 !important;
  cursor: pointer !important;
}

.biy-stat-link:hover {
  background: rgba(255, 255, 255, 0.1) !important;
  transform: translateX(-2px);
}

/* ACTIONS */

.biy-card-actions {
  display: flex;
  justify-content: space-between;
  gap: 6px;
  margin-top: 8px;
}

.biy-action-btn {
  flex: 1;
  border: none;
  border-radius: 8px;
  padding: 6px;
  font-size: 0.75rem;
  background: #3a475c;
  color: white;
  cursor: pointer;
  transition: all 0.12s ease;
}

.biy-action-btn:hover {
  background: #4b5c78;
  transform: translateY(-1px);
}

.biy-action-btn:active {
  transform: translateY(0);
}

/* ================= CLOSE BUTTON ================= */

.biys-close {
  background: transparent;
  border: none;
  color: white;
  font-size: 1.6rem;
  cursor: pointer;
}