:root {
  --bg: #0f1115;
  --bg-2: #151821;
  --panel: #1a1e29;
  --panel-2: #212637;
  --line: #2b3144;
  --text: #e9e6df;
  --text-dim: #a8acb8;
  --text-faint: #767c8c;
  --gold: #f1c40f;
  --gold-soft: #f6dd7a;
  --blue: #4aa3ff;
  --blue-bg: rgba(74, 163, 255, 0.10);
  --red: #ff6b5e;
  --green: #4ade80;
  --amber: #fbbf24;
  --story-font: "Literata", Georgia, "Times New Roman", serif;
  --ui-font: "Inter", system-ui, -apple-system, "Segoe UI", sans-serif;
  --story-size: 19px;
  --story-line: 1.75;
  --story-width: 760px;
  --ui-zoom: 1;
  --radius: 12px;
  /* surfaces & accents that change with the theme */
  --glow: #1b2030;
  --hover-line: #3c4560;
  --hover-bg: #283047;
  --card-bg: rgba(26, 30, 41, .92);
  --bar-bg: rgba(15, 17, 21, .75);
  --pane-bg: rgba(21, 24, 33, .6);
  --track: #2a2f3f;
  --strong: #fff3c4;
  --em: #d9d4c7;
  --say-base: #f2efe8;
  --cond-text: #ffb2aa;
  --hp-text: #ffd0cb;
  --shadow: rgba(0, 0, 0, .5);
}

