/* Hestini Writer — Workspace Layout (Quiet Canvas Design) */

/* === Top Bar === */
.topbar {
  display: flex;
  align-items: center;
  height: var(--topbar-height);
  padding: 0 16px;
  background: rgba(255, 255, 255, 0.92);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  box-shadow: 0 1px 0 rgba(0, 0, 0, 0.04);
  gap: 10px;
  flex-shrink: 0;
  z-index: 10;
}
.topbar-home {
  color: var(--text-tertiary);
  padding: 6px;
  border-radius: var(--radius-sm);
  transition: all 0.15s;
}
.topbar-home:hover {
  color: var(--accent-blue);
  background: rgba(4, 151, 175, 0.06);
}
.topbar-brand {
  font-size: 15px;
  font-weight: 700;
  color: var(--text-primary);
  letter-spacing: -0.3px;
}
.topbar-spacer { flex: 1; }
.topbar-progress-bar { flex: 1; }
.topbar-actions {
  display: flex;
  align-items: center;
  gap: 3px;
}
.topbar-action-btn {
  font-size: 11px !important;
  padding: 4px 10px !important;
  border-color: transparent !important;
  color: var(--text-tertiary) !important;
  background: transparent !important;
  gap: 5px !important;
  border-radius: var(--radius-sm) !important;
}
.topbar-action-btn:hover {
  color: var(--text-primary) !important;
  background: rgba(0, 0, 0, 0.04) !important;
  transform: none !important;
}
.topbar-action-btn svg {
  opacity: 0.6;
}
.topbar-action-btn:hover svg {
  opacity: 1;
}
.btn-present {
  color: var(--accent-purple) !important;
}
.pres-theme-select {
  font-size: 10px;
  padding: 3px 8px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: transparent;
  color: var(--text-tertiary);
  font-family: var(--font-sans);
  cursor: pointer;
}

/* === Main Workspace === */
.workspace {
  display: flex;
  height: calc(100vh - var(--topbar-height));
  overflow: hidden;
  position: relative;
}

/* === Left Panel (Sidebar Nav) === */
.left-panel {
  width: var(--left-panel-width);
  min-width: 0;
  background: var(--bg-elevated);
  border-right: 1px solid var(--border-light);
  display: flex;
  flex-direction: column;
  flex-shrink: 0;
  transition: width var(--transition-normal), min-width var(--transition-normal);
  overflow: hidden;
}
.left-panel.collapsed {
  width: 0;
  min-width: 0;
  border-right: none;
}

/* Sidebar header */
.sidebar-header {
  padding: 24px 20px 16px;
  flex-shrink: 0;
}
.sidebar-project-name {
  font-size: 14px;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--accent-blue);
  line-height: 1.3;
  word-break: break-word;
}
.sidebar-word-count {
  font-size: 10px;
  text-transform: uppercase;
  letter-spacing: 0.15em;
  color: var(--text-hint);
  margin-top: 3px;
}

/* Sidebar nav */
.sidebar-nav {
  flex: 1;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  min-height: 0;
}
.sidebar-section-label {
  font-size: 10px;
  text-transform: uppercase;
  letter-spacing: 0.12em;
  color: var(--text-hint);
  padding: 0 20px;
  display: block;
  margin-bottom: 6px;
  font-weight: 600;
}

/* Left tabs → sidebar nav items */
.left-tab {
  display: flex;
  align-items: center;
  gap: 10px;
  width: 100%;
  padding: 8px 20px;
  font-size: 13px;
  font-weight: 500;
  color: var(--text-secondary);
  background: none;
  border: none;
  border-left: 2px solid transparent;
  cursor: pointer;
  transition: all 0.15s;
  text-align: left;
  flex-shrink: 0;
}
.left-tab:hover {
  color: var(--accent-blue);
  background: rgba(4, 151, 175, 0.04);
}
.left-tab.active {
  color: var(--accent-blue);
  border-left-color: var(--accent-blue);
  background: rgba(4, 151, 175, 0.08);
  font-weight: 600;
}
.left-tab .nav-icon {
  font-size: 15px;
  width: 20px;
  text-align: center;
  flex-shrink: 0;
}

/* Tab content (shows below active tab) */
.left-tab-content {
  display: none;
  flex-direction: column;
  overflow: hidden;
  border-bottom: 1px solid var(--border-light);
}
.left-tab-content.active {
  display: flex;
  flex: 1;
  min-height: 120px;
}

/* Sidebar tab actions & body */
.sidebar-tab-actions {
  padding: 6px 12px;
  display: flex;
  gap: 4px;
  flex-shrink: 0;
}
.sidebar-tab-body {
  flex: 1;
  overflow-y: auto;
  padding: 0 12px 8px;
}
.sidebar-sub-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 4px;
}
.sidebar-sub-label {
  font-size: 10px;
  font-weight: 600;
  color: var(--text-hint);
  text-transform: uppercase;
  letter-spacing: 0.8px;
}

