/* Google Fonts は読み込まない（system-ui のみのとき外部リクエストなし）。
   非 system-ui フォント選択時は index.html の #mdrw-google-fonts を app.js が設定。 */

/* === App Chrome ========================================================= */
/* Google Fonts: テーマで選択（プレビューは app.js が link を更新） */
/* Self-hosted icon font */
@font-face {
  font-family: "Material Symbols Outlined";
  font-style: normal;
  font-weight: 100 700;
  font-display: swap;
  src: url("fonts/MaterialSymbolsOutlined%5BFILL%2CGRAD%2Copsz%2Cwght%5D.woff2")
    format("woff2");
}

:root {
  --ui-bg-app: #1f1f20;
  --ui-bg-surface: #2a2b2d;
  --ui-bg-surface-elevated: #323437;
  --ui-bg-surface-muted: #262729;
  --ui-bg-surface-hover: #3a3c40;
  --ui-bg-surface-active: #41444a;
  --ui-bg-input: #3a3c40;
  --ui-bg-primary: #3f4247;
  --ui-bg-primary-hover: #4a4d53;
  --ui-bg-success: #3f4247;
  --ui-bg-success-hover: #4a4d53;
  --ui-bg-danger: #3a3c40;
  --ui-bg-danger-hover: #46484d;
  --ui-bg-ghost-hover: #3a3c40;
  --ui-text-primary: #d3d6da;
  --ui-text-secondary: #b9bcc1;
  --ui-text-muted: #979ba2;
  --ui-text-on-primary: #e1e4e8;
  --ui-text-warning: #c5c7cb;
  --ui-border: #4a4d52;
  --ui-border-strong: #5a5e64;
  --ui-focus: #8f949d;
  --ui-radius-sm: 8px;
  --ui-radius-md: 8px;
  --ui-header-height: 60px;
  --ui-control-height: 40px;
  --ui-btn-width-type-a: 152px;
  --ui-btn-width-type-b: 164px;
  --ui-gap-button: 8px;
  --ui-gap-editor-controls: 12px;
  --ui-gap-field: 6px;
  --ui-gap-section: 24px;
  --ui-pad-surface-x: 16px;
  --ui-pad-surface-y: 10px;
  --ui-space-1: 0.3rem;
  --ui-space-2: 0.45rem;
  --ui-space-3: 0.6rem;
  --ui-space-4: 0.75rem;
  --ui-space-5: 1rem;
  --ui-shadow-focus: 0 0 0 2px rgba(143, 148, 157, 0.3);
}

* {
  box-sizing: border-box;
}

html,
body {
  margin: 0;
  height: 100%;
  font-family: system-ui, -apple-system, "Segoe UI", sans-serif;
  background: var(--ui-bg-app);
  color: var(--ui-text-primary);
  overflow: hidden;
}

body {
  display: flex;
  flex-direction: column;
}

.ui-btn {
  border: 1px solid var(--ui-border);
  border-radius: var(--ui-radius-md);
  min-height: var(--ui-control-height);
  padding: 0.46rem 0.76rem;
  font-size: 0.8rem;
  font-weight: 600;
  font-family: system-ui, -apple-system, "Segoe UI", sans-serif;
  line-height: 1.2;
  color: var(--ui-text-primary);
  background: transparent;
  cursor: pointer;
  transition:
    background-color 0.18s ease,
    border-color 0.18s ease,
    color 0.18s ease,
    box-shadow 0.18s ease,
    transform 0.18s ease;
}

.ui-btn:hover:not(:disabled) {
  background: var(--ui-bg-surface-hover);
  border-color: var(--ui-border-strong);
  color: var(--ui-text-primary);
  transform: none;
}

.ui-btn:focus-visible {
  outline: none;
  box-shadow: var(--ui-shadow-focus);
}

.ui-btn:disabled {
  opacity: 0.46;
  cursor: not-allowed;
  transform: none;
}

.ui-btn--toolbar {
  padding: 0.46rem 0.8rem;
  border-radius: var(--ui-radius-sm);
  font-size: 0.81rem;
}

.ui-btn--primary,
.ui-btn--secondary,
.ui-btn--danger,
.ui-btn--success {
  border-color: var(--ui-border);
  background: transparent;
  color: var(--ui-text-primary);
}

.ui-btn--primary:hover:not(:disabled),
.ui-btn--danger:hover:not(:disabled),
.ui-btn--success:hover:not(:disabled) {
  border-color: var(--ui-border-strong);
  background: var(--ui-bg-surface-hover);
  color: var(--ui-text-primary);
}

.ui-btn--ghost {
  background: transparent;
  border-color: var(--ui-border);
  color: var(--ui-text-primary);
}

.ui-btn--ghost:hover:not(:disabled) {
  background: var(--ui-bg-ghost-hover);
  color: var(--ui-text-primary);
}

.ui-btn--icon {
  width: 1.45rem;
  height: 1.45rem;
  padding: 0;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border-radius: var(--ui-radius-sm);
}

.ui-field,
.ui-select {
  width: 100%;
  min-width: 0;
  min-height: var(--ui-control-height);
  padding: 0.46rem 0.62rem;
  border: 1px solid var(--ui-border);
  border-radius: var(--ui-radius-md);
  background: var(--ui-bg-input);
  color: var(--ui-text-primary);
  font-size: 0.8rem;
  line-height: 1.3;
  transition: border-color 0.16s ease, box-shadow 0.16s ease, background-color 0.16s ease;
}

.ui-field::placeholder {
  color: color-mix(in srgb, var(--ui-text-muted) 82%, #000000 18%);
}

.ui-field:focus,
.ui-select:focus {
  outline: none;
  border-color: var(--ui-focus);
  box-shadow: var(--ui-shadow-focus);
  background: color-mix(in srgb, var(--ui-bg-input) 92%, #0e1118 8%);
}

#app-top {
  --sidebar-drawer-width: 184px;
  --sidebar-resizer-width: 12px;
  display: flex;
  flex-direction: row;
  align-items: stretch;
  flex-shrink: 0;
  border-bottom: 1px solid var(--ui-border);
  background: var(--ui-bg-surface);
}

#app-brand {
  flex: 0 0 calc(var(--sidebar-drawer-width) + (var(--sidebar-resizer-width) / 2));
  min-width: 0;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 0 0.75rem;
  border-right: 1px solid transparent;
  overflow: hidden;
  transition: flex-basis 0.24s ease, padding 0.2s ease, opacity 0.2s ease;
}

.app-brand-lockup {
  display: inline-flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 0.14rem;
  text-align: center;
  white-space: nowrap;
}

.app-brand-text {
  font-size: 1.28rem;
  font-weight: 800;
  letter-spacing: 0.14em;
  line-height: 1;
  color: color-mix(in srgb, var(--ui-text-primary) 88%, #6aa6ff 12%);
  text-shadow: 0 1px 0 rgba(0, 0, 0, 0.28);
}

.app-brand-subtext {
  font-size: 0.56rem;
  font-weight: 600;
  letter-spacing: 0.06em;
  line-height: 1.1;
  color: var(--ui-text-secondary);
  opacity: 0.95;
}

#app-top.is-sidebar-collapsed #app-brand {
  flex-basis: 0;
  padding-left: 0;
  padding-right: 0;
  opacity: 0;
}

#toolbar {
  display: flex;
  align-items: center;
  flex: 1 1 auto;
  min-width: 0;
  gap: var(--ui-gap-button);
  padding: var(--ui-pad-surface-y) var(--ui-pad-surface-x);
  background: transparent;
  border-bottom: none;
  flex-shrink: 0;
  min-height: var(--ui-header-height);
}

#toolbar .ui-btn {
  width: var(--ui-btn-width-type-a);
  justify-content: center;
}

#context-toolbar {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 0.5rem;
  padding: 0.38rem var(--ui-space-4);
  background: var(--ui-bg-surface-muted);
  min-height: 42px;
  flex-shrink: 0;
}

.context-toolbar-drawers {
  margin-left: auto;
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
}

@media (max-width: 1100px) {
  .context-toolbar-drawers {
    margin-left: 0;
  }
}

#toolbar .toolbar-export-mode {
  flex-shrink: 0;
  width: var(--ui-btn-width-type-a);
  min-width: var(--ui-btn-width-type-a);
  max-width: var(--ui-btn-width-type-a);
  font-size: 0.78rem;
  padding-top: 0.4rem;
  padding-bottom: 0.4rem;
  border-radius: var(--ui-radius-sm);
}

#toolbar #status {
  font-size: 0.8rem;
  color: var(--ui-text-muted);
  margin-left: auto;
  flex: 1 1 0;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  text-align: left;
}

#toolbar #status-dirty-delta {
  flex-shrink: 0;
  font-size: 0.75rem;
  color: var(--ui-text-secondary);
  margin-right: 0;
  white-space: nowrap;
}

#main {
  --sidebar-drawer-width: 184px;
  --sidebar-resizer-width: 12px;
  position: relative;
  display: flex;
  flex: 1 1 auto;
  min-height: 0;
  overflow: hidden;
}

#sidebar {
  flex: 0 0 auto;
  width: var(--sidebar-drawer-width);
  min-width: 0;
  border-right: 1px solid var(--ui-border);
  display: flex;
  flex-direction: column;
  background: var(--ui-bg-surface);
  overflow: hidden;
  transition: width 0.24s ease, border-color 0.2s ease;
}

#sidebar.is-collapsed {
  border-right-color: transparent;
}

#main.is-sidebar-dragging #sidebar {
  transition: none;
}

#sidebar-resizer {
  position: relative;
  flex: 0 0 var(--sidebar-resizer-width);
  width: var(--sidebar-resizer-width);
  cursor: col-resize;
  touch-action: none;
  user-select: none;
  background: transparent;
  z-index: 2;
}

