/* The character details drawer. It slides over the chat from the right
   (frontend2/js/views/sidebar.js toggles .drawer-open; .show only means "a
   character is active", see js/stage.js). */

.sidebar {
  position: fixed; top: var(--header-h); right: 0; bottom: 0; z-index: 25; width: min(var(--drawer-w), 94vw);
  display: none; flex-direction: column; gap: var(--sp-4); overflow-y: auto; padding: var(--sp-5);
  background: var(--panel); border-left: 1px solid var(--border); box-shadow: -24px 0 48px rgba(0, 0, 0, .35);
  transform: translateX(104%); transition: transform .26s ease; visibility: hidden;
  scrollbar-width: thin; scrollbar-color: var(--border) transparent;
}
.sidebar.show { display: flex; }
.sidebar.drawer-open { transform: none; visibility: visible; }

.drawer-scrim { position: fixed; inset: var(--header-h) 0 0 0; z-index: 24; background: rgb(var(--veil) / .45); display: none; }
.drawer-scrim.show { display: block; }

.drawer-head { display: flex; align-items: center; justify-content: space-between; gap: 8px; }
.sb-name { font-size: 26px; line-height: 1.1; letter-spacing: -.015em; }
.sb-genre { color: var(--muted); margin-top: -8px; }

.sb-portrait {
  position: relative; flex: none; width: 100%; aspect-ratio: 1 / 1; border-radius: var(--radius-lg);
  overflow: hidden; background: var(--panel2); border: 1px solid var(--border);
}
.sb-portrait img { width: 100%; height: 100%; object-fit: cover; display: block; }
.sb-portrait .initial {
  position: absolute; top: 50%; left: 50%; transform: translate(-50%, -50%);
  font-family: var(--font-display); font-size: 72px; color: var(--faint); user-select: none;
}
.sb-actions { flex: none; }
.sb-actions button { flex: 1; }

/* Drawer sections: a heading, then the controls. */
.sb-block { display: flex; flex-direction: column; gap: var(--sp-3); border-top: 1px solid var(--border); padding-top: var(--sp-4); }
.sb-block > h3 { font-family: var(--font-ui); font-size: 14px; font-weight: 600; }

.sb-collapsible { flex: none; border-top: 1px solid var(--border); padding-top: var(--sp-4); }
.sb-collapsible summary {
  cursor: pointer; font-size: 14px; font-weight: 600; list-style: none; display: flex; align-items: center; gap: 8px;
}
.sb-collapsible summary::-webkit-details-marker { display: none; }
.sb-collapsible summary::after { content: "+"; margin-left: auto; color: var(--muted); font-weight: 400; font-size: 18px; line-height: 1; }
.sb-collapsible[open] summary::after { content: "–"; }
.sb-collapsible[open] summary { margin-bottom: var(--sp-3); }
.sb-collapsible-body { display: flex; flex-direction: column; gap: var(--sp-3); }
.sb-section { display: flex; flex-direction: column; gap: var(--sp-2); border-top: 1px solid var(--border); padding-top: var(--sp-4); }

/* --- Memories (mounted from views/memories.js) --- */
ul.mem { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 6px; }
ul.mem li { background: var(--panel2); border: 1px solid var(--border); border-radius: 10px; padding: 9px 12px; font-size: 14px; }
.x { float: right; cursor: pointer; color: var(--faint); margin-left: 8px; }
.x:hover { color: var(--dislike); }
.mem-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 8px; }
.mem-head button { padding: 4px 10px; font-size: 13px; }
.mem-head h3 { font-family: var(--font-ui); font-size: 14px; font-weight: 600; line-height: 1.4; }

/* --- Discord bot (mounted from views/character-bot.js) --- */
.bot-status { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }

