:root {
  --bg: #ffffff;
  --surface: #ffffff;
  --surface-alt: #f3f4f6;
  --text: rgba(0, 0, 0, 0.86);
  --text-strong: #111111;
  --muted: #79828b;
  --placeholder: rgba(0, 0, 0, 0.28);
  --border: rgba(0, 0, 0, 0.1);
  --border-strong: rgba(0, 0, 0, 0.22);
  --accent: #111111;
  --accent-text: #ffffff;
  --highlight: #fff3a3;
  --code-bg: #f4f5f6;
  --quote-border: rgba(0, 0, 0, 0.8);
  --menu-shadow: 0 14px 40px rgba(0, 0, 0, 0.14), 0 2px 10px rgba(0, 0, 0, 0.06);
  --font-sans: "Segoe UI", -apple-system, BlinkMacSystemFont, Roboto, "Helvetica Neue", Arial, sans-serif;
  --font-serif: "Sitka Text", Cambria, "Palatino Linotype", "Times New Roman", serif;
  --font-mono: Consolas, "Courier New", monospace;
  --body-font: var(--font-serif);
  --line-height: 1.35;
  --para-gap: 4px;
}

html[data-font="sans"] {
  --body-font: var(--font-sans);
}

html[data-font="mono"] {
  --body-font: var(--font-mono);
}

html[data-theme="sepia"] {
  --bg: #f8f3e8;
  --surface: #fbf7ee;
  --surface-alt: #ede5d4;
  --text: #2c241b;
  --text-strong: #1f1810;
  --muted: #7a6f62;
  --placeholder: rgba(44, 36, 27, 0.34);
  --border: rgba(44, 36, 27, 0.12);
  --border-strong: rgba(44, 36, 27, 0.28);
  --accent: #2c241b;
  --accent-text: #fbf7ee;
  --highlight: #f4dc7a;
  --code-bg: #eee5d3;
  --quote-border: #2c241b;
}

html[data-theme="dark"] {
  --bg: #141517;
  --surface: #1d1f23;
  --surface-alt: #282b31;
  --text: rgba(255, 255, 255, 0.86);
  --text-strong: #f4f5f7;
  --muted: #8b949e;
  --placeholder: rgba(255, 255, 255, 0.28);
  --border: rgba(255, 255, 255, 0.11);
  --border-strong: rgba(255, 255, 255, 0.26);
  --accent: #f4f5f7;
  --accent-text: #141517;
  --highlight: rgba(250, 204, 21, 0.28);
  --code-bg: #22252a;
  --quote-border: rgba(255, 255, 255, 0.72);
  --menu-shadow: 0 18px 46px rgba(0, 0, 0, 0.56), 0 2px 10px rgba(0, 0, 0, 0.34);
}

*,
*::before,
*::after {
  box-sizing: border-box;
}

html,
body {
  margin: 0;
  padding: 0;
  background: var(--bg);
  color: var(--text);
  font-family: var(--font-sans);
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  min-height: 100vh;
  transition: background-color 0.18s ease, color 0.18s ease;
}

.hidden {
  display: none !important;
}

/* Borderless Windows Desktop Drag, Resize & Subtle Corner Overlay */
.window-drag-strip,
.win-resize-zone,
.window-controls {
  display: none;
}

html.is-windows-app .window-drag-strip {
  display: block;
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  height: 36px;
  z-index: 40;
  -webkit-app-region: no-drag;
}

html.is-windows-app .window-controls {
  display: inline-flex;
  position: fixed;
  top: 10px;
  right: 12px;
  z-index: 55;
  align-items: center;
  gap: 2px;
  padding: 2px;
  border-radius: 999px;
  border: 1px solid transparent;
  background: transparent;
  opacity: 0.22;
  transition: opacity 0.18s ease, background-color 0.18s ease, border-color 0.18s ease, box-shadow 0.18s ease;
}