/* ---------- themes ---------- */
:root[data-theme="dim"] {
  --bg: #1d2128; --bg-2: #22272f; --panel: #292f39; --panel-2: #313845; --line: #3d4452;
  --text: #ebe8e1; --text-dim: #b6bac4; --text-faint: #8a909e;
  --glow: #2a303b; --hover-line: #4c5567; --hover-bg: #38404f;
  --card-bg: rgba(41, 47, 57, .95); --bar-bg: rgba(29, 33, 40, .85); --pane-bg: rgba(34, 39, 47, .7); --track: #3a4150;
}
:root[data-theme="parchment"] {
  --bg: #ece2cc; --bg-2: #e6d9bd; --panel: #f6efdf; --panel-2: #ebe0c6; --line: #d3c29f;
  --text: #2b2216; --text-dim: #5a4b36; --text-faint: #86765c;
  --gold: #9a6a00; --gold-soft: #7c5300; --blue: #1c5cb8; --blue-bg: rgba(28, 92, 184, .08);
  --red: #b0372b; --green: #2e7d46; --amber: #a26c06;
  --glow: #f7f0df; --hover-line: #bfa97f; --hover-bg: #e3d5b6;
  --card-bg: rgba(246, 239, 223, .96); --bar-bg: rgba(236, 226, 204, .9); --pane-bg: rgba(230, 217, 189, .55);
  --track: #d8c9a8; --strong: #1c140a; --em: #4a3c28; --say-base: #2b2216;
  --cond-text: #8f2a20; --hp-text: #8f2a20; --shadow: rgba(80, 60, 20, .25);
}
:root[data-theme="light"] {
  --bg: #f3f4f7; --bg-2: #eceef2; --panel: #ffffff; --panel-2: #f1f3f7; --line: #d9dde5;
  --text: #1b2130; --text-dim: #485063; --text-faint: #7a8294;
  --gold: #9a6a00; --gold-soft: #7c5300; --blue: #1d6ad0; --blue-bg: rgba(29, 106, 208, .07);
  --red: #c0392b; --green: #23874a; --amber: #a26c06;
  --glow: #ffffff; --hover-line: #b9c0cc; --hover-bg: #e7eaf0;
  --card-bg: rgba(255, 255, 255, .97); --bar-bg: rgba(243, 244, 247, .92); --pane-bg: rgba(236, 238, 242, .7);
  --track: #dfe3ea; --strong: #0f1420; --em: #3a4253; --say-base: #1b2130;
  --cond-text: #a3291d; --hp-text: #a3291d; --shadow: rgba(20, 30, 50, .18);
}
/* Bright character/NPC colors are tuned for dark backgrounds; deepen them on light themes. */
:root[data-theme="parchment"] .pc-name, :root[data-theme="light"] .pc-name,
:root[data-theme="parchment"] .pc-name-inline, :root[data-theme="light"] .pc-name-inline,
:root[data-theme="parchment"] .player .who, :root[data-theme="light"] .player .who,
:root[data-theme="parchment"] .roll .what b, :root[data-theme="light"] .roll .what b { filter: brightness(.62) saturate(1.3); }
:root[data-theme="parchment"] .say-block, :root[data-theme="light"] .say-block { --npc-ink: color-mix(in srgb, var(--npc) 55%, #000); }

/* ---------- personal display options ---------- */
:root.plain-dialogue .say-block { --npc: var(--text-faint) !important; }
:root.hide-mech .mech { display: none; }
:root.reduce-motion *, :root.reduce-motion *::before, :root.reduce-motion *::after { animation: none !important; transition: none !important; }
.topbar, .party, .info, .composer { zoom: var(--ui-zoom); }

* { box-sizing: border-box; }
html, body { height: 100%; }
body {
  margin: 0;
  background: radial-gradient(1200px 800px at 50% -10%, var(--glow) 0%, var(--bg) 60%) fixed;
  color: var(--text);
  font: 15px/1.5 var(--ui-font);
  -webkit-font-smoothing: antialiased;
}
button, input, select, textarea { font: inherit; color: inherit; }
[hidden] { display: none !important; }

/* ---------- buttons & inputs ---------- */
.btn {
  border: 1px solid var(--line); background: var(--panel-2); color: var(--text);
  padding: 9px 14px; border-radius: 10px; cursor: pointer; font-weight: 600;
  transition: background .15s, border-color .15s, transform .05s;
}
.btn:hover { border-color: var(--hover-line); background: var(--hover-bg); }
.btn:active { transform: translateY(1px); }
.btn:disabled { opacity: .4; cursor: default; pointer-events: none; }
.btn.primary { background: linear-gradient(180deg, #e7bf2e, #c99a12); color: #1b1505; border-color: #e7bf2e; }
.btn.primary:hover { background: linear-gradient(180deg, #f3cd3f, #d6a716); }
.btn.ghost { background: transparent; }
.icon-btn {
  background: transparent; border: 1px solid transparent; color: var(--text-dim);
  width: 36px; height: 36px; border-radius: 9px; cursor: pointer; font-size: 18px;
}
.icon-btn:hover { background: var(--panel-2); color: var(--text); }
input, select, textarea {
  width: 100%; background: var(--bg-2); border: 1px solid var(--line); border-radius: 10px;
  padding: 10px 12px; outline: none;
}
input:focus, select:focus, textarea:focus { border-color: var(--gold); box-shadow: 0 0 0 3px rgba(241,196,15,.15); }
label { display: grid; gap: 6px; font-weight: 600; font-size: 13px; color: var(--text-dim); }
.opt { font-weight: 400; color: var(--text-faint); }
.stack { display: grid; gap: 14px; }
.form-error { color: var(--red); min-height: 1em; margin: 0; font-size: 14px; }
.form-note { color: var(--green); margin: 0; font-size: 14px; }
.chip {
  display: inline-flex; align-items: center; gap: 6px; padding: 3px 10px; border-radius: 999px;
  background: var(--panel-2); border: 1px solid var(--line); font-size: 12.5px; color: var(--text-dim);
  white-space: nowrap;
}

/* ---------- lobby ---------- */
.lobby { min-height: 100%; display: grid; place-items: center; padding: 24px 16px; }
.lobby-card {
  width: min(460px, 100%); background: var(--card-bg); border: 1px solid var(--line);
  border-radius: 18px; padding: 32px 28px; box-shadow: 0 30px 80px var(--shadow);
}
.crest { font-size: 40px; text-align: center; }
.lobby h1 { font: 700 34px/1.1 var(--story-font); text-align: center; margin: 6px 0 4px; color: var(--gold-soft); }
.lede { text-align: center; color: var(--text-dim); margin: 0 0 24px; }
.host { margin-top: 22px; border-top: 1px solid var(--line); padding-top: 16px; }
.host summary { cursor: pointer; color: var(--text-dim); font-weight: 600; }
.host h2 { font-size: 14px; text-transform: uppercase; letter-spacing: .08em; color: var(--text-faint); margin: 20px 0 10px; }
.host .stack { margin-top: 14px; }
.campaign-list { list-style: none; padding: 0; margin: 0; display: grid; gap: 8px; }
.campaign-list li {
  display: flex; justify-content: space-between; align-items: center; gap: 10px;
  background: var(--bg-2); border: 1px solid var(--line); border-radius: 10px; padding: 8px 10px;
}
.campaign-list code { color: var(--gold-soft); font-size: 15px; letter-spacing: .08em; }

/* ---------- table layout ---------- */
.table {
  height: 100vh; display: grid;
  grid-template-columns: 290px minmax(0, 1fr) 330px;
  grid-template-rows: auto minmax(0, 1fr);
  grid-template-areas: "top top top" "party story info";
}
.topbar {
  grid-area: top; display: flex; align-items: center; gap: 14px; padding: 10px 18px;
  border-bottom: 1px solid var(--line); background: var(--bar-bg); backdrop-filter: blur(8px);
}
.title-block { min-width: 0; flex: 1; }
.title-block h1 { margin: 0; font: 700 20px/1.2 var(--story-font); color: var(--gold-soft); }
.scene { color: var(--text-dim); font-size: 13px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.top-right { display: flex; align-items: center; gap: 10px; }
.presence { display: flex; }
.avatar {
  width: 30px; height: 30px; border-radius: 50%; display: grid; place-items: center; font-weight: 700; font-size: 12px;
  color: #10131a; border: 2px solid var(--bg); margin-left: -6px;
}
.menu { position: relative; }
.menu-pop {
  position: absolute; right: 0; top: 42px; z-index: 20; background: var(--panel); border: 1px solid var(--line);
  border-radius: 12px; padding: 6px; min-width: 250px; box-shadow: 0 16px 40px var(--shadow);
}
.menu-pop button {
  display: block; width: 100%; text-align: left; background: none; border: 0; padding: 10px 12px;
  border-radius: 8px; cursor: pointer;
}
.menu-pop button:hover { background: var(--panel-2); }
.only-narrow { display: none; }

/* ---------- party ---------- */
.party, .info { overflow-y: auto; padding: 16px; background: var(--pane-bg); }
.party { grid-area: party; border-right: 1px solid var(--line); }
.info { grid-area: info; border-left: 1px solid var(--line); padding-top: 10px; }
.pane-title { font-size: 12px; text-transform: uppercase; letter-spacing: .12em; color: var(--text-faint); margin: 2px 0 12px; }
.pc {
  background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); padding: 12px 12px 10px;
  margin-bottom: 10px; cursor: pointer; transition: border-color .15s, transform .15s; position: relative;
}
.pc:hover { border-color: var(--hover-line); }
.pc.me { box-shadow: inset 3px 0 0 var(--pc-color); }
.pc.down { opacity: .75; }
.pc-head { display: flex; align-items: baseline; justify-content: space-between; gap: 8px; }
.pc-name { font: 700 16px/1.2 var(--story-font); color: var(--pc-color); }
.pc-ac { font-size: 12px; color: var(--text-dim); display: inline-flex; gap: 4px; align-items: center; }
.pc-sub { color: var(--text-faint); font-size: 12.5px; margin: 2px 0 8px; }
.hp { height: 8px; background: var(--track); border-radius: 99px; overflow: hidden; position: relative; }
.hp > i { display: block; height: 100%; border-radius: 99px; transition: width .6s cubic-bezier(.2,.8,.2,1), background .6s; }
.hp > b { position: absolute; top: 0; right: 0; height: 100%; background: #9ec5ff; opacity: .7; border-radius: 99px; }
.hp-row { display: flex; justify-content: space-between; font-size: 12.5px; color: var(--text-dim); margin-top: 5px; }
.hp-row strong { color: var(--text); font-variant-numeric: tabular-nums; }
.pc.hit { animation: hit .6s; }
@keyframes hit { 20% { transform: translateX(-3px); border-color: var(--red); } 40% { transform: translateX(3px); } 60% { transform: translateX(-2px); } }
.conds { display: flex; flex-wrap: wrap; gap: 5px; margin-top: 7px; }
.cond { font-size: 11.5px; padding: 1px 8px; border-radius: 99px; background: rgba(255,107,94,.12); color: var(--cond-text); border: 1px solid rgba(255,107,94,.3); }
.insp { color: var(--gold); font-size: 12px; }
.initiative { background: var(--panel); border: 1px solid rgba(255,107,94,.35); border-radius: var(--radius); padding: 10px 12px; margin-top: 6px; }
.initiative h3 { margin: 0 0 6px; font-size: 12px; text-transform: uppercase; letter-spacing: .1em; color: var(--cond-text); }
.initiative ol { margin: 0; padding-left: 20px; color: var(--text-dim); }
.claim { margin-top: 14px; background: var(--blue-bg); border: 1px solid rgba(74,163,255,.35); border-radius: var(--radius); padding: 12px; font-size: 14px; }
.claim p { margin: 0 0 8px; }
.claim .btn { margin: 0 6px 6px 0; padding: 6px 10px; }

/* ---------- story ---------- */
.story { grid-area: story; display: flex; flex-direction: column; min-height: 0; }
.feed { flex: 1; overflow-y: auto; padding: 28px 24px 12px; scroll-behavior: smooth; }
.feed > * { max-width: var(--story-width); margin-left: auto; margin-right: auto; }
.entry { margin-bottom: 22px; animation: rise .35s ease-out; }
@keyframes rise { from { opacity: 0; transform: translateY(6px); } to { opacity: 1; transform: none; } }

.dm { font: var(--story-size)/var(--story-line) var(--story-font); color: var(--text); }
.dm .loc { font: 600 11.5px/1 var(--ui-font); letter-spacing: .14em; text-transform: uppercase; color: var(--gold); margin-bottom: 12px; opacity: .9; }
.dm p { margin: 0 0 .9em; }
.dm strong { color: var(--strong); font-weight: 600; }
.dm em { color: var(--em); }
.dm ul { margin: 0 0 .9em; padding-left: 1.2em; }
.dm li { margin: .2em 0; }
.dm code, .mech code { font: 13px var(--ui-font); background: var(--panel-2); padding: 1px 6px; border-radius: 6px; color: var(--text-dim); }
.say-block {
  margin: 0 0 1em; padding: 12px 16px 12px 18px; border-radius: 10px;
  background: linear-gradient(90deg, color-mix(in srgb, var(--npc) 14%, transparent), transparent 85%);
  border-left: 4px solid var(--npc);
}
.say-block .who { font: 700 12px/1 var(--ui-font); letter-spacing: .12em; text-transform: uppercase; color: var(--npc-ink, var(--npc)); margin-bottom: 6px; }
.say-block p { margin: 0 0 .4em; color: color-mix(in srgb, var(--npc) 25%, var(--say-base)); }
.say-block p:last-child { margin-bottom: 0; }
.your-move {
  margin-top: 6px; padding: 16px 18px; border-radius: 12px; background: var(--blue-bg);
  border: 1px solid rgba(74,163,255,.35); box-shadow: 0 0 0 1px rgba(74,163,255,.05), 0 10px 30px rgba(74,163,255,.07);
}
.your-move .label { font: 700 12px/1 var(--ui-font); letter-spacing: .14em; text-transform: uppercase; color: var(--blue); margin-bottom: 8px; }
.your-move p { margin: 0 0 .4em; }
.your-move p:last-child { margin: 0; }
.your-move.for-me { border-color: var(--blue); animation: pulse 2.2s ease-out 2; }
@keyframes pulse { 0% { box-shadow: 0 0 0 0 rgba(74,163,255,.45); } 100% { box-shadow: 0 0 0 14px rgba(74,163,255,0); } }
.mech { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 10px; font: 12.5px/1.4 var(--ui-font); }
.mech .chip.nat20 { color: #1b1505; background: var(--gold); border-color: var(--gold); }
.mech .chip.nat1 { color: #fff; background: #a3322a; border-color: #a3322a; }
.mech .chip.hpchip { color: var(--hp-text); border-color: rgba(255,107,94,.35); }

.player { display: flex; gap: 10px; align-items: flex-start; font-size: 15.5px; }
.player .avatar { margin: 0; flex: none; border: 0; }
.player { font-size: calc(var(--story-size) * .82); }
.player .bubble { background: var(--panel); border: 1px solid var(--line); border-radius: 4px 14px 14px 14px; padding: 8px 12px; max-width: 100%; }
.player .who { font-weight: 700; font-size: 13px; color: var(--pc-color); }
.player .who span { color: var(--text-faint); font-weight: 500; }
.player .text { white-space: pre-wrap; overflow-wrap: anywhere; }
.ooc { font-size: 13.5px; color: var(--text-faint); padding-left: 40px; }
.ooc b { color: var(--text-dim); }
.system, .notice { text-align: center; color: var(--text-faint); font-size: 13px; }
.notice { color: var(--amber); }
.chapter { border: 1px solid var(--line); border-radius: var(--radius); padding: 18px 20px; background: var(--panel); font: 16px/1.7 var(--story-font); }
.chapter h3 { font: 700 12px/1 var(--ui-font); letter-spacing: .14em; text-transform: uppercase; color: var(--gold); margin: 0 0 10px; }

/* dice */
.roll { display: flex; align-items: center; gap: 12px; padding-left: 40px; }
.die {
  width: 54px; height: 54px; flex: none; display: grid; place-items: center; position: relative;
  font: 800 19px var(--ui-font); color: #10131a;
}
.die svg { position: absolute; inset: 0; width: 100%; height: 100%; }
.die span { position: relative; font-variant-numeric: tabular-nums; }
.die.rolling svg { animation: spin .8s cubic-bezier(.3,.7,.3,1); }
@keyframes spin { from { transform: rotate(-540deg) scale(.6); } to { transform: rotate(0) scale(1); } }
.die.nat20 { filter: drop-shadow(0 0 10px rgba(241,196,15,.9)); }
.die.nat1 { filter: drop-shadow(0 0 8px rgba(255,80,60,.8)); }
.roll .what { font-size: 14px; color: var(--text-dim); }
.roll .what b { color: var(--text); }
.roll .flair { font-weight: 800; margin-left: 6px; }
.roll .flair.good { color: var(--gold); }
.roll .flair.bad { color: var(--red); }

.writing { text-align: center; color: var(--text-dim); font: italic 15px var(--story-font); padding: 4px 0 10px; }
.writing .dots i { animation: blink 1.4s infinite both; font-style: normal; }
.writing .dots i:nth-child(2) { animation-delay: .2s; } .writing .dots i:nth-child(3) { animation-delay: .4s; }
@keyframes blink { 0%, 80%, 100% { opacity: .2; } 40% { opacity: 1; } }
.quill { display: inline-block; animation: scribble 1.2s ease-in-out infinite; }
@keyframes scribble { 50% { transform: rotate(-12deg) translateX(-2px); } }

/* composer */
.composer { border-top: 1px solid var(--line); padding: 10px 18px 16px; background: var(--bar-bg); }
.composer > * { max-width: 800px; margin-left: auto; margin-right: auto; }
.round { display: flex; flex-wrap: wrap; align-items: center; gap: 6px 10px; min-height: 26px; margin-bottom: 8px; font-size: 13.5px; color: var(--text-dim); }
.round:empty { display: none; }
.round .turn-banner { font-weight: 700; color: var(--cond-text); background: rgba(255,107,94,.1); border: 1px solid rgba(255,107,94,.35); padding: 3px 10px; border-radius: 999px; }
.round .turn-banner.mine { color: #fff; background: var(--red); border-color: var(--red); animation: pulse-red 2s ease-out 2; }
@keyframes pulse-red { 0% { box-shadow: 0 0 0 0 rgba(255,107,94,.5); } 100% { box-shadow: 0 0 0 12px rgba(255,107,94,0); } }
.round .who-chip { display: inline-flex; align-items: center; gap: 5px; padding: 3px 10px; border-radius: 999px; border: 1px solid var(--line); background: var(--panel); font-weight: 600; }
.round .who-chip.done { border-color: rgba(74,222,128,.45); color: var(--green); }
.round .who-chip.passed { color: var(--text-faint); }
.round .who-chip.typing { border-color: rgba(74,163,255,.45); color: var(--blue); }
.round .who-chip.waiting { color: var(--text); }
.round .who-chip.me { box-shadow: 0 0 0 2px rgba(241,196,15,.35); }
.round .clock { margin-left: auto; font-variant-numeric: tabular-nums; color: var(--text-faint); }
.round .hint { color: var(--text-faint); }
.composer-row { display: flex; align-items: center; gap: 8px; margin-bottom: 8px; flex-wrap: wrap; }
.mode-switch { display: inline-flex; background: var(--bg-2); border: 1px solid var(--line); border-radius: 10px; padding: 3px; margin-right: auto; }
.mode { background: none; border: 0; padding: 6px 12px; border-radius: 8px; cursor: pointer; color: var(--text-dim); font-weight: 600; font-size: 13.5px; }
.mode.active { background: var(--panel-2); color: var(--text); }
.say { display: flex; gap: 8px; align-items: stretch; }
.say textarea { resize: none; font-size: 16px; line-height: 1.5; min-height: 52px; max-height: 200px; }
.say.ooc-mode textarea { border-style: dashed; }
.send { white-space: nowrap; }
.dice-tray { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); padding: 10px; margin-bottom: 8px; display: grid; gap: 8px; }
.dice-row { display: flex; gap: 6px; flex-wrap: wrap; }
.dice-row .btn { padding: 6px 10px; font-size: 13px; }
#dice-expr { width: 110px; } #dice-reason { flex: 1; min-width: 140px; } #dice-mode { width: 150px; }

/* info tabs */
.tabs { display: flex; gap: 4px; margin-bottom: 12px; border-bottom: 1px solid var(--line); }
.tab { background: none; border: 0; padding: 9px 10px; cursor: pointer; color: var(--text-faint); font-weight: 600; border-bottom: 2px solid transparent; }
.tab.active { color: var(--text); border-bottom-color: var(--gold); }
.tab-body h3 { font: 700 18px var(--story-font); margin: 4px 0 2px; color: var(--gold-soft); }
.tab-body .muted { color: var(--text-faint); font-size: 13.5px; }
.abilities { display: grid; grid-template-columns: repeat(3, 1fr); gap: 6px; margin: 12px 0; }
.ability { background: var(--panel); border: 1px solid var(--line); border-radius: 10px; text-align: center; padding: 6px 4px; }
.ability small { display: block; font-size: 10.5px; letter-spacing: .1em; color: var(--text-faint); }
.ability b { font-size: 18px; }
.ability span { display: block; font-size: 12px; color: var(--text-dim); }
.sheet-section { margin: 14px 0; }
.sheet-section h4 { font-size: 11.5px; text-transform: uppercase; letter-spacing: .12em; color: var(--text-faint); margin: 0 0 6px; }
.sheet-section ul { margin: 0; padding-left: 18px; color: var(--text-dim); font-size: 14px; }
.stat-line { display: flex; gap: 8px; flex-wrap: wrap; margin-top: 8px; }
.card-list { display: grid; gap: 8px; }
.card { background: var(--panel); border: 1px solid var(--line); border-radius: 10px; padding: 10px 12px; font-size: 14px; }
.card b { display: block; margin-bottom: 2px; }
.card .meta { color: var(--text-faint); font-size: 12.5px; }
.q-active { border-left: 3px solid var(--amber); } .q-completed { border-left: 3px solid var(--green); opacity: .8; }
.q-failed, .q-abandoned { border-left: 3px solid var(--text-faint); opacity: .6; }

/* modal & toast */
.modal { background: var(--panel); color: var(--text); border: 1px solid var(--line); border-radius: 16px; width: min(640px, 92vw); max-height: 85vh; padding: 22px 24px; }
.modal::backdrop { background: rgba(0,0,0,.6); }
.modal .close { position: absolute; right: 12px; top: 12px; }
.modal h2 { font: 700 22px var(--story-font); color: var(--gold-soft); margin: 0 0 12px; }
.modal .chapter-text { font: 16.5px/1.75 var(--story-font); }
.toast { position: fixed; left: 50%; bottom: 24px; transform: translateX(-50%); background: var(--panel-2); border: 1px solid var(--line); padding: 10px 16px; border-radius: 10px; z-index: 50; box-shadow: 0 10px 30px rgba(0,0,0,.5); }

/* ---------- settings ---------- */
.settings { display: grid; gap: 18px; }
.settings h2 { margin-bottom: 0; }
.set-group { display: grid; gap: 8px; }
.set-group > .set-label { font-weight: 700; font-size: 13px; color: var(--text-dim); display: flex; justify-content: space-between; }
.set-group > .set-label output { color: var(--text-faint); font-weight: 500; }
.set-group input[type="range"] { padding: 0; accent-color: var(--gold); background: none; border: 0; }
.seg { display: flex; flex-wrap: wrap; gap: 6px; }
.seg button { background: var(--bg-2); border: 1px solid var(--line); border-radius: 9px; padding: 7px 12px; cursor: pointer; color: var(--text-dim); font-weight: 600; font-size: 13.5px; }
.seg button[aria-pressed="true"] { border-color: var(--gold); color: var(--text); background: var(--panel-2); box-shadow: 0 0 0 2px rgba(241,196,15,.18); }
.seg .swatch { display: inline-block; width: 12px; height: 12px; border-radius: 50%; margin-right: 6px; vertical-align: -1px; border: 1px solid var(--line); }
.toggle { display: flex; align-items: center; justify-content: space-between; gap: 12px; font-weight: 600; font-size: 14px; color: var(--text); cursor: pointer; }
.toggle small { display: block; color: var(--text-faint); font-weight: 400; font-size: 12.5px; }
.toggle input { width: 42px; height: 24px; appearance: none; background: var(--track); border-radius: 99px; position: relative; cursor: pointer; border: 0; padding: 0; flex: none; transition: background .15s; }
.toggle input::after { content: ""; position: absolute; top: 3px; left: 3px; width: 18px; height: 18px; border-radius: 50%; background: #fff; transition: left .15s; }
.toggle input:checked { background: var(--gold); }
.toggle input:checked::after { left: 21px; }
.preview { border: 1px dashed var(--line); border-radius: 12px; padding: 14px 16px; background: var(--bg-2); }
.preview .dm { margin: 0; }
.set-actions { display: flex; justify-content: space-between; gap: 8px; }

/* ---------- responsive ---------- */
@media (max-width: 1180px) {
  .table { grid-template-columns: 260px minmax(0, 1fr); grid-template-areas: "top top" "party story"; }
  .info { position: fixed; right: 0; top: 57px; bottom: 0; width: min(360px, 92vw); z-index: 30; background: var(--bg-2); transform: translateX(100%); transition: transform .25s; box-shadow: -20px 0 50px rgba(0,0,0,.5); }
  .info.open { transform: none; }
  #toggle-info { display: inline-block; }
}
@media (max-width: 820px) {
  :root { --story-size: 17.5px; }
  .table { grid-template-columns: minmax(0, 1fr); grid-template-areas: "top" "story"; }
  .party { position: fixed; left: 0; top: 57px; bottom: 0; width: min(320px, 88vw); z-index: 30; background: var(--bg-2); transform: translateX(-100%); transition: transform .25s; box-shadow: 20px 0 50px rgba(0,0,0,.5); }
  .party.open { transform: none; }
  #toggle-party { display: inline-block; }
  .feed { padding: 18px 14px 8px; }
  .composer { padding: 8px 10px 12px; }
  #room-chip, .presence { display: none; }
  .roll, .ooc { padding-left: 0; }
}
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation: none !important; transition: none !important; }
}