#sidebar-resizer::before {
  content: "";
  position: absolute;
  top: 0;
  bottom: 0;
  left: calc(50% - 0.5px);
  width: 1px;
  background: var(--ui-border);
  transition: background-color 0.18s ease, width 0.18s ease, left 0.18s ease;
}

#sidebar-resizer:hover::before,
#main.is-sidebar-dragging #sidebar-resizer::before {
  left: calc(50% - 1px);
  width: 2px;
  background: var(--ui-focus);
}

#tree-header {
  display: flex;
  flex-direction: column;
  gap: 0.45rem;
  padding: 0.52rem 0.62rem;
  border-bottom: 1px solid var(--ui-border);
  min-height: var(--ui-header-height);
  justify-content: center;
}

#tree-controls-grid {
  display: flex;
  flex-direction: column;
  gap: 0.42rem;
}

#tree-controls-grid.is-tree-controls-collapsed {
  display: none;
}

.tree-controls-toggle {
  width: var(--ui-btn-width-type-b);
  max-width: 100%;
  margin: 0 auto;
  justify-content: center;
  font-size: 0.74rem;
  padding: 0.34rem 0.48rem;
}

.tree-control-field {
  display: flex;
  flex-direction: column;
  gap: 0.2rem;
  min-width: 0;
}

#tree-current-path {
  font-size: 0.72rem;
  color: var(--ui-text-muted);
  line-height: 1.3;
  padding: 0.02rem 0.02rem 0.02rem;
  overflow: hidden;
  white-space: nowrap;
}

#tree-current-path .tree-crumb {
  color: color-mix(in srgb, var(--ui-focus) 78%, #d7ecff 22%);
  text-decoration: none;
  cursor: pointer;
}

#tree-current-path .tree-crumb:hover {
  color: #d7ecff;
  text-decoration: underline;
}

#tree-current-path .tree-crumb-back {
  margin-right: 0.4rem;
  font-weight: 600;
}

#tree-current-path .tree-crumb-sep {
  color: color-mix(in srgb, var(--ui-text-muted) 82%, #000000 18%);
  margin: 0 0.25rem;
}

#tree-current-path .tree-crumb-current {
  color: var(--ui-text-muted);
}

#tree-search {
  font-size: 0.8rem;
}

#tree-sort {
  font-size: 0.76rem;
}

.btn-tree-delete,
.btn-tree-move,
.btn-tree-new-draft {
  width: 100%;
  margin-top: 0;
  font-size: 0.78rem;
  font-weight: 600;
}

.tree-action-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 0.35rem;
}

.tree-action-grid > button {
  min-width: 0;
  font-size: 0.74rem;
  padding: 0.36rem 0.42rem;
}

.tree-action-grid--toolbar {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  flex-wrap: wrap;
}

.tree-action-grid--toolbar > button {
  width: auto;
  min-width: 4.6rem;
}

#tree-list-header {
  min-height: var(--ui-header-height);
  display: flex;
  align-items: center;
  padding: 0 0.6rem;
  border-bottom: 1px solid var(--ui-border);
}

#tree-list-header #tree-current-path {
  display: block;
}

#tree {
  flex: 1;
  overflow: auto;
  font-size: 0.85rem;
  padding: 0.12rem 0;
}

.tree-item {
  padding: 0.2rem 0.5rem 0.2rem 0.6rem;
  cursor: pointer;
  overflow: hidden;
}

.tree-item:hover {
  background: color-mix(in srgb, var(--ui-bg-surface-hover) 78%, transparent);
}

.tree-item.dir {
  color: color-mix(in srgb, var(--ui-focus) 72%, #d7ecff 28%);
  white-space: nowrap;
  text-overflow: ellipsis;
}

.tree-item.file {
  color: var(--ui-text-primary);
  display: flex;
  flex-direction: column;
  gap: 0.13rem;
  line-height: 1.25;
  border-bottom: 1px solid color-mix(in srgb, var(--ui-border) 42%, transparent);
  padding-top: 0.28rem;
  padding-bottom: 0.3rem;
}

.tree-item-file-heading {
  width: 100%;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  color: var(--ui-text-primary);
  font-size: 0.82rem;
}

.tree-item-file-sub {
  width: 100%;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  color: var(--ui-text-secondary);
  font-size: 0.73rem;
}

.tree-item-file-sub--editable {
  cursor: text;
}

.tree-item.file.tree-item-renaming {
  background: color-mix(in srgb, var(--ui-bg-surface-active) 72%, transparent);
}

.tree-item-slug-input {
  width: 100%;
  min-width: 0;
  box-sizing: border-box;
  padding: 0.12rem 0.28rem;
  border: 1px solid color-mix(in srgb, var(--ui-focus) 58%, transparent);
  border-radius: var(--ui-radius-sm);
  background: color-mix(in srgb, var(--ui-bg-input) 88%, #0e1420 12%);
  color: var(--ui-text-primary);
  font: inherit;
  outline: none;
}

.tree-item-slug-input:focus {
  border-color: var(--ui-focus);
  box-shadow: var(--ui-shadow-focus);
}

.tree-item-file-meta {
  width: 100%;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  color: var(--ui-text-muted);
  font-size: 0.69rem;
}

.tree-item.active {
  background: var(--ui-bg-surface-active);
}

.tree-item.file.active {
  border-bottom-color: color-mix(in srgb, var(--ui-focus) 48%, transparent);
}

.tree-item.tree-loading {
  cursor: default;
  opacity: 0.85;
  font-style: italic;
  color: var(--ui-text-muted);
}

/* 右ペイン: ファイルタブ + .md/プレビュー切替 + 単一表示エリア */
.main-pane {
  display: flex;
  flex-direction: column;
  flex: 1;
  min-width: 0;
  min-height: 0;
  overflow: hidden;
  background: var(--ui-bg-app);
}

#tab-bar {
  flex-shrink: 0;
  display: flex;
  align-items: stretch;
  background: var(--ui-bg-surface);
  border-bottom: 1px solid var(--ui-border);
  min-height: var(--ui-header-height);
}

.view-toggle-row {
  flex-shrink: 0;
  display: flex;
  gap: 0;
  padding: 0 0.5rem;
  background: var(--ui-bg-surface);
  border-bottom: 1px solid var(--ui-border);
}

.view-toggle-btn {
  padding: 0.42rem 1rem;
  font-size: 0.8rem;
  font-weight: 600;
  color: var(--ui-text-muted);
  background: transparent;
  border: none;
  box-shadow: none;
  border-bottom: 2px solid transparent;
  margin-bottom: -1px;
  border-radius: var(--ui-radius-sm) var(--ui-radius-sm) 0 0;
  transform: none;
}

.view-toggle-btn:hover {
  color: var(--ui-text-primary);
  background: var(--ui-bg-ghost-hover);
  transform: none;
}

.view-toggle-btn.active {
  color: var(--ui-text-on-primary);
  background: color-mix(in srgb, var(--ui-bg-app) 86%, transparent);
  border-bottom-color: var(--ui-bg-primary);
}

/* タブ・トグル下: エディタ/プレビュー + 右の設定ドロワー */
.main-pane-body {
  display: flex;
  flex: 1;
  min-height: 0;
  min-width: 0;
  overflow: hidden;
}

#view-stack {
  order: 1;
  flex: 1;
  min-width: 0;
  min-height: 0;
  position: relative;
}

#editor-wrap,
#preview-wrap {
  position: absolute;
  inset: 0;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

.main-pane.mode-md #preview-wrap {
  display: none;
}

.main-pane.mode-preview #editor-wrap {
  display: none;
}

#editor-wrap {
  background: var(--ui-bg-app);
}

#tab-strip {
  display: flex;
  flex: 1;
  flex-wrap: nowrap;
  overflow-x: auto;
  overflow-y: hidden;
  align-items: stretch;
  gap: 0;
  scrollbar-width: thin;
}

#tab-strip::-webkit-scrollbar {
  height: 4px;
}

#tab-strip::-webkit-scrollbar-thumb {
  background: var(--ui-border);
  border-radius: 2px;
}

.editor-tab {
  display: flex;
  align-items: center;
  gap: 0.35rem;
  flex-shrink: 0;
  max-width: 200px;
  padding: 0.1rem 0.2rem 0.1rem 0.65rem;
  font-size: 0.8rem;
  color: var(--ui-text-secondary);
  background: var(--ui-bg-surface-elevated);
  border: none;
  border-right: 1px solid var(--ui-border);
  cursor: pointer;
  user-select: none;
}

.editor-tab:focus {
  outline: none;
}

.editor-tab:focus-visible {
  box-shadow: inset 0 0 0 1px var(--ui-focus);
}

.editor-tab:hover {
  background: var(--ui-bg-surface-hover);
  color: var(--ui-text-primary);
}

.editor-tab.active {
  background: var(--ui-bg-app);
  color: var(--ui-text-on-primary);
  border-bottom: 2px solid var(--ui-bg-primary);
  margin-bottom: -1px;
}

.editor-tab.dirty .editor-tab-label::after {
  content: " ●";
  color: var(--ui-text-warning);
  font-size: 0.65rem;
}

.editor-tab-label {
  flex: 1;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  text-align: left;
}

.editor-tab-close {
  flex-shrink: 0;
  width: 1.45rem;
  height: 1.45rem;
  padding: 0;
  border: none;
  border-radius: var(--ui-radius-sm);
  background: transparent;
  color: var(--ui-text-muted);
  font-size: 1.1rem;
  line-height: 1;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
}

.editor-tab-close:hover {
  background: var(--ui-bg-ghost-hover);
  color: var(--ui-text-primary);
  transform: none;
}

