:root {
  --bg: #12121a;
  --panel: #1d1d29;
  --panel-2: #252534;
  --text: #e8e6df;
  --muted: #9a97a8;
  --accent: #d4573d;
  --accent-2: #e0a64e;
  --border: #34344a;
  --check: #5fbf77;
}

[data-theme="mutated"] {
  --bg: #1c0a0a;
  --panel: #2b0e0e;
  --panel-2: #3b1313;
  --text: #f2e8cf;
  --muted: #c9b18a;
  --accent: #2e4a8f;
  --accent-2: #f4d03f;
  --border: #4d1f1f;
  --check: #f4d03f;
}

[data-theme="mutated"] body {
  background-image: radial-gradient(circle at 20% 10%, rgba(46, 74, 143, 0.15), transparent 50%),
    radial-gradient(circle at 80% 90%, rgba(244, 208, 63, 0.08), transparent 50%);
}

[data-theme="mutated"] #generate,
[data-theme="mutated"] .btn.primary { color: #fff; }

[data-theme="mutated"] .sheet {
  border-left: 4px solid var(--accent-2);
}

[data-theme="mutated"] .sheet h2 {
  border-left: 3px solid var(--accent);
  padding-left: 0.5rem;
}

[data-theme="mutated"] .advances {
  border-left: 4px solid var(--accent);
}

* { box-sizing: border-box; }

body {
  margin: 0;
  font-family: "Georgia", "Times New Roman", serif;
  background: var(--bg);
  color: var(--text);
  line-height: 1.6;
}

header {
  padding: 2rem 1.5rem 1rem;
}

.toolbar {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 1.5rem;
  flex-wrap: wrap;
  max-width: 1100px;
  margin: 0 auto;
}

.toolbar .logo {
  max-width: 220px;
  height: auto;
  flex-shrink: 0;
}

.hex-btn {
  width: 44px;
  height: 44px;
  padding: 0;
  background: rgba(255, 255, 255, 0.5);
  color: var(--muted);
  border: none;
  clip-path: polygon(25% 0%, 75% 0%, 100% 50%, 75% 100%, 25% 100%, 0% 50%);
  font-size: 1.4rem;
  line-height: 1;
  cursor: pointer;
  transition: color 0.15s, background 0.15s;
  flex-shrink: 0;
  position: relative;
}

.hex-btn::before {
  content: '';
  position: absolute;
  inset: 2px;
  clip-path: polygon(25% 0%, 75% 0%, 100% 50%, 75% 100%, 25% 100%, 0% 50%);
  background: var(--panel-2);
  z-index: -1;
}

.hex-btn:hover {
  color: var(--accent-2);
  background: rgba(255, 255, 255, 0.7);
}

.hex-btn:hover::before {
  background: var(--panel);
}

.controls {
  display: flex;
  flex-wrap: wrap;
  gap: 1rem;
  justify-content: center;
  align-items: flex-end;
  flex: 1 1 auto;
  min-width: 0;
}

.controls label {
  display: flex;
  flex-direction: column;
  gap: 0.3rem;
  font-size: 0.85rem;
  color: var(--muted);
}

.controls select,
.controls input {
  background: var(--panel-2);
  color: var(--text);
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 0.5rem 0.7rem;
  font-family: inherit;
  font-size: 0.95rem;
  min-width: 180px;
}

.controls input { min-width: 180px; }

.hint { font-size: 0.75rem; font-style: italic; }

#generate {
  background: var(--accent);
  color: #fff;
  border: none;
  border-radius: 6px;
  padding: 0.6rem 1.6rem;
  font-family: inherit;
  font-size: 1rem;
  cursor: pointer;
}

#generate:hover { background: #e96a4d; }

#generate:disabled { opacity: 0.5; cursor: not-allowed; }

.loading, .error {
  text-align: center;
  padding: 1rem;
  max-width: 900px;
  margin: 0 auto;
}

.layout {
  max-width: 1240px;
  margin: 0 auto;
  padding: 0 1rem;
  display: grid;
  grid-template-columns: minmax(0, 1fr) 330px;
  gap: 1.5rem;
  align-items: start;
}

