:root {
  --sidebar-bg: #141416;
  --sidebar-width: 280px;
  --sidebar-item-hover: rgba(255,255,255,0.06);
  --sidebar-item-active: rgba(74,158,255,0.15);
  --content-bg: #0d0d0d;
  --surface: #1c1c1e;
  --text-primary: #ffffff;
  --text-secondary: #a0a0b0;
  --text-muted: #666680;
  --accent: #4a9eff;
  --accent-hover: #3a8eef;
  --danger: #ff4757;
  --border: rgba(255,255,255,0.08);
  --radius: 8px;
  --radius-sm: 4px;
  --font: 'IBM Plex Sans', 'Eurostile', system-ui, -apple-system, sans-serif;
  --transition: 150ms ease;
}

*, *::before, *::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

body {
  font-family: var(--font);
  background: var(--content-bg);
  color: var(--text-primary);
  overflow: hidden;
  height: 100vh;
}

#app {
  display: grid;
  grid-template-columns: var(--sidebar-width) 1fr;
  height: 100vh;
}

/* ===== SIDEBAR ===== */

#sidebar {
  background: var(--sidebar-bg);
  display: flex;
  flex-direction: column;
  overflow: hidden;
  border-right: 1px solid var(--border);
  user-select: none;
}

.sidebar-header {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 16px 16px 12px;
  flex-shrink: 0;
}

.logo {
  width: 32px;
  height: 32px;
  border-radius: 6px;
  object-fit: contain;
  flex-shrink: 0;
}

.workspace-name {
  font-weight: 600;
  font-size: 15px;
  color: var(--text-primary);
}

.presenting-badge {
  font-size: 9px;
  font-weight: 700;
  color: var(--text-primary);
  background: rgba(255,255,255,0.12);
  padding: 2px 6px;
  border-radius: 3px;
  letter-spacing: 0.05em;
  margin-left: auto;
}

.sidebar-search {
  display: flex;
  align-items: center;
  gap: 8px;
  margin: 0 12px 12px;
  padding: 8px 12px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  color: var(--text-muted);
  font-size: 13px;
  cursor: pointer;
  transition: border-color var(--transition);
}

.sidebar-search:hover {
  border-color: rgba(255,255,255,0.15);
}

.sidebar-search kbd {
  margin-left: auto;
  font-size: 11px;
  background: rgba(255,255,255,0.06);
  padding: 2px 6px;
  border-radius: 3px;
  font-family: var(--font);
}

.sidebar-section {
  flex: 1;
  overflow-y: auto;
  padding-bottom: 12px;
}

.sidebar-section::-webkit-scrollbar {
  width: 4px;
}

.sidebar-section::-webkit-scrollbar-track {
  background: transparent;
}

.sidebar-section::-webkit-scrollbar-thumb {
  background: rgba(255,255,255,0.1);
  border-radius: 2px;
}

.section-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 8px 16px;
  font-size: 11px;
  font-weight: 600;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

.icon-btn {
  width: 20px;
  height: 20px;
  display: flex;
  align-items: center;
  justify-content: center;
  border: none;
  background: none;
  color: var(--text-muted);
  font-size: 16px;
  cursor: pointer;
  border-radius: var(--radius-sm);
  transition: all var(--transition);
}

.icon-btn:hover {
  color: var(--accent);
  background: var(--sidebar-item-hover);
}

/* Dashboard tree items */

.dash-item {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 6px 16px;
  font-size: 13px;
  font-weight: 600;
  color: var(--text-secondary);
  cursor: pointer;
  border-radius: 0;
  transition: background var(--transition);
}

.dash-item:hover {
  background: var(--sidebar-item-hover);
}

.dash-item .chevron {
  font-size: 10px;
  transition: transform var(--transition);
  color: var(--text-muted);
  width: 14px;
  text-align: center;
  flex-shrink: 0;
}

.dash-item .chevron.expanded {
  transform: rotate(90deg);
}

