/* ── PAGE HEADER ── */
.md-page-header {
  display: grid;
  grid-template-columns: 1fr 280px;
  border-bottom: 1px solid var(--border);
  background: #0a0a0a;
}
.md-ph-left {
  padding: 44px 52px 36px;
  border-right: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  position: relative;
  overflow: hidden;
}
.md-ph-left::before {
  content: "";
  position: absolute;
  inset: 0;
  pointer-events: none;
  background: repeating-linear-gradient(
    0deg,
    transparent,
    transparent 3px,
    rgba(255, 255, 255, 0.012) 3px,
    rgba(255, 255, 255, 0.012) 4px
  );
}
.md-ph-eyebrow {
  font-family: var(--mono);
  font-size: 0.68rem;
  color: var(--muted);
  letter-spacing: 0.12em;
  text-transform: uppercase;
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 14px;
}
.md-ph-eyebrow .dot {
  width: 6px;
  height: 6px;
  background: var(--green);
  border-radius: 50%;
  animation: blink 1.8s step-end infinite;
}
@keyframes blink {
  0%,
  100% {
    opacity: 1;
  }
  50% {
    opacity: 0;
  }
}
.md-ph-title {
  font-family: var(--cond);
  font-size: clamp(3rem, 7vw, 5.5rem);
  font-weight: 900;
  line-height: 0.9;
  letter-spacing: -0.02em;
  text-transform: uppercase;
  margin-bottom: 18px;
}
.md-ph-title .yel {
  color: var(--yellow);
}
.md-ph-desc {
  font-size: 0.95rem;
  color: var(--muted);
  max-width: 500px;
  line-height: 1.65;
  border-left: 3px solid var(--yellow);
  padding-left: 14px;
  margin-bottom: 20px;
}
.md-ph-tags {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}
.md-ph-tag {
  font-family: var(--mono);
  font-size: 0.65rem;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  padding: 4px 10px;
  border: 1px solid var(--border);
  color: var(--muted);
}
.md-ph-tag.yellow {
  border-color: var(--yellow);
  color: var(--yellow);
}
.md-ph-tag.green {
  border-color: var(--green);
  color: var(--green);
}
.md-ph-right {
  display: flex;
  flex-direction: column;
}
.md-ph-stat {
  flex: 1;
  padding: 22px 28px;
  border-bottom: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  gap: 5px;
}
.md-ph-stat:last-child {
  border-bottom: none;
}
.md-ps-label {
  font-family: var(--mono);
  font-size: 0.62rem;
  color: var(--muted);
  letter-spacing: 0.1em;
  text-transform: uppercase;
}
.md-ps-val {
  font-family: var(--cond);
  font-size: 2rem;
  font-weight: 900;
  color: var(--yellow);
  line-height: 1;
  letter-spacing: -0.02em;
}
.md-ps-note {
  font-family: var(--mono);
  font-size: 0.62rem;
  color: var(--muted);
}

/* ── MAIN LAYOUT ── */
.md-page-body {
  display: grid;
  grid-template-columns: 1fr 300px;
}
.md-col-main {
  border-right: 1px solid var(--border);
  display: flex;
  flex-direction: column;
}
.md-col-side {
  background: #080808;
  display: flex;
  flex-direction: column;
}

/* ── TOOL PANEL ── */
.md-tool-panel {
  border-bottom: 1px solid var(--border);
}
.md-tool-panel.is-fullscreen {
  position: fixed;
  inset: 0;
  z-index: 1000;
  background: #0a0a0a;
  display: flex;
  flex-direction: column;
}
.md-tool-panel.is-fullscreen .md-editor-wrap {
  flex: 1;
  min-height: 0;
}
.md-tph {
  display: flex;
  align-items: stretch;
  border-bottom: 1px solid var(--border);
  background: #0a0a0a;
  height: 46px;
}
.md-tph-title {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 0 20px;
  font-family: var(--mono);
  font-size: 0.75rem;
  color: var(--muted);
  letter-spacing: 0.06em;
  flex: 1;
  border-right: 1px solid var(--border);
}
.md-tph-status {
  width: 6px;
  height: 6px;
  background: var(--green);
  border-radius: 50%;
  animation: blink 1.8s step-end infinite;
}
.md-tph-status-txt {
  color: var(--green);
  font-size: 0.65rem;
}
.md-tph-actions {
  display: flex;
  align-items: stretch;
}
.md-tph-btn {
  height: 46px;
  padding: 0 16px;
  border-right: 1px solid var(--border);
  font-family: var(--mono);
  font-size: 0.68rem;
  color: var(--muted);
  letter-spacing: 0.06em;
  text-transform: uppercase;
  display: flex;
  align-items: center;
  gap: 6px;
  transition:
    color 0.12s,
    background 0.12s;
}
.md-tph-btn:hover {
  color: var(--white);
  background: #111;
}
.md-tph-btn.active {
  color: var(--yellow);
  background: #111;
}
.md-tph-btn:last-child {
  border-right: none;
}