#editor-host {
  flex: 1;
  min-height: 0;
  width: 100%;
}

/* プレビュー→.md ジャンプ時: 見つかった範囲を黄色で強調（Monaco inlineClassName） */
.monaco-editor .mdrw-preview-jump-highlight {
  background-color: rgba(255, 214, 0, 0.55) !important;
  box-shadow: inset 0 -3px 0 0 #ff9100, 0 0 0 1px rgba(255, 145, 0, 0.85);
  border-radius: 2px;
}

/* === Site / Preview Presentation ======================================= */
/* プレビュー列: 共通ヘッダー・本文・共通フッター。CSS 変数は子の #preview / .preview-shell へ継承 */
#preview-wrap {
  background: #1e1e1e;
  color: #1b1c1c;
  --font-body: system-ui, -apple-system, "Segoe UI", sans-serif;
  --font-heading: system-ui, -apple-system, "Segoe UI", sans-serif;
  --font-ui: system-ui, -apple-system, "Segoe UI", sans-serif;
  --font-code: system-ui, -apple-system, "Segoe UI", sans-serif, ui-monospace,
    "Cascadia Code", "SF Mono", Consolas, monospace;
  font-family: var(--font-body);
  --accent-color: #006b56;
  --tag-accent-color: #006b56;
  --text-font-size: 1.2rem;
  --text-line-height: 2.0;
  --list-line-height: 1.5;
  --list-font-size: 1.2rem;
  --list-indent: 1.35em;
  --nested-indent: 1.25rem;
  --nested-border-width: 2px;
  --list-item-gap: 0.85rem;
  --list-nested-gap: 0.45rem;
  --bullet-size-1: 0.5em;
  --bullet-size-2: 0.55em;
  --bullet-size-3: 0.5em;
  --bullet-char-1: "●";
  --bullet-char-2: "○";
  --bullet-char-3: "▪";
  --header-h1-size: 3rem;
  --header-h1-margin-bottom: 1rem;
  --prose-h1-size: 2.25rem;
  --prose-h1-margin-top: 2rem;
  --prose-h1-margin-bottom: 1rem;
  --h2-size: 1.5rem;
  --h3-size: 1.25rem;
  --h4-size: 1.2rem;
  --h5-size: 1.15rem;
  --h6-size: 1.1rem;
  --h2-margin-top: 4rem;
  --h3-margin-top: 2.5rem;
  --h4-margin-top: 2rem;
  --h5-margin-top: 1.75rem;
  --h6-margin-top: 1.5rem;
  --h2-margin-bottom: 1.5rem;
  --h3-margin-bottom: 1rem;
  --h4-margin-bottom: 0.75rem;
  --h5-margin-bottom: 0.65rem;
  --h6-margin-bottom: 0.5rem;
  --h2-accent-width: 4px;
  --h2-accent-style: solid;
  --h2-accent-padding: 1rem;
  --paragraph-spacing: 1.5rem;
  --section-spacing: 2rem;
  --max-content-width: 768px;
  --index-content-width: 1680px;
  --index-card-min-width: 240px;
  --content-padding-top: 2rem;
  --content-padding-x: 1.5rem;
  --content-padding-bottom: 6rem;
  /* ヘッダー・フッター用（本文 --max-content-width とは独立） */
  --shell-side-padding: clamp(0.75rem, 4vw, 2.5rem);
  --preview-scrollbar-width: 0px;
  --text-muted-contrast: #5f6a65;
  --text-subtle-contrast: #4d5853;
}

/* header.md / footer.md レンダリ結果（#preview 外・同期対象外） */
#preview-wrap .preview-shell {
  flex-shrink: 0;
  background: #fafaf2;
  color: #1a1c18;
}

/* 共通ヘッダー: 記事スクロールに連動して隠す（JS が .shell-header-hidden を付与） */
#preview-wrap .preview-shell-header {
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  z-index: 10;
  border-bottom: none;
  box-shadow: none;
  transition: transform 0.28s ease, opacity 0.22s ease, visibility 0.28s;
  transform: translateY(0);
  opacity: 1;
  visibility: visible;
}

#preview-wrap .preview-shell-header.shell-header-hidden {
  transform: translateY(-100%);
  opacity: 0;
  visibility: hidden;
  pointer-events: none;
}

/* 先頭へ戻る（プレビュー・エクスポート共通。位置はコンテキストで上書き） */
.mdrw-back-to-top {
  box-sizing: border-box;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 2.1rem;
  height: 2.1rem;
  padding: 0;
  margin: 0;
  border: none;
  border-radius: 999px;
  background: color-mix(
    in srgb,
    var(--accent-color, #006b56) 14%,
    rgba(255, 255, 255, 0.06)
  );
  color: color-mix(in srgb, var(--accent-color, #006b56) 72%, #3a403d);
  font-size: 1rem;
  line-height: 1;
  cursor: pointer;
  opacity: 0;
  pointer-events: none;
  transform: translateY(4px);
  transition:
    opacity 160ms ease,
    transform 160ms ease,
    background-color 160ms ease;
}

.mdrw-back-to-top.mdrw-back-to-top--visible {
  opacity: 0.78;
  pointer-events: auto;
  transform: translateY(0);
}

.mdrw-back-to-top:hover {
  opacity: 0.95;
}

.mdrw-back-to-top:focus {
  outline: none;
}

.mdrw-back-to-top:focus-visible {
  box-shadow: 0 0 0 2px
    color-mix(in srgb, var(--accent-color, #006b56) 40%, transparent);
}

/* プレビュー列内: 先頭へ戻る（#preview-wrap が containing block） */
#preview-wrap .mdrw-back-to-top {
  position: absolute;
  right: calc(0.5rem + var(--preview-scrollbar-width, 0px));
  bottom: 1rem;
  z-index: 25;
}

/* ヘッダー分の余白（オーバーレイのため本文が隠れないように） */
#preview-wrap #preview {
  padding-top: var(--site-header-offset, 3.5rem);
}

/* 本文＋フッターをまとめて縦スクロール（フッターはコンテンツ末尾） */
#preview-scroll {
  flex: 1;
  min-height: 0;
  overflow-x: auto;
  overflow-y: scroll;
  scrollbar-gutter: stable;
  background: #fafaf2;
  color: inherit;
  font-family: inherit;
  display: flex;
  flex-direction: column;
}

/* プレビューモードで画像をドラッグ中のフィードバック */
#preview-scroll.preview-drop-active {
  outline: 2px dashed var(--accent-color, #006b56);
  outline-offset: -4px;
  background: color-mix(in srgb, var(--accent-color, #006b56) 10%, #fafaf2);
}

/* 共通フッター: #preview-scroll 内で記事の直後（長文は最後までスクロールで表示） */
#preview-wrap .preview-shell-footer {
  flex-shrink: 0;
  border-top: none;
  background: #f4f4ec;
}

/* Rust が包む .preview-shell-inner: 本文カラム幅に縛らずプレビュー列いっぱい */
#preview-wrap .preview-shell-inner {
  max-width: none;
  width: 100%;
  margin: 0;
  box-sizing: border-box;
  padding: 0.65rem var(--shell-side-padding);
}

#preview-wrap .preview-shell-header .preview-shell-inner {
  padding-right: calc(
    var(--shell-side-padding) + var(--preview-scrollbar-width)
  );
}

#preview-wrap .preview-shell .prose-content {
  font-size: 0.9rem;
  line-height: 1.5;
}

#preview-wrap .preview-shell .prose-content h1 {
  font-family: var(--font-heading);
  font-size: 1.2rem;
  font-weight: 700;
  margin: 0;
  color: #1b1c1c;
}

#preview-wrap .preview-shell .prose-content h2,
#preview-wrap .preview-shell .prose-content h3 {
  font-family: var(--font-heading);
  font-size: 1rem;
  font-weight: 600;
  margin: 0.35rem 0 0;
  color: #2d3330;
}

#preview-wrap .preview-shell .prose-content p {
  margin: 0.25rem 0 0;
}

#preview-wrap .preview-shell .prose-content p:first-child {
  margin-top: 0;
}

#preview-wrap .preview-shell .prose-content a {
  color: var(--accent-color);
  text-decoration: none;
}

#preview-wrap .preview-shell .prose-content a:hover {
  text-decoration: underline;
}

#preview-wrap .preview-shell-error {
  margin: 0;
  font-size: 0.8rem;
  color: #b42318;
}

/* --- site-header（header.md 内 HTML） --- */
#preview-wrap .site-header {
  min-height: 3.25rem;
}

#preview-wrap .site-header.site-header--glass {
  backdrop-filter: blur(20px);
  -webkit-backdrop-filter: blur(20px);
  background: rgba(250, 250, 242, 0.82);
}

#preview-wrap .site-header-inner {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  flex-wrap: wrap;
  /* 横余白は .preview-shell-inner が担当 */
  padding: 0.75rem 0;
  max-width: 80rem;
  margin-left: auto;
  margin-right: auto;
}

#preview-wrap .site-logo {
  display: inline-flex;
  align-items: center;
  flex-shrink: 0;
  line-height: 0;
  text-decoration: none;
}

#preview-wrap .site-logo:hover .site-logo-img {
  opacity: 0.92;
}

#preview-wrap .site-logo-img {
  display: block;
  height: 2.9rem;
  width: auto;
  max-width: min(16rem, 58vw);
  object-fit: contain;
  object-position: left center;
}

#preview-wrap .site-header-right {
  display: flex;
  align-items: center;
  gap: 0.65rem;
  flex: 1;
  justify-content: flex-end;
  min-width: 0;
}

#preview-wrap .site-nav-collapsible {
  position: relative;
}

