:root {
  color-scheme: light;
  --bg: #f6f7f9;
  --panel: #ffffff;
  --panel-soft: #f0f4f8;
  --border: #d7dde5;
  --border-strong: #b7c0cc;
  --text: #1d2733;
  --muted: #667387;
  --accent: #176b87;
  --accent-strong: #0f5269;
  --danger: #a33b2f;
  --shadow: 0 1px 2px rgba(20, 32, 45, 0.08);
  --header-height: 48px;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "Noto Sans TC", "PingFang TC", "Microsoft JhengHei", sans-serif;
}

:root[data-app-theme="white"] {
  --bg: #e8e5dc;
  --panel: #fbfbfc;
  --panel-soft: #f1f2f4;
}

:root[data-app-theme="warm"] {
  --bg: #ede6d8;
  --panel: #fffaf1;
  --panel-soft: #f4eee2;
}

:root[data-app-theme="paper"] {
  --bg: #efe8cf;
  --panel: #fffbe8;
  --panel-soft: #f5edca;
}

:root[data-app-theme="mint"] {
  --bg: #e3ebdf;
  --panel: #f4fff4;
  --panel-soft: #e6f3e5;
}

:root[data-app-theme="blue"] {
  --bg: #e0eaed;
  --panel: #f3fcff;
  --panel-soft: #e4f2f6;
}

:root[data-app-resolved-mode="dark"] {
  color-scheme: dark;
  --bg: #0f1420;
  --panel: #151b28;
  --panel-soft: #1e2635;
  --border: #2b3445;
  --border-strong: #3b465a;
  --text: #e9edf5;
  --muted: #aab3c2;
  --accent: #5aa9c2;
  --accent-strong: #7bc1d8;
  --danger: #ef8a7c;
  --shadow: 0 1px 2px rgba(0, 0, 0, 0.35);
}

:root[data-app-resolved-mode="dark"][data-app-theme="white"] {
  --bg: #111827;
  --panel: #1c2432;
  --panel-soft: #253044;
}

:root[data-app-resolved-mode="dark"][data-app-theme="warm"],
:root[data-app-resolved-mode="dark"][data-app-theme="paper"] {
  --bg: #201b13;
  --panel: #292319;
  --panel-soft: #332b1e;
}

:root[data-app-resolved-mode="dark"][data-app-theme="mint"] {
  --bg: #101b18;
  --panel: #172620;
  --panel-soft: #1f3029;
}

:root[data-app-resolved-mode="dark"][data-app-theme="blue"] {
  --bg: #101922;
  --panel: #172535;
  --panel-soft: #1f3043;
}

:root[data-app-theme="night"] {
  color-scheme: dark;
  --bg: #0f1420;
  --panel: #151b28;
  --panel-soft: #1e2635;
  --border: #2b3445;
  --border-strong: #3b465a;
  --text: #e9edf5;
  --muted: #aab3c2;
  --accent: #5aa9c2;
  --accent-strong: #7bc1d8;
  --danger: #ef8a7c;
  --shadow: 0 1px 2px rgba(0, 0, 0, 0.35);
}

* {
  box-sizing: border-box;
}

html,
body {
  margin: 0;
  min-width: 320px;
  min-height: 100%;
  color: var(--text);
  background: var(--bg);
}

button,
input,
select,
textarea {
  font: inherit;
}

button {
  border: 1px solid var(--border);
  background: var(--panel);
  color: var(--text);
  min-height: 34px;
  padding: 0 10px;
  border-radius: 6px;
  cursor: pointer;
}

button:hover {
  border-color: var(--accent);
}

button:focus-visible,
input:focus-visible,
select:focus-visible {
  outline: 2px solid rgba(23, 107, 135, 0.35);
  outline-offset: 2px;
}

.app-shell {
  display: flex;
  flex-direction: column;
  height: 100vh;
  overflow: hidden;
}

.app-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  min-height: var(--header-height);
  padding: 6px 10px;
  border-bottom: 1px solid var(--border);
  background: var(--panel);
  box-shadow: var(--shadow);
}

.brand {
  display: flex;
  align-items: center;
  gap: 8px;
  min-width: 190px;
}

.brand-mark {
  width: 30px;
  height: 30px;
  object-fit: contain;
}

.brand h1 {
  margin: 0;
  font-size: 15px;
  line-height: 1.15;
}

