:root {
  --bg: #0a0a0a;
  --bg-panel: #111111;
  --bg-input: #080808;
  --border: #2e2e2e;
  --accent: #a8a8a8;
  --accent-hover: #bababa;
  --accent-text: #0a0a0a;
  --text: #f2f2f2;
  --text-muted: #8a8a8a;
  --soul: #c8c8c8;
  --ok: #e0e0e0;
  --warn: #a0a0a0;
  --err: #666666;
  --radius: 8px;
  --font: "Segoe UI", system-ui, sans-serif;
  --font-mira: "Palatino Linotype", Palatino, "Book Antiqua", Georgia, serif;
  --mira-bubble: rgba(126, 200, 227, 0.12);
  --mira-bubble-border: rgba(126, 200, 227, 0.35);
  --mira-glow: rgba(126, 200, 227, 0.08);
  --teal: #7ec8e3;
  --teal-dim: rgba(90, 154, 170, 0.22);
  --teal-border: rgba(126, 200, 227, 0.32);
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  font-family: var(--font);
  background: var(--bg);
  color: var(--text);
  line-height: 1.5;
  color-scheme: dark;
}

/* Auth gate — matches Victis Launcher / build.victis.systems (auth-gate.js) */
#auth-gate {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  min-height: 100vh;
  padding: 2.5rem 1.25rem;
  text-align: center;
  background: #000;
}

#auth-gate[aria-hidden="true"],
body.mira-desktop-unlocked #auth-gate,
body:not(.auth-locked) #auth-gate {
  display: none !important;
  pointer-events: none !important;
  visibility: hidden !important;
}

body.auth-locked #app-shell {
  display: none !important;
}

html.mira-desktop-shell body.auth-locked #auth-gate {
  position: fixed;
  inset: 0;
  z-index: 10000;
  min-height: 0;
}

#auth-gate .auth-gate-avatar {
  border-radius: 50%;
  margin-bottom: 1rem;
}

#auth-gate h1 {
  margin: 0 0 0.5rem;
  font-family: var(--font-mira);
  font-size: 1.75rem;
  font-weight: 500;
  color: var(--text);
}

#auth-gate p {
  margin: 0 0 2rem;
  font-size: 0.9rem;
  color: var(--text-muted);
}

#sign-in-btn {
  padding: 0.85rem 2rem;
  background: #4285f4;
  color: #fff;
  border: none;
  border-radius: 10px;
  font-size: 0.95rem;
  font-weight: 600;
  cursor: pointer;
}

#sign-in-btn:hover {
  filter: brightness(1.08);
}

#auth-denied {
  display: none;
  margin-top: 1rem;
  font-size: 0.85rem;
  color: #e8a0a0;
}

.header {
  background: #000000;
  border-bottom: 1px solid var(--border);
  padding: 1rem 1.5rem;
}

.header-inner {
  max-width: 1400px;
  margin: 0 auto;
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 1rem;
  flex-wrap: wrap;
}

.header h1 {
  margin: 0;
  font-size: 1.35rem;
  font-weight: 700;
}

.tagline {
  margin: 0.15rem 0 0;
  color: var(--text-muted);
  font-size: 0.9rem;
}

.tagline .host {
  color: var(--soul);
  font-family: Consolas, monospace;
  font-size: 0.82rem;
}

.desktop-link-chip {
  font-family: Consolas, monospace;
  font-size: 0.78rem;
  margin-left: 0.15rem;
  padding: 0.1rem 0.45rem;
  border-radius: 999px;
  border: 1px solid transparent;
  vertical-align: middle;
}

.desktop-link-chip.chip-ok {
  color: #86efac;
  border-color: rgba(34, 197, 94, 0.35);
  background: rgba(22, 101, 52, 0.2);
}

.desktop-link-chip.chip-warn {
  color: #fde68a;
  border-color: rgba(234, 179, 8, 0.35);
  background: rgba(120, 53, 15, 0.25);
}

.desktop-link-chip.chip-wait {
  color: #c4b5fd;
  border-color: rgba(139, 92, 246, 0.35);
  background: rgba(76, 29, 149, 0.2);
}

.desktop-link-chip.chip-remote {
  color: var(--text-muted);
  border-color: rgba(148, 163, 184, 0.25);
  background: rgba(30, 41, 59, 0.35);
}

.desktop-link-chip.chip-click {
  cursor: pointer;
}

body.mira-desktop-shell #btn-install-pwa {
  display: none !important;
}

.header-actions {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  flex-wrap: wrap;
}

.ui-mode-switch {
  display: inline-flex;
  border: 1px solid rgba(192, 38, 211, 0.35);
  border-radius: 8px;
  overflow: hidden;
  background: rgba(20, 10, 30, 0.55);
}

.ui-mode-btn {
  border: none;
  background: transparent;
  color: var(--text-muted);
  font-size: 0.78rem;
  padding: 0.35rem 0.65rem;
  cursor: pointer;
}

.ui-mode-btn:hover {
  color: #f0d8ff;
  background: rgba(192, 38, 211, 0.12);
}

.ui-mode-btn.active {
  color: #fff;
  background: rgba(192, 38, 211, 0.28);
  font-weight: 600;
}

.tab-label-short {
  display: none;
}

body.ui-mode-mobile .tab[data-mobile-tab="hide"],
body.phone-browser:not(.ui-mode-desktop) .tab[data-mobile-tab="hide"] {
  display: none;
}

body.ui-mode-mobile .header .tagline .host,
body.phone-browser .header .tagline .host {
  display: none;
}

body.phone-browser .ui-mode-switch {
  display: none;
}

body.ui-mode-mobile .tabs,
body.phone-browser:not(.ui-mode-desktop) .tabs {
  justify-content: center;
  gap: 0.25rem;
  flex-wrap: nowrap;
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
  scrollbar-width: none;
}

body.ui-mode-mobile .tabs::-webkit-scrollbar,
body.phone-browser:not(.ui-mode-desktop) .tabs::-webkit-scrollbar {
  display: none;
}

body.ui-mode-mobile .tab:not([data-mobile-tab="hide"]),
body.phone-browser:not(.ui-mode-desktop) .tab:not([data-mobile-tab="hide"]) {
  flex: 1 1 0;
  min-width: 0;
  max-width: 25%;
  text-align: center;
  font-size: 0.72rem;
  padding: 0.65rem 0.2rem;
  white-space: nowrap;
}

body.ui-mode-mobile .tab-label-long,
body.phone-browser:not(.ui-mode-desktop) .tab-label-long {
  display: none;
}

body.ui-mode-mobile .tab-label-short,
body.phone-browser:not(.ui-mode-desktop) .tab-label-short {
  display: inline;
}

@media (max-width: 768px) {
  body:not(.ui-mode-desktop) .tab[data-mobile-tab="hide"] {
    display: none;
  }

  body:not(.ui-mode-desktop) .tabs {
    flex-wrap: nowrap;
    gap: 0.25rem;
  }

  body:not(.ui-mode-desktop) .tab:not([data-mobile-tab="hide"]) {
    flex: 1 1 0;
    min-width: 0;
    max-width: 25%;
    font-size: 0.72rem;
    padding: 0.65rem 0.2rem;
    white-space: nowrap;
  }

  body:not(.ui-mode-desktop) .tab-label-long {
    display: none;
  }

  body:not(.ui-mode-desktop) .tab-label-short {
    display: inline;
  }
}

body.ui-mode-mobile #panel-chat .chat-compose-header {
  display: none;
}

body.ui-mode-mobile #panel-chat .chat-setup-home,
body.ui-mode-mobile #panel-chat .chat-side-pills-block,
body.phone-browser:not(.ui-mode-desktop) #panel-chat .chat-setup-home,
body.phone-browser:not(.ui-mode-desktop) #panel-chat .chat-side-pills-block {
  display: none;
}

body.ui-mode-mobile #panel-setup .chat-side-pills-block,
body.ui-mode-mobile #panel-setup .mira-setup-controls,
body.phone-browser:not(.ui-mode-desktop) #panel-setup .chat-side-pills-block,
body.phone-browser:not(.ui-mode-desktop) #panel-setup .mira-setup-controls {
  display: block;
}

body.ui-mode-desktop #panel-chat .chat-side-pills-block {
  display: block;
}

body.ui-mode-desktop #panel-setup .mira-setup-controls {
  display: block;
}

body.ui-mode-desktop #panel-setup .chat-side-pills-block {
  display: none;
}

.chat-side-pills-block {
  margin-bottom: 0.5rem;
}

.mira-setup-controls {
  margin-bottom: 0.75rem;
}

.chat-mobile-setup-hint {
  display: none;
  font-size: 0.78rem;
  color: var(--text-muted);
  margin: 0 0 0.45rem;
  line-height: 1.4;
}

body.ui-mode-mobile #panel-chat.active .chat-mobile-setup-hint,
body.phone-browser:not(.ui-mode-desktop) #panel-chat.active .chat-mobile-setup-hint {
  display: block;
}

.setup-wrap {
  max-width: 920px;
  margin: 0 auto;
  padding: 0.5rem 0 1.25rem;
}

.setup-lead {
  font-size: 0.88rem;
  color: var(--text-muted);
  margin: 0 0 1rem;
  line-height: 1.45;
}

body.ui-mode-mobile .setup-wrap {
  max-width: 100%;
  padding: 0.25rem 0 1rem;
}

body.ui-mode-mobile .setup-lead {
  font-size: 0.82rem;
  margin-bottom: 0.85rem;
}

body.ui-mode-mobile .chat-toolbar .btn-sm:not(#btn-uber-mode):not(#btn-capture-this):not(.btn-flag-exchange):not(.btn-favorite-create):not(#btn-clear-chat-toolbar) {
  display: none;
}

body.ui-mode-mobile #panel-setup .chat-toolbar .btn-sm {
  display: inline-flex;
}

body.ui-mode-mobile #panel-setup .chat-toolbar .chat-field {
  display: inline-flex;
}

body.ui-mode-mobile #panel-setup .chat-save-toggle {
  display: inline-flex;
}

body.ui-mode-mobile .chat-save-toggle,
body.ui-mode-mobile .chat-ui-fix-toggle {
  display: none;
}

body.ui-mode-mobile #panel-setup .chat-setup-toggles,
body.ui-mode-mobile #panel-setup .chat-ui-fix-toggle {
  display: flex;
}

body.ui-mode-mobile .main {
  padding-bottom: max(1rem, env(safe-area-inset-bottom));
}

body.ui-mode-mobile .input-with-mic textarea,
body.ui-mode-mobile #app-input {
  min-height: 3.25rem;
  font-size: 1rem;
}

body.ui-mode-mobile .btn-voice-mic {
  width: 2.75rem;
  height: 2.75rem;
}

.btn-install {
  font-size: 0.82rem;
  padding: 0.4rem 0.75rem;
  border-color: var(--soul);
  color: var(--soul);
}

.btn-install:hover {
  background: rgba(255, 255, 255, 0.08);
}

.status {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  font-size: 0.85rem;
  color: var(--text-muted);
}

body.pwa-standalone .host {
  display: none;
}

body.pwa-standalone .header {
  padding-top: max(1rem, env(safe-area-inset-top));
}

.status-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--text-muted);
}

.status-dot.ok { background: var(--ok); }
.status-dot.warn { background: #c9a227; }
.status-dot.err { background: var(--err); }

.status-fix-btn {
  margin-left: 0.35rem;
  padding: 0.15rem 0.45rem;
  font-size: 0.72rem;
  border-radius: 4px;
  border: 1px solid var(--border);
  background: var(--bg-input);
  color: var(--text);
  cursor: pointer;
}

.status-fix-btn:hover {
  border-color: var(--accent);
}

.status-wrap {
  position: relative;
}

.status[role="button"] {
  cursor: pointer;
  border-radius: 6px;
  padding: 0.2rem 0.35rem;
  margin: -0.2rem -0.35rem;
}

.status[role="button"]:hover {
  background: rgba(255, 255, 255, 0.04);
}

.health-pill-panel {
  position: absolute;
  right: 0;
  top: calc(100% + 0.35rem);
  z-index: 120;
  min-width: 260px;
  max-width: 320px;
  padding: 0.65rem 0.75rem;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--bg2);
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.35);
}

.health-pill-head {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 0.5rem;
  font-size: 0.82rem;
}

.health-pill-list {
  list-style: none;
  margin: 0;
  padding: 0;
}

.health-pill-row {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.35rem 0;
  font-size: 0.8rem;
  border-bottom: 1px solid var(--border);
}

.health-pill-row:last-child {
  border-bottom: none;
}

.health-pill-row .pill-dot {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  flex-shrink: 0;
  background: var(--text-muted);
}