/* ── TOOLBAR ── */
.md-toolbar {
  display: flex;
  align-items: stretch;
  border-bottom: 1px solid var(--border);
  background: #0d0d0d;
  flex-wrap: wrap;
}
.md-tb-group {
  display: flex;
  align-items: stretch;
  border-right: 1px solid var(--border);
}
.md-tb-group:last-child {
  border-right: none;
}
.md-tb-btn {
  height: 42px;
  width: 42px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 0.95rem;
  color: var(--muted);
  transition: all 0.12s;
  position: relative;
}
.md-tb-btn:hover {
  color: var(--white);
  background: #161616;
}
.md-tb-btn.active {
  color: var(--yellow);
  background: #161616;
}
.md-tb-btn[title]::after {
  content: attr(title);
  position: absolute;
  bottom: -30px;
  left: 50%;
  transform: translateX(-50%);
  background: var(--ink);
  border: 1px solid var(--border);
  padding: 3px 8px;
  font-family: var(--mono);
  font-size: 0.6rem;
  color: var(--muted);
  white-space: nowrap;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.15s;
  z-index: 10;
}
.md-tb-btn:hover::after {
  opacity: 1;
}
.md-tb-sep {
  width: 1px;
  background: var(--border);
  margin: 8px 0;
}
.md-tb-label {
  font-family: var(--mono);
  font-size: 0.65rem;
  color: var(--muted);
  padding: 0 14px;
  display: flex;
  align-items: center;
  letter-spacing: 0.06em;
}

/* ── EDITOR AREA ── */
.md-editor-wrap {
  display: grid;
  grid-template-columns: 1fr 1fr;
  min-height: 500px;
}
.md-editor-wrap.preview-only {
  grid-template-columns: 0 1fr;
}
.md-editor-wrap.editor-only {
  grid-template-columns: 1fr 0;
}

.md-editor-pane {
  display: flex;
  flex-direction: column;
  border-right: 1px solid var(--border);
  position: relative;
}
.md-pane-header {
  height: 36px;
  padding: 0 16px;
  background: #0a0a0a;
  border-bottom: 1px solid var(--border);
  font-family: var(--mono);
  font-size: 0.65rem;
  color: var(--muted);
  letter-spacing: 0.08em;
  text-transform: uppercase;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}
.md-pane-header .ph-dot {
  width: 5px;
  height: 5px;
  background: var(--yellow);
  border-radius: 50%;
}
.md-pane-actions {
  display: flex;
  gap: 0;
}
.md-pane-btn {
  padding: 0 10px;
  height: 100%;
  font-family: var(--mono);
  font-size: 0.62rem;
  color: var(--muted);
  letter-spacing: 0.06em;
  text-transform: uppercase;
  transition: color 0.12s;
}
.md-pane-btn:hover {
  color: var(--yellow);
}
.md-pane-btn.ok {
  color: var(--green);
}

#markdownInput {
  flex: 1;
  width: 100%;
  padding: 20px;
  resize: none;
  background: #0c0c0c;
  border: none;
  outline: none;
  color: var(--white);
  font-family: var(--mono);
  font-size: 0.88rem;
  line-height: 1.7;
  letter-spacing: 0.02em;
}
#markdownInput::placeholder {
  color: var(--muted);
  opacity: 0.6;
}