.char-column { min-width: 0; }

.roller-column {
  position: sticky;
  top: 1rem;
}

@media (max-width: 1000px) {
  .layout { grid-template-columns: 1fr; }
  .roller-column { position: static; }
}

.portrait-section {
  margin: 0.4rem 0 0;
}

.portrait {
  width: 126px;
  height: 126px;
  border-radius: 10px;
  overflow: hidden;
  flex-shrink: 0;
  border: 1px solid var(--border);
  background: var(--panel-2);
  position: relative;
  box-shadow: 0 4px 14px rgba(0, 0, 0, 0.35);
  margin-left: -3rem;
}

.portrait img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}

.portrait-remove {
  position: absolute;
  bottom: 6px;
  left: 50%;
  transform: translateX(-50%);
  z-index: 5;
  white-space: nowrap;
}

.portrait.has-image:hover .portrait-remove {
  display: inline-flex;
}

.portrait-controls {
  display: flex;
  flex-wrap: wrap;
  gap: 0.6rem;
}

.portrait-controls .btn {
  font-size: 0.8rem;
  padding: 0.25rem 0.7rem;
}

.loading { color: var(--muted); font-style: italic; }

.error { color: #ff9d8a; }

.hidden { display: none; }

.sheet {
  width: 100%;
  margin: 0;
  padding: 1.5rem 2rem;
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 8px;
  font-family: "Georgia", "Times New Roman", serif;
}

.sheet-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1.2rem;
  border-bottom: 2px solid transparent;
  border-image: linear-gradient(90deg, var(--accent), var(--accent-2) 55%, transparent) 1;
  padding-bottom: 0.7rem;
  margin-bottom: 0.6rem;
}

.sheet-head h1 {
  display: inline-block;
  font-size: 2.7rem;
  font-weight: 800;
  line-height: 1.1;
  margin: 0;
  padding: 0;
  border-bottom: none;
  letter-spacing: 0.02em;
  color: #7fd4ff;
  text-shadow: 0 0 6px rgba(224, 166, 78, 0.9), 0 0 18px rgba(224, 166, 78, 0.55), 0 0 32px rgba(224, 166, 78, 0.35);
  animation: headFade 0.45s ease-out;
}

@keyframes headFade {
  from { opacity: 0; transform: translateY(-8px); }
  to { opacity: 1; transform: translateY(0); }
}

.sheet-title {
  display: flex;
  flex-direction: row;
  align-items: center;
  gap: 1.2rem;
  min-width: 0;
}

.sheet-title-text {
  display: flex;
  flex-direction: column;
  min-width: 0;
}

.sheet-sub {
  display: flex;
  align-items: baseline;
  gap: 0.45rem;
  margin-left: 0.8rem;
}

.sheet-calling {
  margin: 0;
  font-size: 0.82rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.22em;
  color: var(--accent);
  animation: headFade 0.45s ease-out 0.05s both;
}

#sheet-class {
  display: inline;
  vertical-align: baseline;
}

.sheet-title h3 {
  margin: 0;
  font-size: 1.1rem;
  color: var(--accent-2);
  font-style: italic;
  font-weight: 600;
  text-transform: none;
  letter-spacing: 0.04em;
  animation: headFade 0.45s ease-out 0.1s both;
}

.section-add {
  display: block;
  margin: 0.9rem 0 0.2rem;
  width: 2rem;
  height: 2rem;
  border-radius: 50%;
  border: 1px dashed var(--accent-2);
  background: var(--panel-2);
  color: var(--accent-2);
  font-size: 1.3rem;
  line-height: 1;
  cursor: pointer;
  padding: 0;
}

.section-add:hover {
  background: var(--accent);
  border-style: solid;
  color: #fff;
}

.ability-remove {
  margin-left: 0.6rem;
  width: 1.3rem;
  height: 1.3rem;
  padding: 0;
  border: 1px solid var(--border);
  border-radius: 50%;
  background: var(--panel-2);
  color: var(--muted);
  font-size: 0.95rem;
  line-height: 1;
  cursor: pointer;
  vertical-align: middle;
}

