.editor-panel {
  display: grid;
  gap: 12px;
}

.editor-hero {
  position: sticky;
  top: 18px;
  z-index: 60;
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #ffffff;
  box-shadow: 0 10px 28px rgba(15, 23, 42, 0.06);
}

@media (max-width: 880px) {
  .editor-hero {
    top: 10px;
  }
}

.editor-cover {
  display: none;
}

.editor-heading {
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 12px 16px;
  transform: none;
}

.editor-heading-actions {
  margin-left: auto;
  padding-bottom: 0;
}

.editor-title {
  width: min(760px, 100%);
  min-height: 40px;
  border: 0;
  background: transparent;
  color: var(--text);
  padding: 0;
  font-size: 24px;
  font-weight: 900;
  letter-spacing: 0;
  line-height: 1.12;
}

.editor-title:focus {
  box-shadow: none;
}

.rich-editor-shell {
  display: grid;
  grid-template-rows: auto minmax(0, 1fr) auto;
  min-height: min(720px, calc(100vh - 220px));
  max-height: calc(100vh - 170px);
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #ffffff;
}

.rich-editor-layout {
  display: grid;
  align-items: start;
  grid-template-columns: 276px minmax(0, 1fr);
  gap: 14px;
}

.rich-tree-panel {
  position: sticky;
  top: 16px;
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #ffffff;
}

.rich-tree-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  border-bottom: 1px solid var(--line);
  padding: 14px;
}

.rich-tree-header strong {
  color: var(--text);
  font-size: 16px;
  font-weight: 900;
}

.editor-title[readonly] {
  cursor: default;
}

.editor-heading-actions .ghost-button {
  background: #eef4fb;
}

.editor-lock-button {
  display: inline-grid;
  width: 42px;
  min-width: 42px;
  height: 42px;
  place-items: center;
  padding: 0;
}

.editor-lock-button .menu-svg-icon {
  width: 17px;
  height: 17px;
  fill: currentColor;
}

.rich-tree-actions,
.rich-tree-row-actions {
  display: flex;
  align-items: center;
  gap: 4px;
}

.rich-tree-actions button,
.rich-tree-row-actions button {
  display: grid;
  width: 30px;
  height: 30px;
  place-items: center;
  border: 1px solid transparent;
  border-radius: 8px;
  background: #eef4ff;
  color: var(--blue);
  font-size: 11px;
  font-weight: 900;
}

.rich-tree-actions button .menu-svg-icon {
  width: 14px;
  height: 14px;
  fill: currentColor;
}

.rich-tree-actions button:hover,
.rich-tree-row-actions button:hover {
  border-color: rgba(37, 99, 235, 0.22);
  background: #e5efff;
}

.rich-tree-list {
  display: grid;
  gap: 2px;
  max-height: 620px;
  overflow: auto;
  padding: 0 8px 8px;
}

.rich-tree-list.is-dragging {
  outline: 1px dashed rgba(37, 99, 235, 0.24);
  outline-offset: -6px;
}

.rich-tree-list.root-drop-target {
  outline-color: rgba(8, 145, 178, 0.55);
  background: linear-gradient(180deg, rgba(236, 254, 255, 0.92), rgba(255, 255, 255, 0.98));
}

.rich-tree-root-drop {
  display: grid;
  min-height: 28px;
  place-items: center;
  border: 1px dashed rgba(8, 145, 178, 0.5);
  border-radius: 8px;
  background: #ecfeff;
  color: #0e7490;
  margin: 4px 8px;
  padding: 0 10px;
  font-size: 12px;
  font-weight: 900;
  opacity: 0;
  pointer-events: none;
  transform: translateY(-2px);
  transition: opacity 120ms ease, transform 120ms ease;
}

.rich-tree-root-drop.visible {
  opacity: 1;
  pointer-events: auto;
  transform: translateY(0);
}

.rich-tree-root-drop.active {
  border-color: rgba(37, 99, 235, 0.55);
  background: #dff7ff;
  color: #075985;
}