html.is-windows-app .window-controls:hover {
  opacity: 1;
  background: var(--surface);
  border-color: var(--border);
  box-shadow: 0 2px 10px rgba(0, 0, 0, 0.08);
}

.win-ctrl-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 26px;
  height: 26px;
  padding: 0;
  border: none;
  border-radius: 999px;
  background: transparent;
  color: var(--muted);
  cursor: pointer;
  transition: background-color 0.14s ease, color 0.14s ease;
}

.win-ctrl-btn:hover {
  background: var(--surface-alt);
  color: var(--text-strong);
}

.win-ctrl-btn.win-close:hover {
  background: rgba(220, 38, 38, 0.14);
  color: #dc2626;
}

html.is-windows-app:not(.is-maximized) .win-resize-zone {
  display: block;
  position: fixed;
  z-index: 65;
}

.win-n  { top: 0; left: 8px; right: 8px; height: 5px; cursor: ns-resize; }
.win-s  { bottom: 0; left: 8px; right: 8px; height: 5px; cursor: ns-resize; }
.win-w  { left: 0; top: 8px; bottom: 8px; width: 5px; cursor: ew-resize; }
.win-e  { right: 0; top: 8px; bottom: 8px; width: 5px; cursor: ew-resize; }
.win-nw { top: 0; left: 0; width: 9px; height: 9px; cursor: nwse-resize; }
.win-ne { top: 0; right: 0; width: 9px; height: 9px; cursor: nesw-resize; }
.win-sw { bottom: 0; left: 0; width: 9px; height: 9px; cursor: nesw-resize; }
.win-se { bottom: 0; right: 0; width: 9px; height: 9px; cursor: nwse-resize; }

/* Whisper-quiet top toolbar */
.whisper-bar {
  position: fixed;
  top: 10px;
  left: 14px;
  z-index: 45;
  display: inline-flex;
  align-items: center;
  gap: 2px;
  max-width: calc(100vw - 130px);
  padding: 3px 6px;
  border-radius: 999px;
  border: 1px solid transparent;
  background: transparent;
  opacity: 0.22;
  transition: opacity 0.18s ease, background-color 0.18s ease, border-color 0.18s ease, box-shadow 0.18s ease;
}

.whisper-bar:hover,
.whisper-bar:focus-within {
  opacity: 1;
  background: var(--surface);
  box-shadow: 0 2px 12px rgba(0, 0, 0, 0.08);
  border-color: var(--border);
}

.whisper-icon-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 28px;
  height: 28px;
  padding: 0;
  border: none;
  border-radius: 999px;
  background: transparent;
  color: var(--muted);
  cursor: pointer;
  transition: background-color 0.14s ease, color 0.14s ease, opacity 0.14s ease;
}

.whisper-icon-btn:hover:not(:disabled),
.whisper-icon-btn:focus-visible:not(:disabled) {
  background: var(--surface-alt);
  color: var(--text-strong);
  outline: none;
}

.whisper-icon-btn:disabled {
  opacity: 0.32;
  cursor: default;
}

.whisper-divider {
  width: 1px;
  height: 14px;
  background: var(--border);
  margin: 0 3px;
}

.file-status-pill {
  padding: 2px 8px;
  font-size: 11.5px;
  color: var(--muted);
  max-width: 180px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  user-select: none;
}

/* Notes Drawer */
.drawer-backdrop {
  position: fixed;
  inset: 0;
  z-index: 90;
  background: rgba(0, 0, 0, 0.18);
  backdrop-filter: blur(1px);
}

.notes-drawer {
  position: fixed;
  top: 0;
  left: 0;
  bottom: 0;
  z-index: 100;
  width: 300px;
  max-width: 86vw;
  background: var(--surface);
  border-right: 1px solid var(--border);
  box-shadow: var(--menu-shadow);
  display: flex;
  flex-direction: column;
  transform: translateX(-104%);
  transition: transform 0.22s cubic-bezier(0.22, 1, 0.36, 1);
}

