@charset "UTF-8";

:root {
    /* --- Spacing System (8px based) --- */
    --space-unit: 8px;
    --space-3xs: calc(var(--space-unit) * 0.25);
    --space-2xs: calc(var(--space-unit) * 0.5);
    --space-xs: calc(var(--space-unit) * 1);
    --space-sm: calc(var(--space-unit) * 1.5);
    --space-md: calc(var(--space-unit) * 2);
    --space-lg: calc(var(--space-unit) * 3);
    --space-xl: calc(var(--space-unit) * 4);
    --space-2xl: calc(var(--space-unit) * 6);
    --space-3xl: calc(var(--space-unit) * 8);

    /* --- Morandi Petal Dark (Optimized Rose) --- */
    --accent: oklch(75% 0.18 350);
    --accent-rgb: 255, 170, 200;

    /* Dynamic States */
    --accent-hover: color-mix(in oklch, var(--accent), white 8%);
    --accent-active: color-mix(in oklch, var(--accent), white 15%);
    --accent-soft: color-mix(in oklch, var(--accent), transparent 82%);

    /* Semantic Colors - Muted for Morandi */
    --success: oklch(72% 0.1 150);
    --warning: oklch(78% 0.1 75);
    --error: oklch(62% 0.12 25);
    --info: oklch(65% 0.1 250);
    --important: oklch(75% 0.14 280);

    /* Neutrals - Petal Dark Base (enhanced for warmth) */
    /* Page Depth Gradient */
    --page-depth-1: oklch(30% 0.02 350);
    --page-depth-2: oklch(28% 0.02 350);

    --bg: oklch(28% 0.02 350);
    --surface: oklch(34% 0.02 350);
    --surface-2: oklch(40% 0.02 350);

    --text: oklch(98% 0.01 350);
    --text-rgb: 255, 245, 248;
    --text-semi: oklch(86% 0.02 350);
    --muted: color-mix(in oklch, var(--text), transparent 30%);

    --border: color-mix(in oklch, var(--text), transparent 88%);
    --border-semi: color-mix(in oklch, var(--text), transparent 78%);

    /* Effects */
    --shadow: 0 16px 48px color-mix(in oklch, var(--bg), black 50%);
    --shadow-lg: 0 30px 80px color-mix(in oklch, var(--bg), black 60%);

    /* Typography */
    --font-sans: "MiSans", "PingFang SC", "Microsoft YaHei", sans-serif;
    --font-mono: ui-monospace, "SF Mono", SFMono-Regular, Menlo, Monaco, Consolas, "Liberation Mono", monospace;

    /* Selection */
    --selection: color-mix(in oklch, var(--accent), transparent 65%);

    /* Code Layer */
    --code-bg: oklch(24% 0.02 350);
    --code-text: var(--text-semi);
    --code-ink: var(--text);
    --code-dot-red: oklch(65% 0.12 25);
    --code-dot-yellow: oklch(78% 0.12 85);
    --code-dot-green: oklch(72% 0.12 145);

    /* Code Token Colors */
    --code-token-keyword: oklch(82% 0.18 350);
    --code-token-string: oklch(72% 0.1 145);
    --code-token-number: oklch(75% 0.1 75);
    --code-token-blue: oklch(70% 0.1 250);
    --code-muted-rgb: 140, 140, 145;
    --ink-rgb: 228, 220, 224;

    /* Typora chrome */
    --bg-color: var(--bg);
    --side-bar-bg-color: color-mix(in oklch, var(--bg), black 5%);
    --item-hover-bg-color: var(--accent-soft);
    --item-hover-text-color: var(--text);
    --primary-color: var(--accent);
    --text-color: var(--text);
    --select-text-bg-color: var(--selection);
    --window-border: 1px solid var(--border);

    /* Icons */
    --icon-document: url("data:image/svg+xml;utf8,%3Csvg%20width%3D%2220%22%20height%3D%2220%22%20viewBox%3D%220%200%2020%2020%22%20fill%3D%22none%22%20xmlns%3D%22http%3A//www.w3.org/2000/svg%22%3E%0A%3Cpath%20d%3D%22M7.5%207C7.22386%207%207%207.22386%207%207.5C7%207.77614%207.22386%208%207.5%208H12.5C12.7761%208%2013%207.77614%2013%207.5C13%207.22386%2012.7761%207%2012.5%207H7.5Z%22%20fill%3D%22%23636566%22/%3E%0A%3Cpath%20d%3D%22M7%2010.5C7%2010.2239%207.22386%2010%207.5%2010H12.5C12.7761%2010%2013%2010.2239%2013%2010.5C13%2010.7761%2012.7761%2011%2012.5%2011H7.5C7.22386%2011%207%2010.7761%207%2010.5Z%22%20fill%3D%22%23636566%22/%3E%0A%3Cpath%20d%3D%22M7.5%2013C7.22386%2013%207%2013.2239%207%2013.5C7%2013.7761%207.22386%2014%207.5%2014H9.5C9.77614%2014%2010%2013.7761%2010%2013.5C10%2013.2239%209.77614%2013%209.5%2013H7.5Z%22%20fill%3D%22%23636566%22/%3E%0A%3Cpath%20d%3D%22M6.5%202C6.22386%202%206%202.22386%206%202.5V3H5.5C4.67157%203%204%203.67157%204%204.5V16.5C4%2017.3284%204.67157%2018%205.5%2018H11.5C11.6326%2018%2011.7598%2017.9473%2011.8536%2017.8536L15.8536%2013.8536C15.9473%2013.7598%2016%2013.6326%2016%2013.5V4.5C16%203.67157%2015.3284%203%2014.5%203H14V2.5C14%202.22386%2013.7761%202%2013.5%202C13.2239%202%2013%202.22386%2013%202.5V3H10.5V2.5C10.5%202.22386%2010.2761%202%2010%202C9.72386%202%209.5%202.22386%209.5%202.5V3H7V2.5C7%202.22386%206.77614%202%206.5%202ZM14.5%204C14.7761%204%2015%204.22386%2015%204.5V13H12.5C11.6716%2013%2011%2013.6716%2011%2014.5V17H5.5C5.22386%2017%205%2016.7761%205%2016.5V4.5C5%204.22386%205.22386%204%205.5%204H14.5ZM14.2929%2014L12%2016.2929V14.5C12%2014.2239%2012.2239%2014%2012.5%2014H14.2929Z%22%20fill%3D%22%23636566%22/%3E%0A%3C/svg%3E%0A");
    --icon-folder: url("data:image/svg+xml;utf8,%3Csvg%20width%3D%2220%22%20height%3D%2220%22%20viewBox%3D%220%200%2020%2020%22%20fill%3D%22none%22%20xmlns%3D%22http%3A//www.w3.org/2000/svg%22%3E%0A%3Cpath%20d%3D%22M7.16667%203C7.43713%203%207.70151%203.0731%207.93238%203.21016L8.06667%203.3L9.667%204.5H15.5C16.7703%204.5%2017.8192%205.44737%2017.9789%206.67409L17.9947%206.83562L18%207V14.5C18%2015.8255%2016.9685%2016.91%2015.6644%2016.9947L15.5%2017H4.5C3.17452%2017%202.08996%2015.9685%202.00532%2014.6644L2%2014.5V5.5C2%204.17452%203.03154%203.08996%204.33562%203.00532L4.5%203H7.16667ZM8.15763%207.03449C7.90991%207.2946%207.57838%207.45592%207.22435%207.49219L7.07143%207.5L3%207.499V14.5C3%2015.2797%203.59489%2015.9204%204.35554%2015.9931L4.5%2016H15.5C16.2797%2016%2016.9204%2015.4051%2016.9931%2014.6445L17%2014.5V7C17%206.2203%2016.4051%205.57955%2015.6445%205.50687L15.5%205.5H9.617L8.15763%207.03449ZM7.16667%204H4.5C3.7203%204%203.07955%204.59489%203.00687%205.35554L3%205.5V6.499L7.07143%206.5C7.1809%206.5%207.28655%206.46411%207.37274%206.39902L7.4335%206.34483L8.694%205.021L7.46667%204.1C7.40176%204.05132%207.32632%204.01941%207.24701%204.0065L7.16667%204Z%22%20fill%3D%22%23636566%22/%3E%0A%3C/svg%3E%0A");
}

