:root {
  color-scheme: light dark;
  --bg: #f4f5f7;
  --surface: #ffffff;
  --surface-2: #f7f8fa;
  --border: #e4e7ec;
  --text: #20242a;
  --muted: #8a93a0;
  --primary: #3478f6;
  --primary-dark: #2466e0;
  --danger: #d4483c;
  --success: #2f9e6b;
  --toolbar-bg: #e9ebee;
  --music-overlay-bg: #2f3740;
  --tabbar-h: 64px;
  --tab-active: #4a5260;
  --tab-inactive: #e6e8ec;
  --tab-text-active: #ffffff;
  --tab-text-inactive: #6b7683;
  --radius-lg: 18px;
  --radius-md: 14px;
  --radius-pill: 999px;
  --shadow: 0 8px 30px rgba(32, 40, 52, 0.08);
  --shadow-sm: 0 2px 10px rgba(32, 40, 52, 0.05);
  --ease-out: cubic-bezier(0.22, 1, 0.36, 1);
  --motion-fast: 160ms;
  --motion-normal: 280ms;
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #101317;
    --surface: #181c22;
    --surface-2: #20262e;
    --border: #2a323c;
    --text: #e9edf2;
    --muted: #8e99a7;
    --primary: #5b93f7;
    --primary-dark: #7aa7f8;
    --danger: #ef6a5d;
    --success: #54c48a;
    --toolbar-bg: #232a33;
    --music-overlay-bg: #161a1f;
    --tab-active: #4c5766;
    --tab-inactive: #262d36;
    --tab-text-active: #ffffff;
    --tab-text-inactive: #8e99a7;
    --shadow: 0 8px 30px rgba(0, 0, 0, 0.35);
    --shadow-sm: 0 2px 10px rgba(0, 0, 0, 0.25);
  }
}

* {
  box-sizing: border-box;
}

html,
body {
  height: 100%;
  overflow: hidden;
}

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: YouYuan, "幼圆", "Microsoft YaHei", sans-serif;
  font-size: 16px;
  line-height: 1.6;
  letter-spacing: 0;
}

a {
  color: var(--primary);
  text-decoration: none;
}

a:hover {
  text-decoration: underline;
}

.tabbar {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  z-index: 30;
  height: var(--tabbar-h, 64px);
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 16px;
  background: var(--bg);
  transform: translateY(0);
  transition: transform var(--motion-normal) var(--ease-out),
    opacity var(--motion-fast) ease;
  will-change: transform;
}

.tab {
  flex: 1;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 44px;
  border-radius: var(--radius-pill);
  background: var(--tab-inactive);
  color: var(--tab-text-inactive);
  font-family: YouYuan, "幼圆", "Microsoft YaHei", sans-serif;
  font-size: 16px;
  font-weight: 600;
  transition: transform var(--motion-fast) var(--ease-out),
    background var(--motion-fast) ease, color var(--motion-fast) ease,
    filter var(--motion-fast) ease;
}

.tab-symbol {
  display: block;
  width: 29px;
  height: 29px;
  transition: transform var(--motion-fast) var(--ease-out);
}

.tab:hover .tab-symbol,
.tab:active .tab-symbol {
  transform: scale(1.08);
}

body.tabbar-hidden .tabbar {
  transform: translateY(-100%);
  opacity: 0;
}

body.tabbar-hidden .container {
  margin-top: 0;
  height: 100vh;
}

.tab:hover {
  text-decoration: none;
  filter: brightness(0.98);
}

.tab.active {
  background: var(--tab-active);
  color: var(--tab-text-active);
}

.container {
  margin-top: var(--tabbar-h, 64px);
  height: calc(100vh - var(--tabbar-h, 64px));
  transition: margin-top var(--motion-normal) var(--ease-out),
    height var(--motion-normal) var(--ease-out);
  padding: 0;
  overflow: hidden;
}

.container.scrollable {
  overflow-y: auto;
  padding: 24px 16px 40px;
}

.footer {
  padding: 16px;
  text-align: center;
  color: var(--muted);
  font-size: 13px;
  border-top: 1px solid var(--border);
}