#preview-wrap .nav-toggle {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 2.25rem;
  height: 2.25rem;
  padding: 0;
  border: 1px solid color-mix(in srgb, var(--accent-color) 35%, #c5c5c5);
  border-radius: 6px;
  background: #fff;
  cursor: pointer;
  color: #1b1c1c;
}

#preview-wrap .nav-toggle:hover {
  border-color: var(--accent-color);
  background: color-mix(in srgb, var(--accent-color) 8%, #fff);
}

#preview-wrap .nav-toggle-icon {
  display: block;
  width: 1rem;
  height: 2px;
  background: currentColor;
  box-shadow: 0 -5px 0 currentColor, 0 5px 0 currentColor;
}

#preview-wrap .nav-menu {
  list-style: none;
  margin: 0;
  padding: 0;
  position: absolute;
  top: calc(100% + 6px);
  right: 0;
  min-width: 11rem;
  background: #fff;
  border: 1px solid #ddd;
  border-radius: 8px;
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.08);
  display: none;
  z-index: 20;
}

#preview-wrap .site-nav-collapsible.is-open .nav-menu {
  display: block;
}

#preview-wrap .nav-menu li {
  border-bottom: 1px solid #eee;
}

#preview-wrap .nav-menu li:last-child {
  border-bottom: none;
}

#preview-wrap .nav-menu a {
  display: block;
  padding: 0.55rem 1rem;
  font-size: 0.875rem;
  font-weight: 600;
  font-family: "Inter", var(--font-ui), system-ui, sans-serif;
  color: #2d3330;
  text-decoration: none;
}

#preview-wrap .nav-menu a:hover {
  background: color-mix(in srgb, #005140 8%, #fff);
  color: #005140;
}

#preview-wrap .site-search {
  display: flex;
  align-items: stretch;
  border: none;
  border-radius: 999px;
  overflow: hidden;
  background: #ffffff;
  box-shadow: 0 1px 0 rgba(26, 28, 24, 0.06);
  min-width: 0;
  max-width: 14rem;
  flex: 1;
}

#preview-wrap .site-search input[type="search"] {
  flex: 1;
  min-width: 0;
  border: none;
  padding: 0.45rem 0.75rem;
  font-size: 0.82rem;
  font-family: "Inter", var(--font-ui), system-ui, sans-serif;
  background: transparent;
  color: #1a1c18;
}

#preview-wrap .site-search input[type="search"]::placeholder {
  color: #6e7a75;
}

#preview-wrap .site-search input[type="search"]:focus {
  outline: none;
}

#preview-wrap .site-search-btn {
  flex-shrink: 0;
  padding: 0 0.65rem;
  border: none;
  border-left: 1px solid color-mix(in srgb, #6e7a75 25%, transparent);
  background: #f4f4ec;
  cursor: pointer;
  font-size: 1rem;
  line-height: 1;
  color: #52625d;
}

#preview-wrap .site-search-btn:hover {
  background: color-mix(in srgb, #005140 10%, #f4f4ec);
  color: #005140;
}

@media (min-width: 768px) {
  #preview-wrap .nav-toggle {
    display: none;
  }

  #preview-wrap .nav-menu {
    display: flex;
    position: static;
    flex-direction: row;
    flex-wrap: wrap;
    gap: 0;
    min-width: 0;
    background: transparent;
    border: none;
    box-shadow: none;
    border-radius: 0;
    align-items: center;
  }

  #preview-wrap .site-nav-collapsible.is-open .nav-menu {
    display: flex;
  }

  #preview-wrap .nav-menu li {
    border-bottom: none;
  }

  #preview-wrap .nav-menu a {
    padding: 0.35rem 0.65rem;
    border-radius: 4px;
    font-weight: 600;
    font-size: 0.9rem;
    color: #52625d;
    font-family: "Inter", var(--font-ui), system-ui, sans-serif;
    border-bottom: 2px solid transparent;
  }

  #preview-wrap .nav-menu a:hover {
    color: #005140;
    background: transparent;
  }
}

/* --- site-footer（footer.md 内 HTML） --- */
#preview-wrap .site-footer {
  width: 100%;
}

#preview-wrap .site-footer-inner {
  /* 横余白は .preview-shell-inner が担当 */
  padding: 1.75rem 0 2rem;
  max-width: 80rem;
  margin-left: auto;
  margin-right: auto;
}

@media (min-width: 1200px) {
  #preview-wrap .site-footer-inner {
    padding: 2rem 0 2.25rem;
  }
}

#preview-wrap .site-footer.site-footer--editorial {
  background: #f4f4ec;
}

#preview-wrap .footer-columns {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 1.25rem 1.5rem;
}

@media (max-width: 640px) {
  #preview-wrap .footer-columns {
    grid-template-columns: 1fr;
  }
}

#preview-wrap .footer-col h3 {
  font-size: 0.72rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: #52625d;
  margin: 0 0 0.5rem;
}

#preview-wrap .footer-col ul {
  list-style: none;
  margin: 0;
  padding: 0;
}

#preview-wrap .footer-col li {
  margin: 0.25rem 0;
}

#preview-wrap .footer-col a {
  font-size: 0.85rem;
  color: #2d4038;
  text-decoration: none;
  font-family: "Inter", var(--font-ui), system-ui, sans-serif;
}

#preview-wrap .footer-col a:hover {
  color: #005140;
  text-decoration: underline;
}

#preview-wrap .footer-copyright {
  margin: 1rem 0 0;
  padding-top: 0.85rem;
  border-top: none;
  font-size: 0.8125rem;
  color: #52625d;
  text-align: center;
  font-family: "Inter", var(--font-ui), system-ui, sans-serif;
}

#preview-wrap .footer-editorial-row {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  text-align: center;
}

@media (min-width: 768px) {
  #preview-wrap .footer-editorial-row {
    flex-direction: row;
    text-align: left;
  }
}

#preview-wrap .footer-editorial-note {
  margin: 0;
  font-size: 0.8125rem;
  line-height: 1.55;
  color: #52625d;
  max-width: 36rem;
}

#preview-wrap .footer-editorial-note a {
  color: #005140;
  font-weight: 600;
  text-decoration: none;
  border-bottom: 1px solid color-mix(in srgb, #005140 35%, transparent);
}

#preview-wrap .footer-editorial-note a:hover {
  color: #006b56;
  border-bottom-color: #006b56;
}

#preview-label {
  padding: 0.35rem 0.6rem;
  font-size: 0.75rem;
  color: #888;
  border-bottom: 1px solid #3c3c3c;
}

/* --- The Curator デザイン: Material Design 3 + Tailwind --- */
/* プレビュー調整は JS（設定メニュー）から #preview-wrap に上書き（子へ継承） */
/* 縦スクロールは親 #preview-scroll に任せ、本文は内容高さで伸びる */
#preview {
  flex-shrink: 0;
  min-height: min-content;
  overflow-x: auto;
  overflow-y: visible;
  background: transparent;
  color: inherit;
  font-family: inherit;
}

#preview [data-preview-body][contenteditable="true"] {
  outline: none;
  box-shadow: none;
}

/* title / description の編集時フォーカス枠は表示しない */
#preview [data-preview-field][contenteditable="true"],
#preview [data-preview-field][contenteditable="true"]:focus,
#preview [data-preview-field][contenteditable="true"]:focus-visible {
  outline: none;
  box-shadow: none;
}

/* プレビュー内部のスタイル（Tailwindが読めない場合のフォールバック） */
#preview > .preview-article {
  max-width: var(--max-content-width);
  margin: 0 auto;
  padding: var(--content-padding-top) var(--content-padding-x)
    var(--content-padding-bottom);
}

#preview > .preview-article[data-preview-layout="index"] {
  width: 100%;
  max-width: none;
  margin: 0;
  padding-left: var(--shell-side-padding);
  padding-right: var(--shell-side-padding);
}

#preview header.preview-frontmatter-header {
  text-align: center;
  margin-bottom: var(--section-spacing);
}

#preview .preview-frontmatter-meta {
  width: 100%;
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  gap: 0.35rem;
  margin: 0 0 0.9rem;
}

#preview header.preview-frontmatter-header h1.preview-frontmatter-title {
  font-family: var(--font-heading);
  /* 設定ドロワー開閉でプレビュー幅が変わっても、ヘッダーサイズが変わらないよう
     純粋な CSS 変数値を使用（12vw との min は除去） */
  font-size: var(--header-h1-size);
  font-weight: 700;
  color: #1b1c1c;
  letter-spacing: -0.02em;
  line-height: 1.2;
  margin: 0 0 var(--header-h1-margin-bottom);
  text-align: left;
}

/* プレビューから title / description を編集するときの空プレースホルダー */
#preview h1.preview-frontmatter-title[data-preview-field="title"]:empty::before {
  content: "タイトル";
  color: color-mix(in srgb, #1b1c1c 38%, #78847f);
  pointer-events: none;
}

#preview p.preview-frontmatter-description[data-preview-field="description"]:empty::before {
  content: "説明（任意）";
  color: color-mix(in srgb, #56635e 45%, #78847f);
  pointer-events: none;
}

#preview .preview-frontmatter-date {
  margin: 0;
  font-size: 0.72rem;
  font-weight: 600;
  color: var(--text-subtle-contrast);
  text-align: right;
}

#preview .preview-draft-badge {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 0.22rem 0.55rem;
  margin-bottom: 0;
  font-size: 0.6rem;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: #ffffff;
  background: #b42318;
  border-radius: 999px;
}

#preview .preview-frontmatter-description {
  max-width: 42rem;
  margin: 0 0 1.25rem;
  font-size: var(--text-font-size) !important;
  line-height: var(--text-line-height) !important;
  color: #56635e;
  text-align: left;
}

#preview .preview-tag-list {
  display: flex;
  justify-content: flex-end;
  flex-wrap: wrap;
  gap: 0.5rem;
  margin: 0 0 0 auto;
  max-width: min(100%, 28rem);
}