.brand p {
  margin: 1px 0 0;
  color: var(--muted);
  font-size: 11px;
  line-height: 1.1;
}

.header-actions,
.sidebar-export-list {
  display: flex;
  align-items: center;
  gap: 6px;
  flex-wrap: wrap;
}

.app-header button {
  min-height: 30px;
  padding: 0 9px;
  font-size: 12px;
}

.tool-button,
.tool-link,
.sidebar-action-button,
.sidebar-export-list button,
.dropdown-menu button,
.settings-form menu button {
  background: var(--accent);
  border-color: var(--accent);
  color: #fff;
}

.tool-button:hover,
.tool-link:hover,
.sidebar-action-button:hover,
.sidebar-export-list button:hover,
.dropdown-menu button:hover,
.settings-form menu button:hover {
  background: var(--accent-strong);
  border-color: var(--accent-strong);
}

.tool-link {
  display: inline-flex;
  align-items: center;
  min-height: 30px;
  padding: 0 10px;
  border: 1px solid var(--accent);
  border-radius: 7px;
  font-size: 12px;
  font-weight: 700;
  text-decoration: none;
  white-space: nowrap;
}

.support-link {
  background: #b8492d;
  border-color: #b8492d;
}

.support-link:hover {
  background: #963a23;
  border-color: #963a23;
}

.danger-action-button,
.mini-danger-button {
  background: #fff;
  border-color: rgba(163, 59, 47, 0.45);
  color: var(--danger);
}

.danger-action-button:hover,
.mini-danger-button:hover {
  background: rgba(163, 59, 47, 0.08);
  border-color: var(--danger);
}

.dropdown {
  position: relative;
}

.dropdown-trigger::after {
  content: "";
  display: inline-block;
  margin-left: 8px;
  border-left: 4px solid transparent;
  border-right: 4px solid transparent;
  border-top: 5px solid currentColor;
  vertical-align: middle;
}

.dropdown-menu {
  position: absolute;
  right: 0;
  top: calc(100% + 8px);
  z-index: 20;
  display: grid;
  gap: 6px;
  width: 150px;
  padding: 8px;
  border: 1px solid var(--border-strong);
  border-radius: 8px;
  background: var(--panel);
  box-shadow: 0 16px 40px rgba(20, 32, 45, 0.18);
}

.dropdown-menu[hidden] {
  display: none;
}

.dropdown-menu button {
  width: 100%;
  justify-content: flex-start;
  text-align: left;
}

:root[data-app-resolved-mode="dark"] .dropdown-menu button,
:root[data-app-theme="night"] .dropdown-menu button {
  color: #101722;
}

.workspace {
  display: grid;
  grid-template-columns: calc(156px + 2em) minmax(360px, 1fr) minmax(360px, 1fr);
  min-height: 0;
  flex: 1;
}

.workspace[data-sync-layout="editor-wide"] {
  grid-template-columns: calc(156px + 2em) minmax(420px, 1.14fr) minmax(340px, 0.86fr);
}

.workspace[data-sync-layout="preview-wide"] {
  grid-template-columns: calc(156px + 2em) minmax(340px, 0.9fr) minmax(420px, 1.1fr);
}

.sidebar,
.editor-pane,
.preview-pane {
  min-width: 0;
  min-height: 0;
  border-right: 1px solid var(--border);
  background: var(--panel);
}

.sidebar {
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

.sidebar-tabs {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr)) 34px;
  gap: 4px;
  padding: 5px 6px;
  border-bottom: 1px solid var(--border);
  background: var(--panel-soft);
}

.sidebar-tab {
  min-height: 30px;
  padding: 0 4px;
  border-color: transparent;
  background: transparent;
  color: var(--muted);
  font-size: 12px;
  font-weight: 700;
}

.settings-tab {
  font-size: 24px;
  line-height: 1;
}

.sidebar-tab.is-active {
  border-color: var(--accent);
  background: var(--panel);
  color: var(--accent-strong);
}

.sidebar-section {
  display: flex;
  flex-direction: column;
  min-height: 0;
  flex: 1;
  overflow-y: auto;
  padding: 12px;
}

.sidebar-section[hidden] {
  display: none;
}

.section-heading,
.document-bar,
.preview-toolbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
}

.section-heading h2 {
  margin: 0;
  font-size: 13px;
  font-weight: 700;
  letter-spacing: 0;
}

.icon-button {
  width: 32px;
  min-height: 32px;
  padding: 0;
}

