:root {
  --grauc-accent: #38bdf8;
}

/* links: no underline, subtle hover */
a { text-decoration: none; }
a:hover { text-decoration: none; opacity: .85; }
.session-info a { color: var(--grauc-accent); }

/* ---- dark theme (default) ---- */
[data-bs-theme="dark"] body {
  background: radial-gradient(1200px 600px at 50% -10%, #102032 0%, #0b1117 55%) fixed, #0b1117;
}
[data-bs-theme="dark"] .grauc-nav { background: rgba(13, 20, 28, 0.85); }
[data-bs-theme="dark"] .hero {
  background:
    radial-gradient(800px 300px at 80% 0%, rgba(56, 189, 248, 0.12), transparent),
    linear-gradient(180deg, rgba(30, 41, 59, 0.6), rgba(15, 23, 42, 0.6));
}
[data-bs-theme="dark"] .grauc-card { background: rgba(30, 41, 59, 0.35); }
[data-bs-theme="dark"] a.grauc-card:hover { background: rgba(56, 189, 248, 0.08); }
[data-bs-theme="dark"] body { --grauc-thead-bg: rgba(56, 189, 248, 0.14); --grauc-table-bg: rgba(30, 41, 59, 0.45); }

/* ---- light theme ---- */
[data-bs-theme="light"] body {
  background: radial-gradient(1200px 600px at 50% -10%, #e8f1fb 0%, #f5f7fa 55%) fixed, #f5f7fa;
}
/* the top toolbar stays dark in every theme (it carries data-bs-theme="dark") */
[data-bs-theme="light"] .grauc-nav { background: rgba(13, 20, 28, 0.85); }
[data-bs-theme="light"] .hero {
  background:
    radial-gradient(800px 300px at 80% 0%, rgba(56, 189, 248, 0.10), transparent),
    linear-gradient(180deg, #ffffff, #eef4fb);
}
[data-bs-theme="light"] .grauc-card { background: #ffffff; }
[data-bs-theme="light"] a.grauc-card:hover { background: #f0f8ff; }
[data-bs-theme="light"] body { --grauc-thead-bg: rgba(56, 189, 248, 0.12); --grauc-table-bg: #ffffff; }

/* ---- shared ---- */
.grauc-nav { backdrop-filter: blur(8px); }
.hero { border: 1px solid rgba(148, 163, 184, 0.18); }
.grauc-card {
  border: 1px solid rgba(148, 163, 184, 0.18);
  transition: transform .12s ease, border-color .12s ease, background .12s ease;
}
a.grauc-card:hover { transform: translateY(-3px); border-color: var(--grauc-accent); }
.navbar .nav-link.active { color: var(--grauc-accent) !important; }

.adv-cost {
  background: rgba(56, 189, 248, 0.14);
  color: var(--grauc-accent);
  border: 1px solid rgba(56, 189, 248, 0.40);
  font-weight: 600;
}

/* headings a touch smaller than Bootstrap defaults */
h2, .h2 { font-size: 1.65rem; }
h3, .h3 { font-size: 1.4rem; }

/* WYSIWYG editor (TipTap) */
.wysiwyg-box { height: auto; overflow: visible; }
.wysiwyg-box:focus-within {
  border-color: var(--grauc-accent);
  box-shadow: 0 0 0 .2rem rgba(56, 189, 248, .15);
}
/* flat toolbar that lives inside the editor box */
.wysiwyg-toolbar {
  display: flex; flex-wrap: wrap; align-items: center; gap: .1rem;
  padding: .3rem .4rem;
  border-bottom: 1px solid var(--bs-border-color);
}
.wysiwyg-toolbar .tbtn {
  display: inline-flex; align-items: center; justify-content: center;
  min-width: 1.9rem; height: 1.9rem; padding: 0 .45rem;
  background: transparent; border: 0; border-radius: 5px;
  color: inherit; line-height: 1; cursor: pointer; font-size: .9rem;
}
.wysiwyg-toolbar .tbtn:hover { background: rgba(127, 127, 127, .18); }
.wysiwyg-toolbar .tbtn.active { background: var(--grauc-accent); color: #08121c; }
.wysiwyg-toolbar .tsep {
  width: 1px; align-self: stretch; margin: .15rem .25rem;
  background: var(--bs-border-color);
}
.tt-icon { font-weight: 700; }
.tt-icon small { font-size: .72em; }

/* toolbar dropdowns (headings, emoji) */
.wysiwyg-dd { position: relative; display: inline-flex; }
.wysiwyg-dd-panel {
  position: absolute; top: 100%; left: 0; z-index: 1080; margin-top: .25rem;
  display: none; min-width: 8rem; padding: .25rem;
  background: var(--bs-body-bg); color: var(--bs-body-color);
  border: 1px solid var(--bs-border-color); border-radius: 7px;
  box-shadow: 0 8px 22px rgba(0, 0, 0, .28);
}
.wysiwyg-dd.open .wysiwyg-dd-panel { display: block; }
.wysiwyg-dd-item {
  display: block; width: 100%; text-align: left; white-space: nowrap;
  background: transparent; border: 0; color: inherit;
  padding: .35rem .6rem; border-radius: 5px; cursor: pointer;
}
.wysiwyg-dd-item:hover { background: rgba(127, 127, 127, .18); }
.wysiwyg-dd-item.active { color: var(--grauc-accent); }
.emoji-panel {
  grid-template-columns: repeat(8, 1.85rem); gap: .1rem; justify-content: start;
  max-height: 12rem; overflow-x: hidden; overflow-y: auto; scrollbar-gutter: stable;
}
/* only show (as a grid) when its dropdown is open */
.wysiwyg-dd.open .emoji-panel { display: grid; }
.emoji-panel button {
  width: 1.85rem; height: 1.85rem; padding: 0;
  background: transparent; border: 0; border-radius: 5px;
  font-size: 1.1rem; line-height: 1; cursor: pointer;
}
.emoji-panel button:hover { background: rgba(127, 127, 127, .18); }

/* text-colour dropdown */
.color-default {
  display: flex; align-items: center; gap: .45rem; width: 100%; text-align: left;
  background: transparent; border: 0; color: inherit;
  padding: .3rem .5rem; border-radius: 5px; cursor: pointer; margin-bottom: .15rem;
}
.color-default:hover { background: rgba(127, 127, 127, .18); }
.color-grid { display: grid; grid-template-columns: repeat(6, 1.5rem); gap: .25rem; }
.color-swatch {
  width: 1.5rem; height: 1.5rem; padding: 0; border-radius: 4px; cursor: pointer;
  border: 1px solid rgba(127, 127, 127, .45);
}
.color-grid .color-swatch:hover { transform: scale(1.12); }
.color-swatch-default {
  background: linear-gradient(135deg, #f5f7fa 0 50%, #0b1117 50% 100%);
  display: inline-block;
}

.wysiwyg-editor {
  min-height: 240px; height: 320px; padding: .6rem .8rem; cursor: text;
  overflow: auto; resize: vertical;   /* drag the bottom-right corner to resize */
}
.wysiwyg-editor .ProseMirror { outline: none; min-height: 100%; }
.wysiwyg-editor .ProseMirror > :last-child { margin-bottom: 0; }
.wysiwyg-editor .ProseMirror p { margin-bottom: .5rem; }
.wysiwyg-editor .ProseMirror blockquote {
  border-left: 3px solid var(--grauc-accent); padding-left: .8rem; margin-left: 0; opacity: .9;
}
/* placeholder when empty */
.wysiwyg-editor .ProseMirror p.is-editor-empty:first-child::before {
  content: attr(data-placeholder); color: #6c757d; float: left; height: 0; pointer-events: none;
}
/* images inside the editor: resizable via the corner handle */
.wysiwyg-editor .ProseMirror img { max-width: 100%; height: auto; border-radius: 6px; }
.wysiwyg-editor .img-resize-wrapper { position: relative; display: inline-block; line-height: 0; max-width: 100%; }
.wysiwyg-editor .ProseMirror-selectednode .img-resize-wrapper img,
.wysiwyg-editor .img-resize-wrapper:hover img { outline: 2px solid var(--grauc-accent); }
.wysiwyg-editor .img-resize-handle {
  position: absolute; right: -6px; bottom: -6px; width: 14px; height: 14px;
  background: var(--grauc-accent); border: 2px solid #fff; border-radius: 50%;
  cursor: nwse-resize; opacity: 0; transition: opacity .1s;
}
.wysiwyg-editor .img-resize-wrapper:hover .img-resize-handle { opacity: 1; }

/* images in rendered write-ups stay within their column */
.session-info img { max-width: 100%; height: auto; border-radius: 6px; }

/* grauc-table: distinct header band; border wraps the body only (not the header) */
table.grauc-table { border-collapse: separate; border-spacing: 0; }
table.grauc-table > thead > tr > th,
table.grauc-table > tbody > tr > td { border: 0; }              /* reset Bootstrap cell borders */
table.grauc-table > thead > tr > th {
  background: var(--grauc-thead-bg);
  font-weight: 600;
  padding: .55rem .5rem;
  border-bottom: 2px solid var(--grauc-accent);
}
table.grauc-table > tbody { background: var(--grauc-table-bg); }
table.grauc-table > tbody > tr:not(:last-child) > td { border-bottom: 1px solid var(--bs-border-color); }
table.grauc-table > tbody > tr > td:first-child { border-left: 1px solid var(--bs-border-color); }
table.grauc-table > tbody > tr > td:last-child  { border-right: 1px solid var(--bs-border-color); }
table.grauc-table > tbody > tr:last-child > td   { border-bottom: 1px solid var(--bs-border-color); }
table.grauc-table > tbody > tr:last-child > td:first-child { border-bottom-left-radius: .5rem; }
table.grauc-table > tbody > tr:last-child > td:last-child  { border-bottom-right-radius: .5rem; }

/* extra-small button (e.g. destructive character actions) */
.btn-xs { padding: .1rem .4rem; font-size: .72rem; line-height: 1.3; }

/* "level up" call-to-action button */
.levelup-flash { animation: levelup-pulse 1.3s ease-in-out infinite; }
@keyframes levelup-pulse {
  0%, 100% { box-shadow: 0 0 0 0 rgba(255, 193, 7, .65); }
  50%      { box-shadow: 0 0 0 .7rem rgba(255, 193, 7, 0); }
}
@media (prefers-reduced-motion: reduce) { .levelup-flash { animation: none; } }

/* character attribute tiles */
.attr-tile {
  position: relative; overflow: hidden;
  border: 1px solid var(--bs-border-color); border-radius: 8px;
  padding: .5rem .25rem; text-align: center; height: 100%;
}
/* faint duotone icon filling the tile behind the content */
.attr-tile { min-height: 6rem; }
.attr-tile > .attr-bg {
  position: absolute; top: 50%; left: 50%; transform: translate(-50%, -50%);
  font-size: 5.5rem; line-height: 1; opacity: .12; pointer-events: none;
  color: var(--grauc-accent);
  --fa-primary-opacity: 1; --fa-secondary-opacity: .45;
}
.attr-tile > :not(.attr-bg) { position: relative; }  /* keep text above the icon */
/* per-attribute tint for the background icon */
.attr-bg.attr-str { color: #e0556b; }   /* strength  - red */
.attr-bg.attr-agi { color: #2fa45a; }   /* agility   - green */
.attr-bg.attr-sta { color: #e8833a; }   /* stamina   - orange */
.attr-bg.attr-int { color: #3b82f6; }   /* intellect - blue */
.attr-bg.attr-app { color: #ec4899; }   /* appearance- pink */
.attr-bg.attr-gra { color: #a855f7; }   /* grace     - purple */
.attr-bg.attr-lck { color: #d6a400; }   /* luck      - gold */
.attr-score { font-size: 1.6rem; font-weight: 700; line-height: 1.05; }
.attr-mod {
  display: inline-block; font-weight: 700; font-size: .8rem;
  padding: .02rem .5rem; border-radius: 999px;
  background: rgba(56, 189, 248, 0.14); color: var(--grauc-accent);
  border: 1px solid rgba(56, 189, 248, 0.40);
}
/* attribute modifier badge: red negative, grey zero, green positive */
.attr-mod.attr-mod-pos {
  background: rgba(47, 164, 90, .16); color: #2fa45a; border-color: rgba(47, 164, 90, .45);
}
.attr-mod.attr-mod-neg {
  background: rgba(224, 85, 107, .16); color: #e0556b; border-color: rgba(224, 85, 107, .45);
}
.attr-mod.attr-mod-zero {
  background: rgba(127, 127, 127, .14); color: var(--bs-secondary-color); border-color: rgba(127, 127, 127, .35);
}

/* a pair of frames that sit side by side when there's room, else stack;
   gap handles spacing in both directions, so zero the inner cards' own margin */
.frame-pair > div > .grauc-card { margin-bottom: 0 !important; }

/* inline "date stamp" inserted from the rich-text editor toolbar */
.date-stamp {
  font-weight: 600;
  color: var(--grauc-accent);
  background: rgba(56, 189, 248, .12);
  border: 1px solid rgba(56, 189, 248, .30);
  padding: .02rem .4rem;
  border-radius: .4rem;
  white-space: nowrap;
}

/* basic-skill marker: subtle blue dot after the skill name */
.basic-dot {
  display: inline-block; width: .5rem; height: .5rem; margin-left: .35rem;
  border-radius: 50%; background: var(--grauc-accent); vertical-align: middle; cursor: help;
}
.skill-link { color: inherit; }
.skill-link:hover { color: var(--grauc-accent); }
/* highlight a skill card when linked to from a character sheet */
.skill-item { scroll-margin-top: 80px; }
.skill-item:target,
.skill-item.skill-flash {
  border-color: var(--grauc-accent);
  box-shadow: 0 0 0 .2rem rgba(56, 189, 248, 0.20);
}
/* deprecated skills: muted, with a faint diagonal "retired" hatch */
.skill-item.skill-deprecated {
  opacity: .72;
  border-color: rgba(224, 133, 58, .35);
  background-image: repeating-linear-gradient(
    -45deg, rgba(224, 133, 58, .07), rgba(224, 133, 58, .07) 10px,
    transparent 10px, transparent 20px);
}
.skill-item.skill-deprecated .fs-5 { text-decoration: line-through; }

/* abilities editor: an ability with 0 points (not taken) reads as muted, but its
   point selector stays fully usable so it can be switched on */
.ability-off .ability-star,
.ability-off .ability-name,
.ability-off .ability-cost-wrap,
.ability-off .ability-effect,
.ability-off .ability-desc { opacity: .4; }
.lang-off .lang-name,
.lang-off .lang-total-wrap { opacity: .4; }

/* highlight a weapon card when linked to from a character sheet */
.weapon-card { scroll-margin-top: 80px; }
.weapon-card:target > .card {
  border-color: var(--grauc-accent);
  box-shadow: 0 0 0 .2rem rgba(56, 189, 248, 0.20);
}

/* system level bars (0-10): system value vs region average */
.lvl-bar { display: flex; gap: 2px; cursor: help; }
.lvl-cell { flex: 1 1 0; height: 14px; border-radius: 2px; background: rgba(127, 127, 127, .22); }
.lvl-cell.lvl-mid { box-shadow: inset 0 0 0 1px rgba(127, 127, 127, .55); }
.lvl-cell.lvl-region { background: transparent; box-shadow: inset 0 0 0 2px var(--grauc-accent); }
.lvl-cell.lvl-system { background: var(--grauc-accent); }

/* worn armour stands out: green tint + left accent border */
.armour-worn > td {
  background: rgba(47, 164, 90, .12) !important;
  border-top: 1px solid rgba(47, 164, 90, .35);
  border-bottom: 1px solid rgba(47, 164, 90, .35);
}
.armour-worn > td:first-child { border-left: 3px solid #2fa45a; }

/* a core-stat value that links to its editor */
.stat-link { border-bottom: 1px dashed transparent; }
.stat-link:hover { border-bottom-color: currentColor; }

/* character header portrait + info chips */
.char-portrait {
  width: 160px; height: 200px; object-fit: cover;
}
@media (max-width: 575.98px) {
  .char-portrait { width: 110px; height: 140px; }
}
/* class descriptions: clamp to 5 lines, fade out, click to reveal the rest */
.class-desc-wrap { position: relative; }
.class-desc {
  display: -webkit-box; -webkit-box-orient: vertical; -webkit-line-clamp: 5;
  overflow: hidden;
}
.class-desc.expanded { display: block; -webkit-line-clamp: none; overflow: visible; }
.class-desc-fade {
  position: absolute; left: 0; right: 0; bottom: 0; height: 3.75rem; width: 100%;
  border: 0; padding: 0; cursor: pointer; text-align: center;
  display: flex; align-items: flex-end; justify-content: center;
  font-size: .82rem; font-weight: 600; color: var(--grauc-accent);
}
.class-desc-fade span { padding-bottom: .1rem; }
.class-desc-fade:hover { color: var(--grauc-accent); filter: brightness(1.15); }
[data-bs-theme="light"] .class-desc-fade { background: linear-gradient(rgba(255,255,255,0), #ffffff 85%); }
[data-bs-theme="dark"] .class-desc-fade { background: linear-gradient(rgba(32,38,47,0), #20262f 85%); }

/* in-place portrait gallery (prev/next over the portrait) */
.char-gallery-nav {
  position: absolute; top: 50%; transform: translateY(-50%);
  width: 1.7rem; height: 1.7rem; border: 0; border-radius: 50%;
  background: rgba(0, 0, 0, .5); color: #fff; cursor: pointer;
  display: flex; align-items: center; justify-content: center;
  opacity: 0; transition: opacity .15s ease;
}
/* reveal the arrows only on hover (devices that have a hover pointer) */
.char-gallery:hover .char-gallery-nav { opacity: .7; }
.char-gallery-nav:hover { opacity: 1; }
/* touch devices have no hover -> always show them */
@media (hover: none) {
  .char-gallery-nav { opacity: .7; }
}
.char-gallery-nav.prev { left: .3rem; }
.char-gallery-nav.next { right: .3rem; }
.char-gallery-count { position: absolute; bottom: .3rem; right: .3rem; font-size: .7rem; opacity: .9; }
.char-chip {
  display: inline-flex; align-items: center; gap: .4rem;
  padding: .15rem .6rem; border-radius: 999px;
  background: rgba(127, 127, 127, .10);
  border: 1px solid rgba(127, 127, 127, .20);
  white-space: nowrap;
}

/* advancement points frame */
.ap-num { font-size: 1.6rem; font-weight: 700; line-height: 1.1; min-width: 2.2rem; }
.ap-op { font-size: 1.3rem; color: var(--bs-secondary-color); padding-bottom: 1.2rem; }
.ap-unused {
  display: inline-block; padding: .05rem .6rem; border-radius: 999px;
  background: rgba(56, 189, 248, 0.14); color: var(--grauc-accent);
  border: 1px solid rgba(56, 189, 248, 0.40);
}
.ap-unused.ap-over {
  background: rgba(224, 85, 107, 0.16); color: #e0556b; border-color: rgba(224, 85, 107, 0.45);
}

/* language proficiency pips */
.lang-pips i { font-size: .5rem; color: var(--grauc-accent); vertical-align: middle; padding-right:0.1rem; }
.lang-pips i.far { color: rgba(127, 127, 127, .5); }

/* gtable: full-width table with comfortable padding + semi-transparent stripes
   (rows let the card/background show through). Used inside character-sheet cards. */
.gtable { width: 100%; margin-bottom: 0; --bs-table-bg: transparent; --bs-table-striped-bg: rgba(127, 127, 127, .08); }
.gtable > :not(caption) > * > * { padding: .5rem .65rem; }
.gtable > thead > tr > th { border-bottom: 2px solid var(--bs-border-color); }

/* shared semi-transparent stripes + a touch more padding for grauc-table too */
table.grauc-table { --bs-table-bg: transparent; --bs-table-striped-bg: rgba(127, 127, 127, .08); }
table.grauc-table > :not(caption) > * > * { padding: .45rem .6rem; }

/* sortable table headers */
th.th-sort { cursor: pointer; white-space: nowrap; }
th.th-sort a { color: inherit; display: inline-block; }
th.th-sort a:hover { color: var(--grauc-accent); }
th.th-sort .fa-caret-up, th.th-sort .fa-caret-down { color: var(--grauc-accent); }

/* highlighted class row (?id=) */
.class-highlight > td {
  background: rgba(56, 189, 248, 0.16) !important;
  box-shadow: inset 3px 0 0 var(--grauc-accent);
}

/* search highlight */
mark { background: #ffd54a; color: #1a1a1a; padding: 0 .12em; border-radius: 2px; }

/* AP (advancement points) — make it stand out on each session */
.session-ap {
  font-weight: 700;
  color: var(--grauc-accent);
  background: rgba(56, 189, 248, 0.12);
  border: 1px solid rgba(56, 189, 248, 0.40);
  border-radius: 999px;
  padding: .15rem .65rem;
  white-space: nowrap;
  font-size: .95rem;
}
.session-ap .fa-star { margin-right: .15rem; }
.session-ap-total { font-weight: 500; opacity: .75; font-size: .82em; }

/* fmtstring output (session write-ups) */
.session-info { line-height: 1.6; }
.session-info p { margin-bottom: .5rem; }   /* match the editor's paragraph spacing */
.session-info p:last-child { margin-bottom: 0; }
.session-info .hh1 { font-weight: 700; font-size: 1.15rem; margin: .6rem 0 .2rem; }
.session-info .hh2 { font-weight: 700; font-size: 1.05rem; color: var(--grauc-accent); margin: .5rem 0 .2rem; }
.session-info h1, .session-info h2, .session-info h3, .session-info h4 { line-height: 1.2; }
.session-quote {
  border-left: 3px solid var(--grauc-accent);
  padding: .4rem .8rem; margin: .6rem 0;
  background: rgba(56, 189, 248, 0.06); border-radius: 0 6px 6px 0;
}
.session-sign { color: #8b949e; font-style: italic; margin-top: .6rem; }
.session-table { width: auto; }