.notes-drawer.open {
  transform: translateX(0);
}

.drawer-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 18px 18px 14px;
  border-bottom: 1px solid var(--border);
}

.drawer-title {
  font-size: 14px;
  font-weight: 700;
  letter-spacing: 0.02em;
  color: var(--text-strong);
}

.drawer-new-btn {
  border: 1px solid var(--border-strong);
  background: transparent;
  color: var(--text-strong);
  font-size: 12px;
  font-weight: 600;
  padding: 5px 12px;
  border-radius: 999px;
  cursor: pointer;
}

.drawer-new-btn:hover {
  background: var(--accent);
  color: var(--accent-text);
  border-color: var(--accent);
}

.notes-list {
  list-style: none;
  margin: 0;
  padding: 8px;
  overflow-y: auto;
  flex: 1;
}

.notes-list-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  padding: 10px 12px;
  border-radius: 10px;
  cursor: pointer;
  transition: background-color 0.14s ease;
}

.notes-list-item:hover {
  background: var(--surface-alt);
}

.notes-list-item.active {
  background: var(--surface-alt);
  box-shadow: inset 2px 0 0 var(--accent);
}

.notes-list-main {
  min-width: 0;
  flex: 1;
}

.notes-list-title {
  font-size: 14px;
  font-weight: 600;
  color: var(--text-strong);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.notes-list-meta {
  font-size: 12px;
  color: var(--muted);
  margin-top: 2px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.notes-delete-btn {
  border: none;
  background: transparent;
  color: var(--muted);
  font-size: 16px;
  line-height: 1;
  width: 24px;
  height: 24px;
  border-radius: 6px;
  cursor: pointer;
  opacity: 0;
  transition: opacity 0.14s ease, background-color 0.14s ease, color 0.14s ease;
}

.notes-list-item:hover .notes-delete-btn,
.notes-list-item.active .notes-delete-btn {
  opacity: 1;
}

.notes-delete-btn:hover {
  background: rgba(220, 38, 38, 0.12);
  color: #dc2626;
}

.drawer-footer {
  padding: 12px 18px;
  border-top: 1px solid var(--border);
}

.drawer-hint {
  font-size: 12px;
  line-height: 1.45;
  color: var(--muted);
}

/* Main Graph.org Paper Canvas with Width Modes */
.paper {
  max-width: 800px;
  margin: 0 auto;
  padding: 62px 30px 140px;
  transition: max-width 0.2s ease, padding 0.2s ease;
}

html[data-width="wide"] .paper {
  max-width: 1140px;
  padding: 62px 40px 140px;
}

html[data-width="full"] .paper {
  max-width: 100%;
  width: 100%;
  margin: 0;
  padding: 62px 56px 140px;
}

.article-header {
  position: relative;
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 20px;
  margin-bottom: 26px;
}

.header-col {
  flex: 1;
  min-width: 0;
}

#note-title {
  margin: 0 0 10px;
  font-family: var(--font-sans);
  font-size: 32px;
  font-weight: 700;
  line-height: 1.2;
  letter-spacing: -0.02em;
  color: var(--text-strong);
  outline: none;
  word-break: break-word;
}

.article-meta {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px;
  font-family: var(--font-sans);
  font-size: 15px;
  line-height: 1.45;
  color: var(--muted);
}

#note-author {
  outline: none;
  min-width: 48px;
}

.meta-sep,
.meta-date {
  color: var(--muted);
  user-select: none;
}

/* Publish & Export Pill inside Whisper Bar */
.pill-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  height: 24px;
  padding: 0 11px;
  margin-left: 2px;
  border: 1.4px solid var(--border-strong);
  border-radius: 999px;
  background: transparent;
  color: var(--text-strong);
  font-family: var(--font-sans);
  font-size: 10.5px;
  font-weight: 700;
  letter-spacing: 0.07em;
  text-transform: uppercase;
  cursor: pointer;
  white-space: nowrap;
  transition: background-color 0.16s ease, border-color 0.16s ease, color 0.16s ease, transform 0.1s ease;
}