.document-list,
.asset-list {
  display: grid;
  gap: 8px;
  margin-top: 10px;
}

.empty-state,
.document-entry,
.document-item,
.asset-item {
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 8px;
  background: var(--panel-soft);
}

.document-entry {
  display: grid;
  gap: 6px;
}

.document-item {
  display: grid;
  gap: 4px;
  text-align: left;
  width: 100%;
  padding: 0;
  border: 0;
  min-height: 0;
  opacity: 0.58;
  color: var(--muted);
  background: transparent;
  transition: opacity 120ms ease, border-color 120ms ease, background 120ms ease;
}

.document-entry.is-current {
  border-color: var(--accent);
  background: #e8f4f8;
  box-shadow: inset 3px 0 0 var(--accent);
}

.document-item.is-current {
  opacity: 1;
  color: var(--text);
}

.document-item:hover {
  opacity: 0.9;
}

.asset-item {
  display: grid;
  grid-template-columns: 1fr;
  gap: 5px;
  align-items: center;
}

.document-item strong {
  font-size: 13px;
  line-height: 1.3;
}

.document-published {
  display: inline-flex;
  width: fit-content;
  max-width: 100%;
  padding: 2px 6px;
  border: 1px solid rgba(23, 107, 135, 0.25);
  border-radius: 999px;
  color: var(--accent-strong);
  background: rgba(23, 107, 135, 0.08);
  overflow: hidden;
  text-overflow: ellipsis;
}

.document-item-actions {
  display: flex;
  justify-content: flex-end;
  min-width: 0;
}

.mini-danger-button {
  min-height: 26px;
  padding: 0 8px;
  font-size: 12px;
  border-radius: 5px;
}

.asset-item strong {
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  font-size: 13px;
  line-height: 1.3;
}

.asset-item .meta-text {
  grid-column: 1;
}

.asset-insert-button {
  grid-column: 1;
  grid-row: auto;
  min-height: 30px;
  padding: 0 8px;
}

.meta-text {
  color: var(--muted);
  font-size: 12px;
  white-space: nowrap;
}

.editor-pane {
  display: grid;
  grid-template-rows: 38px minmax(0, 1fr);
}

.document-bar {
  padding: 4px 8px;
  border-bottom: 1px solid var(--border);
  background: var(--panel);
}

.title-input {
  width: 100%;
  min-width: 0;
  min-height: 29px;
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 0 8px;
  font-size: 14px;
  font-weight: 700;
}

.storage-meter {
  color: var(--muted);
  font-size: 12px;
  white-space: nowrap;
}

.sidebar-actions,
.sidebar-export-list {
  display: grid;
  gap: 8px;
  margin-top: 10px;
}

.sidebar-action-button,
.sidebar-export-list button {
  width: 100%;
  min-width: 0;
  justify-content: flex-start;
  text-align: left;
  white-space: normal;
  overflow-wrap: anywhere;
  line-height: 1.25;
}

.sidebar-settings {
  display: grid;
  gap: 10px;
  margin-top: 10px;
}

.wordpress-site-manager,
.wordpress-site-form {
  display: grid;
  gap: 8px;
  min-width: 0;
}

.wordpress-site-form[hidden] {
  display: none;
}

.wordpress-credential-fields {
  display: grid;
  gap: 8px;
  min-width: 0;
}

.wordpress-credential-fields[hidden] {
  display: none;
}

.wordpress-site-actions {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 6px;
}

.wordpress-site-actions button {
  min-width: 0;
  min-height: 28px;
  padding: 0 6px;
  font-size: 12px;
}

.wordpress-site-summary {
  display: flex;
  align-items: center;
  min-width: 0;
  padding: 7px 8px;
  border: 1px solid rgba(23, 107, 135, 0.28);
  border-radius: 7px;
  background: rgba(23, 107, 135, 0.08);
}

.wordpress-site-summary[hidden] {
  display: none;
}

#wordpress-site-select-wrap[hidden] {
  display: none;
}

.wordpress-site-link {
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  color: var(--accent-strong);
  font-size: 13px;
  font-weight: 800;
  text-decoration: none;
}

.wordpress-site-link:hover {
  text-decoration: underline;
}

.sidebar-settings label,
.settings-fieldset {
  display: grid;
  gap: 5px;
  min-width: 0;
  margin: 0;
  padding: 0;
  border: 0;
  font-size: 12px;
  font-weight: 700;
}

