/* ========================================
   GM STUDIO - SHARED STYLES
   ======================================== */

.statblock-builder-page {
  min-height: calc(100vh - 180px);
  padding: clamp(2rem, 4vw, 3rem) 0;
}

.statblock-header .lead {
  max-width: 720px;
  margin: 0.75rem auto 0;
  color: var(--muted);
}

.reset-animation {
  transition: transform 0.2s ease;
}

.reset-animation:active {
  transform: scale(0.95);
}

.statblock-header {
  text-align: center;
  margin-bottom: clamp(2rem, 4vw, 3rem);
}

.statblock-eyebrow {
  text-transform: uppercase;
  letter-spacing: 0.18em;
  font-size: 0.8rem;
  color: rgba(255, 255, 255, 0.6);
  margin-bottom: 0.5rem;
}

.statblock-header h1 {
  font-family: var(--font-display);
  font-size: clamp(2.25rem, 5vw, 3rem);
  margin: 0;
  text-shadow: 0 18px 40px rgba(0, 0, 0, 0.5);
}

.statblock-lead {
  max-width: 720px;
  margin: 0.75rem auto 0;
  color: var(--muted);
}

.statblock-builder-layout {
  display: grid;
  grid-template-columns: minmax(0, 2.3fr) minmax(280px, 1fr);
  gap: clamp(1.75rem, 3vw, 2.5rem);
  align-items: flex-start;
}

.statblock-main-column {
  min-width: 0;
}