.dash-item .dash-name {
  flex: 1;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.dash-item .add-slide-btn {
  opacity: 0;
  transition: opacity var(--transition);
  font-size: 14px;
}

.dash-item:hover .add-slide-btn {
  opacity: 1;
}

.slide-item {
  display: flex;
  align-items: center;
  padding: 5px 16px 5px 40px;
  font-size: 13px;
  font-weight: 400;
  color: var(--text-muted);
  cursor: pointer;
  transition: all var(--transition);
  border-left: 2px solid transparent;
}

.slide-item:hover {
  background: var(--sidebar-item-hover);
  color: var(--text-secondary);
}

.slide-item.active {
  background: var(--sidebar-item-active);
  color: var(--text-primary);
  border-left-color: var(--accent);
}

.slide-item .slide-name {
  flex: 1;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.slide-item[draggable="true"] {
  cursor: grab;
}

.slide-item.drag-over {
  border-top: 2px solid var(--accent);
}

/* Inline rename input */
.inline-input {
  background: rgba(255,255,255,0.1);
  border: 1px solid var(--accent);
  color: var(--text-primary);
  font-family: var(--font);
  font-size: 13px;
  padding: 2px 6px;
  border-radius: var(--radius-sm);
  outline: none;
  width: 100%;
}

.sidebar-footer {
  padding: 8px 16px;
  flex-shrink: 0;
  border-top: 1px solid var(--border);
}

.version {
  font-size: 11px;
  color: var(--text-muted);
}

/* ===== CONTENT AREA ===== */

#content {
  display: flex;
  flex-direction: column;
  overflow: hidden;
  position: relative;
}

#toolbar {
  display: flex;
  align-items: center;
  gap: 4px;
  padding: 8px 16px;
  background: rgba(13,13,13,0.9);
  backdrop-filter: blur(8px);
  border-bottom: 1px solid var(--border);
  flex-shrink: 0;
  z-index: 10;
}

.toolbar-group {
  display: flex;
  align-items: center;
  gap: 2px;
}

.toolbar-divider {
  width: 1px;
  height: 20px;
  background: var(--border);
  margin: 0 6px;
}

.toolbar-spacer {
  flex: 1;
}

.toolbar-btn {
  width: 36px;
  height: 36px;
  display: flex;
  align-items: center;
  justify-content: center;
  border: none;
  background: none;
  color: var(--text-secondary);
  font-family: var(--font);
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  border-radius: var(--radius);
  transition: all var(--transition);
}

.toolbar-btn:hover {
  background: var(--surface);
  color: var(--text-primary);
}

.toolbar-btn svg {
  pointer-events: none;
}

#slideContent {
  flex: 1;
  overflow-y: auto;
  padding: 40px 60px;
  max-width: 960px;
  width: 100%;
  margin: 0 auto;
}

#slideContent::-webkit-scrollbar {
  width: 6px;
}

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

#slideContent::-webkit-scrollbar-thumb {
  background: rgba(255,255,255,0.08);
  border-radius: 3px;
}

#emptyState {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 12px;
  color: var(--text-muted);
  font-size: 14px;
}

#emptyState.hidden {
  display: none;
}

/* ===== BLOCKS ===== */

.block {
  position: relative;
  margin-bottom: 8px;
  border-radius: var(--radius);
  transition: outline var(--transition);
  outline: 1px solid transparent;
}

.block:hover {
  outline: 1px solid var(--border);
}

.block-handle {
  position: absolute;
  left: -28px;
  top: 50%;
  transform: translateY(-50%);
  width: 20px;
  height: 24px;
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--text-muted);
  font-size: 12px;
  cursor: grab;
  opacity: 0;
  transition: opacity var(--transition);
  border-radius: var(--radius-sm);
  user-select: none;
}

.block:hover .block-handle {
  opacity: 1;
}

.block-handle:hover {
  background: var(--sidebar-item-hover);
  color: var(--text-secondary);
}

.block-delete {
  position: absolute;
  right: -28px;
  top: 50%;
  transform: translateY(-50%);
  width: 20px;
  height: 20px;
  display: flex;
  align-items: center;
  justify-content: center;
  border: none;
  background: none;
  color: var(--text-muted);
  font-size: 14px;
  cursor: pointer;
  opacity: 0;
  transition: opacity var(--transition);
  border-radius: var(--radius-sm);
}

.block:hover .block-delete {
  opacity: 1;
}

.block-delete:hover {
  color: var(--danger);
  background: rgba(255,71,87,0.1);
}

