* {
  box-sizing: border-box;
}

body {
  margin: 0;
  color: var(--ink);
  background: var(--bg-gradient);
  font-family: var(--sans);
}

::selection {
  background: var(--accent);
  color: var(--selection-color);
}

::placeholder {
  color: var(--ink-placeholder);
  font-weight: 400;
}

/* Custom scrollbars */
::-webkit-scrollbar {
  width: 6px;
  height: 6px;
}

::-webkit-scrollbar-track {
  background: transparent;
}

::-webkit-scrollbar-thumb {
  background: var(--scrollbar-thumb);
  border-radius: 3px;
}

::-webkit-scrollbar-thumb:hover {
  background: var(--scrollbar-thumb-hover);
}

/* Firefox thin scrollbar */
* {
  scrollbar-width: thin;
  scrollbar-color: var(--scrollbar-thumb) transparent;
}

/* ---- Topbar ---- */

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  padding: 0.85rem 1.5rem;
  border-bottom: 1px solid var(--line);
  background: var(--panel);
  box-shadow: 0 1px 3px rgba(31, 40, 37, 0.05);
  position: relative;
  z-index: 1002;
}

.topbar h1 {
  margin: 0;
  font-size: 1.15rem;
  letter-spacing: -0.01em;
  color: var(--accent);
}

.topbar-controls {
  display: flex;
  align-items: center;
  gap: 1rem;
}

.debug-toggle {
  display: flex;
  align-items: center;
  gap: 0.4rem;
  font-size: 0.82rem;
  cursor: pointer;
}

.debug-toggle input {
  width: auto;
  margin: 0;
}

.gear-btn {
  background: none;
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  padding: 0.35rem 0.6rem;
  font-size: 1.15rem;
  cursor: pointer;
  line-height: 1;
  color: var(--ink);
  transition: background var(--transition), border-color var(--transition);
}

.gear-btn:hover {
  background: var(--accent-soft);
  border-color: var(--accent-border-hover);
}

.topbar-controls .gear-btn {
  text-align: center;
}

/* ---- Two-column layout ---- */

.layout {
  display: grid;
  grid-template-columns: 280px 1fr;
  gap: 1.1rem;
  padding: 1.1rem;
  height: calc(100vh - 58px);
}

.dtm-linked-shell {
  display: contents;
}

.panel {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: var(--radius-lg);
  padding: 1.1rem;
  min-height: 200px;
  box-shadow: var(--shadow-sm);
}

/* ---- Sidebar ---- */

.sidebar {
  overflow-y: auto;
  max-height: calc(100vh - 80px);
}

.sidebar h2 {
  border-top: 1px solid var(--line);
  padding-top: 0.9rem;
  margin-top: 0.7rem;
}

.sidebar h2:first-child {
  border-top: none;
  padding-top: 0;
  margin-top: 0;
}

h2 {
  margin: 0 0 0.7rem;
  font-size: 0.88rem;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  color: var(--ink-heading);
}

.stack {
  display: grid;
  gap: 0.65rem;
  margin-bottom: 1.1rem;
}

.stack.compact {
  gap: 0.5rem;
}

label {
  display: grid;
  gap: 0.35rem;
  font-size: 0.84rem;
  font-weight: 500;
  color: var(--ink-heading);
}

input,
textarea,
button,
select,
pre {
  font-family: var(--sans);
}

input,
textarea,
select {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  padding: 0.55rem 0.65rem;
  background: var(--surface-white);
  color: var(--ink);
  font-size: 0.88rem;
  transition: border-color var(--transition), box-shadow var(--transition);
}

input:focus,
textarea:focus,
select:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: var(--shadow-focus);
}

textarea {
  resize: vertical;
}

input[type="checkbox"] {
  width: auto;
  margin: 0;
}

/* Range slider custom styling */
input[type="range"] {
  -webkit-appearance: none;
  appearance: none;
  padding: 0;
  height: 6px;
  background: var(--line);
  border: none;
  border-radius: 3px;
  cursor: pointer;
}

input[type="range"]:focus {
  box-shadow: none;
}

input[type="range"]::-webkit-slider-thumb {
  -webkit-appearance: none;
  width: 18px;
  height: 18px;
  border-radius: 50%;
  background: var(--accent);
  cursor: pointer;
  box-shadow: var(--slider-thumb-shadow);
  transition: transform var(--transition);
}

input[type="range"]::-webkit-slider-thumb:hover {
  transform: scale(1.15);
}

input[type="range"]::-moz-range-thumb {
  width: 18px;
  height: 18px;
  border-radius: 50%;
  background: var(--accent);
  cursor: pointer;
  border: none;
  box-shadow: var(--slider-thumb-shadow);
}

button {
  border: 1px solid var(--accent-border);
  border-radius: var(--radius-sm);
  padding: 0.5rem 0.75rem;
  background: var(--accent-soft);
  color: var(--accent-text);
  cursor: pointer;
  text-align: left;
  font-weight: 500;
  font-size: 0.84rem;
  transition: background var(--transition), border-color var(--transition), box-shadow var(--transition), transform var(--transition);
}

button:hover {
  background: var(--button-hover-bg);
  border-color: var(--accent-border-hover);
}

button:active {
  box-shadow: inset 0 1px 3px rgba(0, 0, 0, 0.1);
  transform: translateY(0.5px);
}

button:disabled {
  opacity: 0.5;
  cursor: not-allowed;
  transform: none;
}

.campaign-button {
  display: grid;
  width: 100%;
  min-width: 0;
  padding: 0.55rem 0.75rem;
  transition: background var(--transition), border-color var(--transition), transform var(--transition), box-shadow var(--transition);
}

.window-list {
  width: 100%;
  min-width: 0;
}

