/* Premium Markdown editor UI. Shared LuxTool components and tokens come from /style.css. */
.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;
}

.md-trust-row {
  display: flex;
  align-items: center;
  justify-content: center;
  flex-wrap: wrap;
  gap: .45rem .7rem;
  margin: -.35rem 0 1rem;
  color: var(--muted);
  font-size: .75rem;
}

.md-trust-row > span {
  padding: .4rem .65rem;
  background: color-mix(in srgb, var(--text) 4%, var(--surface));
  border: 1px solid var(--border);
  border-radius: 999px;
}

.md-trust-row .md-private {
  color: #6ee7b7;
  border-color: rgba(52, 211, 153, .24);
  background: rgba(16, 185, 129, .07);
}

.md-app-panel {
  position: relative;
  width: min(100%, 1440px);
  margin-inline: auto;
  padding: 1rem;
}

.md-app-actions {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: .5rem;
  padding-bottom: .9rem;
  margin-bottom: .9rem;
  border-bottom: 1px solid var(--border);
}

.md-sample-label {
  margin-left: auto;
  color: var(--muted);
  font-size: .72rem;
  font-weight: 600;
}

.md-sample-select {
  width: 180px;
  padding-top: .47rem;
  padding-bottom: .47rem;
  font-size: .78rem;
}

.md-clear-btn {
  color: #fca5a5;
  border-color: rgba(248, 113, 113, .28);
  background: rgba(248, 113, 113, .07);
}

.md-clear-btn:hover {
  color: #fecaca;
  background: rgba(248, 113, 113, .17);
}

.md-workspace {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
  gap: .8rem;
  align-items: stretch;
}

.md-pane {
  display: flex;
  flex-direction: column;
  min-width: 0;
  min-height: 610px;
  background: color-mix(in srgb, var(--text) 2.5%, var(--surface));
  border: 1px solid var(--border);
  border-radius: .75rem;
  overflow: hidden;
}

.md-pane-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: .75rem;
  min-height: 43px;
  padding: .7rem .8rem;
  border-bottom: 1px solid var(--border);
}

.md-pane-head .lux-label {
  margin: 0;
}

.md-file-name {
  overflow: hidden;
  color: var(--muted);
  font-size: .68rem;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.md-toolbar {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: .3rem;
  padding: .55rem .6rem;
  background: color-mix(in srgb, var(--text) 3.5%, var(--surface));
  border-bottom: 1px solid var(--border);
}

.md-toolbar button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 34px;
  min-height: 32px;
  padding: .32rem .5rem;
  color: var(--text);
  background: transparent;
  border: 1px solid transparent;
  border-radius: .4rem;
  font: 600 .72rem/1 inherit;
  cursor: pointer;
  transition: color .18s ease, background .18s ease, border-color .18s ease, transform .18s ease;
}

.md-toolbar button:hover {
  color: var(--gold);
  background: rgba(251, 191, 36, .09);
  border-color: var(--gold-dim);
  transform: translateY(-1px);
}

.md-toolbar button:focus-visible,
.md-tab:focus-visible,
.md-options summary:focus-visible {
  outline: 2px solid var(--gold);
  outline-offset: 2px;
}

.md-editor-wrap {
  position: relative;
  display: flex;
  flex: 1;
  min-height: 430px;
}

.md-input,
.md-html-output {
  flex: 1;
  width: 100%;
  min-height: 430px;
  padding: 1rem;
  margin: 0;
  color: var(--text);
  background: transparent;
  border: 0;
  border-radius: 0;
  resize: none;
  font: .84rem/1.65 ui-monospace, SFMono-Regular, Consolas, "Liberation Mono", monospace;
  tab-size: 2;
}

.md-input:focus,
.md-html-output:focus {
  border-color: transparent;
  box-shadow: inset 0 0 0 2px var(--gold-dim);
}

.md-drop-overlay {
  position: absolute;
  inset: .7rem;
  z-index: 4;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-direction: column;
  gap: .3rem;
  color: var(--gold);
  background: color-mix(in srgb, var(--surface) 92%, var(--gold));
  border: 2px dashed var(--gold);
  border-radius: .65rem;
  opacity: 0;
  pointer-events: none;
  transition: opacity .16s ease;
}