.flash {
  max-width: 948px;
  margin: 16px auto 0;
  padding: 10px 14px;
  border: 1px solid color-mix(in srgb, var(--success) 35%, transparent);
  border-radius: var(--radius-md);
  background: color-mix(in srgb, var(--success) 12%, transparent);
  color: var(--success);
  font-size: 14px;
}

.page-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  flex-wrap: wrap;
  margin-bottom: 16px;
}

.page-head h1 {
  margin: 0;
  font-size: 24px;
  font-weight: 650;
}

.panel,
.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-sm);
}

.panel {
  padding: 18px;
  margin-bottom: 18px;
}

.panel-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  margin-bottom: 12px;
}

.panel-head h2 {
  margin: 0;
  font-size: 16px;
}

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 40px;
  padding: 8px 18px;
  border: 1px solid var(--border);
  border-radius: var(--radius-pill);
  background: var(--surface);
  color: var(--text);
  font-size: 14px;
  cursor: pointer;
  text-decoration: none;
  white-space: nowrap;
  transition: transform var(--motion-fast) var(--ease-out),
    background var(--motion-fast) ease, border-color var(--motion-fast) ease,
    color var(--motion-fast) ease, opacity var(--motion-fast) ease;
}

.btn:active,
.tool-btn:active,
.music-result:active {
  transform: scale(0.97);
}

.btn:hover {
  text-decoration: none;
  background: var(--surface-2);
  border-color: color-mix(in srgb, var(--border) 70%, var(--text));
}

.btn:disabled {
  opacity: 0.6;
  cursor: default;
}

.btn-primary {
  border-color: var(--primary);
  background: var(--primary);
  color: #ffffff;
}

.btn-primary:hover {
  border-color: var(--primary-dark);
  background: var(--primary-dark);
  color: #ffffff;
}

.btn-danger {
  border-color: color-mix(in srgb, var(--danger) 35%, transparent);
  color: var(--danger);
}

.btn-danger:hover {
  border-color: var(--danger);
  background: color-mix(in srgb, var(--danger) 10%, transparent);
  color: var(--danger);
}

.btn-soft {
  border-color: transparent;
  background: var(--surface-2);
  color: var(--muted);
  min-height: 36px;
  padding: 6px 16px;
}

.btn-soft:hover {
  color: var(--text);
  background: color-mix(in srgb, var(--surface-2) 80%, var(--text));
}

.link {
  font-size: 14px;
}

.head-actions {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
}

.search-form {
  display: flex;
  align-items: center;
  gap: 8px;
}

.search-form input[type="search"] {
  width: 180px;
}

.inline-form {
  display: inline;
}