@font-face {
  font-family: "MiSans";
  src: url("./bloom/fonts/MiSans-Regular.ttf") format("truetype");
  font-weight: 400;
  font-style: normal;
  font-display: swap;
}

@font-face {
  font-family: "MiSans";
  src: url("./bloom/fonts/MiSans-Medium.ttf") format("truetype");
  font-weight: 500;
  font-style: normal;
  font-display: swap;
}

@font-face {
  font-family: "MiSans";
  src: url("./bloom/fonts/MiSans-Semibold.ttf") format("truetype");
  font-weight: 600;
  font-style: normal;
  font-display: swap;
}

html,
body {
  background: radial-gradient(1200px circle at 18% 8%, rgba(var(--accent-rgb), 0.06), transparent 36%),
    linear-gradient(180deg, rgba(var(--white-rgb), 0.02), transparent 300px),
    linear-gradient(180deg, var(--page-depth-1) 0%, var(--page-depth-2) 100%),
    var(--bg);
  color: var(--text);
  font-family: var(--font-sans);
  -webkit-font-smoothing: antialiased;
}

content,
.typora-node {
  background: radial-gradient(900px circle at 0% 18%, rgba(var(--accent-rgb), 0.05), transparent 60%),
    radial-gradient(900px circle at 100% 18%, rgba(var(--accent-rgb), 0.05), transparent 60%),
    var(--bg);
}

::selection {
  background: var(--selection);
}