.md-drop-overlay span {
  color: var(--muted);
  font-size: .75rem;
}

.md-editor-pane.is-dragging .md-drop-overlay {
  opacity: 1;
}

.md-stats {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: .35rem .7rem;
  min-height: 42px;
  padding: .55rem .75rem;
  color: var(--muted);
  background: color-mix(in srgb, var(--text) 2.5%, var(--surface));
  border-top: 1px solid var(--border);
  font-size: .68rem;
}

.md-stats strong {
  color: var(--text);
  font-variant-numeric: tabular-nums;
}

.md-draft-status {
  margin-left: auto;
  color: var(--gold);
}

.md-tabs {
  display: flex;
  align-items: center;
  min-height: 44px;
  padding: 0 .6rem;
  border-bottom: 1px solid var(--border);
}

.md-tab {
  align-self: stretch;
  min-width: 84px;
  padding: .65rem .85rem;
  color: var(--muted);
  background: transparent;
  border: 0;
  border-bottom: 2px solid transparent;
  font: 700 .78rem/1 inherit;
  cursor: pointer;
  transition: color .18s ease, border-color .18s ease;
}

.md-tab:hover,
.md-tab.is-active {
  color: var(--gold);
  border-bottom-color: var(--gold);
}

.md-render-status {
  margin-left: auto;
  color: #6ee7b7;
  font-size: .67rem;
}

.md-render-status.is-busy {
  color: var(--gold);
}

.md-tab-panel {
  flex: 1;
  min-height: 0;
  overflow: auto;
}

.md-tab-panel[hidden] {
  display: none;
}

.md-preview-content {
  min-height: 500px;
  padding: 1.15rem 1.25rem 2rem;
  overflow-wrap: anywhere;
  color: var(--text);
  font-size: .9rem;
  line-height: 1.72;
}

.md-empty-state {
  display: flex;
  align-items: center;
  justify-content: center;
  flex-direction: column;
  min-height: 390px;
  gap: .35rem;
  color: var(--muted);
  text-align: center;
}

.md-empty-state strong {
  color: var(--text);
}

.md-empty-state span {
  max-width: 320px;
  font-size: .78rem;
}

.md-preview-content > :first-child {
  margin-top: 0;
}

.md-preview-content > :last-child {
  margin-bottom: 0;
}

.md-preview-content h1,
.md-preview-content h2,
.md-preview-content h3,
.md-preview-content h4,
.md-preview-content h5,
.md-preview-content h6 {
  margin: 1.35em 0 .55em;
  color: var(--text);
  line-height: 1.28;
}

.md-preview-content h1 {
  padding-bottom: .35rem;
  color: var(--gold);
  border-bottom: 1px solid var(--border);
  font-size: 1.8rem;
}

.md-preview-content h2 {
  padding-bottom: .25rem;
  border-bottom: 1px solid var(--border);
  font-size: 1.4rem;
}

.md-preview-content h3 { font-size: 1.18rem; }
.md-preview-content p { margin: .75rem 0; }
.md-preview-content ul,
.md-preview-content ol { margin: .7rem 0 .7rem 1.4rem; }
.md-preview-content li + li { margin-top: .25rem; }
.md-preview-content li > ul,
.md-preview-content li > ol { margin-top: .25rem; margin-bottom: .25rem; }

.md-preview-content a {
  color: var(--gold);
  text-decoration-thickness: 1px;
  text-underline-offset: 2px;
}

.md-preview-content img {
  display: block;
  max-width: 100%;
  height: auto;
  margin: 1rem auto;
  border-radius: .55rem;
}

.md-preview-content blockquote {
  padding: .15rem 0 .15rem 1rem;
  margin: 1rem 0;
  color: var(--muted);
  border-left: 3px solid var(--gold);
}

.md-preview-content blockquote p { margin: .35rem 0; }

.md-preview-content code {
  padding: .12em .35em;
  color: var(--gold);
  background: rgba(251, 191, 36, .09);
  border-radius: .3em;
  font-family: ui-monospace, SFMono-Regular, Consolas, monospace;
  font-size: .88em;
}