.composer {
  max-width: 980px;
  height: 100%;
  margin: 0 auto;
  padding: 18px 24px calc(84px + env(safe-area-inset-bottom, 0px));
  min-height: 0;
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.history-drawer,
.history-backdrop {
  display: none;
}

@media (max-width: 760px) {
  .history-drawer {
    position: fixed;
    inset: 0 auto 0 0;
    z-index: 80;
    display: flex;
    width: min(86vw, 360px);
    flex-direction: column;
    background: var(--surface);
    border-right: 1px solid var(--border);
    box-shadow: 18px 0 42px rgba(0, 0, 0, 0.22);
    transform: translateX(-102%);
    visibility: hidden;
    transition: transform var(--motion-normal) var(--ease-out),
      visibility var(--motion-normal);
    will-change: transform;
  }

  body.history-open .history-drawer {
    transform: translateX(0);
    visibility: visible;
  }

  .history-backdrop {
    position: fixed;
    inset: 0;
    z-index: 70;
    display: block;
    border: 0;
    background: rgba(0, 0, 0, 0.38);
    opacity: 0;
    visibility: hidden;
    pointer-events: none;
    transition: opacity var(--motion-normal) ease,
      visibility var(--motion-normal);
  }

  body.history-open .history-backdrop {
    opacity: 1;
    visibility: visible;
    pointer-events: auto;
  }

  .history-head {
    display: flex;
    min-height: 62px;
    align-items: center;
    justify-content: space-between;
    padding: calc(10px + env(safe-area-inset-top, 0px)) 14px 10px 18px;
    border-bottom: 1px solid var(--border);
    font-family: YouYuan, "幼圆", "Microsoft YaHei", sans-serif;
    font-size: 16px;
    font-weight: 600;
  }

  .history-close {
    width: 38px;
    height: 38px;
    border: 0;
    border-radius: 50%;
    background: transparent;
    color: var(--muted);
    font-size: 24px;
    cursor: pointer;
  }

  .history-list {
    flex: 1;
    min-height: 0;
    overflow-y: auto;
    overscroll-behavior: none;
    scroll-behavior: smooth;
    -webkit-overflow-scrolling: touch;
    padding-bottom: env(safe-area-inset-bottom, 0px);
  }

  .history-row {
    display: grid;
    grid-template-columns: minmax(0, 1fr) auto;
    align-items: center;
    gap: 12px;
    min-height: 52px;
    padding: 0 16px 0 18px;
    border-bottom: 1px solid var(--border);
    transition: background var(--motion-fast) ease;
  }

  .history-row:active,
  .history-row.current {
    background: var(--surface-2);
  }

  .history-row-title {
    overflow: hidden;
    font-size: 14px;
    text-overflow: ellipsis;
    white-space: nowrap;
  }

  .history-row-link {
    min-width: 0;
    color: var(--text);
    text-decoration: none;
  }

  .history-row-delete {
    width: 32px;
    height: 32px;
    border: 0;
    border-radius: 50%;
    background: transparent;
    color: var(--muted);
    font-size: 24px;
    font-weight: 300;
    line-height: 1;
    cursor: pointer;
    transition: background var(--motion-fast) ease, color var(--motion-fast) ease;
  }

  .history-row-delete:active {
    background: var(--surface-2);
    color: var(--danger, #dc2626);
  }

  .history-row-delete:disabled {
    cursor: default;
    opacity: 0.45;
  }

  .history-search-wrap {
    padding: 0 14px 10px;
  }

  .history-search {
    width: 100%;
    height: 38px;
    border: 1px solid var(--border);
    border-radius: var(--radius-pill);
    background: var(--surface-2);
    color: var(--text);
    padding: 0 14px;
    outline: none;
  }

  .history-search:focus {
    border-color: var(--primary);
  }

  .history-empty {
    padding: 28px 18px;
    color: var(--muted);
    font-size: 14px;
    text-align: center;
  }
}

.vditor-host {
  flex: 1;
  min-height: 0;
  overflow: hidden;
}

.composer .vditor {
  border: 0;
  border-radius: 0;
  box-shadow: none;
  background: transparent !important;
}

.composer .vditor-content {
  background: transparent !important;
  height: 100%;
  min-height: 0;
}

.composer .vditor-wysiwyg {
  height: 100%;
  overflow-y: auto;
  overscroll-behavior: contain;
  -webkit-overflow-scrolling: touch;
}

.composer .vditor-wysiwyg > .vditor-reset {
  height: auto;
  min-height: 100%;
  padding: 14px 4px 116px;
}

.composer .vditor-reset {
  background: transparent !important;
  color: var(--text);
  font-family: YouYuan, "幼圆", "Microsoft YaHei", sans-serif !important;
  font-size: 18px !important;
  line-height: 1.8;
}

.composer .vditor-toolbar {
  border: 0;
  background: transparent;
}

.composer .vditor-reset {
  padding: 14px 4px;
}

.composer .vditor-reset img {
  max-width: 100%;
  border-radius: 18px;
  box-shadow: var(--shadow-sm);
}

.composer .vditor-reset .inline-music-card.media-drag-ready,
.composer .vditor-reset img.media-drag-ready {
  outline: 2px solid var(--primary);
  outline-offset: 3px;
  cursor: grab;
}

.composer .vditor-reset h1,
.composer .vditor-reset h2,
.composer .vditor-reset h3,
.composer .vditor-reset h4,
.composer .vditor-reset h5,
.composer .vditor-reset h6 {
  border-bottom: 0 !important;
  padding-bottom: 0 !important;
}

.composer .vditor-wysiwyg > .vditor-reset > h1::before,
.composer .vditor-wysiwyg > .vditor-reset > h2::before,
.composer .vditor-wysiwyg > .vditor-reset > h3::before,
.composer .vditor-wysiwyg > .vditor-reset > h4::before,
.composer .vditor-wysiwyg > .vditor-reset > h5::before,
.composer .vditor-wysiwyg > .vditor-reset > h6::before {
  content: none !important;
  display: none !important;
}

.editor-split {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 20px;
  flex: 1;
  min-height: 440px;
}

.editor-pane,
.preview-pane {
  min-width: 0;
}

.composer-input {
  width: 100%;
  height: 100%;
  min-height: 440px;
  border: 0;
  background: transparent;
  color: var(--text);
  font-family: YouYuan, "幼圆", "Microsoft YaHei", sans-serif;
  font-size: 18px;
  line-height: 1.75;
  resize: none;
  padding: 0;
  box-shadow: none;
}

.composer-input:focus {
  outline: none;
}

.composer-input::placeholder {
  color: var(--muted);
}

.composer-tools {
  position: fixed;
  left: 5%;
  right: 5%;
  bottom: calc(10px + env(safe-area-inset-bottom, 0px));
  z-index: 20;
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0;
  padding: 0;
  border-radius: var(--radius-pill);
  background: var(--toolbar-bg);
  box-shadow: var(--shadow-sm);
  overflow: hidden;
}

.tool-btn {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 58px;
  border: 0;
  background: transparent;
  color: var(--muted);
  cursor: pointer;
  transition: transform var(--motion-fast) var(--ease-out),
    color var(--motion-fast) ease, background var(--motion-fast) ease;
}

.tool-btn:first-child {
  border-radius: var(--radius-pill) 0 0 var(--radius-pill);
}

.tool-btn:last-child {
  border-radius: 0 var(--radius-pill) var(--radius-pill) 0;
}

.tool-btn:first-child {
  border-right: 1px solid var(--border);
}

.tool-btn:hover {
  color: var(--text);
  background: color-mix(in srgb, var(--toolbar-bg) 80%, var(--text));
}

.tool-btn.active {
  background: var(--tab-active);
  color: var(--tab-text-active);
}

.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

.view-toggle {
  display: none;
  margin-left: auto;
  gap: 4px;
  padding: 3px;
  background: var(--surface-2);
  border-radius: var(--radius-pill);
}

.view-btn {
  border: 0;
  background: transparent;
  color: var(--muted);
  font-size: 13px;
  cursor: pointer;
  padding: 6px 14px;
  border-radius: var(--radius-pill);
}

.view-btn.active {
  background: var(--surface);
  color: var(--text);
  box-shadow: var(--shadow-sm);
}

.preview-pane {
  overflow-y: auto;
  border-left: 1px solid var(--border);
  padding-left: 22px;
}

.md-preview {
  min-height: 440px;
}

.composer-footer {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 12px;
  min-height: 24px;
}

.select-toolbar {
  position: fixed;
  z-index: 100;
  display: flex;
  align-items: center;
  gap: 4px;
  padding: 6px;
  border: 1px solid var(--border);
  border-radius: var(--radius-pill);
  background: var(--surface);
  box-shadow: var(--shadow);
}

.select-toolbar button {
  min-width: 34px;
  height: 34px;
  border: 0;
  border-radius: 50%;
  background: transparent;
  color: var(--text);
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
}

.select-toolbar button:hover {
  background: var(--surface-2);
}

.save-status {
  color: var(--success);
  font-size: 14px;
}

.music-insert {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  z-index: 40;
  display: flex;
  flex-direction: column;
  gap: 12px;
  padding: 18px 18px 22px;
  border-radius: 0 0 24px 24px;
  background: var(--music-overlay-bg);
  color: var(--text);
  box-shadow: var(--shadow);
  transform: translateY(-110%);
  visibility: hidden;
  pointer-events: none;
  transition: transform var(--motion-normal) var(--ease-out),
    visibility var(--motion-normal), opacity var(--motion-fast) ease;
  opacity: 0;
}

body.music-open .music-insert {
  transform: translateY(0);
  visibility: visible;
  pointer-events: auto;
  opacity: 1;
}

body.music-open::after {
  content: "";
  position: fixed;
  inset: 0;
  z-index: 35;
  background: rgba(0, 0, 0, 0.42);
}

.music-insert-head {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 10px;
}

.music-insert-title {
  font-size: 16px;
  font-weight: 600;
  color: var(--text);
}

.music-close {
  width: 34px;
  height: 34px;
  border: 0;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.12);
  color: var(--text);
  font-size: 20px;
  line-height: 1;
  cursor: pointer;
}

.music-search {
  width: 100%;
}

.music-results {
  display: flex;
  flex-direction: column;
  gap: 6px;
  max-height: 280px;
  overflow-y: auto;
}

.music-result {
  display: flex;
  align-items: center;
  gap: 10px;
  width: 100%;
  padding: 8px;
  border: 0;
  border-radius: 12px;
  background: var(--surface);
  color: var(--text);
  cursor: pointer;
  text-align: left;
}

.music-result:hover {
  background: color-mix(in srgb, var(--surface-2) 70%, var(--primary));
}

.music-result img {
  width: 42px;
  height: 42px;
  object-fit: cover;
  border-radius: 10px;
  flex-shrink: 0;
}

.music-result-text {
  display: flex;
  flex-direction: column;
  min-width: 0;
}

.music-result-name {
  font-size: 14px;
  font-weight: 600;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.music-result-artist {
  font-size: 12px;
  color: var(--muted);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.inline-music-card {
  display: grid !important;
  grid-template-columns: 48px minmax(0, 1fr) minmax(180px, 280px);
  align-items: center;
  gap: 12px;
  margin: 14px 0;
  padding: 10px 12px;
  border: 1px solid var(--border);
  border-radius: 12px;
  background: var(--surface-2);
  color: var(--text);
  box-shadow: var(--shadow-sm);
  animation: music-card-in var(--motion-normal) var(--ease-out) both;
}

@keyframes music-card-in {
  from {
    opacity: 0;
    transform: translateY(8px) scale(0.99);
  }
  to {
    opacity: 1;
    transform: translateY(0) scale(1);
  }
}

.inline-music-cover {
  width: 48px;
  height: 48px;
  border-radius: 8px;
  object-fit: cover;
}

.inline-music-copy {
  display: flex;
  flex-direction: column;
  min-width: 0;
  line-height: 1.4;
}

.inline-music-copy strong,
.inline-music-copy span {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.inline-music-copy strong {
  font-size: 14px;
}

.inline-music-copy span {
  color: var(--muted);
  font-size: 12px;
}

.inline-music-card audio {
  width: 100%;
  height: 36px;
}

.lightbox {
  position: fixed;
  inset: 0;
  z-index: 60;
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(0, 0, 0, 0.82);
  cursor: zoom-out;
}

.lightbox img {
  max-width: 92vw;
  max-height: 88vh;
  border-radius: 12px;
}

.hidden {
  display: none !important;
}

.preview-grid {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
}

.preview-grid img {
  width: 96px;
  height: 96px;
  object-fit: cover;
  border-radius: var(--radius-md);
}

.stack-form {
  display: flex;
  flex-direction: column;
  gap: 14px;
}

.form-row,
.form-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
}

label {
  display: flex;
  flex-direction: column;
  gap: 6px;
  color: var(--muted);
  font-size: 14px;
}

input,
textarea,
select {
  width: 100%;
  padding: 10px 12px;
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  background: var(--surface);
  color: var(--text);
  font: inherit;
}

textarea {
  resize: vertical;
}

input:focus,
textarea:focus,
select:focus {
  outline: 2px solid color-mix(in srgb, var(--primary) 40%, transparent);
  outline-offset: 1px;
  border-color: var(--primary);
}

input[type="range"] {
  padding: 0;
}

input[type="file"] {
  padding: 8px;
  background: var(--surface-2);
}

select {
  min-height: 42px;
}

.form-section {
  margin: 0;
  padding: 14px;
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.form-section legend {
  padding: 0 8px;
  color: var(--muted);
  font-size: 14px;
}

.compact-list {
  list-style: none;
  margin: 0;
  padding: 0;
}

.compact-list li {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 9px 0;
  border-bottom: 1px solid var(--border);
  min-width: 0;
}

.compact-list li:last-child {
  border-bottom: 0;
}

.note-title {
  color: var(--text);
  font-weight: 600;
  overflow-wrap: anywhere;
}

.note-title:hover {
  color: var(--primary);
}

.time {
  margin-left: auto;
  color: var(--muted);
  font-size: 13px;
  white-space: nowrap;
}

.empty {
  color: var(--muted);
}

.muted {
  color: var(--muted);
  font-size: 13px;
}

.count {
  color: var(--muted);
  font-size: 13px;
}

.note-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(260px, 1fr));
  gap: 14px;
}

.card {
  display: flex;
  flex-direction: column;
  gap: 10px;
  padding: 16px;
  min-width: 0;
}

.card-content {
  color: var(--text);
  font-size: 15px;
  line-height: 1.65;
  overflow: hidden;
  display: -webkit-box;
  -webkit-line-clamp: 5;
  -webkit-box-orient: vertical;
  overflow-wrap: anywhere;
}

.card-content:hover {
  color: var(--primary);
}

.chips {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

.chip {
  display: inline-flex;
  align-items: center;
  min-height: 26px;
  padding: 3px 12px;
  border-radius: var(--radius-pill);
  background: var(--surface-2);
  color: var(--muted);
  font-size: 12px;
  white-space: nowrap;
}

a.chip {
  cursor: pointer;
  color: var(--muted);
}

a.chip:hover {
  text-decoration: none;
  color: var(--text);
}

.tag {
  background: color-mix(in srgb, var(--primary) 10%, transparent);
  color: var(--primary);
}

.music {
  background: color-mix(in srgb, var(--danger) 10%, transparent);
  color: var(--danger);
}

.filter-line {
  margin: -6px 0 14px;
  align-items: center;
}

.meta {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  color: var(--muted);
  font-size: 13px;
}

.detail-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  flex-wrap: wrap;
  margin-bottom: 14px;
}

.actions {
  display: flex;
  align-items: center;
  gap: 8px;
}

.detail {
  padding: 26px;
}

.detail .meta {
  margin-bottom: 16px;
}

.content {
  white-space: pre-wrap;
  overflow-wrap: anywhere;
  font-size: 17px;
  line-height: 1.8;
}

.markdown-body {
  color: var(--text);
  font-size: 16px;
  line-height: 1.8;
  overflow-wrap: anywhere;
}

.markdown-body h1,
.markdown-body h2,
.markdown-body h3,
.markdown-body h4 {
  margin: 1em 0 0.5em;
  line-height: 1.35;
  border-bottom: 0;
  padding-bottom: 0;
}

@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    scroll-behavior: auto !important;
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
  }
}