.field-label-with-help {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 5px;
  width: 100%;
  min-width: 0;
}

.field-actions {
  display: inline-flex;
  align-items: center;
  justify-content: flex-end;
  gap: 4px;
  flex: 0 0 auto;
}

.field-hint {
  color: var(--muted);
  font-size: 11px;
  font-weight: 500;
  line-height: 1.45;
}

.term-heading {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  min-width: 0;
}

.term-count {
  flex: 0 0 auto;
  color: var(--muted);
  font-size: 11px;
  font-weight: 700;
}

.inline-help-button {
  display: inline-grid;
  place-items: center;
  width: 17px;
  height: 17px;
  min-height: 17px;
  padding: 0;
  border-radius: 999px;
  border-color: var(--border-strong);
  background: var(--panel-soft);
  color: var(--muted);
  font-size: 11px;
  font-weight: 800;
  line-height: 1;
}

.icon-mini-button {
  display: inline-grid;
  place-items: center;
  width: 21px;
  height: 21px;
  min-height: 21px;
  padding: 0;
  border-radius: 6px;
  border-color: var(--border-strong);
  background: var(--panel-soft);
  color: var(--muted);
  font-size: 13px;
  line-height: 1;
}

.icon-mini-button:hover,
.icon-mini-button:focus-visible {
  border-color: var(--accent);
  color: var(--accent-strong);
  background: var(--panel);
}

.inline-help-button:hover,
.inline-help-button:focus-visible {
  border-color: var(--accent);
  color: var(--accent-strong);
  background: var(--panel);
}

.floating-help-tooltip {
  position: fixed;
  z-index: 80;
  width: min(300px, calc(100vw - 24px));
  padding: 10px 12px;
  border: 1px solid var(--border-strong);
  border-radius: 8px;
  background: var(--panel);
  color: var(--text);
  box-shadow: 0 18px 42px rgba(20, 32, 45, 0.22);
  font-size: 12px;
  font-weight: 600;
  line-height: 1.5;
}

.floating-help-tooltip[hidden] {
  display: none;
}

.floating-help-tooltip p {
  margin: 0 0 8px;
}

.floating-help-tooltip a {
  color: var(--accent-strong);
  overflow-wrap: anywhere;
}

.sidebar-settings input,
.sidebar-settings select,
.sidebar-settings textarea {
  width: 100%;
  min-width: 0;
  border: 1px solid var(--border);
  border-radius: 6px;
  background: var(--panel);
}

.sidebar-settings input,
.sidebar-settings select {
  min-height: 32px;
  padding: 0 8px;
}

.sidebar-settings textarea {
  min-height: 88px;
  padding: 7px 8px;
  line-height: 1.45;
  resize: vertical;
}

.compact-settings-panel {
  display: grid;
  gap: 6px;
  padding: 8px;
  border: 1px solid var(--border);
  border-radius: 6px;
  background: var(--panel-soft);
}

.compact-settings-panel[hidden] {
  display: none;
}

.sidebar-settings select[multiple] {
  min-height: 104px;
  padding: 4px;
}

.term-cloud {
  display: flex;
  flex-wrap: wrap;
  gap: 5px;
  min-width: 0;
}

.term-chip {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 24px;
  max-width: 100%;
  padding: 3px 7px;
  border-radius: 999px;
  border-color: var(--border);
  background: var(--panel-soft);
  color: var(--muted);
  font-size: 11px;
  line-height: 1.2;
  text-align: center;
  overflow-wrap: anywhere;
}

.term-chip-label {
  display: block;
  max-width: 100%;
}

.term-chip.is-compact-cjk .term-chip-label {
  max-width: 2.25em;
  word-break: break-all;
}

.term-chip.is-selected {
  border-color: var(--accent);
  background: rgba(23, 107, 135, 0.13);
  color: var(--accent-strong);
}

.settings-fieldset legend {
  padding: 0;
  margin-bottom: 4px;
  font-weight: 700;
}

.appearance-theme-picker {
  display: flex;
  align-items: center;
  gap: 7px;
  flex-wrap: wrap;
  min-width: 0;
  margin: 0;
  padding: 8px 0 0;
  border: 0;
  font-size: 12px;
  font-weight: 700;
}

.appearance-theme-picker legend {
  width: 100%;
  padding: 0;
  margin-bottom: 2px;
}