.pill-btn:hover {
  background: var(--accent);
  border-color: var(--accent);
  color: var(--accent-text);
}

.pill-btn:active {
  transform: scale(0.97);
}

.pill-btn.is-published {
  background: var(--accent);
  border-color: var(--accent);
  color: var(--accent-text);
}

.rail-sub-btn {
  border: none;
  border-radius: 999px;
  background: transparent;
  color: var(--muted);
  font-family: var(--font-sans);
  font-size: 11.5px;
  font-weight: 500;
  height: 24px;
  padding: 0 8px;
  cursor: pointer;
  white-space: nowrap;
}

.rail-sub-btn:hover {
  background: var(--surface-alt);
  color: var(--text-strong);
}

/* Placeholders */
[data-placeholder]:empty::before {
  content: attr(data-placeholder);
  color: var(--placeholder);
  pointer-events: none;
}

.article-body {
  position: relative;
  min-height: 62vh;
  font-family: var(--body-font);
  font-size: 19px;
  line-height: var(--line-height);
  color: var(--text);
  outline: none;
  word-wrap: break-word;
}

.article-body.is-empty::before {
  content: attr(data-placeholder);
  position: absolute;
  top: 0;
  left: 0;
  color: var(--placeholder);
  pointer-events: none;
  font-family: var(--body-font);
  font-size: 19px;
  line-height: var(--line-height);
}

body.read-mode #note-title,
body.read-mode #note-author,
body.read-mode .article-body,
body.read-mode figcaption {
  cursor: default;
}

body.read-mode [data-placeholder]:empty::before,
body.read-mode .article-body.is-empty::before {
  content: "";
}

/* Editorial Typography Inside Editor */
.article-body > *:first-child {
  margin-top: 0;
}

.article-body p {
  margin: 0 0 var(--para-gap);
}

.article-body h1,
.article-body h2,
.article-body h3 {
  font-family: var(--font-sans);
  font-weight: 700;
  color: var(--text-strong);
  letter-spacing: -0.015em;
  margin: 30px 0 12px;
  line-height: 1.25;
}

.article-body h1 { font-size: 28px; }
.article-body h2 { font-size: 23px; }
.article-body h3 { font-size: 19px; }

.article-body a {
  color: inherit;
  text-decoration: underline;
  text-decoration-thickness: 1.5px;
  text-underline-offset: 3px;
}

.article-body mark {
  background: var(--highlight);
  color: inherit;
  padding: 0 3px;
  border-radius: 3px;
}

.article-body code {
  font-family: var(--font-mono);
  font-size: 0.85em;
  background: var(--code-bg);
  padding: 2px 5px;
  border-radius: 4px;
}

.article-body pre {
  margin: 22px 0;
  padding: 16px 18px;
  background: var(--code-bg);
  border-radius: 8px;
  overflow-x: auto;
  font-family: var(--font-mono);
  font-size: 14.5px;
  line-height: 1.58;
  color: var(--text-strong);
  white-space: pre-wrap;
}

.article-body pre code {
  background: transparent;
  padding: 0;
  font-size: inherit;
}

.article-body blockquote {
  margin: 22px 0;
  padding: 2px 0 2px 18px;
  border-left: 3px solid var(--quote-border);
  font-style: italic;
  color: var(--text);
}

.article-body blockquote.pullquote {
  margin: 30px auto;
  padding: 8px 20px;
  border-left: none;
  text-align: center;
  font-size: 23px;
  line-height: 1.48;
  font-style: italic;
  color: var(--text-strong);
  max-width: 90%;
}

.article-body ul,
.article-body ol {
  margin: 0 0 calc(var(--para-gap) + 6px);
  padding-left: 26px;
}

.article-body li {
  margin-bottom: var(--para-gap);
}

