/* EditDocx Studio v3 — premium dark theme */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

:root {
  --bg:       #08080f;
  --surface:  #0e0e18;
  --surface2: #14141f;
  --surface3: #1c1c2b;
  --border:   #22223a;
  --border2:  #33335a;
  --accent:   #8b5cf6;
  --accent2:  #7c3aed;
  --accent-h: #a78bfa;
  --cyan:     #22d3ee;
  --green:    #10b981;
  --orange:   #f59e0b;
  --red:      #ef4444;
  --text:     #e9e9f2;
  --text-dim: #a0a0b8;
  --text-muted: #6b6b85;
  --grad:     linear-gradient(135deg, #8b5cf6 0%, #22d3ee 100%);
  --r:        10px;
  --r-lg:     16px;
  --r-sm:     6px;
  --shadow:   0 8px 40px rgba(0,0,0,.5);
  --shadow-sm:0 2px 10px rgba(0,0,0,.35);
  --sidebar-w: 264px;
  --right-w:   392px;
  --topbar-h:  56px;
  --status-h:  28px;
}

html, body { height: 100%; font-family: 'Inter', system-ui, sans-serif; background: var(--bg); color: var(--text); font-size: 13px; line-height: 1.5; overflow: hidden; }

/* ── Scrollbar ── */
::-webkit-scrollbar { width: 5px; height: 5px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--border2); border-radius: 10px; }
::-webkit-scrollbar-thumb:hover { background: var(--accent); }

/* ── Layout ── */
.app-shell { display: flex; height: 100vh; overflow: hidden; }

/* ── Sidebar ── */
.sidebar {
  width: var(--sidebar-w); min-width: var(--sidebar-w);
  background: var(--surface); border-right: 1px solid var(--border);
  display: flex; flex-direction: column; overflow: hidden;
  transition: width .22s ease;
}
.sidebar.collapsed { width: 0; min-width: 0; border: none; }

.sidebar-brand {
  display: flex; align-items: center; gap: 11px;
  padding: 18px 16px; border-bottom: 1px solid var(--border); flex-shrink: 0;
}
.brand-logo {
  width: 36px; height: 36px; border-radius: var(--r);
  background: var(--grad);
  display: flex; align-items: center; justify-content: center;
  color: #fff; flex-shrink: 0;
  box-shadow: 0 4px 16px rgba(139,92,246,.4);
}
.brand-name { font-size: 14px; font-weight: 700; letter-spacing: -.01em; white-space: nowrap; }
.brand-name span { background: var(--grad); -webkit-background-clip: text; background-clip: text; -webkit-text-fill-color: transparent; }
.brand-tagline { font-size: 10px; color: var(--text-muted); white-space: nowrap; }

.sidebar-nav { display: flex; flex-direction: column; gap: 3px; padding: 12px 9px; flex-shrink: 0; }
.nav-item {
  display: flex; align-items: center; gap: 10px; padding: 9px 11px;
  border-radius: var(--r); cursor: pointer; font-size: 12px; font-weight: 500;
  color: var(--text-dim); background: transparent; border: none;
  transition: all .15s; white-space: nowrap; text-decoration: none;
}
.nav-item:hover { background: var(--surface2); color: var(--text); }
.nav-item.active { background: linear-gradient(135deg, rgba(139,92,246,.18), rgba(34,211,238,.12)); color: var(--accent-h); }
.nav-item svg { flex-shrink: 0; }

.sidebar-section-label {
  font-size: 10px; font-weight: 700; color: var(--text-muted);
  text-transform: uppercase; letter-spacing: .09em;
  padding: 10px 16px 5px; flex-shrink: 0;
}