.rich-tree-item {
  position: relative;
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  gap: 4px;
  align-items: center;
  border-radius: 8px;
  padding: 2px 4px 2px calc(4px + var(--tree-depth, 0) * 16px);
}

.rich-tree-item:hover,
.rich-tree-item.selected {
  background: #f3f7ff;
}

.rich-tree-item.drop-target {
  background: #e8f2ff;
  box-shadow: inset 0 0 0 1px rgba(37, 99, 235, 0.22);
}

.rich-tree-item.drop-target::before {
  content: "";
  position: absolute;
  left: max(8px, calc(8px + var(--tree-depth, 0) * 16px));
  right: 8px;
  top: -3px;
  z-index: 4;
  height: 4px;
  border-radius: 999px;
  background: var(--blue);
  box-shadow: 0 0 0 5px rgba(37, 99, 235, 0.14), 0 8px 18px rgba(37, 99, 235, 0.24);
  pointer-events: none;
}

.rich-tree-main {
  display: grid;
  min-width: 0;
  grid-template-columns: 14px 24px minmax(0, 1fr);
  align-items: center;
  gap: 5px;
  border: 0;
  background: transparent;
  color: #25334d;
  padding: 7px 4px;
  text-align: left;
}

.rich-tree-main:hover {
  color: var(--blue);
}

.rich-tree-caret,
.rich-tree-icon {
  display: inline-grid;
  place-items: center;
}

.rich-tree-caret {
  color: #72809a;
  font-size: 11px;
}

.rich-tree-icon {
  width: 22px;
  height: 22px;
  border-radius: 7px;
  color: var(--blue);
}

.rich-tree-icon.folder {
  background: #fff7df;
  color: #d97706;
}

.rich-tree-icon.note {
  background: #eaf4ff;
  color: #2563eb;
}

.rich-tree-icon .menu-svg-icon {
  width: 13px;
  height: 13px;
  fill: currentColor;
}