#write {
  max-width: 880px;
  line-height: 1.85;
  /* 略微增加行高提升可读性 */
  letter-spacing: 0.015em;
  font-size: 16px;
  color: var(--text);
  margin: 0 auto;
  padding: var(--space-2xl) var(--space-xl) var(--space-3xl);
  background: linear-gradient(180deg, var(--accent-soft), transparent 460px);
  border: 1px solid var(--border);
  border-radius: 22px;
  box-shadow: var(--shadow-lg);
}

#write> :first-child {
  margin-top: 0;
}

#write p {
  margin: 1.1em 0;
  color: var(--text);
}

#write a {
  color: var(--accent);
  text-decoration: none;
  border-bottom: 1px solid transparent;
  text-underline-offset: 3px;
  transition: color 0.2s ease, border-color 0.2s ease;
}

#write a:hover {
  color: var(--accent-hover);
  border-bottom-color: rgba(var(--accent-rgb), 0.55);
}

/* Headings */
#write h1,
#write h2,
#write h3,
#write h4,
#write h5,
#write h6 {
  color: var(--text);
  font-weight: 800;
  line-height: 1.35;
  margin: var(--space-lg) 0 var(--space-md);
  letter-spacing: -0.02em;
  position: relative;
}

#write h1 {
  font-size: 2.35em;
  border-bottom: 1px solid rgba(var(--accent-rgb), 0.32);
  padding-bottom: 0.35em;
  text-shadow: 0 10px 36px rgba(var(--black-rgb), 0.35);
}

#write h2 {
  font-size: 1.82em;
  border-bottom: 1px solid rgba(var(--accent-rgb), 0.24);
  padding-bottom: 0.3em;
  color: rgba(var(--ink-rgb), 0.92);
}

#write h3 {
  font-size: 1.36em;
  color: rgba(var(--ink-rgb), 0.88);
}

#write h4 {
  font-size: 1.18em;
  color: rgba(var(--ink-rgb), 0.82);
}

#write h1::after,
#write h2::after {
  content: "";
  position: absolute;
  left: 0;
  bottom: -0.52em;
  width: 78px;
  height: 3px;
  background: linear-gradient(90deg, rgba(var(--accent-rgb), 0.5), transparent);
  border-radius: 999px;
}

#write h3::after {
  content: "";
  position: absolute;
  left: 0;
  bottom: -0.4em;
  width: 48px;
  height: 2px;
  background: linear-gradient(90deg, rgba(var(--accent-rgb), 0.35), transparent);
  border-radius: 999px;
}

#write h4::after {
  content: "";
  position: absolute;
  left: 0;
  bottom: -0.35em;
  width: 36px;
  height: 2px;
  background: linear-gradient(90deg, rgba(var(--accent-rgb), 0.25), transparent);
  border-radius: 999px;
}

#write hr {
  border: 0;
  height: 2px;
  background: linear-gradient(90deg, transparent, var(--border-semi), transparent);
  margin: var(--space-2xl) 0;
}

/* Blockquote - Enhanced GitHub Alerts */
#write blockquote {
  margin: var(--space-lg) 0;
  padding: var(--space-lg) var(--space-xl);
  background: rgba(var(--accent-rgb), 0.12);
  border: 1px solid rgba(var(--accent-rgb), 0.18);
  border-left: 4px solid var(--accent);
  border-radius: 14px;
  color: var(--text);
  box-shadow: 0 4px 16px rgba(var(--black-rgb), 0.25);
  position: relative;
  overflow: hidden;
}

/* Decorative background icon */
#write blockquote::before {
  content: "";
  position: absolute;
  right: 16px;
  bottom: 12px;
  width: 48px;
  height: 48px;
  opacity: 0.08;
  background-size: contain;
  background-repeat: no-repeat;
  background-position: center;
  pointer-events: none;
}

#write blockquote p:first-child {
  margin-top: 0;
}

#write blockquote p:last-child {
  margin-bottom: 0;
}

/* GitHub Alerts Support */
/* Typora adds data-type attributes to blockquotes starting with [!NOTE], [!TIP], etc. */

#write blockquote[data-type^="alert-"] {
  padding: var(--space-md) var(--space-lg);
  border-radius: 12px;
  box-shadow: none;
}

#write blockquote[data-type^="alert-"]::before {
  content: none;
}

#write blockquote[data-type^="alert-"]>p:first-child,
#write blockquote[data-type^="alert-"]>p.md-alert-title {
  margin: 0 0 var(--space-xs);
  font-size: 12px;
  font-weight: 600;
  color: var(--alert-color);
  opacity: 0.75;
  text-transform: uppercase;
}

#write blockquote[data-type^="alert-"] .md-alert-icon,
#write blockquote[data-type^="alert-"] .md-alert-title-icon,
#write blockquote[data-type^="alert-"] .md-alert-icon::before,
#write blockquote[data-type^="alert-"] .md-alert-title-icon::before {
  display: none;
}