.appearance-theme-swatch,
.reader-theme-swatch {
  width: 28px;
  min-width: 28px;
  height: 28px;
  min-height: 28px;
  padding: 0;
  border: 2px solid var(--border);
  border-radius: 999px;
  box-shadow: inset 0 0 0 2px rgba(255, 255, 255, 0.55);
}

.appearance-theme-swatch[data-app-theme="white"],
.reader-theme-swatch[data-reader-theme="white"] {
  background: #f8f9fb;
}

.appearance-theme-swatch[data-app-theme="warm"],
.reader-theme-swatch[data-reader-theme="warm"] {
  background: #fff6e7;
}

.appearance-theme-swatch[data-app-theme="paper"],
.reader-theme-swatch[data-reader-theme="paper"] {
  background: #fff3bd;
}

.appearance-theme-swatch[data-app-theme="mint"],
.reader-theme-swatch[data-reader-theme="mint"] {
  background: #e9faea;
}

.appearance-theme-swatch[data-app-theme="blue"],
.reader-theme-swatch[data-reader-theme="blue"] {
  background: #e9f8fc;
}

.appearance-theme-swatch[data-app-theme="night"],
.reader-theme-swatch[data-reader-theme="night"] {
  background: #111827;
}

.appearance-theme-swatch.is-active,
.reader-theme-swatch.is-active {
  border-color: #c84332;
  outline: 4px solid rgba(200, 67, 50, 0.18);
}

.appearance-theme-swatch.is-active::after,
.reader-theme-swatch.is-active::after {
  content: "✓";
  display: grid;
  place-items: center;
  width: 100%;
  height: 100%;
  color: #c84332;
  font-size: 18px;
  font-weight: 800;
}

.appearance-theme-swatch[data-app-theme="night"].is-active::after,
.reader-theme-swatch[data-reader-theme="night"].is-active::after {
  color: #f5d46f;
}

.radio-row {
  grid-template-columns: 16px 1fr;
  align-items: start;
  font-weight: 500;
  line-height: 1.35;
}

.radio-row input {
  min-height: 16px;
  margin: 1px 0 0;
  padding: 0;
}

#editor {
  min-height: 0;
  width: 100%;
  height: 100%;
  overflow: hidden;
}

.preview-pane {
  display: grid;
  grid-template-rows: 34px minmax(0, 1fr);
  border-right: 0;
}

.preview-toolbar {
  display: grid;
  grid-template-columns: 1fr auto auto;
  align-items: center;
  min-height: 34px;
  padding: 3px 8px;
  border-bottom: 1px solid var(--border);
  background: var(--panel-soft);
  font-weight: 700;
  font-size: 12px;
}

.preview-toolbar-left {
  display: flex;
  align-items: center;
  gap: 8px;
  min-width: 0;
  flex-wrap: wrap;
}

.sync-scroll-toggle,
.sync-layout-control {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  color: var(--muted);
  font-weight: 600;
  white-space: nowrap;
}

.sync-scroll-toggle input {
  margin: 0;
}

.sync-layout-control select {
  min-height: 26px;
  max-width: 92px;
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 0 6px;
  background: var(--panel);
  color: var(--text);
}

.preview-fullscreen-button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 30px;
  height: 28px;
  min-height: 28px;
  padding: 0;
  line-height: 1;
}