.block-heading {
  padding: 4px 8px;
  min-height: 1.2em;
}

.block-heading[data-level="1"] {
  font-size: 32px;
  font-weight: 700;
  line-height: 1.2;
}

.block-heading[data-level="2"] {
  font-size: 24px;
  font-weight: 600;
  line-height: 1.3;
}

.block-text {
  font-size: 16px;
  line-height: 1.6;
  padding: 4px 8px;
  min-height: 1.6em;
  white-space: pre-wrap;
}

.block-bullets,
.block-numbered {
  padding: 4px 8px 4px 28px;
  font-size: 16px;
  line-height: 1.6;
}

.block-bullets {
  list-style: none;
}

.block-bullets li::before {
  content: '';
  position: absolute;
  left: -18px;
  top: 0.7em;
  width: 6px;
  height: 6px;
  background: var(--accent);
  border-radius: 50%;
}

.block-bullets li,
.block-numbered li {
  position: relative;
  min-height: 1.6em;
  padding: 1px 0;
}

.block-numbered {
  list-style: decimal;
}

.block-numbered li {
  padding-left: 4px;
}

.block-numbered li::marker {
  color: var(--accent);
  font-weight: 600;
}

.block-image {
  padding: 4px 0;
  position: relative;
  display: inline-block;
  max-width: 100%;
}

.block-image img {
  max-width: 100%;
  border-radius: var(--radius);
  box-shadow: 0 2px 12px rgba(0,0,0,0.3);
  display: block;
}

.img-resize-handle {
  position: absolute;
  bottom: 4px;
  right: 0;
  width: 16px;
  height: 16px;
  cursor: nwse-resize;
  background: var(--accent);
  border-radius: 2px 0 var(--radius) 0;
  opacity: 0;
  transition: opacity var(--transition);
  z-index: 5;
}

.block-image:hover .img-resize-handle {
  opacity: 0.8;
}

.img-resize-handle:hover {
  opacity: 1 !important;
}

.block-embed {
  padding: 4px 0;
}

.embed-container {
  position: relative;
  width: 100%;
  padding-bottom: 56.25%;
  border-radius: var(--radius);
  overflow: hidden;
  background: #000;
}

.embed-container iframe {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  border: none;
}

/* Block editable focus */
[contenteditable]:focus {
  outline: none;
}

[contenteditable]:empty::before {
  content: attr(data-placeholder);
  color: var(--text-muted);
  pointer-events: none;
}

/* Drag over slide content area */
#slideContent.drag-over {
  outline: 2px dashed var(--accent);
  outline-offset: -4px;
}

.block.dragging {
  opacity: 0.4;
}

.block.drag-target-above {
  border-top: 2px solid var(--accent);
}

.block.drag-target-below {
  border-bottom: 2px solid var(--accent);
}

/* ===== SAVE INDICATOR ===== */

#saveIndicator {
  position: absolute;
  top: 12px;
  right: 16px;
  font-size: 12px;
  color: var(--text-muted);
  background: var(--surface);
  padding: 4px 10px;
  border-radius: var(--radius);
  transition: opacity var(--transition);
  z-index: 20;
}

#saveIndicator.hidden {
  opacity: 0;
  pointer-events: none;
}

#saveIndicator.saving {
  color: var(--accent);
}

/* ===== SEARCH MODAL ===== */

.modal {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  z-index: 100;
  display: flex;
  align-items: flex-start;
  justify-content: center;
  padding-top: 20vh;
}

.modal.hidden {
  display: none;
}

.modal-backdrop {
  position: absolute;
  inset: 0;
  background: rgba(0,0,0,0.6);
  backdrop-filter: blur(4px);
}

.modal-content {
  position: relative;
  width: 500px;
  max-height: 400px;
  background: var(--surface);
  border-radius: var(--radius);
  border: 1px solid var(--border);
  box-shadow: 0 16px 48px rgba(0,0,0,0.4);
  overflow: hidden;
  display: flex;
  flex-direction: column;
}

#searchInput {
  width: 100%;
  padding: 14px 16px;
  background: transparent;
  border: none;
  border-bottom: 1px solid var(--border);
  color: var(--text-primary);
  font-family: var(--font);
  font-size: 15px;
  outline: none;
}