.campaign-button-label {
  display: block;
  min-width: 0;
  width: 100%;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.campaign-button:hover:not(.active):not(:disabled) {
  background: var(--surface-accent-light);
  border-color: var(--accent-muted);
  transform: translateY(-1px);
  box-shadow: var(--shadow-sm);
}

.campaign-button small {
  color: var(--ink-secondary);
  font-size: 0.75rem;
}

.campaign-button.active,
.tab-row button.active {
  background: var(--accent);
  color: var(--active-text);
  border-color: var(--active-border);
  box-shadow: var(--shadow-sm);
}

.campaign-button.has-unseen:not(.active) {
  animation: pulse-unseen 2.5s ease-in-out infinite;
  border-color: var(--warning-accent);
}

@keyframes pulse-unseen {
  0%, 100% { box-shadow: 0 0 0 2px rgba(201, 148, 42, 0.15); }
  50% { box-shadow: 0 0 8px 3px rgba(201, 148, 42, 0.35); }
}

/* ---- Status dots ---- */

.status-dots {
  display: grid;
  gap: 0.45rem;
  margin-bottom: 1rem;
}

.status-dot-row {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  font-size: 0.84rem;
}

.status-dot-row small {
  color: var(--ink-secondary);
  font-size: 0.74rem;
}

.dot {
  width: 9px;
  height: 9px;
  border-radius: 50%;
  flex-shrink: 0;
}

.dot-ok {
  background: var(--success);
  box-shadow: 0 0 0 2px rgba(58, 138, 92, 0.18);
  animation: pulse-ok 2.5s ease-in-out infinite;
}

@keyframes pulse-ok {
  0%, 100% { box-shadow: 0 0 0 2px rgba(58, 138, 92, 0.18); }
  50% { box-shadow: 0 0 0 5px rgba(58, 138, 92, 0.08); }
}

.dot-err {
  background: var(--error);
  box-shadow: 0 0 0 2px rgba(146, 47, 37, 0.18);
}

.dot-warn {
  background: var(--warning);
  box-shadow: 0 0 0 2px rgba(184, 154, 62, 0.18);
}

/* GPU Stats Widget */
.gpu-stats-widget {
  margin-top: 0.6rem;
  padding: 0.5rem 0.6rem;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  font-size: 0.78rem;
}
.gpu-stats-header {
  display: flex; align-items: center; gap: 0.4rem;
  margin-bottom: 0.4rem; font-size: 0.84rem;
}
.gpu-stats-header small {
  color: var(--ink-secondary); font-size: 0.7rem; margin-left: auto;
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap; max-width: 120px;
}
.gpu-stats-bars { display: grid; gap: 0.3rem; }
.gpu-stat-row {
  display: grid; grid-template-columns: 32px minmax(0, 1fr) auto;
  align-items: center; gap: 0.35rem;
}
.gpu-stat-label { font-size: 0.72rem; color: var(--ink-secondary); white-space: nowrap; }
.gpu-stat-value { font-size: 0.72rem; text-align: right; font-family: var(--mono); white-space: nowrap; }
.gpu-bar-track {
  height: 6px; background: var(--accent-soft);
  border-radius: 3px; overflow: hidden; min-width: 0;
}
.gpu-bar-fill {
  height: 100%; background: var(--accent);
  border-radius: 3px; transition: width 0.5s ease;
}
.gpu-bar-hot { background: var(--error); }
.gpu-model-list {
  margin-top: 0.35rem; display: flex; flex-wrap: wrap; gap: 0.25rem;
}
.gpu-model-tag {
  background: var(--accent-soft); color: var(--accent);
  padding: 0.1rem 0.35rem; border-radius: 4px; font-size: 0.68rem;
}
.gpu-missing-tool {
  padding: 0.3rem 0;
}
.gpu-missing-tool small {
  display: block;
  font-size: 0.72rem;
  color: var(--warning-brown);
  line-height: 1.4;
}
.gpu-missing-hint {
  color: var(--ink-muted) !important;
  margin-top: 0.15rem;
}
.gpu-missing-hint code {
  background: var(--accent-soft);
  padding: 0.05rem 0.3rem;
  border-radius: 3px;
  font-size: 0.7rem;
}

.sidebar-hint {
  margin: 0;
  font-size: 0.78rem;
  color: var(--ink-faint);
  font-style: italic;
}

.runtime-detail {
  margin-top: 0.6rem;
}

.runtime-detail p {
  margin: 0;
  font-size: 0.78rem;
  line-height: 1.4;
}

.runtime-detail code {
  display: block;
  margin-top: 0.2rem;
  font-family: var(--mono);
  font-size: 0.74rem;
  word-break: break-all;
}

.runtime-actions {
  display: grid;
  gap: 0.4rem;
}

/* ---- Private window row ---- */

.private-window-row {
  display: flex;
  gap: 0.4rem;
  align-items: end;
}

.private-kind-select {
  width: auto;
  font-size: 0.78rem;
  padding: 0.45rem 0.4rem;
}

.private-target-input {
  flex: 1;
  min-width: 0;
  font-size: 0.82rem;
}

/* Game time widget in sidebar */
.game-time-widget {
  display: flex;
  align-items: baseline;
  gap: 0.5rem;
  padding: 0.5rem 0;
  border-top: 1px solid var(--line);
  margin-top: 0.5rem;
}
.game-time-label {
  font-weight: 500;
  font-size: 0.85rem;
  color: var(--ink);
}
.game-time-clock {
  font-family: var(--mono);
  font-size: 0.78rem;
  opacity: 0.6;
}

/* ---- Chapters Panel (sidebar) ---- */

.chapters-panel {
  border-top: 1px solid var(--line);
  margin-top: 0.25rem;
  padding-top: 0.25rem;
}

.chapters-heading {
  display: flex;
  align-items: center;
  gap: 0.35rem;
  user-select: none;
  background: none;
  border: none;
  padding: 0;
  font-size: 1.1rem;
  font-weight: 700;
  color: inherit;
  cursor: pointer;
}

.chapters-heading small {
  font-size: 0.65rem;
  opacity: 0.5;
}

.chapters-list {
  display: flex;
  flex-direction: column;
  gap: 0.15rem;
  margin-bottom: 0.5rem;
}

.chapter-entry {
  padding: 0.25rem 0.4rem;
  border-radius: var(--radius-sm);
  font-size: 0.8rem;
  border-left: 2px solid transparent;
}

.chapter-entry.chapter-current {
  background: var(--accent-soft);
  border-left-color: var(--accent);
}

.chapter-entry.chapter-completed,
.chapter-entry.chapter-resolved {
  opacity: 0.55;
}

.chapter-header {
  display: flex;
  align-items: center;
  gap: 0.3rem;
}

.chapter-status-icon {
  font-size: 0.65rem;
  flex-shrink: 0;
  width: 0.9rem;
  text-align: center;
}

.chapter-current .chapter-status-icon {
  color: var(--accent);
}

.chapter-completed .chapter-status-icon,
.chapter-resolved .chapter-status-icon {
  color: var(--ink-secondary);
}

.chapter-title {
  font-weight: 500;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  min-width: 0;
}

.chapter-current .chapter-title {
  font-weight: 600;
}

.chapter-summary {
  margin: 0.15rem 0 0 1.2rem;
  font-size: 0.73rem;
  color: var(--ink-secondary);
  line-height: 1.35;
}

.scene-list {
  list-style: none;
  margin: 0.2rem 0 0 1.2rem;
  padding: 0;
}

.scene-entry {
  font-size: 0.73rem;
  padding: 0.1rem 0;
  color: var(--ink-secondary);
}

.scene-entry.scene-current {
  color: var(--ink);
  font-weight: 600;
}

.scene-entry.scene-current::before {
  content: "\25B8 ";
  color: var(--accent);
}

.calendar-panel {
  border-top: 1px solid var(--line);
  margin-top: 0.25rem;
  padding-top: 0.45rem;
}

.calendar-list {
  display: flex;
  flex-direction: column;
  gap: 0.35rem;
  margin: 0.35rem 0 0.5rem;
}

.calendar-entry {
  padding: 0.4rem 0.5rem;
  border-radius: var(--radius-sm);
  background: var(--surface-muted);
  border-left: 2px solid transparent;
}

.calendar-entry.calendar-status-today,
.calendar-entry.calendar-status-imminent {
  border-left-color: var(--accent);
  background: var(--accent-soft);
}

.calendar-entry.calendar-status-missed,
.calendar-entry.calendar-status-overdue {
  border-left-color: var(--error);
}

.calendar-entry-top {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 0.5rem;
}

.calendar-title {
  font-size: 0.78rem;
  font-weight: 600;
  line-height: 1.3;
}

.calendar-time {
  flex-shrink: 0;
  font-size: 0.68rem;
  color: var(--ink-secondary);
}

.calendar-location {
  margin: 0.18rem 0 0;
  font-size: 0.72rem;
  color: var(--ink-secondary);
  line-height: 1.35;
}

.calendar-actions {
  display: flex;
  gap: 0.35rem;
  margin-top: 0.28rem;
}

.calendar-visibility-button {
  appearance: none;
  border: 1px solid var(--line);
  background: var(--surface);
  color: var(--ink-secondary);
  border-radius: 999px;
  padding: 0.12rem 0.45rem;
  font-size: 0.67rem;
  line-height: 1.2;
  cursor: pointer;
}

.calendar-visibility-button.active {
  border-color: var(--accent);
  color: var(--accent);
  background: var(--accent-soft);
}

.calendar-visibility-button:disabled {
  opacity: 0.5;
  cursor: default;
}

.calendar-delete-button {
  appearance: none;
  border: 1px solid transparent;
  background: none;
  color: var(--ink-secondary);
  border-radius: 999px;
  padding: 0.1rem 0.3rem;
  font-size: 0.65rem;
  line-height: 1;
  cursor: pointer;
  margin-left: auto;
  opacity: 0.4;
  transition: opacity 0.15s;
}

.calendar-entry:hover .calendar-delete-button {
  opacity: 1;
}

.calendar-delete-button:hover {
  color: var(--error);
  border-color: var(--error);
  opacity: 1;
}

.calendar-empty {
  margin: 0.3rem 0 0.5rem;
  font-size: 0.75rem;
  color: var(--ink-secondary);
}

/* Campaign flags panel */
.campaign-flags {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}
.campaign-flags h4,
.source-material h4 {
  margin: 0;
  font-size: 0.8rem;
  font-weight: 600;
  opacity: 0.6;
  text-transform: uppercase;
  letter-spacing: 0.03em;
}
.flag-toggle {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  cursor: pointer;
  font-size: 0.85rem;
}
.flag-toggle input[type="checkbox"] {
  width: auto;
  margin: 0;
}
.flag-toggle small {
  opacity: 0.5;
  font-size: 0.76rem;
}

/* Source material panel */
.source-docs-list {
  list-style: none;
  padding: 0;
  margin: 0.3rem 0;
  font-size: 0.82rem;
}
.source-docs-list li {
  padding: 0.25rem 0;
  border-bottom: 1px solid var(--line);
}
.source-docs-list li:last-child {
  border-bottom: none;
}
.source-upload-details {
  margin-top: 0.5rem;
}
.source-upload-details summary {
  cursor: pointer;
  font-size: 0.82rem;
  color: var(--accent);
}
.source-upload-details textarea {
  font-family: var(--mono);
  font-size: 0.78rem;
  resize: vertical;
}

/* ---- Player Card ---- */

.player-card {
  display: flex;
  flex-direction: column;
  gap: 0.7rem;
}

.player-identity {
  display: flex;
  align-items: center;
  gap: 0.75rem;
}

.player-avatar {
  width: 56px;
  height: 56px;
  border-radius: 50%;
  object-fit: cover;
  border: 2px solid var(--line);
  flex-shrink: 0;
}

.player-avatar.pending {
  border-style: dashed;
  border-color: var(--accent);
  opacity: 0.75;
}

.action-bar-avatar {
  width: 128px;
  height: 128px;
  border-radius: var(--radius-md);
  object-fit: cover;
  border: 1.5px solid var(--line);
  flex-shrink: 0;
  align-self: center;
  box-shadow: var(--shadow-sm);
}

.player-identity strong {
  display: block;
  font-size: 1rem;
}

.player-location {
  display: block;
  font-size: 0.8rem;
  color: var(--ink-secondary);
  margin-top: 0.15rem;
}

.xp-row {
  display: flex;
  align-items: center;
  gap: 0.55rem;
  font-size: 0.82rem;
}

.xp-level {
  font-weight: 600;
  color: var(--accent);
  white-space: nowrap;
}

.xp-bar-track {
  flex: 1;
  height: 7px;
  background: var(--line);
  border-radius: 4px;
  overflow: hidden;
}

.xp-bar-fill {
  height: 100%;
  background: var(--accent);
  border-radius: 4px;
  transition: width 0.4s ease;
}

.xp-value {
  font-family: var(--mono);
  font-size: 0.74rem;
  color: var(--ink-secondary);
  white-space: nowrap;
}

.player-stats-row {
  display: flex;
  flex-wrap: wrap;
  gap: 0.4rem;
}

.stat-pill {
  font-size: 0.74rem;
  background: var(--accent-soft);
  color: var(--stat-pill-color);
  border-radius: 10px;
  padding: 0.15rem 0.55rem;
  white-space: nowrap;
}

.player-room-desc {
  margin: 0;
  font-size: 0.84rem;
  line-height: 1.5;
  color: var(--ink-heading);
  font-style: italic;
}

.player-inventory {
  font-size: 0.84rem;
}

.player-inventory strong {
  display: block;
  font-size: 0.78rem;
  text-transform: uppercase;
  letter-spacing: 0.03em;
  color: var(--ink-muted);
  margin-bottom: 0.25rem;
}

.player-inventory ul {
  margin: 0;
  padding-left: 1.2rem;
  list-style: disc;
}

.player-inventory li {
  margin-bottom: 0.15rem;
  line-height: 1.4;
}

.pending-avatar {
  background: var(--surface-muted);
  border: 1px dashed var(--line);
  border-radius: var(--radius-sm);
  padding: 0.65rem;
  font-size: 0.84rem;
  text-align: center;
}

.pending-avatar .player-avatar.pending {
  width: 50%;
  height: auto;
  border-radius: var(--radius-md);
}

.pending-avatar p {
  margin: 0 0 0.4rem;
  font-weight: 500;
  color: var(--ink-heading);
}

.muted {
  color: var(--ink-faint);
  font-size: 0.84rem;
  font-style: italic;
  margin: 0;
}

/* ---- Main column ---- */

.main-column {
  display: flex;
  flex-direction: column;
  overflow: hidden;
  min-height: 0;
}

.section-head {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  gap: 0.8rem;
  margin-bottom: 0.35rem;
}

.section-head-main {
  min-width: 0;
}

.section-head small {
  font-family: var(--mono);
  font-size: 0.74rem;
  color: var(--ink-secondary);
}

.section-head-actions {
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.turn-search-toggle {
  white-space: nowrap;
}

.pins-overlay {
  position: fixed;
  top: 68px;
  right: 1rem;
  z-index: 1004;
}

.pins-overlay-card {
  width: min(380px, calc(100vw - 2rem));
  max-height: min(70vh, 720px);
  display: flex;
  flex-direction: column;
  border: 1px solid var(--line);
  border-radius: var(--radius-md);
  background: var(--surface-white);
  box-shadow: 0 14px 40px rgba(0, 0, 0, 0.18);
  overflow: hidden;
}

.pins-overlay-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 0.5rem;
  padding: 0.8rem 0.9rem 0.55rem;
  border-bottom: 1px solid var(--line);
}

.pins-overlay-body {
  overflow-y: auto;
  padding: 0.55rem 0.6rem 0.7rem;
}

.pins-entry {
  display: grid;
  gap: 0.45rem;
  padding: 0.7rem;
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  background: var(--surface-warm);
  margin-bottom: 0.55rem;
}

.pins-entry-head {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  gap: 0.5rem;
}

.pins-entry-head small {
  font-family: var(--mono);
  font-size: 0.7rem;
  color: var(--ink-secondary);
}

.pins-entry-preview {
  margin: 0;
  font-size: 0.82rem;
  line-height: 1.45;
  white-space: pre-wrap;
  word-break: break-word;
}

.pins-entry-actions {
  display: flex;
  justify-content: flex-end;
  gap: 0.4rem;
}

/* ---- Campaign Summary Bar ---- */

.campaign-summary-bar {
  margin-bottom: 0.6rem;
}

.campaign-summary-bar details {
  background: var(--campaign-summary-bg);
  border: 1px solid var(--accent-border);
  border-radius: var(--radius-sm);
  padding: 0.55rem 0.75rem;
}

.campaign-summary-bar summary {
  font-size: 0.82rem;
  font-weight: 600;
  color: var(--accent);
  cursor: pointer;
  padding: 0;
}

.campaign-summary-bar p {
  margin: 0.45rem 0 0;
  font-size: 0.84rem;
  line-height: 1.55;
  color: var(--ink-heading);
  white-space: pre-line;
}

/* ---- Turn Stream ---- */

.turn-stream {
  border: 1px solid var(--line);
  border-radius: var(--radius-md);
  padding: 0.75rem;
  flex: 1;
  min-height: 200px;
  min-width: 0;
  overflow-y: auto;
  overflow-x: hidden;
  -webkit-overflow-scrolling: touch;
  background: var(--surface-warm);
  margin-bottom: 0.35rem;
  box-shadow: var(--shadow-inset);
}

.turn-stream-layout {
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  gap: 0.85rem;
  flex: 1 1 auto;
  min-height: 0;
}

.turn-stream-layout.turn-search-open {
  grid-template-columns: minmax(0, 1fr) 320px;
}

.turn-stream-shell {
  min-width: 0;
  min-height: 0;
  display: flex;
  flex-direction: column;
}

.turn-search-rail {
  min-width: 0;
  min-height: 0;
  display: flex;
  flex-direction: column;
  border: 1px solid var(--line);
  border-radius: var(--radius-md);
  background: var(--surface-white);
  box-shadow: var(--shadow-sm);
  overflow: hidden;
}

.turn-search-header {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  gap: 0.5rem;
  padding: 0.7rem 0.8rem 0.45rem;
  border-bottom: 1px solid var(--line);
}

.turn-search-header small {
  font-family: var(--mono);
  font-size: 0.72rem;
  color: var(--ink-secondary);
}

.turn-search-form {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 0.45rem;
  padding: 0.7rem 0.8rem;
  border-bottom: 1px solid var(--line);
}

.turn-search-status,
.turn-search-empty {
  margin: 0;
  padding: 0.65rem 0.8rem;
  font-size: 0.78rem;
  color: var(--ink-secondary);
}

.turn-search-results {
  flex: 1 1 auto;
  min-height: 0;
  overflow-y: auto;
  padding: 0.45rem 0.5rem 0.75rem;
}

.turn-search-result {
  display: grid;
  gap: 0.45rem;
  padding: 0.7rem;
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  background: var(--surface-warm);
  margin-bottom: 0.55rem;
}

.turn-search-result.active {
  border-color: var(--accent);
  box-shadow: var(--shadow-focus);
}

.turn-search-result-head {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  gap: 0.5rem;
}

.turn-search-result-head small {
  font-family: var(--mono);
  font-size: 0.7rem;
  color: var(--ink-secondary);
}

.turn-search-preview {
  margin: 0;
  font-size: 0.82rem;
  line-height: 1.45;
  color: var(--ink);
  white-space: pre-wrap;
  word-break: break-word;
}

.turn-search-result-actions {
  display: flex;
  justify-content: flex-end;
}

.turn-search-jump {
  text-align: center;
}

.turn-entry {
  padding: 0.45rem 0;
  animation: fadeInUp 250ms ease both;
}

@keyframes fadeInUp {
  from {
    opacity: 0;
    transform: translateY(6px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

.turn-entry:last-child {
  border-bottom: none;
}

/* Narrator card */
.turn-narrator {
  border-bottom: 1px solid var(--narrator-border);
  padding-bottom: 0.7rem;
  margin-bottom: 0.25rem;
}

.narrator-text {
  margin: 0;
  font-family: var(--sans);
  font-size: 0.9rem;
  line-height: 1.6;
  color: var(--ink);
  white-space: normal;
}

.narrator-text.streaming::after {
  content: "\25AE";
  animation: blink-cursor 0.7s step-end infinite;
  margin-left: 2px;
  opacity: 0.7;
}

@keyframes blink-cursor {
  50% { opacity: 0; }
}

.narrator-text.phase-text {
  color: var(--ink-muted);
  font-style: italic;
}

.speaker-label {
  display: block;
  font-size: 0.72rem;
  color: var(--ink-muted);
  font-weight: 500;
  letter-spacing: 0.02em;
  margin-bottom: 0.1rem;
}

.turn-footer {
  display: flex;
  justify-content: flex-end;
  align-items: baseline;
  gap: 0.7rem;
  margin-top: 0.3rem;
}

.turn-game-time {
  font-family: var(--mono);
  font-size: 0.7rem;
  color: var(--accent);
  opacity: 0.7;
}

.turn-time {
  color: var(--ink-ghost);
  font-size: 0.7rem;
}

/* Player action card */
.turn-player {
  background: var(--surface-dim);
  border-radius: var(--radius-sm);
  padding: 0.35rem 0.7rem;
}

.turn-player-other {
  background: color-mix(in srgb, var(--surface-dim) 62%, var(--surface-soft) 38%);
  border-left: 3px solid color-mix(in srgb, var(--ink-muted) 55%, transparent);
}

.turn-player-queued {
  background: color-mix(in srgb, var(--surface-dim) 72%, var(--accent) 28%);
  border: 1px dashed color-mix(in srgb, var(--accent) 45%, transparent);
}

.turn-player-other .turn-player-actor {
  color: color-mix(in srgb, var(--ink-muted) 72%, var(--ink) 28%);
}

.turn-player-other .player-action-text {
  color: color-mix(in srgb, var(--player-action-text) 80%, var(--ink) 20%);
}

.turn-player-shell {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 0.55rem;
}

.turn-player-meta {
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  gap: 0.3rem;
  flex-shrink: 0;
}

.turn-player-footnote {
  max-width: 22rem;
  color: var(--ink-muted);
  text-align: right;
  line-height: 1.35;
}

.turn-player-body {
  display: flex;
  flex-direction: column;
  gap: 0.08rem;
  min-width: 0;
}

.turn-player-actor {
  font-size: 0.68rem;
  color: var(--ink-muted);
  font-weight: 600;
  letter-spacing: 0.02em;
  text-transform: none;
}

.turn-player-queue-badge {
  display: inline-flex;
  width: fit-content;
  font-size: 0.62rem;
  line-height: 1;
  padding: 0.18rem 0.38rem;
  border-radius: 999px;
  background: color-mix(in srgb, var(--accent) 22%, transparent);
  color: var(--accent);
  border: 1px solid color-mix(in srgb, var(--accent) 45%, transparent);
}

.player-action-text {
  font-size: 0.8rem;
  color: var(--player-action-text);
  line-height: 1.4;
  display: block;
  min-width: 0;
}

.turn-type-player {
  padding: 0.15rem 0;
}

.discord-md {
  min-width: 0;
}

.discord-md > :first-child {
  margin-top: 0;
}

.discord-md > :last-child {
  margin-bottom: 0;
}

.discord-md p,
.discord-md ul,
.discord-md ol,
.discord-md blockquote,
.discord-md pre,
.discord-md .discord-heading {
  margin: 0 0 0.55rem 0;
}

.discord-md ul,
.discord-md ol {
  padding-left: 1.25rem;
}

.discord-md li + li {
  margin-top: 0.18rem;
}

.discord-md blockquote {
  margin-left: 0;
  padding: 0.1rem 0 0.1rem 0.75rem;
  border-left: 3px solid var(--narrator-border);
  color: var(--ink-muted);
}

.discord-md a {
  color: var(--accent);
  text-decoration: underline;
}

.discord-inline-code {
  font-family: var(--mono);
  font-size: 0.92em;
  background: color-mix(in srgb, var(--surface-strong) 72%, transparent);
  border-radius: 0.3rem;
  padding: 0.08rem 0.32rem;
}

.discord-code-block {
  font-family: var(--mono);
  font-size: 0.83rem;
  line-height: 1.5;
  background: color-mix(in srgb, var(--surface-strong) 82%, transparent);
  border: 1px solid var(--narrator-border);
  border-radius: var(--radius-sm);
  overflow-x: auto;
}

.discord-code-block pre {
  margin: 0;
  padding: 0.65rem 0.8rem 0.75rem;
  white-space: pre-wrap;
  overflow-x: auto;
}

.discord-code-block code {
  font-family: inherit;
}

.discord-code-toolbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem;
  padding: 0.45rem 0.8rem 0;
}

.discord-code-label {
  font-size: 0.68rem;
  font-weight: 600;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  color: var(--ink-muted);
}

.code-copy-btn {
  border: 1px solid var(--accent-border);
  background: var(--surface-soft);
  color: var(--ink-secondary);
  border-radius: 999px;
  font-size: 0.68rem;
  line-height: 1;
  padding: 0.26rem 0.5rem;
}

.code-copy-btn:hover {
  color: var(--accent);
}

.discord-heading {
  font-weight: 700;
  line-height: 1.3;
}

.discord-heading-1 {
  font-size: 1.1rem;
}

.discord-heading-2 {
  font-size: 1rem;
}

.discord-heading-3,
.discord-heading-4,
.discord-heading-5,
.discord-heading-6 {
  font-size: 0.92rem;
}

.player-action-text .discord-code-block,
.player-action-text .discord-inline-code {
  font-style: normal;
}

/* Notice card */
.turn-notice {
  background: var(--surface-soft);
  border-left: 3px solid var(--accent);
  border-radius: 0 var(--radius-sm) var(--radius-sm) 0;
  padding: 0.55rem 0.75rem;
  font-size: 0.84rem;
  display: flex;
  align-items: baseline;
  gap: 0.55rem;
  flex-wrap: wrap;
}

.turn-actions {
  display: inline-flex;
  align-items: center;
  gap: 0.25rem;
}

.turn-action-btn {
  opacity: 0;
  background: none;
  border: 1px solid transparent;
  color: var(--ink-secondary);
  cursor: pointer;
  font-size: 0.78rem;
  padding: 0 0.3rem;
  border-radius: 3px;
  transition: opacity 0.15s ease, color 0.15s ease, border-color 0.15s ease;
  vertical-align: middle;
}

.turn-narrator:hover .turn-action-btn,
.turn-narrator:focus-within .turn-action-btn,
.turn-player:hover .turn-action-btn,
.turn-player:focus-within .turn-action-btn,
.turn-collapsed:hover .turn-action-btn,
.turn-action-btn:focus-visible {
  opacity: 1;
}

.turn-action-btn:hover {
  color: var(--accent);
  border-color: var(--accent-border, var(--accent));
}

.turn-pin-btn.pinned,
.turn-pin-btn:hover {
  opacity: 1;
  color: var(--accent);
  border-color: var(--accent-border, var(--accent));
  background: color-mix(in srgb, var(--accent-soft) 70%, transparent);
}

.pins-close-btn {
  opacity: 1;
}

.turn-delete-btn:hover {
  color: var(--danger, #b44545);
  border-color: color-mix(in srgb, var(--danger, #b44545) 60%, transparent);
}

.turn-editor {
  display: grid;
  gap: 0.45rem;
}

.turn-editor-input {
  width: 100%;
  min-height: 7rem;
  resize: vertical;
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  background: var(--surface-soft);
  color: var(--ink);
  padding: 0.65rem 0.75rem;
  font: inherit;
  line-height: 1.45;
}

.turn-editor-actions {
  display: flex;
  justify-content: flex-end;
  gap: 0.45rem;
}

.turn-collapsed {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.6rem;
  color: var(--ink-muted);
  font-size: 0.82rem;
  padding: 0.25rem 0;
}

.notice-label {
  font-weight: 600;
  font-size: 0.72rem;
  text-transform: uppercase;
  letter-spacing: 0.03em;
  color: var(--accent);
  flex-shrink: 0;
}

/* Reasoning card (debug only) */
.turn-reasoning .reasoning-text {
  margin: 0;
  font-size: 0.82rem;
  line-height: 1.5;
  color: var(--reasoning-text-color);
  font-style: italic;
}

/* Scene prompt card (non-debug) */
.scene-prompt-card {
  display: flex;
  align-items: flex-start;
  gap: 0.5rem;
  background: var(--scene-card-bg);
  border: 1px solid var(--scene-card-border);
  border-radius: var(--radius-sm);
  padding: 0.5rem 0.7rem;
  margin: 0.15rem 0;
}

.scene-prompt-icon {
  font-size: 1rem;
  flex-shrink: 0;
  line-height: 1.4;
}

.scene-prompt-text {
  font-size: 0.82rem;
  line-height: 1.45;
  color: var(--scene-prompt-text-color);
  font-style: italic;
  flex: 1;
}

.scene-prompt-gen-btn {
  flex-shrink: 0;
  font-size: 0.72rem;
  padding: 0.2rem 0.5rem;
  background: var(--accent-soft);
  border: 1px solid var(--accent-border);
  border-radius: 4px;
  cursor: pointer;
  white-space: nowrap;
  align-self: center;
}

.scene-prompt-gen-btn:hover:not(:disabled) {
  background: var(--button-hover-bg);
}

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

.scene-prompt-result {
  display: block;
  max-width: 100%;
  max-height: 400px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--line);
  margin-top: 0.35rem;
}

.scene-prompt-error {
  margin: 0.25rem 0 0;
  font-size: 0.78rem;
  color: var(--error);
}

/* Debug cards (summary, image_prompt, system events) */
.turn-debug-card {
  background: var(--surface-muted);
  border: 1px dashed var(--debug-border);
  border-radius: var(--radius-sm);
  padding: 0.5rem 0.65rem;
  margin: 0.25rem 0;
}

.turn-debug-card header {
  display: flex;
  justify-content: space-between;
  margin-bottom: 0.3rem;
}

.turn-debug-card strong {
  text-transform: uppercase;
  font-size: 0.7rem;
  letter-spacing: 0.03em;
  color: var(--ink-muted);
}

.turn-debug-card small {
  color: var(--ink-ghost);
  font-size: 0.68rem;
}

.turn-debug-card pre {
  font-size: 0.74rem;
}

pre {
  margin: 0;
  white-space: pre-wrap;
  word-break: break-word;
  font-family: var(--mono);
  font-size: 0.78rem;
  line-height: 1.4;
}

.empty {
  margin: 0;
  padding: 2.5rem 0;
  font-size: 0.86rem;
  color: var(--ink-muted);
  text-align: center;
}

/* ---- Action bar (unified chat input) ---- */

.action-bar-wrapper {
  display: flex;
  align-items: stretch;
  gap: 0.75rem;
  margin-bottom: 0.15rem;
}

.action-bar-column {
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: 0.4rem;
}

.char-hud {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.3rem 0.6rem;
  background: var(--accent-soft);
  border: 1px solid var(--line);
  border-radius: var(--radius-md);
  padding: 0.4rem 0.65rem;
}

.char-hud-top {
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.char-hud-name {
  font-size: 0.92rem;
  white-space: nowrap;
}

.char-hud-stats {
  display: flex;
  align-items: center;
  gap: 0.35rem;
}

.char-hud-xp {
  width: 80px;
}

.char-hud-location {
  font-size: 0.78rem;
  color: var(--ink-muted);
  font-style: italic;
}

.action-bar {
  display: flex;
  align-items: center;
  gap: 0.4rem;
  background: var(--surface-white);
  border: 1.5px solid var(--line);
  border-radius: var(--radius-md);
  padding: 0.35rem 0.4rem 0.35rem 0.55rem;
  box-shadow: var(--shadow-sm);
  transition: border-color var(--transition), box-shadow var(--transition);
}

.action-input-shell {
  position: relative;
  flex: 1;
  min-width: 0;
}

.action-bar:focus-within {
  border-color: var(--accent);
  box-shadow: var(--action-bar-focus-shadow), var(--shadow-sm);
}

.actor-select {
  width: auto;
  min-width: 90px;
  max-width: 150px;
  font-size: 0.78rem;
  border: none;
  background: var(--surface-white);
  border-radius: 4px;
  padding: 0.25rem 0.35rem;
}

.actor-select:focus {
  box-shadow: none;
  outline: 1.5px solid var(--accent);
  outline-offset: -1px;
}

.action-prompt {
  font-family: var(--mono);
  font-weight: 700;
  font-size: 1.05rem;
  color: var(--accent);
  flex-shrink: 0;
}

.action-input {
  flex: 1;
  font-size: 0.9rem;
  border: none;
  background: transparent;
  padding: 0.4rem 0.3rem;
  resize: none;
  overflow-x: hidden;
  overflow-y: auto;
  line-height: 1.4;
  min-height: 1.4em;
  max-height: 8em;
  font-family: inherit;
  field-sizing: content;
}

.action-input:focus {
  box-shadow: none;
  outline: none;
}

.mention-menu {
  position: absolute;
  left: 0;
  right: 0;
  bottom: calc(100% + 0.45rem);
  display: grid;
  gap: 0.2rem;
  padding: 0.35rem;
  border: 1px solid var(--line);
  border-radius: var(--radius-md);
  background: var(--panel);
  box-shadow: var(--shadow-md);
  z-index: 30;
}

.mention-option {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem;
  width: 100%;
  padding: 0.45rem 0.55rem;
  border: 1px solid transparent;
  border-radius: var(--radius-sm);
  background: transparent;
  color: var(--ink);
  cursor: pointer;
  text-align: left;
}

.mention-option:hover,
.mention-option.active {
  background: var(--accent-soft);
  border-color: var(--accent-border-hover);
}

.mention-option-name {
  font-weight: 600;
}

.mention-option-id {
  font-size: 0.76rem;
  color: var(--ink-muted);
}

.action-submit {
  flex-shrink: 0;
  background: var(--accent);
  color: var(--active-text);
  border-color: var(--active-border);
  text-align: center;
  padding: 0.55rem 1.25rem;
  font-size: 0.88rem;
  border-radius: var(--radius-sm);
}

.action-submit:hover {
  background: var(--accent-hover);
}

.action-submit.action-thinking {
  animation: pulse-thinking 1.8s ease-in-out infinite;
}

@keyframes pulse-thinking {
  0%, 100% { opacity: 0.5; }
  50% { opacity: 0.8; }
}

.status,
.error {
  margin: 0.15rem 0 0;
  font-size: 0.82rem;
}

.status {
  color: var(--status-text);
}

.error {
  color: var(--error);
  font-weight: 500;
  cursor: pointer;
}

/* ---- Inspector Panel ---- */

.inspector-panel {
  border-top: 1px solid var(--line);
  padding-top: 0.85rem;
  margin-top: 0.65rem;
}

.tab-row {
  display: flex;
  flex-wrap: wrap;
  gap: 0.35rem;
  margin-bottom: 0.75rem;
}

.tab-row button {
  text-align: center;
  font-size: 0.8rem;
  padding: 0.4rem 0.85rem;
  border-radius: 20px;
  border-color: transparent;
  background: transparent;
  color: var(--ink-secondary);
}

.tab-row button:hover:not(.active) {
  background: var(--accent-soft);
  color: var(--accent);
}

.tab-row button.active {
  border-radius: 20px;
}

.inspector-panel pre {
  background: var(--surface-subtle);
  border: 1px solid rgba(200, 190, 176, 0.4);
  border-radius: var(--radius-sm);
  padding: 0.65rem;
  max-height: 320px;
  overflow: auto;
}

/* ---- Welcome card ---- */

.welcome-card {
  background: var(--accent-soft);
  border: 1px solid var(--accent-border-hover);
  border-radius: var(--radius-md);
  padding: 1.75rem 2rem;
  margin-bottom: 1.25rem;
  text-align: center;
  box-shadow: var(--shadow-sm);
}

.welcome-card h2 {
  margin: 0 0 0.6rem;
  text-transform: none;
  font-size: 1.2rem;
  color: var(--ink);
}

.welcome-card p {
  margin: 0;
  font-size: 0.9rem;
  color: var(--status-text);
  line-height: 1.5;
}

/* ---- Settings Drawer ---- */

[x-cloak] {
  display: none !important;
}

.settings-overlay {
  position: fixed;
  top: 58px;
  right: 0;
  bottom: 0;
  left: 0;
  background: var(--overlay-light);
  z-index: 100;
  display: flex;
  justify-content: flex-end;
}

.settings-drawer {
  width: 420px;
  max-width: 92vw;
  background: var(--panel);
  border-left: 1px solid var(--line);
  padding: 1.5rem 1.75rem;
  overflow-y: auto;
  height: calc(100vh - 58px);
  box-shadow: var(--shadow-drawer);
  animation: drawerSlideIn 200ms ease;
}

@keyframes drawerSlideIn {
  from {
    transform: translateX(1.5rem);
    opacity: 0;
  }
  to {
    transform: translateX(0);
    opacity: 1;
  }
}

.drawer-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 1.25rem;
  padding-bottom: 0.75rem;
  border-bottom: 1px solid var(--line);
}

.drawer-header h2 {
  margin: 0;
  font-size: 1rem;
  color: var(--ink);
}

.settings-tabs {
  display: flex;
  gap: 0.25rem;
}

.settings-tab {
  background: none;
  border: none;
  border-bottom: 2px solid transparent;
  padding: 0.3rem 0.75rem;
  font-size: 0.92rem;
  cursor: pointer;
  color: var(--ink-muted);
  transition: color var(--transition), border-color var(--transition);
}

.settings-tab:hover {
  color: var(--ink);
}

.settings-tab.active {
  border-bottom-color: var(--accent);
  color: var(--accent);
  font-weight: 500;
}

.drawer-close {
  background: none;
  border: none;
  font-size: 1.5rem;
  cursor: pointer;
  color: var(--ink-muted);
  padding: 0.2rem 0.4rem;
  line-height: 1;
  border-radius: var(--radius-sm);
  transition: color var(--transition), background var(--transition);
}

.drawer-close:hover {
  color: var(--ink);
  background: var(--close-hover-bg);
}

.settings-group {
  background: var(--settings-group-bg);
  border: 1px solid rgba(200, 190, 176, 0.45);
  border-radius: var(--radius-md);
  padding: 0.9rem;
}

.settings-group .stack {
  margin-bottom: 0;
}

.settings-group-title {
  font-size: 0.72rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--ink-muted);
  margin: 0 0 0.65rem;
}

.drawer-actions {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0.55rem;
  margin-top: 0.5rem;
  padding-top: 0.75rem;
  border-top: 1px solid var(--line);
}

.btn-primary {
  background: var(--accent);
  color: var(--active-text);
  border-color: var(--active-border);
  text-align: center;
}

.btn-primary:hover {
  background: var(--accent-hover);
}

.settings-note {
  margin: 0.75rem 0 0;
  font-size: 0.78rem;
  color: var(--ink-ghost);
  font-style: italic;
}

.settings-status {
  margin: 0.4rem 0 0;
  font-size: 0.82rem;
}

details {
  margin-top: 0.4rem;
}

details summary {
  cursor: pointer;
  font-size: 0.84rem;
  font-weight: 500;
  color: var(--accent);
  padding: 0.3rem 0;
}

/* ---- Inspector debug mode tabs ---- */

.inline-actions {
  display: grid;
  gap: 0.4rem;
  grid-template-columns: 1fr 1fr;
}

.diagnostics-panel {
  border: 1px solid var(--line);
  border-radius: var(--radius-md);
  padding: 0.75rem;
  background: var(--surface-warm-deep);
}

.diagnostics-panel h2 {
  margin: 0 0 0.5rem;
}

.diagnostics-panel p {
  margin: 0;
  font-size: 0.8rem;
  line-height: 1.4;
  word-break: break-word;
}

.debug-actions {
  display: grid;
  gap: 0.35rem;
}

.debug-actions small {
  font-size: 0.78rem;
  color: var(--ink-secondary);
}

/* ---- Player Attributes ---- */

.player-attributes {
  display: flex;
  flex-direction: column;
  gap: 0.4rem;
}

.attr-header {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
}

.attr-header strong {
  font-size: 0.78rem;
  text-transform: uppercase;
  letter-spacing: 0.03em;
  color: var(--ink-muted);
}

.attr-header small {
  font-size: 0.74rem;
  color: var(--ink-secondary);
  font-family: var(--mono);
}

.attr-grid {
  display: grid;
  gap: 0.3rem;
}

.attr-row {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  font-size: 0.82rem;
}

.attr-name {
  width: 100px;
  font-weight: 500;
  text-transform: capitalize;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.attr-bar-track {
  flex: 1;
  height: 6px;
  background: var(--line);
  border-radius: 3px;
  overflow: hidden;
}

.attr-bar-fill {
  height: 100%;
  background: var(--accent);
  border-radius: 3px;
  transition: width 0.3s ease;
}

.attr-value {
  font-family: var(--mono);
  font-size: 0.74rem;
  color: var(--ink-secondary);
  min-width: 1.5rem;
  text-align: right;
}

.attr-set-form {
  display: flex;
  gap: 0.35rem;
  align-items: end;
  margin-top: 0.3rem;
}

.attr-input {
  flex: 1;
  min-width: 0;
  font-size: 0.8rem;
  padding: 0.35rem 0.5rem;
}

.attr-input-num {
  max-width: 60px;
}

.level-up-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.5rem;
  padding: 0.4rem 0;
  border-top: 1px solid var(--line);
}

.xp-needed {
  font-size: 0.78rem;
  color: var(--ink-secondary);
  font-family: var(--mono);
}

.btn-level-up {
  background: var(--accent);
  color: var(--active-text);
  border-color: var(--active-border);
  text-align: center;
  font-size: 0.8rem;
  padding: 0.35rem 0.75rem;
}

.btn-level-up:hover:not(:disabled) {
  background: var(--accent-hover);
}

/* ---- Campaign Persona ---- */

.campaign-persona {
  display: flex;
  flex-direction: column;
  gap: 0.4rem;
}

.campaign-persona h4 {
  margin: 0;
  font-size: 0.8rem;
  font-weight: 600;
  opacity: 0.6;
  text-transform: uppercase;
  letter-spacing: 0.03em;
}

.persona-text {
  margin: 0;
  font-size: 0.84rem;
  line-height: 1.5;
  color: var(--ink);
  font-style: italic;
}

.persona-source {
  font-size: 0.72rem;
  color: var(--ink-ghost);
}

.persona-edit-details {
  margin-top: 0.3rem;
}

.persona-edit-details summary {
  font-size: 0.82rem;
  color: var(--accent);
  cursor: pointer;
}

/* ---- Turn History ---- */

.turn-history-list {
  display: grid;
  gap: 0.35rem;
  max-height: 400px;
  overflow-y: auto;
}

.history-row {
  background: var(--surface-subtle);
  border: 1px solid rgba(200, 190, 176, 0.4);
  border-radius: var(--radius-sm);
  padding: 0.5rem 0.65rem;
}

.history-row.history-kind-narrator {
  border-left: 3px solid var(--accent);
}

.history-row.history-kind-player {
  border-left: 3px solid var(--history-player-border);
}

.history-header {
  display: flex;
  align-items: baseline;
  gap: 0.5rem;
  flex-wrap: wrap;
  margin-bottom: 0.25rem;
}

.history-id {
  font-family: var(--mono);
  font-size: 0.72rem;
  font-weight: 600;
  color: var(--accent);
}

.history-kind {
  font-size: 0.7rem;
  text-transform: uppercase;
  letter-spacing: 0.03em;
  color: var(--ink-muted);
  font-weight: 600;
}

.history-actor {
  font-size: 0.78rem;
  color: var(--ink-heading);
  font-weight: 500;
}

.history-time {
  font-size: 0.68rem;
  color: var(--ink-ghost);
  margin-left: auto;
}

.history-content {
  margin: 0;
  font-size: 0.82rem;
  line-height: 1.5;
  color: var(--ink);
}

.history-reasoning {
  margin-top: 0.2rem;
}

.history-reasoning summary {
  font-size: 0.74rem;
  color: var(--accent);
  padding: 0.1rem 0;
}

.history-reasoning p {
  margin: 0.2rem 0 0;
  font-size: 0.78rem;
  line-height: 1.45;
  color: var(--reasoning-text-color);
  font-style: italic;
}

/* ---- Dice Result Card ---- */

.dice-result-card {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.45rem 0.7rem;
  border-radius: var(--radius-sm);
  font-size: 0.84rem;
  flex-wrap: wrap;
}

.dice-result-card.dice-success {
  background: var(--dice-success-bg);
  border: 1px solid var(--success-border);
}

.dice-result-card.dice-fail {
  background: var(--dice-fail-bg);
  border: 1px solid var(--error-border);
}

.dice-icon {
  font-size: 1.1rem;
  flex-shrink: 0;
}

.dice-text {
  font-family: var(--mono);
  font-size: 0.82rem;
  flex: 1;
}

/* ---- Game Mechanic Cards (Puzzle / Minigame) ---- */

.game-mechanic-card {
  background: var(--mechanic-bg);
  border: 1px solid var(--mechanic-border);
  border-radius: var(--radius-sm);
  padding: 0.7rem 0.85rem;
}

.game-mechanic-card strong {
  display: block;
  font-size: 0.82rem;
  text-transform: uppercase;
  letter-spacing: 0.03em;
  color: var(--accent);
  margin-bottom: 0.35rem;
}

.game-mechanic-card p {
  margin: 0.2rem 0;
  font-size: 0.84rem;
}

.mechanic-prompt {
  font-style: italic;
  color: var(--ink-heading);
  line-height: 1.5;
}

.game-board {
  font-family: var(--mono);
  font-size: 0.82rem;
  background: var(--surface-white);
  border: 1px solid var(--line);
  border-radius: 4px;
  padding: 0.5rem;
  line-height: 1.3;
}

.mechanic-controls {
  margin-top: 0.4rem;
  display: flex;
  flex-direction: column;
  gap: 0.3rem;
}

.mechanic-input-row {
  display: flex;
  gap: 0.35rem;
  align-items: end;
}

.mechanic-input {
  flex: 1;
  min-width: 0;
  font-size: 0.82rem;
  padding: 0.35rem 0.5rem;
}

.mechanic-result {
  margin: 0.3rem 0 0;
  font-size: 0.84rem;
  font-weight: 600;
}

.mechanic-success {
  color: var(--success-bright);
}

.mechanic-fail {
  color: var(--error);
}

/* ---- Campaign Setup Wizard ---- */

.setup-wizard {
  background: var(--surface-tint);
  border: 1px solid var(--line);
  border-radius: var(--radius-md);
  padding: 0.85rem 1rem;
  display: flex;
  flex-direction: column;
  gap: 0.6rem;
}

.setup-wizard-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.5rem;
}

.setup-wizard-header h4 {
  margin: 0;
  font-size: 0.84rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.03em;
  color: var(--accent);
}

.setup-phase-badge {
  font-family: var(--mono);
  font-size: 0.72rem;
  background: var(--accent-soft);
  color: var(--accent);
  padding: 0.15rem 0.5rem;
  border-radius: 999px;
  text-transform: lowercase;
}

.setup-start-controls {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}

.setup-start-controls p {
  margin: 0;
  font-size: 0.84rem;
  line-height: 1.5;
  color: var(--setup-text-color);
}

.setup-attachment-details summary {
  font-size: 0.82rem;
  color: var(--accent);
  cursor: pointer;
}

.setup-attachment-details textarea {
  margin-top: 0.3rem;
  width: 100%;
  font-size: 0.82rem;
}

.btn-setup-start {
  background: var(--accent);
  color: var(--active-text);
  border-color: var(--active-border);
  font-size: 0.84rem;
  padding: 0.45rem 1rem;
  align-self: flex-start;
}

.btn-setup-start:hover:not(:disabled) {
  background: var(--accent-hover);
}

.setup-response-card {
  background: var(--surface-white);
  border: 1px solid var(--line);
  border-left: 3px solid var(--accent);
  border-radius: var(--radius-sm);
  padding: 0.6rem 0.8rem;
}

.setup-response-card p {
  margin: 0;
  font-size: 0.84rem;
  line-height: 1.55;
  color: var(--ink);
  white-space: pre-wrap;
}

.setup-message-form {
  display: flex;
  gap: 0.35rem;
}

.setup-message-input {
  flex: 1;
  min-width: 0;
  font-size: 0.84rem;
  padding: 0.4rem 0.6rem;
}

.setup-complete-card {
  background: var(--success-bg);
  border: 1px solid var(--success-border);
  border-radius: var(--radius-sm);
  padding: 0.6rem 0.8rem;
}

.setup-complete-card p {
  margin: 0;
  font-size: 0.84rem;
  line-height: 1.5;
  color: var(--success-bright);
}

/* ---- Scene Images ---- */

.scene-images-panel {
  display: flex;
  flex-direction: column;
  gap: 0.4rem;
}

.scene-images-panel h4 {
  margin: 0;
  font-size: 0.8rem;
  font-weight: 600;
  opacity: 0.6;
  text-transform: uppercase;
  letter-spacing: 0.03em;
}

.scene-images-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(120px, 1fr));
  gap: 0.5rem;
}

.scene-image-card {
  display: flex;
  flex-direction: column;
  gap: 0.2rem;
  text-align: center;
}

.scene-image-card img {
  width: 100%;
  aspect-ratio: 1;
  object-fit: cover;
  border-radius: var(--radius-sm);
  border: 1px solid var(--line);
}

.scene-image-card small {
  font-size: 0.7rem;
  color: var(--ink-muted);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

/* ---- Literary Styles ---- */

.literary-styles-panel {
  display: flex;
  flex-direction: column;
  gap: 0.4rem;
}

.literary-styles-panel h4 {
  margin: 0;
  font-size: 0.8rem;
  font-weight: 600;
  opacity: 0.6;
  text-transform: uppercase;
  letter-spacing: 0.03em;
}

.literary-styles-list {
  display: grid;
  gap: 0.2rem;
}

.literary-style-item summary {
  font-size: 0.82rem;
  font-weight: 500;
  color: var(--ink);
  cursor: pointer;
  padding: 0.25rem 0;
}

.literary-style-item summary:hover {
  color: var(--accent);
}

.literary-style-profile {
  margin: 0.2rem 0 0.4rem;
  font-size: 0.8rem;
  line-height: 1.5;
  color: var(--reasoning-text-color);
  padding-left: 0.8rem;
  border-left: 2px solid var(--line);
  white-space: pre-wrap;
}

/* ---- SMS Actions ---- */

.sms-actions {
  margin-bottom: 0.5rem;
}

.btn-cancel-sms {
  background: var(--cancel-bg);
  border: 1px solid var(--cancel-border);
  color: var(--cancel-text);
  font-size: 0.82rem;
  padding: 0.35rem 0.75rem;
}

.btn-cancel-sms:hover:not(:disabled) {
  background: var(--cancel-bg-hover);
}

/* ---- Source Material Search ---- */

.source-search-row {
  display: flex;
  gap: 0.35rem;
  align-items: end;
}

.source-search-input {
  flex: 2;
  min-width: 0;
  font-size: 0.82rem;
  padding: 0.35rem 0.5rem;
}

.source-search-dockey {
  flex: 1;
  min-width: 0;
  font-size: 0.82rem;
  padding: 0.35rem 0.5rem;
}

.source-search-results {
  display: grid;
  gap: 0.35rem;
  max-height: 300px;
  overflow-y: auto;
  margin-top: 0.3rem;
}

.source-search-hit {
  background: var(--surface-white);
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  padding: 0.45rem 0.6rem;
}

.source-hit-header {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  margin-bottom: 0.2rem;
}

.source-hit-header small {
  font-size: 0.72rem;
  color: var(--ink-muted);
}

.source-hit-score {
  font-family: var(--mono);
}

.source-hit-text {
  margin: 0;
  font-size: 0.82rem;
  line-height: 1.5;
  color: var(--ink);
  white-space: pre-wrap;
  max-height: 120px;
  overflow-y: auto;
}

/* ---- Campaign Delete ---- */

.btn-delete-campaign {
  background: transparent;
  border: 1px solid var(--error-border);
  color: var(--error-bright);
  font-size: 0.78rem;
  padding: 0.3rem 0.6rem;
  width: 100%;
  margin-top: 0.3rem;
}

.btn-delete-campaign:hover {
  background: var(--error-bg);
}

/* ---- File Drop Zone ---- */

.file-drop-zone {
  border: 2px dashed var(--line);
  border-radius: 6px;
  padding: 0.75rem;
  text-align: center;
  transition: border-color 0.2s, background 0.2s;
}
.file-drop-zone.drag-over {
  border-color: var(--accent);
  background: var(--file-drop-hover-bg);
}
.file-drop-zone.drop-zone-disabled {
  opacity: 0.5;
  pointer-events: none;
}
.drop-zone-text { margin: 0; font-size: 0.85rem; color: var(--ink-faint); }
.file-pick-label { color: var(--accent); cursor: pointer; text-decoration: underline; }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0,0,0,0); }
.file-list { list-style: none; padding: 0; margin: 0.5rem 0 0; }
.file-item {
  display: flex; align-items: center; gap: 0.5rem;
  padding: 0.25rem 0; font-size: 0.85rem;
  min-width: 0;
}
.file-name {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  min-width: 0;
}
.file-item small { color: var(--ink-faint); margin-left: auto; white-space: nowrap; }
.file-status-dot { width: 8px; height: 8px; border-radius: 50%; display: inline-block; }
.dot-reading { background: var(--ink-faint); animation: blink-cursor 0.7s step-end infinite; }
.dot-ready { background: var(--ink-faint); }
.dot-uploading { background: var(--accent); animation: blink-cursor 0.7s step-end infinite; }
.dot-done { background: var(--success); }
.dot-error { background: var(--error); }
.file-remove { background: none; border: none; color: var(--ink-faint); cursor: pointer; font-size: 1.1rem; padding: 0 0.25rem; }
.file-remove:hover { color: var(--error); }