.rich-tree-title {
  overflow: hidden;
  font-size: 13px;
  font-weight: 850;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.rich-tree-row-actions {
  position: absolute;
  top: 50%;
  right: 5px;
  opacity: 0;
  transform: translateY(-50%);
  border-radius: 8px;
  background: linear-gradient(90deg, rgba(243, 247, 255, 0.2), #f3f7ff 18%);
  padding-left: 8px;
  pointer-events: none;
  transition: opacity 0.15s ease;
}

.rich-tree-item:hover .rich-tree-main,
.rich-tree-item:focus-within .rich-tree-main {
  padding-right: 104px;
}

.rich-tree-item:hover .rich-tree-row-actions,
.rich-tree-item:focus-within .rich-tree-row-actions {
  opacity: 1;
  pointer-events: auto;
}

.rich-tree-row-actions button {
  width: 24px;
  height: 24px;
  background: transparent;
  color: #5d6a82;
}

.rich-tree-row-actions button .menu-svg-icon {
  width: 12px;
  height: 12px;
  fill: currentColor;
}

.rich-tree-row-actions button:hover {
  background: #eaf1ff;
  color: var(--blue);
}

.rich-tree-rename {
  min-width: 0;
}

.rich-tree-rename input {
  width: 100%;
  min-height: 32px;
  border: 1px solid #bfdbfe;
  border-radius: 7px;
  background: #ffffff;
  color: var(--text);
  padding: 0 9px;
  font-size: 13px;
  font-weight: 850;
}

.rich-tree-empty,
.rich-tree-hint {
  margin: 0;
  color: var(--muted);
  font-size: 12px;
  font-weight: 750;
  padding: 12px 14px;
}

.rich-tree-hint {
  border-top: 1px solid var(--line);
}

.rich-editor-toolbar {
  position: sticky;
  top: 0;
  z-index: 2;
  display: flex;
  align-items: center;
  gap: 6px;
  flex-wrap: wrap;
  border-bottom: 1px solid var(--line);
  background: rgba(255, 255, 255, 0.96);
  padding: 10px;
}

.editor-tool-group {
  display: flex;
  align-items: center;
  gap: 4px;
  border-right: 1px solid var(--line);
  padding-right: 6px;
}

.editor-tool-group:last-child {
  border-right: 0;
  padding-right: 0;
}

.rich-editor-toolbar select {
  width: 112px;
  min-height: 34px;
  padding-left: 10px;
  font-size: 12px;
  font-weight: 850;
}

.rich-editor-toolbar .custom-select {
  width: auto;
  min-width: 72px;
}

.rich-editor-toolbar .custom-select-trigger {
  min-height: 34px;
  border-radius: 8px;
  padding: 0 9px 0 10px;
  font-size: 12px;
  font-weight: 850;
}

.rich-editor-toolbar .custom-select-trigger .menu-svg-icon {
  width: 13px;
  height: 13px;
}

.rich-editor-toolbar .editor-tool-group:first-child .custom-select {
  min-width: 76px;
}

.rich-editor-toolbar button {
  display: grid;
  min-width: 34px;
  height: 34px;
  place-items: center;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: linear-gradient(#ffffff, #f8fafd);
  color: #26354f;
  font-size: 13px;
  font-weight: 900;
}

.rich-editor-toolbar button:hover {
  border-color: #c8d4e4;
  background: #eef4fb;
  color: var(--blue);
}

.rich-editor-toolbar button:disabled,
.rich-editor-toolbar select:disabled,
.editor-color-picker:has(input:disabled),
.editor-color-palette:has(button:disabled) {
  cursor: not-allowed;
  opacity: 0.48;
}

.editor-color-picker {
  position: relative;
  display: grid;
  width: 34px;
  height: 34px;
  place-items: center;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: linear-gradient(#ffffff, #f8fafd);
  color: #26354f;
  font-size: 12px;
  font-weight: 900;
  overflow: hidden;
}

.editor-color-picker:hover {
  border-color: #c8d4e4;
  background: #eef4fb;
  color: var(--blue);
}

.rt-icon {
  width: 18px;
  height: 18px;
  fill: none;
  stroke: currentColor;
  stroke-width: 2;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.editor-tool-wide {
  grid-template-columns: 18px auto;
  gap: 6px;
  width: auto;
  min-width: 88px;
  padding: 0 10px;
}

.editor-tool-wide span {
  font-size: 12px;
  font-weight: 850;
}

.editor-color-picker input {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  border: 0;
  opacity: 0;
  cursor: pointer;
}

.editor-color-palette {
  position: relative;
  display: inline-grid;
  grid-template-columns: 34px 22px;
  height: 34px;
  border-radius: 8px;
}

.editor-color-palette button {
  border-radius: 0 !important;
}

.editor-color-palette .editor-color-apply {
  position: relative;
  border-top-left-radius: 8px !important;
  border-bottom-left-radius: 8px !important;
  padding-bottom: 8px;
}

.editor-color-palette .editor-color-apply::after {
  content: "";
  position: absolute;
  left: 7px;
  right: 7px;
  bottom: 4px;
  height: 6px;
  border: 1px solid rgba(15, 23, 42, 0.12);
  border-radius: 4px;
  background: var(--selected-color, currentColor);
}

.editor-color-palette .editor-color-picker-trigger {
  min-width: 22px !important;
  width: 22px !important;
  border-left: 0 !important;
  border-top-right-radius: 8px !important;
  border-bottom-right-radius: 8px !important;
  border-top-left-radius: 0 !important;
  border-bottom-left-radius: 0 !important;
  padding: 0 !important;
  color: #64748b;
}

.editor-color-picker-trigger span {
  display: block;
  transform: translateY(-1px);
  font-size: 13px;
  font-weight: 950;
}

.editor-color-palette-menu {
  position: absolute;
  top: calc(100% + 6px);
  left: 0;
  z-index: 12;
  display: grid;
  grid-template-columns: repeat(6, 22px);
  gap: 5px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #ffffff;
  padding: 8px;
  box-shadow: 0 18px 36px rgba(31, 45, 68, 0.16);
}

.editor-color-palette-menu button {
  min-width: 22px;
  width: 22px;
  height: 22px;
  min-height: 22px;
  border: 1px solid rgba(15, 23, 42, 0.14);
  border-radius: 5px;
  background: var(--swatch-color);
  padding: 0;
}

.editor-color-palette-menu button:hover {
  border-color: var(--blue);
  box-shadow: 0 0 0 2px rgba(37, 99, 235, 0.12);
}

.editor-image-input {
  display: none;
}

.rich-editor-scroll {
  min-height: 0;
  overflow-y: auto;
  overscroll-behavior: contain;
  background: #ffffff;
}

.rich-editor-surface {
  min-height: 560px;
  max-width: 820px;
  margin: 0 auto;
  outline: none;
  padding: 54px 48px 72px;
  color: var(--text);
  font-size: 16px;
  line-height: 1.78;
  overflow-wrap: anywhere;
  word-break: break-word;
}

.rich-editor-surface * {
  max-width: 100%;
  overflow-wrap: anywhere;
  word-break: break-word;
}

.rich-editor-surface[contenteditable="false"] {
  cursor: default;
}

.rich-editor-surface:empty::before {
  content: "ここから書き始める";
  color: #9aa6b8;
}

.rich-editor-empty {
  display: grid;
  min-height: 560px;
  place-content: center;
  gap: 8px;
  padding: 40px;
  color: var(--muted);
  text-align: center;
}

.rich-editor-empty strong {
  color: var(--text);
  font-size: 18px;
  font-weight: 900;
}

.rich-editor-empty span {
  font-size: 13px;
  font-weight: 750;
}

.rich-editor-surface h1,
.rich-editor-surface h2,
.rich-editor-surface h3 {
  margin: 1.1em 0 0.35em;
  color: var(--text);
  line-height: 1.25;
  white-space: pre-wrap !important;
}

.rich-editor-surface p,
.rich-editor-surface blockquote,
.rich-editor-surface .editor-callout {
  white-space: pre-wrap !important;
}

.rich-editor-surface p *,
.rich-editor-surface h1 *,
.rich-editor-surface h2 *,
.rich-editor-surface h3 *,
.rich-editor-surface blockquote *,
.rich-editor-surface .editor-callout * {
  overflow-wrap: anywhere;
  word-break: break-word;
  white-space: inherit !important;
}

.rich-editor-surface h1 {
  font-size: 32px;
}

.rich-editor-surface h2 {
  font-size: 24px;
}

.rich-editor-surface h3 {
  font-size: 19px;
}

.rich-editor-surface p {
  margin: 0.35em 0;
}

.rich-editor-surface a {
  color: var(--blue);
  font-weight: 750;
  text-decoration: underline;
  text-underline-offset: 3px;
}

.rich-editor-surface blockquote {
  margin: 1em 0;
  border-left: 4px solid #d6deea;
  color: #42506a;
  padding: 4px 0 4px 14px;
}

.rich-editor-surface pre {
  position: relative;
  overflow-x: auto;
  border: 1px solid #d9e1ec;
  border-radius: 8px;
  background: #111827;
  color: #f8fafc;
  padding: 12px 48px 12px 14px;
  font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, monospace;
  font-size: 13px;
  line-height: 1.45;
  white-space: pre-wrap;
}

.editor-code-copy-button {
  position: absolute;
  top: 8px;
  right: 8px;
  display: inline-grid;
  width: 26px;
  height: 26px;
  place-items: center;
  border: 1px solid rgba(226, 232, 240, 0.24);
  border-radius: 8px;
  background: rgba(15, 23, 42, 0.86);
  color: #dbeafe;
  font-family: inherit;
  font-size: 14px;
  font-weight: 900;
  line-height: 1;
  cursor: pointer;
  backdrop-filter: blur(8px);
}

.editor-code-copy-button:hover {
  border-color: rgba(147, 197, 253, 0.55);
  background: rgba(37, 99, 235, 0.92);
  color: #ffffff;
}

.rich-editor-surface code {
  font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, monospace;
  white-space: pre-wrap;
}

.rich-editor-surface code[data-placeholder]:empty::before {
  content: attr(data-placeholder);
  color: rgba(203, 213, 225, 0.58);
  pointer-events: none;
}

.rich-editor-surface ul,
.rich-editor-surface ol {
  margin: 0.45em 0 0.8em;
  padding-left: 1.35em;
}

.rich-editor-surface hr {
  height: 1px;
  border: 0;
  background: var(--line);
  margin: 28px 0;
}

.rich-editor-surface table {
  width: 100%;
  margin: 16px 0;
  border-collapse: collapse;
  font-size: 14px;
}

.rich-editor-surface th,
.rich-editor-surface td {
  border: 1px solid #d9e1ec;
  padding: 9px 10px;
  text-align: left;
}

.rich-editor-surface th {
  background: #f4f7fb;
  font-weight: 900;
}

.rich-editor-surface figure {
  margin: 18px 0;
}

.rich-editor-surface img {
  display: block;
  max-width: 100%;
  border: 1px solid #d9e1ec;
  border-radius: 8px;
  box-shadow: 0 12px 28px rgba(31, 45, 68, 0.1);
}

.rich-editor-surface figcaption {
  margin-top: 8px;
  color: var(--muted);
  font-size: 13px;
  font-weight: 750;
  text-align: center;
}

.editor-check-row {
  display: flex;
  align-items: center;
  gap: 10px;
  min-height: 32px;
}

.editor-check-row input {
  width: 16px;
  height: 16px;
}

.editor-callout {
  margin: 16px 0;
  border: 1px solid #dbe5f3;
  border-left: 4px solid #2563eb;
  border-radius: 8px;
  background: #f7faff;
  padding: 12px 14px;
  color: #26354f;
  font-style: normal;
  font-weight: 750;
}

.rich-editor-debug {
  border-top: 1px solid var(--line);
  background: #f8fbff;
}

.rich-editor-debug-header {
  display: grid;
  width: 100%;
  grid-template-columns: auto 1fr auto;
  align-items: center;
  gap: 10px;
  border: 0;
  border-radius: 0;
  background: transparent;
  padding: 10px 14px;
  color: #24324a;
  text-align: left;
}

.rich-editor-debug-header span {
  font-size: 12px;
  font-weight: 950;
}

.rich-editor-debug-header small {
  min-width: 0;
  color: var(--muted);
  font-size: 11px;
  font-weight: 800;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.rich-editor-debug-header strong {
  border: 1px solid var(--line);
  border-radius: 999px;
  background: #ffffff;
  padding: 4px 9px;
  color: var(--blue);
  font-size: 11px;
  font-weight: 950;
}

.rich-editor-debug-source {
  display: block;
  width: calc(100% - 28px);
  min-height: 150px;
  max-height: 280px;
  margin: 0 14px 14px;
  border: 1px solid #d9e1ec;
  border-radius: 8px;
  background: #0f172a;
  color: #e5edf8;
  padding: 12px;
  font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, monospace;
  font-size: 12px;
  line-height: 1.55;
  overflow: auto;
  resize: none;
  white-space: pre-wrap;
}

.editor-status {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  border-top: 1px solid var(--line);
  background: #fbfcfe;
  padding: 10px 14px;
  color: var(--muted);
  font-size: 12px;
  font-weight: 750;
}

@media (max-width: 760px) {
  .editor-heading {
    align-items: flex-start;
    padding: 0 16px 16px;
  }

  .editor-title {
    font-size: 26px;
  }

  .rich-editor-layout {
    grid-template-columns: 1fr;
  }

  .rich-tree-panel {
    position: static;
  }

  .rich-tree-list {
    max-height: 300px;
  }

  .rich-editor-surface {
    min-height: 460px;
    padding: 34px 22px 56px;
  }

  .editor-tool-group {
    border-right: 0;
    padding-right: 0;
  }

  .rich-editor-toolbar select {
    width: 118px;
  }
}