#searchInput::placeholder {
  color: var(--text-muted);
}

#searchResults {
  overflow-y: auto;
  max-height: 300px;
  padding: 8px;
}

.search-group-label {
  font-size: 11px;
  font-weight: 600;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.05em;
  padding: 8px 8px 4px;
}

.search-result {
  padding: 8px 12px;
  font-size: 13px;
  color: var(--text-secondary);
  cursor: pointer;
  border-radius: var(--radius-sm);
  transition: background var(--transition);
}

.search-result:hover,
.search-result.focused {
  background: var(--sidebar-item-hover);
  color: var(--text-primary);
}

/* ===== CONTEXT MENU ===== */

.context-menu {
  position: fixed;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: 0 8px 24px rgba(0,0,0,0.4);
  padding: 4px;
  z-index: 200;
  min-width: 160px;
}

.context-menu.hidden {
  display: none;
}

.ctx-item {
  display: block;
  width: 100%;
  padding: 8px 12px;
  border: none;
  background: none;
  color: var(--text-secondary);
  font-family: var(--font);
  font-size: 13px;
  text-align: left;
  cursor: pointer;
  border-radius: var(--radius-sm);
  transition: all var(--transition);
}

.ctx-item:hover {
  background: var(--sidebar-item-hover);
  color: var(--text-primary);
}

.ctx-danger {
  color: var(--danger);
}

.ctx-danger:hover {
  background: rgba(255,71,87,0.1);
  color: var(--danger);
}

.ctx-divider {
  height: 1px;
  background: var(--border);
  margin: 4px 0;
}

/* ===== EMBED PROMPT ===== */

.embed-prompt {
  position: fixed;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 16px;
  z-index: 150;
  display: flex;
  gap: 8px;
  box-shadow: 0 8px 24px rgba(0,0,0,0.4);
}

.embed-prompt.hidden {
  display: none;
}

.embed-prompt input {
  width: 360px;
  padding: 8px 12px;
  background: rgba(255,255,255,0.06);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  color: var(--text-primary);
  font-family: var(--font);
  font-size: 13px;
  outline: none;
}

.embed-prompt input:focus {
  border-color: var(--accent);
}

.embed-prompt button {
  padding: 8px 14px;
  border: none;
  border-radius: var(--radius-sm);
  font-family: var(--font);
  font-size: 13px;
  cursor: pointer;
  transition: all var(--transition);
}

#embedConfirm {
  background: var(--accent);
  color: #fff;
}

#embedConfirm:hover {
  background: var(--accent-hover);
}

#embedCancel {
  background: rgba(255,255,255,0.06);
  color: var(--text-secondary);
}

#embedCancel:hover {
  background: rgba(255,255,255,0.1);
}

/* ===== TOASTS ===== */

#toastContainer {
  position: fixed;
  bottom: 16px;
  right: 16px;
  z-index: 300;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.toast {
  padding: 10px 16px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  font-size: 13px;
  color: var(--text-secondary);
  box-shadow: 0 4px 12px rgba(0,0,0,0.3);
  animation: toastIn 150ms ease;
}

.toast.error {
  border-color: rgba(255,71,87,0.3);
  color: var(--danger);
}

.toast.success {
  border-color: rgba(46,213,115,0.3);
  color: #2ed573;
}

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

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

#slideContent {
  animation: fadeIn 150ms ease;
}

/* ===== PRESENTATION MODE ===== */

.presentation-mode #toolbar {
  display: none;
}

.presentation-mode #slideContent {
  padding: 24px 40px;
}

/* ===== INLINE CONFIRM ===== */

.confirm-bar {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 6px 12px;
  background: rgba(255,71,87,0.1);
  border-radius: var(--radius-sm);
  font-size: 12px;
  color: var(--danger);
  margin: 4px 12px;
}

.confirm-bar button {
  padding: 3px 10px;
  border: none;
  border-radius: var(--radius-sm);
  font-family: var(--font);
  font-size: 12px;
  cursor: pointer;
}

.confirm-bar .confirm-yes {
  background: var(--danger);
  color: #fff;
}

.confirm-bar .confirm-no {
  background: rgba(255,255,255,0.06);
  color: var(--text-secondary);
}