.fullscreen-icon {
  width: 17px;
  height: 17px;
  display: block;
  flex: 0 0 auto;
  fill: none;
  stroke: currentColor;
  stroke-width: 2;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.preview-output {
  min-width: 0;
  overflow: auto;
  padding: 28px 34px 80px;
  background: var(--panel);
}

.markdown-body {
  color: var(--text);
  background-color: var(--panel);
}

.markdown-body h1,
.markdown-body h2 {
  border-bottom: 0;
}

.publication-byline {
  margin: 0.25em 0 1.8em;
  color: var(--muted);
  font-size: 1em;
  text-align: right;
}

.markdown-body img {
  background-color: transparent;
}

.markdown-body blockquote {
  color: var(--muted);
  border-left-color: var(--border);
}

.markdown-body hr {
  background-color: var(--border);
}

.markdown-body table tr {
  background-color: var(--panel);
  border-top-color: var(--border);
}

.markdown-body table tr:nth-child(2n) {
  background-color: var(--panel-soft);
}

.markdown-body table th,
.markdown-body table td {
  border-color: var(--border);
}

.markdown-body code,
.markdown-body tt,
.markdown-body pre {
  background-color: var(--panel-soft);
}

:root[data-app-resolved-mode="dark"] .markdown-body a,
:root[data-app-theme="night"] .markdown-body a {
  color: #8ecfff;
}

.preview-output img {
  max-width: 100%;
  height: auto;
}

.reader-overlay {
  position: fixed;
  inset: 0;
  z-index: 100;
  display: block;
  overflow-y: auto;
  overscroll-behavior: contain;
  --reader-page-bg: #ede7d8;
  --reader-surface: #fffdf7;
  --reader-text: #1d2733;
  --reader-muted: #6f6659;
  --reader-border: #ded4c2;
  --reader-toolbar-bg: rgba(255, 253, 247, 0.96);
  --reader-shadow: 0 1px 2px rgba(42, 35, 25, 0.08);
  background: var(--reader-page-bg);
  color: var(--reader-text);
}

.reader-overlay[data-reader-theme="white"] {
  --reader-page-bg: #e8e5dc;
  --reader-surface: #fbfbfc;
  --reader-border: #d8d6cf;
}

.reader-overlay[data-reader-theme="warm"] {
  --reader-page-bg: #ede6d8;
  --reader-surface: #fffaf1;
  --reader-border: #ded3c0;
}

.reader-overlay[data-reader-theme="paper"] {
  --reader-page-bg: #efe8cf;
  --reader-surface: #fffbe8;
  --reader-border: #ded5ad;
}

.reader-overlay[data-reader-theme="mint"] {
  --reader-page-bg: #e3ebdf;
  --reader-surface: #f4fff4;
  --reader-border: #cddfca;
}

.reader-overlay[data-reader-theme="blue"] {
  --reader-page-bg: #e0eaed;
  --reader-surface: #f3fcff;
  --reader-border: #c9dce2;
}

.reader-overlay[data-reader-theme="night"],
.reader-overlay[data-reader-resolved-mode="dark"] {
  --reader-page-bg: #0f1420;
  --reader-surface: #151b28;
  --reader-text: #e9edf5;
  --reader-muted: #aab3c2;
  --reader-border: #2b3445;
  --reader-toolbar-bg: rgba(21, 27, 40, 0.96);
  --reader-shadow: 0 1px 2px rgba(0, 0, 0, 0.35);
}

.reader-overlay[data-reader-resolved-mode="dark"][data-reader-theme="white"] {
  --reader-page-bg: #111827;
  --reader-surface: #1c2432;
  --reader-border: #354052;
}

.reader-overlay[data-reader-resolved-mode="dark"][data-reader-theme="warm"],
.reader-overlay[data-reader-resolved-mode="dark"][data-reader-theme="paper"] {
  --reader-page-bg: #201b13;
  --reader-surface: #292319;
  --reader-border: #4d4230;
}

.reader-overlay[data-reader-resolved-mode="dark"][data-reader-theme="mint"] {
  --reader-page-bg: #101b18;
  --reader-surface: #172620;
  --reader-border: #294239;
}

.reader-overlay[data-reader-resolved-mode="dark"][data-reader-theme="blue"] {
  --reader-page-bg: #101922;
  --reader-surface: #172535;
  --reader-border: #2b4256;
}

.reader-overlay[hidden] {
  display: none;
}

.reader-toolbar {
  position: sticky;
  top: 0;
  z-index: 2;
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
  padding: 10px 14px;
  border-bottom: 1px solid var(--reader-border);
  background: var(--reader-toolbar-bg);
  box-shadow: var(--reader-shadow);
}

.reader-toolbar button,
.reader-toolbar select {
  min-height: 34px;
  border-color: var(--reader-border);
  background: var(--reader-surface);
  color: var(--reader-text);
}

.reader-toolbar label {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  color: var(--reader-muted);
  font-size: 13px;
  font-weight: 700;
}

.reader-theme-picker {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  min-width: 0;
  margin: 0;
  padding: 0;
  border: 0;
}

.reader-theme-picker legend {
  padding: 0;
  color: var(--reader-muted);
  font-size: 13px;
  font-weight: 700;
}

.reader-theme-swatch {
  border: 2px solid var(--reader-border);
}

.reader-export-dropdown {
  margin-left: auto;
}

.reader-output {
  box-sizing: border-box;
  width: min(794px, calc(100vw - 32px));
  min-width: 0;
  margin: 24px auto 42px;
  padding: 0;
  display: grid;
  gap: 22px;
  overflow: visible;
  border: 0;
  border-radius: 0;
  background: transparent;
  color: var(--reader-text);
  font-size: var(--reader-font-size, 18px);
  line-height: 1.85;
  font-family: var(--reader-font-family, "LXGW WenKai TC", "Noto Serif TC", "Noto Sans TC", serif);
}

.reader-page {
  box-sizing: border-box;
  width: min(794px, calc(100vw - 32px));
  min-height: 1123px;
  display: grid;
  grid-template-rows: 64px minmax(0, 987px) 72px;
  border: 1px solid var(--reader-border);
  border-radius: 2px;
  background: var(--reader-surface);
  color: var(--reader-text);
  box-shadow: var(--reader-shadow);
}

.reader-page-header,
.reader-page-footer {
  min-width: 0;
}

.reader-page-body {
  width: min(var(--reader-width, 800px), calc(100% - 136px));
  min-width: 0;
  max-width: min(var(--reader-width, 800px), 100%);
  margin-left: auto;
  margin-right: auto;
  overflow: visible;
}

.reader-page-body > pre,
.reader-page-body > table,
.reader-page-body > blockquote,
.reader-page-body > ul,
.reader-page-body > ol {
  width: min(var(--reader-width, 800px), 100%);
}

.reader-page-footer {
  display: flex;
  align-items: flex-start;
  justify-content: center;
  padding-top: 18px;
  color: var(--reader-muted);
  font-size: 12px;
}

.reader-output[data-reader-font="serif"] {
  font-family: "Noto Serif TC", "Source Han Serif TC", "Songti TC", serif;
}

.reader-output[data-reader-font="sans"] {
  font-family: "Noto Sans TC", "PingFang TC", "Microsoft JhengHei", sans-serif;
}

.reader-output[data-reader-font="kai"] {
  font-family: "LXGW WenKai TC", "Kaiti TC", "BiauKai", "Noto Serif TC", serif;
}

.reader-output img {
  max-width: 100%;
  height: auto;
}

.settings-dialog {
  width: min(560px, calc(100vw - 28px));
  border: 1px solid var(--border-strong);
  border-radius: 8px;
  padding: 0;
  box-shadow: 0 20px 55px rgba(20, 32, 45, 0.25);
}

.settings-dialog::backdrop {
  background: rgba(20, 32, 45, 0.35);
}

.settings-form {
  display: grid;
  gap: 14px;
  padding: 16px;
}

.settings-form header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  border-bottom: 1px solid var(--border);
  padding-bottom: 10px;
}