/* ---- Modal System ---- */

.modal-overlay {
  position: fixed;
  inset: 0;
  background: var(--overlay-dark);
  z-index: 200;
  display: flex;
  align-items: center;
  justify-content: center;
  animation: modalOverlayIn 150ms ease;
}

@keyframes modalOverlayIn {
  from { opacity: 0; }
  to { opacity: 1; }
}

.modal-panel {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-modal);
  width: 90vw;
  max-width: 440px;
  max-height: 85vh;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  animation: modalFadeIn 200ms ease;
}

.modal-panel--md { max-width: 600px; }
.modal-panel--lg { max-width: 780px; }

@keyframes modalFadeIn {
  from { opacity: 0; transform: translateY(12px) scale(0.97); }
  to { opacity: 1; transform: translateY(0) scale(1); }
}

.modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0.85rem 1.1rem;
  border-bottom: 1px solid var(--line);
  flex-shrink: 0;
}

.modal-header h3 {
  margin: 0;
  font-size: 0.95rem;
  color: var(--ink);
}

.modal-close {
  background: none;
  border: none;
  font-size: 1.4rem;
  cursor: pointer;
  color: var(--ink-muted);
  padding: 0.15rem 0.35rem;
  line-height: 1;
  border-radius: var(--radius-sm);
}

