* {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
}

body {
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  height: 100vh;
  display: flex;
  flex-direction: column;
  background: #1a1a2e;
  color: #e0e0e0;
}

#toolbar {
  display: flex;
  align-items: center;
  gap: 16px;
  padding: 8px 16px;
  background: #16213e;
  border-bottom: 1px solid #0f3460;
}

#toolbar h1 {
  font-size: 16px;
  font-weight: 600;
  color: #e94560;
}

.toolbar-btn {
  padding: 4px 12px;
  border: 1px solid #0f3460;
  border-radius: 4px;
  background: #1a1a2e;
  color: #e0e0e0;
  font-size: 12px;
  cursor: pointer;
}

.toolbar-btn:hover {
  background: #0f3460;
}

.toolbar-upgrade {
  background: #e94560;
  color: #fff;
  border-color: #e94560;
  font-weight: 600;
}
.toolbar-upgrade:hover {
  background: #d63851;
}

#file-name {
  font-size: 12px;
  color: #999;
  font-family: monospace;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  min-width: 0;
  flex-shrink: 1;
}

.toolbar-spacer {
  flex: 1;
}

.status {
  font-size: 12px;
  padding: 2px 8px;
  border-radius: 4px;
}

.status.connected {
  background: #0a3d0a;
  color: #4ade80;
}

.status.disconnected {
  background: #3d0a0a;
  color: #f87171;
}

#session-token {
  font-size: 11px;
  color: #666;
  font-family: monospace;
}

#workspace {
  flex: 1;
  display: flex;
  overflow: hidden;
}

#editor-pane {
  flex: 1;
  min-width: 100px;
  overflow: auto;
  position: relative;
}

#resize-handle {
  width: 5px;
  cursor: col-resize;
  background: #0f3460;
  flex-shrink: 0;
}

#resize-handle:hover,
#resize-handle.dragging {
  background: #e94560;
}

#preview-pane {
  flex: 1;
  min-width: 100px;
  overflow: hidden;
  position: relative;
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  font-size: 14px;
  line-height: 1.6;
}

#preview-content {
  height: 100%;
  overflow: auto;
  padding: 16px 24px;
}

/* Copy buttons */
.pane-copy-btn {
  position: absolute;
  top: 8px;
  right: 8px;
  z-index: 10;
  padding: 2px 10px;
  border: 1px solid #0f3460;
  border-radius: 4px;
  background: rgba(26, 26, 46, 0.85);
  color: #999;
  font-size: 11px;
  cursor: pointer;
  opacity: 0;
  transition: opacity 0.15s;
}

#editor-pane:hover .pane-copy-btn,
#preview-pane:hover .pane-copy-btn {
  opacity: 0.7;
}

.pane-copy-btn:hover {
  opacity: 1 !important;
  color: #e0e0e0;
  background: #16213e;
}

/* Click-to-navigate hover */
#preview-content [data-source-line]:hover {
  background: rgba(233, 69, 96, 0.06);
  cursor: pointer;
}

#preview-pane h1, #preview-pane h2, #preview-pane h3,
#preview-pane h4, #preview-pane h5, #preview-pane h6 {
  color: #e94560;
  margin: 1em 0 0.5em;
  border-bottom: 1px solid #0f3460;
  padding-bottom: 4px;
}

#preview-pane h1 { font-size: 1.8em; }
#preview-pane h2 { font-size: 1.4em; }
#preview-pane h3 { font-size: 1.2em; }

#preview-pane code {
  background: #16213e;
  padding: 2px 6px;
  border-radius: 3px;
  font-family: 'JetBrains Mono', 'Fira Code', monospace;
  font-size: 0.9em;
}

#preview-pane pre {
  background: #16213e;
  padding: 12px;
  border-radius: 6px;
  overflow-x: auto;
}

#preview-pane pre code {
  background: none;
  padding: 0;
}

#preview-pane blockquote {
  border-left: 3px solid #e94560;
  padding-left: 12px;
  margin-left: 0;
  color: #999;
}

#preview-pane a {
  color: #4dabf7;
  text-decoration: none;
}

#preview-pane ul, #preview-pane ol {
  padding-left: 24px;
}

#preview-pane li {
  margin: 4px 0;
}

#preview-pane table {
  border-collapse: collapse;
  width: 100%;
  margin: 1em 0;
}

#preview-pane th, #preview-pane td {
  border: 1px solid #0f3460;
  padding: 8px;
  text-align: left;
}

#preview-pane th {
  background: #16213e;
}

#preview-pane hr {
  border: none;
  border-top: 1px solid #0f3460;
  margin: 1em 0;
}