.doc-list { flex: 1; overflow-y: auto; padding: 4px 8px; display: flex; flex-direction: column; gap: 3px; }
.doc-card {
  padding: 9px 11px; border-radius: var(--r); cursor: pointer;
  border: 1px solid transparent; transition: all .15s;
  display: flex; align-items: flex-start; gap: 8px;
  position: relative;
}
.doc-card:hover { background: var(--surface2); border-color: var(--border); }
.doc-card.active { background: var(--surface2); border-color: var(--accent); box-shadow: 0 0 0 1px rgba(139,92,246,.3); }
.doc-card-body { flex: 1; min-width: 0; }
.doc-card-name { font-size: 12px; font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.doc-card-meta { font-size: 10px; color: var(--text-muted); margin-top: 2px; }
.doc-card-actions {
  display: flex; gap: 2px; opacity: 0; transition: opacity .15s; flex-shrink: 0;
}
.doc-card:hover .doc-card-actions, .doc-card.active .doc-card-actions { opacity: 1; }
.doc-card-btn {
  width: 24px; height: 24px; display: flex; align-items: center; justify-content: center;
  background: transparent; border: none; border-radius: var(--r-sm);
  color: var(--text-muted); cursor: pointer; transition: all .12s;
}
.doc-card-btn:hover { background: var(--surface3); color: var(--text); }
.doc-card-btn.delete:hover { background: rgba(239,68,68,.15); color: var(--red); }
.empty-doc-list { font-size: 11px; color: var(--text-muted); padding: 8px 8px; }

.sidebar-footer { padding: 13px 16px; border-top: 1px solid var(--border); flex-shrink: 0; }
.status-dot-row { display: flex; align-items: center; gap: 6px; font-size: 11px; color: var(--text-dim); }
.status-dot { width: 7px; height: 7px; border-radius: 50%; background: var(--text-muted); flex-shrink: 0; }
.status-dot.online { background: var(--green); box-shadow: 0 0 8px rgba(16,185,129,.6); }
.status-dot.offline { background: var(--red); }
.sidebar-footer-sub { font-size: 10px; color: var(--text-muted); margin-top: 4px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

/* ── Main area ── */
.main-area { flex: 1; display: flex; flex-direction: column; overflow: hidden; min-width: 0; }

/* ── Topbar ── */
.topbar {
  height: var(--topbar-h); min-height: var(--topbar-h);
  display: flex; align-items: center; justify-content: space-between;
  padding: 0 16px; border-bottom: 1px solid var(--border);
  background: rgba(14,14,24,.85); backdrop-filter: blur(12px);
  gap: 12px; flex-shrink: 0;
}
.topbar-left { display: flex; align-items: center; gap: 11px; min-width: 0; }
.topbar-doc-info { min-width: 0; }
.topbar-doc-title { font-size: 14px; font-weight: 700; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; letter-spacing: -.01em; }
.topbar-doc-meta { font-size: 11px; color: var(--text-muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.topbar-actions { display: flex; align-items: center; gap: 8px; flex-shrink: 0; }

/* Model badge */
.btn-model {
  display: inline-flex; align-items: center; gap: 7px;
  padding: 6px 12px; background: var(--surface2);
  border: 1px solid var(--border2); border-radius: 20px;
  color: var(--text); font-size: 11px; font-weight: 600;
  cursor: pointer; transition: all .15s;
}
.btn-model:hover { border-color: var(--accent); }
.model-dot { width: 7px; height: 7px; border-radius: 50%; background: var(--text-muted); }
.model-dot.online { background: var(--green); box-shadow: 0 0 8px rgba(16,185,129,.6); }
.model-dot.offline { background: var(--red); }

/* ── Buttons ── */
.btn-primary {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 8px 16px; background: var(--grad); color: #fff;
  border: none; border-radius: var(--r); cursor: pointer;
  font-size: 12px; font-weight: 600; transition: all .15s; white-space: nowrap;
}
.btn-primary:hover:not(:disabled) { filter: brightness(1.1); transform: translateY(-1px); }
.btn-primary:disabled { opacity: .4; cursor: not-allowed; }

.btn-ghost {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 7px 13px; background: transparent; color: var(--text-dim);
  border: 1px solid var(--border); border-radius: var(--r); cursor: pointer;
  font-size: 12px; font-weight: 500; transition: all .15s;
}
.btn-ghost:hover:not(:disabled) { background: var(--surface2); color: var(--text); border-color: var(--border2); }
.btn-ghost:disabled { opacity: .4; cursor: not-allowed; }

.btn-icon {
  width: 34px; height: 34px; display: flex; align-items: center; justify-content: center;
  background: transparent; border: none; border-radius: var(--r);
  cursor: pointer; color: var(--text-dim); transition: all .15s; flex-shrink: 0;
}
.btn-icon:hover { background: var(--surface2); color: var(--text); }

.btn-sm { padding: 5px 10px !important; font-size: 11px !important; }
.w-full { width: 100%; justify-content: center; }
.hidden { display: none !important; }

/* ── Form controls ── */
.input-field, .textarea-field, .select-field {
  width: 100%; padding: 9px 12px;
  background: var(--surface2); border: 1px solid var(--border);
  border-radius: var(--r); color: var(--text); font-size: 12px; font-family: inherit;
  transition: border-color .15s;
}
.input-field:focus, .textarea-field:focus, .select-field:focus {
  outline: none; border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(139,92,246,.15);
}
.input-field::placeholder, .textarea-field::placeholder { color: var(--text-muted); }
.textarea-field { resize: vertical; line-height: 1.5; }
.select-field { cursor: pointer; }
.field-label { display: block; font-size: 11px; font-weight: 600; color: var(--text-dim); margin-bottom: 6px; }

/* ── Workspace ── */
.workspace { flex: 1; display: flex; overflow: hidden; position: relative; }

/* ── Editor panel ── */
.editor-panel {
  flex: 1; display: flex; flex-direction: column;
  background: #0c0c15; overflow: hidden; position: relative;
}
.editor-canvas-wrap {
  flex: 1; display: flex; flex-direction: column;
  overflow: hidden; background: #3d3d3d;
  position: relative;
  background-image:
    radial-gradient(circle at 1px 1px, rgba(255,255,255,.04) 1px, transparent 0);
  background-size: 16px 16px;
}
.editor-view-controls {
  display: flex; align-items: center; justify-content: space-between;
  padding: 5px 12px; background: var(--surface);
  border-bottom: 1px solid var(--border); flex-shrink: 0; gap: 10px;
}
.view-controls-left, .view-controls-right { display: flex; align-items: center; gap: 6px; }
.view-btn {
  width: 28px; height: 28px; display: inline-flex; align-items: center; justify-content: center;
  background: var(--surface2); border: 1px solid var(--border); border-radius: var(--r-sm);
  color: var(--text-dim); cursor: pointer; font-size: 13px; transition: all .12s;
}
.view-btn:hover { background: var(--surface3); color: var(--text); border-color: var(--border2); }
.view-select {
  height: 28px; padding: 0 8px; background: var(--surface2);
  border: 1px solid var(--border); border-radius: var(--r-sm);
  color: var(--text); font-size: 11px; font-family: inherit; cursor: pointer;
}
.view-toggle {
  display: inline-flex; align-items: center; gap: 5px;
  font-size: 10px; color: var(--text-muted); cursor: pointer; user-select: none;
}
.view-toggle input { accent-color: var(--accent); }
.view-page-info { font-size: 10px; color: var(--text-dim); font-weight: 600; padding-left: 8px; border-left: 1px solid var(--border); }

.editor-ruler-row {
  display: flex; flex-shrink: 0; background: #ececec;
  border-bottom: 1px solid #b0b0b0; height: 22px; overflow: hidden;
}
.ruler-corner {
  width: 28px; min-width: 28px; background: #e0e0e0;
  border-right: 1px solid #b0b0b0; flex-shrink: 0;
}
.editor-ruler {
  flex: 1; height: 22px; position: relative; overflow: hidden;
  background: linear-gradient(180deg, #f5f5f5 0%, #ececec 100%);
}
.ruler-tick {
  position: absolute; bottom: 0; width: 1px; background: #888;
}
.ruler-tick.major { height: 12px; background: #555; }
.ruler-tick.minor { height: 6px; }
.ruler-label {
  position: absolute; bottom: 12px; font-size: 8px; color: #666;
  transform: translateX(-50%); font-family: Arial, sans-serif; user-select: none;
}
.ruler-margin {
  position: absolute; top: 0; bottom: 0; width: 1px;
  background: #4a90d9; opacity: .7; pointer-events: none;
}
.ruler-margin.left { box-shadow: 1px 0 0 rgba(74,144,217,.3); }
.ruler-margin.right { box-shadow: -1px 0 0 rgba(74,144,217,.3); }

.para-block.ai-target {
  border-color: rgba(139,92,246,.55) !important;
  background: rgba(139,92,246,.06) !important;
  box-shadow: inset 3px 0 0 var(--accent);
  animation: ai-target-pulse 1.6s ease-in-out infinite;
}
@keyframes ai-target-pulse {
  0%, 100% { box-shadow: inset 3px 0 0 var(--accent), 0 0 0 0 rgba(139,92,246,0); }
  50% { box-shadow: inset 3px 0 0 var(--accent), 0 0 0 3px rgba(139,92,246,.18); }
}
.para-block.ai-edited {
  animation: ai-flash 1.8s ease;
}
@keyframes ai-flash {
  0%,100% { background: transparent; }
  15% { background: rgba(163,230,53,.18); box-shadow: inset 3px 0 0 #a3e635; }
}

/* ── Inline AI chat (fixed bottom of editor) ── */
.editor-ai-dock {
  flex-shrink: 0;
  margin: 0 12px 10px;
  z-index: 20;
  background: rgba(14,14,24,.96);
  backdrop-filter: blur(16px);
  border: 1px solid rgba(139,92,246,.45);
  border-radius: 16px;
  box-shadow: 0 -4px 32px rgba(0,0,0,.4), 0 0 0 1px rgba(139,92,246,.15);
  overflow: hidden;
  transition: max-height .25s ease, opacity .2s ease, margin .2s ease;
  max-height: 200px;
}
.editor-ai-dock.collapsed {
  max-height: 0; opacity: 0; margin-bottom: 0; margin-top: 0;
  border-width: 0; pointer-events: none; overflow: hidden;
}
.editor-ai-dock.hidden { display: none !important; }
.editor-ai-header {
  display: flex; align-items: center; gap: 10px;
  padding: 8px 12px; border-bottom: 1px solid var(--border);
  background: linear-gradient(135deg, rgba(139,92,246,.12), rgba(34,211,238,.06));
}
.editor-ai-brand {
  display: flex; align-items: center; gap: 6px;
  font-size: 11px; font-weight: 700; color: var(--accent-h);
  white-space: nowrap; flex-shrink: 0;
}
.editor-ai-target {
  flex: 1; min-width: 0; display: flex; align-items: center; gap: 5px;
  font-size: 10px; color: var(--text-dim);
  padding: 4px 10px; background: rgba(0,0,0,.25);
  border-radius: 20px; border: 1px solid var(--border);
}
.editor-ai-target.active { border-color: rgba(139,92,246,.45); color: var(--text); }
.editor-ai-target .target-icon { flex-shrink: 0; }
#editor-ai-target-text {
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.editor-ai-collapse {
  width: 28px; height: 28px; display: flex; align-items: center; justify-content: center;
  background: transparent; border: none; border-radius: var(--r-sm);
  color: var(--text-muted); cursor: pointer; flex-shrink: 0;
  transition: all .12s;
}
.editor-ai-collapse:hover { background: var(--surface3); color: var(--text); }
.editor-ai-body { padding: 10px 12px 12px; }
.editor-ai-quick {
  display: flex; gap: 6px; flex-wrap: wrap; margin-bottom: 8px;
}
.ea-chip {
  padding: 4px 10px; background: var(--surface2);
  border: 1px solid var(--border); border-radius: 20px;
  font-size: 10px; font-weight: 600; color: var(--text-dim);
  cursor: pointer; transition: all .12s; white-space: nowrap;
}
.ea-chip:hover:not(:disabled) {
  border-color: var(--accent); color: var(--accent-h);
  background: rgba(139,92,246,.1);
}
.ea-chip:disabled { opacity: .35; cursor: not-allowed; }
.editor-ai-input-row {
  display: flex; align-items: flex-end; gap: 8px;
}
.editor-ai-input {
  flex: 1; padding: 10px 12px; background: var(--surface2);
  border: 1px solid var(--border2); border-radius: 12px;
  color: var(--text); font-size: 12px; font-family: inherit;
  resize: none; max-height: 100px; line-height: 1.5;
  transition: border-color .15s, box-shadow .15s;
}
.editor-ai-input:focus {
  outline: none; border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(139,92,246,.18);
}
.editor-ai-input::placeholder { color: var(--text-muted); }
.editor-ai-send {
  width: 40px; height: 40px; border-radius: 12px; border: none;
  background: var(--grad); color: #fff; cursor: pointer;
  display: flex; align-items: center; justify-content: center;
  transition: all .15s; flex-shrink: 0;
}
.editor-ai-send:hover:not(:disabled) { filter: brightness(1.1); transform: scale(1.03); }
.editor-ai-send:disabled { opacity: .4; cursor: not-allowed; }
.editor-ai-hint {
  margin-top: 6px; font-size: 9px; color: var(--text-muted);
}
.editor-ai-hint kbd {
  padding: 1px 5px; background: var(--surface3); border-radius: 4px;
  font-family: inherit; font-size: 9px; border: 1px solid var(--border);
}

/* Busy state — AI is editing the document right now */
.editor-ai-dock.busy {
  border-color: rgba(139,92,246,.75);
  box-shadow: 0 -4px 32px rgba(0,0,0,.4), 0 0 0 1px rgba(139,92,246,.35),
    0 0 24px rgba(139,92,246,.25);
}
.editor-ai-dock.busy .editor-ai-brand::before {
  content: '';
  width: 10px; height: 10px; border-radius: 50%;
  border: 2px solid rgba(255,255,255,.25);
  border-top-color: #fff;
  animation: ai-spin .7s linear infinite;
  flex-shrink: 0;
}
.editor-ai-dock.busy .editor-ai-target {
  border-color: rgba(34,211,238,.5);
  color: var(--text);
  animation: ai-target-blink 1s ease-in-out infinite;
}
@keyframes ai-spin { to { transform: rotate(360deg); } }
@keyframes ai-target-blink {
  0%, 100% { opacity: 1; }
  50% { opacity: .55; }
}
.editor-ai-fab {
  position: absolute; bottom: 14px; right: 14px;
  width: 48px; height: 48px; border-radius: 50%;
  background: var(--grad); border: none; color: #fff;
  cursor: pointer; z-index: 19;
  display: flex; align-items: center; justify-content: center;
  box-shadow: 0 6px 24px rgba(139,92,246,.45);
  transition: all .18s;
}
.editor-ai-fab:hover { transform: scale(1.06); filter: brightness(1.08); }
.editor-ai-fab.hidden { display: none; }

.view-btn-ai {
  width: auto !important; padding: 0 10px !important; gap: 4px;
  font-size: 10px; font-weight: 700; color: var(--accent-h);
  border-color: rgba(139,92,246,.35) !important;
}
.view-btn-ai:hover { background: rgba(139,92,246,.15) !important; }

/* Floating toolbar on text selection */
.canvas-ai-toolbar {
  position: fixed; z-index: 100;
  display: flex; align-items: center; gap: 3px;
  padding: 4px 6px; background: rgba(14,14,24,.96);
  border: 1px solid rgba(139,92,246,.45); border-radius: 10px;
  box-shadow: 0 8px 32px rgba(0,0,0,.5);
  backdrop-filter: blur(12px);
  pointer-events: all;
  animation: toolbar-in .15s ease;
}
@keyframes toolbar-in {
  from { opacity: 0; transform: translateY(4px); }
  to { opacity: 1; transform: none; }
}
.cat-btn {
  min-width: 30px; height: 28px; padding: 0 8px;
  background: transparent; border: none; border-radius: 7px;
  color: var(--text-dim); font-size: 13px; cursor: pointer;
  transition: all .1s;
}
.cat-btn:hover { background: var(--surface3); color: var(--text); }
.cat-btn-primary {
  background: linear-gradient(135deg, rgba(139,92,246,.25), rgba(34,211,238,.12));
  color: var(--accent-h); font-size: 11px; font-weight: 700;
}
.cat-btn-primary:hover { filter: brightness(1.1); }
.cat-sep { width: 1px; height: 18px; background: var(--border); margin: 0 2px; }

/* Right-click context menu */
.canvas-ctx-menu {
  position: fixed; z-index: 101; min-width: 220px;
  background: rgba(14,14,24,.98); border: 1px solid var(--border2);
  border-radius: 12px; padding: 6px;
  box-shadow: var(--shadow); backdrop-filter: blur(14px);
  animation: toolbar-in .12s ease;
}
.ctx-head {
  padding: 6px 10px 4px; font-size: 10px; font-weight: 700;
  color: var(--text-muted); text-transform: uppercase; letter-spacing: .05em;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.ctx-item {
  display: block; width: 100%; text-align: left;
  padding: 8px 10px; background: transparent; border: none;
  border-radius: 8px; color: var(--text-dim); font-size: 12px;
  cursor: pointer; transition: all .1s;
}
.ctx-item:hover { background: var(--surface3); color: var(--text); }
.ctx-item.ctx-primary { color: var(--accent-h); font-weight: 600; }
.ctx-sep { height: 1px; background: var(--border); margin: 4px 6px; }

.editor-viewport {
  flex: 1; overflow: auto; padding: 28px 20px 20px;
  scroll-behavior: smooth; position: relative;
}

.editor-zoom-wrap {
  display: flex; justify-content: center;
  transform-origin: top center;
  transition: transform .15s ease;
  min-height: 100%;
}
.doc-page-frame {
  position: relative; flex-shrink: 0;
}
.page-margin-guides {
  position: absolute; inset: 0; pointer-events: none; z-index: 2;
}
.page-margin-guides.hidden { display: none; }
.margin-guide {
  position: absolute; border: 1px dashed rgba(74,144,217,.35);
  pointer-events: none;
}
.page-break-overlay {
  position: absolute; inset: 0; pointer-events: none; z-index: 1;
}
.page-break-line {
  position: absolute; left: -8px; right: -8px; height: 0;
  border-top: 1px dashed rgba(100,100,100,.25);
}
.page-break-label {
  position: absolute; right: -4px; top: -8px;
  font-size: 9px; color: rgba(100,100,100,.5);
  background: #3d3d3d; padding: 0 4px; border-radius: 3px;
  font-family: Arial, sans-serif;
}

.editor-canvas {
  background: #fff; color: #1a1a1a;
  width: 210mm; min-height: 297mm;
  padding: 25mm 25mm 25mm 30mm;
  box-shadow:
    0 2px 8px rgba(0,0,0,.15),
    0 12px 40px rgba(0,0,0,.35),
    0 0 0 1px rgba(0,0,0,.08);
  position: relative; outline: none;
  border-radius: 1px;
  font-family: Calibri, 'Segoe UI', Arial, sans-serif;
  font-size: 11pt; line-height: 1.5;
  z-index: 0;
}

.para-block {
  outline: none; border: 1px solid transparent; border-radius: 2px;
  transition: border-color .1s; cursor: text;
  white-space: pre-wrap; word-break: break-word; min-height: 1.4em;
  position: relative;
}
.para-block:hover { border-color: rgba(74,144,217,.25); }
.para-block:focus { border-color: rgba(74,144,217,.45); background: rgba(74,144,217,.03); }
.para-block.h1 { font-size: 18pt; font-weight: 700; margin: 10px 0 5px; }
.para-block.h2 { font-size: 14pt; font-weight: 700; margin: 8px 0 4px; }
.para-block.h3 { font-size: 12pt; font-weight: 700; margin: 6px 0 3px; }
.citation-mark { color: #7c3aed; font-size: .8em; vertical-align: super; cursor: pointer; font-weight: 600; }
.citation-mark:hover { text-decoration: underline; }

.flash-para { transition: box-shadow .3s; }

/* ── Format ribbon (Word-like tools) ── */
.format-ribbon {
  display: flex; align-items: center; gap: 4px;
  padding: 6px 10px; background: var(--surface);
  border-bottom: 1px solid var(--border);
  flex-wrap: wrap; flex-shrink: 0;
  position: sticky; top: 0; z-index: 5;
}
.ribbon-group { display: flex; align-items: center; gap: 2px; }
.ribbon-sep { width: 1px; height: 20px; background: var(--border); margin: 0 5px; }
.ribbon-btn {
  min-width: 30px; height: 28px; padding: 0 6px;
  display: inline-flex; align-items: center; justify-content: center;
  background: transparent; border: 1px solid transparent; border-radius: var(--r-sm);
  color: var(--text-dim); font-size: 12px; cursor: pointer; transition: all .12s;
}
.ribbon-btn:hover:not(:disabled) { background: var(--surface3); color: var(--text); }
.ribbon-btn.active { background: rgba(139,92,246,.18); color: var(--accent-h); border-color: rgba(139,92,246,.4); }
.ribbon-btn:disabled { opacity: .35; cursor: not-allowed; }
.ribbon-btn-inline { font-family: Georgia, 'Times New Roman', serif; font-size: 14px; }
.ribbon-btn-inline b { font-weight: 800; }
.ribbon-btn-inline i { font-family: Georgia, serif; }
.ribbon-btn-inline u { text-decoration: underline; text-underline-offset: 2px; }
.ribbon-btn-inline s { text-decoration: line-through; }
.ribbon-select {
  height: 28px; padding: 0 6px; background: var(--surface2);
  border: 1px solid var(--border); border-radius: var(--r-sm);
  color: var(--text); font-size: 11px; font-family: inherit; cursor: pointer;
  max-width: 110px;
}
.ribbon-select-wide { max-width: 130px; }
.ribbon-select:focus { outline: none; border-color: var(--accent); }
.ribbon-number {
  width: 46px; height: 28px; padding: 0 4px; text-align: center;
  background: var(--surface2); border: 1px solid var(--border); border-radius: var(--r-sm);
  color: var(--text); font-size: 11px; font-family: inherit;
}
.ribbon-number:focus { outline: none; border-color: var(--accent); }
.ribbon-unit { font-size: 10px; color: var(--text-muted); margin-left: -2px; }

.color-group { gap: 4px; }
.color-tool {
  display: inline-flex; align-items: center; gap: 3px;
  position: relative; height: 28px; padding: 0 7px;
  background: var(--surface2); border: 1px solid var(--border);
  border-radius: var(--r-sm); cursor: pointer; color: var(--text-dim);
  font-weight: 700; font-size: 12px;
}
.color-tool:hover { border-color: var(--accent); color: var(--text); }
.color-tool input[type="color"] {
  width: 14px; height: 14px; border: none; padding: 0; background: transparent;
  cursor: pointer;
}
.color-tool input[type="color"]::-webkit-color-swatch-wrapper { padding: 0; }
.color-tool input[type="color"]::-webkit-color-swatch { border: none; border-radius: 3px; }
.highlight-tool span { background: linear-gradient(180deg, transparent 45%, #fff59d 45%, #fff59d 70%, transparent 70%); border-radius: 2px; }

/* Table picker popover */
.table-picker {
  position: absolute; top: 100%; left: 0; z-index: 60;
  background: var(--surface2); border: 1px solid var(--border2);
  border-radius: var(--r); padding: 10px;
  box-shadow: var(--shadow); min-width: 200px;
}
.tp-label { font-size: 11px; font-weight: 600; color: var(--text-dim); margin-bottom: 8px; }
.tp-grid {
  display: grid; grid-template-columns: repeat(8, 14px); gap: 3px;
  margin-bottom: 8px;
}
.tp-cell {
  width: 14px; height: 14px; border: 1px solid var(--border2);
  border-radius: 2px; cursor: pointer; background: var(--surface3);
  transition: all .1s;
}
.tp-cell.hover { background: var(--accent); border-color: var(--accent-h); }
.tp-foot { display: flex; align-items: center; gap: 4px; font-size: 11px; color: var(--text-dim); }
.tp-foot input {
  width: 42px; height: 24px; padding: 0 4px; text-align: center;
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--r-sm);
  color: var(--text); font-size: 11px;
}

/* ── Document canvas: lists & tables (Word-like) ── */
#editor-canvas ul.docx-list, #editor-canvas ul, #editor-canvas ol {
  padding-left: 2.2em; margin: 4px 0; list-style-position: outside;
}
#editor-canvas ul.docx-list li, #editor-canvas ul li, #editor-canvas ol li {
  margin: 2px 0; padding-left: 4px;
}
#editor-canvas .para-table {
  border-collapse: collapse; margin: 8px 0; width: 100%;
  font-size: 11pt;
}
#editor-canvas .para-table td {
  border: 1px solid #bbb; padding: 4px 8px; min-width: 46px;
  vertical-align: top; background: #fff;
}
#editor-canvas .para-table td:focus {
  outline: 2px solid rgba(74,144,217,.5); outline-offset: -1px;
}

/* ── Hero (scispace-style) ── */
.empty-state {
  flex: 1; display: flex; flex-direction: column; align-items: center;
  justify-content: center; gap: 18px; padding: 40px 24px; text-align: center;
  background:
    radial-gradient(700px 320px at 30% 0%, rgba(139,92,246,.16), transparent 60%),
    radial-gradient(700px 320px at 75% 10%, rgba(34,211,238,.12), transparent 60%);
}
.hero-badge {
  display: inline-flex; align-items: center; gap: 8px;
  padding: 6px 14px; border: 1px solid var(--border2);
  border-radius: 20px; font-size: 11px; font-weight: 600; color: var(--accent-h);
  background: rgba(139,92,246,.08);
}
.hero-pulse { width: 7px; height: 7px; border-radius: 50%; background: var(--green); animation: pulse 1.6s infinite; }
.hero-title {
  font-family: 'Sora', 'Inter', sans-serif;
  font-size: clamp(26px, 4vw, 40px); font-weight: 800; line-height: 1.15;
  letter-spacing: -.02em;
}
.grad-text { background: var(--grad); -webkit-background-clip: text; background-clip: text; -webkit-text-fill-color: transparent; }
.hero-sub { font-size: 13px; color: var(--text-dim); max-width: 560px; line-height: 1.7; }

.hero-input-wrap { width: 100%; max-width: 760px; display: flex; flex-direction: column; gap: 12px; }
.hero-input-box {
  display: flex; align-items: flex-start; gap: 12px;
  background: var(--surface); border: 1px solid var(--border2);
  border-radius: 18px; padding: 16px 18px;
  box-shadow: var(--shadow);
  transition: border-color .2s, box-shadow .2s;
}
.hero-input-box:focus-within { border-color: var(--accent); box-shadow: 0 0 0 4px rgba(139,92,246,.18), var(--shadow); }
.hero-input-icon { color: var(--accent-h); margin-top: 3px; flex-shrink: 0; }
.hero-input {
  flex: 1; background: transparent; border: none; outline: none;
  color: var(--text); font-size: 15px; line-height: 1.55;
  font-family: inherit; resize: none; min-height: 48px;
}
.hero-input::placeholder { color: var(--text-muted); }
.hero-options { display: flex; gap: 10px; flex-wrap: wrap; align-items: flex-end; }
.hero-option { display: flex; flex-direction: column; gap: 4px; flex: 1; min-width: 110px; text-align: left; }
.hero-opt-label { font-size: 10px; font-weight: 600; color: var(--text-muted); text-transform: uppercase; letter-spacing: .05em; }
.hero-cta { min-height: 40px; }

.hero-features { display: flex; gap: 8px; flex-wrap: wrap; justify-content: center; margin-top: 6px; }
.hero-feature {
  display: inline-flex; align-items: center; gap: 6px;
  font-size: 11px; color: var(--text-dim); padding: 5px 12px;
  border: 1px solid var(--border); border-radius: 20px; background: rgba(14,14,24,.6);
}
.feat-icon { font-size: 12px; }

/* ── Right panel ── */
.panel-resizer {
  width: 7px; flex-shrink: 0; cursor: col-resize;
  background: transparent; position: relative; z-index: 6;
  transition: background .15s;
}
.panel-resizer::before {
  content: ''; position: absolute; inset: 0 2px; border-radius: 4px;
  transition: background .15s, box-shadow .15s;
}
.panel-resizer:hover::before,
.panel-resizer.dragging::before {
  background: var(--accent); box-shadow: 0 0 12px rgba(139,92,246,.45);
}
.panel-resizer.dragging { z-index: 8; }
body.resizing { cursor: col-resize; user-select: none; }
body.resizing iframe { pointer-events: none; }

.right-panel {
  width: var(--right-w); min-width: var(--right-w);
  border-left: 1px solid var(--border); background: var(--surface);
  display: flex; flex-direction: column; overflow: hidden;
  transition: width .22s cubic-bezier(.4,0,.2,1), min-width .22s cubic-bezier(.4,0,.2,1), border-color .22s;
}
.right-panel.collapsed { width: 0; min-width: 0; border-left-color: transparent; }

.panel-reopen {
  position: absolute; top: 50%; right: 0; transform: translateY(-50%);
  width: 30px; height: 72px; border-radius: 9px 0 0 9px;
  background: var(--surface2); border: 1px solid var(--border2); border-right: none;
  color: var(--text-dim); cursor: pointer; z-index: 5;
  display: flex; align-items: center; justify-content: center;
  transition: all .18s ease;
}
.panel-reopen:hover { background: var(--accent); color: #fff; border-color: var(--accent); box-shadow: -6px 0 18px rgba(139,92,246,.35); }

.panel-toggle.active { background: rgba(139,92,246,.16); color: var(--accent-h); border-color: rgba(139,92,246,.4); }

.panel-tabs { display: flex; border-bottom: 1px solid var(--border); flex-shrink: 0; }
.tab-btn {
  flex: 1; display: flex; align-items: center; justify-content: center; gap: 5px;
  padding: 12px 4px; background: transparent; border: none; border-bottom: 2px solid transparent;
  cursor: pointer; font-size: 11px; font-weight: 600; color: var(--text-muted); transition: all .15s;
}
.tab-btn:hover { color: var(--text); }
.tab-btn.active { color: var(--accent-h); border-bottom-color: var(--accent); }
.tab-collapse {
  width: 40px; flex-shrink: 0; display: flex; align-items: center; justify-content: center;
  background: transparent; border: none; cursor: pointer;
  color: var(--text-muted); transition: all .15s;
}
.tab-collapse:hover { color: var(--accent-h); background: var(--surface3); }
.tab-content { display: none; flex-direction: column; flex: 1; overflow: hidden; }
.tab-content.active { display: flex; }

/* ── Chat tab ── */
.chat-panel { flex: 1; display: flex; flex-direction: column; overflow: hidden; }
.chat-messages { flex: 1; overflow-y: auto; padding: 14px 12px; display: flex; flex-direction: column; gap: 12px; }
.chat-msg { display: flex; gap: 8px; align-items: flex-start; }
.chat-user { flex-direction: row-reverse; }
.chat-avatar {
  width: 28px; height: 28px; border-radius: 50%; flex-shrink: 0;
  display: flex; align-items: center; justify-content: center;
  background: var(--grad); color: #fff;
}
.chat-user .chat-avatar { background: var(--surface3); color: var(--text-dim); }
.chat-bubble {
  max-width: 82%; padding: 10px 13px; border-radius: 14px;
  font-size: 12px; line-height: 1.6; color: var(--text);
  background: var(--surface2); border: 1px solid var(--border);
  border-top-left-radius: 4px;
}
.chat-user .chat-bubble {
  background: linear-gradient(135deg, rgba(139,92,246,.2), rgba(34,211,238,.12));
  border-color: rgba(139,92,246,.3); border-top-left-radius: 14px; border-top-right-radius: 4px;
}
.chat-bubble p { margin-bottom: 6px; }
.chat-bubble p:last-child { margin-bottom: 0; }
.chat-suggestions { display: flex; flex-direction: column; gap: 6px; margin-top: 8px; }
.chip {
  padding: 6px 10px; background: transparent; border: 1px dashed var(--border2);
  border-radius: 10px; color: var(--text-dim); font-size: 11px; cursor: pointer;
  text-align: left; transition: all .15s;
}
.chip:hover { border-color: var(--accent); color: var(--accent-h); background: rgba(139,92,246,.06); }
.thinking { display: flex; align-items: center; gap: 6px; color: var(--text-muted); }
.thinking span {
  width: 6px; height: 6px; border-radius: 50%; background: var(--accent-h);
  animation: bounce 1.2s infinite;
}
.thinking span:nth-child(2) { animation-delay: .15s; }
.thinking span:nth-child(3) { animation-delay: .3s; }
@keyframes bounce { 0%,100% { opacity:.3; transform: translateY(0); } 50% { opacity:1; transform: translateY(-3px); } }

.chat-input-wrap {
  display: flex; align-items: flex-end; gap: 8px;
  padding: 12px; border-top: 1px solid var(--border);
  background: var(--surface);
}
.chat-input {
  flex: 1; padding: 10px 13px; background: var(--surface2);
  border: 1px solid var(--border2); border-radius: 14px;
  color: var(--text); font-size: 12px; font-family: inherit;
  resize: none; max-height: 120px; line-height: 1.5;
}
.chat-input:focus { outline: none; border-color: var(--accent); }
.chat-input::placeholder { color: var(--text-muted); }
.chat-send {
  width: 38px; height: 38px; border-radius: 12px; border: none;
  background: var(--grad); color: #fff; cursor: pointer;
  display: flex; align-items: center; justify-content: center;
  transition: all .15s; flex-shrink: 0;
}
.chat-send:hover:not(:disabled) { filter: brightness(1.1); }
.chat-send:disabled { opacity: .4; cursor: not-allowed; }

/* ── Research tab ── */
.search-box { padding: 11px; border-bottom: 1px solid var(--border); flex-shrink: 0; }
.search-input-wrap { display: flex; align-items: center; gap: 6px; position: relative; }
.search-icon { position: absolute; left: 10px; color: var(--text-muted); pointer-events: none; }
.search-input {
  flex: 1; padding: 8px 9px 8px 30px; background: var(--surface2);
  border: 1px solid var(--border); border-radius: var(--r);
  color: var(--text); font-size: 12px; font-family: inherit;
}
.search-input:focus { outline: none; border-color: var(--accent); }
.search-filters { display: flex; gap: 5px; margin-top: 8px; flex-wrap: wrap; }
.filter-btn {
  padding: 3px 9px; background: transparent; border: 1px solid var(--border);
  border-radius: 20px; cursor: pointer; font-size: 10px; color: var(--text-muted);
  transition: all .15s;
}
.filter-btn:hover { border-color: var(--accent); color: var(--accent-h); }
.filter-btn.active { background: linear-gradient(135deg, rgba(139,92,246,.15), rgba(34,211,238,.1)); border-color: var(--accent); color: var(--accent-h); font-weight: 600; }

.search-results { flex: 1; overflow-y: auto; padding: 9px; display: flex; flex-direction: column; gap: 9px; }
.search-empty { display: flex; flex-direction: column; align-items: center; gap: 8px; padding: 36px 16px; color: var(--text-muted); text-align: center; }
.search-empty p { font-size: 12px; }

.research-card {
  background: var(--surface2); border: 1px solid var(--border);
  border-radius: var(--r-lg); padding: 13px; transition: all .15s;
}
.research-card:hover { border-color: var(--border2); transform: translateY(-1px); }
.research-card-top { display: flex; align-items: flex-start; justify-content: space-between; gap: 8px; margin-bottom: 6px; }
.research-card-badges { display: flex; align-items: center; gap: 4px; flex-wrap: wrap; flex-shrink: 0; }
.research-card-title { font-size: 12px; font-weight: 600; line-height: 1.45; color: var(--text); }
.research-card-title a { color: inherit; text-decoration: none; }
.research-card-title a:hover { color: var(--accent-h); text-decoration: underline; }
.research-card-meta { font-size: 11px; color: var(--text-dim); margin-bottom: 6px; }
.research-card-abstract { font-size: 11px; color: var(--text-dim); line-height: 1.55; margin-bottom: 9px; }
.research-card-actions { display: flex; gap: 6px; flex-wrap: wrap; }

.badge {
  display: inline-flex; align-items: center; padding: 2px 7px;
  border-radius: 20px; font-size: 10px; font-weight: 600;
  background: var(--surface3); color: var(--text-dim);
}
.badge-count { background: rgba(139,92,246,.18); color: var(--accent-h); }
.source-badge { font-size: 9px; font-weight: 700; padding: 2px 7px; border-radius: var(--r-sm); }
.source-badge.crossref { background: rgba(59,130,246,.15); color: #60a5fa; }
.source-badge.semanticscholar { background: rgba(16,185,129,.12); color: #34d399; }
.source-badge.openalex { background: rgba(245,158,11,.12); color: #fbbf24; }
.source-badge.scholar { background: rgba(139,92,246,.15); color: var(--accent-h); }
.source-badge.garuda { background: rgba(239,68,68,.12); color: #f87171; }

/* ── Reference verification (anti-halucination) ── */
.ref-verify-wrap { margin-left: auto; }
.verify-badge {
  display: inline-flex; align-items: center; gap: 4px;
  font-size: 10px; font-weight: 600; padding: 2px 8px;
  border-radius: 20px; margin-top: 6px;
}
.verify-badge.ok { background: rgba(16,185,129,.14); color: #34d399; border: 1px solid rgba(16,185,129,.35); }
.verify-badge.bad { background: rgba(239,68,68,.12); color: #f87171; border: 1px solid rgba(239,68,68,.35); }
.verify-badge.pending { background: rgba(245,158,11,.12); color: #fbbf24; border: 1px solid rgba(245,158,11,.3); }
.spinner-sm { width: 12px; height: 12px; border: 2px solid rgba(255,255,255,.25); border-top-color: var(--accent-h); border-radius: 50%; display: inline-block; vertical-align: -2px; margin-right: 4px; animation: spin .7s linear infinite; }
.search-empty-sub { font-size: 11px; color: var(--text-muted); max-width: 260px; line-height: 1.55; }
.search-empty code { font-family: ui-monospace, monospace; font-size: 10px; color: var(--accent-h); background: var(--surface3); padding: 1px 5px; border-radius: 4px; }
.open-access-badge { background: rgba(16,185,129,.15); color: #34d399; }

.skeleton { background: linear-gradient(90deg, var(--surface2) 25%, var(--surface3) 50%, var(--surface2) 75%); background-size: 200% 100%; animation: shimmer 1.4s infinite; border-radius: var(--r); }
.skeleton-card { height: 110px; }
@keyframes shimmer { 0% { background-position: 200% 0; } 100% { background-position: -200% 0; } }

/* ── References panel ── */
.ref-panel { flex: 1; display: flex; flex-direction: column; overflow: hidden; }
.ref-toolbar { display: flex; align-items: center; justify-content: space-between; padding: 11px 11px 7px; flex-shrink: 0; }
.ref-count-label { font-size: 11px; color: var(--text-dim); }
.ref-list { flex: 1; overflow-y: auto; padding: 6px 9px; display: flex; flex-direction: column; gap: 7px; }
.empty-refs { display: flex; flex-direction: column; align-items: center; gap: 8px; padding: 36px 16px; color: var(--text-muted); text-align: center; }
.empty-refs p { font-size: 11px; }
.ref-item {
  background: var(--surface2); border: 1px solid var(--border);
  border-radius: var(--r); padding: 9px 11px;
  display: flex; align-items: flex-start; gap: 8px;
}
.ref-num { font-size: 10px; font-weight: 700; color: var(--accent-h); min-width: 22px; padding-top: 1px; }
.ref-item-body { flex: 1; min-width: 0; }
.ref-item-title { font-size: 11px; font-weight: 600; line-height: 1.4; }
.ref-item-meta { font-size: 10px; color: var(--text-muted); margin-top: 2px; }

/* ── Spinner ── */
.spinner {
  width: 16px; height: 16px; border: 2px solid rgba(255,255,255,.25);
  border-top-color: #fff; border-radius: 50%;
  animation: spin .7s linear infinite; flex-shrink: 0;
}
.spinner-lg { width: 24px; height: 24px; border-color: var(--border2); border-top-color: var(--accent); }
@keyframes spin { to { transform: rotate(360deg); } }

/* ── Status bar ── */
.status-bar {
  height: var(--status-h); min-height: var(--status-h);
  display: flex; align-items: center; justify-content: space-between;
  padding: 0 16px; border-top: 1px solid var(--border);
  background: var(--surface); font-size: 10px; color: var(--text-muted); flex-shrink: 0;
}
.status-right { display: flex; align-items: center; gap: 8px; }
.status-sep { color: var(--border2); }

/* ── Modal ── */
.modal-backdrop {
  position: fixed; inset: 0; background: rgba(4,4,10,.7);
  backdrop-filter: blur(6px); z-index: 1000;
  display: flex; align-items: center; justify-content: center; padding: 20px;
}
.modal {
  background: var(--surface); border: 1px solid var(--border2);
  border-radius: var(--r-lg); width: 100%; max-width: 500px;
  max-height: 90vh; display: flex; flex-direction: column;
  box-shadow: var(--shadow); animation: modal-in .2s ease;
}
.modal-lg { max-width: 680px; }
.modal-sm { max-width: 420px; }
.delete-doc-msg { font-size: 13px; color: var(--text-dim); line-height: 1.6; margin-bottom: 10px; }
.delete-doc-name {
  padding: 10px 12px; background: var(--surface2); border: 1px solid var(--border);
  border-radius: var(--r); font-size: 13px; font-weight: 600; color: var(--text);
}
.btn-danger {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 8px 16px; background: var(--red); color: #fff;
  border: none; border-radius: var(--r); cursor: pointer;
  font-size: 12px; font-weight: 600; transition: all .15s;
}
.btn-danger:hover { filter: brightness(1.1); }
@keyframes modal-in { from { opacity: 0; transform: translateY(12px) scale(.98); } to { opacity: 1; transform: none; } }
.modal-header {
  display: flex; align-items: center; justify-content: space-between;
  padding: 17px 20px; border-bottom: 1px solid var(--border); flex-shrink: 0;
}
.modal-header h3 { font-size: 15px; font-weight: 700; letter-spacing: -.01em; }
.modal-body { padding: 20px; overflow-y: auto; flex: 1; }
.modal-footer {
  display: flex; align-items: center; justify-content: flex-end; gap: 8px;
  padding: 13px 20px; border-top: 1px solid var(--border); flex-shrink: 0;
}
.settings-note {
  margin-top: 14px; padding: 10px 12px; border-radius: var(--r);
  background: rgba(139,92,246,.07); border: 1px solid rgba(139,92,246,.2);
  font-size: 11px; color: var(--text-dim); line-height: 1.6;
}

.template-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 9px; margin-top: 6px; }
.template-card {
  display: flex; flex-direction: column; align-items: center; gap: 7px;
  padding: 14px 8px; background: var(--surface2);
  border: 2px solid var(--border); border-radius: var(--r);
  cursor: pointer; font-size: 11px; font-weight: 600; color: var(--text-dim);
  transition: all .15s; text-align: center;
}
.template-card:hover { border-color: var(--border2); color: var(--text); }
.template-card.active { border-color: var(--accent); color: var(--accent-h); background: linear-gradient(135deg, rgba(139,92,246,.1), rgba(34,211,238,.06)); }

/* ── Toast ── */
.toast-wrap { position: fixed; bottom: 26px; right: 26px; z-index: 2000; display: flex; flex-direction: column; gap: 8px; pointer-events: none; }
.toast {
  padding: 11px 17px; border-radius: var(--r); font-size: 12px; font-weight: 500;
  pointer-events: all; box-shadow: var(--shadow); max-width: 340px;
  animation: toast-in .2s ease;
}
.toast.info { background: var(--surface2); border: 1px solid var(--border2); color: var(--text); }
.toast.success { background: #06281b; border: 1px solid var(--green); color: #6ee7b7; }
.toast.error { background: #2b0a0a; border: 1px solid var(--red); color: #fca5a5; }
@keyframes toast-in { from { opacity: 0; transform: translateY(10px); } to { opacity: 1; transform: none; } }

/* ── Ref detail modal ── */
.ref-detail-section { margin-bottom: 16px; }
.ref-detail-section h4 { font-size: 11px; font-weight: 700; color: var(--text-muted); margin-bottom: 6px; text-transform: uppercase; letter-spacing: .06em; }
.ref-detail-section p { font-size: 13px; line-height: 1.65; color: var(--text); }
.tldr-box { background: linear-gradient(135deg, rgba(139,92,246,.1), rgba(34,211,238,.06)); border: 1px solid rgba(139,92,246,.2); border-radius: var(--r); padding: 11px 13px; font-size: 12px; color: var(--text-dim); font-style: italic; }
.ref-mini-list { display: flex; flex-direction: column; gap: 6px; max-height: 220px; overflow-y: auto; }
.ref-mini-item { font-size: 11px; padding: 7px 9px; background: var(--surface2); border-radius: var(--r-sm); color: var(--text-dim); }

/* ── Mobile ── */
@media (max-width: 900px) {
  :root { --sidebar-w: 0px; --right-w: 100%; }
  .sidebar { display: none; }
  .right-panel { display: none; }
  .panel-resizer { display: none; }
  .panel-reopen { display: none; }
  .panel-toggle { display: none; }
  .editor-canvas { width: 100%; min-height: auto; padding: 16mm; }
  .editor-ruler-row, .editor-view-controls { display: none; }
  .editor-viewport { padding: 12px; }
  .hero-title { font-size: 24px; }
}

/* ── Premium / Humanize additions ───────────────────────────────────────────── */
.hero-premium-badge {
  display: inline-flex; align-items: center; gap: 6px;
  margin-top: 4px; padding: 5px 14px;
  border-radius: 20px; font-size: 11px; font-weight: 600;
  color: #6ee7b7;
  background: linear-gradient(135deg, rgba(16,185,129,.14), rgba(139,92,246,.14));
  border: 1px solid rgba(16,185,129,.35);
  box-shadow: 0 0 18px rgba(16,185,129,.12);
}
.hero-premium-badge.inactive { color: var(--text-muted); border-color: var(--border2); background: rgba(14,14,24,.6); box-shadow: none; }

.hero-badge {
  animation: hero-badge-glow 3.2s ease-in-out infinite;
}
@keyframes hero-badge-glow {
  0%,100% { box-shadow: 0 0 0 rgba(139,92,246,.0); }
  50% { box-shadow: 0 0 22px rgba(139,92,246,.35); }
}
.hero-title { text-shadow: 0 0 40px rgba(139,92,246,.18); }
.hero-feature:hover { border-color: var(--accent); color: var(--accent-h); transform: translateY(-1px); }
.hero-feature { transition: all .15s ease; }

/* chat preview toggle */
.preview-toggle {
  display: flex; align-items: center; gap: 6px; flex: 0 0 auto;
  cursor: pointer; padding: 3px 0;
  user-select: none;
}
.preview-toggle input { accent-color: var(--accent); cursor: pointer; }
.preview-toggle-label { font-size: 10px; font-weight: 600; color: var(--text-muted); letter-spacing: .02em; }
.preview-toggle:hover .preview-toggle-label { color: var(--accent-h); }

/* edit preview modal */
.preview-intro { font-size: 12px; color: var(--text-dim); margin-bottom: 12px; }
.preview-list { display: flex; flex-direction: column; gap: 10px; }
.preview-item {
  background: var(--surface2); border: 1px solid var(--border);
  border-radius: var(--r); padding: 12px;
}
.pv-head { font-size: 11px; font-weight: 700; color: var(--accent-h); margin-bottom: 8px; }
.pv-block {
  position: relative; font-size: 11px; line-height: 1.6; color: var(--text);
  padding: 9px 11px 9px 11px; border-radius: var(--r-sm);
  margin-bottom: 7px; white-space: pre-wrap; word-break: break-word;
}
.pv-block:last-child { margin-bottom: 0; }
.pv-before { background: rgba(239,68,68,.08); border: 1px solid rgba(239,68,68,.25); color: var(--text-dim); }
.pv-after { background: rgba(16,185,129,.08); border: 1px solid rgba(16,185,129,.25); }
.pv-tag {
  display: inline-block; font-size: 9px; font-weight: 700;
  text-transform: uppercase; letter-spacing: .06em;
  margin-bottom: 4px; padding: 1px 6px; border-radius: 4px;
}
.pv-before .pv-tag { background: rgba(239,68,68,.18); color: #fca5a5; }
.pv-after .pv-tag { background: rgba(16,185,129,.18); color: #6ee7b7; }

/* humanize chip accent */
.ea-chip[onclick*="humanizeFocused"] {
  background: linear-gradient(135deg, rgba(16,185,129,.16), rgba(139,92,246,.16));
  border-color: rgba(16,185,129,.4); color: #6ee7b7; font-weight: 600;
}

/* unsaved-changes indicator */
.topbar-doc-title-row { display: flex; align-items: center; gap: 8px; }
.dirty-indicator {
  font-size: 10px; font-weight: 700; color: #fbbf24;
  background: rgba(245,158,11,.12); border: 1px solid rgba(245,158,11,.35);
  padding: 2px 8px; border-radius: 20px; animation: dirty-pulse 2s infinite;
}
.dirty-indicator.hidden { display: none; }
@keyframes dirty-pulse {
  0%,100% { opacity: .75; } 50% { opacity: 1; }
}