.ability-remove:hover {
  background: var(--accent);
  border-color: var(--accent);
  color: #fff;
}

.sheet h2 {
  font-size: 1.15rem;
  margin: 1.4rem 0 0.5rem;
  color: var(--accent-2);
  border-bottom: 1px solid var(--border);
  padding-bottom: 0.2rem;
}

.sheet h3 {
  font-size: 0.95rem;
  margin: 1rem 0 0.4rem;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: 0.08em;
}

.sheet ul { margin: 0.3rem 0 0.8rem; padding-left: 1.4rem; }

.sheet li { margin: 0.25rem 0; }

.sheet .desc {
  color: var(--muted);
  font-style: italic;
  margin-left: 1.4rem;
  padding-left: 0.4rem;
  border-left: 2px solid var(--border);
  white-space: pre-wrap;
}

.sheet input[type="checkbox"] { margin-right: 0.4rem; }

.sheet .empty { color: var(--muted); font-style: italic; }

.saves {
  padding-bottom: 2rem;
}

.btn {
  background: var(--panel-2);
  color: var(--text);
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 0.5rem 1.4rem;
  font-family: inherit;
  font-size: 0.95rem;
  cursor: pointer;
}

.btn:hover:not(:disabled) { border-color: var(--accent-2); }

.btn:disabled { opacity: 0.5; cursor: not-allowed; }