/* CodeMirror overrides */
.cm-editor {
  height: 100%;
}

.cm-editor .cm-scroller {
  font-family: 'JetBrains Mono', 'Fira Code', monospace;
  font-size: 14px;
}

.cm-editor .cm-content {
  padding: 16px;
}

/* Lock indicators */
.section-locked {
  background: rgba(233, 69, 96, 0.1);
  border-left: 3px solid #e94560;
}

/* Flash indicator for AI edits */
.ai-edit-flash {
  animation: flash 0.5s ease-out;
}

@keyframes flash {
  0% { background: rgba(233, 69, 96, 0.3); }
  100% { background: transparent; }
}

/* Write confirmation overlay (I6) */
.confirmation-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.7);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 1000;
}

.confirmation-dialog {
  background: #16213e;
  border: 1px solid #0f3460;
  border-radius: 8px;
  padding: 24px;
  max-width: 700px;
  width: 90%;
  max-height: 80vh;
  display: flex;
  flex-direction: column;
}

.confirmation-dialog h2 {
  color: #e94560;
  margin-bottom: 12px;
  font-size: 16px;
}

.confirmation-summary {
  color: #999;
  font-size: 13px;
  margin-bottom: 12px;
}

.confirmation-diff {
  flex: 1;
  overflow: auto;
  background: #1a1a2e;
  border: 1px solid #0f3460;
  border-radius: 4px;
  padding: 12px;
  font-family: 'JetBrains Mono', monospace;
  font-size: 12px;
  max-height: 400px;
  white-space: pre-wrap;
  color: #e0e0e0;
}

.confirmation-buttons {
  display: flex;
  gap: 12px;
  margin-top: 16px;
  justify-content: flex-end;
}

.confirmation-buttons button {
  padding: 8px 20px;
  border: none;
  border-radius: 4px;
  cursor: pointer;
  font-size: 14px;
  font-weight: 500;
}

.btn-accept {
  background: #4ade80;
  color: #000;
}

.btn-reject {
  background: #f87171;
  color: #000;
}

/* Account panel */
.account-panel {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.5);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 999;
}

.account-panel.hidden {
  display: none;
}

.account-card {
  background: #16213e;
  border: 1px solid #0f3460;
  border-radius: 8px;
  padding: 24px;
  width: 420px;
  max-width: 90vw;
}

.account-card h2 {
  color: #e94560;
  margin-bottom: 16px;
  font-size: 16px;
}

.account-field {
  margin-bottom: 14px;
}

.account-field label {
  display: block;
  font-size: 11px;
  color: #999;
  margin-bottom: 4px;
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

.account-field span, .account-field code {
  font-size: 13px;
  color: #e0e0e0;
}

.account-field code {
  font-family: 'JetBrains Mono', monospace;
  background: #1a1a2e;
  padding: 4px 8px;
  border-radius: 3px;
  font-size: 11px;
  word-break: break-all;
}

.api-key-row {
  display: flex;
  gap: 8px;
  align-items: center;
}

.api-key-row code {
  flex: 1;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
}

.account-actions {
  display: flex;
  gap: 8px;
  justify-content: flex-end;
  margin-top: 16px;
  padding-top: 12px;
  border-top: 1px solid #0f3460;
}

/* Context menu */
.tc-context-menu {
  position: fixed;
  z-index: 2000;
  background: #16213e;
  border: 1px solid #0f3460;
  border-radius: 6px;
  padding: 4px 0;
  min-width: 180px;
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.5);
  font-size: 13px;
  max-height: 80vh;
  overflow-y: auto;
}

.tc-ctx-item {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 6px 14px;
  cursor: pointer;
  color: #e0e0e0;
  gap: 16px;
}

.tc-ctx-item:hover {
  background: #0f3460;
  color: #fff;
}

.tc-ctx-shortcut {
  font-size: 11px;
  color: #666;
  font-family: monospace;
}

.tc-ctx-item:hover .tc-ctx-shortcut {
  color: #999;
}

.tc-ctx-separator {
  height: 1px;
  background: #0f3460;
  margin: 4px 8px;
}

/* Setup / Welcome modal code blocks */
.setup-code-block {
  display: flex;
  align-items: center;
  gap: 8px;
  background: #1a1a2e;
  border: 1px solid #0f3460;
  border-radius: 4px;
  padding: 8px 12px;
}

.setup-code-block code {
  flex: 1;
  font-family: 'JetBrains Mono', 'Fira Code', monospace;
  font-size: 13px;
  color: #e0e0e0;
  word-break: break-all;
  min-width: 0;
}

.setup-copy-btn {
  flex-shrink: 0;
}
