:root {
  --bg:       #1a1a1a;
  --bar:      #212121;
  --border:   #2e2e2e;
  --surface:  #2a2a2a;
  --text:     #e6e6e6;
  --muted:    #888;
  --accent:   #7ba7f7;
  --page-bg:  #ffffff;
  --page-txt: #111111;
  --r:        6px;
}

html, body { height: 100%; }

body {
  font-family: 'Inter', system-ui, sans-serif;
  background: var(--bg);
  color: var(--text);
  display: flex;
  flex-direction: column;
  height: 100vh;
  overflow: hidden;
}

#app {
  display: flex;
  flex-direction: column;
  height: 100vh;
  overflow: hidden;
}

/* ── Top bar ── */
#topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  background: var(--bar);
  border-bottom: 1px solid var(--border);
  padding: 0 14px;
  height: 44px;
  flex-shrink: 0;
  gap: 10px;
}

#topbar-left {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-shrink: 0;
}

#home-link {
  display: flex;
  align-items: center;
  color: var(--muted);
  transition: color 0.15s;
  padding: 4px;
  border-radius: 4px;
}
#home-link:hover { color: var(--text); background: var(--surface); }

.sep {
  width: 1px;
  height: 18px;
  background: var(--border);
}

#app-title {
  font-size: 13px;
  font-weight: 600;
  white-space: nowrap;
}

#topbar-actions {
  display: flex;
  align-items: center;
  gap: 6px;
  overflow: hidden;
}

.tbtn {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 5px 11px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--r);
  color: var(--text);
  font-size: 12.5px;
  font-family: inherit;
  white-space: nowrap;
  transition: background 0.15s, border-color 0.15s;
}
.tbtn svg { width: 14px; height: 14px; flex-shrink: 0; }
.tbtn:hover:not(:disabled) { background: #363636; border-color: #444; }
.tbtn:disabled { opacity: 0.35; cursor: not-allowed; }

#file-badge {
  font-size: 12px;
  color: var(--muted);
  max-width: 220px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  padding-left: 4px;
}

/* ── Format bar (Quill toolbar) ── */
#format-bar {
  background: var(--bar) !important;
  border: none !important;
  border-bottom: 1px solid var(--border) !important;
  padding: 5px 10px !important;
  flex-shrink: 0;
}
#format-bar .ql-formats { margin-right: 10px !important; }
#format-bar button,
#format-bar .ql-picker-label { color: var(--text) !important; }
#format-bar .ql-stroke { stroke: var(--text) !important; }
#format-bar .ql-fill   { fill:   var(--text) !important; }
#format-bar button:hover .ql-stroke,
#format-bar button.ql-active .ql-stroke { stroke: var(--accent) !important; }
#format-bar button:hover .ql-fill,
#format-bar button.ql-active .ql-fill   { fill:   var(--accent) !important; }
#format-bar button:hover,
#format-bar button.ql-active { color: var(--accent) !important; }
#format-bar .ql-picker-label { border-color: var(--border) !important; }
#format-bar .ql-picker-options {
  background: #2c2c2c !important;
  border-color: var(--border) !important;
}
#format-bar .ql-picker-item { color: var(--text) !important; }
#format-bar .ql-picker-item:hover { color: var(--accent) !important; }

/* ── Main ── */
#main {
  flex: 1;
  overflow: hidden;
  display: flex;
  flex-direction: column;
  min-height: 0;
}

/* ── Drop zone ── */
#drop-zone {
  flex: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: background 0.2s;
}
#drop-zone.drag-over { background: rgba(123,167,247,0.06); }

#drop-inner {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 13px;
  text-align: center;
  padding: 24px;
}

#drop-icon svg {
  width: 60px;
  height: 60px;
  color: #444;
  margin-bottom: 4px;
}

#drop-inner h2 {
  font-size: 18px;
  font-weight: 600;
  color: var(--text);
}
#drop-inner p {
  font-size: 13.5px;
  color: var(--muted);
}
#drop-inner .hint {
  font-size: 11.5px;
  color: #555;
  margin-top: -4px;
}