#preview .preview-tag-chip {
  display: inline-block;
  padding: 0.25rem 1rem;
  font-size: 0.75rem;
  font-weight: 600;
  letter-spacing: 0.05em;
  color: color-mix(in srgb, var(--tag-accent-color) 70%, #1b1c1c);
  background: color-mix(in srgb, var(--tag-accent-color) 15%, #f0f5f2);
  border-radius: 999px;
  text-decoration: none;
  border-bottom: none;
  transition:
    transform 160ms ease,
    background-color 160ms ease,
    color 160ms ease;
}

#preview .preview-tag-chip:hover {
  transform: translateY(-1px);
  color: color-mix(in srgb, var(--tag-accent-color) 84%, #1b1c1c);
  background: color-mix(in srgb, var(--tag-accent-color) 22%, #f0f5f2);
  border-bottom: none;
}

#preview .preview-index-page {
  display: grid;
  align-content: start;
  gap: 1.25rem;
  max-width: 56rem;
  margin-left: auto;
  margin-right: auto;
  font-family: "Inter", var(--font-ui), system-ui, sans-serif;
}

#preview .preview-index-page-header {
  display: grid;
  align-content: start;
  gap: 0.35rem;
  margin: 0;
}

#preview .preview-index-filter-summary {
  margin: 0;
  font-size: 0.86rem;
  font-weight: 600;
  line-height: 1.5;
  color: #44524d;
}

#preview .preview-index-filter-summary[hidden] {
  display: none !important;
}

#preview .preview-index-empty[hidden] {
  display: none !important;
}

#preview .preview-index-page .preview-index-page-header > h1 {
  margin: 0;
  font-family: "Plus Jakarta Sans", var(--font-heading), system-ui, sans-serif;
  font-size: clamp(1.9rem, calc(var(--header-h1-size) * 0.72), 2.35rem);
  font-weight: 700;
  color: #1a1c18;
  letter-spacing: -0.02em;
  line-height: 1.2;
}

#preview .preview-home-section {
  display: grid;
  align-content: start;
  gap: 0.78rem;
  margin: 0;
}

#preview .preview-home-section-header {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 0.75rem;
  margin: 0;
}

#preview .preview-home-section-title {
  margin: 0;
  font-family: "Plus Jakarta Sans", var(--font-heading), system-ui, sans-serif;
  font-size: 1.3rem;
  font-weight: 700;
  line-height: 1.3;
  color: #1a1c18;
}

#preview .preview-home-tag-groups {
  display: grid;
  align-content: start;
  gap: 1rem;
}

#preview .preview-index-empty {
  margin: 0;
  color: #66736d;
}

#preview .preview-index-grid {
  display: grid;
  grid-template-columns: repeat(
    auto-fit,
    minmax(
      min(100%, var(--index-card-min-width)),
      min(100%, var(--index-card-min-width))
    )
  );
  justify-content: start;
  gap: 10px;
}

/* 縦並びフィード（横長カード） */
#preview .preview-index-feed {
  display: flex;
  flex-direction: column;
  gap: 2.5rem;
  width: 100%;
}

#preview .preview-hero-wrap {
  width: 100%;
  margin-bottom: 0.25rem;
}

#preview .preview-feed-section-title {
  margin: 2rem 0 0;
  font-size: 0.75rem;
  font-weight: 700;
  letter-spacing: 0.2em;
  text-transform: uppercase;
  color: #6e7a75;
  font-family: "Inter", var(--font-ui), system-ui, sans-serif;
}

#preview .preview-index-card-item {
  margin: 0;
  min-width: 0;
  padding: 0;
  max-width: none;
}

/* --- 横並びカード --- */
#preview .preview-index-card.preview-index-card--horizontal {
  display: flex;
  flex-direction: column;
  gap: 0;
  text-decoration: none;
  color: inherit;
  border-bottom: none;
  border-radius: 0;
  background: transparent;
}

@media (min-width: 768px) {
  #preview .preview-index-card.preview-index-card--horizontal {
    flex-direction: row;
    align-items: stretch;
    gap: 2rem;
  }
}

#preview .preview-index-card.preview-index-card--horizontal:hover
  .preview-index-card-title {
  color: #005140;
}

#preview .preview-index-card.preview-index-card--horizontal:hover
  .preview-index-card-image {
  transform: scale(1.08);
}

#preview .preview-index-card.preview-index-card--horizontal .preview-index-card-media {
  position: relative;
  flex-shrink: 0;
  width: 100%;
  max-width: 100%;
  aspect-ratio: 16 / 9;
  overflow: hidden;
  border-radius: 0.5rem;
  background: #f4f4ec;
}

@media (min-width: 768px) {
  #preview .preview-index-card.preview-index-card--horizontal .preview-index-card-media {
    width: 16rem;
    max-width: 40%;
    aspect-ratio: 1 / 1;
  }
}

#preview .preview-index-card.preview-index-card--horizontal .preview-index-card-content {
  display: flex;
  flex-direction: column;
  justify-content: center;
  gap: 0.5rem;
  flex: 1;
  min-width: 0;
  padding: 0.15rem 0;
}

#preview .preview-index-tag-chip-list {
  display: flex;
  flex-wrap: wrap;
  gap: 0.4rem;
  align-items: center;
}

#preview .preview-index-tag-chip {
  display: inline-flex;
  align-items: center;
  padding: 0.25rem 0.75rem;
  margin-bottom: 0.15rem;
  font-size: 0.6875rem;
  font-weight: 700;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: #005140;
  font-family: "Inter", var(--font-ui), system-ui, sans-serif;
}

#preview .preview-index-card.preview-index-card--horizontal .preview-index-tag-chip {
  background: transparent;
  padding-left: 0;
  padding-right: 0;
  margin-bottom: 0;
}

#preview .preview-index-card.preview-index-card--hero .preview-index-tag-chip {
  background: #d2e4dd;
  color: #566661;
  border-radius: 999px;
  padding: 0.25rem 0.75rem;
}

#preview .preview-index-card .preview-index-card-title {
  margin: 0;
  font-family: "Plus Jakarta Sans", var(--font-heading), system-ui, sans-serif;
  font-size: clamp(1.25rem, 2.8vw, 1.5rem);
  line-height: 1.3;
  font-weight: 700;
  color: #1a1c18;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
  text-wrap: pretty;
  transition: color 0.3s ease;
}

#preview .preview-index-card-description {
  margin: 0;
  font-size: 0.9375rem;
  line-height: 1.65;
  color: #3e4945;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
  font-family: "Inter", var(--font-ui), system-ui, sans-serif;
}

#preview .preview-index-card-meta {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.25rem;
  margin-top: 0.25rem;
  font-size: 0.75rem;
  font-weight: 500;
  color: #6e7a75;
  font-family: "Inter", var(--font-ui), system-ui, sans-serif;
}

#preview .preview-index-card-date {
  font-variant-numeric: tabular-nums;
}

#preview .preview-index-card-media > .preview-index-card-image {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
  margin: 0;
  max-width: none;
  border-radius: 0;
  transition: transform 0.5s ease;
}

#preview .preview-index-card-placeholder {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 100%;
  height: 100%;
  padding: 0.9rem;
  background: #f4f4ec;
  color: #6e7a75;
}

#preview .preview-index-card-placeholder-label {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 5rem;
  padding: 0.24rem 0.55rem;
  font-size: 0.66rem;
  font-weight: 600;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  background: rgba(255, 255, 255, 0.85);
  border-radius: 999px;
}

/* --- ヒーロー --- */
#preview .preview-index-card.preview-index-card--hero {
  display: block;
  text-decoration: none;
  color: inherit;
  border-bottom: none;
}

#preview .preview-hero-media {
  margin-bottom: 1.5rem;
}

#preview .preview-hero-image-wrap {
  position: relative;
  width: 100%;
  aspect-ratio: 16 / 9;
  overflow: hidden;
  border-radius: 0.75rem;
  background: #f4f4ec;
  transition: transform 0.5s ease;
}

#preview .preview-index-card--hero:hover .preview-hero-image-wrap {
  transform: scale(1.01);
}

#preview .preview-hero-image {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
  margin: 0;
}

#preview .preview-hero-content {
  gap: 0.65rem;
}

#preview .preview-hero-meta-row {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.4rem;
}

#preview .preview-hero-title {
  margin: 0;
  font-family: "Plus Jakarta Sans", var(--font-heading), system-ui, sans-serif;
  font-size: clamp(2rem, 5vw, 2.75rem);
  font-weight: 800;
  line-height: 1.15;
  letter-spacing: -0.03em;
  color: #1a1c18;
  transition: color 0.3s ease;
}

#preview .preview-index-card--hero:hover .preview-hero-title {
  color: #005140;
}

#preview .preview-hero-description {
  max-width: 42rem;
  font-size: 1.0625rem;
  -webkit-line-clamp: 4;
}

#preview .preview-hero-footer-meta {
  padding-top: 0.35rem;
}

#preview .preview-tag-directory {
  display: flex;
  flex-wrap: wrap;
  gap: 0.55rem;
  margin: 0;
}

#preview .preview-tag-directory-link {
  display: inline-flex;
  align-items: center;
  gap: 0.45rem;
  padding: 0.4rem 0.85rem;
  border-radius: 999px;
  text-decoration: none;
  color: #566661;
  background: #d2e4dd;
  border: none;
  font-family: "Inter", var(--font-ui), system-ui, sans-serif;
  transition:
    background-color 0.2s ease,
    color 0.2s ease,
    transform 0.2s ease;
}

#preview .preview-tag-directory-link:hover {
  color: #005140;
  background: color-mix(in srgb, #005140 12%, #d2e4dd);
  border-bottom: none;
  transform: translateY(-1px);
}