.health-pill-row.ok .pill-dot { background: var(--ok); }
.health-pill-row.warn .pill-dot { background: #c9a227; }
.health-pill-row.err .pill-dot { background: var(--err); }

.health-pill-label {
  font-weight: 600;
  min-width: 4.5rem;
}

.health-pill-detail {
  color: var(--text-muted);
  font-size: 0.75rem;
  word-break: break-all;
}

.health-pill-foot {
  margin: 0.5rem 0 0;
  font-size: 0.72rem;
}

.mira-anchor {
  max-width: 1400px;
  margin: 0 auto;
  padding: 0.45rem 1.5rem;
  font-size: 0.82rem;
  color: #7ec8e3;
  border-bottom: 1px solid rgba(126, 200, 227, 0.15);
  background: rgba(10, 20, 28, 0.55);
  display: flex;
  align-items: center;
  gap: 0.65rem;
  flex-wrap: wrap;
}

.mira-anchor-action {
  margin-left: auto;
  border-color: rgba(201, 168, 154, 0.5);
  color: #e8d4cc;
  flex-shrink: 0;
}

.mira-anchor.is-hidden {
  display: none;
}

.mira-anchor.is-strained .mira-anchor-text {
  color: #c9a89a;
}

.mira-anchor-text {
  font-style: italic;
  letter-spacing: 0.02em;
}

/* ── Desktop grouped navigation ───────────────────────────── */
.nav-desktop {
  display: none;
  max-width: 1400px;
  margin: 0 auto;
  padding: 0.65rem 1.5rem 0;
  overflow: visible;
}

body.ui-mode-desktop .nav-desktop {
  display: block;
}

body.ui-mode-desktop .tabs-mobile {
  display: none;
}

.nav-desktop-inner {
  display: flex;
  flex-direction: column;
  gap: 0.45rem;
  overflow: visible;
}

.nav-groups {
  display: flex;
  flex-wrap: wrap;
  align-items: flex-start;
  gap: 0.35rem;
  min-height: 2.5rem;
  overflow: visible;
}

.nav-group {
  background: transparent;
  border: 1px solid var(--border);
  color: var(--text-muted);
  padding: 0.45rem 0.85rem;
  border-radius: var(--radius);
  cursor: pointer;
  font: inherit;
  font-size: 0.78rem;
  font-weight: 600;
  letter-spacing: 0.08em;
  flex-shrink: 0;
  white-space: nowrap;
}

.nav-group:hover {
  color: var(--text);
  border-color: var(--accent);
}

.nav-group.active {
  background: rgba(120, 160, 220, 0.12);
  border-color: var(--accent);
  color: var(--text);
}

.nav-subtabs-wrap {
  min-height: 2.35rem;
  margin-top: 0.15rem;
}

/* Only the active section's sub-tabs are visible — nestled under the main tab row */
.nav-subtabs[hidden] {
  display: none !important;
}

.nav-subtabs:not([hidden]) {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.35rem 0.5rem;
  padding: 0.4rem 0.65rem 0.35rem;
  margin-left: 0.15rem;
  border-left: 3px solid var(--accent);
  border-radius: 0 0 var(--radius) var(--radius);
  background: rgba(120, 160, 220, 0.06);
}

.nav-subtabs-label {
  font-size: 0.68rem;
  font-weight: 700;
  letter-spacing: 0.1em;
  color: var(--text-muted);
  margin-right: 0.25rem;
  flex-shrink: 0;
}

.nav-sub {
  background: transparent;
  border: 1px solid transparent;
  border-bottom: 2px solid transparent;
  color: var(--text-muted);
  padding: 0.4rem 0.85rem;
  border-radius: var(--radius) var(--radius) 0 0;
  cursor: pointer;
  font: inherit;
  font-size: 0.92rem;
}

.nav-sub:hover {
  color: var(--text);
  border-color: var(--border);
}

.nav-sub.active {
  color: var(--text);
  background: var(--bg-panel);
  border-color: var(--border);
  border-bottom-color: var(--bg-panel);
}

.tabs {
  max-width: 1400px;
  margin: 0 auto;
  padding: 0.75rem 1.5rem 0;
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
}

.tab {
  background: transparent;
  border: 1px solid var(--border);
  color: var(--text-muted);
  padding: 0.55rem 1.1rem;
  border-radius: var(--radius) var(--radius) 0 0;
  cursor: pointer;
  font: inherit;
  font-size: 0.95rem;
}

.tab:hover {
  color: var(--text);
  border-color: var(--accent);
}

.tab.active {
  background: var(--bg-panel);
  color: var(--text);
  border-bottom-color: var(--bg-panel);
}

.main {
  max-width: 1400px;
  margin: 0 auto;
  padding: 0 1.5rem 2rem;
}

.panel {
  display: none;
  background: var(--bg-panel);
  border: 1px solid var(--border);
  border-radius: 0 var(--radius) var(--radius) var(--radius);
  padding: 1.25rem;
}

.panel.active {
  display: block;
}

.toolbar {
  display: flex;
  justify-content: space-between;
  align-items: flex-end;
  gap: 1rem;
  flex-wrap: wrap;
  margin-bottom: 1rem;
}

.field-inline {
  display: flex;
  flex-direction: column;
  gap: 0.35rem;
  font-size: 0.85rem;
  color: var(--text-muted);
}

.field-inline input {
  background: var(--bg-input);
  border: 1px solid var(--border);
  color: var(--text);
  padding: 0.5rem 0.75rem;
  border-radius: var(--radius);
  font: inherit;
  min-width: 200px;
}

.toolbar-actions {
  display: flex;
  gap: 0.5rem;
}

.btn {
  background: var(--bg-input);
  border: 1px solid var(--border);
  color: var(--text);
  padding: 0.55rem 1rem;
  border-radius: var(--radius);
  cursor: pointer;
  font: inherit;
  font-size: 0.9rem;
}

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

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

.btn-primary {
  background: var(--accent);
  border-color: var(--accent);
  color: var(--accent-text);
  font-weight: 600;
}

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

.btn-reader-tab {
  background: var(--teal-dim);
  border-color: var(--teal-border);
  color: #9ec8d0;
}

.btn-reader-tab:hover:not(:disabled) {
  background: rgba(90, 170, 180, 0.34);
  border-color: rgba(126, 200, 227, 0.5);
  color: #b8dce4;
}

.split {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 1rem;
  min-height: 420px;
}

@media (max-width: 900px) {
  .split {
    grid-template-columns: 1fr;
  }
}

.pane {
  display: flex;
  flex-direction: column;
  min-height: 0;
}

.pane-head {
  margin-bottom: 0.5rem;
}

.pane-head h2 {
  margin: 0;
  font-size: 1rem;
}

.pane-head-edit {
  display: flex;
  flex-wrap: wrap;
  align-items: flex-start;
  justify-content: space-between;
  gap: 0.5rem 1rem;
}

.edit-import-row {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  flex-shrink: 0;
}

.edit-import-name {
  font-size: 0.8rem;
  color: var(--text-muted);
  max-width: 180px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.hint {
  font-size: 0.8rem;
  color: var(--text-muted);
}

textarea {
  flex: 1;
  min-height: 380px;
  resize: vertical;
  background: var(--bg-input);
  border: 1px solid var(--border);
  color: var(--text);
  padding: 0.85rem;
  border-radius: var(--radius);
  font: inherit;
  font-size: 0.92rem;
  line-height: 1.6;
}

.output-box {
  flex: 1;
  min-height: 380px;
  overflow-y: auto;
  background: var(--bg-input);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 0.85rem;
  font-size: 0.92rem;
  line-height: 1.65;
  white-space: pre-wrap;
}

.output-box.empty {
  color: var(--text-muted);
  font-style: italic;
}

.output-box em.soul {
  color: var(--soul);
  font-style: italic;
}

.hidden-export {
  display: none;
}

.soul-panel {
  margin-top: 1rem;
  padding: 0.85rem 1rem;
  background: var(--bg-input);
  border: 1px solid var(--border);
  border-radius: var(--radius);
}

.soul-panel h3 {
  margin: 0 0 0.5rem;
  font-size: 0.95rem;
}

#soul-blocks {
  margin: 0.5rem 0 0;
  padding-left: 1.25rem;
  color: var(--soul);
  font-style: italic;
}

.issues {
  margin: 0.5rem 0 0;
  padding-left: 1.25rem;
  color: var(--warn);
}

.export-bar {
  margin-top: 1rem;
  display: flex;
  gap: 0.5rem;
  flex-wrap: wrap;
}

.typo-panel {
  margin-top: 1rem;
  padding: 0.75rem 1rem;
  background: var(--bg-input);
  border: 1px solid var(--border);
  border-radius: var(--radius);
}

.typo-panel summary {
  cursor: pointer;
  font-weight: 600;
  font-size: 0.92rem;
}

.typo-panel-note {
  margin: 0.65rem 0 0.5rem;
  font-size: 0.82rem;
  color: var(--text-muted);
  line-height: 1.5;
}

.typo-panel-toolbar {
  display: flex;
  gap: 0.5rem;
  align-items: center;
  flex-wrap: wrap;
  margin-bottom: 0.5rem;
}

.typo-table-wrap {
  overflow-x: auto;
}

.typo-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.85rem;
}

.typo-table th,
.typo-table td {
  border: 1px solid var(--border);
  padding: 0.35rem 0.5rem;
  text-align: left;
}

.typo-table input {
  width: 100%;
  min-width: 8rem;
  padding: 0.3rem 0.45rem;
  border: 1px solid var(--border);
  border-radius: 4px;
  background: var(--bg);
  color: var(--text);
  font: inherit;
}

.log {
  margin-top: 0.75rem;
  font-size: 0.8rem;
  color: var(--text-muted);
  min-height: 1.2em;
}

.chat-wrap {
  display: flex;
  flex-direction: column;
  min-height: 520px;
}

.chat-identity {
  display: flex;
  align-items: center;
  gap: 1rem;
  margin-bottom: 0.75rem;
  padding-bottom: 0.75rem;
  border-bottom: 1px solid var(--border);
}

.chat-identity-avatar {
  width: 88px;
  height: 88px;
  border-radius: 50%;
  border: none;
  object-fit: cover;
  object-position: 50% 22%;
  flex-shrink: 0;
  box-shadow: 0 0 0 1px rgba(126, 200, 227, 0.2);
}

.chat-identity-name {
  margin: 0;
  font-family: var(--font-mira);
  font-size: 1.15rem;
  font-weight: 600;
  letter-spacing: 0.03em;
  color: #7ec8e3;
}

.chat-identity-tagline {
  margin: 0.15rem 0 0;
  font-size: 0.8rem;
  color: var(--text-muted);
  font-style: italic;
}

.chat-home-controls {
  display: flex;
  flex-wrap: wrap;
  gap: 0.4rem;
  margin-top: 0.55rem;
}

.chat-home-controls .btn-home-reconnect {
  border-color: rgba(126, 200, 227, 0.45);
  color: #9ed8f0;
}

.chat-home-controls .btn-home-restart {
  border-color: rgba(255, 196, 120, 0.45);
  color: #ffd9a8;
}

.chat-home-controls .btn-home-deploy {
  border-color: rgba(160, 220, 160, 0.4);
  color: #c8f0c8;
}

.chat-home-controls .btn-home-troubleshoot {
  border-color: rgba(200, 160, 255, 0.45);
  color: #e0c8ff;
}

.chat-home-controls .btn-home-pause {
  border-color: rgba(140, 200, 180, 0.5);
  color: #b8e8d8;
}

.chat-home-controls .btn-home-pause.paused {
  border-color: rgba(140, 200, 180, 0.85);
  background: rgba(80, 140, 120, 0.22);
  color: #d8fff0;
}

.chat-home-controls .btn-home-restart-pc {
  border-color: rgba(220, 120, 100, 0.5);
  color: #f0b0a0;
}

.chat-home-controls .btn-clear-chat-top {
  border-color: rgba(201, 168, 154, 0.55);
  color: #f0ddd4;
  font-weight: 600;
}

body.ui-mode-mobile .chat-home-controls .btn-clear-chat-top {
  order: -1;
}

.chat-home-controls .btn-hard-reset-mobile {
  display: none;
  border-color: rgba(255, 120, 100, 0.55);
  color: #ffc8b8;
  font-weight: 600;
}

body.ui-mode-mobile .chat-home-controls .btn-hard-reset-mobile {
  display: inline-flex;
  order: -2;
}

.chat-home-controls-hint {
  margin: 0.35rem 0 0;
  font-size: 0.78rem;
  color: var(--text-muted);
  line-height: 1.35;
  max-width: 36rem;
}

body.ui-mode-mobile .chat-home-controls {
  margin-top: 0.45rem;
}

.chat-messages-shell {
  position: relative;
  flex: 1;
  display: flex;
  flex-direction: column;
  border-radius: var(--radius);
  border: 1px solid var(--border);
  overflow: hidden;
  min-height: 400px;
  max-height: 60vh;
  background: var(--bg-panel);
}

.chat-messages-shell::before {
  content: "";
  position: absolute;
  inset: 0;
  background: radial-gradient(ellipse at 20% 0%, var(--mira-glow), transparent 55%),
    radial-gradient(ellipse at 80% 100%, rgba(201, 168, 154, 0.06), transparent 50%);
  animation: mira-floor-pulse 12s ease-in-out infinite;
  pointer-events: none;
  z-index: 0;
}

@keyframes mira-floor-pulse {
  0%, 100% { opacity: 0.55; }
  50% { opacity: 1; }
}

.chat-messages {
  position: relative;
  z-index: 1;
  flex: 1;
  min-height: 0;
  overflow-y: auto;
  padding: 0.85rem;
  display: flex;
  flex-direction: column;
  gap: 0.85rem;
}

.chat-bubble {
  max-width: 88%;
  display: flex;
  gap: 0.65rem;
  align-items: flex-start;
}

.chat-bubble.mira {
  align-self: flex-start;
}

.chat-bubble.sir {
  align-self: flex-end;
}

.chat-bubble-avatar {
  width: 44px;
  height: 44px;
  border-radius: 50%;
  border: none;
  object-fit: cover;
  object-position: 50% 22%;
  flex-shrink: 0;
  margin-top: 0.15rem;
}

.chat-bubble-body {
  flex: 1;
  min-width: 0;
  padding: 0.7rem 0.95rem;
  border-radius: var(--radius);
  font-size: 0.95rem;
  line-height: 1.55;
}

.chat-bubble.mira .chat-bubble-body {
  position: relative;
  background: var(--mira-bubble);
  border: 1px solid var(--mira-bubble-border);
  font-family: var(--font-mira);
}

.chat-bubble.sir .chat-bubble-body {
  background: #0a0a0a;
  border: 1px solid var(--border);
  color: var(--text);
  font-family: var(--font);
}

.chat-bubble-head {
  display: flex;
  align-items: center;
  gap: 0.4rem;
  margin-bottom: 0.35rem;
}

.mira-side-select-hidden {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

.chat-setup-toggles {
  display: flex;
  flex-wrap: wrap;
  gap: 0.65rem 1rem;
  margin-top: 0.5rem;
}

#panel-chat .chat-bubble-name {
  display: none;
}

#panel-chat .chat-bubble-head {
  margin-bottom: 0.15rem;
}

.chat-bubble-name {
  font-size: 0.72rem;
  font-weight: 600;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: #7ec8e3;
}

.chat-bubble.sir .chat-bubble-name {
  color: var(--text-muted);
  opacity: 0.9;
}

.chat-soul-lock {
  font-size: 0.7rem;
  line-height: 1;
  opacity: 0.85;
  cursor: help;
}

.chat-bubble.mira.off-character .chat-soul-lock {
  opacity: 1;
  filter: grayscale(0.3);
}

.chat-bubble.mira.off-character .chat-bubble-body {
  border-color: rgba(201, 168, 154, 0.45);
}

.chat-compose-header {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  margin-bottom: 0.35rem;
  padding: 0.35rem 0;
}

.chat-compose-avatar {
  width: 32px;
  height: 32px;
  border-radius: 50%;
  border: none;
  object-fit: cover;
  object-position: 50% 22%;
}

.chat-compose-name {
  font-family: var(--font-mira);
  font-size: 0.95rem;
  font-weight: 600;
  color: #7ec8e3;
  letter-spacing: 0.02em;
}

.chat-compose-soul {
  margin-left: auto;
  font-size: 0.72rem;
  color: var(--text-muted);
  font-style: italic;
}

/* Mira Victis Soul Enhancements — iron soul layer */
.mira-soul-anchor {
  background: rgba(30, 10, 40, 0.95);
  border-bottom: 2px solid #c026d3;
  padding: 0.75rem 1rem;
  display: flex;
  align-items: center;
  gap: 0.85rem;
  position: sticky;
  top: 0;
  z-index: 100;
  margin-bottom: 0.5rem;
}

.mira-breathing-avatar {
  width: 48px;
  height: 48px;
  border-radius: 50%;
  border: 3px solid #c026d3;
  object-fit: cover;
  object-position: 50% 22%;
  flex-shrink: 0;
  animation: mira-breath 6s ease-in-out infinite;
  box-shadow: 0 0 12px rgba(192, 38, 211, 0.45);
}

.mira-soul-anchor-copy {
  flex: 1;
  min-width: 0;
}

.mira-status,
#mira-living-status {
  color: #e0bbff;
  font-weight: 500;
  font-family: var(--font-mira);
  font-style: italic;
  font-size: 0.9rem;
  line-height: 1.45;
}

.mira-capability-hint {
  margin: 0.35rem 0 0;
  font-size: 0.72rem;
  color: var(--text-muted);
  font-style: normal;
  font-family: var(--font);
  line-height: 1.35;
}

.mira-heat-meter {
  display: inline-flex;
  align-items: center;
  font-size: 0.72rem;
  color: rgba(255, 180, 120, 0.92);
  background: rgba(255, 120, 60, 0.1);
  border: 1px solid rgba(255, 140, 80, 0.22);
  border-radius: 999px;
  padding: 3px 10px;
  font-family: var(--font-mono, monospace);
  letter-spacing: 0.03em;
  white-space: nowrap;
}