/* Interactive Checklist */
.article-body ul.checklist {
  list-style: none;
  padding-left: 4px;
}

.article-body ul.checklist li {
  position: relative;
  padding-left: 30px;
  margin-bottom: var(--para-gap);
}

.article-body ul.checklist li::before {
  content: "";
  position: absolute;
  left: 0;
  top: 6px;
  width: 17px;
  height: 17px;
  border: 1.6px solid var(--border-strong);
  border-radius: 4px;
  background: var(--surface);
  cursor: pointer;
  transition: background-color 0.14s ease, border-color 0.14s ease;
}

.article-body ul.checklist li[data-checked="true"]::before {
  background: var(--accent);
  border-color: var(--accent);
}

.article-body ul.checklist li[data-checked="true"]::after {
  content: "";
  position: absolute;
  left: 6px;
  top: 9px;
  width: 5px;
  height: 9px;
  border: solid var(--accent-text);
  border-width: 0 2px 2px 0;
  transform: rotate(45deg);
  pointer-events: none;
}

.article-body ul.checklist li[data-checked="true"] {
  color: var(--muted);
  text-decoration: line-through;
}

/* Telegraph-style • • • Divider */
.article-body hr {
  border: none;
  text-align: center;
  margin: 34px 0;
  height: 24px;
  line-height: 24px;
  user-select: none;
}

.article-body hr::before {
  content: "• • •";
  letter-spacing: 0.7em;
  color: var(--muted);
  font-size: 14px;
}

/* Embedded Multimedia Figures */
.article-body figure.media-block {
  margin: 26px auto;
  padding: 0;
  position: relative;
  border-radius: 8px;
  transition: width 0.2s ease, margin 0.2s ease, box-shadow 0.15s ease;
}

.article-body figure.media-block.is-selected {
  outline: 2px solid var(--accent);
  outline-offset: 4px;
}

html[data-width="centered"] .article-body figure.media-block[data-size="wide"] {
  width: calc(100% + 140px);
  max-width: calc(100vw - 40px);
  margin-left: 50%;
  transform: translateX(-50%);
}

html[data-width="wide"] .article-body figure.media-block[data-size="wide"],
html[data-width="full"] .article-body figure.media-block[data-size="wide"] {
  width: 100%;
  margin-left: 0;
  transform: none;
}

.article-body figure.media-block img,
.article-body figure.media-block video {
  display: block;
  width: 100%;
  max-height: 78vh;
  object-fit: contain;
  border-radius: 6px;
  background: rgba(0, 0, 0, 0.04);
}

.article-body figure.media-block .embed-frame-wrap {
  position: relative;
  width: 100%;
  padding-top: 56.25%;
  border-radius: 8px;
  overflow: hidden;
  background: #000;
}

.article-body figure.media-block .embed-frame-wrap iframe {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  border: 0;
}

.article-body figure.media-block .audio-card {
  display: flex;
  flex-direction: column;
  gap: 8px;
  padding: 14px 16px;
  border: 1px solid var(--border);
  border-radius: 10px;
  background: var(--surface-alt);
}