.modal-close:hover {
  color: var(--ink);
  background: var(--close-hover-bg);
}

.modal-body {
  padding: 1rem 1.1rem;
  overflow-y: auto;
  flex: 1;
}

.modal-footer {
  padding: 0.75rem 1.1rem;
  border-top: 1px solid var(--line);
  flex-shrink: 0;
}

/* ---- Campaign Selector (sidebar top) ---- */

.campaign-selector-row {
  display: flex;
  align-items: center;
  gap: 0.35rem;
  margin-bottom: 0.75rem;
}

.campaign-selector-row select {
  flex: 1;
  min-width: 0;
  font-size: 0.84rem;
  padding: 0.45rem 0.55rem;
}

.campaign-selector-row .icon-btn {
  background: none;
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  padding: 0.35rem 0.5rem;
  font-size: 0.95rem;
  cursor: pointer;
  line-height: 1;
  color: var(--ink-secondary);
  flex-shrink: 0;
}

.campaign-selector-row .icon-btn:hover {
  background: var(--accent-soft);
  color: var(--accent);
  border-color: var(--accent-border-hover);
}

/* ---- Quick Info Area ---- */

.quick-info {
  display: flex;
  flex-direction: column;
  gap: 0.4rem;
  padding: 0.55rem 0.65rem;
  background: var(--quick-info-bg);
  border: 1px solid var(--accent-border);
  border-radius: var(--radius-sm);
  margin-bottom: 0.75rem;
}