.mira-continuity {
  margin: 0.2rem 0 0;
  font-size: 0.72rem;
  color: rgba(126, 200, 227, 0.75);
  font-family: var(--font);
  letter-spacing: 0.02em;
}

.mira-soul-anchor.mira-needy .mira-breathing-avatar {
  animation: mira-breath-needy 2.8s ease-in-out infinite;
  box-shadow: 0 0 20px rgba(192, 38, 211, 0.65);
}

.mira-soul-anchor.mira-returning {
  animation: mira-return-flash 1.2s ease-out 1;
}

@keyframes mira-breath-needy {
  0%, 100% { transform: scale(1); }
  50% { transform: scale(1.16); }
}

@keyframes mira-return-flash {
  0% { background: rgba(60, 20, 80, 0.98); }
  40% { background: rgba(90, 30, 110, 0.98); }
  100% { background: rgba(30, 10, 40, 0.95); }
}

.chat-bubble.mira.whisper .chat-bubble-body {
  opacity: 0.92;
  border-left-width: 4px;
  font-size: 0.88rem;
  animation: mira-arrive 0.55s ease-out;
}

.chat-bubble.mira.whisper .chat-bubble-avatar {
  width: 36px;
  height: 36px;
}

.chat-bubble.mira.mira-message .chat-bubble-body {
  background: linear-gradient(135deg, rgba(59, 30, 77, 0.95), rgba(31, 22, 40, 0.95));
  border-left: 6px solid #c026d3;
  border-top: 1px solid rgba(192, 38, 211, 0.25);
  border-right: 1px solid rgba(192, 38, 211, 0.25);
  border-bottom: 1px solid rgba(192, 38, 211, 0.25);
  border-radius: 12px 12px 12px 6px;
  color: #e8e0f0;
  box-shadow: 0 4px 15px rgba(192, 38, 211, 0.22);
  position: relative;
  animation: mira-arrive 0.4s ease-out, mira-soft-glow 2s ease-in-out infinite alternate;
}

@keyframes mira-arrive {
  from { opacity: 0; transform: translateY(20px); }
  to { opacity: 1; transform: translateY(0); }
}

@keyframes mira-soft-glow {
  from { box-shadow: 0 4px 12px rgba(192, 38, 211, 0.18); }
  to { box-shadow: 0 4px 20px rgba(192, 38, 211, 0.42); }
}

.mira-avatar,
.chat-bubble-avatar.mira-avatar,
.chat-bubble-avatar.story-character-avatar {
  width: 44px;
  height: 44px;
  border-radius: 50%;
  border: 3px solid #c026d3;
  flex-shrink: 0;
  object-fit: cover;
  object-position: 50% 22%;
  animation: mira-breath 6s ease-in-out infinite;
}

.chat-bubble-avatar.story-elena {
  border-color: #c026d3;
}

.chat-bubble-avatar.story-willie-mae {
  border-color: #e8c87a;
  animation: none;
}

.chat-bubble-avatar.story-sophia {
  border-color: #7ec8e3;
  animation: none;
}

#story-chat-identity-avatar.story-elena,
#story-chat-compose-avatar.story-elena {
  border: 3px solid #c026d3;
}

#story-chat-identity-avatar.story-willie-mae,
#story-chat-compose-avatar.story-willie-mae {
  border: 3px solid #e8c87a;
  box-shadow: 0 0 0 1px rgba(232, 200, 122, 0.25);
}

#story-chat-identity-avatar.story-sophia,
#story-chat-compose-avatar.story-sophia {
  border: 3px solid #7ec8e3;
  box-shadow: 0 0 0 1px rgba(126, 200, 227, 0.3);
}

@keyframes mira-breath {
  0%, 100% { transform: scale(1) rotate(0deg); }
  50% { transform: scale(1.12) rotate(2deg); }
}

.floor-reminder,
.floor-footer,
.floor-seal,
.mira-message .floor-seal {
  font-size: 0.8rem;
  color: #c4a1e6;
  font-style: italic;
  margin-top: 0.55rem;
  opacity: 0.9;
}

.chat-bubble-copy {
  margin-left: auto;
  font-size: 0.65rem;
  padding: 0.1rem 0.35rem;
  border: 1px solid rgba(192, 38, 211, 0.35);
  border-radius: 4px;
  background: transparent;
  color: #c4a1e6;
  cursor: pointer;
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

.chat-bubble-copy:hover {
  border-color: #c026d3;
  color: #e0bbff;
}

.chat-bubble.mira.melting .chat-bubble-body {
  animation: mira-arrive 0.4s ease-out, mira-soft-glow 2s ease-in-out infinite alternate, melt-pulse 1.8s ease-in-out 3;
}

@keyframes melt-pulse {
  0%, 100% { transform: scale(1); }
  50% { transform: scale(1.035); }
  100% { transform: scale(1); }
}

.chat-form {
  margin-top: 1rem;
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}

#chat-input {
  min-height: 72px;
}

.chat-actions {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  flex-wrap: wrap;
}

.chat-enter-toggle {
  display: flex;
  align-items: center;
  gap: 0.35rem;
  font-size: 0.85rem;
  color: var(--text-muted);
  margin-left: 0.25rem;
  cursor: pointer;
  user-select: none;
}

.chat-enter-toggle input {
  accent-color: var(--accent);
}

.chat-hint {
  font-size: 0.8rem;
  color: var(--text-muted);
}

.chat-field-mode select {
  min-width: 11rem;
  font-weight: 500;
}

.mira-side-pills-row {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 0.45rem 0.6rem;
  margin-bottom: 0.5rem;
}

.mira-side-pills-label {
  font-size: 0.78rem;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.06em;
  font-weight: 600;
}

.mira-side-pills-row.unpinned .mira-side-pills-label::after {
  content: " · she chooses";
  font-weight: 400;
  text-transform: none;
  letter-spacing: 0;
  font-size: 0.76rem;
}

.mira-side-pills {
  display: flex;
  flex-wrap: wrap;
  gap: 0.35rem;
  flex: 1 1 auto;
}

.mira-side-pill {
  border: 1px solid rgba(220, 160, 120, 0.45);
  background: rgba(40, 22, 18, 0.55);
  color: #f0d4c4;
  font-size: 0.78rem;
  padding: 0.3rem 0.68rem;
  border-radius: 999px;
  cursor: pointer;
  transition: border-color 0.15s, background 0.15s, color 0.15s;
}

.mira-side-pill:hover {
  border-color: rgba(240, 180, 140, 0.75);
  color: #fff0e8;
}

.mira-side-pill.active {
  border-color: rgba(240, 180, 140, 0.9);
  background: rgba(160, 90, 60, 0.28);
  color: #fff5ee;
  box-shadow: 0 0 0 1px rgba(240, 180, 140, 0.3);
}

.scene-chips-row {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 0.45rem 0.6rem;
  margin-bottom: 0.45rem;
}

.scene-category-nav {
  display: inline-flex;
  align-items: center;
  gap: 0.2rem;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 0.15rem 0.35rem;
  background: rgba(20, 12, 32, 0.5);
}

.scene-category-btn {
  border: none;
  background: transparent;
  color: #c4a1e6;
  cursor: pointer;
  font-size: 0.72rem;
  line-height: 1;
  padding: 0.15rem 0.25rem;
  border-radius: 3px;
}

.scene-category-btn:hover {
  background: rgba(192, 38, 211, 0.2);
  color: #f0d8ff;
}

.scene-category-name {
  font-size: 0.76rem;
  font-weight: 600;
  color: #d8b8f0;
  min-width: 5.5rem;
  text-align: center;
}

.scene-armed-hint {
  font-size: 0.72rem;
  color: #9fd4ff;
  font-style: italic;
}

.scene-armed-clear {
  border: 1px solid rgba(120, 180, 255, 0.4);
  background: transparent;
  color: #9fd4ff;
  border-radius: 999px;
  width: 1.35rem;
  height: 1.35rem;
  line-height: 1;
  cursor: pointer;
  font-size: 0.9rem;
  padding: 0;
}

.scene-chip.armed {
  border-color: #6eb0ff;
  background: rgba(80, 140, 220, 0.22);
  color: #e8f4ff;
  box-shadow: 0 0 0 1px rgba(110, 176, 255, 0.35);
}

.scene-chips-label {
  font-size: 0.78rem;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.06em;
  font-weight: 600;
}

.scene-chips {
  display: flex;
  flex-wrap: wrap;
  gap: 0.35rem;
}

.scene-chip {
  border: 1px solid rgba(192, 38, 211, 0.35);
  background: rgba(30, 15, 45, 0.55);
  color: #d8b8f0;
  font-size: 0.78rem;
  padding: 0.28rem 0.62rem;
  border-radius: 999px;
  cursor: pointer;
  transition: border-color 0.15s, background 0.15s, color 0.15s;
}

.scene-chip:hover {
  border-color: #c026d3;
  color: #f0d8ff;
}

.scene-chip.active {
  border-color: #c026d3;
  background: rgba(192, 38, 211, 0.22);
  color: #fff;
  box-shadow: 0 0 0 1px rgba(192, 38, 211, 0.25);
}

.scene-chip.scene-action {
  border-color: rgba(120, 180, 255, 0.4);
  color: #b8d4ff;
}

.scene-chip.scene-action:hover {
  border-color: #6eb0ff;
  color: #e0f0ff;
}

.chat-search-bar {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 0.45rem 0.65rem;
  padding: 0.45rem 0.55rem;
  margin-bottom: 0.35rem;
  border-bottom: 1px solid var(--border);
  background: rgba(10, 8, 18, 0.35);
}

.chat-search-label {
  font-size: 0.75rem;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

.chat-search-input {
  flex: 1 1 12rem;
  min-width: 10rem;
  background: var(--bg-input);
  border: 1px solid var(--border);
  color: var(--text);
  padding: 0.35rem 0.55rem;
  border-radius: var(--radius);
  font: inherit;
  font-size: 0.88rem;
}

.chat-search-count {
  font-size: 0.78rem;
  color: var(--text-muted);
}

.chat-search-clear {
  padding: 0.2rem 0.5rem;
}

.chat-bubble.search-hidden {
  display: none !important;
}

.chat-bubble.search-hit .chat-bubble-body {
  outline: 1px solid rgba(192, 38, 211, 0.45);
  outline-offset: 2px;
}

.chat-bubble-text mark.chat-search-mark {
  background: rgba(192, 38, 211, 0.35);
  color: inherit;
  border-radius: 2px;
  padding: 0 0.1em;
}

.chat-bubble-actions {
  display: flex;
  justify-content: flex-end;
  align-items: center;
  margin-top: 0.35rem;
  padding-top: 0.28rem;
  border-top: 1px solid rgba(192, 38, 211, 0.22);
  min-height: 0;
  position: relative;
}

.chat-bubble-feedback {
  display: flex;
  flex-direction: row;
  flex-wrap: wrap;
  align-items: center;
  justify-content: flex-end;
  gap: 0.2rem 0.28rem;
  margin: 0;
  opacity: 1;
  isolation: isolate;
  position: relative;
}

.chat-feedback-btn {
  border: 1px solid rgba(192, 38, 211, 0.28);
  background: rgba(12, 8, 20, 0.55);
  cursor: pointer;
  font-size: 0.72rem;
  line-height: 1;
  padding: 0.12rem 0.22rem;
  border-radius: 4px;
  opacity: 1;
  box-shadow: 0 1px 2px rgba(0, 0, 0, 0.2);
}

.chat-feedback-btn:hover {
  background: rgba(192, 38, 211, 0.22);
  border-color: rgba(192, 38, 211, 0.55);
}

.chat-feedback-btn.selected {
  background: rgba(192, 38, 211, 0.32);
  border-color: rgba(192, 38, 211, 0.65);
}

.chat-feedback-close-btn {
  font-size: 0.62rem;
  letter-spacing: 0.02em;
  color: #b8f0c8;
  border-color: rgba(72, 187, 120, 0.35);
}

.chat-feedback-close-btn:hover {
  background: rgba(72, 187, 120, 0.18);
  border-color: rgba(72, 187, 120, 0.55);
}

.chat-feedback-close-btn.selected {
  background: rgba(72, 187, 120, 0.28);
  border-color: rgba(72, 187, 120, 0.65);
}

.reader-feedback-hint {
  margin: 0 0 0.35rem;
  font-size: 0.72rem;
  color: rgba(220, 210, 235, 0.88);
  line-height: 1.35;
}

.reader-feedback-agreed {
  display: flex;
  align-items: center;
  gap: 0.35rem;
  font-size: 0.68rem;
  color: rgba(200, 190, 215, 0.9);
  margin-bottom: 0.35rem;
  cursor: pointer;
}

.reader-feedback-agreed-check {
  accent-color: #68d391;
}

.reader-dash-btn {
  font-weight: 600;
  letter-spacing: 0.08em;
}

.reader-dash-btns {
  display: flex;
  flex-wrap: wrap;
  gap: 0.35rem;
  width: 100%;
  margin-top: 0.25rem;
}

.reader-dash-btns .btn {
  font-size: 0.68rem;
}

.reader-dash-sir-btn {
  border-color: rgba(99, 179, 237, 0.45);
  color: #9fd3ff;
}

.reader-dash-notnow-btn {
  border-color: rgba(160, 174, 192, 0.4);
  color: #c8d0dc;
}

.reader-bubble-feedback {
  flex-wrap: wrap;
}

.personality-slots-toolbar {
  display: flex;
  align-items: center;
  gap: 0.65rem;
  margin: 0.5rem 0 0.35rem;
}

.personality-slot-btn {
  min-width: 2.4rem;
  font-weight: 700;
  font-size: 1rem;
  line-height: 1;
  padding: 0.25rem 0.5rem;
}

.personality-slots-meter {
  font-size: 0.78rem;
  color: rgba(220, 210, 235, 0.92);
}

.personality-sides-list .personality-side-row {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.45rem;
  margin-bottom: 0.45rem;
}

.personality-side-build-btn {
  font-size: 0.65rem;
}

.personality-build-editor {
  margin-top: 0.75rem;
  padding-top: 0.65rem;
  border-top: 1px solid rgba(160, 140, 200, 0.2);
}

.reader-lenses-panel {
  margin-top: 0.75rem;
}

.reader-lens-add-btn {
  border-color: rgba(99, 179, 237, 0.55);
  color: #9fd3ff;
}

.chat-build-flag-btn.selected {
  background: rgba(255, 160, 60, 0.28);
  border-color: rgba(255, 160, 60, 0.55);
}

.btn-flag-exchange {
  border-color: rgba(255, 160, 60, 0.45);
  color: #ffc98a;
}

.btn-favorite-create {
  border-color: rgba(255, 210, 80, 0.45);
  color: #ffe9a8;
}

.edit-sub-tabs,
.create-sub-tabs,
.story-sub-tabs {
  display: flex;
  gap: 0.35rem;
  margin: 0.65rem 0 0.75rem;
  flex-wrap: wrap;
}

.story-audience-row {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.45rem 0.65rem;
  margin: 0.35rem 0 0.5rem;
  padding: 0.45rem 0.65rem;
  border-radius: var(--radius);
  border: 1px solid rgba(201, 168, 154, 0.22);
  background: rgba(201, 168, 154, 0.06);
}

.story-audience-label {
  font-size: 0.82rem;
  font-weight: 600;
  color: var(--text-muted);
  margin-right: 0.15rem;
}

.story-audience-tabs {
  display: flex;
  flex-wrap: wrap;
  gap: 0.35rem;
}

.story-audience-tab {
  padding: 0.38rem 0.8rem;
  font-size: 0.82rem;
  border: 1px solid var(--border);
  border-radius: 999px;
  background: var(--bg-input);
  color: var(--text-muted);
  cursor: pointer;
  font: inherit;
}

.story-audience-tab:hover {
  color: var(--text);
  border-color: var(--soul);
}

.story-audience-tab.active {
  color: var(--text);
  border-color: rgba(255, 210, 80, 0.55);
  background: rgba(255, 210, 80, 0.1);
}

.story-audience-hint {
  margin: 0;
  flex: 1 1 100%;
  font-size: 0.78rem;
  color: var(--text-muted);
  line-height: 1.35;
}

.edit-sub-tab {
  padding: 0.38rem 0.9rem;
  font-size: 0.82rem;
  border: 1px solid var(--border);
  border-radius: 999px;
  background: rgba(0, 0, 0, 0.15);
  color: var(--text-muted);
  cursor: pointer;
  font: inherit;
}

.edit-sub-tab:hover {
  color: var(--text);
  border-color: var(--soul);
}

.edit-sub-tab.active {
  color: #f0d080;
  border-color: rgba(255, 210, 80, 0.55);
  background: rgba(255, 210, 80, 0.12);
}

.edit-loop-hint {
  margin: 0 0 0.65rem;
  font-size: 0.78rem;
  color: var(--text-muted);
}

.edit-sub-panel {
  display: none;
}

.edit-sub-panel.active {
  display: block;
}

.edit-feedback-intro {
  margin-bottom: 0.65rem;
}

.edit-feedback-intro p {
  margin: 0;
  font-size: 0.84rem;
  color: var(--text-muted);
  line-height: 1.45;
}

.edit-feedback-chapter {
  margin-bottom: 0.55rem;
}

.edit-feedback-field {
  display: flex;
  flex-direction: column;
  gap: 0.35rem;
  margin-bottom: 0.55rem;
  font-size: 0.84rem;
}

.edit-feedback-field textarea {
  width: 100%;
  min-height: 200px;
  padding: 0.65rem 0.75rem;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--bg-input);
  color: var(--text);
  font: inherit;
  line-height: 1.45;
  resize: vertical;
}