#preview .preview-tag-directory-name {
  font-size: 0.76rem;
  font-weight: 700;
  letter-spacing: 0.02em;
}

#preview .preview-tag-directory-count {
  font-size: 0.7rem;
  font-weight: 600;
  color: #52625d;
}

#preview .preview-tag-section {
  margin: 0;
  display: grid;
  align-content: start;
  gap: 0.78rem;
  scroll-margin-top: calc(var(--site-header-offset, 3.5rem) + 0.9rem);
}

#preview .preview-tag-section-header {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 0.75rem;
  margin: 0;
}

#preview .preview-tag-section .preview-tag-section-title {
  margin: 0;
  font-family: var(--font-heading);
  font-size: 1.3rem;
  font-weight: 700;
  line-height: 1.3;
  color: #1b1c1c;
  border-left: none;
  padding-left: 0;
}

#preview .preview-tag-section-count {
  display: inline-block;
  font-size: 0.74rem;
  font-weight: 600;
  color: #73807a;
}

@media (max-width: 720px) {
  #preview .preview-index-grid {
    grid-template-columns: minmax(0, 1fr);
    gap: 10px;
  }

  #preview .preview-index-feed {
    gap: 2rem;
  }

  #preview .preview-tag-section-header {
    flex-direction: column;
    align-items: flex-start;
    gap: 0.25rem;
  }

  #preview .preview-home-section-header {
    flex-direction: column;
    align-items: flex-start;
    gap: 0.25rem;
  }
}

#preview .prose-content h1 {
  font-family: var(--font-heading);
  font-size: var(--prose-h1-size);
  font-weight: 700;
  color: #1b1c1c;
  line-height: 1.25;
  margin-top: var(--prose-h1-margin-top);
  margin-bottom: var(--prose-h1-margin-bottom);
}

#preview .preview-date-badge {
  display: inline-block;
  padding: 0.35rem 1rem;
  margin-bottom: 1rem;
  font-size: 0.75rem;
  font-weight: 600;
  letter-spacing: 0.05em;
  color: #ffffff;
  background: var(--accent-color);
  border-radius: 999px;
}

#preview .preview-tags {
  display: flex;
  justify-content: center;
  flex-wrap: wrap;
  gap: 0.5rem;
  margin-top: 1.5rem;
}

#preview .preview-tag {
  display: inline-block;
  padding: 0.4rem 1rem;
  font-size: 0.75rem;
  font-weight: 600;
  letter-spacing: 0.02em;
  color: color-mix(in srgb, var(--tag-accent-color) 70%, #1b1c1c);
  background: color-mix(in srgb, var(--tag-accent-color) 15%, #f0f5f2);
  border-radius: 999px;
  text-decoration: none;
}

#preview .preview-featured-image {
  position: relative;
  aspect-ratio: 16/9;
  overflow: hidden;
  border-radius: 0.75rem;
  background: #eae8e7;
  margin-top: 0;
  margin-bottom: var(--section-spacing);
}

#preview .preview-featured-image.preview-featured-image-empty {
  display: flex;
  align-items: center;
  justify-content: center;
  border: 1px dashed color-mix(in srgb, var(--accent-color) 40%, #bccac3);
  background:
    linear-gradient(180deg, rgba(255, 255, 255, 0.85), rgba(238, 241, 239, 0.92)),
    #eef1ef;
}

#preview .preview-featured-image-placeholder {
  padding: 1.5rem;
  text-align: center;
}

#preview .preview-featured-image-label {
  margin: 0;
  font-size: 1rem !important;
  font-weight: 700;
  color: #1b1c1c;
}

#preview .preview-featured-image-help {
  margin: 0.45rem 0 0 !important;
  font-size: 0.9rem !important;
  color: #56635e;
}

#preview .preview-featured-image.featured-image-drop-active {
  outline: 3px dashed var(--accent-color, #006b56);
  outline-offset: -4px;
  background: color-mix(in srgb, var(--accent-color, #006b56) 15%, #eae8e7);
  cursor: copy;
}

#preview .preview-featured-image.featured-image-drop-active::after {
  content: "Drop to replace featured image";
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  font-family: var(--font-ui);
  font-size: 1rem;
  font-weight: 600;
  color: var(--accent-color, #006b56);
  background: rgba(255, 255, 255, 0.85);
  pointer-events: none;
  z-index: 2;
}

#preview .preview-featured-image-img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
  margin: 0;
  max-width: none;
  border-radius: 0;
  box-shadow: 0 0 0 1px rgba(107, 114, 128, 0.18);
}

#preview .preview-youtube-embed {
  display: block;
  margin: 0 0 var(--paragraph-spacing);
  border-radius: 1rem;
  overflow: hidden;
  background: #111;
  box-shadow: 0 18px 40px rgba(0, 0, 0, 0.14);
  user-select: none;
}

#preview .preview-youtube-embed-frame {
  position: relative;
  width: 100%;
  padding-top: 56.25%;
  background:
    radial-gradient(circle at top, rgba(255, 255, 255, 0.14), transparent 48%),
    #000;
}

#preview .preview-youtube-activate {
  position: absolute;
  inset: 0;
  display: block;
  width: 100%;
  height: 100%;
  padding: 0;
  border: 0;
  background:
    linear-gradient(180deg, rgba(0, 0, 0, 0.08), rgba(0, 0, 0, 0.42)),
    transparent;
  cursor: pointer;
}

#preview .preview-youtube-activate:focus-visible {
  outline: 3px solid #fff;
  outline-offset: -6px;
}

#preview .preview-youtube-thumb {
  position: absolute;
  inset: 0;
  display: block;
  width: 100%;
  height: 100%;
  object-fit: cover;
}

#preview .preview-youtube-play {
  position: absolute;
  left: 50%;
  top: 50%;
  width: 92px;
  height: 64px;
  border-radius: 20px;
  transform: translate(-50%, -50%);
  background: rgba(18, 18, 18, 0.74);
  box-shadow: 0 18px 36px rgba(0, 0, 0, 0.26);
  transition:
    transform 0.18s ease,
    background-color 0.18s ease,
    box-shadow 0.18s ease;
}

#preview .preview-youtube-play::before {
  content: "";
  position: absolute;
  left: 50%;
  top: 50%;
  transform: translate(-38%, -50%);
  border-style: solid;
  border-width: 12px 0 12px 20px;
  border-color: transparent transparent transparent #fff;
}

#preview .preview-youtube-activate:hover .preview-youtube-play,
#preview .preview-youtube-activate:focus-visible .preview-youtube-play {
  transform: translate(-50%, -50%) scale(1.06);
  background: #ff0033;
  box-shadow: 0 24px 44px rgba(0, 0, 0, 0.3);
}

#preview .preview-youtube-embed-frame iframe {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  border: 0;
  pointer-events: auto;
}

#preview .preview-body img.preview-image-selected {
  outline: 3px solid var(--accent-color, #006b56);
  outline-offset: 4px;
  box-shadow: 0 0 0 6px
    color-mix(in srgb, var(--accent-color, #006b56) 14%, transparent);
  cursor: pointer;
}

#preview .preview-md-copy-row {
  margin: 1.25rem 0 0;
  padding: 0.75rem 0 0;
  border-top: 1px solid color-mix(in srgb, var(--accent-color) 18%, #d4d4d4);
  font-size: 0.82rem;
  color: #66736d;
  line-height: 1.5;
}

#preview .preview-md-copy-row--in-header {
  margin-top: 0.65rem;
  padding-top: 0;
  border-top: none;
  text-align: left;
}

#preview .preview-md-copy-btn {
  margin-right: 0.5rem;
  padding: 0.28rem 0.65rem;
  font-size: 0.78rem;
  font-weight: 600;
  color: #2d4038;
  background: #eef1ef;
  border: 1px solid #c5d1cb;
  border-radius: 6px;
  cursor: pointer;
  font-family: var(--font-ui);
}

#preview .preview-md-copy-btn:hover {
  border-color: var(--accent-color);
  color: var(--accent-color);
  background: color-mix(in srgb, var(--accent-color) 8%, #fff);
}

#preview .preview-md-copy-hint {
  font-size: 0.78rem;
  color: var(--text-muted-contrast);
}

/* エクスポート記事末尾: 更新履歴（バックアップ）・関連記事（自動生成） */
#preview .article-version-history,
#preview .article-related {
  margin-top: var(--section-spacing, 2rem);
  padding-top: 1.25rem;
  border-top: 1px solid color-mix(in srgb, var(--accent-color) 12%, #d4d4d4);
  font-size: 0.95rem;
  line-height: 1.55;
  color: var(--text-color, #2d4038);
}

#preview .article-version-history h2,
#preview .article-related h2 {
  font-size: 1.15rem;
  font-weight: 700;
  margin: 0 0 0.65rem;
}

#preview .article-version-history ul,
#preview .article-related ul {
  margin: 0;
  padding-left: 1.25rem;
}

#preview .article-version-history li,
#preview .article-related li {
  margin: 0.2rem 0;
}

#preview .article-related a {
  color: var(--accent-color, #006b56);
  text-decoration: underline;
  text-underline-offset: 2px;
}

/* エディタプレビュー: 記事末尾の自動フッター（編集不可・本文同期の対象外） */
#preview .preview-article-footer {
  cursor: default;
  user-select: text;
}

#preview .preview-youtube-embed-meta {
  display: block;
  padding: 0.85rem 1rem 1rem;
  font-family: var(--font-ui);
  font-size: 0.95rem;
  line-height: 1.5;
  color: rgba(255, 255, 255, 0.88);
  background:
    linear-gradient(180deg, rgba(255, 255, 255, 0.06), rgba(255, 255, 255, 0.02)),
    #111;
  overflow-wrap: anywhere;
}

