/* =========================
   Mindset Digital · Heading Structure Analyzer
   ========================= */

.mdt-heading-analyzer {
  background: var(--md-background); color: var(--md-foreground);
  min-height: 100vh; display: grid; place-items: start center; padding: 2rem;
}
@supports (height:1dvh) { .mdt-heading-analyzer { min-height: 100dvh; } }
.mdt-heading-analyzer .md-card { width: min(880px, 96vw); background: var(--md-surface,#fff); }

/* Header */
.header-row { display:flex; align-items:center; justify-content:space-between; gap:1rem; margin-bottom:.75rem; }
.theme-toggle { display:inline-flex; align-items:center; gap:.5rem; padding:.35rem .65rem; border:1px solid var(--md-border,rgba(0,0,0,.12)); border-radius:999px; background:transparent; color:var(--md-foreground); cursor:pointer; line-height:1; }
.theme-toggle:hover { background:rgba(0,0,0,.04); }
[data-theme="dark"] .theme-toggle:hover { background:rgba(255,255,255,.06); }
.theme-toggle svg { width:18px; height:18px; display:block; }
#iconMoon { display:none; } [data-theme="dark"] #iconSun { display:none; } [data-theme="dark"] #iconMoon { display:block; }
@media (max-width:480px) { .theme-toggle__label { display:none; } }

/* Input */
.form-label { font-weight: 600; font-size: .9rem; color: var(--md-foreground); margin-bottom: .3rem; }

.html-textarea {
  width: 100%; box-sizing: border-box;
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  font-size: .82rem; line-height: 1.55;
  resize: vertical; min-height: 180px;
  padding: .75rem .85rem;
  border: 1px solid var(--md-border);
  border-radius: var(--md-radius, 8px);
  background: var(--md-surface);
  color: var(--md-foreground);
  tab-size: 2;
}
.html-textarea:focus { border-color: var(--md-color-primary); }

/* Actions */
.actions { display:flex; gap:.65rem; flex-wrap:wrap; margin:1rem 0; align-items:center; position:relative; }
.md-btn { background:var(--md-color-primary,#1063ff); color:var(--md-color-primary-contrast,#fff); }
.md-btn--secondary { background:var(--md-color-secondary,#f0b138); color:var(--md-color-secondary-contrast,#090a08); }

/* Help */
.icon-btn { display:inline-flex; align-items:center; justify-content:center; width:32px; height:32px; padding:0; border:1px solid var(--md-border); border-radius:50%; background:var(--md-surface); color:var(--md-foreground); cursor:pointer; }
.icon-btn svg { width:18px; height:18px; }
.help-popover { position:absolute; right:0; top:100%; margin-top:.5rem; z-index:1000; width:min(540px,86vw); background:var(--md-surface); color:var(--md-foreground); border:1px solid var(--md-border); border-radius:var(--md-radius); box-shadow:0 10px 30px rgba(0,0,0,.12); padding:.85rem 1rem; display:none; }
.help-popover.is-open { display:block; }
.help-popover ul { padding-left:1.2rem; margin:.5rem 0; }
.help-popover li { margin-bottom:.4rem; }
.help-popover code { background:rgba(0,0,0,.06); padding:.1rem .3rem; border-radius:3px; font-size:.85em; }
[data-theme="dark"] .help-popover code { background:rgba(255,255,255,.08); }

/* Summary bar */
.summary-bar {
  display: flex; flex-wrap: wrap; gap: .5rem;
  margin-bottom: 1rem;
}
.summary-chip {
  display: inline-flex; align-items: center; gap: .3rem;
  padding: .35rem .7rem; border-radius: 999px;
  font-size: .85rem; font-weight: 600;
  background: rgba(16,99,255,.08); color: var(--md-color-primary);
  border: 1px solid rgba(16,99,255,.15);
}
.summary-chip.chip-warn {
  background: rgba(245,158,11,.08); color: #b45309;
  border-color: rgba(245,158,11,.2);
}
[data-theme="dark"] .summary-chip.chip-warn { color: #fbbf24; }
.summary-chip.chip-error {
  background: rgba(220,38,38,.08); color: #dc2626;
  border-color: rgba(220,38,38,.15);
}
.summary-chip.chip-ok {
  background: rgba(22,163,74,.08); color: #16a34a;
  border-color: rgba(22,163,74,.15);
}

/* Warnings list */
.warnings-list { display: grid; gap: .4rem; margin-bottom: 1rem; }

.warning-item {
  display: flex; align-items: flex-start; gap: .5rem;
  padding: .6rem .75rem;
  border-radius: 8px;
  font-size: .88rem;
  line-height: 1.45;
}
.warning-item.warn-error {
  background: rgba(220,38,38,.06);
  border: 1px solid rgba(220,38,38,.15);
  color: #dc2626;
}
[data-theme="dark"] .warning-item.warn-error { color: #f87171; }
.warning-item.warn-warning {
  background: rgba(245,158,11,.06);
  border: 1px solid rgba(245,158,11,.15);
  color: #b45309;
}
[data-theme="dark"] .warning-item.warn-warning { color: #fbbf24; }
.warning-item.warn-info {
  background: rgba(16,99,255,.06);
  border: 1px solid rgba(16,99,255,.12);
  color: var(--md-color-primary);
}
.warn-icon { flex-shrink: 0; font-size: 1rem; line-height: 1.3; }

/* Heading tree */
.section-heading { font-size: 1rem; font-weight: 600; margin: .5rem 0 .75rem; color: var(--md-foreground); font-family: var(--md-font-body); }

.heading-tree { display: grid; gap: .25rem; }

.ht-item {
  display: flex; align-items: center; gap: .5rem;
  padding: .4rem .6rem;
  border-radius: 6px;
  font-size: .9rem;
  line-height: 1.4;
  border: 1px solid transparent;
  transition: background .15s;
}
.ht-item:hover { background: rgba(0,0,0,.02); }
[data-theme="dark"] .ht-item:hover { background: rgba(255,255,255,.03); }

.ht-item.ht-error {
  border-color: rgba(220,38,38,.2);
  background: rgba(220,38,38,.03);
}

.ht-tag {
  display: inline-flex; align-items: center; justify-content: center;
  min-width: 32px; padding: .15rem .4rem;
  border-radius: 4px;
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  font-size: .78rem; font-weight: 700;
  text-transform: uppercase; flex-shrink: 0;
}
.ht-tag-h1 { background: #dbeafe; color: #1d4ed8; }
.ht-tag-h2 { background: #d1fae5; color: #047857; }
.ht-tag-h3 { background: #fef3c7; color: #b45309; }
.ht-tag-h4 { background: #fce7f3; color: #be185d; }
.ht-tag-h5 { background: #ede9fe; color: #6d28d9; }
.ht-tag-h6 { background: #f1f5f9; color: #475569; }
[data-theme="dark"] .ht-tag-h1 { background: #1e3a5f; color: #93c5fd; }
[data-theme="dark"] .ht-tag-h2 { background: #064e3b; color: #6ee7b7; }
[data-theme="dark"] .ht-tag-h3 { background: #78350f; color: #fcd34d; }
[data-theme="dark"] .ht-tag-h4 { background: #831843; color: #f9a8d4; }
[data-theme="dark"] .ht-tag-h5 { background: #4c1d95; color: #c4b5fd; }
[data-theme="dark"] .ht-tag-h6 { background: #334155; color: #94a3b8; }

/* Char count badge */
.ht-chars {
  display: inline-flex; align-items: center; justify-content: center;
  min-width: 24px; padding: .1rem .35rem;
  border-radius: 3px;
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  font-size: .72rem; font-weight: 500;
  color: color-mix(in srgb, var(--md-foreground) 50%, transparent);
  background: rgba(0,0,0,.04);
  flex-shrink: 0;
}
[data-theme="dark"] .ht-chars { background: rgba(255,255,255,.06); }
.ht-chars-long { background: rgba(245,158,11,.12); color: #b45309; }
[data-theme="dark"] .ht-chars-long { color: #fbbf24; }
.ht-chars-short { background: rgba(16,99,255,.08); color: var(--md-color-primary); }

.ht-text {
  color: var(--md-foreground);
  word-break: break-word;
}

/* Export row */
.export-row {
  display: flex; gap: .5rem; flex-wrap: wrap;
  margin-top: 1rem; padding-top: .75rem;
  border-top: 1px solid var(--md-border);
}
.md-btn--small { font-size: .82rem; padding: .35rem .7rem; }

/* Status */
.status-line { font-family:ui-monospace,SFMono-Regular,Menlo,Consolas,monospace; font-size:.95rem; color:var(--md-foreground); display:inline-block; padding:.3rem .5rem; border-radius:6px; background:color-mix(in srgb,var(--md-surface) 85%,transparent); min-height:1.4em; }
.status-line::after { content:"▊"; margin-left:.3rem; opacity:.7; animation:blink 1s steps(2,end) infinite; }
@keyframes blink { 0%,50%{opacity:0} 50.01%,100%{opacity:1} }

/* A11y */
.skip-link { position:absolute; left:.5rem; top:-1000px; background:var(--md-foreground); color:var(--md-background); padding:.5rem .75rem; border-radius:6px; text-decoration:none; }
.skip-link:focus { top:.5rem; z-index:10; }
textarea:focus-visible,input:focus-visible,button:focus-visible,select:focus-visible { outline:3px solid var(--md-focus,#0a57ff); outline-offset:2px; }
:root { color-scheme:light dark; }
.sr-only { position:absolute; width:1px; height:1px; margin:-1px; overflow:hidden; clip:rect(0 0 0 0); }