.markdown-body h1 {
  font-size: 1.7em;
}

.markdown-body h2 {
  font-size: 1.4em;
}

.markdown-body h3 {
  font-size: 1.2em;
}

.markdown-body p {
  margin: 0.6em 0;
}

.markdown-body ul,
.markdown-body ol {
  margin: 0.6em 0;
  padding-left: 1.4em;
}

.markdown-body blockquote {
  margin: 0.8em 0;
  padding: 0.2em 1em;
  border-left: 3px solid var(--primary);
  border-radius: 8px;
  background: var(--surface-2);
  color: var(--muted);
}

.markdown-body code {
  padding: 2px 6px;
  border-radius: 6px;
  background: var(--surface-2);
  font-family: Consolas, "Courier New", monospace;
  font-size: 0.9em;
}

.markdown-body pre {
  padding: 12px;
  border-radius: 12px;
  background: var(--surface-2);
  overflow-x: auto;
}

.markdown-body pre code {
  padding: 0;
  background: transparent;
}

.markdown-body img {
  max-width: 100%;
  border-radius: 12px;
}

.markdown-body table {
  width: 100%;
  margin: 0.8em 0;
  border-collapse: collapse;
}

.markdown-body th,
.markdown-body td {
  padding: 8px 10px;
  border: 1px solid var(--border);
  text-align: left;
}