.open-btn {
  display: inline-flex;
  align-items: center;
  padding: 9px 22px;
  background: var(--accent);
  color: #fff;
  border-radius: var(--r);
  font-size: 13.5px;
  font-weight: 500;
  font-family: inherit;
  transition: opacity 0.15s;
  margin-top: 2px;
}
.open-btn:hover { opacity: 0.85; }

/* ── Page shell ── */
#page-shell {
  flex: 1;
  overflow: hidden;
  display: flex;
  flex-direction: column;
  min-height: 0;
}

#page-scroll {
  flex: 1;
  overflow-y: auto;
  background: #6b6b6b;
  padding: 36px 24px;
}

#page {
  width: 100%;
  max-width: 820px;
  margin: 0 auto;
  background: var(--page-bg);
  box-shadow: 0 4px 24px rgba(0,0,0,0.5);
  min-height: 600px;
}

/* ── Quill editor (inside the "page") ── */
.ql-container.ql-snow {
  border: none !important;
  font-family: 'Calibri', Georgia, 'Times New Roman', serif !important;
  font-size: 12pt !important;
  color: var(--page-txt) !important;
  background: var(--page-bg) !important;
}

.ql-editor {
  padding: 52px 64px !important;
  min-height: 600px !important;
  color: var(--page-txt) !important;
  background: var(--page-bg) !important;
  line-height: 1.65 !important;
}

/* Restore heading styles that get wiped by our reset */
.ql-editor h1 { font-size: 2em !important;    font-weight: 700 !important; line-height: 1.2 !important; margin: 0.6em 0 0.3em !important; }
.ql-editor h2 { font-size: 1.5em !important;   font-weight: 700 !important; line-height: 1.25 !important; margin: 0.5em 0 0.25em !important; }
.ql-editor h3 { font-size: 1.25em !important;  font-weight: 600 !important; line-height: 1.3 !important; margin: 0.4em 0 0.2em !important; }
.ql-editor h4 { font-size: 1.05em !important;  font-weight: 600 !important; margin: 0.4em 0 0.15em !important; }
.ql-editor p  { margin-bottom: 0.5em !important; }
.ql-editor ul, .ql-editor ol { padding-left: 1.5em !important; margin-bottom: 0.5em !important; }
.ql-editor li { margin-bottom: 0.2em !important; list-style: revert !important; }
.ql-editor blockquote {
  border-left: 3px solid #ccc !important;
  padding-left: 1em !important;
  color: #555 !important;
  margin: 0.5em 0 !important;
}
.ql-editor table { width: 100% !important; border-collapse: collapse !important; margin: 1em 0 !important; }
.ql-editor td, .ql-editor th {
  border: 1px solid #ccc !important;
  padding: 6px 10px !important;
  vertical-align: top !important;
}
.ql-editor strong { font-weight: 700 !important; }
.ql-editor em     { font-style: italic !important; }
.ql-editor u      { text-decoration: underline !important; }
.ql-editor s      { text-decoration: line-through !important; }

/* View mode — no caret, no focus ring */
.ql-editor.view-mode {
  cursor: default !important;
  caret-color: transparent !important;
  user-select: text !important;
}

@media (max-width: 600px) {
  .ql-editor { padding: 24px 20px !important; }
  #page-scroll { padding: 16px 8px; }
}

/* ── Status bar ── */
#statusbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  background: var(--bar);
  border-top: 1px solid var(--border);
  padding: 3px 14px;
  font-size: 11.5px;
  color: var(--muted);
  flex-shrink: 0;
  height: 24px;
}

/* ── Toast ── */
#toast {
  position: fixed;
  bottom: 34px;
  left: 50%;
  transform: translateX(-50%) translateY(12px);
  background: #2e2e2e;
  color: #eee;
  padding: 7px 18px;
  border-radius: 20px;
  font-size: 12.5px;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.18s, transform 0.18s;
  z-index: 999;
  white-space: nowrap;
}
#toast.show { opacity: 1; transform: translateX(-50%) translateY(0); }
#toast.err  { background: #7f2929; }

/* ── Loader ── */
#loader {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.45);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 1000;
}
#loader.hidden { display: none; }

.spin {
  width: 34px; height: 34px;
  border: 3px solid #444;
  border-top-color: var(--accent);
  border-radius: 50%;
  animation: spin 0.65s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }
