/* Markdown editor (/personal/markdown). Uses the site tokens from taste.css
   (--bg, --surface, --surface-alt, --ink, --muted, --line, --action) so it sits
   in the same light and dark palette as Travel and Gallery. One accent
   (--action), one radius scale (6px controls, 12px dialogs), one button pair
   (.btn / .btn--primary from the shared motion layer). */

.md-shell { width: min(100% - 2 * var(--gut), 1600px); margin: auto; min-height: 100svh; display: flex; flex-direction: column; }
.md-shell .site-header { flex-shrink: 0; }
.md-sprite { position: absolute; width: 0; height: 0; overflow: hidden; }
.md-icon { width: 18px; height: 18px; flex: none; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }
.md-shell [hidden] { display: none !important; }

:root { --md-ok: #2f8a5f; --md-warn: #b0741c; --md-bad: #c0434b; --md-hover: color-mix(in srgb, var(--ink) 7%, transparent); --md-current: color-mix(in srgb, var(--action) 12%, transparent); }
html[data-theme="dark"] { --md-ok: #6cc79a; --md-warn: #e0b06a; --md-bad: #f08a90; }

/* ---------- workspace frame ---------- */
.md-app { background: color-mix(in srgb, var(--bg) 86%, transparent);
  flex: 1; display: grid; grid-template-columns: 272px minmax(0, 1fr); min-height: 0; height: calc(100svh - 89px); min-height: 560px; }
.md-app[data-sidebar="closed"] { grid-template-columns: 0 minmax(0, 1fr); }
.md-app[data-sidebar="closed"] .md-sidebar { visibility: hidden; }

/* ---------- buttons owned by the editor ---------- */
.md-icon-btn, .md-tool, .md-text-btn, .md-view-btn, .md-folder-toggle, .md-doc-link {
  -webkit-tap-highlight-color: transparent;
  transition: background-color 120ms var(--ease), color 120ms var(--ease), border-color 120ms var(--ease);
}
.md-icon-btn { display: inline-grid; place-items: center; width: 36px; height: 36px; padding: 0; border: 1px solid transparent; border-radius: 6px; background: transparent; color: var(--ink); }
.md-icon-btn--sm { width: 30px; height: 30px; }
.md-icon-btn--sm .md-icon { width: 16px; height: 16px; }
.md-text-btn { display: inline-flex; align-items: center; gap: 6px; min-height: 32px; padding: 4px 8px; border: 0; border-radius: 6px; background: transparent; color: var(--action); font-size: 13px; }
@media (hover: hover) and (pointer: fine) {
  .md-icon-btn:hover, .md-tool:hover, .md-text-btn:hover, .md-folder-toggle:hover, .md-doc-link:hover, .md-view-btn:hover:not([aria-pressed="true"]) { background: var(--md-hover); transition-duration: 150ms; }
}
@media (prefers-reduced-motion: no-preference) {
  .md-icon-btn:active, .md-tool:active, .md-text-btn:active, .md-view-btn:active { transform: translateY(1px) scale(.985); transition: transform 90ms var(--ease); }
}
.md-icon-btn:focus-visible, .md-tool:focus-visible, .md-text-btn:focus-visible, .md-view-btn:focus-visible, .md-folder-toggle:focus-visible, .md-doc-link:focus-visible { outline: 2px solid var(--action); outline-offset: 2px; }
.btn .md-icon { margin-right: 8px; }

/* ---------- sidebar ---------- */
.md-sidebar { min-width: 0; overflow: hidden auto; display: flex; flex-direction: column; padding: 20px 16px 24px 0; border-right: 1px solid var(--line); }
.md-sidebar-head { display: flex; align-items: center; justify-content: space-between; gap: 8px; min-height: 36px; margin-bottom: 8px; }
.md-sidebar-head h2 { margin: 0; font-size: 13px; font-weight: 500; color: var(--muted); }
.md-sidebar-actions { display: flex; gap: 2px; }
.md-drawer-close { display: none !important; }
.md-tree, .md-docs { list-style: none; margin: 0; padding: 0; }
.md-folder + .md-folder { margin-top: 4px; }
.md-folder-row, .md-doc-item { position: relative; display: flex; align-items: center; border-radius: 6px; }
.md-folder-toggle { flex: 1; min-width: 0; display: flex; align-items: center; gap: 8px; min-height: 38px; padding: 0 8px 0 4px; border: 0; border-radius: 6px; background: transparent; color: var(--ink); font-size: 14px; font-weight: 600; text-align: left; }
.md-folder-toggle .md-icon:first-child { width: 14px; height: 14px; color: var(--muted); }
@media (prefers-reduced-motion: no-preference) { .md-folder-toggle .md-icon:first-child { transition: transform 150ms var(--ease); } }
.md-folder-toggle[aria-expanded="true"] .md-icon:first-child { transform: rotate(90deg); }
.md-folder-toggle .md-icon:nth-child(2) { color: var(--muted); }
.md-folder-name, .md-doc-link span { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.md-count { margin-left: auto; font-size: 12px; font-weight: 500; color: var(--muted); font-variant-numeric: tabular-nums; }
.md-docs { margin: 2px 0 6px 22px; padding-left: 8px; border-left: 1px solid var(--line); }
.md-doc-link { flex: 1; min-width: 0; display: flex; align-items: center; gap: 8px; min-height: 34px; padding: 0 8px; border-radius: 6px; color: var(--ink); font-size: 14px; }
.md-doc-link .md-icon { width: 16px; height: 16px; color: var(--muted); }
.md-doc-item.is-current .md-doc-link { background: var(--md-current); font-weight: 600; }
.md-doc-item.is-current .md-doc-link .md-icon { color: var(--action); }
.md-doc-item.is-current::before { content: ''; position: absolute; left: -9px; top: 6px; bottom: 6px; width: 2px; border-radius: 2px; background: var(--action); }
.md-row-actions { position: absolute; right: 2px; top: 50%; translate: 0 -50%; display: flex; gap: 0; }
@media (hover: hover) and (pointer: fine) {
  .md-row-actions { opacity: 0; }
  .md-folder-row:hover .md-row-actions, .md-folder-row:focus-within .md-row-actions, .md-doc-item:hover .md-row-actions, .md-doc-item:focus-within .md-row-actions { opacity: 1; }
  .md-folder-row:hover .md-count, .md-folder-row:focus-within .md-count { visibility: hidden; }
  /* Room for the row's buttons, so a long name ends in an ellipsis before them
     instead of running under them (the current row keeps its tint). */
  .md-folder-row:is(:hover, :focus-within) .md-folder-toggle { padding-right: 96px; }
  .md-doc-item:is(:hover, :focus-within) .md-doc-link { padding-right: 66px; }
}
@media (pointer: coarse) {
  .md-row-actions { position: static; translate: none; background: none; padding: 0; }
  .md-count { display: none; }
  .md-folder-toggle, .md-doc-link { min-height: 44px; }
  .md-icon-btn, .md-icon-btn--sm { width: 44px; height: 44px; }
}
.md-docs-empty { padding: 4px 0; font-size: 13px; color: var(--muted); }
.md-docs-empty > span { display: block; padding: 6px 8px; }
.md-tree-note { margin: 8px 4px; font-size: 13px; color: var(--muted); }
.md-tree-empty { padding: 8px 4px; }
.md-tree-empty p { margin: 0 0 12px; font-size: 14px; color: var(--muted); line-height: 1.6; }
.md-readonly-note { margin: auto 4px 0; padding-top: 16px; font-size: 12.5px; color: var(--muted); line-height: 1.6; }
.md-scrim { display: none; }

/* ---------- workspace ---------- */
.md-workspace { min-width: 0; min-height: 0; display: flex; flex-direction: column; padding-left: 24px; }
.md-app[data-sidebar="closed"] .md-workspace { padding-left: 0; }
.md-titlebar { display: flex; align-items: center; gap: 12px; min-height: 76px; padding: 12px 0; }
.md-heading { flex: 1; min-width: 0; }
.md-crumb { display: flex; align-items: center; gap: 6px; margin: 0 0 2px; font-size: 13px; line-height: 1.4; color: var(--muted); white-space: nowrap; overflow: hidden; }
.md-crumb a { color: inherit; }
.md-crumb a:hover { color: var(--ink); text-decoration: underline; text-underline-offset: 3px; }
.md-crumb span:last-child { overflow: hidden; text-overflow: ellipsis; }
.md-heading h1 { margin: 0; font-size: 22px; font-weight: 600; line-height: 1.3; letter-spacing: -.02em; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.md-title-actions { display: flex; align-items: center; gap: 12px; flex: none; }
.md-save { display: inline-flex; align-items: center; gap: 6px; margin: 0; min-width: 64px; font-size: 13px; color: var(--muted); white-space: nowrap; }
.md-save-dot { width: 6px; height: 6px; border-radius: 50%; background: transparent; }
.md-save[data-save-state="saved"] .md-save-dot { background: var(--md-ok); }
.md-save[data-save-state="saving"] .md-save-dot { background: var(--muted); }
.md-save[data-save-state="error"] { color: var(--md-bad); }
.md-save[data-save-state="error"] .md-save-dot { background: var(--md-bad); }
.md-save[data-save-state="conflict"] { color: var(--md-warn); }
.md-save[data-save-state="conflict"] .md-save-dot { background: var(--md-warn); }
.md-save[data-save-state="idle"] .md-save-dot { display: none; }
.md-app:not([data-state="document"]) .md-views { display: none; }
.md-views { display: inline-flex; padding: 3px; border: 1px solid var(--line); border-radius: 8px; }
/* Icon-only segments; the Korean label is the accessible name and shows as a
   tooltip on hover and keyboard focus (it repeats the name, so no aria link). */
.md-view-btn { position: relative; display: inline-grid; place-items: center; width: 36px; min-height: 32px; padding: 0; border: 0; border-radius: 5px; background: transparent; color: var(--muted); }
.md-view-btn .md-icon { width: 17px; height: 17px; }
.md-view-btn[aria-pressed="true"] { background: var(--ink); color: var(--bg); }
.md-view-btn::after { content: attr(data-tip); position: absolute; z-index: 20; top: calc(100% + 8px); left: 50%; translate: -50% -2px; padding: 5px 8px; border-radius: 6px; background: var(--ink); color: var(--bg); font-size: 12px; font-weight: 500; line-height: 1.3; white-space: nowrap; pointer-events: none; opacity: 0; visibility: hidden; }
.md-view-btn:focus-visible::after { opacity: 1; visibility: visible; translate: -50% 0; }
@media (hover: hover) and (pointer: fine) { .md-view-btn:hover::after { opacity: 1; visibility: visible; translate: -50% 0; transition-delay: 350ms; } }
@media (prefers-reduced-motion: no-preference) { .md-view-btn::after { transition: opacity 120ms var(--ease), translate 120ms var(--ease), visibility 0s linear 120ms; } .md-view-btn:is(:hover, :focus-visible)::after { transition: opacity 120ms var(--ease) 350ms, translate 120ms var(--ease) 350ms, visibility 0s linear 350ms; } }

/* ---------- theme picker ---------- */
.md-app:not([data-state="document"]) .md-theme-control { display: none; }
.md-theme-trigger { display: inline-flex; align-items: center; gap: 8px; min-height: 40px; max-width: 220px; padding: 0 8px 0 6px; border: 1px solid var(--line); border-radius: 8px; background: transparent; color: var(--ink); font-size: 13px; font-weight: 500; -webkit-tap-highlight-color: transparent; transition: background-color 120ms var(--ease), border-color 120ms var(--ease); }
.md-theme-trigger > .md-icon { width: 15px; height: 15px; color: var(--muted); }
@media (prefers-reduced-motion: no-preference) { .md-theme-trigger > .md-icon { transition: rotate 150ms var(--ease); } }
.md-theme-trigger[aria-expanded="true"] > .md-icon { rotate: 180deg; }
.md-theme-trigger-name { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
@media (hover: hover) and (pointer: fine) { .md-theme-trigger:hover { background: var(--md-hover); } }
@media (prefers-reduced-motion: no-preference) { .md-theme-trigger:active { transform: translateY(1px) scale(.985); transition: transform 90ms var(--ease); } }
.md-theme-trigger:focus-visible { outline: 2px solid var(--action); outline-offset: 2px; }
/* A two-tone chip of the current theme: its page colour with a line of its text colour. */
.md-theme-chip { flex: none; width: 26px; height: 26px; overflow: hidden; border: 1px solid var(--line); border-radius: 6px; }
.md-theme-chip > .md-doc[data-md-theme] { display: block; width: 100%; height: 100%; padding: 0 !important; border-radius: 0; box-shadow: none; }
.md-theme-chip > .md-doc[data-md-theme]::before { content: 'Aa'; display: grid; place-items: center; height: 100%; font-size: 11px; font-weight: 600; line-height: 1; }
.md-app[data-preview-themed="false"] .md-theme-chip { opacity: .55; }

.md-theme-panel { width: min(380px, calc(100vw - 24px)); max-height: min(72dvh, 560px); padding: 0; border: 1px solid var(--line); border-radius: 12px; background: var(--surface); color: var(--ink); box-shadow: 0 18px 48px #00000030; overscroll-behavior: contain; }
.md-theme-panel:popover-open { display: flex; flex-direction: column; }
@supports (position-area: block-end) {
  .md-theme-panel { inset: auto; margin: 8px 0 0; position-area: block-end span-inline-start; position-try-fallbacks: flip-inline, flip-block; }
}
@media (prefers-reduced-motion: no-preference) {
  .md-theme-panel { transform-origin: top right; transition: opacity 140ms var(--ease), scale 140ms var(--ease), overlay 140ms allow-discrete, display 140ms allow-discrete; }
  @starting-style { .md-theme-panel:popover-open { opacity: 0; scale: .97; } }
}
.md-theme-panel-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 14px 16px 6px; }
.md-theme-panel-head h2 { margin: 0; font-size: 15px; font-weight: 600; letter-spacing: -.01em; }
.md-theme-panel-note { margin: 0; padding: 0 16px 10px; border-bottom: 1px solid var(--line); font-size: 12.5px; line-height: 1.5; color: var(--muted); word-break: keep-all; }
.md-theme-panel .md-theme-list { flex: 1; min-height: 0; overflow: auto; padding: 8px; }

/* A switch built on a native checkbox (role=switch keeps the on/off semantics). */
.md-switch { display: inline-flex; align-items: center; gap: 8px; min-height: 32px; font-size: 13px; color: var(--muted); cursor: pointer; white-space: nowrap; }
.md-switch input { appearance: none; position: relative; flex: none; width: 32px; height: 18px; margin: 0; border-radius: 999px; background: color-mix(in srgb, var(--ink) 22%, transparent); cursor: pointer; transition: background-color 150ms var(--ease); }
.md-switch input::after { content: ''; position: absolute; top: 2px; left: 2px; width: 14px; height: 14px; border-radius: 50%; background: var(--surface); box-shadow: 0 1px 2px #0003; transition: translate 150ms var(--ease); }
.md-switch input:checked { background: var(--action); }
.md-switch input:checked::after { translate: 14px 0; }
.md-switch input:focus-visible { outline: 2px solid var(--action); outline-offset: 2px; }
@media (prefers-reduced-motion: reduce) { .md-switch input, .md-switch input::after { transition: none; } }
@media (forced-colors: active) { .md-switch input { border: 1px solid CanvasText; } .md-switch input:checked { background: Highlight; } }

/* ---------- theme list (picker and PDF dialog) ---------- */
.md-theme-list { --tile-w: 68px; display: grid; gap: 2px; margin: 0; padding: 0; border: 0; min-width: 0; }
.md-theme-family { display: grid; grid-template-columns: minmax(0, 1fr) var(--tile-w) var(--tile-w); align-items: center; column-gap: 10px; padding: 6px 8px 6px 10px; border-radius: 8px; }
.md-theme-family:has(:checked) { background: var(--md-current); }
.md-theme-family-name { grid-column: 1; grid-row: 1; min-width: 0; font-size: 14px; font-weight: 500; line-height: 1.35; word-break: keep-all; }
.md-theme-family:has(:checked) .md-theme-family-name { font-weight: 600; }
.md-theme-tile { position: relative; grid-row: 1; display: grid; justify-items: center; gap: 4px; cursor: pointer; }
.md-theme-tile[data-variant="light"] { grid-column: 2; }
.md-theme-tile[data-variant="dark"] { grid-column: 3; }
.md-theme-tile[data-variant="single"] { grid-column: 2 / span 2; justify-self: end; }
.md-theme-tile input { position: absolute; inset: 0; width: 100%; height: 100%; margin: 0; opacity: 0; cursor: pointer; }
.md-theme-sample { display: block; width: var(--tile-w); height: 44px; overflow: hidden; border: 1px solid var(--line); border-radius: 6px; background: var(--surface-alt); transition: box-shadow 120ms var(--ease), translate 120ms var(--ease); }
.md-theme-tile:has(:checked) .md-theme-sample { border-color: transparent; box-shadow: 0 0 0 2px var(--action); }
.md-theme-tile:has(:focus-visible) .md-theme-sample { box-shadow: 0 0 0 2px var(--surface), 0 0 0 4px var(--action); }
@media (hover: hover) and (pointer: fine) {
  .md-theme-family:hover:not(:has(:checked)) { background: var(--md-hover); }
  .md-theme-tile:hover .md-theme-sample { translate: 0 -1px; }
}
@media (prefers-reduced-motion: reduce) { .md-theme-sample { transition: none; } .md-theme-tile:hover .md-theme-sample { translate: none; } }
.md-theme-sample > .md-doc[data-md-theme] { display: block; height: 100%; padding: 6px 8px !important; font-size: 9.5px; line-height: 1.35; border-radius: 0; box-shadow: none; overflow: hidden; }
.md-theme-sample > .md-doc[data-md-theme] h3 { margin: 0 0 2px !important; padding: 0 !important; border: 0 !important; font-size: 13px !important; line-height: 1.2 !important; white-space: nowrap; }
.md-theme-sample > .md-doc[data-md-theme] h3::before, .md-theme-sample > .md-doc[data-md-theme] h3::after { content: none !important; }
.md-theme-sample > .md-doc[data-md-theme] p { margin: 0 !important; font-size: 9.5px !important; white-space: nowrap; }
.md-theme-variant { display: inline-flex; align-items: center; gap: 3px; font-size: 11.5px; line-height: 1.2; color: var(--muted); }
.md-theme-variant .md-icon { width: 12px; height: 12px; }
.md-theme-tile:has(:checked) .md-theme-variant { color: var(--ink); font-weight: 600; }
@media (forced-colors: active) { .md-theme-tile:has(:checked) .md-theme-sample { outline: 3px solid Highlight; outline-offset: 1px; } }
.md-export { min-height: 40px; padding: 8px 16px; font-size: 14px; white-space: nowrap; }

/* ---------- toolbar ---------- */
.md-toolbar { display: flex; flex-wrap: wrap; align-items: center; gap: 2px; padding: 6px 0; border-top: 1px solid var(--line); border-bottom: 1px solid var(--line); }
.md-tool-group { display: flex; gap: 2px; }
.md-tool { display: inline-grid; place-items: center; min-width: 34px; min-height: 34px; padding: 0; border: 1px solid transparent; border-radius: 6px; background: transparent; color: var(--ink); }
.md-tool-sep { width: 1px; height: 20px; margin: 0 6px; border-left: 1px solid var(--line); }
@media (pointer: coarse) { .md-tool { min-width: 44px; min-height: 44px; } }
@media (forced-colors: active) { .md-view-btn[aria-pressed="true"] { background: Highlight; color: HighlightText; } }

.md-conflict { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 12px; margin: 12px 0 0; padding: 12px 16px; border: 1px solid color-mix(in srgb, var(--md-warn) 55%, var(--line)); border-radius: 8px; background: color-mix(in srgb, var(--md-warn) 9%, transparent); }
.md-conflict p { margin: 0; font-size: 14px; }
.md-conflict-actions { display: flex; flex-wrap: wrap; gap: 8px; }
.md-conflict .btn { min-height: 36px; padding: 6px 14px; font-size: 13px; }

/* ---------- panes ---------- */
.md-panes { flex: 1; min-height: 0; display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); grid-template-rows: minmax(0, 1fr); }
.md-app[data-view="edit"] .md-panes, .md-app[data-view="preview"] .md-panes { grid-template-columns: minmax(0, 1fr); }
.md-pane { min-width: 0; min-height: 0; overflow: auto; }
.md-pane--editor { display: flex; }
.md-app[data-view="split"] .md-pane--editor { border-right: 1px solid var(--line); }
.md-source { flex: 1; width: 100%; min-height: 100%; margin: 0; padding: 24px 24px 64px 0; border: 0; border-radius: 0; background: transparent; color: var(--ink); resize: none; font-family: ui-monospace, "D2Coding", "SFMono-Regular", Menlo, Consolas, "Malgun Gothic", monospace; font-size: 15px; line-height: 1.75; tab-size: 4; caret-color: var(--action); }
.md-app[data-view="edit"] .md-source { max-width: 880px; margin: 0 auto; padding-left: 0; }
.md-source:focus, .md-source:focus-visible { outline: none; }
.md-pane--editor:focus-within { box-shadow: inset 2px 0 0 var(--action); }
.md-app[data-view="split"] .md-pane--editor:focus-within, .md-app[data-view="edit"] .md-pane--editor:focus-within { box-shadow: inset 0 2px 0 var(--action); }
.md-source::placeholder { color: color-mix(in srgb, var(--muted) 70%, transparent); }
.md-pane--preview { padding: 24px; background: color-mix(in srgb, var(--surface-alt) 55%, transparent); }
.md-app[data-view="split"] .md-pane--preview { padding: 24px 0 24px 24px; }
.md-pane--preview > .md-doc { max-width: 820px; min-height: calc(100% - 8px); margin: 0 auto; border-radius: 8px; box-shadow: 0 1px 0 color-mix(in srgb, var(--ink) 8%, transparent); }
.md-pane--preview > .md-doc:focus-visible { outline: 2px solid var(--action); outline-offset: 3px; }

/* ---------- empty state ---------- */
.md-empty { flex: 1; display: grid; place-content: center; justify-items: center; gap: 8px; padding: 48px 16px; text-align: center; border-top: 1px solid var(--line); }
.md-empty img { width: 168px; height: 168px; object-fit: contain; margin-bottom: 8px; }
.md-empty h2 { margin: 0; font-size: 24px; font-weight: 600; letter-spacing: -.02em; }
.md-empty p { max-width: 380px; margin: 0 0 12px; color: var(--muted); font-size: 15px; word-break: keep-all; }

/* ---------- logged out ---------- */
.md-gate { flex: 1; display: grid; justify-items: center; align-content: center; gap: 6px; max-width: 560px; margin: 0 auto; padding: 48px 0 64px; text-align: center; }
.md-gate .space-eyebrow { margin: 12px 0 0; font-size: 13px; letter-spacing: .015em; color: var(--muted); }
.md-gate img { width: 220px; height: 220px; object-fit: contain; }
.md-gate h1 { margin: 4px 0 6px; font-size: clamp(32px, 4vw, 44px); font-weight: 600; letter-spacing: -.035em; line-height: 1.15; }
.md-gate > p:not(.space-eyebrow) { margin: 0 0 20px; color: var(--muted); line-height: 1.7; word-break: keep-all; }
.md-gate-actions { display: flex; flex-wrap: wrap; justify-content: center; gap: 12px; }

/* ---------- dialogs ---------- */
.md-dialog { width: min(440px, calc(100vw - 32px)); max-height: calc(100dvh - 32px); padding: 0; border: 1px solid var(--line); border-radius: 12px; background: var(--surface); color: var(--ink); box-shadow: 0 24px 64px #00000038; }
.md-dialog--export { width: min(640px, calc(100vw - 32px)); }
.md-dialog:modal { overscroll-behavior: contain; }
.md-dialog::backdrop { background: #0b0d1099; overflow: hidden; overscroll-behavior: contain; }
.md-dialog-body { margin: 0; padding: 24px; }
.md-dialog h2 { margin: 0 0 8px; font-size: 20px; font-weight: 600; letter-spacing: -.02em; line-height: 1.35; word-break: keep-all; }
.md-dialog-text { margin: 0 0 8px; color: var(--muted); font-size: 14px; word-break: keep-all; }
.md-field-label { display: block; margin: 16px 0 8px; padding: 0; font-size: 14px; font-weight: 500; }
.md-field { display: block; width: 100%; height: 48px; padding: 0 12px; border: 1px solid var(--line); border-radius: 6px; background: var(--bg); color: var(--ink); font-size: 16px; }
.md-field:focus-visible { outline: 2px solid var(--action); outline-offset: 2px; }
.md-field[aria-invalid="true"] { border-color: var(--md-bad); }
.md-field-error { min-height: 20px; margin: 6px 0 0; font-size: 13px; line-height: 1.5; color: var(--md-bad); }
.md-dialog-actions { display: flex; justify-content: flex-end; gap: 8px; margin-top: 16px; }
.md-danger { background: #b4373e; border-color: #b4373e; color: #fff; }
.md-dialog--export .md-field-label { margin: 12px 0 6px; }
.md-dialog--export .md-theme-list { --tile-w: 84px; max-height: min(46dvh, 400px); overflow: auto; overscroll-behavior: contain; padding: 4px; border: 1px solid var(--line); border-radius: 8px; }
.md-dialog--export .md-theme-sample { height: 50px; }
.md-theme-selected { min-height: 20px; margin: 8px 0 0; font-size: 13px; line-height: 1.5; color: var(--muted); word-break: keep-all; }
.md-check { display: flex; align-items: center; gap: 8px; min-height: 36px; margin-top: 4px; font-size: 14px; cursor: pointer; }
.md-check input { width: 16px; height: 16px; margin: 0; accent-color: var(--action); }
[data-export-submit][aria-busy="true"] { cursor: progress; opacity: .8; }
@media (prefers-reduced-motion: no-preference) {
  [data-export-submit][aria-busy="true"] .md-icon { animation: md-busy 1.1s var(--ease) infinite; }
  @keyframes md-busy { 50% { translate: 0 2px; opacity: .45; } }
}

/* ---------- drawer (tablet and phone) ---------- */
@media (max-width: 1023px) {
  .md-app, .md-app[data-sidebar="closed"] { grid-template-columns: minmax(0, 1fr); }
  .md-app[data-sidebar="closed"] .md-sidebar { visibility: visible; }
  .md-sidebar { position: fixed; z-index: 70; inset: 0 auto 0 0; width: min(320px, 86vw); padding: 16px; background: var(--bg); border-right: 1px solid var(--line); box-shadow: 16px 0 48px #0000002e; transform: translateX(-104%); }
  .md-app[data-sidebar="open"] .md-sidebar { transform: none; }
  @media (prefers-reduced-motion: no-preference) { .md-sidebar { transition: transform 200ms var(--ease); } }
  .md-drawer-close { display: inline-grid !important; }
  .md-scrim { display: block; position: fixed; inset: 0; z-index: 65; background: #0b0d1073; }
  .md-workspace, .md-app[data-sidebar="closed"] .md-workspace { padding-left: 0; }
}
@media (max-width: 1180px) and (min-width: 761px) {
  .md-titlebar { flex-wrap: wrap; }
  .md-title-actions { width: 100%; justify-content: flex-end; }
}

/* ---------- phone ---------- */
@media (max-width: 760px) {
  .md-app { height: auto; min-height: calc(100svh - 89px); }
  .md-titlebar { flex-wrap: wrap; gap: 8px 12px; padding: 12px 0 10px; }
  .md-heading h1 { font-size: 19px; }
  .md-title-actions { width: 100%; flex-wrap: wrap; gap: 8px; }
  .md-save { order: 3; width: 100%; min-height: 20px; }
  .md-views { flex: 1; }
  .md-view-btn { flex: 1; min-height: 38px; }
  .md-view-btn::after { display: none; }
  .md-view-btn[data-view-mode="split"] { display: none; }
  .md-export { min-height: 44px; }
  .md-toolbar { flex-wrap: nowrap; overflow-x: auto; scrollbar-width: none; scroll-snap-type: x proximity; mask-image: linear-gradient(90deg, #000 88%, transparent); }
  .md-toolbar::-webkit-scrollbar { display: none; }
  .md-tool-group { flex: none; }
  .md-tool { scroll-snap-align: start; }
  .md-panes { min-height: 62svh; }
  .md-source { font-size: 16px; padding: 16px 0 48px; }
  .md-pane--preview, .md-app[data-view="split"] .md-pane--preview { padding: 12px 0; background: none; }
  .md-pane--preview > .md-doc { border-radius: 6px; }
  .md-view-btn { width: auto; }
  .md-theme-trigger { min-height: 44px; }
  .md-theme-family { column-gap: 8px; }
  .md-dialog--export .md-theme-list { --tile-w: 72px; }
  .md-dialog-actions { flex-direction: column-reverse; }
  .md-dialog-actions .btn { width: 100%; }
  .md-gate img { width: 168px; height: 168px; }
}
@media (max-width: 760px) { .md-export { padding: 8px 14px; } }

/* ---------- preview without a theme ----------
   "미리보기에 테마 적용" off: the site's own reading style, light or dark with
   the site. "_site" is never a theme key, so no theme rule matches it. */
.md-doc[data-md-theme="_site"] { background: var(--surface); color: var(--ink); font-family: inherit; }
.md-doc[data-md-theme="_site"] :is(h1, h2, h3, h4, h5, h6) { font-weight: 650; letter-spacing: -.015em; color: var(--ink); }
.md-doc[data-md-theme="_site"] h1 { font-size: 1.9em; }
.md-doc[data-md-theme="_site"] h2 { font-size: 1.45em; padding-bottom: .3em; border-bottom: 1px solid var(--line); }
.md-doc[data-md-theme="_site"] h3 { font-size: 1.2em; }
.md-doc[data-md-theme="_site"] a { color: var(--action); text-decoration: underline; text-underline-offset: .2em; }
.md-doc[data-md-theme="_site"] :is(code, kbd) { padding: .12em .35em; border-radius: 4px; background: var(--surface-alt); font-family: ui-monospace, "D2Coding", "SFMono-Regular", Menlo, Consolas, monospace; font-size: .9em; }
.md-doc[data-md-theme="_site"] pre { margin: 0 0 1.05em; padding: 14px 16px; overflow: auto; border: 1px solid var(--line); border-radius: 8px; background: var(--surface-alt); line-height: 1.6; }
.md-doc[data-md-theme="_site"] pre code { padding: 0; background: none; font-size: .88em; }
.md-doc[data-md-theme="_site"] blockquote { margin: 0 0 1.05em; padding: .2em 0 .2em 1em; border-left: 3px solid var(--line); color: var(--muted); }
.md-doc[data-md-theme="_site"] table { width: 100%; margin: 0 0 1.05em; border-collapse: collapse; font-size: .95em; }
.md-doc[data-md-theme="_site"] :is(th, td) { padding: 8px 10px; border: 1px solid var(--line); text-align: left; }
.md-doc[data-md-theme="_site"] th { background: var(--surface-alt); font-weight: 600; }
.md-doc[data-md-theme="_site"] hr { height: 1px; margin: 2em 0; border: 0; background: var(--line); }
.md-doc[data-md-theme="_site"] img { max-width: 100%; height: auto; border-radius: 6px; }
.md-doc[data-md-theme="_site"] mark { background: color-mix(in srgb, var(--action) 22%, transparent); color: inherit; }