/* --- ALERTS & CALLOUTS --- */
/* Common Alert Styles */
#write blockquote[data-type] {
  border-radius: 8px;
  padding: 1em 1em 1em 1.2em;
  margin: 1.5em 0;
  border: 1px solid transparent;
  position: relative;
  transition: all 0.2s ease;
}

#write blockquote[data-type] p {
  margin: 0;
}

/* NOTE (Blue) */
#write blockquote[data-type="alert-note"] {
  --alert-color: var(--info);
  background: color-mix(in srgb, var(--alert-color), var(--bg) 88%);
  border-color: color-mix(in srgb, var(--alert-color), var(--bg) 60%);
  border-left: 4px solid var(--alert-color);
}

/* TIP (Green) */
#write blockquote[data-type="alert-tip"] {
  --alert-color: var(--success);
  background: color-mix(in srgb, var(--alert-color), var(--bg) 88%);
  border-color: color-mix(in srgb, var(--alert-color), var(--bg) 60%);
  border-left: 4px solid var(--alert-color);
}

/* WARNING (Orange) */
#write blockquote[data-type="alert-warning"] {
  --alert-color: var(--warning);
  background: color-mix(in srgb, var(--alert-color), var(--bg) 85%);
  border-color: color-mix(in srgb, var(--alert-color), var(--bg) 60%);
  border-left: 4px solid var(--alert-color);
}

/* IMPORTANT (Purple) */
#write blockquote[data-type="alert-important"] {
  --alert-color: var(--important);
  background: color-mix(in srgb, var(--alert-color), var(--bg) 88%);
  border-color: color-mix(in srgb, var(--alert-color), var(--bg) 60%);
  border-left: 4px solid var(--alert-color);
}

/* CAUTION (Red) */
#write blockquote[data-type="alert-caution"] {
  --alert-color: var(--error);
  background: color-mix(in srgb, var(--alert-color), var(--bg) 85%);
  border-color: color-mix(in srgb, var(--alert-color), var(--bg) 60%);
  border-left: 4px solid var(--alert-color);
}

/* Lists */
#write ul,
#write ol {
  padding-left: 1.5em;
  margin: 1em 0;
}

#write li {
  margin: 0.55em 0;
}

#write li>ul,
#write li>ol {
  margin: 0.4em 0;
}

#write ul li::marker {
  color: rgba(var(--accent-rgb), 0.9);
  font-size: 0.98em;
  font-weight: 700;
}

#write ol li::marker {
  color: rgba(var(--accent-rgb), 0.75);
  font-weight: 800;
  font-variant-numeric: tabular-nums;
}

/* Adjust ordered list alignment for longer numbers */
#write ol {
  list-style-position: outside;
}

/* Task Lists */
.task-list-item {
  list-style-type: none;
  padding-left: 0;
}

.task-list-item input {
  margin-right: 0.6em;
  accent-color: var(--accent);
  transform: translateY(1px);
}

/* Tables */
#write table {
  border-collapse: separate;
  border-spacing: 0;
  width: 100%;
  margin: 2.1em 0;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 16px;
  overflow: hidden;
  box-shadow: 0 10px 36px rgba(var(--black-rgb), 0.25);
}

#write th,
#write td {
  padding: 0.85em 1.1em;
  border-bottom: 1px solid var(--border);
}

#write th {
  text-align: left;
  background: linear-gradient(180deg, rgba(var(--white-rgb), 0.04), transparent);
  font-weight: 700;
  color: var(--text);
}

#write tr:last-child td {
  border-bottom: 0;
}

#write tr:nth-child(even) td {
  background: rgba(var(--accent-rgb), 0.03);
}

#write tr:hover td {
  background: rgba(var(--accent-rgb), 0.05);
}

/* Code */
#write code {
  font-family: var(--font-mono);
  font-size: 0.9em;
  padding: 0.2em 0.45em;
  border-radius: 7px;
  background: rgba(var(--accent-rgb), 0.14);
  color: var(--code-inline-text);
  font-weight: 600;
  border: 1px solid rgba(var(--accent-rgb), 0.32);
}

#write pre.md-fences,
#write pre[mdtype="fences"],
#write .md-fences {
  background: var(--code-bg);
  color: var(--code-text);
  border: 1px solid rgba(var(--accent-rgb), 0.14);
  border-radius: 18px;
  padding: 3.3em 1.5em 1.5em;
  margin: 2.2em 0;
  overflow: auto;
  box-shadow: 0 20px 58px rgba(var(--black-rgb), 0.48);
  font-family: var(--font-mono);
  font-size: 14.5px;
  line-height: 1.65;
  position: relative;
}