.settings-form h2 {
  margin: 0;
  font-size: 18px;
}

.settings-form label {
  display: grid;
  gap: 6px;
  font-size: 13px;
  font-weight: 700;
}

.settings-form input,
.settings-form select {
  width: 100%;
  min-height: 36px;
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 0 10px;
  background: var(--panel);
  color: var(--text);
}

.check-row {
  grid-template-columns: 18px 1fr;
  align-items: start;
  font-weight: 500;
}

.check-row input {
  width: 16px;
  min-height: 16px;
  margin: 2px 0 0;
}

.warning-text {
  margin: 0;
  color: var(--danger);
  font-size: 12px;
  line-height: 1.45;
}

.preflight-panel {
  display: grid;
  gap: 8px;
  min-width: 0;
  padding: 10px 0;
  border-top: 1px solid var(--border);
  border-bottom: 1px solid var(--border);
}

.preflight-panel h3 {
  margin: 0;
  font-size: 13px;
  line-height: 1.3;
}

.preflight-list {
  display: grid;
  gap: 6px;
  margin: 0;
  padding: 0;
  list-style: none;
}

.preflight-item {
  display: grid;
  grid-template-columns: 28px 1fr;
  gap: 6px;
  align-items: start;
  min-width: 0;
  color: var(--muted);
  font-size: 12px;
  line-height: 1.35;
}

.preflight-marker {
  display: inline-grid;
  place-items: center;
  min-width: 24px;
  height: 20px;
  border-radius: 999px;
  border: 1px solid var(--border);
  font-size: 10px;
  font-weight: 800;
  line-height: 1;
}

.preflight-item.is-ok .preflight-marker {
  border-color: rgba(23, 107, 135, 0.35);
  color: var(--accent-strong);
  background: rgba(23, 107, 135, 0.08);
}