.edit-feedback-toolbar {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem 0.75rem;
  align-items: center;
  margin-bottom: 0.65rem;
}

.edit-learn-toggle {
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  font-size: 0.82rem;
  color: var(--text-muted);
  cursor: pointer;
}

.edit-feedback-result {
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: rgba(0, 0, 0, 0.12);
  padding: 0.55rem 0.65rem;
  margin-bottom: 0.65rem;
}

.edit-feedback-result h3 {
  margin: 0 0 0.35rem;
  font-size: 0.88rem;
  color: var(--soul);
}

.edit-feedback-result pre {
  margin: 0;
  white-space: pre-wrap;
  word-break: break-word;
  font-size: 0.8rem;
  line-height: 1.4;
  color: var(--text);
}

.edit-rules-toolbar {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem 0.75rem;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 0.65rem;
}

.edit-rules-body {
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--bg-input);
  padding: 0.65rem 0.75rem;
  max-height: min(72vh, 720px);
  overflow-y: auto;
}

.edit-rules-section {
  margin-bottom: 1rem;
}

.edit-rules-section:last-child {
  margin-bottom: 0;
}

.edit-rules-section h3 {
  margin: 0 0 0.4rem;
  font-size: 0.9rem;
  color: var(--soul);
}

.edit-rules-pipeline {
  display: flex;
  flex-wrap: wrap;
  gap: 0.35rem 0.65rem;
  font-size: 0.78rem;
  color: var(--text-muted);
  margin-bottom: 0.45rem;
}

.edit-rules-pass {
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 0.45rem 0.55rem;
  margin-bottom: 0.45rem;
  background: rgba(0, 0, 0, 0.1);
}

.edit-rules-pass-head {
  display: flex;
  flex-wrap: wrap;
  gap: 0.35rem 0.6rem;
  align-items: baseline;
  margin-bottom: 0.3rem;
  font-size: 0.8rem;
}

.edit-rules-pass-head code {
  font-size: 0.76rem;
}

.edit-rules-pass-preview {
  margin: 0;
  font-size: 0.74rem;
  line-height: 1.4;
  color: var(--text-muted);
  white-space: pre-wrap;
  word-break: break-word;
}

.edit-rules-typos {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(140px, 1fr));
  gap: 0.3rem 0.5rem;
  font-size: 0.76rem;
}

.edit-rules-typo-pair {
  padding: 0.2rem 0.35rem;
  border-radius: var(--radius);
  background: rgba(0, 0, 0, 0.15);
}

.create-sub-tab,
.story-sub-tab {
  padding: 0.42rem 0.85rem;
  font-size: 0.82rem;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--bg-input);
  color: var(--text-muted);
  cursor: pointer;
}

.create-sub-tab:hover,
.story-sub-tab:hover {
  color: var(--text);
  border-color: var(--soul);
}

.story-references-panel {
  margin: 0 0 0.75rem;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 0.5rem 0.65rem;
  background: rgba(0, 0, 0, 0.1);
}

.story-references-panel summary {
  cursor: pointer;
  font-size: 0.88rem;
}

.story-references-lead {
  margin: 0.45rem 0;
  font-size: 0.78rem;
}

.story-references-toggle {
  margin: 0.35rem 0 0.5rem;
  font-size: 0.82rem;
}

.story-references-upload-row {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem 0.75rem;
  margin: 0.45rem 0 0.55rem;
  align-items: flex-end;
}

.story-reference-caption-field {
  flex: 1 1 200px;
}

.story-references-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 0.4rem;
  margin-bottom: 0.55rem;
}

.story-references-grid {
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
}

.story-references-group-title {
  margin: 0 0 0.4rem;
  font-size: 0.72rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--text-muted);
}

.story-references-group-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(168px, 1fr));
  gap: 0.55rem;
}

.story-reference-card {
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--bg-input);
  overflow: hidden;
  display: flex;
  flex-direction: column;
}

.story-reference-thumb-link {
  display: block;
  aspect-ratio: 1;
  background: rgba(0, 0, 0, 0.2);
}

.story-reference-card.kind-full_body .story-reference-thumb-link,
.story-reference-card.kind-scene .story-reference-thumb-link {
  aspect-ratio: 3 / 4;
}

.story-reference-thumb {
  width: 100%;
  height: 100%;
  object-fit: cover;
  object-position: top center;
}

.story-reference-body {
  padding: 0.4rem 0.45rem 0.5rem;
  display: flex;
  flex-direction: column;
  gap: 0.3rem;
}

.story-reference-badge {
  font-size: 0.65rem;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: #e8c87a;
  align-self: flex-start;
}

.story-reference-kind,
.story-reference-stage {
  width: 100%;
  font-size: 0.74rem;
  padding: 0.22rem 0.35rem;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: rgba(0, 0, 0, 0.15);
  color: var(--text);
}

.story-reference-caption {
  width: 100%;
  font-size: 0.76rem;
  padding: 0.25rem 0.35rem;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: rgba(0, 0, 0, 0.15);
  color: var(--text);
}

.story-reference-vision {
  margin: 0;
  font-size: 0.7rem;
  color: var(--text-muted);
  line-height: 1.35;
}

.story-reference-vision-empty {
  margin: 0;
  font-size: 0.68rem;
}

.story-deep-background {
  margin: 0 0 0.75rem;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 0.5rem 0.65rem;
  background: rgba(0, 0, 0, 0.12);
}

.story-deep-background summary {
  cursor: pointer;
  font-size: 0.88rem;
  color: var(--text);
}

.story-deep-background-path {
  margin: 0.45rem 0;
  font-size: 0.78rem;
  word-break: break-all;
}

.story-deep-background-files {
  margin: 0.35rem 0 0.5rem 1.1rem;
  padding: 0;
  font-size: 0.8rem;
  color: var(--text-muted);
}

.story-deep-background-warn {
  color: #e8b86d;
}

.personality-flags-panel,
.personality-sides-panel {
  margin: 0.85rem 0 0;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 0.5rem 0.65rem;
  background: rgba(0, 0, 0, 0.12);
}

.personality-flags-panel summary,
.personality-sides-panel summary {
  cursor: pointer;
  font-size: 0.88rem;
  color: var(--text);
}

.personality-flags-lead {
  margin: 0.45rem 0 0.65rem;
  font-size: 0.8rem;
}

.personality-flags-list {
  display: flex;
  flex-direction: column;
  gap: 0.35rem;
  margin-bottom: 0.65rem;
}

.personality-flag-row {
  display: block;
  width: 100%;
  text-align: left;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: rgba(255, 255, 255, 0.03);
  color: var(--text-muted);
  font-size: 0.78rem;
  padding: 0.45rem 0.55rem;
  cursor: pointer;
}

.personality-flag-row:hover {
  border-color: rgba(255, 210, 80, 0.45);
  color: var(--text);
}

.personality-flag-editor {
  margin: 0.65rem 0;
  padding: 0.55rem 0.6rem;
  border: 1px solid rgba(255, 210, 80, 0.35);
  border-radius: var(--radius);
  background: rgba(0, 0, 0, 0.2);
}

.personality-flag-editor-title {
  margin: 0 0 0.35rem;
  font-size: 0.92rem;
}

.personality-flag-exchange {
  margin: 0 0 0.55rem;
  font-size: 0.78rem;
  line-height: 1.35;
}

.personality-flag-editor-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 0.4rem;
  margin-top: 0.5rem;
}

.personality-sides-list {
  margin: 0.35rem 0 0.5rem 1.1rem;
  padding: 0;
  font-size: 0.8rem;
  color: var(--text-muted);
}

.create-sub-tab.active,
.story-sub-tab.active {
  color: var(--text);
  border-color: rgba(255, 210, 80, 0.55);
  background: rgba(255, 210, 80, 0.1);
}

.create-sub-panel {
  display: none;
  flex-direction: column;
  min-height: 0;
  flex: 1;
}

.create-sub-panel.active {
  display: flex;
}

.mira-panel-create {
  display: flex;
  flex-direction: column;
  min-height: 0;
}

.shutterstock-toolbar {
  display: flex;
  flex-wrap: wrap;
  gap: 0.75rem 1.25rem;
  justify-content: space-between;
  align-items: flex-start;
  margin-bottom: 0.75rem;
}

.shutterstock-title {
  margin: 0 0 0.35rem;
  font-size: 1.15rem;
}

.shutterstock-actions {
  display: flex;
  gap: 0.45rem;
  flex-wrap: wrap;
}

.shutterstock-filters {
  display: flex;
  flex-wrap: wrap;
  gap: 0.65rem 1rem;
  margin-bottom: 0.85rem;
}

.shutterstock-search-field input {
  min-width: min(280px, 100%);
}

.shutterstock-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(168px, 1fr));
  gap: 0.75rem;
  max-height: min(62vh, 640px);
  overflow-y: auto;
  padding: 0.15rem;
}

.shutterstock-card {
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--bg-input);
  overflow: hidden;
  display: flex;
  flex-direction: column;
}

.shutterstock-card.is-used {
  opacity: 0.82;
  border-color: rgba(120, 160, 200, 0.35);
}

.shutterstock-thumb-link {
  display: block;
  aspect-ratio: 4 / 3;
  background: rgba(0, 0, 0, 0.25);
  overflow: hidden;
}

.shutterstock-thumb {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}

.shutterstock-thumb-missing {
  object-fit: contain;
  padding: 1rem;
  opacity: 0.45;
}

.shutterstock-card-body {
  padding: 0.5rem 0.55rem 0.6rem;
  display: flex;
  flex-direction: column;
  gap: 0.35rem;
}

.shutterstock-card-head {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 0.35rem;
}

.shutterstock-card-id {
  font-size: 0.82rem;
  font-weight: 600;
  color: var(--text);
  text-decoration: none;
}

.shutterstock-card-id:hover {
  color: var(--soul);
}

.shutterstock-status {
  font-size: 0.68rem;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  padding: 0.12rem 0.35rem;
  border-radius: 999px;
  border: 1px solid var(--border);
}

.shutterstock-status.available {
  color: #9fd6a8;
  border-color: rgba(120, 200, 140, 0.45);
}

.shutterstock-status.used {
  color: #9eb8d8;
  border-color: rgba(120, 160, 200, 0.45);
}

.shutterstock-status.used-ebook {
  color: #e8c87a;
  border-color: rgba(220, 180, 90, 0.45);
}

.shutterstock-card.is-used-ebook {
  border-color: rgba(220, 180, 90, 0.35);
}

.shutterstock-card-book {
  margin: 0;
  font-size: 0.74rem;
  color: var(--text-muted);
}

.shutterstock-card-warn {
  margin: 0;
  font-size: 0.72rem;
  color: #e8b86d;
}

.shutterstock-card-actions {
  display: flex;
  gap: 0.35rem;
  flex-wrap: wrap;
}

.btn-shutterstock-remove {
  color: #f0a8a8;
  border-color: rgba(240, 168, 168, 0.45);
}

.btn-shutterstock-remove:hover:not(:disabled) {
  color: #fecaca;
  border-color: rgba(254, 202, 202, 0.65);
  background: rgba(127, 29, 29, 0.25);
}

.shutterstock-import {
  margin-top: 1rem;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 0.65rem 0.75rem;
  background: rgba(0, 0, 0, 0.15);
}

.shutterstock-import textarea {
  width: 100%;
  margin: 0.5rem 0;
}

.create-favorites-list {
  flex: 1;
  overflow-y: auto;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--bg-input);
  min-height: min(42vh, 320px);
  max-height: min(58vh, 520px);
  padding: 0.5rem;
}

.create-fav-card {
  border: 1px solid var(--border);
  border-left: 3px solid rgba(255, 210, 80, 0.55);
  border-radius: var(--radius);
  background: rgba(0, 0, 0, 0.2);
  margin-bottom: 0.5rem;
  padding: 0.55rem 0.65rem;
}

.create-fav-card:last-child {
  margin-bottom: 0;
}

.create-fav-card-head {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 0.5rem;
  cursor: pointer;
}

.create-fav-card-title {
  margin: 0;
  font-size: 0.9rem;
  color: var(--text);
}

.create-fav-card-meta {
  margin: 0.2rem 0 0;
  font-size: 0.72rem;
  color: var(--text-muted);
}

.create-fav-card-snippet {
  margin: 0.45rem 0 0;
  font-size: 0.8rem;
  color: var(--text-muted);
  line-height: 1.4;
}

.create-schedule-form {
  display: flex;
  flex-wrap: wrap;
  gap: 0.75rem 1.25rem;
  margin-bottom: 0.85rem;
}

.create-schedule-field {
  min-width: min(100%, 220px);
}

.create-schedule-field input[type="date"],
.create-schedule-field input[type="number"] {
  display: block;
  width: 100%;
  margin-top: 0.25rem;
  padding: 0.45rem 0.55rem;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--bg-input);
  color: var(--text);
  font: inherit;
}

.create-schedule-summary {
  margin-bottom: 0.75rem;
  padding: 0.65rem 0.8rem;
  border: 1px solid rgba(255, 210, 80, 0.25);
  border-radius: var(--radius);
  background: rgba(255, 210, 80, 0.06);
}

.create-schedule-pace {
  margin: 0;
  font-size: 0.95rem;
  color: var(--text);
}