/* Graph container (inside content tab) */
.graph-container {
  flex: 55 0 0;
  position: relative;
  background: var(--bg-graph);
  box-shadow: 0 1px 0 var(--border-light);
  overflow: hidden;
  transition: flex 0.2s ease;
}
.graph-container.collapsed {
  flex: 0 0 32px;
}
.graph-container.collapsed #cy-mini {
  display: none;
}
.graph-container.collapsed .graph-toggle-btn {
  transform: rotate(-90deg);
}
.graph-container .graph-header {
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 6px 12px;
  z-index: 10;
  background: linear-gradient(to bottom, var(--bg-graph), transparent);
  cursor: pointer;
}
.graph-container.collapsed .graph-header {
  position: relative;
  background: var(--bg-graph);
}
.graph-toggle-btn {
  transition: transform 0.2s ease;
  font-size: 10px !important;
}
.graph-header .label {
  font-size: 10px;
  font-weight: 600;
  color: var(--text-tertiary);
  text-transform: uppercase;
  letter-spacing: 0.8px;
}
#cy-mini {
  width: 100%;
  height: 100%;
}

/* Chunk list */
.chunk-list-container {
  flex: 45 0 0;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}
.chunk-list-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 8px 12px;
  font-size: 10px;
  font-weight: 600;
  color: var(--text-tertiary);
  text-transform: uppercase;
  letter-spacing: 0.8px;
}
.chunk-list {
  flex: 1;
  overflow-y: auto;
  padding: 4px 0;
}

/* Chunk item */
.chunk-item {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 6px 12px;
  cursor: pointer;
  transition: background var(--transition-fast);
  border-left: 2px solid transparent;
  font-size: 13px;
}
.chunk-item:hover {
  background: rgba(0, 0, 0, 0.02);
}
.chunk-item.active {
  background: rgba(4, 151, 175, 0.06);
  border-left-color: var(--accent-blue);
}
.chunk-item .chunk-order {
  font-size: 11px;
  color: var(--text-hint);
  min-width: 16px;
}
.chunk-item .chunk-title {
  flex: 1;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  color: var(--text-primary);
}
.chunk-item .chunk-words {
  font-size: 11px;
  color: var(--text-hint);
}
.chunk-item .chunk-icon {
  font-size: 12px;
  color: var(--node-illustration);
}
.chunk-item.dragging {
  opacity: 0.4;
}
.chunk-item.drag-over {
  border-top: 2px solid var(--accent-blue);
  background: rgba(91, 156, 246, 0.08);
}
.chunk-item .status-dot {
  cursor: pointer;
  transition: transform 0.15s;
}
.chunk-item .status-dot:hover {
  transform: scale(1.4);
}
.chunk-item .chunk-edit,
.chunk-item .chunk-del {
  font-size: 13px;
  color: var(--text-hint);
  opacity: 0;
  cursor: pointer;
  transition: opacity 0.1s;
  padding: 0 2px;
  flex-shrink: 0;
}
.chunk-item:hover .chunk-edit,
.chunk-item:hover .chunk-del { opacity: 1; }
.chunk-item .chunk-edit:hover { color: var(--accent-blue); }
.chunk-item .chunk-del:hover { color: var(--accent-red); }
.chunk-rename-input {
  width: 100%;
  border: 1px solid var(--accent-blue);
  border-radius: 3px;
  padding: 1px 4px;
  font-size: 13px;
  font-family: var(--font-sans);
  outline: none;
  background: var(--bg-surface);
  color: var(--text-primary);
}