.markdown-body hr {
  margin: 1.2em 0;
  border: 0;
  border-top: 1px solid var(--border);
}

.image-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(160px, 1fr));
  gap: 10px;
  margin-top: 18px;
}

.image-grid img {
  width: 100%;
  height: 160px;
  object-fit: cover;
  border-radius: var(--radius-md);
}

.existing-images {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
}

.existing-images figure {
  margin: 0;
  width: 120px;
}

.existing-images img {
  display: block;
  width: 120px;
  height: 90px;
  object-fit: cover;
  border-radius: var(--radius-md);
}

.existing-images figcaption {
  margin-top: 4px;
  text-align: center;
}

.delete-image-btn {
  border: 0;
  background: none;
  color: var(--danger);
  font-size: 13px;
  cursor: pointer;
  padding: 2px 6px;
}

.music-card {
  display: flex;
  align-items: center;
  gap: 14px;
  margin-top: 18px;
  padding: 14px;
  border: 1px solid color-mix(in srgb, var(--danger) 25%, transparent);
  border-radius: var(--radius-lg);
  background: color-mix(in srgb, var(--danger) 6%, transparent);
}

.selected-music {
  margin-top: 0;
}

.music-remove {
  min-height: 34px;
  padding: 6px 14px;
  flex-shrink: 0;
}

.music-cover {
  width: 60px;
  height: 60px;
  object-fit: cover;
  border-radius: var(--radius-md);
  flex-shrink: 0;
}

.music-info {
  display: flex;
  flex-direction: column;
  min-width: 0;
  flex: 1;
}

.music-label {
  color: var(--danger);
  font-size: 12px;
}

.music-name {
  font-weight: 600;
  overflow-wrap: anywhere;
}

.music-artist {
  color: var(--muted);
  font-size: 14px;
}

.music-link {
  flex-shrink: 0;
}

.plan-section {
  max-width: 760px;
  margin: 0 auto 22px;
}

.plan-list {
  list-style: none;
  margin: 0;
  padding: 0;
}

.plan-row {
  display: grid;
  grid-template-columns: 24px minmax(0, 1fr);
  align-items: center;
  gap: 10px;
  min-height: 68px;
  margin-bottom: 10px;
  padding: 12px 14px;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--surface);
  box-shadow: var(--shadow-sm);
  cursor: grab;
  touch-action: pan-y;
  transition: transform var(--motion-normal) var(--ease-out), opacity var(--motion-normal) ease,
    background var(--motion-fast) ease;
}

.plan-row:active {
  cursor: grabbing;
}

.plan-row.done .note-title {
  color: var(--muted);
  text-decoration: line-through;
}