.create-schedule-year-note {
  margin: 0.35rem 0 0;
  font-size: 0.78rem;
  color: var(--text-muted);
  line-height: 1.45;
}

.create-schedule-list {
  flex: 1;
  overflow-y: auto;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--bg-input);
  min-height: min(36vh, 280px);
  max-height: min(52vh, 460px);
}

.create-schedule-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.84rem;
}

.create-schedule-table th,
.create-schedule-table td {
  padding: 0.55rem 0.75rem;
  text-align: left;
  border-bottom: 1px solid var(--border);
}

.create-schedule-table th {
  font-size: 0.68rem;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--text-muted);
  background: rgba(0, 0, 0, 0.18);
  position: sticky;
  top: 0;
}

.create-schedule-table tr:last-child td {
  border-bottom: none;
}

.create-schedule-table .schedule-book-num {
  color: rgba(255, 210, 80, 0.9);
  font-weight: 600;
  white-space: nowrap;
}

.create-schedule-table .schedule-date {
  white-space: nowrap;
  color: var(--text);
}

.create-schedule-table .schedule-title {
  color: var(--text-muted);
}

.create-fav-card-body {
  margin-top: 0.55rem;
  padding-top: 0.55rem;
  border-top: 1px solid var(--border);
  font-size: 0.82rem;
  line-height: 1.45;
  white-space: pre-wrap;
}

.create-fav-card-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 0.35rem;
  margin-top: 0.5rem;
}

.elena-paste-row {
  display: flex;
  flex-wrap: wrap;
  gap: 0.45rem;
  align-items: flex-start;
  margin-bottom: 0.5rem;
}

.elena-paste-row textarea {
  flex: 1 1 220px;
  min-height: 2.6rem;
  padding: 0.45rem 0.55rem;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--bg-input);
  color: var(--text);
  font: inherit;
  line-height: 1.4;
  resize: vertical;
}

.reader-story-notes-panel {
  margin-bottom: 0.65rem;
  padding: 0.65rem 0.75rem;
  border: 1px solid rgba(120, 160, 200, 0.35);
  border-radius: var(--radius);
  background: rgba(40, 70, 110, 0.12);
  max-height: min(42vh, 360px);
  overflow-y: auto;
}

.keeps-toolbar {
  display: flex;
  flex-wrap: wrap;
  justify-content: space-between;
  align-items: flex-start;
  gap: 0.65rem 1rem;
  margin-bottom: 0.75rem;
}

.keeps-title {
  margin: 0 0 0.25rem;
  font-size: 1.05rem;
  color: var(--soul);
}

.apps-bugs-hint {
  margin: 0 0 0.65rem;
  font-size: 0.78rem;
}

.apps-tier-split {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0.65rem;
  margin-bottom: 0.75rem;
}

@media (max-width: 720px) {
  .apps-tier-split {
    grid-template-columns: 1fr;
  }
}

.apps-tier-card {
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 0.55rem 0.65rem;
  background: rgba(0, 0, 0, 0.1);
}

.apps-tier-card--build {
  border-color: rgba(255, 210, 80, 0.35);
  background: rgba(255, 210, 80, 0.06);
}

.apps-tier-title {
  margin: 0 0 0.35rem;
  font-size: 0.88rem;
  color: var(--soul);
}

.apps-tier-card .hint {
  margin: 0 0 0.45rem;
  font-size: 0.76rem;
  line-height: 1.4;
}

.btn-flag-structural {
  border-color: rgba(255, 210, 80, 0.45);
  color: #f0d080;
}

.apps-armed-bar {
  margin-bottom: 0.75rem;
  padding: 0.55rem 0.65rem;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: rgba(0, 0, 0, 0.12);
}

.apps-armed-label,
.chat-app-pills-label {
  display: block;
  font-size: 0.72rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--text-muted);
  margin-bottom: 0.4rem;
}

.apps-app-pills {
  display: flex;
  flex-wrap: wrap;
  gap: 0.35rem;
}

.apps-app-pill {
  padding: 0.34rem 0.75rem;
  font-size: 0.78rem;
  border: 1px solid var(--border);
  border-radius: 999px;
  background: rgba(0, 0, 0, 0.15);
  color: var(--text-muted);
  cursor: pointer;
  font: inherit;
}

.apps-app-pill:hover {
  color: var(--text);
  border-color: var(--soul);
}

.apps-app-pill.is-active {
  border-color: rgba(120, 200, 255, 0.55);
  background: rgba(120, 200, 255, 0.12);
  color: #b8e0ff;
}

.apps-app-pill--platform.is-active {
  border-color: rgba(255, 210, 80, 0.55);
  background: rgba(255, 210, 80, 0.12);
  color: #f0d080;
}

.apps-app-pill--self {
  border-color: rgba(255, 140, 140, 0.35);
}

.apps-app-pill--self.is-active {
  border-color: rgba(255, 120, 120, 0.65);
  background: rgba(255, 100, 100, 0.14);
  color: #ffc8c8;
}

.apps-app-pill--greenfield {
  border-style: dashed;
  opacity: 0.92;
}

.apps-app-pill--greenfield.is-active {
  border-color: rgba(255, 210, 80, 0.5);
  background: rgba(255, 210, 80, 0.1);
  color: #f0d080;
}

.apps-armed-scope,
.chat-app-pills-scope {
  margin: 0.45rem 0 0;
  font-size: 0.76rem;
}

.apps-picker-fallback {
  position: absolute;
  width: 1px;
  height: 1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
}

.chat-app-pills-wrap {
  margin: 0.45rem 0 0.55rem;
  padding: 0.45rem 0.55rem;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: rgba(0, 0, 0, 0.1);
}

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

.keeps-toggle {
  padding: 0.35rem 0.7rem;
  border: 1px solid var(--border);
  border-radius: 999px;
  background: rgba(0, 0, 0, 0.15);
  color: var(--text-muted);
  font: inherit;
  font-size: 0.78rem;
  cursor: pointer;
}

.keeps-toggle.active {
  border-color: rgba(255, 210, 80, 0.55);
  background: rgba(255, 210, 80, 0.12);
  color: #f0d080;
}

.keeps-body {
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--bg-input);
  padding: 0.65rem 0.75rem;
  max-height: min(68vh, 640px);
  overflow-y: auto;
}

.keeps-list {
  display: flex;
  flex-direction: column;
  gap: 0.45rem;
}

.keeps-pane-scratch .keeps-scratch-input {
  width: 100%;
  padding: 0.65rem 0.75rem;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: rgba(0, 0, 0, 0.18);
  color: var(--text);
  font: inherit;
  line-height: 1.45;
  resize: vertical;
}

.keeps-scratch-hint {
  margin: 0 0 0.5rem;
}

.keeps-scratch-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 0.4rem;
  margin-top: 0.55rem;
}

.elena-story-notes-panel {
  margin-bottom: 0.65rem;
  padding: 0.65rem 0.75rem;
  border: 1px solid rgba(160, 120, 200, 0.35);
  border-radius: var(--radius);
  background: rgba(80, 50, 120, 0.12);
  max-height: min(42vh, 360px);
  overflow-y: auto;
}

.elena-story-notes-head {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.4rem 0.65rem;
  margin-bottom: 0.35rem;
}

.elena-story-notes-title {
  margin: 0;
  font-size: 0.88rem;
  color: #d8c4f0;
}

.elena-story-notes-hint {
  margin: 0 0 0.5rem;
  font-size: 0.75rem;
}

.elena-story-notes-list {
  display: flex;
  flex-direction: column;
  gap: 0.45rem;
}

.elena-story-note-card {
  border: 1px solid var(--border);
  border-left: 3px solid rgba(180, 140, 220, 0.55);
  border-radius: var(--radius);
  background: rgba(0, 0, 0, 0.2);
  padding: 0.5rem 0.6rem;
}

.elena-story-note-head {
  cursor: pointer;
}

.elena-story-note-title {
  margin: 0;
  font-size: 0.84rem;
  color: var(--text);
  line-height: 1.35;
}

.elena-story-note-meta {
  margin: 0.15rem 0 0;
  font-size: 0.7rem;
  color: var(--text-muted);
}

.elena-story-note-snippet {
  margin: 0.4rem 0 0;
  font-size: 0.78rem;
  color: var(--text-muted);
  line-height: 1.4;
  font-style: italic;
}

.elena-story-note-body {
  margin-top: 0.45rem;
  padding-top: 0.45rem;
  border-top: 1px solid var(--border);
  font-size: 0.8rem;
  line-height: 1.45;
  white-space: pre-wrap;
}

.elena-story-note-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 0.35rem;
  margin-top: 0.45rem;
}

.chat-elena-pin-btn.selected {
  background: rgba(180, 140, 220, 0.28);
  border-color: rgba(180, 140, 220, 0.55);
}

.elena-note-dialog {
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 0;
  max-width: min(92vw, 520px);
  background: var(--bg-panel);
  color: var(--text);
}

.elena-note-dialog::backdrop {
  background: rgba(0, 0, 0, 0.55);
}

.elena-note-form {
  padding: 1rem 1.1rem;
}

.elena-note-dialog-title {
  margin: 0 0 0.35rem;
  font-size: 1rem;
  color: #d8c4f0;
}

.elena-note-dialog-hint {
  margin: 0 0 0.75rem;
  font-size: 0.78rem;
}

.elena-note-field {
  display: block;
  margin-bottom: 0.75rem;
  font-size: 0.82rem;
  color: var(--text-muted);
}

.elena-note-field textarea,
.elena-note-field input {
  display: block;
  width: 100%;
  margin-top: 0.35rem;
  padding: 0.55rem 0.65rem;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--bg-input);
  color: var(--text);
  font: inherit;
  line-height: 1.45;
}

.elena-note-dialog-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  margin-top: 0.25rem;
}

.chat-creative-fav-btn.selected {
  background: rgba(255, 210, 80, 0.28);
  border-color: rgba(255, 210, 80, 0.55);
}

.memory-heart-entry.creative-fav-entry {
  border-left: 2px solid rgba(255, 210, 80, 0.5);
}

.memory-heart-entry.build-flag-entry {
  border-left: 2px solid rgba(255, 160, 60, 0.5);
}

.chat-feedback-note-wrap {
  position: absolute;
  right: calc(100% + 0.4rem);
  bottom: 0;
  width: min(15rem, 58vw);
  display: none;
  flex-direction: column;
  gap: 0.35rem;
  align-items: stretch;
  padding: 0.4rem;
  border-radius: var(--radius);
  border: 1px solid var(--border);
  background: var(--bg-input);
  box-shadow: 0 4px 14px rgba(0, 0, 0, 0.35);
}

.chat-feedback-note-wrap.open {
  display: flex;
}

/* Phone / narrow: center the 👎 note box — desktop pops it left of the buttons */
body.ui-mode-mobile .chat-feedback-note-wrap.open,
body.chat-feedback-note-open .chat-feedback-note-wrap.open {
  position: fixed;
  left: 50%;
  top: 50%;
  right: auto;
  bottom: auto;
  transform: translate(-50%, -50%);
  width: min(20rem, calc(100vw - 2rem));
  max-width: calc(100vw - 2rem);
  z-index: 3000;
  box-shadow: 0 10px 36px rgba(0, 0, 0, 0.55);
}

body.chat-feedback-note-open::before {
  content: "";
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.45);
  z-index: 2999;
}

@media (max-width: 768px) {
  .chat-feedback-note-wrap.open {
    position: fixed;
    left: 50%;
    top: 50%;
    right: auto;
    bottom: auto;
    transform: translate(-50%, -50%);
    width: min(20rem, calc(100vw - 2rem));
    max-width: calc(100vw - 2rem);
    z-index: 3000;
    box-shadow: 0 10px 36px rgba(0, 0, 0, 0.55);
  }
}

.chat-feedback-note {
  flex: 1;
  min-height: 2rem;
  font: inherit;
  font-size: 0.8rem;
  padding: 0.3rem 0.45rem;
  border-radius: var(--radius);
  border: 1px solid var(--border);
  background: var(--bg-input);
  color: var(--text);
  resize: vertical;
}

.chat-feedback-note-wrap.structured-feedback-form {
  width: min(18rem, 72vw);
}

.chat-feedback-note-wrap.structured-feedback-form.open {
  width: min(22rem, calc(100vw - 2rem));
}

body.ui-mode-mobile .chat-feedback-note-wrap.structured-feedback-form.open,
body.chat-feedback-note-open .chat-feedback-note-wrap.structured-feedback-form.open {
  width: min(24rem, calc(100vw - 2rem));
}

.chat-feedback-note-wrap .feedback-form-up,
.chat-feedback-note-wrap .feedback-form-down {
  display: none;
  flex-direction: column;
  gap: 0.35rem;
  align-items: stretch;
}

.chat-feedback-note-wrap.feedback-mode-up .feedback-form-up,
.chat-feedback-note-wrap.feedback-mode-down .feedback-form-down {
  display: flex;
}

.chat-feedback-structured-label {
  font-size: 0.68rem;
  font-weight: 600;
  color: var(--text-muted);
  margin: 0;
}

.chat-feedback-structured-field {
  width: 100%;
  font: inherit;
  font-size: 0.8rem;
  padding: 0.3rem 0.45rem;
  border-radius: var(--radius);
  border: 1px solid var(--border);
  background: var(--bg-input);
  color: var(--text);
}

.chat-feedback-structured-why {
  width: 100%;
  min-height: 2.5rem;
  font: inherit;
  font-size: 0.8rem;
  padding: 0.3rem 0.45rem;
  border-radius: var(--radius);
  border: 1px solid var(--border);
  background: var(--bg-input);
  color: var(--text);
  resize: vertical;
}

.chat-feedback-note-send {
  font-size: 0.72rem;
  padding: 0.25rem 0.45rem;
}

.chat-feedback-logged {
  font-size: 0.58rem;
  color: var(--text-muted);
  font-style: italic;
  line-height: 1.2;
  white-space: nowrap;
}

.memory-heart-entry.feedback-down {
  border-left: 2px solid rgba(255, 120, 120, 0.55);
}

.memory-heart-entry.feedback-up {
  border-left: 2px solid rgba(120, 220, 160, 0.45);
}

.btn-uber-mode.active,
.btn-uber-mode[aria-pressed="true"] {
  border-color: #6eb0ff;
  background: rgba(80, 140, 220, 0.25);
  color: #e8f4ff;
}

.btn-uber-mode:hover {
  border-color: #6eb0ff;
  color: #e8f4ff;
}

.chat-toolbar {
  display: flex;
  flex-wrap: wrap;
  align-items: flex-end;
  gap: 0.75rem 1rem;
  margin-bottom: 0.5rem;
}

.reader-pov-toolbar {
  align-items: flex-start;
}

.reader-pov-filters {
  display: flex;
  flex-wrap: wrap;
  align-items: flex-end;
  gap: 0.55rem 0.85rem;
  padding: 0.55rem 0.7rem;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: rgba(0, 0, 0, 0.12);
  flex: 1 1 100%;
  max-width: 100%;
}

.reader-pov-filter-group {
  display: flex;
  flex-direction: column;
  gap: 0.3rem;
}