.article-body figure.media-block .audio-name {
  font-family: var(--font-sans);
  font-size: 13px;
  font-weight: 600;
  color: var(--text-strong);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.article-body figure.media-block audio {
  width: 100%;
  height: 38px;
}

.article-body figure.media-block figcaption {
  margin-top: 9px;
  text-align: center;
  font-family: var(--font-sans);
  font-size: 14px;
  line-height: 1.45;
  color: var(--muted);
  outline: none;
  min-height: 1.2em;
}

body.read-mode .article-body figure.media-block figcaption:empty {
  display: none;
}

/* Drag & Drop Overlay */
.drop-overlay {
  position: fixed;
  inset: 0;
  z-index: 150;
  background: rgba(255, 255, 255, 0.82);
  backdrop-filter: blur(4px);
  display: flex;
  align-items: center;
  justify-content: center;
  pointer-events: none;
}

html[data-theme="dark"] .drop-overlay {
  background: rgba(20, 21, 23, 0.84);
}

.drop-box {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 10px;
  padding: 36px 48px;
  border: 2px dashed var(--border-strong);
  border-radius: 16px;
  background: var(--surface);
  color: var(--text-strong);
  font-family: var(--font-sans);
  font-size: 16px;
  font-weight: 600;
  box-shadow: var(--menu-shadow);
}

/* Iconified Right-Click Context Menu */
.context-menu {
  position: fixed;
  z-index: 200;
  width: 274px;
  max-height: calc(100vh - 20px);
  overflow-y: auto;
  padding: 8px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 14px;
  box-shadow: var(--menu-shadow);
  font-family: var(--font-sans);
  color: var(--text);
  user-select: none;
}

.ctx-hint-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  padding: 2px 6px 6px;
  font-size: 11.5px;
  font-weight: 600;
  color: var(--muted);
  min-height: 22px;
}

#ctx-hint {
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.ctx-hint-key {
  font-size: 10.5px;
  font-weight: 500;
  opacity: 0.8;
  flex-shrink: 0;
}

.ctx-sep {
  height: 1px;
  background: var(--border);
  margin: 6px 4px;
}

.ctx-icon-grid-8 {
  display: grid;
  grid-template-columns: repeat(8, 1fr);
  gap: 2px;
}

.ctx-icon-grid-7 {
  display: grid;
  grid-template-columns: repeat(7, 1fr);
  gap: 2px;
}

.ctx-media-bar {
  margin-top: 6px;
  padding: 3px;
  border-radius: 9px;
  background: var(--surface-alt);
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 3px;
}

.ctx-icon-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  height: 30px;
  padding: 0;
  border: none;
  border-radius: 7px;
  background: transparent;
  color: var(--text-strong);
  font-family: var(--font-sans);
  cursor: pointer;
  transition: background-color 0.12s ease, color 0.12s ease, opacity 0.12s ease;
}

.ctx-icon-btn:hover:not(:disabled) {
  background: var(--surface-alt);
}

.ctx-group .ctx-icon-btn:hover:not(:disabled) {
  background: var(--surface);
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.08);
}

.ctx-icon-btn.active {
  background: var(--accent) !important;
  color: var(--accent-text) !important;
}

.ctx-icon-btn:disabled {
  opacity: 0.28;
  cursor: default;
}

.ctx-icon-btn.ctx-danger {
  color: #dc2626;
}

.ctx-glyph-h {
  font-size: 12px;
  font-weight: 700;
  letter-spacing: -0.02em;
  line-height: 1;
}

.ctx-glyph-h sub {
  font-size: 9px;
  vertical-align: -2px;
}

.ctx-group {
  margin-top: 6px;
  padding: 4px;
  border-radius: 10px;
  background: var(--surface-alt);
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.ctx-media-duo {
  margin-top: 6px;
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 5px;
}

.ctx-pill-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  height: 30px;
  border: none;
  border-radius: 8px;
  background: var(--surface-alt);
  color: var(--text-strong);
  font-family: var(--font-sans);
  font-size: 12px;
  font-weight: 600;
  cursor: pointer;
  transition: background-color 0.12s ease;
}

.ctx-pill-btn:hover {
  filter: brightness(0.95);
}

html[data-theme="dark"] .ctx-pill-btn:hover {
  filter: brightness(1.15);
}

.ctx-url-box {
  margin-top: 6px;
  padding: 6px;
  border-radius: 9px;
  background: var(--surface-alt);
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.ctx-url-box input {
  width: 100%;
  border: 1px solid var(--border-strong);
  border-radius: 6px;
  background: var(--surface);
  color: var(--text-strong);
  padding: 6px 8px;
  font-family: var(--font-sans);
  font-size: 12.5px;
  outline: none;
}

.ctx-url-box input:focus {
  border-color: var(--accent);
}

.ctx-url-actions {
  display: flex;
  gap: 6px;
  justify-content: flex-end;
}

.ctx-mini-btn {
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--text);
  border-radius: 6px;
  padding: 4px 10px;
  font-size: 11.5px;
  font-weight: 600;
  cursor: pointer;
}