.btn.primary { background: var(--accent); color: #fff; border: none; }
.btn.primary:hover:not(:disabled) { background: #e96a4d; }

.btn.small { padding: 0.3rem 0.8rem; font-size: 0.85rem; }

.btn.danger:hover:not(:disabled) { border-color: var(--accent); color: #ff9d8a; }

.save-status { color: var(--check); font-size: 0.9rem; }

.user-bar {
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
  font-size: 0.85rem;
  color: var(--muted);
}

.user-name {
  font-weight: 700;
  color: var(--accent-2);
  letter-spacing: 0.04em;
}

.auth-screen {
  position: fixed;
  inset: 0;
  z-index: 200;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--bg);
  padding: 1rem;
}

.auth-screen.hidden,
.user-bar.hidden {
  display: none;
}

.auth-box {
  width: 100%;
  max-width: 360px;
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 2rem;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.8rem;
  box-shadow: 0 12px 40px rgba(0, 0, 0, 0.45);
}

.auth-logo {
  max-width: 130px;
  height: auto;
}

.auth-title {
  margin: 0;
  font-size: 1.6rem;
  font-weight: 800;
  letter-spacing: 0.06em;
  color: #7fd4ff;
}

.auth-tabs {
  display: flex;
  gap: 0.4rem;
  margin-top: 0.4rem;
}

.auth-tab {
  padding: 0.35rem 0.9rem;
  font-size: 0.85rem;
  border: 1px solid var(--border);
  border-radius: 6px;
  background: transparent;
  color: var(--muted);
  cursor: pointer;
}

.auth-tab.active {
  background: var(--accent-2);
  border-color: var(--accent-2);
  color: #1a1a20;
  font-weight: 700;
}

.auth-form {
  width: 100%;
  display: flex;
  flex-direction: column;
  gap: 0.7rem;
}

.auth-form label {
  display: flex;
  flex-direction: column;
  gap: 0.3rem;
  font-size: 0.85rem;
  color: var(--muted);
}

.auth-form input {
  background: var(--panel-2);
  color: var(--text);
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 0.5rem 0.7rem;
  font-family: inherit;
  font-size: 0.95rem;
}

.auth-form .btn {
  margin-top: 0.3rem;
}

.advances {
  margin: 1.5rem 0 0;
  padding: 1.2rem 2rem;
  background: var(--panel);
  border: 1px solid var(--border);
  border-left: 4px solid var(--accent-2);
  border-radius: 8px;
}

.advances h2 {
  margin: 0 0 0.6rem;
  font-size: 1.1rem;
  color: var(--accent-2);
}

.advance-stats {
  display: flex;
  gap: 0.6rem;
  margin-bottom: 0.8rem;
}

.advance-chip {
  background: var(--panel-2);
  border: 1px solid var(--border);
  border-radius: 999px;
  padding: 0.25rem 0.9rem;
  font-size: 0.85rem;
}

.advance-chip.ready {
  border-color: var(--check);
  color: var(--check);
}

.advance-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 0.6rem;
}

.advances .hint { margin-top: 0.8rem; }

.res-tracker {
  margin: 0.3rem 0 1rem;
}

.res-row {
  display: flex;
  align-items: center;
  gap: 1rem;
  padding: 0.3rem 0;
  border-bottom: 1px dashed var(--border);
}

.res-row:last-child { border-bottom: none; }

.res-name {
  width: 7rem;
  font-weight: 600;
  cursor: help;
  border-bottom: 1px dotted var(--border);
}

.res-track {
  display: flex;
  align-items: center;
  gap: 0.45rem;
}

.res-btn {
  background: var(--panel-2);
  color: var(--text);
  border: 1px solid var(--border);
  border-radius: 5px;
  width: 1.7rem;
  height: 1.7rem;
  font-size: 1.1rem;
  line-height: 1;
  cursor: pointer;
  padding: 0;
}

.res-btn:hover { border-color: var(--accent-2); color: var(--accent-2); }

.beat-item {
  display: flex;
  align-items: center;
  gap: 0.4rem;
}

.res-stress {
  display: inline-block;
  min-width: 2rem;
  text-align: center;
  font-size: 1.1rem;
  font-weight: 700;
  color: var(--accent-2);
}

.res-stress.danger {
  color: var(--accent);
}

.res-stress.protected {
  position: relative;
  padding: 0.1em 0.35em;
  outline: 1.5px solid #9b59b640;
  border-radius: 2px;
}

.res-header {
  display: flex;
  align-items: center;
  gap: 1rem;
  padding: 0.2rem 0;
  font-size: 0.75rem;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

.res-track-label {
  width: calc(1.7rem + 0.45rem + 2rem + 0.45rem + 1.7rem);
  text-align: center;
}

.res-prot-label {
  width: calc(22px + 0.4rem);
  text-align: center;
}

.res-prot-shield {
  position: relative;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 22px;
  height: 26px;
  background: #9b59b6;
  color: var(--bg);
  font-size: 0.75rem;
  font-weight: 600;
  clip-path: polygon(0% 0%, 100% 0%, 100% 60%, 50% 100%, 0% 60%);
  margin-left: 0.4rem;
  line-height: 1;
  filter: drop-shadow(0 0 4px #9b59b6);
  z-index: 0;
}

.res-prot-shield.empty {
  background: transparent;
  filter: none;
}

.res-prot-shield.empty::before {
  content: '';
  position: absolute;
  inset: -2px;
  clip-path: polygon(0% 0%, 100% 0%, 100% 60%, 50% 100%, 0% 60%);
  background: #9b59b640;
  z-index: -1;
}

.roller {
  margin: 0;
  width: 100%;
  padding: 1.2rem 2rem;
  background: var(--panel);
  border: 1px solid var(--border);
  border-left: 4px solid var(--accent-2);
  border-radius: 8px;
}

.roller h2 {
  margin: 0 0 0.6rem;
  font-size: 1.1rem;
  color: var(--accent-2);
}

.roller-controls {
  display: flex;
  flex-wrap: wrap;
  align-items: flex-end;
  gap: 1rem;
}

.roller-controls label {
  display: flex;
  flex-direction: column;
  gap: 0.3rem;
  font-size: 0.85rem;
  color: var(--muted);
}

.roller-controls select {
  background: var(--panel-2);
  color: var(--text);
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 0.4rem 0.6rem;
  font-family: inherit;
  min-width: 12rem;
}

.roller-mastery {
  flex-direction: row !important;
  align-items: center !important;
  gap: 0.5rem !important;
  color: var(--text) !important;
  padding-bottom: 0.45rem;
}

.roller-mastery input {
  accent-color: var(--accent-2);
  width: 1rem;
  height: 1rem;
}

.roller-column .roller-controls {
  flex-direction: column;
  align-items: stretch;
  gap: 0.7rem;
}

.roller-column .roller-controls label { width: 100%; }

.roller-column .roller-controls select {
  min-width: 0;
  width: 100%;
}

.roller-column .roller-mastery { align-self: flex-start; }

.roller-column #roll { width: 100%; }

.roll-result {
  margin-top: 1rem;
}

.roll-dice {
  display: flex;
  flex-wrap: wrap;
  gap: 0.6rem;
  margin-bottom: 0.8rem;
}

.die {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 2.8rem;
  height: 2.8rem;
  border-radius: 8px;
  background: var(--panel-2);
  border: 1px solid var(--border);
  font-size: 1.4rem;
  font-weight: 700;
  color: var(--text);
}

.die.high {
  border-color: var(--accent-2);
  color: var(--accent-2);
  filter: drop-shadow(0 0 6px color-mix(in srgb, var(--accent-2) 50%, transparent));
}

.die.high.fail {
  border-color: var(--accent);
  color: var(--accent);
  filter: drop-shadow(0 0 6px color-mix(in srgb, var(--accent) 50%, transparent));
}

.die.removed {
  opacity: 0.35;
  text-decoration: line-through;
  border-style: dashed;
}

.roll-removed-hint {
  font-size: 0.8rem;
  color: var(--muted);
  font-style: italic;
  margin: 0 0 0.6rem;
}

.roll-outcome {
  display: flex;
  align-items: baseline;
  gap: 1rem;
  margin-bottom: 0.4rem;
}

.roll-tier {
  font-size: 1.25rem;
  font-weight: 800;
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

.roll-tier.crit { color: var(--accent-2); }
.roll-tier.major { color: var(--check); }
.roll-tier.minor { color: #e8c46a; }
.roll-tier.fail { color: var(--accent); }

.roll-highest {
  color: var(--muted);
  font-size: 0.95rem;
}

.roll-text {
  margin: 0;
  color: var(--muted);
  font-size: 0.92rem;
}

.appearance {
  margin: 0;
  padding: 0.4rem 0.9rem 0.5rem;
  background: transparent;
  border: 1px solid var(--border);
  border-radius: 6px;
  font-family: "Georgia", "Times New Roman", serif;
  max-width: 320px;
  flex-shrink: 0;
  display: flex;
  flex-direction: column;
  justify-content: center;
}

.appearance h2 {
  font-size: 0.72rem;
  font-weight: 700;
  margin: 0 0 0.2rem;
  color: var(--accent-2);
  border-bottom: 1px solid var(--border);
  padding-bottom: 0.15rem;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.appearance ul {
  margin: 0.2rem 0 0.3rem;
  padding-left: 1.1rem;
  font-size: 0.78rem;
  line-height: 1.3;
  column-count: 2;
  column-gap: 1.2rem;
}

.appearance li { margin: 0.1rem 0; }

.appearance .btn {
  margin-top: 0.3rem;
  font-size: 0.75rem;
  padding: 0.2rem 0.6rem;
  align-self: flex-start;
}

.notes {
  margin: 1.5rem 0 0;
  width: 100%;
  padding: 1.2rem 2rem;
  background: var(--panel);
  border: 1px solid var(--border);
  border-left: 4px solid var(--accent-2);
  border-radius: 8px;
}

.notes h2 {
  margin: 0 0 0.6rem;
  font-size: 1.1rem;
  color: var(--accent-2);
}

.notes textarea {
  width: 100%;
  background: var(--panel-2);
  color: var(--text);
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 0.6rem;
  font-family: inherit;
  font-size: 0.9rem;
  resize: vertical;
  min-height: 8rem;
}

.notes textarea:focus {
  outline: none;
  border-color: var(--accent-2);
}

.notes-actions {
  display: flex;
  align-items: center;
  gap: 0.6rem;
  margin-top: 0.7rem;
}

.appearance-grid {
  display: flex;
  flex-direction: column;
  gap: 0.4rem;
}

.fallout {
  margin: 1.5rem 0 0;
  padding: 1.5rem 2rem;
  background: var(--panel);
  border: 1px solid var(--border);
  border-left: 4px solid var(--accent-2);
  border-radius: 8px;
}

.fallout h2 {
  margin: 0 0 0.4rem;
  font-size: 1.15rem;
  color: var(--accent-2);
}

.fallout-controls {
  display: flex;
  flex-wrap: wrap;
  align-items: flex-end;
  gap: 0.6rem;
  margin: 0.8rem 0;
}

.fallout-controls label {
  display: flex;
  flex-direction: column;
  gap: 0.2rem;
  font-size: 0.8rem;
  color: var(--muted);
}

.fallout-controls select {
  padding: 0.3rem 0.5rem;
  background: var(--panel-2);
  color: var(--text);
  border: 1px solid var(--border);
  border-radius: 4px;
}

.fallout-list {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}

.fallout-card {
  padding: 0.6rem 0.9rem;
  background: var(--panel-2);
  border: 1px solid var(--border);
  border-radius: 6px;
}

.fallout-card-head {
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  gap: 0.4rem;
  margin-bottom: 0.2rem;
}

.fallout-tag {
  font-size: 0.7rem;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--muted);
  border: 1px solid var(--border);
  border-radius: 999px;
  padding: 0.05rem 0.5rem;
}

.fallout-tag.also { color: var(--accent-2); border-color: var(--accent-2); }

.fallout-desc { font-size: 0.9rem; }

.stress-check {
  margin: 0.8rem 0;
  padding: 0.9rem 1rem;
  background: var(--panel-2);
  border: 1px solid var(--border);
  border-radius: 6px;
}

.stress-check-info {
  display: flex;
  flex-wrap: wrap;
  gap: 1.2rem;
  margin-bottom: 0.6rem;
  font-size: 0.9rem;
  color: var(--muted);
}

.stress-check-info strong { color: var(--text); }

.stress-result { margin-top: 0.8rem; }

.roll-tier.none { color: var(--muted); }

.fallout-add {
  margin-top: 0.5rem;
  padding: 0.25rem 0.7rem;
  font-size: 0.8rem;
  background: var(--panel-2);
  color: var(--text);
  border: 1px solid var(--border);
  border-radius: 4px;
  cursor: pointer;
}

.fallout-add:hover:not(:disabled) {
  border-color: var(--check);
  color: var(--check);
}

.fallout-add:disabled {
  opacity: 0.55;
  cursor: default;
  border-color: var(--check);
  color: var(--check);
}

.fallout-remove {
  margin-left: 0.6rem;
  width: 1.3rem;
  height: 1.3rem;
  padding: 0;
  border: 1px solid var(--border);
  border-radius: 50%;
  background: var(--panel-2);
  color: var(--muted);
  font-size: 0.95rem;
  line-height: 1;
  cursor: pointer;
  vertical-align: middle;
}

.fallout-remove:hover {
  background: var(--accent);
  border-color: var(--accent);
  color: #fff;
}

.resource-tracker {
  margin: 0.3rem 0 0.8rem;
}

.resource-row {
  display: flex;
  align-items: center;
  gap: 0.8rem;
  padding: 0.3rem 0;
  border-bottom: 1px dashed var(--border);
}

.resource-row:last-of-type { border-bottom: none; }

.resource-name {
  font-weight: 600;
}

.resource-meta {
  color: var(--muted);
  font-size: 0.9rem;
}

.resource-tracker .btn { margin-top: 0.6rem; }

.skill-domain-tracker {
  margin: 0.3rem 0 0.8rem;
}

.skill-domain-row {
  display: flex;
  align-items: center;
  gap: 0.8rem;
  padding: 0.3rem 0;
  border-bottom: 1px dashed var(--border);
}

.skill-domain-row:last-of-type { border-bottom: none; }

.sd-name {
  font-weight: 600;
  cursor: help;
  border-bottom: 1px dotted var(--border);
}
}

.sd-source {
  color: var(--muted);
  font-size: 0.9rem;
}

.skill-domain-tracker .btn { margin-top: 0.6rem; }

.form-field {
  display: flex;
  flex-direction: column;
  gap: 0.3rem;
  margin: 0.8rem 0;
  color: var(--muted);
  font-size: 0.9rem;
}

.form-field input,
.form-field select {
  background: var(--panel-2);
  color: var(--text);
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 0.45rem 0.6rem;
  font-family: inherit;
}

.form-field input:focus,
.form-field select:focus {
  outline: none;
  border-color: var(--accent-2);
}

.modal-actions {
  display: flex;
  gap: 0.6rem;
  margin-top: 1rem;
}

.saves {
  max-width: 1240px;
  margin: 2.5rem auto;
  padding: 0 1rem;
}

.saves h2 {
  color: var(--accent-2);
  font-size: 1.1rem;
  border-bottom: 1px solid var(--border);
  padding-bottom: 0.3rem;
}

.saves-list {
  list-style: none;
  padding: 0;
  margin: 0.6rem 0 0;
}

.save-item {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 1rem;
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 0.7rem 1rem;
  margin-bottom: 0.5rem;
}

.save-info {
  display: flex;
  flex-direction: column;
  gap: 0.15rem;
}

.save-meta { color: var(--muted); font-size: 0.8rem; }

.save-actions { display: flex; gap: 0.5rem; }

.modal {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.65);
  display: flex;
  align-items: flex-start;
  justify-content: center;
  padding: 3rem 1rem;
  z-index: 100;
}

.modal.hidden { display: none; }

.modal-box {
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 10px;
  width: 100%;
  max-width: 640px;
  max-height: 80vh;
  overflow-y: auto;
  padding: 1.2rem 1.5rem;
}

.modal-head {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 0.8rem;
  font-weight: bold;
  color: var(--accent-2);
  border-bottom: 1px solid var(--border);
  padding-bottom: 0.5rem;
}

.modal-close {
  background: none;
  border: none;
  color: var(--muted);
  font-size: 1.4rem;
  cursor: pointer;
}

.modal-close:hover { color: var(--text); }

.modal .opt-card {
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 0.7rem 0.9rem;
  margin-bottom: 0.6rem;
}

.opt-btn {
  background: none;
  border: none;
  color: var(--text);
  font-family: inherit;
  font-size: 0.95rem;
  font-weight: bold;
  text-align: left;
  cursor: pointer;
  padding: 0;
}

.opt-btn:hover { color: var(--accent-2); }

.opt-desc {
  color: var(--muted);
  font-style: italic;
  font-size: 0.88rem;
  margin-top: 0.35rem;
  white-space: pre-wrap;
}

.minor-label {
  display: flex;
  flex-direction: column;
  gap: 0.3rem;
  margin: 0.8rem 0;
  color: var(--muted);
  font-size: 0.9rem;
}

.minor-label select {
  background: var(--panel-2);
  color: var(--text);
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 0.4rem 0.6rem;
  font-family: inherit;
}

.sheet input[type="checkbox"]:not(:disabled) { cursor: pointer; accent-color: var(--check); }

.back-to-top {
  position: fixed;
  right: 1.2rem;
  bottom: 1.2rem;
  width: 2.6rem;
  height: 2.6rem;
  border-radius: 50%;
  border: 1px solid var(--accent-2);
  background: var(--panel-2);
  color: var(--accent-2);
  font-size: 1.3rem;
  line-height: 1;
  cursor: pointer;
  opacity: 0;
  pointer-events: none;
  transform: translateY(6px);
  transition: opacity 0.25s ease, transform 0.25s ease, background 0.25s ease, color 0.25s ease;
  z-index: 50;
}

.back-to-top.visible {
  opacity: 1;
  pointer-events: auto;
  transform: translateY(0);
}

/* Hex Map Modal */
.hex-modal-box {
  max-width: 720px;
}

.hex-modal-body {
  display: flex;
  gap: 1.2rem;
  padding: 0.8rem;
}

.hex-palette {
  flex: 0 0 140px;
}

.hex-palette h3 {
  margin: 0 0 0.5rem;
  font-size: 0.9rem;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

.hex-tiles {
  display: flex;
  flex-wrap: wrap;
  gap: 0.35rem;
}

.hex-category {
  flex-basis: 100%;
  font-size: 0.65rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--muted);
  margin: 0.4rem 0 0.1rem;
}

.hex-category:first-child {
  margin-top: 0;
}

.hex-tile-chip {
  padding: 0.25rem 0.5rem;
  border-radius: 4px;
  font-size: 0.7rem;
  font-weight: 600;
  color: #fff;
  cursor: grab;
  user-select: none;
  white-space: nowrap;
}

.hex-tile-chip:has(.hex-chip-image) {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.15rem;
  padding: 0.25rem;
  background: var(--panel-2);
}

.hex-chip-image {
  width: 34px;
  height: 34px;
  object-fit: cover;
  border-radius: 3px;
  display: block;
}

.hex-chip-name {
  font-size: 0.6rem;
  max-width: 60px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.hex-image-controls {
  display: flex;
  flex-direction: column;
  gap: 0.3rem;
  margin-top: 0.6rem;
}

.hex-image-controls .btn {
  width: 100%;
}

.hex-tile-chip:active {
  cursor: grabbing;
}

.hex-tile-chip.hex-dragging {
  opacity: 0.4;
}

.hex-cell.hex-dragging {
  opacity: 0.5;
}

.hex-custom {
  display: flex;
  gap: 0.3rem;
  margin-top: 0.6rem;
}

.hex-custom input {
  flex: 1;
  min-width: 0;
  background: var(--panel-2);
  color: var(--text);
  border: 1px solid var(--border);
  border-radius: 4px;
  padding: 0.25rem 0.4rem;
  font-size: 0.75rem;
}

.hex-grid-wrapper {
  flex: 1;
  overflow: auto;
}

.hex-grid {
  position: relative;
  padding: 0.5rem;
  isolation: isolate;
}

.hex-cell {
  position: absolute;
  width: 54px;
  height: 46px;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: default;
  z-index: 0;
}

.hex-cell::before {
  content: '';
  position: absolute;
  inset: 0;
  background: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='54' height='46' viewBox='0 0 54 46'%3E%3Cpolygon points='14.5,1 39.5,1 53,23 39.5,45 14.5,45 1,23' fill='none' stroke='white' stroke-opacity='0.9' stroke-width='1.5'/%3E%3C/svg%3E") no-repeat center/100% 100%;
  z-index: 1;
  pointer-events: none;
}

.hex-cell::after {
  content: '';
  position: absolute;
  inset: 0;
  clip-path: polygon(25% 0%, 75% 0%, 100% 50%, 75% 100%, 25% 100%, 0% 50%);
  background: var(--panel-2);
  z-index: -1;
  pointer-events: none;
}

.hex-cell.hex-drag-over::after {
  background: var(--panel);
}

.hex-cell.hex-occupied::after {
  background: var(--hex-bg, var(--panel-2));
}

.hex-cell.hex-occupied {
  cursor: grab;
}

.hex-cell.hex-occupied:active {
  cursor: grabbing;
}

.hex-label {
  position: relative;
  z-index: 1;
  font-size: 0.55rem;
  font-weight: 700;
  color: #fff;
  text-align: center;
  line-height: 1.1;
  padding: 0 0.2rem;
  pointer-events: none;
  text-shadow: 0 1px 2px rgba(0,0,0,0.5);
  word-wrap: break-word;
  overflow-wrap: break-word;
  max-width: 100%;
}

.hex-tile-image {
  width: 100%;
  height: 100%;
  object-fit: cover;
  position: absolute;
  inset: 0;
  clip-path: polygon(25% 0%, 75% 0%, 100% 50%, 75% 100%, 25% 100%, 0% 50%);
}

.hex-remove {
  position: absolute;
  top: 4px;
  left: 56%;
  background: none;
  border: none;
  color: rgba(255,255,255,0.6);
  font-size: 0.7rem;
  line-height: 1;
  cursor: pointer;
  padding: 0;
  opacity: 0;
  transition: opacity 0.15s;
  z-index: 2;
}

.hex-cell:hover .hex-remove {
  opacity: 1;
}

.hex-remove:hover {
  color: #fff;
}

.back-to-top:hover {
  background: var(--accent);
  border-color: var(--accent);
  color: #fff;
}