.plan-main {
  display: flex;
  flex-direction: column;
  min-width: 0;
}

.plan-drag {
  color: var(--muted);
  font-size: 20px;
  line-height: 1;
  user-select: none;
}

.plan-row.dragging {
  opacity: 0.45;
  transform: scale(0.98);
}

.plan-row.touch-dragging {
  background: var(--surface-2);
  box-shadow: var(--shadow-md);
  transform: scale(1.02);
}

.plan-row.completing {
  opacity: 0;
  transform: translateX(110%);
}

.plan-row.deleting {
  opacity: 0;
  transform: translateX(-110%);
}

.plan-actions {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-shrink: 0;
}

@media (max-width: 760px) {
  .form-row,
  .form-grid {
    grid-template-columns: 1fr;
  }

  .editor-split {
    grid-template-columns: 1fr;
    min-height: 0;
  }

  .preview-pane {
    display: none;
    border-left: 0;
    padding-left: 0;
  }

  .composer.viewing-preview .editor-pane {
    display: none;
  }

  .composer.viewing-preview .preview-pane {
    display: block;
  }

  .view-toggle {
    display: inline-flex;
  }

  .plan-row {
    align-items: flex-start;
  }

  .plan-actions {
    width: 100%;
  }

  .composer {
    padding: 18px 14px calc(84px + env(safe-area-inset-bottom, 0px));
  }

  .composer-input {
    min-height: 320px;
  }

  .md-preview {
    min-height: 320px;
  }
}

@media (max-width: 480px) {
  .inline-music-card {
    grid-template-columns: 42px minmax(0, 1fr);
  }

  .inline-music-cover {
    width: 42px;
    height: 42px;
  }

  .inline-music-card audio {
    grid-column: 1 / -1;
  }

  .tabbar {
    padding: 8px 12px;
  }

  .tab {
    font-size: 14px;
  }

  .container {
    padding: 0;
  }

  .page-head h1 {
    font-size: 22px;
  }

  .head-actions {
    width: 100%;
  }

  .search-form {
    flex: 1;
  }

  .search-form input[type="search"] {
    width: 100%;
  }

  .music-card {
    flex-wrap: wrap;
  }

  .music-link {
    width: 100%;
  }

  .detail {
    padding: 18px;
  }
}
