/* Rune Forge — the grimoire.
   Parchment page (CSS/SVG layers, no photo), dark-brown ink, burgundy for headings/active states,
   brass for borders and ornaments only (never text), violet ink for Forbidden, grey stone for Jeffrey.
   Selection is always shown by shape/glyph/border weight as well as colour. */

@font-face { font-family: "Fell SC"; src: url("fonts/im-fell-english-sc-latin-400-normal.woff2") format("woff2"); font-display: swap; }
@font-face { font-family: "Fell"; font-style: italic; src: url("fonts/im-fell-english-latin-400-italic.woff2") format("woff2"); font-display: swap; }
@font-face { font-family: "Garamond"; font-weight: 400; src: url("fonts/eb-garamond-latin-400-normal.woff2") format("woff2"); font-display: swap; }
@font-face { font-family: "Garamond"; font-weight: 400; font-style: italic; src: url("fonts/eb-garamond-latin-400-italic.woff2") format("woff2"); font-display: swap; }
@font-face { font-family: "Garamond"; font-weight: 600; src: url("fonts/eb-garamond-latin-600-normal.woff2") format("woff2"); font-display: swap; }
@font-face { font-family: "Garamond"; font-weight: 700; src: url("fonts/eb-garamond-latin-700-normal.woff2") format("woff2"); font-display: swap; }

:root {
  --parch: #eadcbd;
  --parch-light: #f4ead2;
  --parch-deep: #d8c39b;
  --ink: #3b2a1a;
  --ink-2: #5b4430;
  --ink-faint: #8c7659;
  --wine: #7a1f1f;
  --wine-deep: #561313;
  --gold: #a37a2c;
  --gold-hi: #d6b56c;
  --violet: #5a2c7a;
  --moss: #2f5a2a;
  --stone: #5f5c56;
  --stone-dark: #3e3c38;
  --glow: #9fe0d2;
  --display: "Fell SC", "Palatino Linotype", Palatino, "Book Antiqua", Georgia, serif;
  --display-italic: "Fell", "Garamond", Georgia, serif;
  --serif: "Garamond", "Palatino Linotype", Palatino, Georgia, serif;
  --noise: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='260' height='260'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='.9' numOctaves='3' stitchTiles='stitch'/%3E%3CfeColorMatrix values='0 0 0 0 .32 0 0 0 0 .22 0 0 0 0 .1 0 0 0 .16 0'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23n)'/%3E%3C/svg%3E");
  --fibers: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='1600' height='1000'%3E%3Cfilter id='f'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='.005 .09' numOctaves='2' seed='7' stitchTiles='stitch'/%3E%3CfeColorMatrix values='0 0 0 0 .4 0 0 0 0 .28 0 0 0 0 .14 0 0 0 .13 -.035'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23f)'/%3E%3C/svg%3E");
  --mottle: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='1600' height='1000'%3E%3Cfilter id='m'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='.0075' numOctaves='3' seed='3' stitchTiles='stitch'/%3E%3CfeColorMatrix values='0 0 0 0 .45 0 0 0 0 .3 0 0 0 0 .12 0 0 0 .55 -.22'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23m)'/%3E%3C/svg%3E");
  --r: 3px;
  color-scheme: light;
}

/* ---------- page ---------- */
* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0; min-height: 100vh; color: var(--ink);
  font: 17.5px/1.55 var(--serif); font-variant-numeric: lining-nums;
  background-color: var(--parch);
  background-image: var(--noise), var(--fibers), var(--mottle),
    radial-gradient(ellipse at 20% 15%, rgba(255, 248, 225, .55), transparent 55%),
    radial-gradient(ellipse at 85% 80%, rgba(150, 105, 50, .12), transparent 50%);
  background-repeat: repeat, no-repeat, no-repeat, no-repeat, no-repeat;
  background-size: auto, cover, cover, auto, auto;   /* only the fine grain tiles, so no seams */
  background-attachment: fixed;
}
body::before { /* darkened, weathered page edge */
  content: ""; position: fixed; inset: 0; pointer-events: none; z-index: 0;
  background: radial-gradient(ellipse at center, transparent 58%, rgba(95, 60, 25, .22) 88%, rgba(60, 35, 12, .42) 100%);
}
body::after { /* faint rune watermark */
  content: ""; position: fixed; right: -140px; bottom: -160px; width: 620px; height: 620px; z-index: 0;
  pointer-events: none; opacity: .055; background: url("img/rune-circle.svg") center / contain no-repeat;
}
body > * { position: relative; z-index: 1; }

h1, h2, h3, .display { font-family: var(--display); font-weight: 400; color: var(--wine); line-height: 1.15; letter-spacing: .01em; }
h1 { font-size: 2rem; margin: 0 0 .3rem; }
h2 { font-size: 1.45rem; margin: 1.4rem 0 .5rem; }
h3 { font-size: 1.15rem; margin: 1rem 0 .4rem; }
p { margin: .3rem 0 .8rem; }
a { color: var(--wine); text-decoration-color: rgba(122, 31, 31, .4); text-underline-offset: 3px; }
a:hover { text-decoration-color: var(--wine); }
.muted { color: var(--ink-2); }
.small { font-size: .9rem; }
.hint { color: var(--ink-2); font-size: .85rem; font-style: italic; }
em, .flavor { font-family: var(--display-italic); font-style: italic; }
:focus-visible { outline: 2px solid var(--gold); outline-offset: 2px; box-shadow: 0 0 0 4px rgba(214, 181, 108, .35); }
@media (prefers-reduced-motion: reduce) { *, *::before, *::after { transition: none !important; animation: none !important; } }