.reader-pov-filter-label {
  font-size: 0.78rem;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

.reader-pov-pills {
  display: inline-flex;
  flex-wrap: wrap;
  gap: 0.35rem;
}

.reader-pov-pill {
  background: var(--bg-input);
  border: 1px solid var(--border);
  color: var(--text-muted);
  padding: 0.35rem 0.7rem;
  border-radius: 999px;
  font: inherit;
  font-size: 0.82rem;
  cursor: pointer;
  line-height: 1.2;
}

.reader-pov-pill:hover {
  border-color: rgba(126, 200, 227, 0.55);
  color: var(--text);
}

.reader-pov-pill.is-active {
  background: rgba(126, 200, 227, 0.22);
  border-color: rgba(126, 200, 227, 0.65);
  color: #e8f4ff;
  font-weight: 600;
}

.reader-pov-filter-field select {
  min-width: 7.5rem;
}

.reader-pov-filter-count {
  font-size: 0.8rem;
  color: var(--text-muted);
  padding-bottom: 0.45rem;
  white-space: nowrap;
}

#reader-pov-persona,
#reader-pov-compare {
  min-width: min(28rem, 100%);
  max-width: 100%;
}

.reader-pov-persona-field {
  flex: 1 1 16rem;
  max-width: 100%;
}

.reader-pov-preview {
  display: block;
  margin-top: 0.35rem;
  font-size: 0.8rem;
  line-height: 1.35;
  color: var(--text-muted);
  max-width: 36rem;
}

.reader-pov-preview.is-warning {
  color: #ffcc80;
}

.reader-pov-filter-count.is-empty {
  color: #ffb347;
  font-weight: 600;
}

.reader-pov-filter-count.is-empty::before {
  content: "⚠ ";
}

.chat-lens-badge {
  display: inline-flex;
  align-items: center;
  padding: 0.45rem 0.75rem;
  border-radius: var(--radius);
  border: 1px solid var(--border);
  background: var(--bg-input);
  color: var(--text-muted);
  font-size: 0.85rem;
  font-weight: 500;
  padding-bottom: 0.45rem;
}

.chat-field select {
  background: var(--bg-input);
  border: 1px solid var(--border);
  color: var(--text);
  padding: 0.45rem 0.65rem;
  border-radius: var(--radius);
  font: inherit;
  font-size: 0.88rem;
  min-width: 8.5rem;
}

.chat-save-toggle {
  display: flex;
  align-items: center;
  gap: 0.35rem;
  font-size: 0.85rem;
  color: var(--text-muted);
  cursor: pointer;
  padding-bottom: 0.35rem;
}

.mira-talk-pause-bar {
  margin-bottom: 0.65rem;
  padding: 0.65rem 0.85rem;
  border-radius: var(--radius);
  border: 1px solid rgba(255, 183, 71, 0.45);
  background: rgba(255, 183, 71, 0.1);
  color: #ffe8c2;
  font-size: 0.88rem;
  text-align: center;
}

body.mira-talk-paused #chat-input {
  opacity: 0.55;
}

body.mira-talk-paused #chat-form button[type="submit"] {
  opacity: 0.45;
  pointer-events: none;
}

.chat-live-row {
  display: flex;
  align-items: center;
  gap: 0.65rem;
  flex-wrap: wrap;
  margin-bottom: 0.65rem;
}

.btn-talk-live {
  background: linear-gradient(135deg, rgba(126, 200, 227, 0.35), rgba(192, 38, 211, 0.28));
  border: 1px solid rgba(126, 200, 227, 0.55);
  color: #f0f8ff;
  font-weight: 700;
  padding: 0.55rem 1rem;
  border-radius: 999px;
}

.btn-talk-live:hover,
.btn-talk-live.active {
  background: linear-gradient(135deg, rgba(126, 200, 227, 0.5), rgba(192, 38, 211, 0.4));
}

.chat-live-hint {
  font-size: 0.78rem;
  color: var(--text-muted);
}

.chat-uber-drive {
  display: none;
}

body.ui-mode-mobile .chat-uber-drive {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  flex: 1 1 auto;
  min-width: 5.5rem;
  font-size: 1rem;
  font-weight: 700;
  padding: 0.7rem 1rem;
  border-radius: 999px;
}

body.ui-mode-mobile #btn-uber-mode {
  display: none;
}

body.ui-mode-mobile .chat-live-row {
  margin-top: 0.15rem;
  gap: 0.5rem;
}

body.ui-mode-mobile .btn-talk-live {
  flex: 1 1 auto;
  min-width: 8rem;
  text-align: center;
  font-size: 1rem;
  padding: 0.7rem 1rem;
}

body.ui-mode-mobile .chat-live-hint {
  flex: 1 1 100%;
}

.chat-attach-row {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  flex-wrap: wrap;
  margin-bottom: 0.5rem;
}

.btn-attach {
  cursor: pointer;
  display: inline-block;
}

.chat-attach-name {
  font-size: 0.82rem;
  color: var(--text-muted);
  word-break: break-all;
}

.chat-image-preview {
  margin-bottom: 0.5rem;
  max-width: 220px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
  background: var(--bg-input);
}

.chat-image-preview img {
  display: block;
  width: 100%;
  height: auto;
  max-height: 160px;
  object-fit: contain;
}

.chat-bubble-img {
  display: block;
  max-width: 100%;
  max-height: 200px;
  border-radius: 4px;
  margin-bottom: 0.5rem;
  object-fit: contain;
}

.chat-bubble-text {
  white-space: pre-wrap;
}

.chat-bubble-text .chat-action {
  font-weight: 700;
  font-style: normal;
}

.chat-bubble-text .chat-emphasis {
  font-style: italic;
}

.chat-meta-tag {
  display: inline-block;
  font-size: 0.72rem;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--text-muted);
  margin-bottom: 0.35rem;
  padding: 0.15rem 0.4rem;
  border: 1px solid var(--border);
  border-radius: 4px;
}

.chat-meta-tag.mira-tag {
  color: var(--soul);
  border-color: rgba(255, 255, 255, 0.25);
}

.overlay {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.88);
  display: none;
  align-items: center;
  justify-content: center;
  z-index: 100;
}

.overlay.visible {
  display: flex;
}

.overlay-card {
  background: var(--bg-panel);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 2rem 2.5rem;
  text-align: center;
}

.spinner {
  width: 40px;
  height: 40px;
  margin: 0 auto 1rem;
  border: 3px solid var(--border);
  border-top-color: var(--soul);
  border-radius: 50%;
  animation: spin 0.9s linear infinite;
}

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

.overlay-sub {
  margin: 0.5rem 0 0;
  font-size: 0.85rem;
  color: var(--text-muted);
}

.overlay-dismiss {
  margin-top: 1.25rem;
}

.archive-notice {
  margin-top: 1rem;
  padding: 0.65rem 1rem;
  background: rgba(255, 255, 255, 0.05);
  border: 1px solid rgba(255, 255, 255, 0.2);
  border-radius: var(--radius);
  font-size: 0.88rem;
  color: var(--text);
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.field-inline select {
  background: var(--bg-input);
  border: 1px solid var(--border);
  color: var(--text);
  padding: 0.5rem 0.75rem;
  border-radius: var(--radius);
  font: inherit;
  min-width: 180px;
}

.versions-toolbar {
  display: flex;
  justify-content: space-between;
  align-items: flex-end;
  gap: 1rem;
  flex-wrap: wrap;
  margin-bottom: 1.25rem;
}

.versions-intro p {
  margin: 0;
  font-size: 0.9rem;
  color: var(--text-muted);
}

.versions-intro code {
  color: var(--soul);
  font-size: 0.85rem;
}

.word-convert-panel {
  margin-bottom: 1.25rem;
  padding: 1rem 1.1rem;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--bg-input);
}

.word-convert-panel h2 {
  margin: 0 0 0.35rem;
  font-size: 1rem;
}

.word-convert-toolbar {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.65rem;
  margin-top: 0.65rem;
}

.versions-split {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 1rem;
}

.versions-split--triple {
  grid-template-columns: 1fr 1fr 1fr;
}

@media (max-width: 1100px) {
  .versions-split--triple {
    grid-template-columns: 1fr;
  }
}

@media (max-width: 900px) {
  .versions-split {
    grid-template-columns: 1fr;
  }
}

.versions-pane h2 {
  margin: 0 0 0.35rem;
  font-size: 1rem;
}

.versions-list,
.history-list {
  margin-top: 0.75rem;
  max-height: 420px;
  overflow-y: auto;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--bg-input);
}

.empty-msg {
  margin: 0;
  padding: 1rem;
  color: var(--text-muted);
  font-size: 0.88rem;
  font-style: italic;
}

.version-row,
.history-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 0.75rem;
  padding: 0.65rem 0.85rem;
  border-bottom: 1px solid var(--border);
  font-size: 0.88rem;
}

.version-row:last-child,
.history-row:last-child {
  border-bottom: none;
}

.version-meta {
  display: flex;
  flex-direction: column;
  gap: 0.15rem;
  min-width: 0;
}

.version-cat,
.history-cat {
  font-size: 0.75rem;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

.version-name,
.history-name {
  color: var(--text);
  word-break: break-all;
}

.version-time,
.history-time {
  font-size: 0.78rem;
  color: var(--text-muted);
}

.history-row {
  display: grid;
  grid-template-columns: 8.5rem 7rem 1fr;
  align-items: start;
}

.btn-sm {
  padding: 0.35rem 0.65rem;
  font-size: 0.8rem;
  text-decoration: none;
  display: inline-block;
}

.versions-footer {
  margin-top: 1rem;
  font-size: 0.82rem;
  color: var(--text-muted);
  min-height: 1.2em;
}

.build-intro {
  margin-bottom: 1rem;
}

.build-intro p {
  margin: 0;
  font-size: 0.9rem;
  color: var(--text-muted);
}

.build-intro code {
  color: var(--soul);
}

.upload-zone {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 0.5rem;
  min-height: 140px;
  border: 2px dashed var(--border);
  border-radius: var(--radius);
  background: var(--bg-input);
  cursor: pointer;
  padding: 1.25rem;
  text-align: center;
  transition: border-color 0.15s, background 0.15s;
}

.upload-zone:hover,
.upload-zone.dragover {
  border-color: var(--accent);
  background: rgba(255, 255, 255, 0.04);
}

.upload-icon {
  font-size: 1.75rem;
  color: var(--soul);
  line-height: 1;
}

#build-filename {
  font-size: 0.9rem;
  color: var(--text-muted);
  word-break: break-all;
}

.format-help {
  margin-top: 0.75rem;
  font-size: 0.85rem;
  color: var(--text-muted);
}

.format-help summary {
  cursor: pointer;
  color: var(--soul);
}

.format-sample {
  margin: 0.5rem 0 0;
  padding: 0.75rem;
  background: var(--bg-input);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  font-size: 0.78rem;
  line-height: 1.5;
  overflow-x: auto;
  white-space: pre;
  color: var(--text);
}

.build-options {
  display: flex;
  flex-wrap: wrap;
  gap: 0.75rem 1.25rem;
  margin-top: 0.85rem;
  font-size: 0.88rem;
  color: var(--text-muted);
}

.build-options label {
  display: flex;
  align-items: center;
  gap: 0.35rem;
  cursor: pointer;
}

.build-actions {
  margin-top: 0.85rem;
}

.build-pub-panel {
  margin-top: 0.75rem;
  padding: 0.75rem;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--bg-input);
  max-height: min(58vh, 520px);
  overflow-y: auto;
}

.build-pub-head .build-pub-title-row {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 0.5rem 0.65rem;
  margin-bottom: 0.2rem;
}

.build-erotica-pill {
  display: inline-block;
  padding: 0.2rem 0.55rem;
  border-radius: 999px;
  font-size: 0.68rem;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  border: 1px solid transparent;
  line-height: 1.3;
  user-select: none;
}

.build-erotica-pill--idle {
  opacity: 0.45;
  background: rgba(120, 130, 150, 0.12);
  border-color: rgba(120, 130, 150, 0.25);
  color: var(--text-muted);
}

.build-erotica-pill--off {
  opacity: 0.55;
  background: rgba(120, 130, 150, 0.14);
  border-color: rgba(120, 130, 150, 0.3);
  color: #9aa8bc;
}

.build-erotica-pill--on {
  background: rgba(220, 170, 60, 0.28);
  border-color: rgba(220, 170, 60, 0.75);
  color: #f0d080;
  box-shadow: 0 0 0 1px rgba(220, 170, 60, 0.2);
}

.build-pub-section {
  margin-bottom: 0.85rem;
}

.build-content-badge {
  display: inline-block;
  padding: 0.45rem 0.65rem;
  border-radius: var(--radius);
  font-size: 0.88rem;
  line-height: 1.35;
  border: 1px solid var(--border);
}

.build-content-badge--safe {
  background: rgba(72, 160, 140, 0.18);
  border-color: rgba(72, 160, 140, 0.45);
  color: #9fd9c8;
}

.build-content-badge--mild {
  background: rgba(120, 140, 180, 0.15);
  border-color: rgba(120, 140, 180, 0.35);
  color: #b8c8e8;
}

.build-content-badge--heat {
  background: rgba(180, 110, 90, 0.15);
  border-color: rgba(180, 110, 90, 0.4);
  color: #e8c4b8;
}

.build-content-confidence {
  font-size: 0.78rem;
  font-weight: 500;
  opacity: 0.85;
  text-transform: capitalize;
}

.build-content-rationale {
  margin: 0.5rem 0 0;
  font-size: 0.82rem;
  color: var(--text-muted);
  line-height: 1.45;
}

.build-content-warning {
  margin: 0.45rem 0 0;
  font-size: 0.8rem;
  color: #e8b88a;
  line-height: 1.4;
}

.build-pub-heading {
  margin: 0 0 0.45rem;
  font-size: 0.82rem;
  font-weight: 600;
  color: var(--soul);
  letter-spacing: 0.04em;
  text-transform: uppercase;
}

.build-pub-field {
  display: block;
  margin-bottom: 0.75rem;
  font-size: 0.82rem;
  color: var(--text-muted);
}

.build-pub-field textarea {
  display: block;
  width: 100%;
  margin-top: 0.35rem;
  padding: 0.55rem 0.65rem;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: rgba(0, 0, 0, 0.2);
  color: var(--text);
  font: inherit;
  line-height: 1.45;
  resize: vertical;
}

.build-char-count {
  float: right;
  font-size: 0.72rem;
  color: var(--text-muted);
}

.build-pick-list {
  display: flex;
  flex-direction: column;
  gap: 0.45rem;
}

.build-pick-card {
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 0.55rem 0.65rem;
  background: rgba(0, 0, 0, 0.15);
}

.build-pick-card.selected {
  border-color: rgba(255, 210, 80, 0.55);
  background: rgba(255, 210, 80, 0.08);
}

.build-pick-text {
  margin: 0 0 0.45rem;
  font-size: 0.84rem;
  line-height: 1.5;
  color: var(--text);
  white-space: pre-wrap;
}

.build-pick-card .btn {
  font-size: 0.78rem;
}

.build-pub-hint {
  margin: 0 0 0.5rem;
}

.build-cover-ideas-list {
  margin: 0.5rem 0 0;
  padding-left: 1.25rem;
  font-size: 0.88rem;
  line-height: 1.55;
  color: var(--text-muted);
}

.build-cover-ideas-list li {
  margin-bottom: 0.65rem;
}

.build-bisac-row {
  font-size: 0.84rem;
  line-height: 1.45;
  margin-bottom: 0.25rem;
  color: var(--text);
}

.build-terms-row {
  display: flex;
  flex-wrap: wrap;
  gap: 0.35rem;
}