.md-preview-content pre {
  max-width: 100%;
  padding: 1rem;
  margin: 1rem 0;
  overflow: auto;
  color: #e5e7eb;
  background: #0b1020;
  border: 1px solid rgba(148, 163, 184, .2);
  border-radius: .55rem;
}

.md-preview-content pre code {
  padding: 0;
  color: inherit;
  background: transparent;
}

.md-preview-content hr {
  margin: 1.4rem 0;
  border: 0;
  border-top: 1px solid var(--border);
}

.md-preview-content table {
  display: block;
  width: 100%;
  margin: 1rem 0;
  overflow-x: auto;
  border-collapse: collapse;
}

.md-preview-content th,
.md-preview-content td {
  min-width: 100px;
  padding: .5rem .65rem;
  border: 1px solid var(--border);
  text-align: left;
}

.md-preview-content th {
  color: var(--gold);
  background: color-mix(in srgb, var(--gold) 7%, var(--surface));
}

.md-preview-content input[type="checkbox"] {
  margin-right: .4rem;
  accent-color: var(--gold);
}

.md-output-actions {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: .4rem;
  min-height: 53px;
  padding: .55rem .65rem;
  background: color-mix(in srgb, var(--text) 2.5%, var(--surface));
  border-top: 1px solid var(--border);
}

.md-output-actions .btn {
  flex: 1 1 auto;
  min-height: 34px;
  padding-right: .55rem;
  padding-left: .55rem;
  white-space: nowrap;
}

.md-options {
  margin-top: .8rem;
  border: 1px solid var(--border);
  border-radius: .7rem;
  overflow: hidden;
}

.md-options summary {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  padding: .8rem .95rem;
  color: var(--text);
  background: color-mix(in srgb, var(--text) 3.5%, var(--surface));
  cursor: pointer;
  list-style: none;
}

.md-options summary::-webkit-details-marker { display: none; }

.md-options summary > span:first-child {
  display: flex;
  flex-direction: column;
  gap: .12rem;
}

.md-options summary strong { font-size: .82rem; }
.md-options summary small { color: var(--muted); font-size: .68rem; }

.md-options-chevron {
  color: var(--gold);
  transition: transform .18s ease;
}

.md-options[open] .md-options-chevron { transform: rotate(180deg); }

.md-options-body {
  padding: .9rem;
  border-top: 1px solid var(--border);
}

.md-option-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: .5rem;
}

.md-option {
  display: flex;
  align-items: flex-start;
  gap: .55rem;
  min-width: 0;
  padding: .65rem;
  background: color-mix(in srgb, var(--text) 3%, var(--surface));
  border: 1px solid transparent;
  border-radius: .55rem;
  cursor: pointer;
  transition: border-color .18s ease, background .18s ease;
}

.md-option:hover,
.md-option:has(input:checked) {
  border-color: var(--gold-dim);
}

.md-option:has(input:checked) {
  background: color-mix(in srgb, var(--gold) 7%, var(--surface));
}

.md-option:has(input:focus-visible) {
  outline: 2px solid var(--gold);
  outline-offset: 2px;
}

.md-option input {
  width: 1rem;
  height: 1rem;
  margin-top: .1rem;
  accent-color: var(--gold);
  flex: 0 0 auto;
}

.md-option span {
  display: flex;
  flex-direction: column;
  gap: .16rem;
  min-width: 0;
}

.md-option strong { color: var(--text); font-size: .74rem; }
.md-option small { color: var(--muted); font-size: .64rem; line-height: 1.35; }

.md-option:has(input:disabled) {
  cursor: not-allowed;
  opacity: .45;
}

.md-publish-options {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: .7rem;
  padding-top: .8rem;
  margin-top: .8rem;
  border-top: 1px solid var(--border);
}

.md-publish-options .lux-label { margin-bottom: .35rem; }
.md-publish-options .lux-select,
.md-publish-options .lux-input { min-height: 40px; }

.md-filename-field {
  display: flex;
  align-items: center;
}

.md-filename-field .lux-input {
  border-radius: .6rem 0 0 .6rem;
}

.md-filename-field span {
  align-self: stretch;
  display: inline-flex;
  align-items: center;
  padding: 0 .65rem;
  color: var(--muted);
  background: var(--surface2);
  border: 1px solid var(--gold-dim);
  border-left: 0;
  border-radius: 0 .6rem .6rem 0;
  font-size: .78rem;
}