.quick-info-top {
  display: flex;
  align-items: center;
  gap: 0.55rem;
}

.quick-info-avatar {
  width: 36px;
  height: 36px;
  border-radius: 50%;
  object-fit: cover;
  border: 1.5px solid var(--line);
  flex-shrink: 0;
}

.quick-info-details {
  flex: 1;
  min-width: 0;
}

.quick-info-name {
  font-weight: 600;
  font-size: 0.88rem;
  display: block;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.quick-info-xp {
  display: flex;
  align-items: center;
  gap: 0.3rem;
  margin-top: 0.15rem;
}

.quick-info-xp .xp-level {
  font-size: 0.72rem;
}

.quick-info-xp .xp-bar-track {
  width: 60px;
  height: 5px;
}

.quick-info-xp .xp-value {
  font-size: 0.68rem;
}

.quick-info-room {
  font-size: 0.78rem;
  color: var(--ink-secondary);
  font-style: italic;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.quick-info-buttons {
  display: grid;
  grid-template-columns: 1fr 1fr 1fr;
  gap: 0.3rem;
}

.quick-info-buttons button {
  text-align: center;
  font-size: 0.76rem;
  padding: 0.3rem 0.35rem;
  background: var(--surface-white);
  border: 1px solid var(--line);
}

.quick-info-buttons button:hover {
  background: var(--accent-soft);
  border-color: var(--accent-border-hover);
}

/* ---- Campaign Manager Modal ---- */

.campaign-manager-list {
  display: grid;
  gap: 0.35rem;
}

.campaign-manager-row {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.55rem 0.7rem;
  background: var(--surface-subtle);
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
}

.campaign-manager-row.cm-active {
  border-color: var(--accent);
  border-left: 3px solid var(--accent);
}

.campaign-manager-row .cm-info {
  flex: 1;
  min-width: 0;
}

.campaign-manager-row .cm-name {
  display: block;
  font-weight: 500;
  font-size: 0.88rem;
}

.campaign-manager-row .cm-actor {
  display: block;
  font-size: 0.74rem;
  color: var(--ink-secondary);
}

.campaign-manager-row .cm-actions {
  display: flex;
  gap: 0.3rem;
  flex-shrink: 0;
}

.campaign-manager-row .cm-actions button {
  font-size: 0.76rem;
  padding: 0.25rem 0.55rem;
  text-align: center;
}

.cm-btn-delete {
  background: transparent;
  border: 1px solid var(--error-border);
  color: var(--error-bright);
}

.cm-btn-delete:hover {
  background: var(--error-bg);
}

/* ---- Campaign Config Modal Sub-tabs ---- */

.config-tabs {
  display: flex;
  gap: 0.25rem;
  margin-bottom: 0.85rem;
  border-bottom: 1px solid var(--line);
  padding-bottom: 0.45rem;
}

.config-tab {
  background: none;
  border: none;
  border-bottom: 2px solid transparent;
  padding: 0.3rem 0.65rem;
  font-size: 0.82rem;
  cursor: pointer;
  color: var(--ink-muted);
}

.config-tab:hover {
  color: var(--ink);
}

.config-tab.active {
  border-bottom-color: var(--accent);
  color: var(--accent);
  font-weight: 500;
}

.tab-explainer {
  color: var(--ink-faint);
  font-size: 0.8rem;
  line-height: 1.45;
  margin: 0 0 0.6rem 0;
  padding: 0.45rem 0.6rem;
  background: var(--surface-muted);
  border-radius: var(--radius-sm);
  border-left: 3px solid var(--explainer-border);
}

.flag-hint {
  display: block;
  color: var(--flag-hint-color);
  font-size: 0.76rem;
  line-height: 1.4;
  margin: -0.15rem 0 0.55rem 1.65rem;
}

/* ---- New Campaign Wizard ---- */

.wizard-step-indicator {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  margin-bottom: 0.85rem;
}

.wizard-step-dot {
  width: 28px;
  height: 28px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 0.72rem;
  font-weight: 600;
  border: 2px solid var(--line);
  color: var(--ink-muted);
  background: var(--surface-white);
  flex-shrink: 0;
}

.wizard-step-dot.active {
  border-color: var(--accent);
  background: var(--accent);
  color: var(--surface-white);
}

.wizard-step-dot.done {
  border-color: var(--success);
  background: var(--success);
  color: var(--surface-white);
}

.wizard-step-line {
  flex: 1;
  height: 2px;
  background: var(--line);
}

.wizard-step-line.done {
  background: var(--success);
}

.wizard-creating {
  text-align: center;
  padding: 2rem 1rem;
}

.wizard-creating .spinner {
  display: inline-block;
  width: 32px;
  height: 32px;
  border: 3px solid var(--line);
  border-top-color: var(--accent);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
  margin-bottom: 0.75rem;
}

@keyframes spin {
  to { transform: rotate(360deg); }
}

.wizard-creating p {
  margin: 0;
  font-size: 0.88rem;
  color: var(--ink-secondary);
}

.wizard-setup-conversation {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
  min-height: 120px;
  max-height: 55vh;
  overflow-y: auto;
  margin-bottom: 0.75rem;
  padding: 0.5rem;
  background: var(--wizard-conv-bg);
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
}

.wizard-msg {
  padding: 0.5rem 0.7rem;
  border-radius: var(--radius-sm);
  font-size: 0.84rem;
  line-height: 1.55;
  white-space: pre-wrap;
  max-width: 85%;
}

.wizard-msg-narrator {
  background: var(--surface-white);
  border: 1px solid var(--line);
  border-left: 3px solid var(--accent);
  align-self: flex-start;
}

.wizard-msg-player {
  background: var(--accent-soft);
  border: 1px solid var(--accent-border);
  align-self: flex-end;
}

.wizard-complete {
  text-align: center;
  padding: 2rem 1rem;
}

.wizard-complete h3 {
  margin: 0 0 0.5rem;
  font-size: 1.1rem;
  color: var(--accent);
}

.wizard-complete p {
  margin: 0 0 1rem;
  font-size: 0.88rem;
  color: var(--ink-secondary);
}

/* ---- Rewind button (turn stream) ---- */

.rewind-btn {
  opacity: 0;
  background: none;
  border: 1px solid transparent;
  color: var(--ink-secondary);
  cursor: pointer;
  font-size: 0.78rem;
  padding: 0 0.3rem;
  margin-left: 0.3rem;
  border-radius: 3px;
  transition: opacity 0.15s ease, color 0.15s ease, border-color 0.15s ease;
  vertical-align: middle;
}

.turn-narrator:hover .rewind-btn {
  opacity: 1;
}

.turn-narrator:focus-within .rewind-btn,
.rewind-btn:focus-visible {
  opacity: 1;
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

.rewind-btn:hover {
  color: var(--accent);
  border-color: var(--accent-border, var(--accent));
}

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

/* ---- Turn stream loading indicator ---- */

.turn-stream-loading {
  text-align: center;
  padding: 0.5rem;
  color: var(--ink-secondary);
}

/* ---- Song player ---- */

.song-player {
  border-top: 1px solid var(--line);
  padding: 0.5rem;
  margin-top: auto;
}

.song-player-header {
  display: flex;
  align-items: center;
  gap: 0.35rem;
  margin-bottom: 0.3rem;
}

.song-player-title {
  flex: 1;
  font-size: 0.8rem;
  font-weight: 600;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.song-nav-btn {
  background: none;
  border: 1px solid var(--line);
  border-radius: 4px;
  padding: 0.15rem 0.45rem;
  cursor: pointer;
  font-size: 0.7rem;
  color: var(--ink-secondary);
  line-height: 1;
}

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

.song-nav-btn:disabled {
  opacity: 0.3;
  cursor: default;
}

.song-sender,
.song-caption {
  display: block;
  font-size: 0.72rem;
  color: var(--ink-secondary);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  margin-bottom: 0.2rem;
}

.song-caption {
  font-style: italic;
}

.song-embed-wrap {
  position: relative;
  width: 100%;
  padding-bottom: 56.25%; /* 16:9 */
  height: 0;
  overflow: hidden;
  border-radius: 4px;
}

.song-embed {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
}

.song-counter {
  display: block;
  text-align: center;
  font-size: 0.68rem;
  color: var(--ink-secondary);
  margin-top: 0.25rem;
}

/* ---- Sidebar toggle (hidden on desktop) ---- */

.sidebar-toggle {
  display: none;
  background: none;
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  padding: 0.3rem 0.55rem;
  font-size: 1.15rem;
  cursor: pointer;
  line-height: 1;
  color: var(--ink);
  position: relative;
  z-index: 1003;
}

.topbar-left {
  display: flex;
  align-items: center;
  gap: 0.6rem;
}

.sidebar-backdrop {
  display: none;
}

/* ---- Responsive ---- */

@media (max-width: 768px) {
  .sidebar-toggle {
    display: block;
  }

  .layout {
    grid-template-columns: 1fr;
    height: calc(100dvh - 58px);
    min-height: calc(100dvh - 58px);
    padding: 0.6rem;
    gap: 0.6rem;
    overflow: hidden;
  }

  /* Sidebar becomes a fixed overlay drawer */
  .sidebar {
    position: fixed;
    top: 58px;
    left: 0;
    bottom: 0;
    width: 300px;
    max-width: 85vw;
    max-height: calc(100dvh - 58px);
    z-index: 1000;
    transform: translateX(-100%);
    transition: transform 0.25s ease;
    border-radius: 0;
    border-right: 1px solid var(--line);
    box-shadow: none;
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
  }

  .sidebar.sidebar-open {
    transform: translateX(0);
    box-shadow: 4px 0 24px rgba(0, 0, 0, 0.25);
  }

  .sidebar-backdrop {
    display: block;
    position: fixed;
    top: 58px;
    right: 0;
    bottom: 0;
    left: 0;
    z-index: 999;
    background: rgba(0, 0, 0, 0.4);
  }

  /* Main column takes full viewport height */
  .main-column {
    min-height: 0;
    height: calc(100dvh - 80px);
    max-height: calc(100dvh - 80px);
    display: flex;
    flex-direction: column;
    overflow: hidden;
  }

  .turn-stream {
    flex: 1 1 auto;
    height: auto;
    min-height: 0;
    margin-bottom: 0;
    padding-bottom: 0.4rem;
  }

  .turn-stream-layout,
  .turn-stream-layout.turn-search-open {
    grid-template-columns: minmax(0, 1fr);
  }

  .turn-search-rail {
    max-height: 35dvh;
  }

  .pins-overlay {
    top: 64px;
    right: 0.6rem;
    left: 0.6rem;
  }

  .pins-overlay-card {
    width: auto;
    max-height: 55dvh;
  }

  .section-head,
  .campaign-summary-bar,
  .action-bar-wrapper,
  .status,
  .error {
    flex-shrink: 0;
  }

  .section-head {
    margin-bottom: 0.3rem;
  }

  .action-bar-wrapper {
    position: sticky;
    bottom: var(--visual-viewport-bottom-gap, 0px);
    z-index: 6;
    margin-top: auto;
    margin-bottom: 0;
    padding-top: 0.2rem;
    padding-bottom: calc(0.2rem + env(safe-area-inset-bottom));
    background: var(--panel);
  }

  /* Compact topbar */
  .topbar {
    padding: 0.5rem 0.75rem;
  }

  .topbar h1 {
    font-size: 0.95rem;
  }

  /* Compact action bar on mobile */
  .action-bar-avatar {
    display: none;
  }

  .action-bar-wrapper {
    gap: 0.4rem;
  }

  .action-bar-column {
    gap: 0;
  }

  .char-hud {
    display: none !important;
  }

  .status,
  .error {
    margin: 0;
    padding: 0 0.1rem;
    font-size: 0.78rem;
  }

  /* Settings drawer full width */
  .settings-overlay {
    top: 48px;
  }

  .settings-drawer {
    width: 100vw;
    height: calc(100vh - 48px);
  }

  /* Modals */
  .modal-panel {
    max-width: 95vw;
    max-height: 90vh;
    margin: 0.5rem;
  }

  /* Song player compact */
  .song-player {
    padding: 0.4rem;
  }

  .song-embed-wrap {
    padding-bottom: 56.25%;
  }
}