/* inked divider rule: tapered burgundy line */
.rule { height: 3px; border: 0; margin: .6rem 0; background: linear-gradient(90deg, var(--wine) 0%, var(--wine) 45%, transparent 100%); clip-path: polygon(0 0, 100% 50%, 0 100%); }
.flourish { text-align: center; color: var(--gold); letter-spacing: .6em; margin: .8rem 0; user-select: none; }
.flourish::before { content: "❦ ✦ ❦"; }

/* ---------- controls ---------- */
button, input, select, textarea { font: inherit; color: inherit; }
button, .btn {
  display: inline-flex; align-items: center; justify-content: center; gap: .4rem;
  min-height: 42px; padding: .4rem 1rem; cursor: pointer; font-weight: 600; font-size: 1rem;
  color: var(--ink); background: linear-gradient(#f6ecd4, #e2cfa6); text-decoration: none;
  border: 1px solid #7d5c33; border-radius: var(--r);
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, .6), 0 1px 0 rgba(58, 39, 23, .35);
}
button:hover:not(:disabled), .btn:hover { border-color: var(--wine); box-shadow: inset 0 1px 0 rgba(255, 255, 255, .6), 0 0 0 2px rgba(214, 181, 108, .45); }
button:active:not(:disabled) { transform: translateY(1px); }
button:disabled { cursor: not-allowed; opacity: .5; filter: saturate(.4); }
button.primary { /* wax seal */
  color: #f7e9c4; border-color: #3f0d0d; letter-spacing: .02em;
  background: radial-gradient(circle at 32% 28%, #a3302e, #74191a 55%, #561313 100%);
  box-shadow: inset 0 1px 0 rgba(255, 210, 180, .35), inset 0 -2px 3px rgba(0, 0, 0, .3), 0 2px 0 #3a0b0b;
}
button.primary:hover:not(:disabled) { box-shadow: inset 0 1px 0 rgba(255, 210, 180, .35), 0 0 0 2px var(--gold-hi); }
button.ghost { background: transparent; box-shadow: none; border-color: rgba(125, 92, 51, .55); }
button.danger { background: transparent; box-shadow: none; color: var(--wine); border-color: var(--wine); }
button.link { background: none; border: 0; box-shadow: none; min-height: 0; padding: 0; color: var(--ink-2); font-weight: 400; text-decoration: underline dotted; }
input, select, textarea {
  width: 100%; min-height: 42px; padding: .4rem .6rem; color: var(--ink);
  background: rgba(252, 246, 231, .75); border: 1px solid #8c6a3f; border-radius: 2px;
  box-shadow: inset 0 1px 2px rgba(58, 39, 23, .18);
}
textarea { font-family: ui-monospace, Menlo, Consolas, monospace; font-size: .85rem; line-height: 1.45; }
label { display: block; font-size: .95rem; color: var(--ink-2); font-weight: 600; }
label > input, label > select, label > textarea { margin-top: .25rem; font-weight: 400; }
label.check { display: inline-flex; gap: .5rem; align-items: center; font-weight: 400; color: var(--ink); }
label.check input { width: auto; min-height: 0; accent-color: var(--wine); }
form.inline { display: inline; }
.row { display: flex; gap: .5rem; flex-wrap: wrap; align-items: center; }
.row > input { flex: 1 1 12rem; width: auto; }
.row.spread { justify-content: space-between; }
.form-grid { display: grid; gap: .8rem; grid-template-columns: repeat(auto-fit, minmax(12rem, 1fr)); align-items: end; }
.actions { display: flex; gap: .6rem; flex-wrap: wrap; margin-top: .8rem; align-items: center; }
ul.plain { list-style: none; padding: 0; margin: 0; }
ul.plain li { padding: .55rem 0; border-bottom: 1px solid rgba(125, 92, 51, .3); }
.flash { padding: .5rem .8rem; border-left: 3px solid var(--gold); background: rgba(252, 246, 231, .6); font-style: italic; }
.flash-error, .errors { color: var(--wine); }
.flash-error { border-left-color: var(--wine); }
.errors { list-style: none; padding: 0; margin: .5rem 0; font-style: italic; }
.errors li { padding-left: 1.3rem; position: relative; }
.errors li::before { content: "✠"; position: absolute; left: 0; }
.errors.uncharted { color: var(--violet); }
.num { text-align: right !important; font-variant-numeric: tabular-nums lining-nums; }
.undone { text-decoration: line-through; color: var(--ink-faint); }
.forb, td.forb, span.forb { color: var(--violet); }
.badge { color: var(--wine); font-weight: 700; }

/* panel = inset manuscript section with brass double border */
.panel, .tome-panel {
  background: rgba(250, 243, 225, .62); border: 1px solid rgba(163, 122, 44, .8); border-radius: 2px;
  box-shadow: inset 0 0 0 3px rgba(250, 243, 225, .6), inset 0 0 0 4px rgba(163, 122, 44, .45), 0 2px 8px rgba(58, 39, 23, .12);
  padding: 1.1rem 1.25rem;
}

/* ---------- header: title + bookmark ribbons ---------- */
.topbar { display: flex; justify-content: space-between; align-items: flex-end; gap: 1rem; flex-wrap: wrap;
  padding: .9rem 1.5rem 0; border-bottom: 2px solid rgba(122, 31, 31, .55); }
.brand { text-decoration: none; padding-bottom: .5rem; }
.brand b { display: block; font-family: var(--display); font-weight: 400; color: var(--wine); font-size: 1.75rem; line-height: 1; }
.brand span { font-family: var(--display-italic); font-style: italic; color: var(--ink-2); font-size: .95rem; }
.topbar nav { display: flex; gap: .3rem; align-items: flex-end; flex-wrap: wrap; }
.topbar nav a, .topbar nav button.link {
  font-family: var(--display); font-size: 1.02rem; text-decoration: none; color: #f2e1b8;
  background: linear-gradient(#6e1b1b, #561313); border: 1px solid #3f0d0d; border-bottom: 0;
  padding: .35rem .8rem .45rem; border-radius: 3px 3px 0 0; min-height: 0;
  clip-path: polygon(0 0, 100% 0, 100% 100%, 0 100%);
}
.topbar nav a:hover { color: #fff3d6; }
.topbar nav a[aria-current="page"] { background: var(--parch-light); color: var(--wine); border-color: rgba(122, 31, 31, .55);
  padding-bottom: .6rem; margin-bottom: -2px; }
.topbar nav a[aria-current="page"]::before { content: "✦ "; color: var(--gold); }
.topbar nav form button.link { background: transparent; color: var(--ink-2); border: 0; text-decoration: underline dotted; }

/* ---------- character stat block ---------- */
.charstrip { display: grid; grid-template-columns: minmax(10rem, 1fr) auto minmax(15rem, 19rem); gap: 1.2rem; align-items: center;
  max-width: 1240px; margin: 1rem auto 0; padding: .8rem 1.25rem;
  background: rgba(250, 243, 225, .55); border-top: 3px double var(--gold); border-bottom: 3px double var(--gold); }
.charstrip h1 { margin: 0; font-size: 1.9rem; }
.charstrip .who p { margin: 0; font-family: var(--display-italic); font-style: italic; color: var(--ink-2); }
.stats { display: flex; gap: 1.1rem; margin: 0; flex-wrap: wrap; }
.stats div { text-align: center; min-width: 3.2rem; }
.stats dt { font-size: .78rem; color: var(--wine); font-weight: 700; font-variant-caps: small-caps; letter-spacing: .04em; }
.stats dd { margin: 0; font-size: 1.3rem; font-weight: 600; font-variant-numeric: tabular-nums lining-nums; }
.rp-num { font-family: var(--display); font-size: 2rem; color: var(--wine); line-height: 1; }
.rp-num small { font-family: var(--serif); font-size: .95rem; color: var(--ink-2); margin-left: .3rem; }
.meter { height: 9px; margin: .45rem 0; border: 1px solid #7d5c33; border-radius: 5px; background: rgba(58, 39, 23, .12); overflow: hidden; }
.meter i { display: block; height: 100%; width: 0; transition: width .4s ease;
  background: linear-gradient(#e2c27a, #a37a2c); box-shadow: inset 0 1px 0 rgba(255, 255, 255, .5); }
.rp-actions { display: flex; gap: .4rem; }
.rp-actions button { min-height: 34px; padding: .2rem .7rem; font-size: .9rem; }
.sustained { max-width: 1240px; margin: .4rem auto 0; padding: .35rem 1.25rem; font-style: italic; color: var(--wine); }
.sustained button { min-height: 28px; padding: 0 .5rem; margin-left: .4rem; font-size: .8rem; }

/* ---------- page layout ---------- */
.page { max-width: 1240px; margin: 0 auto; padding: 1rem 1.25rem 4rem; }
.narrow { max-width: 46rem; }
section > h2:first-child { margin-top: .6rem; }

/* ---------- Quick Use bookmarks ---------- */
.quick { margin: .4rem 0 1.4rem; }
.quick-head { display: flex; justify-content: space-between; align-items: baseline; gap: 1rem; }
.quick-head h2 { margin: .3rem 0 .5rem; }
.quick-grid { display: grid; grid-template-columns: repeat(5, minmax(0, 1fr)); gap: .55rem; }
.qslot {
  position: relative; text-align: left; display: grid; justify-content: stretch; justify-items: start; align-items: start; gap: .08rem; align-content: start; min-height: 5.6rem;
  padding: .55rem .7rem 1rem; font-weight: 400; border-radius: 2px;
  background: linear-gradient(#f7eed8, #e8d7b1); border: 1px solid #8c6a3f; border-top: 4px solid var(--wine);
  clip-path: polygon(0 0, 100% 0, 100% 100%, 55% 100%, 50% calc(100% - 7px), 45% 100%, 0 100%);
}
.qslot .n { position: absolute; right: .55rem; top: .35rem; font-family: var(--display); color: var(--gold); font-size: .9rem; }
.qslot .t { font-family: var(--display); color: var(--wine); font-size: 1.08rem; line-height: 1.1; padding-right: 1.3rem; }
.qslot .p { font-size: .75rem; letter-spacing: .08em; color: var(--ink-2); font-variant-caps: small-caps; }
.qslot .m { font-size: .86rem; color: var(--ink); }
.qslot .c { font-weight: 700; font-size: .9rem; color: var(--ink); }
.qslot.empty { min-height: 3rem; background: transparent; border: 1px dashed rgba(125, 92, 51, .6); border-top: 4px solid rgba(125, 92, 51, .35); color: var(--ink-faint); box-shadow: none; }
.qslot.empty .t { color: var(--ink-faint); font-size: .95rem; }
.qslot.armed { border-color: var(--wine); background: linear-gradient(#fbe9d8, #efd0b3); }
.qslot.armed .c { color: var(--wine); }
.qslot.bad { border-top-color: var(--ink-faint); }
.qslot.bad .m { color: var(--wine); font-style: italic; }
.qslot.bad::after { content: "✠ cannot be used now"; position: absolute; left: .7rem; bottom: .15rem; font-size: .72rem; color: var(--wine); font-style: italic; }
.qslot.dragging { opacity: .5; }
.qslot.drop { outline: 2px dashed var(--gold); outline-offset: 2px; }
@media (max-width: 1000px) { .quick-grid { grid-template-columns: repeat(auto-fill, minmax(9.5rem, 1fr)); } }
@media (max-width: 640px) {
  .quick-grid { display: flex; overflow-x: auto; scroll-snap-type: x mandatory; padding-bottom: .4rem; }
  .qslot { flex: 0 0 9.5rem; scroll-snap-align: start; }
  .qslot.empty { flex-basis: 4.5rem; }
}

/* ---------- guided builder: the ritual ---------- */
.forge { display: grid; grid-template-columns: minmax(0, 1.08fr) minmax(0, 1fr); gap: 1.6rem; align-items: start; }
.forge > * { min-width: 0; }
.ritual-steps { display: flex; gap: .2rem; flex-wrap: wrap; align-items: center; justify-content: center; margin: .2rem 0 1rem; padding: .35rem 0;
  list-style: none; border-top: 1px solid rgba(163, 122, 44, .6); border-bottom: 1px solid rgba(163, 122, 44, .6); }
.ritual-steps li { display: flex; align-items: center; }
.ritual-steps li + li::before { content: "⟶"; color: var(--gold); margin: 0 .35rem; }
.ritual-steps button {
  min-height: 34px; padding: .15rem .55rem; background: transparent; border: 1px solid transparent; box-shadow: none;
  font-family: var(--display); font-weight: 400; font-size: 1rem; color: var(--ink-faint);
}
.ritual-steps .numeral { font-size: .85rem; margin-right: .3rem; }
.ritual-steps .done button { color: var(--ink); }
.ritual-steps .done button::after { content: " ✓"; color: var(--moss); font-family: var(--serif); font-weight: 700; }
.ritual-steps .current button { color: var(--wine); border-color: var(--gold); background: rgba(250, 243, 225, .7); }

.chain { list-style: none; margin: 0; padding: 0; }
.link-step { position: relative; padding-left: 2.4rem; }
.link-step::before { /* inked connecting line */
  content: ""; position: absolute; left: .95rem; top: 2.2rem; bottom: -.2rem; border-left: 2px solid rgba(91, 68, 48, .45);
}
.link-step:last-child::before { display: none; }
.link-step .roman { position: absolute; left: 0; top: .35rem; width: 2rem; height: 2rem; display: grid; place-items: center;
  font-family: var(--display); font-size: .92rem; color: var(--ink-faint); border: 1px solid rgba(125, 92, 51, .5);
  border-radius: 50%; background: var(--parch-light); }
.link-step.done .roman { color: var(--parch-light); background: var(--ink-2); border-color: var(--ink-2); }
.link-step.current .roman { color: var(--wine); border: 2px solid var(--wine); box-shadow: 0 0 0 3px rgba(214, 181, 108, .45); }
.link-step.future { opacity: .62; }
.link-step > header { display: flex; align-items: baseline; gap: .7rem; min-height: 2.6rem; flex-wrap: wrap; }
.link-step > header h3 { margin: .45rem 0 .2rem; font-size: 1.2rem; }
.link-step.future > header h3 { color: var(--ink-faint); }
.link-step .chosen { font-family: var(--display); color: var(--ink); font-size: 1.1rem; letter-spacing: .06em;
  border: 1px solid #7d5c33; padding: .05rem .6rem; background: rgba(250, 243, 225, .75); }
.link-step .chosen.forbidden { color: var(--violet); border-style: dashed; }
.link-step .change { min-height: 30px; padding: 0 .55rem; font-size: .85rem; }
.step-body { padding: .3rem 0 1rem; }
.step-note { font-style: italic; color: var(--ink-2); margin: 0 0 .6rem; }
.family { width: 100%; margin: .5rem 0 .15rem; font-family: var(--display); color: var(--wine); font-size: .95rem; }

/* rune plates (choices) */
.plates { display: grid; grid-template-columns: repeat(auto-fill, minmax(10.5rem, 1fr)); gap: .5rem; }
.plates.wide { grid-template-columns: repeat(auto-fill, minmax(13rem, 1fr)); }
.plate {
  position: relative; display: grid; gap: .1rem; align-content: start; justify-content: stretch; justify-items: start; align-items: start; text-align: left;
  min-height: 3.2rem; padding: .5rem .7rem; font-weight: 400;
  background: linear-gradient(#f8f0dc, #eadbb7); border: 1px solid #8c6a3f; border-radius: 2px;
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, .7), 0 1px 0 rgba(58, 39, 23, .25);
}
.plate .nm { font-weight: 700; font-size: 1.05rem; color: var(--ink); letter-spacing: .02em; }
.plate .ds { font-size: .86rem; color: var(--ink-2); font-style: italic; line-height: 1.3; }
.plate .pv { font-size: .84rem; color: var(--ink); line-height: 1.3; }
.plate .tag { font-size: .78rem; font-style: italic; color: var(--violet); }
.plate[aria-pressed="true"] { /* engraved/inked selection: double wine border + seal glyph */
  background: linear-gradient(#fbf3e2, #efdfbd); border: 2px solid var(--wine);
  box-shadow: inset 0 0 0 2px rgba(214, 181, 108, .8), 0 2px 4px rgba(58, 39, 23, .25);
}
.plate[aria-pressed="true"]::after { content: "✦"; position: absolute; top: .25rem; right: .45rem; color: var(--wine); font-size: .95rem; }
.plate.forbidden .nm { color: var(--violet); }
.plate.forbidden { border-style: dashed; }
.plate.uncharted { border-style: dashed; background: linear-gradient(#f3ecdf, #e5dccb); }
.plate.unavailable { cursor: not-allowed; opacity: 1; filter: none; background: transparent; border-style: dotted; box-shadow: none; }
.plate.unavailable .nm, .plate.unavailable .pv { color: var(--ink-faint); }
.plate.unavailable .ds { color: var(--ink-2); }
.plate.none-plate .nm { font-weight: 600; font-style: italic; }
.plates.compact { grid-template-columns: repeat(auto-fill, minmax(11rem, 1fr)); gap: .35rem; margin-top: .5rem; }
.plates.compact .plate { min-height: 0; padding: .35rem .6rem; }
.plates.compact .plate .nm { font-size: .98rem; font-weight: 600; }
details.added { margin-top: .7rem; }
details.added > summary { cursor: pointer; font-family: var(--display); color: var(--wine); font-size: 1.05rem; }
.empower .hint { display: block; }
.empower { display: grid; grid-template-columns: repeat(auto-fit, minmax(12rem, 1fr)); gap: .8rem; }
.stepper { display: flex; align-items: center; gap: .4rem; margin-top: .3rem; }
.stepper button { width: 42px; padding: 0; font-size: 1.2rem; }
.stepper output { min-width: 2.2ch; text-align: center; font-size: 1.25rem; font-weight: 700; color: var(--ink); }
.locked-note { font-style: italic; color: var(--ink-2); font-size: .88rem; }

/* ---------- generated ability card (original stat-block styling) ---------- */
.result { position: sticky; top: 1rem; }
.statblock {
  position: relative; padding: 1.1rem 1.35rem 1rem;
  background: linear-gradient(rgba(253, 248, 235, .9), rgba(246, 236, 212, .9)), var(--noise);
  border: 1px solid #8c6a3f; border-top: 5px solid var(--wine); border-bottom: 5px solid var(--wine);
  box-shadow: 0 3px 12px rgba(58, 39, 23, .25);
}
.statblock h2.title { margin: 0; font-size: 1.95rem; color: var(--wine); padding-right: 4.8rem; }
.statblock .subtitle { margin: 0 0 .1rem; font-family: var(--display-italic); font-style: italic; color: var(--ink-2); }
.statblock .seal-cost {
  position: absolute; top: .9rem; right: 1.1rem; width: 4.2rem; height: 4.2rem; border-radius: 50%;
  display: grid; place-content: center; text-align: center; color: #f7e9c4; line-height: 1;
  background: radial-gradient(circle at 32% 28%, #a3302e, #74191a 55%, #561313 100%);
  box-shadow: inset 0 -2px 4px rgba(0, 0, 0, .35), 0 2px 0 #3a0b0b, 0 0 0 3px rgba(214, 181, 108, .7);
}
.statblock .seal-cost b { font-family: var(--display); font-size: 1.7rem; font-weight: 400; }
.statblock .seal-cost small { font-size: .7rem; letter-spacing: .08em; }
.statblock .seal-cost.over { background: radial-gradient(circle at 32% 28%, #7d7466, #4b463f); }
.statblock dl.mech { display: grid; grid-template-columns: max-content 1fr; gap: .12rem .9rem; margin: .3rem 0; }
.statblock dl.mech dt { font-weight: 700; color: var(--wine); }
.statblock dl.mech dd { margin: 0; }
.statblock .rules { margin: .2rem 0 .4rem; line-height: 1.6; }
.statblock .rules b { font-style: italic; }
.statblock .inscription-line { text-align: center; font-family: var(--display); letter-spacing: .22em; color: var(--ink-2);
  font-size: .95rem; margin: .7rem 0 0; padding-top: .5rem; border-top: 1px solid rgba(163, 122, 44, .7); }
.statblock .inscription-line .plus { color: var(--gold); margin: 0 .4em; letter-spacing: 0; }
.statblock .inscription-line .forb { color: var(--violet); }
.statblock .purse { display: flex; justify-content: space-between; flex-wrap: wrap; gap: .3rem 1rem; font-size: .95rem;
  margin-top: .6rem; padding: .4rem .6rem; background: rgba(58, 39, 23, .06); border: 1px solid rgba(125, 92, 51, .35); }
.statblock .purse .short { color: var(--wine); font-weight: 700; }
.statblock.empty { text-align: center; padding: 2.2rem 1.4rem; }
.statblock.empty .glyph { width: 110px; height: 110px; margin: 0 auto .8rem; opacity: .35; background: url("img/rune-circle.svg") center / contain no-repeat; }
.statblock.uncharted { border-top-color: var(--violet); border-bottom-color: var(--violet); background: linear-gradient(rgba(246, 240, 232, .92), rgba(236, 226, 214, .92)); }
.statblock.uncharted h2.title { color: var(--violet); }
.statblock details { margin-top: .5rem; }
.statblock details summary { cursor: pointer; color: var(--ink-2); font-style: italic; }
.statblock #res-breakdown { width: 100%; font-size: .92rem; border-collapse: collapse; }
.statblock #res-breakdown td { padding: .1rem 0; border-bottom: 1px dotted rgba(125, 92, 51, .4); }
.statblock #res-breakdown td:last-child { text-align: right; font-weight: 700; }
.inscribing { display: inline-flex; align-items: center; gap: .4rem; font-style: italic; color: var(--ink-2); font-size: .9rem; min-height: 1.4rem; }
.inscribing::before { content: "✺"; display: inline-block; color: var(--gold); animation: turn 1.6s linear infinite; }
.inscribing[hidden] { display: none; }
@keyframes turn { to { transform: rotate(360deg); } }
.stamp { position: absolute; left: 50%; top: 42%; transform: translate(-50%, -50%) rotate(-12deg) scale(1.6); opacity: 0;
  font-family: var(--display); font-size: 2rem; color: var(--wine); border: 3px double var(--wine); padding: .2rem 1rem; pointer-events: none; }
.stamp.go { animation: stamp 1.3s ease-out; }
@keyframes stamp { 0% { opacity: 0; transform: translate(-50%, -50%) rotate(-12deg) scale(1.6); }
  18% { opacity: .9; transform: translate(-50%, -50%) rotate(-12deg) scale(1); } 75% { opacity: .75; } 100% { opacity: 0; } }
.foundry textarea { margin-top: .4rem; }
@media (max-width: 900px) {
  .forge { grid-template-columns: minmax(0, 1fr); }
  .result { position: static; order: 2; }
  .charstrip { grid-template-columns: 1fr; gap: .6rem; }
  .stats { display: grid; grid-template-columns: repeat(6, auto); gap: .4rem; justify-content: space-between; }
  .stats dd { font-size: 1.1rem; }
  .ritual-steps { flex-wrap: nowrap; overflow-x: auto; justify-content: flex-start; }
  .ritual-steps li + li::before { margin: 0 .15rem; }
}
@media (max-width: 480px) {
  body { font-size: 16.5px; }
  .page { padding: .8rem .8rem 3rem; }
  .charstrip { padding: .7rem .8rem; }
  .topbar { padding: .6rem .8rem 0; }
  .topbar nav a { font-size: .92rem; padding: .3rem .5rem .4rem; }
  .plates { grid-template-columns: repeat(auto-fill, minmax(8.7rem, 1fr)); }
  .link-step { padding-left: 2.1rem; }
  .statblock h2.title { font-size: 1.6rem; }
}

/* ---------- library / lists / tables ---------- */
.slot-list { padding-left: 1.6rem; }
.slot-list li { padding: .5rem 0; border-bottom: 1px solid rgba(125, 92, 51, .3); }
.slot-list li::marker { font-family: var(--display); color: var(--wine); }
.library { display: grid; gap: .7rem; grid-template-columns: repeat(auto-fill, minmax(19rem, 1fr)); }
.lib-item { background: rgba(250, 243, 225, .7); border: 1px solid #8c6a3f; border-top: 4px solid var(--wine); padding: .75rem 1rem; }
.lib-item h3 { margin: 0; }
.lib-item .c { font-weight: 700; }
.table-wrap { overflow-x: auto; }
table.grid td button { min-height: 32px; padding: .1rem .7rem; font-size: .92rem; }
table.grid { border-collapse: collapse; width: 100%; font-size: .96rem; background: rgba(250, 243, 225, .5); }
table.grid th, table.grid td { text-align: left; padding: .45rem .6rem; border-bottom: 1px solid rgba(125, 92, 51, .35); vertical-align: top; }
table.grid th { font-family: var(--display); font-weight: 400; color: var(--wine); border-bottom: 2px solid var(--wine); }
table.grid tbody tr:nth-child(even) { background: rgba(163, 122, 44, .06); }
.token-box { font-family: ui-monospace, Menlo, Consolas, monospace; padding: .8rem; border: 2px dashed var(--wine); background: rgba(252, 246, 231, .8); word-break: break-all; white-space: pre-wrap; }

/* ---------- Jeffrey: carved stone ---------- */
.stone-panel {
  position: relative; color: #efe9dd; padding: 1.2rem 1.4rem; margin-bottom: 1.2rem; border-radius: 4px;
  background-color: #57544e;
  background-image:
    url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 1000 300' preserveAspectRatio='none'%3E%3Cpath d='M0 40 L60 62 L96 58 L150 96 L170 140 M1000 30 L930 70 L900 66 L860 120 M720 300 L700 250 L735 210 L720 170 M420 0 L436 40 L410 70' fill='none' stroke='%23000' stroke-opacity='.3' stroke-width='1.6'/%3E%3Cpath d='M61 63 L70 90 M900 66 L905 100 M700 250 L660 262' fill='none' stroke='%23000' stroke-opacity='.2' stroke-width='1'/%3E%3C/svg%3E"),
    var(--noise), linear-gradient(160deg, #77736b, #57544e 55%, #494741);
  background-repeat: no-repeat, repeat, no-repeat;
  background-size: 100% 100%, auto, 100% 100%;
  border: 1px solid #2c2a27;
  box-shadow: inset 0 2px 0 rgba(255, 255, 255, .12), inset 0 -3px 8px rgba(0, 0, 0, .4), inset 0 0 0 6px rgba(0, 0, 0, .08), 0 4px 10px rgba(30, 20, 10, .35);
}
.stone-panel h2, .stone-panel h3 { color: #f1e6c8; text-shadow: 0 1px 0 rgba(0, 0, 0, .6); }
.stone-panel .muted, .stone-panel .small { color: #d7d0c2; }
.stone-panel .heart-runes { font-family: var(--display); font-size: clamp(1.6rem, 4vw, 2.5rem); letter-spacing: .14em; margin: .3rem 0 .5rem;
  color: #dff7f1; text-shadow: 0 0 10px rgba(159, 224, 210, .75), 0 0 22px rgba(159, 224, 210, .35), 0 1px 0 #000; }
.stone-panel .heart-runes.hidden { color: #bdb6a8; text-shadow: 0 1px 0 #000, 0 -1px 0 rgba(255, 255, 255, .15); letter-spacing: .1em; }
.stone-panel .desc { font-family: var(--serif); color: #f3ede1; max-width: 70ch; }
.sockets { list-style: none; padding: 0; margin: .5rem 0; display: grid; gap: .6rem; grid-template-columns: repeat(auto-fill, minmax(15rem, 1fr)); }
.sockets li { padding: .7rem .9rem; border-radius: 3px; background: rgba(0, 0, 0, .22);
  box-shadow: inset 0 3px 6px rgba(0, 0, 0, .55), inset 0 -1px 0 rgba(255, 255, 255, .12); }
.sockets li b { font-family: var(--display); font-weight: 400; letter-spacing: .1em; color: #dff7f1; text-shadow: 0 0 8px rgba(159, 224, 210, .6); }
.sockets li.empty-socket { color: #b9b2a5; font-style: italic; }
.sockets li .small { color: #e4ddd0; }
.stone-panel select, .stone-panel input { background: #eee6d4; }
.stone-panel label { color: #efe6d3; }

/* ---------- dialogs, toast ---------- */
dialog { color: var(--ink); width: min(36rem, 94vw); padding: 1.3rem 1.4rem; border: 1px solid #7d5c33; border-top: 5px solid var(--wine);
  background: linear-gradient(rgba(252, 246, 231, .97), rgba(243, 232, 207, .97)), var(--noise); box-shadow: 0 10px 40px rgba(30, 18, 8, .5); }
dialog::backdrop { background: rgba(40, 25, 10, .55); }
dialog form { display: grid; gap: .8rem; }
dialog h2 { margin: 0; }
#toast { position: fixed; left: 50%; bottom: 1.2rem; transform: translateX(-50%); z-index: 50; max-width: 92vw;
  display: none; gap: .8rem; align-items: center; padding: .6rem 1rem; color: var(--ink);
  background: linear-gradient(#fbf3df, #efdfbc); border: 1px solid #7d5c33; border-left: 5px solid var(--moss); box-shadow: 0 4px 14px rgba(30, 18, 8, .35); }
#toast.show { display: flex; }
#toast.error { border-left-color: var(--wine); color: var(--wine); }
#toast button { min-height: 32px; padding: .1rem .7rem; }

/* ---------- login: the tome's cover ---------- */
.login-page { min-height: 100vh; display: grid; place-items: center; padding: 1rem; }
.login { width: min(26rem, 100%); display: grid; gap: .9rem; padding: 2rem 1.8rem;
  background: linear-gradient(rgba(252, 246, 231, .92), rgba(243, 232, 207, .92));
  border: 1px solid #7d5c33; box-shadow: inset 0 0 0 4px rgba(250, 243, 225, .9), inset 0 0 0 5px rgba(163, 122, 44, .8), 0 12px 40px rgba(40, 25, 10, .35); }
.login h1 { text-align: center; font-size: 2.6rem; margin: 0; }
.login .muted { text-align: center; font-family: var(--display-italic); font-style: italic; }

/* ---------- GM: the arcane ledger ---------- */
.gm-head { display: flex; justify-content: space-between; align-items: end; gap: 1rem; flex-wrap: wrap; }
.gm-head h1 { margin: 0; }
.gm-head label { min-width: 15rem; }
.tabs { display: flex; gap: .2rem; flex-wrap: wrap; margin: 1rem 0 0; border-bottom: 2px solid var(--wine); }
.tabs button { /* index tabs */
  min-height: 36px; padding: .2rem .8rem; border-radius: 4px 4px 0 0; border: 1px solid #7d5c33; border-bottom: 0;
  font-family: var(--display); font-weight: 400; font-size: 1rem; color: var(--ink-2);
  background: linear-gradient(#efe3c7, #dcc79d); box-shadow: none; }
.tabs button[aria-selected="true"] { color: var(--wine); background: var(--parch-light); border-color: var(--wine); margin-bottom: -2px; padding-bottom: .4rem; }
.tabs button[aria-selected="true"]::before { content: "✦ "; color: var(--gold); }
.gm-panel { padding: 1rem 1.2rem; background: rgba(250, 243, 225, .6); border: 1px solid rgba(122, 31, 31, .45); border-top: 0; }
.gm-panel .toolbar { display: flex; gap: .5rem; flex-wrap: wrap; align-items: center; margin-bottom: .8rem; }
.gm-panel .toolbar input { max-width: 18rem; }
.unlock-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(12rem, 1fr)); gap: .35rem; }
.unlock { display: flex; justify-content: space-between; align-items: center; gap: .5rem; padding: .25rem .5rem;
  background: rgba(252, 246, 231, .7); border: 1px solid rgba(125, 92, 51, .4); border-left-width: 4px; }
.unlock select { width: auto; min-height: 32px; padding: .05rem .3rem; font-size: .9rem; }
.unlock.known { border-left-color: var(--moss); }
.unlock.known > span::before { content: "✓ "; color: var(--moss); font-weight: 700; }
.unlock.locked { border-left-color: var(--ink-faint); }
.unlock.locked > span::before { content: "? "; color: var(--ink-faint); }
.chips { display: flex; flex-wrap: wrap; gap: .4rem; }
.chip { padding: .3rem .6rem; background: rgba(252, 246, 231, .75); border: 1px solid #8c6a3f; border-radius: 2px; font-weight: 400; }
.kv { display: grid; grid-template-columns: repeat(auto-fit, minmax(13rem, 1fr)); gap: .8rem; }
.json { min-height: 6rem; }
.setting { border-bottom: 1px solid rgba(125, 92, 51, .35); padding: .5rem 0; }
.setting summary { cursor: pointer; }
.setting summary strong { font-family: var(--display); font-weight: 400; color: var(--wine); font-size: 1.05rem; }
pre.small { white-space: pre-wrap; font-size: .8rem; color: var(--ink-2); margin: 0; max-height: 12rem; overflow: auto; }
.slot-list li .row { justify-content: space-between; }
.slot-list li .row .row { justify-content: flex-end; gap: .3rem; }
.slot-list li button, .lib-item button, .lib-item select { min-height: 32px; padding: .1rem .6rem; font-size: .9rem; }
.lib-item select { width: auto; }
.delivery { margin: .1rem 0 .7rem; }
.delivery .family { margin-top: 0; }

/* ---------- the written First Language ---------- */
.glyph-mini { position: absolute; left: .45rem; top: .5rem; width: 1.5rem; height: 2.25rem; }
.glyph-mini path, .glyph-chip path, .rune-script path, .lex-glyph path {
  fill: none; stroke: currentColor; stroke-width: 2.6; stroke-linecap: round; stroke-linejoin: round; }
.plate.has-glyph { padding-left: 2.35rem; }
.plate .glyph-mini { color: var(--ink-2); }
.plate[aria-pressed="true"] .glyph-mini { color: var(--wine); }
.plate.forbidden .glyph-mini { color: var(--violet); }
.glyph-chip { width: .9rem; height: 1.35rem; vertical-align: -0.3rem; margin-right: .3rem; color: var(--wine); }
.statblock .script { display: flex; justify-content: center; margin: .8rem 0 0; color: var(--ink); }
.statblock .script svg { height: 68px; max-width: 100%; }
.statblock .script.writing .rune-script > g path {
  stroke-dasharray: 1; stroke-dashoffset: 1; animation: write .7s ease-in-out forwards; animation-delay: calc(var(--i) * .45s); }
@keyframes write { to { stroke-dashoffset: 0; } }
@media (prefers-reduced-motion: reduce) { .statblock .script.writing .rune-script > g path { stroke-dashoffset: 0; animation: none; } }
.statblock .inscription-line { margin-top: .2rem; border-top: 0; padding-top: 0; font-size: .82rem; }
.qslot .tierb { position: absolute; right: .55rem; bottom: .55rem; font-size: .72rem; font-weight: 700; color: var(--wine);
  border: 1px solid rgba(122, 31, 31, .5); border-radius: 2px; padding: 0 .25rem; background: rgba(250, 243, 225, .7); }
.stone-panel .heart-glyphs { color: #dff7f1; filter: drop-shadow(0 0 6px rgba(159, 224, 210, .8)); margin: .2rem 0 .4rem; }
.stone-panel .heart-glyphs svg { height: 96px; max-width: 100%; }
.stone-panel .heart-glyphs .rune-script > path:first-child { display: none; }
/* Lexicon */
.lexicon { display: grid; grid-template-columns: repeat(auto-fill, minmax(15rem, 1fr)); gap: .7rem; }
.lex-entry { display: grid; grid-template-columns: 4rem 1fr; gap: .2rem .8rem; align-items: start; padding: .7rem .8rem;
  background: rgba(250, 243, 225, .65); border: 1px solid rgba(125, 92, 51, .55); border-top: 3px solid var(--wine); }
.lex-entry.forbidden { border-top-color: var(--violet); }
.lex-glyph { grid-row: span 3; width: 4rem; height: 6rem; color: var(--ink); }
.lex-entry.forbidden .lex-glyph { color: var(--violet); }
.lex-entry h3 { margin: 0; }
.lex-entry .meaning { font-style: italic; color: var(--ink-2); margin: 0; }
.lex-entry .facts { font-size: .88rem; margin: 0; }
.lex-tools { display: flex; gap: .6rem; align-items: center; flex-wrap: wrap; margin-bottom: .8rem; }
@media print {
  .topbar, .charstrip, .sustained, .lex-tools, #toast { display: none !important; }
  body { background: #fff !important; } body::before, body::after { display: none; }
  .lex-entry { break-inside: avoid; background: #fff; }
}
.lex-entry > :not(.lex-glyph) { grid-column: 2; }
.lex-entry .lex-glyph { grid-column: 1; grid-row: 1 / span 4; }

/* ---------- character sheet (v0.8) ---------- */
.sheet { display: grid; gap: 1rem; }
.sheet-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(21rem, 1fr)); gap: 1rem; }
.sheet h1 { margin: 0; }
.sheet .wide-mech { display: grid; grid-template-columns: max-content 1fr; gap: .15rem .9rem; margin: .6rem 0 0; }
.sheet .wide-mech dt { font-weight: 700; color: var(--wine); }
.sheet .wide-mech dd { margin: 0; }
.ability-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(5.5rem, 1fr)); gap: .5rem; margin-bottom: .6rem; }
.ability-grid input { text-align: center; font-weight: 700; }
details.feature { border-bottom: 1px solid rgba(125, 92, 51, .3); padding: .35rem 0; }
details.feature summary { cursor: pointer; }
details.feature.inactive summary b { color: var(--ink-faint); }
details.feature.inactive { opacity: .85; }
.use-options { margin-top: .6rem; }
.use-options summary { cursor: pointer; font-style: italic; color: var(--ink-2); }
fieldset { border: 1px solid rgba(125, 92, 51, .5); padding: .5rem .7rem; display: grid; gap: .5rem; }
legend { font-family: var(--display); color: var(--wine); }
.rbadge { font-size: .78rem; padding: 0 .35rem; border: 1px solid; border-radius: 2px; white-space: nowrap; }
.rbadge.established { color: var(--ink-2); }
.rbadge.approved { color: var(--moss); font-weight: 700; }
.rbadge.proposed { color: var(--violet); }
.rbadge.rejected { color: var(--ink-faint); text-decoration: line-through; }
.rbadge.confirm { color: var(--wine); }