.md-sanitize-warning {
  padding: .65rem .75rem;
  margin: .75rem 0 0;
  color: #fecaca;
  background: rgba(248, 113, 113, .08);
  border: 1px solid rgba(248, 113, 113, .28);
  border-radius: .55rem;
  font-size: .74rem;
}

.md-toast {
  position: fixed;
  right: 1.2rem;
  bottom: 1.2rem;
  z-index: 1000;
  max-width: min(360px, calc(100vw - 2rem));
  padding: .72rem 1rem;
  color: #a7f3d0;
  background: color-mix(in srgb, #052e22 88%, var(--surface));
  border: 1px solid rgba(52, 211, 153, .35);
  border-radius: .7rem;
  box-shadow: 0 14px 36px rgba(0, 0, 0, .28);
  font-size: .84rem;
  font-weight: 600;
  opacity: 0;
  pointer-events: none;
  transform: translateY(12px);
  transition: opacity .2s ease, transform .2s ease;
}

.md-toast.is-visible { opacity: 1; transform: translateY(0); }
.md-toast.info { color: var(--gold); background: color-mix(in srgb, var(--surface) 92%, var(--gold)); border-color: var(--gold-dim); }
.md-toast.error { color: #fecaca; background: color-mix(in srgb, #450a0a 88%, var(--surface)); border-color: rgba(248, 113, 113, .4); }

.md-copy-text-holder {
  position: fixed;
  left: -99999px;
  top: 0;
  width: 700px;
  white-space: normal;
}

/* Highlight.js token colors, scoped to converted output. */
.md-preview-content .hljs-keyword,
.md-preview-content .hljs-selector-tag,
.md-preview-content .hljs-literal { color: #c084fc; }
.md-preview-content .hljs-string,
.md-preview-content .hljs-attr { color: #86efac; }
.md-preview-content .hljs-number,
.md-preview-content .hljs-symbol { color: #fca5a5; }
.md-preview-content .hljs-title,
.md-preview-content .hljs-function { color: #93c5fd; }
.md-preview-content .hljs-comment,
.md-preview-content .hljs-quote { color: #94a3b8; font-style: italic; }
.md-preview-content .hljs-built_in,
.md-preview-content .hljs-type { color: #fde68a; }

html.theme-light .md-trust-row .md-private,
html.theme-light .md-render-status { color: #047857; }

html.theme-light .md-preview-content pre {
  color: #e5e7eb;
  background: #0f172a;
}

html.theme-light .md-toast { color: #065f46; background: #ecfdf5; border-color: rgba(5, 150, 105, .32); }
html.theme-light .md-toast.info { color: var(--gold); background: #fffbeb; }
html.theme-light .md-toast.error { color: #991b1b; background: #fef2f2; }

@media (max-width: 1100px) {
  .md-option-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}

@media (max-width: 900px) {
  .md-workspace { grid-template-columns: 1fr; }
  .md-pane { min-height: 540px; }
  .md-preview-content { min-height: 430px; }
}

@media (max-width: 640px) {
  .md-app-panel { padding: .75rem; }
  .md-app-actions .btn { flex: 1 1 calc(50% - .5rem); }
  .md-sample-label { width: 100%; margin: .15rem 0 -.15rem; }
  .md-sample-select { width: 100%; }
  .md-toolbar { flex-wrap: nowrap; overflow-x: auto; scrollbar-width: thin; }
  .md-toolbar button { flex: 0 0 auto; min-height: 38px; }
  .md-pane { min-height: 500px; }
  .md-editor-wrap,
  .md-input,
  .md-html-output { min-height: 350px; }
  .md-preview-content { min-height: 390px; padding: 1rem; }
  .md-output-actions .btn { flex: 1 1 calc(50% - .4rem); }
  .md-option-grid,
  .md-publish-options { grid-template-columns: 1fr; }
  .md-draft-status { width: 100%; margin-left: 0; }
  .md-toast { right: 1rem; bottom: 1rem; left: 1rem; text-align: center; }
}

@media (prefers-reduced-motion: reduce) {
  .md-toolbar button,
  .md-drop-overlay,
  .md-options-chevron,
  .md-toast { transition: none; }
}