.md-preview-pane {
  display: flex;
  flex-direction: column;
  background: #0a0a0a;
  overflow: hidden;
}
#previewOutput {
  flex: 1;
  padding: 24px;
  overflow-y: auto;
  font-size: 0.95rem;
  line-height: 1.75;
  color: var(--white);
}

/* ── PREVIEW STYLES ── */
#previewOutput h1 {
  font-family: var(--cond);
  font-size: 2.5rem;
  font-weight: 900;
  color: var(--yellow);
  margin: 0 0 16px;
  line-height: 1.1;
  text-transform: uppercase;
  letter-spacing: -0.02em;
}
#previewOutput h2 {
  font-family: var(--cond);
  font-size: 1.8rem;
  font-weight: 800;
  color: var(--white);
  margin: 28px 0 12px;
  border-bottom: 1px solid var(--border);
  padding-bottom: 8px;
  text-transform: uppercase;
}
#previewOutput h3 {
  font-family: var(--cond);
  font-size: 1.3rem;
  font-weight: 700;
  color: var(--white);
  margin: 24px 0 10px;
  text-transform: uppercase;
}
#previewOutput h4,
#previewOutput h5,
#previewOutput h6 {
  font-size: 1rem;
  font-weight: 600;
  color: var(--muted);
  margin: 20px 0 8px;
}
#previewOutput p {
  margin: 0 0 16px;
  color: var(--white);
}
#previewOutput strong {
  color: var(--yellow);
  font-weight: 700;
}
#previewOutput em {
  font-style: italic;
  color: #b8b8b0;
}
#previewOutput del {
  color: var(--muted);
  text-decoration: line-through;
}
#previewOutput a {
  color: var(--yellow);
  text-decoration: underline;
  text-underline-offset: 3px;
  transition: color 0.12s;
}
#previewOutput a:hover {
  color: var(--white);
}
#previewOutput code {
  font-family: var(--mono);
  font-size: 0.85em;
  background: #161616;
  border: 1px solid var(--border);
  padding: 2px 6px;
  color: var(--yellow);
}
#previewOutput pre {
  background: #0c0c0c;
  border: 1px solid var(--border);
  padding: 16px;
  margin: 0 0 16px;
  overflow-x: auto;
  position: relative;
}
#previewOutput pre code {
  background: none;
  border: none;
  padding: 0;
  color: var(--white);
  font-size: 0.82rem;
  line-height: 1.6;
}
#previewOutput blockquote {
  border-left: 3px solid var(--yellow);
  padding: 12px 20px;
  margin: 0 0 16px;
  background: #0d0d0d;
  color: var(--muted);
  font-style: italic;
}
#previewOutput blockquote p {
  margin: 0;
}
#previewOutput ul,
#previewOutput ol {
  margin: 0 0 16px;
  padding-left: 24px;
}
#previewOutput li {
  margin: 6px 0;
  color: var(--white);
}
#previewOutput li::marker {
  color: var(--yellow);
}
#previewOutput hr {
  border: none;
  border-top: 1px solid var(--border);
  margin: 24px 0;
}
#previewOutput img {
  max-width: 100%;
  height: auto;
  border: 1px solid var(--border);
}
#previewOutput table {
  width: 100%;
  border-collapse: collapse;
  margin: 0 0 16px;
  font-size: 0.88rem;
}
#previewOutput th,
#previewOutput td {
  border: 1px solid var(--border);
  padding: 10px 14px;
  text-align: left;
}
#previewOutput th {
  background: #0d0d0d;
  font-family: var(--mono);
  font-size: 0.75rem;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--yellow);
}
#previewOutput td {
  background: #0a0a0a;
}
#previewOutput input[type="checkbox"] {
  margin-right: 8px;
  accent-color: var(--yellow);
}

/* ── STATS BAR ── */
.md-stats-bar {
  display: flex;
  align-items: stretch;
  border-top: 1px solid var(--border);
  background: #0a0a0a;
  height: 38px;
}
.md-stat-item {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 0 16px;
  border-right: 1px solid var(--border);
  font-family: var(--mono);
  font-size: 0.68rem;
  color: var(--muted);
  letter-spacing: 0.04em;
}
.md-stat-item .sv {
  color: var(--white);
}
.md-stat-item:last-child {
  border-right: none;
}