.statblock-card {
  border-radius: 18px;
  padding: clamp(1.25rem, 3vw, 1.75rem);
  background: radial-gradient(circle at 20% 0%, rgba(255, 214, 163, 0.18), transparent 65%),
    radial-gradient(circle at 80% 100%, rgba(255, 236, 179, 0.16), transparent 60%),
    linear-gradient(145deg, #2a2117, #1a130b);
  border: 1px solid rgba(255, 214, 163, 0.55);
  box-shadow: 0 18px 40px rgba(0, 0, 0, 0.58);
  color: #fbeedd;
}

.statblock-card.statblock-theme-ink {
  background:
    radial-gradient(circle at 18% 0%, rgba(138, 123, 255, 0.32), transparent 65%),
    radial-gradient(circle at 82% 100%, rgba(123, 209, 255, 0.24), transparent 60%),
    linear-gradient(145deg, #151426, #05040c);
  border-color: rgba(138, 123, 255, 0.75);
  box-shadow: 0 18px 42px rgba(5, 4, 18, 0.9);
  color: #f7f6ff;
}

.statblock-card.statblock-theme-ember {
  background:
    radial-gradient(circle at 20% 0%, rgba(255, 196, 160, 0.3), transparent 65%),
    radial-gradient(circle at 82% 100%, rgba(255, 120, 82, 0.26), transparent 60%),
    linear-gradient(145deg, #3b1f14, #150805);
  border-color: rgba(255, 156, 120, 0.85);
  box-shadow: 0 18px 42px rgba(0, 0, 0, 0.85);
  color: #ffeadd;
}

.statblock-card.statblock-theme-starlight {
  background:
    radial-gradient(circle at 18% 0%, rgba(255, 255, 220, 0.35), transparent 65%),
    radial-gradient(circle at 82% 100%, rgba(168, 148, 255, 0.28), transparent 60%),
    linear-gradient(145deg, #181624, #05040c);
  border-color: rgba(255, 236, 179, 0.9);
  box-shadow: 0 18px 40px rgba(0, 0, 0, 0.85);
  color: #fdfcf5;
}

.statblock-card-header {
  border-bottom: 2px solid rgba(80, 52, 30, 0.9);
  padding-bottom: 0.5rem;
  margin-bottom: 0.75rem;
}

.statblock-card.statblock-theme-ink .statblock-card-header,
.statblock-card.statblock-theme-ink .statblock-abilities,
.statblock-card.statblock-theme-ink .statblock-divider {
  border-color: rgba(138, 123, 255, 0.85);
}

.statblock-card.statblock-theme-ember .statblock-card-header,
.statblock-card.statblock-theme-ember .statblock-abilities,
.statblock-card.statblock-theme-ember .statblock-divider {
  border-color: rgba(255, 156, 120, 0.85);
}

.statblock-card.statblock-theme-starlight .statblock-card-header,
.statblock-card.statblock-theme-starlight .statblock-abilities,
.statblock-card.statblock-theme-starlight .statblock-divider {
  border-color: rgba(255, 236, 179, 0.9);
}

.spell-card .statblock-subtitle.spell-level-line {
  font-style: italic;
}

.spell-card .spell-top-grid {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
  column-gap: 1rem;
  row-gap: 0.4rem;
}

.spell-card .spell-top-cell .statblock-label {
  display: inline-block;
  margin-bottom: 0.1rem;
}

.spell-card .statblock-inline-input {
  min-height: 2.2rem;
}

.spell-card .spell-components-label,
.spell-card .spell-duration-label {
  display: flex;
  align-items: center;
  gap: 0.75rem;
}

.spell-card .spell-components-toggles,
.spell-card .spell-duration-flags {
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
}

.item-card .item-top-grid {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
  column-gap: 1rem;
  row-gap: 0.4rem;
}

.item-card .item-top-cell .statblock-label {
  display: inline-block;
  margin-bottom: 0.1rem;
}

.item-card .statblock-inline-input {
  min-height: 2.2rem;
}

.statblock-card.statblock-theme-ink .statblock-inline-input,
.statblock-card.statblock-theme-ink .statblock-inline-textarea {
  border-color: rgba(138, 123, 255, 0.85);
}

.statblock-card.statblock-theme-ember .statblock-inline-input,
.statblock-card.statblock-theme-ember .statblock-inline-textarea {
  border-color: rgba(255, 156, 120, 0.85);
}

.statblock-card.statblock-theme-starlight .statblock-inline-input,
.statblock-card.statblock-theme-starlight .statblock-inline-textarea {
  border-color: rgba(255, 236, 179, 0.9);
}

.statblock-name {
  margin: 0;
  font-family: var(--font-display);
  font-size: 1.5rem;
  letter-spacing: 0.03em;
}

.statblock-subtitle {
  margin: 0.25rem 0 0;
  font-style: italic;
  font-size: 0.92rem;
}

.statblock-basics,
.statblock-details {
  margin-bottom: 0.75rem;
}

.statblock-line {
  margin: 0.15rem 0;
  font-size: 0.9rem;
}

.statblock-label {
  font-weight: 700;
}

.statblock-label::after {
  content: ' ';
}

.statblock-value {
  font-weight: 400;
}

.statblock-abilities {
  display: grid;
  grid-template-columns: repeat(6, minmax(0, 1fr));
  gap: 0.35rem;
  margin: 0.75rem 0;
  padding: 0.5rem 0.35rem;
  border-top: 1px solid rgba(80, 52, 30, 0.9);
  border-bottom: 1px solid rgba(80, 52, 30, 0.9);
}

.statblock-ability {
  text-align: center;
  font-size: 0.85rem;
}

.statblock-ability-toggle {
  display: block;
  background: none;
  border: none;
  padding: 0;
  cursor: pointer;
  color: inherit;
}

.statblock-ability-label {
  display: block;
  font-weight: 700;
  font-size: 0.8rem;
  letter-spacing: 0.06em;
}

.statblock-ability-value {
  display: block;
  margin-top: 0.1rem;
}

.statblock-ability-toggle.statblock-save-toggle--active .statblock-ability-label {
  text-decoration: underline;
}

.statblock-divider {
  border: 0;
  border-top: 1px solid rgba(80, 52, 30, 0.9);
  margin: 0.75rem 0;
}

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

.statblock-section-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem;
  margin-bottom: 0.25rem;
}

.statblock-section-header h3 {
  margin: 0;
  font-size: 0.98rem;
  text-transform: uppercase;
  letter-spacing: 0.08em;
}

.statblock-add-entry {
  border-radius: 999px;
  border: 1px solid rgba(255, 214, 163, 0.6);
  background: rgba(0, 0, 0, 0.26);
  color: #fbeedd;
  font-size: 0.76rem;
  padding: 0.25rem 0.65rem;
  cursor: pointer;
}

.statblock-add-entry:hover {
  background: rgba(0, 0, 0, 0.4);
}

.statblock-section-entries {
  display: grid;
  gap: 0.35rem;
}

.statblock-section-empty {
  margin: 0;
  font-size: 0.82rem;
  font-style: italic;
  opacity: 0.85;
}

.statblock-entry-row {
  border-radius: 8px;
  padding: 0.35rem 0.5rem;
  background: rgba(0, 0, 0, 0.16);
  border: 1px solid rgba(255, 214, 163, 0.25);
  display: grid;
  grid-template-columns: minmax(0, 1.2fr) minmax(0, 3fr) auto;
  gap: 0.5rem;
  align-items: flex-start;
}

.statblock-entry-actions {
  display: flex;
  gap: 0.35rem;
  align-items: center;
}

.statblock-entry-name {
  font-weight: 700;
  font-size: 0.9rem;
  cursor: pointer;
}

.statblock-entry-body {
  font-size: 0.88rem;
  cursor: pointer;
}

.statblock-entry-duplicate,
.statblock-entry-remove {
  border-radius: 999px;
  border: 1px solid rgba(255, 214, 163, 0.4);
  background: transparent;
  color: #fbeedd;
  font-size: 0.75rem;
  padding: 0.1rem 0.5rem;
  cursor: pointer;
  white-space: nowrap;
}

.statblock-entry-duplicate:hover,
.statblock-entry-remove:hover {
  background: rgba(0, 0, 0, 0.4);
}

.statblock-card.statblock-theme-ink .statblock-entry-duplicate,
.statblock-card.statblock-theme-ink .statblock-entry-remove {
  border-color: rgba(138, 123, 255, 0.5);
  color: #f7f6ff;
}

.statblock-card.statblock-theme-ember .statblock-entry-duplicate,
.statblock-card.statblock-theme-ember .statblock-entry-remove {
  border-color: rgba(255, 156, 120, 0.5);
  color: #ffeadd;
}

.statblock-card.statblock-theme-starlight .statblock-entry-duplicate,
.statblock-card.statblock-theme-starlight .statblock-entry-remove {
  border-color: rgba(255, 236, 179, 0.6);
  color: #fdfcf5;
}

.statblock-inline-input,
.statblock-inline-textarea {
  width: 100%;
  font: inherit;
  color: inherit;
  background: rgba(0, 0, 0, 0.4);
  border-radius: 6px;
  border: 1px solid rgba(255, 214, 163, 0.85);
  padding: 0.2rem 0.4rem;
}

.statblock-inline-textarea {
  resize: vertical;
}

.statblock-preview {
  min-height: 6em;
  white-space: pre-wrap;
  line-height: 1.6;
}

.statblock-preview strong {
  font-weight: 700;
  color: inherit;
}

.statblock-preview em {
  font-style: italic;
  color: inherit;
}

.statblock-inline-input.is-invalid,
.statblock-inline-textarea.is-invalid {
  border-color: #ff4757 !important;
  box-shadow: 0 0 0 1px #ff4757;
}

.statblock-hp-formula {
  cursor: pointer;
}

.statblock-hp-editor {
  display: inline-flex;
  align-items: center;
  gap: 0.3rem;
}

.statblock-hp-editor button {
  border-radius: 999px;
  border: 1px solid rgba(255, 214, 163, 0.6);
  background: transparent;
  color: #fbeedd;
  font-size: 0.6rem;
  padding: 0.05rem 0.25rem;
  cursor: pointer;
}

.statblock-hp-dice-input {
  width: 5ch;
  font: inherit;
  font-size: 0.75em;
  color: inherit;
  background: rgba(0, 0, 0, 0.4);
  border-radius: 4px;
  border: 1px solid rgba(255, 214, 163, 0.6);
  padding: 0.1rem 0.25rem;
}

.statblock-hp-dice-input::-webkit-outer-spin-button,
.statblock-hp-dice-input::-webkit-inner-spin-button {
  -webkit-appearance: none;
  margin: 0;
}

.statblock-hp-dice-input[type='number'] {
  -moz-appearance: textfield;
}

.statblock-hp-die-control {
  display: inline-flex;
  align-items: center;
  gap: 0.15rem;
  padding: 0 0.2rem;
  border-radius: 4px;
  border: 1px solid rgba(255, 214, 163, 0.6);
  background: rgba(0, 0, 0, 0.4);
}

.statblock-hp-die-value {
  min-width: 2ch;
  text-align: center;
  font-size: 0.75em;
}

.statblock-hp-die-stepper {
  display: inline-flex;
  flex-direction: column;
  gap: 0.05rem;
}

.statblock-hp-die-stepper button {
  font-size: 0.5rem;
  padding: 0;
  width: 0.7rem;
  height: 0.7rem;
  line-height: 0.7rem;
  border: none;
  background: transparent;
}

.statblock-sidebar {
  border-radius: 18px;
  padding: clamp(1rem, 2.5vw, 1.5rem);
  background: linear-gradient(150deg, rgba(10, 8, 16, 0.96), rgba(18, 12, 28, 0.9));
  border: 1px solid rgba(255, 255, 255, 0.1);
  box-shadow: 0 16px 40px rgba(0, 0, 0, 0.55);
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
}

.statblock-sidebar.statblock-theme-ink {
  background: linear-gradient(150deg, rgba(10, 10, 26, 0.98), rgba(18, 16, 40, 0.94));
  border-color: rgba(138, 123, 255, 0.6);
  box-shadow: 0 16px 40px rgba(5, 4, 18, 0.9);
}

.statblock-sidebar.statblock-theme-ember {
  background: linear-gradient(150deg, rgba(26, 10, 8, 0.98), rgba(34, 14, 8, 0.96));
  border-color: rgba(255, 156, 120, 0.6);
  box-shadow: 0 16px 40px rgba(0, 0, 0, 0.9);
}

.statblock-sidebar.statblock-theme-starlight {
  background: linear-gradient(150deg, rgba(12, 10, 24, 0.98), rgba(22, 20, 40, 0.96));
  border-color: rgba(255, 236, 179, 0.6);
  box-shadow: 0 16px 40px rgba(0, 0, 0, 0.95);
}

.statblock-sidebar-header h2 {
  margin: 0;
  font-size: 1.1rem;
}

.statblock-sidebar-eyebrow {
  font-size: 0.72rem;
  letter-spacing: 0.08em;
  color: rgba(255, 255, 255, 0.6);
  margin: 0 0 0.2rem;
}

.statblock-sidebar-eyebrow {
  text-transform: uppercase;
}

.statblock-sidebar-eyebrow--plain {
  text-transform: none;
  font-size: 0.8rem;
  color: rgba(138, 123, 255, 0.9);
  font-style: italic;
  padding: 6px 10px;
  background: rgba(138, 123, 255, 0.12);
  border-radius: 6px;
  border: 1px solid rgba(138, 123, 255, 0.3);
  margin-bottom: 0.6rem;
}

.statblock-sidebar-body {
  display: grid;
  gap: 0.6rem;
}

.statblock-sidebar-section {
  padding: 0.5rem 0;
  border-top: 1px solid rgba(255, 255, 255, 0.12);
}

.statblock-sidebar-section:first-of-type {
  border-top: none;
}

.statblock-sidebar-title {
  margin: 0 0 0.4rem;
  font-size: 0.95rem;
}

.statblock-sidebar-button {
  width: 100%;
  border-color: rgba(138, 123, 255, 0.7);
  background: linear-gradient(135deg, rgba(24, 22, 48, 0.98), rgba(12, 10, 28, 1));
  color: #ffffff;
  box-shadow: 0 10px 24px rgba(6, 4, 20, 0.75);
}

.statblock-sidebar-button:hover {
  border-color: rgba(138, 123, 255, 0.95);
  background: linear-gradient(135deg, rgba(36, 32, 72, 0.98), rgba(18, 14, 40, 1));
  box-shadow: 0 14px 30px rgba(10, 6, 32, 0.85);
}

.statblock-theme-list {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  margin-top: 0.25rem;
}

.statblock-theme-swatch {
  width: 32px;
  height: 32px;
  border-radius: 999px;
  border: 1px solid rgba(255, 255, 255, 0.28);
  background: radial-gradient(circle at 30% 10%, rgba(255, 255, 255, 0.25), transparent 55%);
  box-shadow: 0 8px 18px rgba(0, 0, 0, 0.5);
  cursor: pointer;
  position: relative;
  overflow: hidden;
}

.statblock-theme-swatch::after {
  content: '';
  position: absolute;
  inset: 0;
  mix-blend-mode: screen;
  opacity: 0;
  transition: opacity 0.2s ease;
}

.statblock-theme-swatch[aria-pressed='true'] {
  box-shadow: 0 0 0 2px rgba(255, 255, 255, 0.85), 0 10px 24px rgba(0, 0, 0, 0.7);
}

.statblock-theme-swatch:hover::after {
  opacity: 0.4;
}

.statblock-theme-swatch:focus {
  outline: 2px solid var(--focus);
  outline-offset: 2px;
}

.statblock-theme-swatch--parchment {
  background:
    radial-gradient(circle at 15% 0%, rgba(255, 236, 179, 0.85), transparent 60%),
    radial-gradient(circle at 80% 100%, rgba(255, 214, 163, 0.7), transparent 60%),
    linear-gradient(145deg, #3a2b1c, #1b1209);
}

.statblock-theme-swatch--ink {
  background:
    radial-gradient(circle at 20% 0%, rgba(138, 123, 255, 0.6), transparent 60%),
    radial-gradient(circle at 85% 100%, rgba(123, 209, 255, 0.4), transparent 60%),
    linear-gradient(145deg, #151427, #05040c);
}

.statblock-theme-swatch--ember {
  background:
    radial-gradient(circle at 25% 0%, rgba(255, 196, 160, 0.8), transparent 60%),
    radial-gradient(circle at 80% 100%, rgba(255, 120, 82, 0.7), transparent 60%),
    linear-gradient(145deg, #3b1f14, #150805);
}

.statblock-theme-swatch--starlight {
  background:
    radial-gradient(circle at 20% 0%, rgba(255, 255, 220, 0.9), transparent 60%),
    radial-gradient(circle at 80% 100%, rgba(168, 148, 255, 0.6), transparent 60%),
    linear-gradient(145deg, #181624, #05040c);
}

.statblock-sidebar-note {
  font-size: 0.85rem;
  color: rgba(255, 255, 255, 0.85);
  margin: 0.5rem 0 0;
  padding: 8px 10px;
  background: rgba(255, 255, 255, 0.05);
  border-radius: 6px;
  border-left: 3px solid rgba(138, 123, 255, 0.5);
  line-height: 1.5;
}

.statblock-cr-row {
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
}

.statblock-cr-step {
  border-radius: 999px;
  border: 1px solid rgba(255, 214, 163, 0.6);
  background: transparent;
  color: #fbeedd;
  font-size: 0.8rem;
  line-height: 1;
  width: 1.4rem;
  height: 1.4rem;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
}

.statblock-cr-value {
  display: inline-flex;
  align-items: baseline;
  gap: 0.3rem;
}

.statblock-cr-xp {
  font-size: 0.85rem;
  opacity: 0.9;
}

.statblock-toggle-list {
  display: grid;
  gap: 0.35rem;
  margin-top: 0.25rem;
}

.statblock-toggle {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  font-size: 0.85rem;
}

.statblock-toggle input[type='checkbox'] {
  width: 14px;
  height: 14px;
}

.statblock-skill-list {
  margin-top: 0.6rem;
}

.statblock-skill-toggle {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem;
  width: 100%;
  padding: 0.35rem 0.6rem;
  border-radius: 999px;
  border: 1px solid rgba(255, 255, 255, 0.18);
  background: rgba(0, 0, 0, 0.3);
  color: inherit;
  font-size: 0.85rem;
  cursor: pointer;
}

.statblock-skill-toggle:hover {
  border-color: rgba(255, 255, 255, 0.35);
  background: rgba(0, 0, 0, 0.5);
}

.statblock-skill-label {
  text-align: left;
}

.statblock-skill-badge {
  min-width: 42px;
  text-align: right;
  font-variant-numeric: tabular-nums;
  font-size: 0.8rem;
  opacity: 0.9;
}

.statblock-toast {
  position: fixed;
  bottom: 24px;
  left: 50%;
  transform: translateX(-50%) translateY(100px);
  background: linear-gradient(135deg, rgba(24, 22, 48, 0.98), rgba(12, 10, 28, 1));
  color: #ffffff;
  padding: 12px 20px;
  border-radius: 12px;
  border: 1.5px solid rgba(138, 123, 255, 0.7);
  box-shadow: 0 10px 30px rgba(6, 4, 20, 0.85);
  font-size: 0.9rem;
  font-weight: 500;
  z-index: 1000;
  max-width: 90vw;
  opacity: 0;
  transition: transform 0.3s ease, opacity 0.3s ease;
  pointer-events: none;
}

.statblock-toast--visible {
  transform: translateX(-50%) translateY(0);
  opacity: 1;
}

.library-list {
  list-style: none;
  padding: 0;
  margin: 12px 0 0;
  display: flex;
  flex-direction: column;
  gap: 8px;
  max-height: 300px;
  overflow-y: auto;
}

.library-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 8px 12px;
  background: rgba(255, 255, 255, 0.05);
  border-radius: 6px;
  border: 1px solid transparent;
  transition: all 0.2s ease;
}

.library-item:hover {
  background: rgba(255, 255, 255, 0.1);
  border-color: rgba(255, 255, 255, 0.2);
}

.library-item-name {
  font-size: 0.9rem;
  font-weight: 500;
  cursor: pointer;
  flex: 1;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  margin-right: 8px;
}

.library-item-actions {
  display: flex;
  gap: 4px;
}

.library-btn {
  background: none;
  border: none;
  color: var(--muted);
  cursor: pointer;
  padding: 4px;
  border-radius: 4px;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: color 0.2s;
}

.library-btn:hover {
  color: var(--fg);
  background: rgba(255, 255, 255, 0.1);
}

.library-btn.delete:hover {
  color: #ff4757;
}

.library-empty {
  color: var(--muted);
  font-size: 0.85rem;
  text-align: center;
  padding: 12px;
  font-style: italic;
}

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

@media (max-width: 640px) {
  .statblock-entry-row {
    grid-template-columns: minmax(0, 1fr);
  }
}