/* --- Personality sliders (mounted from views/personality.js) --- */
.tr-group { border-top: 1px solid var(--border); padding: var(--sp-3) 0 var(--sp-1); }
.tr-group:first-of-type { border-top: 0; padding-top: 0; }
.tr-group summary { cursor: pointer; list-style: none; display: flex; align-items: center; gap: 8px; font-size: 14px; font-weight: 600; }
.tr-group summary::-webkit-details-marker { display: none; }
.tr-group summary::after { content: "+"; margin-left: auto; color: var(--muted); font-weight: 400; font-size: 16px; line-height: 1; }
/* The outer .sb-collapsible[open] rules reach nested summaries too; these out-rank them. */
.sb-collapsible .tr-group summary { margin-bottom: 0; }
.sb-collapsible[open] .tr-group summary::after { content: "+"; }
.sb-collapsible[open] .tr-group[open] summary::after { content: "–"; }
.sb-collapsible[open] .tr-group[open] summary { margin-bottom: var(--sp-2); }
.tr-count { font-size: 12px; font-weight: 400; color: var(--accent-text); }
.tr-row { display: flex; flex-direction: column; gap: 2px; margin-bottom: var(--sp-3); }
.tr-head { display: flex; justify-content: space-between; gap: 8px; font-size: 14px; }
.tr-val { color: var(--muted); font-size: 13px; text-align: right; }
.tr-row.set .tr-val { color: var(--accent-text); }
.tr-row input[type=range] { width: 100%; padding: 0; accent-color: var(--accent); }
.tr-ends { display: flex; justify-content: space-between; gap: 8px; font-size: 12px; color: var(--faint); }

/* --- Game: stats + dice (mounted from views/game.js) --- */
.game-block { display: flex; flex-direction: column; gap: var(--sp-2); }
.game-block + .game-block { border-top: 1px solid var(--border); padding-top: var(--sp-3); }
.game-stat { display: flex; flex-direction: column; gap: 2px; margin-bottom: var(--sp-2); }
.game-stat-head { display: flex; justify-content: space-between; font-size: 14px; }
.game-stat-val { font-variant-numeric: tabular-nums; color: var(--muted); }
.game-stat.low .game-stat-val { color: var(--dislike); }
.game-stat.high .game-stat-val { color: var(--accent2); }
.game-stat input[type=range] { width: 100%; padding: 0; accent-color: var(--accent); }
.game-toggle { display: flex; gap: 8px; align-items: flex-start; font-size: 14px; color: var(--text); }
#fateSheet { flex-direction: column; gap: var(--sp-2); }
.game-approaches { display: grid; grid-template-columns: repeat(3, 1fr); gap: 6px; }
.game-approaches label { display: flex; flex-direction: column; gap: 2px; }
.game-approaches input { width: 100%; }
#fateAspects { width: 100%; resize: vertical; }

/* --- Scene picker (mounted from views/scenes.js) --- */
.scene-list { display: flex; flex-direction: column; gap: 6px; }
.scene-group { font-family: var(--font-ui); font-size: 12.5px; font-weight: 600; color: var(--muted); margin: var(--sp-2) 0 0; }
.scene-item { display: flex; flex-direction: column; gap: 6px; }
/* Buttons: own colours and a hover rule, or the global solid-accent hover turns the text ~1:1. */
.scene-list .scene-card {
  display: flex; flex-direction: column; gap: 2px; width: 100%; text-align: left;
  padding: 9px 12px; border-radius: 12px; background: var(--panel2); color: var(--text);
  border: 1px solid var(--border); font-weight: 400;
}
.scene-list .scene-card:hover:not(:disabled) { background: var(--panel2); color: var(--text); border-color: color-mix(in srgb, var(--accent) 55%, var(--border)); }
.scene-item.on .scene-card { border-color: var(--accent); background: color-mix(in srgb, var(--accent) 12%, var(--panel2)); }
.scene-name { font-weight: 600; font-size: 14px; }
.scene-item.on .scene-name::before { content: ""; display: inline-block; width: 8px; height: 8px; border-radius: 50%; background: var(--accent); margin-right: 7px; }
.scene-desc { font-size: 12.5px; color: var(--muted); line-height: 1.35; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
.scene-item.on .scene-desc { -webkit-line-clamp: unset; display: block; }
.scene-chips { display: flex; flex-direction: column; align-items: flex-start; gap: 6px; padding: 0 2px 4px; }
.scene-more { margin-top: var(--sp-1); }
.scene-more summary { cursor: pointer; font-size: 13px; color: var(--muted); padding: 4px 2px; list-style: none; }
.scene-more summary::-webkit-details-marker { display: none; }
.scene-more summary::after { content: " +"; }
.scene-more[open] summary::after { content: " –"; }
.scene-more[open] summary { margin-bottom: 6px; }
.scene-more[open] { display: flex; flex-direction: column; gap: 6px; }
.scene-chip {
  text-align: left; font-size: 13px; font-weight: 400; line-height: 1.35;
  padding: 6px 11px; border-radius: 14px; background: transparent; color: var(--accent-text);
  border: 1px solid color-mix(in srgb, var(--accent) 40%, var(--border));
}
.scene-chip:hover:not(:disabled) { background: color-mix(in srgb, var(--accent) 14%, var(--panel)); color: var(--text); border-color: var(--accent); }