/* Narration child items */
.chunk-item.chunk-child {
  padding-left: 28px;
  font-size: 12px;
  border-left: 2px solid transparent;
  background: rgba(0,0,0,0.015);
  min-height: 28px;
}
.chunk-item.chunk-child .chunk-order { display: none; }
.chunk-item.chunk-child .chunk-title { font-size: 12px; color: var(--text-secondary); }
.chunk-item.chunk-child.active { background: rgba(4,151,175,0.08); }
.chunk-item .narration-icon { color: #e57373; font-size: 11px; }
.chunk-item .slide-icon { color: var(--accent-blue); font-size: 11px; }

/* TTS buttons: generate (gear) + play (triangle) */
.chunk-item .chunk-tts-gen,
.chunk-item .chunk-tts-play {
  font-size: 11px;
  cursor: pointer;
  opacity: 0;
  transition: opacity 0.15s;
  padding: 0 2px;
  flex-shrink: 0;
}
.chunk-item .chunk-tts-gen { color: var(--text-hint); }
.chunk-item .chunk-tts-play { color: var(--accent-green, #1aae39); }
.chunk-item:hover .chunk-tts-gen,
.chunk-item:hover .chunk-tts-play { opacity: 1; }
.chunk-item .chunk-tts-play:not(.hidden) { opacity: 1; } /* always visible if audio exists */
.chunk-item .chunk-tts-gen:hover { color: var(--accent-blue); }
.chunk-item .chunk-tts-play:hover { color: #0d8a2a; }
.chunk-item .chunk-tts-play.tts-active { color: var(--accent-red, #e57373); opacity: 1; }
.chunk-item .chunk-tts-gen.tts-loading { opacity: 1; animation: pulse-tts 1s infinite; }
@keyframes pulse-tts { 0%,100%{opacity:0.4} 50%{opacity:1} }

/* Add narration button */
.chunk-add-narration {
  padding: 3px 8px 3px 28px;
  font-size: 11px;
  color: var(--text-hint);
  cursor: pointer;
  transition: color 0.15s, background 0.15s;
  display: flex;
  align-items: center;
  gap: 4px;
}
.chunk-add-narration:hover {
  color: var(--accent-blue);
  background: rgba(4,151,175,0.04);
}
.chunk-add-narration .narration-add-icon {
  font-weight: 600;
  font-size: 13px;
}

/* === Center Panel === */
.center-panel {
  flex: 1;
  display: flex;
  flex-direction: column;
  min-width: 0;
  overflow: hidden;
}

/* Graph full view */
.graph-full {
  flex: 1;
  position: relative;
  background: var(--bg-graph);
  overflow: hidden;
}
#cy-main {
  width: 100%;
  height: 100%;
}

/* Star field canvas (behind cytoscape) */
#star-field {
  position: absolute;
  inset: 0;
  z-index: 0;
  pointer-events: none;
}

/* Editor area */
.editor-area {
  flex: 1;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}
.editor-content {
  flex: 1;
  padding: 24px 40px;
  overflow-y: auto;
  font-size: 15px;
  line-height: 1.75;
  color: var(--text-primary);
  outline: none;
  min-height: 200px;
  max-width: 780px;
  margin: 0 auto;
  width: 100%;
}
.editor-content:empty::before {
  content: attr(data-placeholder);
  color: var(--text-hint);
  font-style: italic;
}
.editor-content h1 { font-size: 1.6em; margin: 0.6em 0 0.3em; }
.editor-content h2 { font-size: 1.3em; margin: 0.5em 0 0.3em; }
.editor-content h3 { font-size: 1.1em; margin: 0.4em 0 0.2em; }
.editor-content p { margin-bottom: 0.8em; }
.editor-content ul, .editor-content ol { margin: 6px 0; padding-left: 24px; }
.editor-content li { margin: 3px 0; line-height: 1.6; }
.editor-content hr { border: 0; border-top: 1px solid var(--border, rgba(0,0,0,0.1)); margin: 16px 0; }
.editor-content blockquote {
  border-left: 3px solid var(--accent-blue);
  padding-left: 14px;
  margin: 0.8em 0;
  color: var(--text-secondary);
}
.editor-content code {
  background: var(--bg-elevated);
  padding: 2px 5px;
  border-radius: 3px;
  font-size: 0.9em;
}
/* Audio player */
.editor-content .inline-audio {
  margin: 16px 0;
  padding: 12px;
  background: var(--bg-elevated);
  border-radius: var(--radius-md);
  border: 1px solid var(--border-light);
}
.editor-content .inline-audio audio {
  width: 100%;
  height: 36px;
}
.editor-content .audio-caption {
  font-size: 12px;
  color: var(--text-tertiary);
  margin-top: 6px;
  font-style: italic;
}

.editor-content img {
  max-width: 100%;
  border-radius: var(--radius-md);
  margin: 12px 0;
}

/* Paragraph numbers (toggle) */
.editor-content.show-paranums > * {
  position: relative;
  counter-increment: para;
}
.editor-content.show-paranums > *::before {
  content: counter(para);
  position: absolute;
  left: -28px;
  top: 2px;
  font-size: var(--text-xs);
  color: var(--text-hint);
  font-weight: 600;
  width: 20px;
  text-align: right;
  user-select: none;
  pointer-events: none;
}
.editor-content.show-paranums {
  counter-reset: para;
  padding-left: 36px !important;
}
.toolbar-btn.active {
  background: var(--accent-blue);
  color: #fff;
  border-color: var(--accent-blue);
}

.toolbar-btn.is-loading {
  opacity: 0.6;
  cursor: wait;
}

.toolbar-btn.is-playing {
  background: var(--accent-blue, #3b82f6);
  color: #fff;
  border-color: var(--accent-blue, #3b82f6);
  animation: tts-pulse 1.4s ease-in-out infinite;
}

@keyframes tts-pulse {
  0%, 100% { box-shadow: 0 0 0 0 rgba(59, 130, 246, 0.55); }
  50%      { box-shadow: 0 0 0 6px rgba(59, 130, 246, 0); }
}

/* Inline notes (footnote-style superscript) */
.editor-content .inline-note {
  display: inline;
  cursor: help;
  font-size: var(--text-xs);
  font-weight: 700;
  color: var(--accent-purple);
  background: rgba(107, 63, 160, 0.08);
  padding: 0 3px;
  border-radius: 3px;
  margin: 0 1px;
  user-select: none;
  vertical-align: super;
  line-height: 1;
}
.editor-content .inline-note:hover {
  background: rgba(107, 63, 160, 0.16);
}

/* Note list in panel */
.note-item {
  font-size: 11px;
  padding: 3px 0;
  border-bottom: 1px solid var(--border-light);
  color: var(--text-secondary);
}
.note-num {
  color: var(--accent-purple);
  font-weight: 700;
  font-size: 10px;
}
.note-text {
  color: var(--text-primary);
}

/* Citations */
.editor-content sup.citation {
  color: var(--accent-blue);
  font-size: 10px;
  font-weight: 600;
  cursor: pointer;
  margin-left: 1px;
}
.editor-content sup.citation:hover {
  text-decoration: underline;
}

/* Comment highlights */
.editor-content mark.comment-hl {
  background: rgba(245, 158, 11, 0.12);
  border-bottom: 2px solid rgba(245, 158, 11, 0.5);
  cursor: pointer;
  padding: 0 1px;
  border-radius: 2px;
}
.editor-content mark.comment-hl:hover {
  background: rgba(245, 158, 11, 0.22);
}

/* Comment popup */
.comment-popup {
  position: absolute;
  z-index: 100;
  width: 280px;
  background: var(--bg-surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-md);
  padding: 8px;
}
.comment-popup textarea {
  width: 100%;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 6px 8px;
  font-size: 12px;
  resize: none;
  margin-bottom: 6px;
  font-family: var(--font-sans);
}

/* Comment panel below editor */
.comment-panel {
  max-height: 120px;
  overflow-y: auto;
  padding: 4px 16px 6px;
  flex-shrink: 0;
  border-top: 1px solid var(--border-light);
}
.comment-panel:empty { display: none; }
.comment-panel-header {
  font-size: 10px;
  font-weight: 600;
  color: var(--text-hint);
  text-transform: uppercase;
  letter-spacing: 0.8px;
  margin-bottom: 2px;
}
.comment-item {
  padding: 6px 0;
  border-bottom: 1px solid var(--border-light);
  font-size: 12px;
}
.comment-selected {
  color: var(--text-tertiary);
  font-style: italic;
  margin-bottom: 2px;
}
.comment-text {
  color: var(--text-primary);
  margin-bottom: 2px;
}
.comment-meta {
  font-size: 11px;
  color: var(--text-hint);
}
.comment-meta a {
  color: var(--accent-blue);
  text-decoration: none;
}

/* Resolve popup (click on highlight) */
.resolve-popup {
  position: absolute;
  z-index: 100;
  width: 240px;
  background: var(--bg-surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-md);
  padding: 10px;
}
.resolve-comment-text {
  font-size: 12px;
  color: var(--text-primary);
  margin-bottom: 2px;
}
.resolve-author {
  font-size: 11px;
  color: var(--text-hint);
}

/* Resolve button in comment list */
.comment-resolve-btn {
  min-width: 28px;
  height: 28px;
  padding: 0;
  font-size: 14px;
  color: var(--accent-green);
  border-color: var(--accent-green);
  flex-shrink: 0;
}
.comment-resolve-btn:hover {
  background: rgba(26, 174, 57, 0.1);
}

/* Editor footer — hidden, info duplicated in statusbar */
.editor-footer {
  display: none;
}
.editor-footer .save-status {
  display: flex;
  align-items: center;
  gap: 4px;
}
.save-status.saving { color: var(--accent-orange); }
.save-status.saved { color: var(--accent-green); }
.save-status.error { color: var(--accent-red); }

/* === Right Panel (AI Muse) === */
.right-panel {
  width: var(--right-panel-width);
  min-width: 0;
  background: var(--bg-elevated);
  border-left: none;
  display: flex;
  flex-direction: column;
  flex-shrink: 0;
  transition: width var(--transition-normal), min-width var(--transition-normal);
  overflow: hidden;
  position: relative;
}
.right-panel.collapsed {
  width: 0;
  min-width: 0;
  border-left: none;
}

/* Chat sidebar header */
.chat-sidebar-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 20px 20px 12px;
  flex-shrink: 0;
}
.chat-sidebar-title {
  font-size: 11px;
  font-weight: 800;
  color: var(--accent-blue);
  text-transform: uppercase;
  letter-spacing: 0.2em;
}
.chat-sidebar-actions {
  display: flex;
  align-items: center;
  gap: 2px;
}
.chat-sidebar-actions .btn-icon {
  color: var(--text-hint);
  padding: 4px;
  border-radius: var(--radius-sm);
}
.chat-sidebar-actions .btn-icon:hover {
  color: var(--text-tertiary);
  background: rgba(0, 0, 0, 0.04);
}

/* Jiva segment control */
.jiva-segment-wrap {
  padding: 0 16px 8px;
  flex-shrink: 0;
}
.right-panel .jiva-chips {
  display: flex;
  gap: 2px;
  padding: 3px;
  background: var(--bg-graph);
  border-radius: var(--radius-md);
  border: none;
  flex-wrap: nowrap;
  overflow: hidden;
}
.right-panel .jiva-chip {
  flex: 1;
  padding: 6px 4px;
  border-radius: var(--radius-sm);
  font-size: 10px;
  border: none;
  background: transparent;
  color: var(--text-tertiary);
  cursor: pointer;
  white-space: nowrap;
  transition: all 0.15s;
  font-weight: 600;
  text-align: center;
  text-transform: uppercase;
  letter-spacing: 0.03em;
}
.right-panel .jiva-chip.active {
  background: var(--bg-surface);
  color: var(--accent-blue);
  box-shadow: var(--shadow-sm);
}
.right-panel .jiva-chip:hover:not(.active) {
  color: var(--text-primary);
  background: rgba(0, 0, 0, 0.03);
  border-color: transparent;
}
.right-panel .jiva-more-toggle {
  flex: none;
  padding: 6px 8px;
  background: transparent !important;
  border: none !important;
  color: var(--text-hint) !important;
  font-size: 10px !important;
}

/* AI messages */
.ai-draft-area {
  margin-bottom: 12px;
}
.ai-messages {
  min-height: 150px;
  overflow-y: auto;
  margin-bottom: 0;
  padding: 12px 16px;
  display: flex;
  flex-direction: column;
  gap: 8px;
}
.right-panel .ai-messages {
  flex: 1;
  overflow-y: auto;
  padding: 8px 16px;
  min-height: 80px;
}
.right-panel .ai-draft-area {
  flex-shrink: 0;
  max-height: 200px;
  overflow-y: auto;
}

/* AI input area */
.ai-input-area {
  padding: 12px 16px;
  background: rgba(255, 255, 255, 0.5);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  flex-shrink: 0;
}
.ai-input-inner {
  position: relative;
}
.ai-input-field {
  width: 100%;
  background: var(--bg-graph);
  border: none;
  border-radius: var(--radius-lg);
  padding: 12px 48px 12px 16px;
  font-size: 13px;
  font-family: var(--font-sans);
  color: var(--text-primary);
  resize: none;
  min-height: 44px;
  max-height: 120px;
  line-height: 1.4;
  outline: none;
  transition: box-shadow 0.15s;
}
.ai-input-field::placeholder {
  color: var(--text-hint);
}
.ai-input-field:focus {
  box-shadow: 0 0 0 2px rgba(4, 151, 175, 0.15);
}
.ai-send-btn {
  position: absolute;
  bottom: 8px;
  right: 8px;
  width: 32px;
  height: 32px;
  background: var(--accent-blue);
  color: #fff;
  border: none;
  border-radius: var(--radius-md);
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: all 0.15s;
  box-shadow: var(--shadow-sm);
}
.ai-send-btn:hover {
  background: var(--accent-blue-hover);
  transform: scale(1.05);
}
.ai-send-btn:active {
  transform: scale(0.95);
}

/* Legacy ai-input-row support */
.ai-input-row {
  display: flex;
  gap: 8px;
  padding: 10px 14px;
  border-top: 1px solid var(--border-light);
  background: var(--bg-primary);
  align-items: flex-end;
}

/* Workflow controls */
.workflow-controls {
  margin-bottom: 0;
  padding: 0 10px;
  border-bottom: 1px solid var(--border);
}
.workflow-toggle {
  display: flex; align-items: center; justify-content: space-between;
  padding: 6px 0; cursor: pointer; user-select: none;
  font-size: 11px; color: var(--text-tertiary); text-transform: uppercase;
  letter-spacing: 0.5px; font-weight: 600;
}
.workflow-toggle:hover { color: var(--text-secondary); }
.workflow-toggle .wf-arrow {
  transition: transform 0.2s; font-size: 10px;
}
.workflow-toggle .wf-arrow.collapsed { transform: rotate(-90deg); }
.workflow-body { overflow: hidden; transition: max-height 0.25s ease; }
.workflow-body.collapsed { max-height: 0 !important; padding: 0; }
.attach-actions {
  margin-top: 16px;
  display: flex;
  flex-direction: column;
  gap: 6px;
}

/* === World items (abilities/artifacts) === */
.world-item-wrap {
  margin-bottom: 2px;
}
.world-item {
  display: flex;
  align-items: center;
  gap: 4px;
  padding: 5px 6px;
  border-radius: var(--radius-sm);
  transition: background 0.1s;
}
.world-item:hover { background: rgba(0, 0, 0, 0.02); }
.world-item-main { flex: 1; min-width: 0; }
.world-item-name { font-size: 12px; font-weight: 600; color: var(--text-primary); display: block; }
.world-item-meta { font-size: 10px; color: var(--text-tertiary); }
.world-item-del { font-size: 14px; color: var(--text-hint); opacity: 0; transition: opacity 0.1s; }
.world-item:hover .world-item-del { opacity: 1; }
.world-item-del:hover { color: var(--accent-red); }
.world-item-detail {
  display: none;
  padding: 4px 6px 8px 6px;
}
.world-item-wrap.expanded .world-item-detail {
  display: block;
}

/* === Character Relation Graph Modal === */
.char-graph-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.3);
  z-index: 200;
  display: flex;
  align-items: center;
  justify-content: center;
}
.char-graph-modal {
  width: 80vw;
  height: 70vh;
  max-width: 900px;
  background: var(--bg-surface);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-lg);
  display: flex;
  flex-direction: column;
  overflow: hidden;
  position: relative;
}
.char-graph-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 10px 16px;
  border-bottom: 1px solid var(--border);
  flex-shrink: 0;
}
.char-graph-title {
  font-size: 15px;
  font-weight: 600;
  color: var(--text-primary);
}
.char-graph-legend {
  padding: 8px 16px;
  border-top: 1px solid var(--border);
  flex-shrink: 0;
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 4px;
}
.char-graph-detail {
  position: absolute;
  bottom: 50px;
  right: 16px;
  width: 280px;
  max-height: 250px;
  overflow-y: auto;
  background: var(--bg-surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-md);
  padding: 10px;
  z-index: 10;
}
.char-graph-detail.hidden { display: none; }

/* === Sidebar-scoped component sizing === */
.sidebar-tab-body .btn-sm,
.sidebar-tab-actions .btn-sm {
  font-size: 10px;
  padding: 3px 8px;
}
.sidebar-tab-actions .btn-primary {
  font-weight: 600;
}
.left-tab-content .char-card {
  border-color: var(--border-light) !important;
  background: var(--bg-surface) !important;
  transition: border-color 0.15s;
}
.left-tab-content .char-card:hover {
  border-color: var(--border) !important;
}
.char-card:hover .char-del-btn {
  opacity: 1 !important;
}
.char-del-btn:hover {
  color: var(--accent-red) !important;
}

/* === Outline tree === */
.outline-tree {
  font-size: 13px;
  color: var(--text-secondary);
}

/* Panel collapse buttons */
.panel-toggle {
  position: absolute;
  top: 50%;
  transform: translateY(-50%);
  width: 16px;
  height: 40px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--bg-surface);
  border: 1px solid var(--border);
  border-radius: 0 var(--radius-sm) var(--radius-sm) 0;
  cursor: pointer;
  z-index: 20;
  color: var(--text-hint);
  font-size: 10px;
  transition: all var(--transition-fast);
}
.panel-toggle:hover {
  color: var(--text-primary);
  background: var(--bg-elevated);
}
.panel-toggle.left {
  left: 0;
  border-left: none;
}
.panel-toggle.right {
  right: 0;
  border-radius: var(--radius-sm) 0 0 var(--radius-sm);
  border-right: none;
}