/* ── EXPORT SECTION ── */
.md-export-section {
  border-bottom: 1px solid var(--border);
}
.md-section-bar {
  display: flex;
  align-items: center;
  height: 44px;
  border-bottom: 1px solid var(--border);
  background: #0a0a0a;
}
.md-sb-label {
  font-family: var(--mono);
  font-size: 0.65rem;
  color: var(--muted);
  letter-spacing: 0.1em;
  text-transform: uppercase;
  padding: 0 16px;
  border-right: 1px solid var(--border);
  height: 100%;
  display: flex;
  align-items: center;
  gap: 8px;
}
.md-sb-dot {
  width: 6px;
  height: 6px;
  background: var(--yellow);
  border-radius: 50%;
  animation: blink 1.4s step-end infinite;
}
.md-sb-title {
  font-family: var(--cond);
  font-size: 1rem;
  font-weight: 900;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--white);
  padding: 0 20px;
}

.md-export-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 0;
}
.md-export-btn {
  padding: 20px;
  border-right: 1px solid var(--border);
  border-bottom: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
  transition: all 0.12s;
  text-align: center;
}
.md-export-btn:nth-child(4n) {
  border-right: none;
}
.md-export-btn:hover {
  background: #111;
}
.md-export-btn .eb-icon {
  font-size: 1.5rem;
}
.md-export-btn .eb-label {
  font-family: var(--mono);
  font-size: 0.7rem;
  color: var(--muted);
  letter-spacing: 0.06em;
  text-transform: uppercase;
}
.md-export-btn .eb-desc {
  font-size: 0.72rem;
  color: #555;
}
.md-export-btn:hover .eb-label {
  color: var(--yellow);
}
.md-export-btn.ok .eb-label {
  color: var(--green);
}

/* ── TEMPLATES ── */
.md-templates-section {
  border-bottom: 1px solid var(--border);
}
.md-templates-grid {
  display: flex;
  flex-direction: column;
}
.md-tpl-row {
  display: grid;
  grid-template-columns: 1fr auto;
  align-items: center;
  border-bottom: 1px solid var(--border);
  transition: background 0.12s;
  cursor: pointer;
}
.md-tpl-row:last-child {
  border-bottom: none;
}
.md-tpl-row:hover {
  background: #0d0d0d;
}
.md-tpl-info {
  padding: 14px 20px;
  display: flex;
  align-items: center;
  gap: 12px;
}
.md-tpl-icon {
  font-size: 1.2rem;
}
.md-tpl-name {
  font-size: 0.88rem;
  font-weight: 600;
  color: var(--white);
}
.md-tpl-desc {
  font-family: var(--mono);
  font-size: 0.68rem;
  color: var(--muted);
}
.md-tpl-insert {
  padding: 0 20px;
  height: 100%;
  border-left: 1px solid var(--border);
  font-family: var(--mono);
  font-size: 0.65rem;
  color: var(--muted);
  letter-spacing: 0.06em;
  text-transform: uppercase;
  display: flex;
  align-items: center;
  transition: all 0.12s;
}
.md-tpl-row:hover .md-tpl-insert {
  color: var(--yellow);
  background: #111;
}

/* ── CHEATSHEET ── */
.md-cheat-section {
  border-bottom: 1px solid var(--border);
}
.md-cheat-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
}
.md-cheat-item {
  padding: 12px 16px;
  border-right: 1px solid var(--border);
  border-bottom: 1px solid var(--border);
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
  transition: background 0.12s;
}
.md-cheat-item:nth-child(2n) {
  border-right: none;
}
.md-cheat-item:hover {
  background: #0d0d0d;
}
.md-ci-syntax {
  font-family: var(--mono);
  font-size: 0.75rem;
  color: var(--yellow);
}
.md-ci-result {
  font-size: 0.8rem;
  color: var(--muted);
}