.ctx-mini-btn.primary {
  background: var(--accent);
  color: var(--accent-text);
  border-color: var(--accent);
}

.ctx-appear-list {
  display: flex;
  flex-direction: column;
  gap: 5px;
}

.ctx-control-row {
  display: flex;
  align-items: center;
  gap: 7px;
}

.ctx-row-icon {
  width: 20px;
  height: 24px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  color: var(--muted);
  flex-shrink: 0;
}

.ctx-seg-track {
  flex: 1;
  display: grid;
  gap: 2px;
  padding: 2px;
  border-radius: 8px;
  background: var(--surface-alt);
}

.ctx-seg-track.cols-4 {
  grid-template-columns: repeat(4, 1fr);
}

.ctx-seg-track.cols-3 {
  grid-template-columns: repeat(3, 1fr);
}

.flex-1 {
  flex: 1;
}

.ctx-seg-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  height: 24px;
  padding: 0 4px;
  border: none;
  border-radius: 6px;
  background: transparent;
  color: var(--muted);
  font-family: var(--font-sans);
  font-size: 11.5px;
  font-weight: 600;
  cursor: pointer;
  transition: background-color 0.12s ease, color 0.12s ease, box-shadow 0.12s ease;
}

.ctx-seg-btn:hover {
  color: var(--text-strong);
}

.ctx-seg-btn.active {
  background: var(--surface);
  color: var(--text-strong);
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.12);
}

.font-serif-sample { font-family: var(--font-serif); font-size: 12.5px; }
.font-sans-sample { font-family: var(--font-sans); font-size: 12px; }
.font-mono-sample { font-family: var(--font-mono); font-size: 12px; }

.ctx-font-theme-wrap {
  flex: 1;
  display: flex;
  align-items: center;
  gap: 8px;
}

.ctx-theme-pills {
  display: flex;
  align-items: center;
  gap: 6px;
  flex-shrink: 0;
}

.ctx-theme-dot {
  width: 18px;
  height: 18px;
  border-radius: 50%;
  border: 1.5px solid var(--border-strong);
  cursor: pointer;
  padding: 0;
}

