/* ============================================================
   Full-Page Note Editor — Writing Experience
   ============================================================ */

.note-editor {
  display: flex;
  flex-direction: column;
  height: 100%;
  min-height: calc(100vh - var(--navbar-height));
  min-height: calc(100dvh - var(--navbar-height));
  background-color: var(--color-bg);
  animation: fadeInUp var(--duration-slow) var(--ease-out) both;
}

.note-editor.is-fullscreen {
  min-height: 100vh;
  min-height: 100dvh;
  background-color: var(--color-bg-elevated);
}

/* ── Top toolbar ── */
.note-editor__toolbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 12px 24px;
  background-color: var(--color-bg-elevated);
  border-bottom: 1px solid var(--color-border);
  flex-shrink: 0;
}

.note-editor__toolbar-left,
.note-editor__toolbar-right {
  display: flex;
  align-items: center;
  gap: 10px;
}

.note-editor__back {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 6px 10px 6px 6px;
  font-size: var(--font-size-sm);
  font-weight: var(--font-weight-medium);
  color: var(--color-text-secondary);
  border-radius: var(--radius-sm);
  transition: background-color var(--duration-fast) var(--ease-out),
              color var(--duration-fast) var(--ease-out);
}

.note-editor__back:hover {
  background-color: var(--color-bg-hover);
  color: var(--color-text-primary);
}

/* Save status indicator */
.note-editor__status {
  position: relative;
  min-width: 120px;
  height: 28px;
}

.editor-status {
  position: absolute;
  left: 0;
  top: 50%;
  transform: translateY(-50%);
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: var(--font-size-xs);
  font-weight: var(--font-weight-medium);
  opacity: 0;
  visibility: hidden;
  transition: opacity var(--duration-fast) var(--ease-out),
              visibility var(--duration-fast) var(--ease-out);
}

.editor-status.is-visible {
  opacity: 1;
  visibility: visible;
}

.editor-status--saved {
  color: var(--color-accent);
}

.editor-status--saving {
  color: var(--color-text-tertiary);
}

.editor-status--unsaved {
  color: var(--color-text-secondary);
}

.editor-status__spinner {
  width: 12px;
  height: 12px;
  border: 2px solid var(--color-border);
  border-top-color: var(--color-accent);
  border-radius: 50%;
  animation: editorSpin 0.7s linear infinite;
}

@keyframes editorSpin {
  to { transform: rotate(360deg); }
}

/* Toolbar tool buttons */
.note-editor__tool-btn {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 34px;
  height: 34px;
  border-radius: var(--radius-sm);
  color: var(--color-text-secondary);
  transition: background-color var(--duration-fast) var(--ease-out),
              color var(--duration-fast) var(--ease-out),
              opacity var(--duration-fast) var(--ease-out);
}

.note-editor__tool-btn:hover:not(:disabled) {
  background-color: var(--color-bg-hover);
  color: var(--color-text-primary);
}

.note-editor__tool-btn:disabled {
  opacity: 0.35;
  cursor: not-allowed;
}

.note-editor__tool-btn:active:not(:disabled) {
  transform: scale(0.94);
}

.note-editor__tool-btn--danger {
  width: auto;
  padding: 0 12px;
  font-size: var(--font-size-sm);
  font-weight: 500;
  color: #c0392b;
}

.note-editor__tool-btn--danger:hover:not(:disabled) {
  background-color: rgba(192, 57, 43, 0.1);
  color: #922b21;
}

.note-editor__tool-divider {
  width: 1px;
  height: 20px;
  background-color: var(--color-border);
  margin: 0 2px;
}

#editorFullscreenBtn .icon-exit-fs { display: none; }
.note-editor.is-fullscreen #editorFullscreenBtn .icon-enter-fs { display: none; }
.note-editor.is-fullscreen #editorFullscreenBtn .icon-exit-fs { display: block; }

/* ── Meta fields (title, chapter, tags) ── */
.note-editor__meta {
  padding: 24px 40px 16px;
  max-width: 820px;
  width: 100%;
  margin: 0 auto;
  flex-shrink: 0;
}

.note-editor__breadcrumb {
  font-size: var(--font-size-xs);
  font-weight: var(--font-weight-semibold);
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--color-text-tertiary);
  margin-bottom: 12px;
}