/* === Floating Status Pill === */
.statusbar {
  position: absolute;
  bottom: 16px;
  left: 50%;
  transform: translateX(-50%);
  z-index: 20;
  pointer-events: auto;
}
.statusbar-pill {
  display: flex;
  align-items: center;
  gap: 0;
  padding: 8px 20px;
  background: rgba(26, 28, 28, 0.88);
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
  border-radius: 9999px;
  box-shadow: 0 4px 24px rgba(0, 0, 0, 0.15), 0 1px 6px rgba(0, 0, 0, 0.1);
  color: #fff;
}
.statusbar-group {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 0 12px;
}
.statusbar-label {
  font-size: 8px;
  text-transform: uppercase;
  letter-spacing: 0.15em;
  color: rgba(255, 255, 255, 0.4);
  font-weight: 500;
}
.statusbar-value {
  font-size: 11px;
  font-weight: 600;
  color: rgba(255, 255, 255, 0.9);
}
.statusbar-divider {
  width: 1px;
  height: 16px;
  background: rgba(255, 255, 255, 0.15);
}
/* Legacy statusbar-item & statusbar-spacer support */
.statusbar-item {
  display: flex;
  align-items: center;
  gap: 4px;
}
.statusbar-spacer { flex: 1; }
.statusbar kbd {
  font-size: 10px;
  padding: 1px 4px;
  background: rgba(255, 255, 255, 0.1);
  border: 1px solid rgba(255, 255, 255, 0.15);
  border-radius: 2px;
  font-family: var(--font-sans);
  color: rgba(255, 255, 255, 0.6);
}