#preview .preview-youtube-embed-meta a {
  color: inherit;
  text-decoration: underline;
  text-underline-offset: 0.18em;
}

#preview .preview-youtube-embed-meta a:hover,
#preview .preview-youtube-embed-meta a:focus-visible {
  color: #fff;
}

#preview .preview-youtube-embed.preview-youtube-selected {
  outline: 3px solid var(--accent-color, #006b56);
  outline-offset: 4px;
  box-shadow: 0 0 0 6px
    color-mix(in srgb, var(--accent-color, #006b56) 14%, transparent);
  cursor: pointer;
}

#preview img[data-md-image-index].body-image-drop-active {
  outline: 3px dashed var(--accent-color, #006b56);
  outline-offset: 4px;
  cursor: copy;
  box-shadow: 0 0 0 6px color-mix(in srgb, var(--accent-color, #006b56) 18%, transparent);
}

/* 本文スタイル */
#preview .prose-content {
  line-height: var(--text-line-height);
}

/* 記事内ローカル動画（Markdown の ![](*.webm) から生成） */
.prose-content video {
  max-width: 100%;
  height: auto;
}

/* 本文見出し（.prose-content 内のみ。設定の CSS 変数が確実に効くよう具体化） */
#preview .prose-content h2 {
  font-family: var(--font-heading);
  font-size: var(--h2-size);
  font-weight: 700;
  color: #1b1c1c;
  border-left: var(--h2-accent-width) var(--h2-accent-style) var(--accent-color);
  padding-left: var(--h2-accent-padding);
  margin-top: var(--h2-margin-top);
  margin-bottom: var(--h2-margin-bottom);
}

#preview .prose-content h3 {
  font-family: var(--font-heading);
  font-size: var(--h3-size);
  font-weight: 700;
  color: #1b1c1c;
  margin-top: var(--h3-margin-top);
  margin-bottom: var(--h3-margin-bottom);
}

#preview .prose-content h4 {
  font-family: var(--font-heading);
  font-size: var(--h4-size);
  font-weight: 700;
  color: #1b1c1c;
  margin-top: var(--h4-margin-top);
  margin-bottom: var(--h4-margin-bottom);
}

#preview .prose-content h5 {
  font-family: var(--font-heading);
  font-size: var(--h5-size);
  font-weight: 700;
  color: #1b1c1c;
  margin-top: var(--h5-margin-top);
  margin-bottom: var(--h5-margin-bottom);
}

#preview .prose-content h6 {
  font-family: var(--font-heading);
  font-size: var(--h6-size);
  font-weight: 700;
  color: #1b1c1c;
  margin-top: var(--h6-margin-top);
  margin-bottom: var(--h6-margin-bottom);
}

#preview p {
  font-size: var(--text-font-size) !important;
  line-height: var(--text-line-height) !important;
  color: #3d4a45;
  margin-top: 0;
  margin-bottom: var(--paragraph-spacing);
}

#preview a {
  color: var(--accent-color);
  font-weight: 500;
  text-decoration: none;
  border-bottom: 1px solid transparent;
  transition: border-color 0.2s;
}

#preview a:hover {
  border-bottom-color: var(--accent-color);
}

/* 引用ブロック */
#preview blockquote {
  position: relative;
  padding: 2.5rem 2rem;
  background: color-mix(in srgb, var(--accent-color) 8%, transparent);
  border-left: 8px solid var(--accent-color);
  border-radius: 0 1rem 1rem 0;
  margin-top: 0;
  margin-bottom: var(--section-spacing);
  /* UA 既定の左右マージンを打ち消し、本文と同じ左端から始める */
  margin-left: 0;
  margin-right: 0;
}

#preview blockquote.preview-blockquote::after {
  content: "note";
  position: absolute;
  top: 1rem;
  right: 1rem;
  font-family: inherit;
  font-size: 0.75rem;
  font-weight: 600;
  letter-spacing: 0.06em;
  text-transform: lowercase;
  line-height: 1;
  color: color-mix(in srgb, var(--accent-color) 45%, #3d4a45);
  pointer-events: none;
  user-select: none;
}

#preview blockquote p {
  font-size: var(--text-font-size) !important;
  line-height: var(--text-line-height) !important;
  font-style: italic;
  color: #3d4a45;
  margin: 0;
}

/* リスト（箇条書き: 行頭記号のコントラスト + ぶら下げ + 項目間／行間の差） */
/* flex + gap で項目間を一定に（隣接 margin の相殺・Tailwind space-y の片側だけ上マージンを避ける） */
#preview ul {
  list-style: none;
  padding: 0;
  margin-top: 0;
  margin-bottom: var(--paragraph-spacing);
  display: flex;
  flex-direction: column;
  gap: var(--list-item-gap);
}

#preview ul ul {
  margin: 0.35rem 0 0.35rem 0;
  padding-left: var(--nested-indent);
  border-left: var(--nested-border-width) solid
    color-mix(in srgb, var(--accent-color) 18%, transparent);
  gap: var(--list-nested-gap);
}

#preview ol {
  list-style: decimal;
  padding-left: 1.6rem;
  margin-top: 0;
  margin-bottom: var(--paragraph-spacing);
  display: flex;
  flex-direction: column;
  gap: var(--list-item-gap);
}

#preview ol ol {
  margin: 0.35rem 0 0.35rem 0;
  padding-left: 1.45rem;
}

/* 2行目以降は本文開始位置で揃い、● だけ左に張り出す（padding-left + 絶対配置） */
#preview ul li {
  position: relative;
  padding-left: var(--list-indent);
  margin: 0;
  line-height: var(--list-line-height);
  font-size: var(--list-font-size);
  color: #3d4a45;
}

#preview ul li > p {
  margin-top: 0;
  margin-bottom: 0.45rem;
  line-height: inherit;
}

#preview ol li {
  margin: 0;
  line-height: var(--list-line-height);
  font-size: var(--list-font-size);
  color: #3d4a45;
}

#preview ol li > p {
  margin-top: 0;
  margin-bottom: 0.45rem;
  line-height: inherit;
}

#preview ul li > p:last-child {
  margin-bottom: 0;
}

#preview ol li > p:last-child {
  margin-bottom: 0;
}

/* 主行頭記号: li 要素の縦中央（ルートの ul＝親が li でない ul 配下の li） */
#preview :not(li) > ul > li::before {
  content: var(--bullet-char-1);
  position: absolute;
  left: 0;
  top: 50%;
  transform: translateY(-50%);
  font-size: var(--bullet-size-1);
  line-height: 1;
  color: var(--accent-color);
}

/* ネスト: 中空円で階層差（項目間は ul ul の gap） */
#preview ul ul li {
  padding-left: 1.2em;
  margin: 0;
  line-height: var(--list-line-height);
}

#preview li > ul > li::before {
  content: var(--bullet-char-2);
  position: absolute;
  left: 0;
  top: 50%;
  transform: translateY(-50%);
  font-size: var(--bullet-size-2);
  line-height: 1;
  color: color-mix(in srgb, var(--accent-color) 72%, #3d4a45);
}

/* 3階層目: 小さめの角丸 */
#preview ul ul ul li {
  padding-left: 1.1em;
}

#preview li > ul > li > ul > li::before {
  content: var(--bullet-char-3);
  position: absolute;
  left: 0;
  top: 50%;
  transform: translateY(-50%);
  font-size: var(--bullet-size-3);
  line-height: 1;
  color: color-mix(in srgb, var(--accent-color) 60%, #3d4a45);
}

/* タスクリストは横線マーカーを出さない */
#preview ul li.task-list-item::before,
#preview ul li:has(> input[type="checkbox"])::before {
  display: none;
}

#preview ul li.task-list-item,
#preview ul li:has(> input[type="checkbox"]) {
  padding-left: 0.35rem;
}

/* テーブル（GFM）: 外枠 + セル縦横線 */
#preview .preview-table-wrapper {
  margin-top: 0;
  margin-bottom: var(--section-spacing);
  border: 1px solid #bccac3;
  border-radius: 0.5rem;
  overflow: auto;
  box-shadow: 0 1px 3px rgba(27, 28, 28, 0.06);
  background: #fff;
}

#preview table,
#preview table.preview-table {
  width: 100%;
  margin-top: 0;
  margin-bottom: var(--section-spacing);
  border-collapse: collapse;
  font-size: 0.875rem;
  border: 1px solid #bccac3;
  border-radius: 0.5rem;
  overflow: hidden;
  box-shadow: 0 1px 3px rgba(27, 28, 28, 0.06);
  background: #fff;
}

#preview .preview-table-wrapper table,
#preview .preview-table-wrapper table.preview-table {
  margin: 0;
  border: none;
  border-radius: 0;
  box-shadow: none;
}

#preview thead {
  background: #f0eded;
}

#preview th,
#preview td {
  padding: 0.85rem 1rem;
  text-align: left;
  border-right: 1px solid rgba(188, 202, 195, 0.95);
  border-bottom: 1px solid rgba(188, 202, 195, 0.95);
}

#preview th:last-child,
#preview td:last-child {
  border-right: none;
}

#preview tbody tr:last-child td {
  border-bottom: none;
}

#preview thead tr:last-child th {
  border-bottom: 1px solid rgba(188, 202, 195, 0.95);
}

#preview th {
  font-weight: 700;
  color: #1b1c1c;
}

#preview td:first-child {
  color: var(--accent-color);
  font-weight: 600;
}

/* コードブロック */
#preview [data-md-code-block] {
  margin-top: 0;
  margin-bottom: var(--section-spacing);
}

