/* ---- Tiptap editor wrapper ---- */
.tt-editor-wrap {
  border: 1px solid var(--border-default, #ccc);
  border-radius: var(--radius, 6px);
  overflow: hidden;
}

/* ---- Toolbar ---- */
.tt-toolbar {
  display: flex;
  flex-wrap: wrap;
  gap: 2px;
  padding: 6px 8px;
  background: var(--bg-surface, #f7f7f7);
  border-bottom: 1px solid var(--border-default, #ccc);
  align-items: center;
}

.tt-btn-group {
  display: inline-flex;
  gap: 2px;
  align-items: center;
}

.tt-btn-group + .tt-btn-group {
  margin-left: 4px;
  padding-left: 6px;
  border-left: 1px solid var(--border-default, #ddd);
}

.tt-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 28px;
  height: 28px;
  padding: 0 4px;
  border: none;
  border-radius: 4px;
  background: transparent;
  color: var(--fg-default, #333);
  font-size: 13px;
  cursor: pointer;
  line-height: 1;
}

.tt-btn:hover {
  background: var(--bg-surface-hover, #e0e0e0);
}

.tt-btn.is-active {
  background: var(--accent-subtle, #d0d0ff);
  color: var(--accent, #4040d0);
}

/* ---- Color picker ---- */
.tt-color-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 28px;
  height: 28px;
  padding: 0 4px;
  border-radius: 4px;
  cursor: pointer;
  position: relative;
}

.tt-color-btn:hover {
  background: var(--bg-surface-hover, #e0e0e0);
}

.tt-color-icon {
  font-weight: 700;
  font-size: 13px;
  line-height: 1;
}

.tt-color-input {
  position: absolute;
  top: 0; left: 0;
  width: 100%; height: 100%;
  opacity: 0;
  cursor: pointer;
}

/* ---- Editor content area ---- */
.tt-editor-content {
  background: var(--bg, #fff);
}

.tt-prosemirror {
  min-height: 100px;
  max-height: 300px;
  overflow-y: auto;
  padding: 10px 14px;
  font-size: 0.9rem;
  line-height: 1.6;
  outline: none;
}

.tt-prosemirror > *:first-child { margin-top: 0; }
.tt-prosemirror > *:last-child { margin-bottom: 0; }

.tt-prosemirror p { margin: 0.4em 0; }

.tt-prosemirror h1 { font-size: 1.5em; margin: 0.6em 0 0.3em; }
.tt-prosemirror h2 { font-size: 1.25em; margin: 0.5em 0 0.25em; }
.tt-prosemirror h3 { font-size: 1.1em; margin: 0.4em 0 0.2em; }

.tt-prosemirror ul,
.tt-prosemirror ol {
  padding-left: 1.5em;
  margin: 0.4em 0;
}

.tt-prosemirror blockquote {
  border-left: 3px solid var(--border-default, #ccc);
  margin: 0.5em 0;
  padding: 0.3em 1em;
  color: var(--fg-muted, #666);
}

.tt-prosemirror pre {
  background: var(--bg-surface, #f5f5f5);
  border-radius: 4px;
  padding: 0.6em 1em;
  font-family: monospace;
  font-size: 0.85em;
  overflow-x: auto;
}

.tt-prosemirror a {
  color: var(--accent, #4040d0);
  text-decoration: underline;
}

/* ---- Table styles ---- */
.tt-prosemirror table {
  border-collapse: collapse;
  width: 100%;
  margin: 8px 0;
  table-layout: auto;
}

.tt-prosemirror table td,
.tt-prosemirror table th {
  border: 1px solid var(--border-default, #ccc);
  padding: 6px 8px;
  min-width: 40px;
  vertical-align: top;
  position: relative;
}

.tt-prosemirror table th {
  font-weight: 600;
  background: var(--bg-surface, #f5f5f5);
}

.tt-prosemirror table .selectedCell {
  background: var(--accent-subtle, rgba(100, 100, 255, 0.15));
}

/* Column resize handle */
.tt-prosemirror .column-resize-handle {
  position: absolute;
  right: -2px;
  top: 0;
  bottom: -2px;
  width: 4px;
  cursor: col-resize;
  background: var(--accent, #4040d0);
  opacity: 0;
  z-index: 20;
}

.tt-prosemirror .column-resize-handle:hover,
.tt-prosemirror .resize-cursor .column-resize-handle {
  opacity: 1;
}

.tableWrapper {
  overflow-x: auto;
  margin: 8px 0;
}

.resize-cursor {
  cursor: col-resize;
}

/* ---- Table insert grid menu ---- */
.tt-table-menu {
  background: var(--bg, #fff);
  border: 1px solid var(--border-default, #ccc);
  border-radius: 6px;
  box-shadow: 0 4px 12px rgba(0,0,0,0.15);
  padding: 8px;
}

.tt-table-label {
  text-align: center;
  font-size: 0.8rem;
  color: var(--fg-muted, #666);
  margin-bottom: 4px;
}

.tt-table-cell {
  width: 24px;
  height: 24px;
  border: 1px solid var(--border-default, #ccc);
  border-radius: 2px;
  cursor: pointer;
  background: var(--bg, #fff);
}

.tt-table-cell:hover,
.tt-table-cell.active {
  background: var(--accent-subtle, rgba(100, 100, 255, 0.25));
  border-color: var(--accent, #4040d0);
}

/* ---- Table context menu ---- */
.tt-ctx-menu {
  background: var(--bg, #fff);
  border: 1px solid var(--border-default, #ccc);
  border-radius: 6px;
  box-shadow: 0 4px 12px rgba(0,0,0,0.15);
  padding: 4px 0;
  min-width: 180px;
}

.tt-ctx-item {
  display: block;
  width: 100%;
  padding: 6px 14px;
  border: none;
  background: transparent;
  text-align: left;
  font-size: 0.85rem;
  color: var(--fg-default, #333);
  cursor: pointer;
  white-space: nowrap;
}

.tt-ctx-item:hover {
  background: var(--bg-surface-hover, #f0f0f0);
}

.tt-ctx-danger {
  color: var(--danger-500, #dc2626);
}

.tt-ctx-danger:hover {
  background: #fef2f2;
}

.tt-ctx-sep {
  height: 1px;
  background: var(--border-default, #e0e0e0);
  margin: 4px 0;
}

/* ---- Placeholder ---- */
.tt-prosemirror p.is-editor-empty:first-child::before {
  content: attr(data-placeholder);
  float: left;
  color: var(--fg-muted, #aaa);
  pointer-events: none;
  height: 0;
}