/* === Preview Content === */
.preview-content {
  flex: 1;
  overflow-y: auto;
  padding: 40px;
  max-width: 720px;
  margin: 0 auto;
  width: 100%;
  font-family: var(--font-serif);
  font-size: 17px;
  line-height: 1.8;
  color: var(--text-primary);
}

/* === Welcome Screen === */
.screen-welcome {
  display: flex;
  flex-direction: column;
  height: 100vh;
  background: var(--bg-elevated);
}
.welcome-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 28px 40px 20px;
  flex-shrink: 0;
}
.welcome-brand {
  display: flex;
  flex-direction: column;
  gap: 4px;
}
.welcome-brand .brand-row {
  display: flex;
  align-items: baseline;
  gap: 8px;
}
.welcome-brand .brand-star {
  flex-shrink: 0;
  align-self: center;
  margin-right: 2px;
}
.brand-org {
  font-size: 28px;
  font-weight: 700;
  letter-spacing: 0.01em;
  color: var(--accent-blue, #0497AF);
  line-height: 1;
}
/* Masked logo: source SVG ships as white raster → use CSS mask so we control
   the final color. --logo-url is set inline by the bootstrap script. */
.welcome-brand .brand-logo {
  display: inline-block;
  width: 125px;
  height: 27px;
  background-color: var(--accent-blue, #0497AF);
  -webkit-mask-image: var(--logo-url);
  mask-image: var(--logo-url);
  -webkit-mask-size: contain;
  mask-size: contain;
  -webkit-mask-repeat: no-repeat;
  mask-repeat: no-repeat;
  -webkit-mask-position: left center;
  mask-position: left center;
}
.brand-wordmark {
  font-size: 28px;
  font-weight: 300;
  letter-spacing: 0.04em;
  color: var(--text-primary);
  line-height: 1;
}
.welcome-title {
  font-size: 18px;
  font-weight: 800;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--accent-blue);
  line-height: 1.2;
}
.welcome-subtitle {
  font-size: 10px;
  letter-spacing: 0.15em;
  text-transform: uppercase;
  color: var(--text-hint);
  margin-top: 2px;
}
.topbar-brand {
  display: inline-flex !important;
  align-items: baseline;
  gap: 6px;
}
.topbar-brand .topbar-star {
  flex-shrink: 0;
  align-self: center;
  margin-right: 1px;
}
.topbar-org {
  font-size: 16px;
  font-weight: 700;
  letter-spacing: 0.01em;
  color: var(--accent-blue, #0497AF);
  line-height: 1;
}
.topbar-brand .topbar-logo {
  display: inline-block;
  width: 80px;
  height: 18px;
  vertical-align: middle;
  background-color: var(--accent-blue, #0497AF);
  -webkit-mask-image: var(--logo-url);
  mask-image: var(--logo-url);
  -webkit-mask-size: contain;
  mask-size: contain;
  -webkit-mask-repeat: no-repeat;
  mask-repeat: no-repeat;
  -webkit-mask-position: left center;
  mask-position: left center;
}
.topbar-wordmark {
  font-size: 16px;
  font-weight: 400;
  letter-spacing: 0.03em;
  color: var(--text-primary);
  line-height: 1;
}
.welcome-header-actions {
  display: flex;
  align-items: center;
  gap: 8px;
}
.home-lang-select {
  padding: 4px 8px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  font-size: 11px;
  font-weight: 600;
  color: var(--text-tertiary);
  background: var(--bg-surface);
  cursor: pointer;
  font-family: var(--font-sans);
}
.welcome-header .user-badge {
  position: static;
}

/* Home toolbar */
.home-toolbar {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 0 40px 16px;
  flex-shrink: 0;
}
.home-search-wrap {
  position: relative;
  display: flex;
  align-items: center;
}
.home-search-icon {
  position: absolute;
  left: 10px;
  color: var(--text-hint);
  pointer-events: none;
}
.home-search {
  padding: 7px 12px 7px 32px;
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  font-size: 13px;
  width: 220px;
  background: var(--bg-surface);
  font-family: var(--font-sans);
  transition: border-color 0.15s;
}
.home-search:focus {
  border-color: var(--accent-blue);
  outline: none;
  box-shadow: 0 0 0 3px rgba(4, 151, 175, 0.08);
}
.home-filter {
  padding: 7px 28px 7px 10px;
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  font-size: 12px;
  background: var(--bg-surface);
  color: var(--text-secondary);
  font-family: var(--font-sans);
  cursor: pointer;
  appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg width='10' height='6' xmlns='http://www.w3.org/2000/svg'%3E%3Cpath d='M0 0l5 6 5-6z' fill='%23a39e98'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 10px center;
}
.home-toolbar-spacer { flex: 1; }
.home-view-btn {
  padding: 6px;
  color: var(--text-hint);
  border-radius: var(--radius-sm);
  transition: all 0.15s;
}
.home-view-btn.active {
  color: var(--accent-blue);
  background: rgba(4, 151, 175, 0.08);
}
.home-view-btn:hover:not(.active) {
  color: var(--text-secondary);
}
.home-new-btn {
  background: var(--accent-blue) !important;
  border-color: var(--accent-blue) !important;
  color: #fff !important;
  font-weight: 600 !important;
  gap: 6px !important;
  padding: 6px 16px !important;
  border-radius: var(--radius-md) !important;
  letter-spacing: 0.02em;
}
.home-new-btn:hover {
  background: var(--accent-blue-hover) !important;
  transform: none !important;
  box-shadow: var(--shadow-sm);
}

/* Project container */
.project-container {
  flex: 1;
  overflow-y: auto;
  padding: 0 40px 24px;
}

.project-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
  gap: 12px;
}
.project-grid.hidden { display: none; }

/* Project table */
.project-table { width: 100%; }
.project-table.hidden { display: none; }
.project-table table {
  width: 100%;
  border-collapse: collapse;
  font-size: 13px;
}
.project-table th {
  text-align: left;
  padding: 8px 12px;
  font-size: 10px;
  font-weight: 600;
  color: var(--text-hint);
  text-transform: uppercase;
  letter-spacing: 0.1em;
  border-bottom: 1px solid var(--border);
}
.project-row {
  cursor: pointer;
  transition: background 0.12s;
}
.project-row:hover { background: rgba(4, 151, 175, 0.04); }
.project-row td {
  padding: 10px 12px;
  border-bottom: 1px solid var(--border-light);
}
.project-row-title {
  font-weight: 600;
  color: var(--text-primary);
}

/* Card delete button */
.card-actions { display: flex; justify-content: flex-end; margin-top: 8px; }
.card-del {
  font-size: 16px;
  color: var(--text-hint);
  opacity: 0;
  transition: opacity 0.15s;
}
.project-card:hover .card-del,
.project-row:hover .card-del { opacity: 1; }
.card-del:hover { color: var(--accent-red); }

/* === Workspace Screen === */
.screen-workspace {
  display: flex;
  flex-direction: column;
  height: 100vh;
  position: relative;
}

/* === Preview Screen === */
.screen-preview {
  display: flex;
  flex-direction: column;
  height: 100vh;
}

/* === New Project Screen === */
.screen-new-project {
  display: flex;
  flex-direction: column;
  height: 100vh;
  background: var(--bg-elevated);
  overflow: hidden;
}
.new-project-content {
  max-width: 640px;
  margin: 0 auto;
  padding: 32px 40px 40px;
  width: 100%;
  flex: 1;
  overflow-y: auto;
}
.new-project-heading {
  font-size: 16px;
  font-weight: 700;
  margin-bottom: 20px;
  color: var(--text-primary);
  letter-spacing: -0.2px;
}

.type-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 12px;
  margin-bottom: 24px;
}

.form-footer {
  display: flex;
  gap: 8px;
  justify-content: flex-end;
  margin-top: 24px;
}

/* === Resizable Right Panel === */
.resize-handle {
  position: absolute;
  left: -3px;
  top: 0;
  bottom: 0;
  width: 6px;
  cursor: col-resize;
  z-index: 20;
  background: transparent;
  transition: background 0.15s;
}
.resize-handle:hover,
.resize-handle.active {
  background: var(--accent-blue);
}
.editor-content pre {
  background: var(--bg-elevated, #f6f5f4);
  border-radius: 8px;
  padding: 16px;
  overflow-x: auto;
  margin: 12px 0;
}
.editor-content pre code {
  font-family: var(--font-mono);
  font-size: 13px;
  line-height: 1.5;
  white-space: pre;
  background: none;
  padding: 0;
}
.editor-content table {
  width: 100%;
  border-collapse: collapse;
  margin: 12px 0;
  font-size: 14px;
}
.editor-content th {
  background: var(--bg-elevated, #f6f5f4);
  padding: 8px 12px;
  text-align: left;
  border-bottom: 2px solid var(--border, rgba(0,0,0,0.1));
  font-weight: 600;
}
.editor-content td {
  padding: 6px 12px;
  border-bottom: 1px solid var(--border, rgba(0,0,0,0.1));
}
.editor-content tr:hover td {
  background: rgba(0,0,0,0.02);
}

.inline-diagram {
  margin: 20px 0;
  text-align: center;
  user-select: none;
}
.inline-diagram img {
  max-width: 100%;
  border-radius: 8px;
  box-shadow: 0 2px 8px rgba(0,0,0,0.1);
}
.inline-diagram figcaption {
  font-size: 13px;
  color: var(--text-tertiary, #888);
  margin-top: 8px;
  font-style: italic;
}
.editor-content .inline-diagram {
  cursor: default;
}

.preview-content h1 { font-size: 1.8em; margin: 0.8em 0 0.4em; }
.preview-content h2 { font-size: 1.4em; margin: 1em 0 0.4em; border-bottom: 1px solid var(--border, rgba(0,0,0,0.1)); padding-bottom: 6px; }
.preview-content h3 { font-size: 1.15em; margin: 0.8em 0 0.3em; }
.preview-content h4 { font-size: 1.05em; margin: 0.6em 0 0.2em; }
.preview-content h5 { font-size: 1em; margin: 0.5em 0 0.2em; font-weight: 600; }
.preview-content ul, .preview-content ol { margin: 8px 0; padding-left: 28px; }
.preview-content li { margin: 4px 0; line-height: 1.7; }
.preview-content hr { border: 0; border-top: 1px solid var(--border, rgba(0,0,0,0.1)); margin: 20px 0; }
.preview-content pre {
  background: var(--bg-elevated);
  border-radius: 8px;
  padding: 16px;
  overflow-x: auto;
  margin: 16px 0;
}
.preview-content pre code {
  font-family: var(--font-mono);
  font-size: 13px;
  line-height: 1.5;
  white-space: pre;
  background: none;
  padding: 0;
}
.preview-content code {
  background: var(--bg-elevated);
  padding: 2px 6px;
  border-radius: 4px;
  font-size: 0.9em;
}
.preview-content table {
  width: 100%;
  border-collapse: collapse;
  margin: 16px 0;
  font-size: 15px;
}
.preview-content th {
  background: var(--bg-elevated, #f6f5f4);
  padding: 10px 14px;
  text-align: left;
  border-bottom: 2px solid var(--border, rgba(0,0,0,0.1));
  font-weight: 600;
}
.preview-content td {
  padding: 8px 14px;
  border-bottom: 1px solid var(--border, rgba(0,0,0,0.1));
}
.preview-content tr:hover td {
  background: rgba(255,255,255,0.03);
}

/* ── Block flash animation (AI content update) ── */
@keyframes block-flash-anim {
  0% { background-color: rgba(0, 117, 222, 0.18); }
  70% { background-color: rgba(0, 117, 222, 0.08); }
  100% { background-color: transparent; }
}
.editor-content .block-flash {
  animation: block-flash-anim 2s ease-out;
  border-radius: 4px;
}