/* Mac-style Window Controls */
#write pre.md-fences::before,
#write pre[mdtype="fences"]::before,
#write .md-fences::before {
  content: "";
  position: absolute;
  top: 14px;
  left: 14px;
  width: 10px;
  height: 10px;
  border-radius: 50%;
  background: var(--code-dot-red);
  box-shadow: 18px 0 0 var(--code-dot-yellow), 36px 0 0 var(--code-dot-green);
  z-index: 2;
  opacity: 0.9;
}

#write pre.md-fences code,
#write pre[mdtype="fences"] code,
#write .md-fences code {
  background: transparent;
  padding: 0;
  color: var(--code-text);
  font-weight: normal;
}

#write pre.md-fences .CodeMirror,
#write pre.md-fences .CodeMirror-scroll,
#write pre.md-fences .CodeMirror-gutters,
#write pre.md-fences .cm-s-inner,
#write pre[mdtype="fences"] .CodeMirror,
#write pre[mdtype="fences"] .CodeMirror-scroll,
#write pre[mdtype="fences"] .CodeMirror-gutters,
#write pre[mdtype="fences"] .cm-s-inner,
#write .md-fences .CodeMirror,
#write .md-fences .CodeMirror-scroll,
#write .md-fences .CodeMirror-gutters,
#write .md-fences .cm-s-inner {
  background: transparent !important;
  color: var(--code-ink);
}

#write pre.md-fences .CodeMirror-linenumber,
#write pre[mdtype="fences"] .CodeMirror-linenumber,
#write .md-fences .CodeMirror-linenumber {
  color: rgba(var(--ink-rgb), 0.55);
}

#write pre.md-fences .CodeMirror-cursor,
#write pre[mdtype="fences"] .CodeMirror-cursor,
#write .md-fences .CodeMirror-cursor {
  border-left: 2px solid rgba(var(--accent-rgb), 0.8);
}

#write pre.md-fences .CodeMirror-gutters,
#write pre[mdtype="fences"] .CodeMirror-gutters,
#write .md-fences .CodeMirror-gutters {
  border-right: 1px solid rgba(var(--accent-rgb), 0.12);
}

#write pre.md-fences .CodeMirror-line,
#write pre.md-fences .CodeMirror-code,
#write pre[mdtype="fences"] .CodeMirror-line,
#write pre[mdtype="fences"] .CodeMirror-code,
#write .md-fences .CodeMirror-line,
#write .md-fences .CodeMirror-code {
  color: var(--code-ink);
}

/* Code token colors for readability */
#write pre.md-fences .cm-s-inner .cm-comment,
#write pre[mdtype="fences"] .cm-s-inner .cm-comment,
#write .md-fences .cm-s-inner .cm-comment {
  color: rgba(var(--code-muted-rgb), 0.55);
}

#write pre.md-fences .cm-s-inner .cm-keyword,
#write pre[mdtype="fences"] .cm-s-inner .cm-keyword,
#write .md-fences .cm-s-inner .cm-keyword {
  color: var(--code-token-keyword);
  font-weight: 700;
}

#write pre.md-fences .cm-s-inner .cm-string,
#write pre[mdtype="fences"] .cm-s-inner .cm-string,
#write .md-fences .cm-s-inner .cm-string {
  color: var(--code-token-string);
}

#write pre.md-fences .cm-s-inner .cm-number,
#write pre[mdtype="fences"] .cm-s-inner .cm-number,
#write .md-fences .cm-s-inner .cm-number {
  color: var(--code-token-number);
}

#write pre.md-fences .cm-s-inner .cm-def,
#write pre[mdtype="fences"] .cm-s-inner .cm-def,
#write .md-fences .cm-s-inner .cm-def {
  color: var(--code-token-blue);
}

#write pre.md-fences .cm-s-inner .cm-variable,
#write pre[mdtype="fences"] .cm-s-inner .cm-variable,
#write .md-fences .cm-s-inner .cm-variable {
  color: var(--code-ink);
}

#write pre.md-fences .cm-s-inner .cm-property,
#write pre[mdtype="fences"] .cm-s-inner .cm-property,
#write .md-fences .cm-s-inner .cm-property {
  color: var(--code-token-blue);
}

#write pre.md-fences .cm-s-inner .cm-operator,
#write pre[mdtype="fences"] .cm-s-inner .cm-operator,
#write .md-fences .cm-s-inner .cm-operator {
  color: var(--code-ink);
}

/* 防止嵌套多层 pre/code 造成重复背景 */
#write pre.md-fences pre,
#write pre.md-fences pre code,
#write pre.md-fences .cm-s-inner .CodeMirror-lines,
#write pre[mdtype="fences"] pre,
#write pre[mdtype="fences"] pre code,
#write pre[mdtype="fences"] .cm-s-inner .CodeMirror-lines,
#write .md-fences pre,
#write .md-fences pre code,
#write .md-fences .cm-s-inner .CodeMirror-lines {
  background: transparent !important;
  border: 0 !important;
  box-shadow: none !important;
}

#write pre.md-fences pre,
#write pre[mdtype="fences"] pre,
#write .md-fences pre {
  padding: 0 !important;
  margin: 0 !important;
}