.preflight-item.is-warn .preflight-marker {
  border-color: rgba(163, 116, 47, 0.45);
  color: #7a551b;
  background: rgba(190, 139, 57, 0.12);
}

.preflight-item.is-error .preflight-marker {
  border-color: rgba(163, 59, 47, 0.45);
  color: var(--danger);
  background: rgba(163, 59, 47, 0.1);
}

.storage-detail-panel {
  display: grid;
  gap: 8px;
  min-width: 0;
  padding: 10px 0;
  border-bottom: 1px solid var(--border);
}

.panel-title-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  min-width: 0;
}

.panel-title-row h3 {
  margin: 0;
  font-size: 13px;
  line-height: 1.3;
}

.mini-plain-button {
  min-width: 0;
  min-height: 26px;
  padding: 0 8px;
  border-radius: 5px;
  font-size: 12px;
  line-height: 1.25;
  white-space: normal;
  overflow-wrap: anywhere;
}

.storage-detail-list {
  display: grid;
  gap: 6px;
  margin: 0;
}

.storage-detail-list div {
  display: grid;
  grid-template-columns: minmax(64px, auto) minmax(0, 1fr);
  gap: 8px;
  min-width: 0;
}

.storage-detail-list dt {
  color: var(--muted);
  font-size: 11px;
  font-weight: 700;
}

.storage-detail-list dd {
  min-width: 0;
  margin: 0;
  font-size: 12px;
  font-weight: 600;
  overflow: hidden;
  text-overflow: ellipsis;
  text-align: right;
}

.storage-backup-actions {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 8px;
}

.publish-result-panel {
  display: grid;
  gap: 8px;
  min-width: 0;
  margin-top: 4px;
  padding-top: 10px;
  border-top: 1px solid var(--border);
}

.publish-result-panel h3 {
  margin: 0;
  font-size: 13px;
  line-height: 1.3;
}

.publish-empty-text {
  margin: 0;
  min-width: 0;
  color: var(--muted);
  font-size: 12px;
  line-height: 1.45;
  white-space: normal;
  overflow-wrap: anywhere;
}

.publish-result-panel dl {
  display: grid;
  gap: 6px;
  margin: 0;
}

.publish-result-panel dl[hidden] {
  display: none;
}

.publish-result-panel div {
  display: grid;
  gap: 2px;
  min-width: 0;
}

.publish-result-panel dt {
  color: var(--muted);
  font-size: 11px;
  font-weight: 700;
}

.publish-result-panel dd {
  min-width: 0;
  margin: 0;
  font-size: 12px;
  font-weight: 600;
  overflow: hidden;
  text-overflow: ellipsis;
}

.publish-result-panel a {
  color: var(--accent-strong);
  text-decoration: none;
  overflow-wrap: anywhere;
}

.publish-result-panel a:hover {
  text-decoration: underline;
}

.publish-open-button {
  justify-self: start;
  width: auto;
  max-width: 100%;
  min-height: 28px;
  padding: 0 9px;
  font-size: 12px;
  line-height: 1.2;
}

.publish-result-panel button:disabled {
  opacity: 0.55;
  cursor: not-allowed;
}

.settings-form menu {
  display: flex;
  justify-content: flex-end;
  gap: 8px;
  margin: 0;
  padding: 0;
}

.status {
  position: fixed;
  left: 50%;
  bottom: 18px;
  transform: translateX(-50%);
  max-width: min(560px, calc(100vw - 28px));
  padding: 9px 12px;
  border-radius: 6px;
  background: rgba(29, 39, 51, 0.92);
  color: #fff;
  font-size: 13px;
  opacity: 0;
  pointer-events: none;
  transition: opacity 160ms ease;
}

.status.is-visible {
  opacity: 1;
}

@media (max-width: 900px) {
  .workspace,
  .workspace[data-sync-layout="editor-wide"],
  .workspace[data-sync-layout="preview-wide"] {
    grid-template-columns: 1fr;
    grid-template-rows: minmax(360px, 1fr) minmax(320px, 1fr);
    overflow-y: auto;
  }

  .sidebar {
    display: none;
  }
}

@media (max-width: 760px) {
  .app-header {
    align-items: stretch;
    flex-direction: column;
  }

  .header-actions {
    width: 100%;
  }

  .tool-button {
    flex: 1;
  }

  .dropdown {
    flex: 1;
  }

  .dropdown-trigger {
    width: 100%;
  }

  .workspace {
    grid-template-columns: 1fr;
  }
}