.note-editor__title {
  width: 100%;
  font-size: 1.75rem;
  font-weight: var(--font-weight-bold);
  font-family: inherit;
  letter-spacing: var(--letter-spacing-tight);
  color: var(--color-text-primary);
  background: transparent;
  border: none;
  outline: none;
  padding: 0;
  margin-bottom: 16px;
  line-height: var(--line-height-tight);
}

.note-editor__title::placeholder {
  color: var(--color-text-tertiary);
}

.note-editor__fields {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
}

.note-editor__field {
  flex: 1;
  min-width: 140px;
  height: 36px;
  padding: 0 12px;
  font-size: var(--font-size-sm);
  font-family: inherit;
  color: var(--color-text-secondary);
  background-color: var(--color-bg-subtle);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-sm);
  transition: border-color var(--duration-fast) var(--ease-out),
              background-color var(--duration-fast) var(--ease-out),
              color var(--duration-fast) var(--ease-out);
}

.note-editor__field:focus {
  outline: none;
  background-color: var(--color-bg-elevated);
  border-color: var(--color-accent);
  color: var(--color-text-primary);
  box-shadow: 0 0 0 3px var(--color-accent-soft);
}

.note-editor__field--select {
  cursor: pointer;
  appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 24 24' fill='none' stroke='%239b9a97' stroke-width='2'%3E%3Cpolyline points='6 9 12 15 18 9'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 10px center;
  padding-right: 28px;
  max-width: 160px;
  flex: 0 1 160px;
}

/* ── Writing area ── */
.note-editor__body {
  flex: 1;
  display: flex;
  flex-direction: column;
  min-height: 0;
  padding: 0 40px 16px;
  max-width: 820px;
  width: 100%;
  margin: 0 auto;
}

/* Legacy single-pane body — overridden by markdown-editor.css workspace */
.note-editor:not([data-view-mode]) .note-editor__body,
.note-editor .note-editor__workspace + .note-editor__body {
  max-width: none;
}

.note-editor__content {
  flex: 1;
  width: 100%;
  min-height: 320px;
  padding: 20px 0 32px;
  font-size: 1.0625rem;
  font-family: inherit;
  line-height: 1.75;
  color: var(--color-text-primary);
  background: transparent;
  border: none;
  outline: none;
  resize: none;
  overflow-y: auto;
  scrollbar-width: thin;
  scrollbar-color: var(--color-border-strong) transparent;
}

.note-editor__content::placeholder {
  color: var(--color-text-tertiary);
}

.note-editor__content::-webkit-scrollbar {
  width: 5px;
}

.note-editor__content::-webkit-scrollbar-thumb {
  background-color: var(--color-border-strong);
  border-radius: var(--radius-full);
}

.note-editor.is-fullscreen .note-editor__body {
  max-width: 900px;
}

.note-editor.is-fullscreen .note-editor__content {
  font-size: 1.125rem;
  line-height: 1.8;
}

/* ── Footer stats bar ── */
.note-editor__footer {
  flex-shrink: 0;
  padding: 12px 24px;
  background-color: var(--color-bg-elevated);
  border-top: 1px solid var(--color-border);
}

.note-editor__stats {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: center;
  gap: 8px;
  max-width: 820px;
  margin: 0 auto;
}

.note-editor__stat {
  font-size: var(--font-size-xs);
  font-weight: var(--font-weight-medium);
  color: var(--color-text-secondary);
}

.note-editor__stat--muted {
  color: var(--color-text-tertiary);
}

.note-editor__stat-sep {
  color: var(--color-text-tertiary);
  font-size: var(--font-size-xs);
  user-select: none;
}

/* ── Responsive ── */
@media (max-width: 768px) {
  .note-editor__toolbar {
    padding: 10px 16px;
    flex-wrap: wrap;
  }

  .note-editor__toolbar-left {
    flex: 1;
    min-width: 0;
  }

  .note-editor__status {
    min-width: 100px;
  }

  .note-editor__meta {
    padding: 20px 16px 12px;
  }

  .note-editor__title {
    font-size: var(--font-size-xl);
  }

  .note-editor__body {
    padding: 0 16px;
  }

  .note-editor__fields {
    flex-direction: column;
  }

  .note-editor__field--select {
    max-width: none;
    flex: 1;
  }

  .note-editor__footer {
    padding: 10px 16px;
  }

  .note-editor__stats {
    justify-content: flex-start;
  }
}

@media (max-width: 480px) {
  .note-editor__toolbar-right {
    gap: 4px;
  }

  .note-editor__tool-btn {
    width: 32px;
    height: 32px;
  }
}