#write pre.md-fences .CodeMirror-scroll,
#write pre[mdtype="fences"] .CodeMirror-scroll,
#write .md-fences .CodeMirror-scroll {
  overflow: visible !important;
}

#write pre.has-toolbar .code-toolbar {
  position: absolute;
  top: 10px;
  left: 84px;
  right: 12px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  z-index: 3;
  pointer-events: none;
}

#write pre.has-toolbar .code-lang {
  font-size: 12px;
  font-weight: 700;
  letter-spacing: 0.02em;
  color: rgba(var(--white-rgb), 0.76);
  padding: 4px 10px;
  border-radius: 999px;
  border: 1px solid rgba(var(--white-rgb), 0.14);
  background: rgba(var(--white-rgb), 0.08);
}

#write pre.has-toolbar .code-copy-btn {
  pointer-events: auto;
  appearance: none;
  border: 1px solid rgba(var(--white-rgb), 0.16);
  background: rgba(var(--white-rgb), 0.08);
  color: rgba(var(--white-rgb), 0.9);
  font-size: 12px;
  font-weight: 700;
  padding: 6px 12px;
  border-radius: 999px;
  cursor: pointer;
  transition: transform 0.15s ease, background 0.15s ease, border-color 0.15s ease;
}

#write pre.has-toolbar .code-copy-btn:hover {
  transform: translateY(-1px);
  border-color: rgba(var(--white-rgb), 0.26);
  background: rgba(var(--white-rgb), 0.12);
}

#write pre.has-toolbar .code-copy-btn[data-state="copied"] {
  border-color: rgba(var(--accent-rgb), 0.6);
  background: rgba(var(--accent-rgb), 0.3);
}

/* Typora built-in code toolbar (compat: .md-fences / pre.md-fences / #write pre.md-fences) */
#write pre.md-fences .code-tooltip,
#write pre[mdtype="fences"] .code-tooltip,
#write .md-fences .code-tooltip,
#write [mdtype="fences"] .code-tooltip {
  position: absolute;
  top: 10px;
  right: 12px;
  bottom: auto;
  left: auto;
  z-index: 4;
  display: inline-flex;
  align-items: center;
  gap: 8px;
  opacity: 0;
  transform: translateY(-2px);
  transition: opacity 0.15s ease, transform 0.15s ease;
  pointer-events: none;
  float: none !important;
  padding: 0;
  min-width: 0;
  height: auto;
  background: transparent;
  box-shadow: none;
}

#write pre.md-fences:hover .code-tooltip,
#write pre[mdtype="fences"]:hover .code-tooltip,
#write .md-fences:hover .code-tooltip,
#write [mdtype="fences"]:hover .code-tooltip,
#write pre.md-fences:focus-within .code-tooltip,
#write pre[mdtype="fences"]:focus-within .code-tooltip,
#write .md-fences:focus-within .code-tooltip,
#write [mdtype="fences"]:focus-within .code-tooltip {
  opacity: 1;
  transform: translateY(0);
  pointer-events: auto;
}

#write pre.md-fences .code-tooltip-content,
#write pre[mdtype="fences"] .code-tooltip-content,
#write .md-fences .code-tooltip-content,
#write [mdtype="fences"] .code-tooltip-content {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 4px 10px;
  border-radius: 999px;
  border: 1px solid rgba(var(--white-rgb), 0.16);
  background: rgba(var(--white-rgb), 0.08);
  color: rgba(var(--white-rgb), 0.8);
  line-height: 1;
}

#write pre.md-fences .code-tooltip a,
#write pre.md-fences .code-tooltip button,
#write pre[mdtype="fences"] .code-tooltip a,
#write pre[mdtype="fences"] .code-tooltip button,
#write .md-fences .code-tooltip a,
#write .md-fences .code-tooltip button,
#write [mdtype="fences"] .code-tooltip a,
#write [mdtype="fences"] .code-tooltip button {
  pointer-events: auto;
  appearance: none;
  border: 1px solid rgba(var(--white-rgb), 0.16);
  background: rgba(var(--white-rgb), 0.08);
  color: rgba(var(--white-rgb), 0.9);
  font-size: 12px;
  font-weight: 700;
  padding: 6px 12px;
  border-radius: 999px;
  cursor: pointer;
  line-height: 1;
  transition: transform 0.15s ease, background 0.15s ease, border-color 0.15s ease;
}

#write pre.md-fences .code-tooltip a:hover,
#write pre.md-fences .code-tooltip button:hover,
#write pre[mdtype="fences"] .code-tooltip a:hover,
#write pre[mdtype="fences"] .code-tooltip button:hover,
#write .md-fences .code-tooltip a:hover,
#write .md-fences .code-tooltip button:hover,
#write [mdtype="fences"] .code-tooltip a:hover,
#write [mdtype="fences"] .code-tooltip button:hover {
  transform: translateY(-1px);
  border-color: rgba(var(--white-rgb), 0.28);
  background: rgba(var(--white-rgb), 0.12);
}