.ctx-theme-dot[data-value="light"] { background: #ffffff; }
.ctx-theme-dot[data-value="sepia"] { background: #f5ebd6; }
.ctx-theme-dot[data-value="dark"] { background: #1b1d21; }

.ctx-theme-dot.active {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

/* Publish & Export Modal */
.modal-backdrop {
  position: fixed;
  inset: 0;
  z-index: 220;
  background: rgba(0, 0, 0, 0.32);
  backdrop-filter: blur(2px);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
}

.modal-card {
  width: 100%;
  max-width: 620px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 16px;
  box-shadow: var(--menu-shadow);
  padding: 24px;
  font-family: var(--font-sans);
}

.modal-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
}

.modal-head h2 {
  margin: 0;
  font-size: 20px;
  font-weight: 700;
  color: var(--text-strong);
}

.modal-sub {
  margin: 4px 0 0;
  font-size: 13px;
  color: var(--muted);
}

.modal-close {
  border: none;
  background: transparent;
  color: var(--muted);
  font-size: 24px;
  line-height: 1;
  width: 32px;
  height: 32px;
  border-radius: 8px;
  cursor: pointer;
}

.modal-close:hover {
  background: var(--surface-alt);
  color: var(--text-strong);
}

.publish-mode-bar {
  margin-top: 16px;
  padding: 11px 14px;
  border: 1px solid var(--border);
  border-radius: 10px;
  background: var(--surface-alt);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  font-size: 13.5px;
  color: var(--text-strong);
}

.mode-toggle-btn {
  border: 1px solid var(--border-strong);
  background: var(--surface);
  color: var(--text-strong);
  border-radius: 999px;
  padding: 5px 14px;
  font-size: 12.5px;
  font-weight: 600;
  cursor: pointer;
}

.mode-toggle-btn:hover {
  background: var(--accent);
  color: var(--accent-text);
  border-color: var(--accent);
}

.export-grid {
  margin-top: 16px;
  display: grid;
  grid-template-columns: 1fr;
  gap: 12px;
}

.export-card {
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 14px 16px;
  background: var(--surface);
}

.export-card.highlight-card {
  border-color: var(--border-strong);
  background: var(--surface-alt);
}

.export-card-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
}

.export-title {
  font-size: 15px;
  font-weight: 700;
  color: var(--text-strong);
}

.export-badge {
  font-size: 11.5px;
  font-weight: 600;
  padding: 2px 8px;
  border-radius: 999px;
  background: var(--surface-alt);
  border: 1px solid var(--border);
  color: var(--muted);
}

.export-desc {
  margin: 6px 0 12px;
  font-size: 13px;
  line-height: 1.5;
  color: var(--muted);
}

.export-desc code {
  font-family: var(--font-mono);
  font-size: 12px;
  background: var(--code-bg);
  padding: 1px 4px;
  border-radius: 4px;
}

.export-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.export-primary-btn {
  border: 1px solid var(--accent);
  background: var(--accent);
  color: var(--accent-text);
  border-radius: 999px;
  padding: 7px 16px;
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
}

.export-primary-btn:hover {
  opacity: 0.88;
}

.export-secondary-btn {
  border: 1px solid var(--border-strong);
  background: transparent;
  color: var(--text-strong);
  border-radius: 999px;
  padding: 7px 14px;
  font-size: 13px;
  font-weight: 500;
  cursor: pointer;
}

.export-secondary-btn:hover {
  background: var(--surface-alt);
}

/* Touch-only Floating Menu Button */
.touch-fab {
  display: none;
  position: fixed;
  right: 18px;
  bottom: 20px;
  z-index: 180;
  width: 46px;
  height: 46px;
  border-radius: 50%;
  border: 1px solid var(--border-strong);
  background: var(--accent);
  color: var(--accent-text);
  font-family: var(--font-sans);
  font-size: 20px;
  font-weight: 700;
  line-height: 1;
  align-items: center;
  justify-content: center;
  box-shadow: var(--menu-shadow);
  cursor: pointer;
  touch-action: manipulation;
  user-select: none;
  -webkit-user-select: none;
}

@media (pointer: coarse) {
  .touch-fab {
    display: inline-flex;
  }

  .whisper-bar {
    opacity: 0.9;
  }
}

/* Toast */
.toast {
  position: fixed;
  bottom: 22px;
  left: 50%;
  transform: translateX(-50%);
  z-index: 260;
  background: var(--accent);
  color: var(--accent-text);
  padding: 8px 16px;
  border-radius: 999px;
  font-family: var(--font-sans);
  font-size: 13px;
  font-weight: 500;
  box-shadow: var(--menu-shadow);
  pointer-events: none;
}

@media (max-width: 760px) {
  .paper,
  html[data-width="wide"] .paper,
  html[data-width="full"] .paper {
    padding: 64px 18px 110px;
  }

  .article-header {
    margin-bottom: 20px;
  }

  html[data-width="centered"] .article-body figure.media-block[data-size="wide"] {
    width: 100%;
    margin-left: 0;
    transform: none;
  }
}

@media print {
  .whisper-bar,
  .notes-drawer,
  .drawer-backdrop,
  .context-menu,
  .modal-backdrop,
  .drop-overlay,
  .touch-fab,
  .toast {
    display: none !important;
  }

  .paper {
    padding: 0;
  }
}