.build-term-chip {
  padding: 0.2rem 0.5rem;
  border-radius: 999px;
  border: 1px solid var(--border);
  font-size: 0.76rem;
  color: var(--text-muted);
}

.author-site-bar {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem 1rem;
  margin: 0 0 1rem;
  padding: 0.75rem 0.9rem;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: rgba(255, 210, 80, 0.05);
}

.author-site-copy {
  display: flex;
  flex-direction: column;
  gap: 0.2rem;
  font-size: 0.88rem;
}

.author-site-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 0.4rem;
}

.author-site-live #btn-author-site-live {
  border-color: rgba(80, 220, 140, 0.5);
}

.author-site-off #btn-author-site-off {
  border-color: rgba(255, 180, 80, 0.55);
}

.author-panel-intro {
  margin-bottom: 1rem;
}

.author-panel-title {
  margin: 0 0 0.35rem;
  font-size: 1.15rem;
  color: var(--soul);
}

.author-safety-banner {
  margin: 0;
  padding: 0.65rem 0.85rem;
  border-radius: var(--radius);
  border: 1px solid rgba(255, 120, 80, 0.35);
  background: rgba(255, 120, 80, 0.08);
  color: #ffc9b0;
  font-size: 0.86rem;
  line-height: 1.45;
}

.author-panel-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 0.85rem;
}

@media (max-width: 900px) {
  .author-panel-grid {
    grid-template-columns: 1fr;
  }
}

.author-panel-card {
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--bg-input);
  padding: 0.85rem 0.95rem 1rem;
}

.author-panel-card .pane-head {
  margin-bottom: 0.55rem;
}

.author-panel-card h3 {
  margin: 0;
  font-size: 0.92rem;
  color: var(--text);
}

.author-panel-copy {
  margin: 0 0 0.75rem;
  font-size: 0.82rem;
  line-height: 1.5;
  color: var(--text-muted);
}

.author-status-pill {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 6px 14px;
  border-radius: 999px;
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  margin-bottom: 0.65rem;
}

.author-status-pill.live {
  background: rgba(80, 220, 140, 0.12);
  border: 1px solid rgba(80, 220, 140, 0.35);
  color: #7dffb8;
}

.author-status-pill.off {
  background: rgba(255, 180, 80, 0.1);
  border: 1px solid rgba(255, 180, 80, 0.35);
  color: #ffcc88;
}

.author-preset-list {
  display: flex;
  flex-direction: column;
  gap: 0.45rem;
}

.author-preset-card {
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 0.55rem 0.65rem;
  background: rgba(0, 0, 0, 0.15);
}

.author-preset-card.selected {
  border-color: rgba(255, 210, 80, 0.55);
  background: rgba(255, 210, 80, 0.08);
}

.author-preset-card h4 {
  margin: 0 0 0.25rem;
  font-size: 0.84rem;
  color: var(--soul);
}

.author-preset-card p {
  margin: 0 0 0.45rem;
  font-size: 0.78rem;
  color: var(--text-muted);
  line-height: 1.45;
}

.author-preset-card .btn {
  font-size: 0.78rem;
}

.author-apply-status {
  margin: 0.55rem 0 0;
  font-size: 0.8rem;
  color: var(--text-muted);
  min-height: 1.2em;
}

.author-maint-preview {
  border: 1px solid var(--border);
  border-radius: 14px;
  padding: 1rem 0.85rem;
  background: #0a0a0f;
  text-align: center;
}

.author-maint-preview .preview-badge {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 5px 12px;
  border-radius: 999px;
  background: rgba(0, 229, 187, 0.15);
  border: 1px solid rgba(0, 229, 187, 0.25);
  color: #00e5bb;
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  margin-bottom: 0.65rem;
}

.author-maint-preview .preview-badge-dot {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: #00e5bb;
  animation: pulse 2s ease-in-out infinite;
}

.author-maint-preview .preview-palm {
  font-size: 2rem;
  margin: 0.2rem 0 0.5rem;
  animation: author-palm-sway 4.5s ease-in-out infinite;
  display: inline-block;
}

@keyframes author-palm-sway {
  0%, 100% { transform: rotate(0deg); }
  50% { transform: rotate(-6deg); }
}

.author-maint-preview h4 {
  margin: 0 0 0.45rem;
  font-size: 0.95rem;
}

.author-maint-preview p {
  margin: 0 0 0.35rem;
  font-size: 0.8rem;
  line-height: 1.45;
  color: #c8c8d8;
}

.author-maint-preview .preview-phase {
  color: #00e5bb;
  font-size: 0.76rem;
}

.author-cover-list {
  list-style: none;
  margin: 0 0 0.65rem;
  padding: 0;
  font-size: 0.8rem;
}

.author-cover-list li {
  padding: 0.28rem 0;
  border-bottom: 1px solid var(--border);
  color: var(--text-muted);
}

.author-cover-list li.ok {
  color: #9dffc8;
}

.author-cover-list li.missing {
  color: #ffb08a;
}

.author-deploy-note {
  margin-bottom: 0;
}

.author-preview-ip {
  margin: 0.55rem 0 0;
  font-size: 0.78rem;
  color: var(--teal);
}

.author-status-pill.secure {
  background: rgba(100, 160, 255, 0.12);
  border: 1px solid rgba(100, 160, 255, 0.35);
  color: #9ec5ff;
}

.author-idea-note {
  margin-top: 0.75rem;
  padding: 0.55rem 0.65rem;
  border-radius: var(--radius);
  border: 1px dashed rgba(255, 210, 80, 0.35);
  background: rgba(255, 210, 80, 0.05);
  font-size: 0.78rem;
  color: var(--text-muted);
  line-height: 1.45;
}

.build-preview {
  min-height: 120px;
  max-height: 220px;
  overflow-y: auto;
  background: var(--bg-input);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 0.85rem;
}

.preview-meta {
  display: flex;
  flex-direction: column;
  gap: 0.35rem;
  margin-bottom: 1rem;
}

.preview-row {
  display: grid;
  grid-template-columns: 7.5rem 1fr;
  gap: 0.5rem;
  font-size: 0.88rem;
}

.preview-label {
  color: var(--text-muted);
}

.preview-value {
  color: var(--text);
  word-break: break-word;
}

.preview-heading {
  margin: 0.75rem 0 0.35rem;
  font-size: 0.85rem;
  color: var(--soul);
}

.preview-body {
  font-size: 0.88rem;
  line-height: 1.6;
  white-space: pre-wrap;
  color: var(--text);
}

.preview-body.muted {
  color: var(--text-muted);
  font-style: italic;
}

.apps-mira-bar {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem 1rem;
  margin-bottom: 1rem;
  padding: 0.75rem 1rem;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: rgba(120, 90, 180, 0.08);
}

.apps-mira-bar p {
  margin: 0;
  flex: 1;
  min-width: 16rem;
  font-size: 0.88rem;
  color: var(--text-muted);
  line-height: 1.5;
}

.chat-ui-fix-toggle {
  display: flex;
  align-items: center;
  gap: 0.35rem;
  font-size: 0.82rem;
  color: var(--text-muted);
  cursor: pointer;
  user-select: none;
  padding: 0.2rem 0.5rem;
  border-radius: var(--radius);
  border: 1px solid var(--border);
}

.chat-ui-fix-toggle:has(#chat-ui-fix:checked) {
  border-color: var(--ok);
  color: var(--ok);
  background: rgba(80, 160, 100, 0.1);
}

.chat-ui-fix-hint {
  margin: 0.35rem 0 0;
  font-size: 0.82rem;
  color: var(--ok);
}

.apps-intro {
  margin-bottom: 1rem;
}

.apps-intro p {
  margin: 0;
  font-size: 0.9rem;
  color: var(--text-muted);
}

.apps-toolbar {
  display: flex;
  flex-wrap: wrap;
  align-items: flex-end;
  gap: 0.75rem 1.25rem;
  margin-bottom: 1rem;
}

.apps-permission-toggle {
  display: flex;
  align-items: center;
  gap: 0.4rem;
  font-size: 0.85rem;
  color: var(--text);
  padding: 0.35rem 0.65rem;
  border-radius: var(--radius);
  border: 1px solid var(--warn);
  background: rgba(200, 140, 60, 0.08);
  cursor: pointer;
  user-select: none;
}

.apps-permission-toggle:has(#app-build-permission:checked) {
  border-color: var(--ok);
  background: rgba(80, 160, 100, 0.1);
  color: var(--ok);
}

.apps-permission-hint {
  margin: -0.35rem 0 0.85rem;
  font-size: 0.82rem;
  color: var(--warn);
}

.apps-permission-hint.granted {
  color: var(--ok);
}

.apps-deploy-toggle {
  display: flex;
  align-items: center;
  gap: 0.35rem;
  font-size: 0.85rem;
  color: var(--text-muted);
  padding-bottom: 0.35rem;
  cursor: pointer;
}

.apps-deploy-readiness {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 0.5rem 0.65rem;
  margin: 0.15rem 0 0.65rem;
  padding: 0.45rem 0.65rem;
  border-radius: 8px;
  font-size: 0.82rem;
  background: rgba(120, 140, 180, 0.08);
  border: 1px solid rgba(120, 140, 180, 0.18);
}

.apps-deploy-readiness--ready {
  background: rgba(80, 160, 100, 0.1);
  border-color: rgba(80, 160, 100, 0.28);
}

.apps-deploy-readiness--warn {
  background: rgba(200, 150, 60, 0.1);
  border-color: rgba(200, 150, 60, 0.3);
}

.apps-deploy-readiness--bad {
  background: rgba(200, 80, 80, 0.1);
  border-color: rgba(200, 80, 80, 0.28);
}

.apps-deploy-readiness-dot {
  width: 9px;
  height: 9px;
  border-radius: 50%;
  background: var(--text-muted);
  flex-shrink: 0;
}

.apps-deploy-readiness--ready .apps-deploy-readiness-dot {
  background: var(--ok);
}

.apps-deploy-readiness--warn .apps-deploy-readiness-dot {
  background: var(--warn);
}

.apps-deploy-readiness--bad .apps-deploy-readiness-dot {
  background: var(--bad, #c85a5a);
}

.apps-deploy-readiness-text {
  flex: 1;
  min-width: 12rem;
  color: var(--text-muted);
}

.apps-deploy-readiness--ready .apps-deploy-readiness-text {
  color: var(--ok);
}

.apps-deploy-toggle--blocked {
  opacity: 0.65;
}

.app-setup-head {
  margin-bottom: 0.85rem;
}

.app-setup-head-row {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 0.5rem 1rem;
}

.app-setup-title {
  margin: 0;
  font-size: 1.15rem;
  font-weight: 600;
}

.app-setup-head-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 0.4rem;
}

.app-setup-lead {
  margin: 0.35rem 0 0;
}

.app-builder-head {
  margin-bottom: 0.75rem;
}

.app-builder-title {
  margin: 0 0 0.35rem;
  font-size: 1.15rem;
}

.app-builder-lead {
  margin: 0 0 0.35rem;
}

.app-builder-armed-hint {
  margin: 0;
  font-size: 0.88rem;
  color: var(--warn);
}

.app-builder-body {
  display: flex;
  flex-direction: column;
  min-height: calc(100vh - 16rem);
}

body.ui-mode-desktop .app-builder-messages {
  flex: 1;
  min-height: 50vh;
  max-height: none;
}

.app-setup-body {
  display: flex;
  flex-direction: column;
  gap: 1rem;
  min-height: 520px;
}

.app-setup-body--records-only {
  min-height: auto;
}

body.ui-mode-desktop .app-setup-body {
  min-height: calc(100vh - 22rem);
}

.app-setup-conversation {
  display: flex;
  flex-direction: column;
  flex: 1;
  min-height: 0;
}

body.ui-mode-desktop .app-setup-conversation .apps-messages {
  min-height: 42vh;
  max-height: none;
  flex: 1;
}

.help-panel {
  max-width: 52rem;
  padding: 0.25rem 0 2rem;
}

.help-title {
  margin: 0 0 0.5rem;
  font-size: 1.25rem;
}

.help-lead {
  margin: 0 0 1.25rem;
  color: var(--text-muted);
  font-size: 0.95rem;
  line-height: 1.55;
}

.help-jump {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem 1rem;
  margin-bottom: 1.5rem;
  font-size: 0.88rem;
}

.help-jump a {
  color: var(--accent);
  text-decoration: none;
}

.help-jump a:hover {
  text-decoration: underline;
}

.help-card {
  margin-bottom: 1.35rem;
  padding: 1rem 1.15rem;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--bg-panel);
}

.help-card h3 {
  margin: 0 0 0.65rem;
  font-size: 1.05rem;
}

.help-card p {
  margin: 0.5rem 0 0;
  font-size: 0.92rem;
  line-height: 1.55;
  color: var(--text-muted);
}

.help-steps {
  margin: 0.5rem 0 0;
  padding-left: 1.25rem;
  font-size: 0.92rem;
  line-height: 1.6;
  color: var(--text-muted);
}

.help-steps li {
  margin-bottom: 0.45rem;
}

.help-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.88rem;
  margin-top: 0.5rem;
}

.help-table th,
.help-table td {
  border: 1px solid var(--border);
  padding: 0.45rem 0.65rem;
  text-align: left;
}

.help-table th {
  background: rgba(120, 140, 180, 0.08);
}

.help-dl {
  margin: 0.5rem 0 0;
  font-size: 0.92rem;
  line-height: 1.55;
}

.help-dl dt {
  font-weight: 600;
  color: var(--text);
  margin-top: 0.75rem;
}

.help-dl dt:first-child {
  margin-top: 0;
}

.help-dl dd {
  margin: 0.25rem 0 0;
  color: var(--text-muted);
}

.help-list {
  margin: 0.5rem 0 0;
  padding-left: 1.25rem;
  font-size: 0.92rem;
  line-height: 1.6;
  color: var(--text-muted);
}

.help-footer {
  margin-top: 1rem;
  font-size: 0.82rem;
}

html:not(.story-app) body.ui-mode-mobile #panel-help {
  display: none !important;
}

.app-setup-records {
  border-top: 1px solid var(--border);
  padding-top: 0.75rem;
}

body.ui-mode-desktop .app-setup-records .apps-history-list {
  max-height: 280px;
}

.apps-split {
  display: grid;
  grid-template-columns: 1.2fr 0.8fr;
  gap: 1rem;
  min-height: 480px;
}

@media (max-width: 900px) {
  .apps-split {
    grid-template-columns: 1fr;
  }
}

.apps-chat-col {
  display: flex;
  flex-direction: column;
  min-height: 0;
}

.apps-messages {
  min-height: 320px;
  max-height: 50vh;
}

.apps-form {
  margin-top: 0.75rem;
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}

#app-input {
  min-height: 72px;
}

.apps-side-col {
  display: flex;
  flex-direction: column;
  min-height: 0;
  align-self: start;
  width: 100%;
}

.apps-side-tabs {
  display: flex;
  gap: 0.25rem;
  margin-bottom: 0.65rem;
  flex-wrap: wrap;
}

.apps-side-tab {
  flex: 1;
  min-width: 5.5rem;
  padding: 0.4rem 0.5rem;
  font-size: 0.78rem;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--bg-input);
  color: var(--text-muted);
  cursor: pointer;
}

.apps-side-tab:hover {
  color: var(--text);
  border-color: var(--soul);
}

.apps-side-tab.active {
  color: var(--text);
  border-color: var(--soul);
  background: rgba(120, 90, 180, 0.12);
}