#preview .preview-code-block-header {
  display: flex;
  align-items: center;
  justify-content: flex-start;
  padding: 0.6rem 0.9rem;
  background: #17202d;
  border: 1px solid rgba(148, 163, 184, 0.25);
  border-bottom: none;
  border-radius: 0.75rem 0.75rem 0 0;
}

#preview .preview-code-block-language {
  width: min(100%, 7rem);
  padding: 0.24rem 0.65rem;
  border: 1px solid rgba(148, 163, 184, 0.35);
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.08);
  color: #e5edf8;
  font-family: var(--font-code);
  font-size: 0.72rem;
  line-height: 1.3;
  outline: none;
}

#preview .preview-code-block-language::placeholder {
  color: rgba(229, 237, 248, 0.58);
}

#preview .preview-code-block-language:disabled {
  opacity: 0.65;
  cursor: default;
}

#preview pre,
#preview pre.preview-fenced-pre {
  margin-top: 0;
  margin-bottom: var(--section-spacing);
  padding: 1.25rem;
  background: #1f2937;
  color: #f9fafb;
  border-radius: 0.75rem;
  overflow: auto;
  font-family: var(--font-code);
  font-size: 0.875rem;
  line-height: 1.7;
}

#preview [data-md-code-block] pre.preview-fenced-pre {
  margin-bottom: 0;
  border-top-left-radius: 0;
  border-top-right-radius: 0;
}

#preview code.preview-inline-code {
  padding: 0.2rem 0.5rem;
  background: rgba(0, 0, 0, 0.05);
  color: #1f2937;
  border-radius: 0.375rem;
  font-family: var(--font-code);
  font-size: 0.9em;
}

#preview pre code,
#preview pre code.preview-fenced-code {
  padding: 0;
  background: none;
  color: inherit;
  font-size: inherit;
  border-radius: 0;
}

#preview [data-md-code-content][contenteditable] {
  outline: none;
}

/* 画像 */
#preview img {
  max-width: 100%;
  height: auto;
  border-radius: 0.75rem;
  display: block;
  margin-top: 0;
  margin-bottom: 2rem;
  margin-left: auto;
  margin-right: auto;
}

#preview .preview-body img[data-md-image-index] {
  box-shadow: 0 0 0 1px rgba(107, 114, 128, 0.18);
}

/* 区切り線 */
#preview hr {
  margin-top: 0;
  margin-bottom: 3rem;
  border: none;
  height: 1px;
  background: linear-gradient(90deg, transparent, #bccac3, transparent);
}

/* エラー表示 */
.preview-error {
  color: #b42318;
  font-size: 0.95rem;
  padding: 1rem;
}

/* スクロールバースタイル */
#preview::-webkit-scrollbar {
  width: 8px;
}

#preview::-webkit-scrollbar-track {
  background: #f0eded;
}

#preview::-webkit-scrollbar-thumb {
  background: #bccac3;
  border-radius: 4px;
}

#preview::-webkit-scrollbar-thumb:hover {
  background: #6d7a74;
}

/* --- Editor: メイン横の右スライドドロワー --- */
/* width のみをアニメーション（transform は使わない）でガタつきを防ぐ。
   min-width は常に 0 で固定し、閉じた状態では width=0 でレイアウト上も消える */
#insert-backdrop.settings-drawer {
  --settings-drawer-width: min(360px, 42vw);
  order: 2;
  flex-shrink: 0;
  box-sizing: border-box;
  width: 0;
  min-width: 0;
  overflow: hidden;
  display: flex;
  flex-direction: column;
  background: var(--ui-bg-surface);
  border-left: 1px solid transparent;
  transition: width 0.25s ease, border-color 0.25s ease;
  z-index: 1;
}

#insert-backdrop.settings-drawer.is-open {
  width: var(--settings-drawer-width);
  border-left-color: var(--ui-border);
}

#insert-panel {
  box-sizing: border-box;
  width: var(--settings-drawer-width);
  flex: 1 1 auto;
  min-height: 0;
  display: flex;
  flex-direction: column;
  background: var(--ui-bg-surface);
  border: none;
  border-radius: 0;
  box-shadow: none;
  padding: 0;
  color: var(--ui-text-primary);
}

#insert-scroll {
  flex: 1 1 auto;
  min-height: 0;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: var(--ui-gap-section);
  padding: var(--ui-pad-surface-y) var(--ui-pad-surface-x) var(--ui-pad-surface-x);
}

#insert-fields {
  display: flex;
  flex-direction: column;
  gap: var(--ui-gap-section);
}

.editor-state-actions,
.editor-frontmatter-section {
  display: flex;
  flex-direction: column;
  gap: var(--ui-gap-editor-controls);
  margin-bottom: 0;
  padding-bottom: 0;
  border-bottom: none;
}

.editor-state-actions {
  width: 100%;
}

.editor-state-actions-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: var(--ui-gap-editor-controls);
  width: 100%;
}

.editor-state-actions-grid > button {
  width: 100%;
  min-width: 0;
  font-size: 0.8rem;
}

.editor-state-actions-grid #btn-save {
  grid-column: 1 / -1;
}

.editor-state-actions-grid #btn-new-draft-article {
  grid-column: 1;
}

.editor-state-actions-grid #btn-view-toggle {
  grid-column: 2;
  font-size: 0.82rem;
}

.editor-state-actions-grid #btn-toggle-publish-draft {
  grid-column: 1;
}

.editor-state-actions-grid #btn-delete-article {
  grid-column: 2;
}

.editor-frontmatter-section.is-disabled {
  opacity: 0.6;
}

.insert-section {
  display: flex;
  flex-direction: column;
  gap: var(--ui-gap-button);
}

.settings-section-title {
  margin: 0 0 var(--ui-gap-button) 0;
  font-size: 0.74rem;
  font-weight: 700;
  letter-spacing: 0.05em;
  text-transform: uppercase;
  color: var(--ui-text-muted);
}

.insert-action-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 0.35rem;
}

.insert-action-card {
  width: 100%;
  min-height: 2.3rem;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 0.42rem;
  border-radius: 8px;
  color: var(--ui-text-primary);
  text-align: center;
}

.insert-action-title {
  font-size: 0.86rem;
  font-weight: 600;
  color: #f4f8ff;
}

.insert-action-description {
  font-size: 0.74rem;
  line-height: 1.45;
  color: var(--ui-text-secondary);
}

.insert-action-icon {
  font-size: 1.1rem;
  line-height: 1;
}

.insert-link-form {
  display: grid;
  gap: var(--ui-gap-button);
  padding: var(--ui-pad-surface-y);
  border: 1px solid var(--ui-border);
  border-radius: 10px;
  background: color-mix(in srgb, var(--ui-bg-surface-elevated) 78%, transparent);
}

.insert-link-field {
  display: grid;
  gap: var(--ui-gap-field);
}

.insert-link-field label {
  font-size: 0.8rem;
  color: var(--ui-text-secondary);
}

.insert-link-field .ui-field {
  font-size: 0.84rem;
}

.insert-link-field .ui-field:disabled {
  opacity: 0.6;
  cursor: default;
}

.insert-link-submit {
  justify-self: flex-start;
  font-size: 0.82rem;
  margin-top: var(--ui-gap-button);
}

#frontmatter-fields {
  display: flex;
  flex-direction: column;
  gap: calc(var(--ui-gap-button) * 2);
}

.frontmatter-row {
  display: flex;
  flex-direction: column;
  gap: var(--ui-gap-field);
}

.frontmatter-row label {
  font-size: 0.85rem;
  color: var(--ui-text-secondary);
}

.frontmatter-row .ui-field {
  font-size: 0.85rem;
  font-family: inherit;
}

.frontmatter-row textarea.ui-field {
  min-height: 6rem;
  resize: vertical;
  line-height: 1.5;
}

.settings-check {
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
  cursor: pointer;
  font-size: 0.85rem;
  color: var(--ui-text-secondary);
}

.settings-check input {
  accent-color: var(--ui-bg-success);
}

.frontmatter-help {
  margin: 0;
  font-size: 0.76rem;
  color: var(--ui-text-muted);
  line-height: 1.45;
}

.frontmatter-image-actions {
  display: flex;
  gap: 0.5rem;
  align-items: center;
}

.frontmatter-image-actions button {
  padding: 0.4rem 0.75rem;
  font-size: 0.8rem;
}

/* Material Symbols アイコン（CDNフォールバック） */
.material-symbols-outlined {
  font-family: 'Material Symbols Outlined', sans-serif;
  font-variation-settings: 'FILL' 0, 'wght' 400, 'GRAD' 0, 'opsz' 24;
  font-size: 1.25em;
  vertical-align: middle;
}

html,
body {
  min-height: 100%;
  height: auto;
  overflow: auto;
  background: #fafaf2;
  color: #1a1c18;
}

body.mdrw-export-page {
  margin: 0;
  /* テーマの CSS 変数は body のインライン style で定義され、子（#preview-wrap 含む）へ継承 */
}

body.mdrw-export-page #preview-wrap {
  position: relative;
  inset: auto;
  min-height: 100vh;
  overflow: visible;
  background: #fafaf2;
}

body.mdrw-export-page #preview-scroll {
  min-height: 100vh;
  overflow: visible;
  scrollbar-gutter: auto;
}

body.mdrw-export-page #preview-wrap #preview {
  padding-top: 0;
}

body.mdrw-export-page #preview-wrap .preview-shell-header {
  position: sticky;
  top: 0;
}

body.mdrw-export-page #preview-wrap .preview-shell-footer {
  margin-top: auto;
}

/* 書き出し: ビューポート右下に固定（プレビュー列とは別レイアウト） */
body.mdrw-export-page .mdrw-back-to-top {
  position: fixed;
  right: 0.75rem;
  bottom: 1rem;
  z-index: 60;
}