/* YAML Frontmatter */
#write .md-frontmatter {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 1em;
  margin-bottom: 2em;
  font-size: 0.9em;
  color: var(--muted);
}

/* Footnotes */
#write .md-footnote {
  color: var(--accent);
}

#write .md-footnotes {
  border-top: 1px solid var(--border);
  margin-top: 3em;
  padding: 1.2em 1.4em;
  font-size: 0.9em;
  color: rgba(var(--text-rgb), 0.75);
  background: rgba(var(--accent-rgb), 0.08);
  border: 1px solid rgba(var(--accent-rgb), 0.2);
  border-radius: 12px;
  box-shadow: 0 14px 40px rgba(var(--black-rgb), 0.35);
}

#write .md-footnotes a {
  color: var(--accent);
  text-decoration: none;
  border-bottom: 1px solid rgba(var(--accent-rgb), 0.35);
}

#write .md-footnotes a:hover {
  border-bottom-color: rgba(var(--accent-rgb), 0.7);
}

sup.md-footnote {
  background: rgba(var(--accent-rgb), 0.2);
  color: var(--accent);
  border: 1px solid rgba(var(--accent-rgb), 0.35);
  border-radius: 6px;
  padding: 2px 6px;
}

#write .md-def-name {
  color: var(--accent);
  font-weight: 700;
}

#write .md-def-url {
  color: var(--accent);
  text-decoration: underline;
  text-decoration-color: rgba(var(--accent-rgb), 0.55);
}

#write .md-def-title,
#write .md-def-content {
  color: var(--text-semi);
}

#write .md-def-url:empty:before,
#write .md-def-title:empty:before,
#write .md-def-content:empty:after {
  color: var(--muted);
  opacity: 0.85;
}

/* Images */
#write img {
  max-width: 100%;
  height: auto;
  border-radius: 16px;
  box-shadow: 0 20px 70px rgba(var(--black-rgb), 0.35);
  display: block;
  margin: 1.6em auto;
}

/* Mark */
#write mark {
  background: linear-gradient(120deg, rgba(var(--accent-rgb), 0.34), rgba(var(--accent-rgb), 0.18));
  color: var(--text);
  padding: 0.12em 0.28em;
  border-radius: 9px;
  box-shadow: 0 8px 24px rgba(var(--accent-rgb), 0.32);
  border: 1px solid rgba(var(--accent-rgb), 0.42);
}

/* --- Advanced Interactions --- */
a {
  transition: all 0.25s cubic-bezier(0.4, 0, 0.2, 1);
}

a:hover {
  transform: translateY(-1px);
}

/* --- Immersive Focus Mode --- */
.on-focus-mode .md-focus-element {
  opacity: 1 !important;
  filter: blur(0) !important;
  transition: all 0.35s cubic-bezier(0.4, 0, 0.2, 1) !important;
}

.on-focus-mode #write>*:not(.md-focus-element),
.on-focus-mode .md-focus-element~*,
.on-focus-mode #write>.md-focus-element~* {
  opacity: 0.15 !important;
  filter: blur(1px);
  transition: all 0.4s ease !important;
}

.on-focus-mode #write {
  background: transparent !important;
  border-color: transparent !important;
  box-shadow: none !important;
}

/* Underline */
#write u {
  text-decoration: none;
  background-image: linear-gradient(120deg, rgba(var(--accent-rgb), 0.55), rgba(var(--accent-rgb), 0.2));
  background-repeat: no-repeat;
  background-size: 100% 0.18em;
  background-position: 0 90%;
  border-radius: 4px;
  padding-bottom: 2px;
}

/* KBD */
#write kbd {
  font-family: var(--font-mono);
  font-size: 0.85em;
  padding: 0.2em 0.5em;
  border: 1px solid var(--border-semi);
  border-bottom-width: 3px;
  border-radius: 10px;
  background: var(--bg);
  color: var(--text);
  margin: 0 0.2em;
}

/* Math */
.md-math-block {
  margin: var(--space-xl) 0;
  padding: var(--space-md);
  background: var(--surface);
  border-radius: 12px;
  overflow-x: auto;
}

/* Fix: macOS Title Bar / Header "White Strip" Issue */
body.mac-seamless-mode titlebar,
body.mac-seamless-mode header,
titlebar,
header,
.title-bar {
  background: var(--bg) !important;
  color: var(--text) !important;
  opacity: 0.9;
}

/* Ensure Sidebar fits the theme */
#typora-sidebar {
  color: var(--text);
  background: transparent;
}

/* Scrollbar */
::-webkit-scrollbar {
  width: 10px;
  height: 10px;
}

::-webkit-scrollbar-thumb {
  background: rgba(var(--white-rgb), 0.12);
  border-radius: 999px;
  border: 2px solid transparent;
  background-clip: padding-box;
}