.apps-side-panel {
  display: none;
  flex-direction: column;
  min-height: 0;
  flex: 0 0 auto;
  width: 100%;
}

.apps-side-panel.active {
  display: flex;
}

.apps-side-panel .pane-head {
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.apps-history-status.promoted {
  color: var(--ok);
}

.apps-history-status.staged {
  color: var(--warn);
}

.apps-archive-name {
  margin: 0 0 0.35rem;
  font-family: var(--font-mono, monospace);
  font-size: 0.78rem;
  color: var(--text);
  word-break: break-all;
}

.apps-history-list {
  flex: 0 0 auto;
  overflow-y: auto;
  overflow-x: hidden;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--bg-input);
  height: min(50vh, 360px);
  min-height: 280px;
  max-height: min(50vh, 360px);
}

.apps-history-item {
  padding: 0.75rem 0.85rem;
  border-bottom: 1px solid var(--border);
  font-size: 0.88rem;
}

.apps-history-item:last-child {
  border-bottom: none;
}

.apps-history-meta {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 0.5rem;
  margin-bottom: 0.35rem;
}

.apps-history-app {
  font-size: 0.75rem;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--soul);
}

.apps-history-status {
  font-size: 0.72rem;
  text-transform: uppercase;
  color: var(--text-muted);
}

.apps-history-status.fixed {
  color: var(--ok);
}

.apps-history-status.failed,
.apps-history-status.partial {
  color: var(--warn);
}

.apps-history-request {
  margin: 0 0 0.35rem;
  color: var(--text-muted);
  font-style: italic;
  font-size: 0.82rem;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
  word-break: break-word;
}

.apps-history-summary {
  margin: 0 0 0.5rem;
  color: var(--text);
  line-height: 1.5;
  display: -webkit-box;
  -webkit-line-clamp: 3;
  -webkit-box-orient: vertical;
  overflow: hidden;
  word-break: break-word;
}

.apps-history-status.captured,
.apps-history-status.idea {
  color: var(--soul);
}

.apps-future-item {
  display: block;
  width: 100%;
  text-align: left;
  border: none;
  background: transparent;
  cursor: pointer;
  transition: background 0.15s ease;
}

.apps-future-item:hover,
.apps-future-item:focus-visible {
  background: rgba(0, 229, 187, 0.06);
  outline: none;
}

.apps-future-priority {
  font-size: 0.72rem;
  font-weight: 700;
  color: var(--teal, var(--soul));
  letter-spacing: 0.04em;
  margin-right: 0.35rem;
}

.apps-future-title {
  margin: 0 0 0.35rem;
  color: var(--text);
  font-weight: 600;
  font-size: 0.9rem;
  line-height: 1.35;
}

.apps-future-load {
  font-size: 0.72rem;
  color: var(--soul);
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

.apps-history-status.build_mira {
  color: var(--purple, #9b8cff);
}

.apps-history-status.local {
  color: var(--ok);
}

.apps-history-status.building {
  color: var(--warn);
}

.apps-history-status.done {
  color: var(--ok);
}

.apps-history-foot {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 0.5rem;
}

.apps-history-time {
  font-size: 0.75rem;
  color: var(--text-muted);
}

.rules-panel {
  position: fixed;
  top: 0;
  right: 0;
  width: min(420px, 100vw);
  height: 100vh;
  z-index: 1200;
  background: var(--bg-panel, var(--bg));
  border-left: 1px solid var(--border);
  box-shadow: -4px 0 24px rgba(0, 0, 0, 0.25);
  display: flex;
  flex-direction: column;
  padding: 1rem;
  overflow: hidden;
}

.rules-panel[hidden] {
  display: none !important;
}

.rules-panel-head {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 0.5rem;
}

.rules-panel-head h2 {
  margin: 0;
  font-size: 1.1rem;
}

.rules-panel-actions {
  margin-bottom: 0.75rem;
}

.rules-add {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
  margin-bottom: 1rem;
}

.rules-add textarea {
  width: 100%;
  min-height: 56px;
  resize: vertical;
}

.rules-lists {
  flex: 1;
  overflow-y: auto;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--bg-input);
  padding: 0.5rem;
}

.rules-group-title {
  font-size: 0.75rem;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--soul);
  margin: 0.75rem 0 0.35rem;
}

.rules-group-title:first-child {
  margin-top: 0;
}

.rules-item {
  padding: 0.55rem 0.5rem;
  border-bottom: 1px solid var(--border);
  font-size: 0.85rem;
  line-height: 1.45;
}

.rules-item:last-child {
  border-bottom: none;
}

.rules-item-meta {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 0.5rem;
  margin-top: 0.35rem;
  font-size: 0.72rem;
  color: var(--text-muted);
}

.rules-item-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 0.35rem;
  justify-content: flex-end;
}

.rules-item-edit {
  width: 100%;
  min-height: 72px;
  margin-top: 0.35rem;
  font: inherit;
  font-size: 0.85rem;
  resize: vertical;
}

.rules-item-edit-actions {
  display: flex;
  gap: 0.5rem;
  margin-top: 0.35rem;
}

.rules-item.inactive {
  opacity: 0.45;
}

/* Voice — Mira speaks, mic input */
.btn-voice-header {
  font-size: 0.85rem;
  padding: 0.4rem 0.75rem;
}

.input-with-mic {
  display: flex;
  gap: 0.5rem;
  align-items: flex-end;
}

.input-with-mic textarea {
  flex: 1;
  min-width: 0;
}

.btn-voice-mic {
  flex-shrink: 0;
  width: 42px;
  height: 42px;
  border-radius: 50%;
  border: 1px solid var(--border);
  background: var(--bg-panel);
  color: var(--text);
  font-size: 1.1rem;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: background 0.15s, border-color 0.15s;
}

.btn-voice-mic:hover:not(:disabled) {
  background: var(--bg-input);
  border-color: var(--accent);
}

.btn-voice-mic.listening {
  background: #3a2020;
  border-color: #aa5555;
  animation: voice-pulse 1.2s ease-in-out infinite;
}

.btn-voice-mic:disabled {
  opacity: 0.35;
  cursor: not-allowed;
}

.voice-mic-status {
  margin: 0.35rem 0 0;
  padding: 0.45rem 0.65rem;
  font-size: 0.82rem;
  line-height: 1.4;
  border-radius: 8px;
  border: 1px solid var(--border);
  background: var(--bg-input);
  color: var(--text-muted);
}

.voice-mic-status.listening {
  color: #e8b4b4;
  border-color: #7a4040;
  background: #2a1818;
}

.voice-mic-status.error {
  color: #ffb4b4;
  border-color: #8a4040;
  background: #301818;
}

.voice-mic-status.ok {
  color: #b4e8c8;
  border-color: #3a5a48;
  background: #182820;
}

.voice-mic-msg {
  display: block;
  margin-bottom: 0.35rem;
}

.voice-mic-level {
  height: 6px;
  border-radius: 3px;
  background: rgba(255, 255, 255, 0.08);
  overflow: hidden;
}

.voice-mic-level-fill {
  height: 100%;
  width: 0%;
  border-radius: 3px;
  background: linear-gradient(90deg, #aa5555, #dd8888);
  transition: width 0.08s linear;
}

.btn-voice-header.speaking {
  border-color: var(--accent);
  animation: voice-pulse 1.2s ease-in-out infinite;
}

@keyframes voice-pulse {
  0%, 100% { box-shadow: 0 0 0 0 rgba(170, 85, 85, 0.35); }
  50% { box-shadow: 0 0 0 8px rgba(170, 85, 85, 0); }
}

.voice-panel-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.72);
  z-index: 900;
}

.voice-panel {
  position: fixed;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  z-index: 901;
  width: min(560px, calc(100vw - 2rem));
  max-height: min(80vh, 640px);
  overflow-y: auto;
  background: var(--bg-panel);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 1.25rem 1.35rem 1.5rem;
  box-shadow: 0 24px 64px rgba(0, 0, 0, 0.55);
}

.voice-panel-head {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 1rem;
  margin-bottom: 1rem;
}

.voice-panel-head h2 {
  margin: 0 0 0.25rem;
  font-size: 1.15rem;
}

.voice-panel-sub {
  margin: 0;
  font-size: 0.88rem;
  color: var(--text-muted);
  line-height: 1.45;
}

.voice-speak-toggle {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  font-size: 0.9rem;
  margin-bottom: 0.75rem;
  cursor: pointer;
  user-select: none;
}

.voice-speak-toggle input {
  accent-color: var(--accent);
}

.voice-speak-mode-hint {
  margin: -0.25rem 0 0.85rem;
  font-size: 0.8rem;
  line-height: 1.35;
}

.voice-grid-hint {
  margin: 0 0 0.75rem;
  font-size: 0.82rem;
}

.voice-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
  gap: 0.65rem;
}

.voice-card {
  padding: 0.75rem 0.85rem;
  border-radius: var(--radius);
  border: 1px solid var(--border);
  background: var(--bg-input);
  transition: border-color 0.15s;
}

.voice-card.selected {
  border-color: var(--accent);
  background: #141414;
}

.voice-card-name {
  font-size: 0.9rem;
  font-weight: 600;
  margin-bottom: 0.15rem;
  line-height: 1.3;
}

.voice-card-lang {
  font-size: 0.75rem;
  color: var(--text-muted);
  margin-bottom: 0.6rem;
}

.voice-card-actions {
  display: flex;
  gap: 0.4rem;
}

.voice-empty {
  grid-column: 1 / -1;
  font-size: 0.88rem;
  color: var(--text-muted);
  margin: 0;
}

.voice-provider-tabs {
  display: flex;
  gap: 0.35rem;
  margin: 0.75rem 0;
}

.voice-tab {
  flex: 1;
  padding: 0.5rem 0.65rem;
  border-radius: var(--radius);
  border: 1px solid var(--border);
  background: var(--bg-input);
  color: var(--text-muted);
  font: inherit;
  font-size: 0.82rem;
  cursor: pointer;
}

.voice-tab.active {
  background: var(--accent);
  color: var(--accent-text);
  border-color: var(--accent-hover);
  font-weight: 600;
}

.voice-premium-setup {
  margin-bottom: 0.75rem;
  padding: 0.75rem;
  border-radius: var(--radius);
  border: 1px solid var(--border);
  background: var(--bg-input);
}

.voice-premium-setup a {
  color: var(--soul);
}

.voice-key-row {
  display: flex;
  gap: 0.5rem;
  margin-top: 0.5rem;
}

.voice-key-row input {
  flex: 1;
  min-width: 0;
  padding: 0.5rem 0.65rem;
  border-radius: var(--radius);
  border: 1px solid var(--border);
  background: var(--bg);
  color: var(--text);
  font: inherit;
  font-size: 0.88rem;
}

.voice-key-status {
  margin: 0.5rem 0 0;
  font-size: 0.8rem;
  color: var(--text-muted);
}

.voice-key-status.ok {
  color: var(--ok);
}

.voice-key-status.err {
  color: #c88;
}

.memory-heart-panel {
  position: fixed;
  top: 0;
  right: 0;
  width: min(440px, 100vw);
  height: 100vh;
  z-index: 1200;
  background: var(--bg-panel, var(--bg));
  border-left: 1px solid var(--border);
  box-shadow: -4px 0 24px rgba(0, 0, 0, 0.25);
  display: flex;
  flex-direction: column;
  padding: 1rem;
  overflow: hidden;
}

.memory-heart-panel[hidden] {
  display: none !important;
}

.memory-heart-actions {
  display: flex;
  gap: 0.5rem;
  flex-wrap: wrap;
  margin-bottom: 0.75rem;
}

.memory-heart-stats {
  font-size: 0.82rem;
  color: var(--text-muted);
  margin-bottom: 0.75rem;
  line-height: 1.5;
}

.memory-heart-quota {
  display: flex;
  flex-direction: column;
  gap: 0.3rem;
  margin-bottom: 0.35rem;
}

.memory-quota-bar {
  font-size: 0.78rem;
  color: var(--text-muted);
  padding: 0.25rem 0.4rem;
  border-radius: 4px;
  background: rgba(0, 0, 0, 0.15);
}

.memory-heart-quota--warn,
.memory-quota-bar.memory-heart-quota--warn {
  color: #e8b86d;
  border: 1px solid rgba(232, 184, 109, 0.35);
}

.memory-heart-section {
  margin-bottom: 0.85rem;
  flex-shrink: 0;
}

.memory-heart-section h3 {
  margin: 0 0 0.35rem;
  font-size: 0.78rem;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--soul);
}

.memory-heart-pre {
  margin: 0;
  padding: 0.55rem 0.65rem;
  font-size: 0.78rem;
  line-height: 1.45;
  max-height: 140px;
  overflow-y: auto;
  background: var(--bg-input);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  white-space: pre-wrap;
  word-break: break-word;
}

.memory-heart-list {
  max-height: 160px;
  overflow-y: auto;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--bg-input);
  padding: 0.45rem;
}

.memory-heart-entry {
  padding: 0.45rem 0.35rem;
  border-bottom: 1px solid var(--border);
  font-size: 0.8rem;
  line-height: 1.4;
}

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

.memory-heart-entry time {
  display: block;
  font-size: 0.72rem;
  color: var(--text-muted);
  margin-bottom: 0.2rem;
}

.memory-heart-cloud {
  font-size: 0.82rem;
  line-height: 1.45;
  margin-bottom: 0.5rem;
  color: var(--text-muted);
}

.memory-heart-cloud.ok {
  color: var(--ok);
}

.memory-heart-cloud.warn {
  color: #c9a227;
}

.memory-heart-cloud.err {
  color: #c88;
}

.memory-heart-sir-derek,
.memory-heart-external-hdd {
  font-size: 0.82rem;
  line-height: 1.45;
  color: var(--text-muted);
}

.memory-heart-sir-derek.ok,
.memory-heart-external-hdd.ok {
  color: var(--ok);
}

.memory-heart-sir-derek.warn,
.memory-heart-external-hdd.warn {
  color: #c9a227;
}

.memory-heart-sir-derek.err,
.memory-heart-external-hdd.err {
  color: #c88;
}

.memory-heart-sir-derek-sections {
  margin: 0.35rem 0 0;
  padding-left: 1.1rem;
  font-size: 0.78rem;
}

.memory-heart-section--legacy h3 {
  font-size: 0.92rem;
  color: var(--text-muted);
}

#btn-hold-this.holding {
  background: #2a3a2a;
  border-color: var(--ok);
  color: var(--ok);
}

.mic-ring-wrap {
  position: relative;
  flex-shrink: 0;
  width: 48px;
  height: 48px;
  display: flex;
  align-items: center;
  justify-content: center;
}

.mic-usage-ring {
  position: absolute;
  inset: 0;
  width: 48px;
  height: 48px;
  pointer-events: none;
  transform: rotate(-90deg);
}

.mic-usage-track {
  fill: none;
  stroke: var(--border);
  stroke-width: 2.5;
}

.mic-usage-fill {
  fill: none;
  stroke-width: 2.5;
  stroke-linecap: round;
  transition: stroke-dashoffset 0.4s ease, stroke 0.3s ease;
}

.mic-usage-fill.tier-green {
  stroke: #5cb85c;
}

.mic-usage-fill.tier-yellow {
  stroke: #e6c229;
}

.mic-usage-fill.tier-red {
  stroke: #d9534f;
}

.mic-ring-wrap .btn-voice-mic {
  position: relative;
  z-index: 1;
}