/* ── HOW TO / FAQ ── */
.md-steps {
  display: flex;
  flex-direction: column;
  gap: 0;
}
.md-step {
  display: grid;
  grid-template-columns: 64px 1fr;
  border-bottom: 1px solid var(--border);
  transition: background 0.12s;
}
.md-step:hover {
  background: #0d0d0d;
}
.md-step:last-child {
  border-bottom: none;
}
.md-step-num {
  display: flex;
  align-items: flex-start;
  justify-content: center;
  padding-top: 22px;
  border-right: 1px solid var(--border);
  font-family: var(--cond);
  font-size: 2rem;
  font-weight: 900;
  color: var(--border);
  letter-spacing: -0.04em;
  transition: color 0.15s;
}
.md-step:hover .md-step-num {
  color: var(--yellow);
}
.md-step-content {
  padding: 20px 24px;
}
.md-step-title {
  font-family: var(--cond);
  font-size: 1rem;
  font-weight: 800;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--white);
  margin-bottom: 6px;
}
.md-step-desc {
  font-size: 0.84rem;
  color: var(--muted);
  line-height: 1.6;
}
.md-code {
  font-family: var(--mono);
  font-size: 0.75rem;
  background: #161616;
  border: 1px solid var(--border);
  padding: 1px 6px;
  color: var(--yellow);
}
.md-faq-item {
  border-bottom: 1px solid var(--border);
}
.md-faq-item:last-child {
  border-bottom: none;
}
.md-faq-q {
  width: 100%;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 18px 28px;
  text-align: left;
  font-size: 0.9rem;
  font-weight: 600;
  color: var(--white);
  transition:
    background 0.12s,
    color 0.12s;
}
.md-faq-q:hover {
  background: #0d0d0d;
  color: var(--yellow);
}
.md-faq-q[aria-expanded="true"] {
  background: #0d0d0d;
  color: var(--yellow);
}
.md-faq-icon {
  font-family: var(--mono);
  font-size: 1rem;
  color: var(--muted);
  flex-shrink: 0;
  transition:
    transform 0.2s,
    color 0.12s;
}
.md-faq-q[aria-expanded="true"] .md-faq-icon {
  transform: rotate(45deg);
  color: var(--yellow);
}
.md-faq-a {
  display: none;
  padding: 0 28px 18px;
  font-size: 0.84rem;
  color: var(--muted);
  line-height: 1.7;
  background: #0a0a0a;
  border-top: 1px solid var(--border);
  padding-top: 14px;
}
.md-faq-a.open {
  display: block;
}

/* ── RESPONSIVE ── */
@media (max-width: 1100px) {
  .md-page-body {
    grid-template-columns: 1fr;
  }
}
@media (max-width: 900px) {
  .md-page-header {
    grid-template-columns: 1fr;
  }
  .md-ph-right {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    border-top: 1px solid var(--border);
  }
  .md-ph-stat {
    border-bottom: none;
    border-right: 1px solid var(--border);
  }
  .md-ph-stat:last-child {
    border-right: none;
  }
  .md-ph-left {
    padding: 28px 20px;
  }
  .md-editor-wrap {
    grid-template-columns: 1fr;
    grid-template-rows: 1fr 1fr;
  }
  .md-editor-pane {
    border-right: none;
    border-bottom: 1px solid var(--border);
  }
  .md-export-grid {
    grid-template-columns: repeat(2, 1fr);
  }
  .md-export-btn:nth-child(2n) {
    border-right: none;
  }
  .md-cheat-grid {
    grid-template-columns: 1fr;
  }
  .md-cheat-item {
    border-right: none;
  }
}
@media (max-width: 600px) {
  .md-ph-title {
    font-size: 2.8rem;
  }
  .md-toolbar {
    overflow-x: auto;
  }
  .md-export-grid {
    grid-template-columns: 1fr;
  }
  .md-export-btn {
    border-right: none;
  }
}

/* Mobile Screens (Max 480px) */
@media (max-width: 480px) {
  .md-tph {
    height: auto;
    flex-wrap: wrap;
    padding: 10px 16px;
    gap: 10px;
  }
  .md-tph-actions {
    width: 100%;
    flex-wrap: wrap;
    border-top: 1px solid var(--border);
  }
  .md-tph-btn {
    flex: 1;
    border-right: none;
    border-left: 1px solid var(--border);
  }
  .md-tph-btn:first-child {
    border-left: none;
  }
}