::-webkit-scrollbar-thumb:hover {
  background: rgba(var(--accent-rgb), 0.5);
}

/* Typora chrome */
#typora-sidebar {
  background: var(--side-bar-bg-color);
  border-right: 1px solid var(--border);
  color: var(--muted);
  box-shadow: none;
}

.sidebar-tabs {
  border-bottom: 1px solid var(--border);
}

.sidebar-tab {
  color: var(--muted);
}

.sidebar-tab:hover {
  color: var(--text);
  background: rgba(var(--white-rgb), 0.04);
  border-radius: 10px;
}

.sidebar-tab.active {
  color: var(--text);
  background: rgba(var(--accent-rgb), 0.16);
  border-radius: 10px;
}

.sidebar-content,
.sidebar-content-content {
  background: var(--side-bar-bg-color);
}

.file-list-item,
.file-library-node {
  color: var(--muted);
}

.file-node-content {
  border-radius: 10px;
  padding-left: 10px;
}

#typora-sidebar .file-node-icon {
  width: 18px;
  height: 18px;
  margin-right: 8px;
  display: inline-block;
  flex: 0 0 18px;
  background-color: currentColor;
  background-image: none;
  -webkit-mask-repeat: no-repeat;
  -webkit-mask-size: contain;
  -webkit-mask-position: center;
  mask-repeat: no-repeat;
  mask-size: contain;
  mask-position: center;
}

#typora-sidebar .file-list-item .file-node-icon {
  -webkit-mask-image: var(--icon-document);
  mask-image: var(--icon-document);
}

#typora-sidebar .file-library-node>.file-node-content .file-node-icon {
  -webkit-mask-image: var(--icon-folder);
  mask-image: var(--icon-folder);
}

#typora-sidebar .file-library-file-node>.file-node-content .file-node-icon {
  -webkit-mask-image: var(--icon-document);
  mask-image: var(--icon-document);
}

.file-node-content:hover {
  background: rgba(var(--white-rgb), 0.04);
  color: var(--text);
}

.file-library-node.active>.file-node-content,
.file-list-item.active {
  background: rgba(var(--accent-rgb), 0.16);
  color: var(--text);
  box-shadow: 0 10px 28px rgba(var(--black-rgb), 0.35);
}

.file-library-node.active>.file-node-background,
.file-list-item.active .file-node-background {
  background: transparent;
  border-left: 3px solid rgba(var(--accent-rgb), 0.85);
  border-radius: 10px 0 0 10px;
}

.sidebar-footer-item:hover,
.footer-item:hover {
  background: rgba(var(--accent-rgb), 0.08);
  color: var(--text);
}

.typora-node::-webkit-scrollbar-thumb:vertical {
  background: rgba(var(--white-rgb), 0.16);
}

.typora-node::-webkit-scrollbar-thumb:vertical:active {
  background: rgba(var(--accent-rgb), 0.4);
}

.modal-content,
.megamenu-content,
.ty-preferences {
  background: var(--bg);
  color: var(--text);
}

/* --- Advanced Interactions --- */
a {
  transition: all 0.25s cubic-bezier(0.4, 0, 0.2, 1);
}

a:hover {
  transform: translateY(-1px);
}

/* --- Immersive Focus Mode --- */
.on-focus-mode .md-focus-element {
  opacity: 1 !important;
  filter: blur(0) !important;
  transition: all 0.35s cubic-bezier(0.4, 0, 0.2, 1) !important;
}

.on-focus-mode #write>*:not(.md-focus-element),
.on-focus-mode .md-focus-element~*,
.on-focus-mode #write>.md-focus-element~* {
  opacity: 0.15 !important;
  filter: blur(1px);
  transition: all 0.4s ease !important;
}

.on-focus-mode #write {
  background: transparent !important;
  border-color: transparent !important;
  box-shadow: none !important;
}

/* --- Mermaid Diagram Support for Dark Themes (Issue #1) --- */
:root {
  --mermaid-theme: night;
}

#write .mermaid {
  background: rgba(var(--white-rgb), 0.02) !important;
  border-radius: 12px;
  padding: 10px;
}

#write .mermaid text {
  fill: var(--text) !important;
  font-family: var(--font-sans) !important;
}

/* 
   We rely on --mermaid-theme: night for internal coloring (lines, actors).
   Replacements below are minimal overrides only if needed for high contrast text 
   or background blending. 
*/

#write .mermaid .node rect,
#write .mermaid .node circle,
#write .mermaid .node polygon,
#write .mermaid .node path {
  fill: var(--bg) !important;
  stroke: var(--accent) !important;
  stroke-width: 1.5px !important;
}

/* Ensure text is always readable */
#write .mermaid text.actor {
  fill: var(--text) !important;
}

/* Edge Paths */
#write .mermaid .edgePath .path {
  stroke: var(--text-semi) !important;
  stroke-width: 1.5px !important;
}
