:root {
  --bg: #071427;
  --panel: #10284c;
  --panel-dark: #0b1d38;
  --code: #061225;
  --gold: #ffd166;
  --text: #eef4ff;
  --muted: #a9b7cc;
  --border: rgba(255, 255, 255, 0.14);
  --danger: #ff6b6b;
  --ok: #40c057;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  font-family: Tahoma, Arial, sans-serif;
  background:
    radial-gradient(circle at top right, rgba(255, 209, 102, 0.12), transparent 34%),
    var(--bg);
  color: var(--text);
}

.lab-header {
  padding: 18px 22px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 14px;
  border-bottom: 1px solid var(--border);
}

.eyebrow { margin: 0 0 6px; color: var(--gold); font-weight: 700; }
h1 { margin: 0 0 6px; font-size: clamp(20px, 4vw, 34px); }
p { margin: 0; color: var(--muted); font-size: 14px; }

.actions { display: flex; gap: 10px; flex-wrap: wrap; align-items: center; }

button {
  padding: 9px 16px;
  border: 1px solid var(--border);
  border-radius: 12px;
  cursor: pointer;
  background: var(--panel);
  color: var(--text);
  font-weight: bold;
  font-size: 14px;
  transition: opacity 0.15s, background .15s, color .15s;
}

button:hover { opacity: 0.85; }
button.primary { background: var(--gold); color: #071427; border-color: transparent; }
#pickerBtn.is-active { background: var(--gold); color: #071427; border-color: transparent; }

.import-label {
  display: inline-flex;
  align-items: center;
  min-height: 36px;
  padding: 9px 16px;
  border: 1px solid var(--border);
  border-radius: 12px;
  cursor: pointer;
  background: var(--panel);
  color: var(--text);
  font-weight: bold;
  font-size: 14px;
}

.import-label input {
  display: none;
}

.shortcut {
  font-size: 12px;
  color: var(--muted);
  background: rgba(255, 255, 255, 0.06);
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 3px 8px;
  white-space: nowrap;
}

.mode-toggle {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  min-height: 34px;
  padding: 4px 8px;
  border: 1px solid var(--border);
  border-radius: 999px;
  background: rgba(255,255,255,.06);
  color: var(--muted);
  cursor: pointer;
  user-select: none;
  font-size: 12px;
  font-weight: 700;
}

.mode-toggle input { display: none; }

.mode-ui {
  width: 38px;
  height: 20px;
  border-radius: 999px;
  background: rgba(255,255,255,.16);
  position: relative;
  transition: .2s ease;
}

.mode-ui::after {
  content: "";
  width: 16px;
  height: 16px;
  border-radius: 50%;
  background: var(--muted);
  position: absolute;
  top: 2px;
  left: 2px;
  transition: .2s ease;
}

.mode-toggle input:checked + .mode-ui { background: rgba(255, 209, 102, .35); }
.mode-toggle input:checked + .mode-ui::after { left: 20px; background: var(--gold); }

.workspace {
  display: grid;
  grid-template-columns: minmax(360px, .9fr) minmax(420px, 1.1fr);
  gap: 14px;
  padding: 14px;
}

.editor-stack,
.preview-stack { display: grid; gap: 12px; align-content: start; }

.panel {
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 16px;
  overflow: hidden;
  box-shadow: 0 18px 42px rgba(0, 0, 0, 0.22);
}

.panel-head {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 10px;
  padding: 8px 14px;
  background: var(--panel-dark);
  border-bottom: 1px solid var(--border);
}

.panel h2 { margin: 0; color: var(--gold); font-size: 14px; }

.CodeMirror {
  height: 210px;
  background: var(--code) !important;
  font-family: Consolas, Monaco, "Fira Code", monospace;
  font-size: 13.5px;
  line-height: 1.7;
  direction: ltr;
}

.CodeMirror-scroll { background: var(--code); }
.CodeMirror-gutters { background: #050f1f; border-right: 1px solid rgba(255,255,255,.07); }
.CodeMirror-linenumber { color: #3a5070; padding: 0 8px; }
.CodeMirror-activeline-background { background: rgba(255, 209, 102, .04) !important; }
.CodeMirror-cursor { border-left-color: var(--gold) !important; }
.CodeMirror-selected { background: rgba(255, 209, 102, .15) !important; }

.CodeMirror-hints {
  background: #0b1d38;
  border: 1px solid var(--border);
  border-radius: 10px;
  font-family: Consolas, Monaco, monospace;
  font-size: 13px;
  z-index: 9999;
}

.CodeMirror-hint { color: var(--text); padding: 4px 12px; }
.CodeMirror-hint-active { background: rgba(255, 209, 102, .2) !important; color: var(--gold); }

.line-count { font-size: 11px; color: var(--muted); opacity: .7; }

iframe {
  width: 100%;
  height: 390px;
  border: 0;
  background: #fff;
  display: block;
}

.preview-shell {
  min-height: 390px;
  overflow: auto;
  padding: 10px;
  background:
    linear-gradient(45deg, rgba(255,255,255,.04) 25%, transparent 25%),
    linear-gradient(-45deg, rgba(255,255,255,.04) 25%, transparent 25%),
    var(--code);
  background-size: 18px 18px;
}

.preview-shell iframe {
  margin-inline: auto;
  border-radius: 12px;
  box-shadow: 0 16px 35px rgba(0,0,0,.22);
}

.responsive-toolbar {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px;
  border-bottom: 1px solid var(--border);
  background: rgba(255,255,255,.035);
  overflow-x: auto;
}

.device-btn {
  padding: 6px 10px;
  font-size: 12px;
  border-radius: 9px;
  color: var(--muted);
}

.device-btn.is-active {
  background: var(--gold);
  color: #071427;
  border-color: transparent;
}

.custom-size {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  color: var(--muted);
  font-size: 12px;
  white-space: nowrap;
}

.custom-size input,
#projectName {
  border: 1px solid var(--border);
  background: var(--code);
  color: var(--text);
  border-radius: 9px;
  padding: 7px 8px;
  outline: none;
  direction: ltr;
  text-align: left;
}

.custom-size input {
  width: 84px;
}

#viewportLabel {
  color: var(--muted);
  font-family: Consolas, Monaco, monospace;
  font-size: 12px;
  margin-inline-start: auto;
}

.inspector-panel { min-height: 430px; }

.tabs {
  display: flex;
  gap: 6px;
  padding: 8px;
  background: var(--panel-dark);
  border-bottom: 1px solid var(--border);
  overflow-x: auto;
}

.tab {
  padding: 8px 12px;
  border-radius: 10px;
  color: var(--muted);
  background: rgba(255,255,255,.04);
}

.tab.is-active {
  background: var(--gold);
  color: #071427;
  border-color: transparent;
}

.breadcrumbs {
  min-height: 36px;
  padding: 8px 12px;
  border-bottom: 1px solid var(--border);
  color: var(--muted);
  font-family: Consolas, Monaco, monospace;
  font-size: 12px;
  direction: ltr;
  text-align: left;
  overflow-x: auto;
  white-space: nowrap;
}

.tab-panel { display: none; }
.tab-panel.is-active { display: block; }

.dom-tools { padding: 8px; border-bottom: 1px solid var(--border); }

#domSearch {
  width: 100%;
  border: 1px solid var(--border);
  background: var(--code);
  color: var(--text);
  border-radius: 10px;
  padding: 9px 10px;
  outline: none;
  direction: ltr;
  text-align: left;
}

#dom, #info, #console, #cssInspector, #boxModel {
  padding: 12px;
  height: 340px;
  overflow: auto;
  font-family: Consolas, Monaco, monospace;
  font-size: 13px;
  line-height: 1.9;
  direction: ltr;
  text-align: left;
  white-space: pre-wrap;
  color: var(--muted);
}

#info { height: auto; min-height: 120px; border-bottom: 1px solid var(--border); }
#cssInspector { height: 190px; }

#cssRulesInspector {
  padding: 12px;
  height: 320px;
  overflow: auto;
  font-family: Consolas, Monaco, monospace;
  font-size: 12.5px;
  line-height: 1.75;
  direction: ltr;
  text-align: left;
  color: var(--muted);
  border-top: 1px solid var(--border);
}

.rule-card {
  border: 1px solid var(--border);
  border-radius: 12px;
  margin-bottom: 10px;
  background: rgba(255,255,255,.035);
  overflow: hidden;
}

.rule-card__head {
  display: flex;
  justify-content: space-between;
  gap: 10px;
  padding: 8px 10px;
  border-bottom: 1px solid var(--border);
  background: rgba(255,255,255,.035);
}

.rule-selector {
  color: var(--gold);
  font-weight: 800;
}

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

.rule-decl {
  display: grid;
  grid-template-columns: minmax(120px, 180px) 1fr auto;
  gap: 8px;
  padding: 6px 10px;
  border-bottom: 1px solid rgba(255,255,255,.055);
  cursor: pointer;
}

.rule-decl:last-child {
  border-bottom: 0;
}

.rule-decl:hover {
  background: rgba(255,209,102,.07);
}

.rule-decl.overridden {
  opacity: .52;
  text-decoration: line-through;
}

.rule-decl.inherited {
  background: rgba(88,166,255,.055);
}

.rule-prop {
  color: #ffd166;
}

.rule-value {
  color: var(--text);
  word-break: break-word;
}

.rule-line {
  color: var(--muted);
  font-size: 11px;
}

.rule-section-title {
  margin: 12px 0 8px;
  color: var(--gold);
  font-weight: 900;
}

.rule-empty {
  color: var(--muted);
  padding: 8px;
}
#console { height: 300px; }

.csslab-head {
  display: flex;
  justify-content: space-between;
  gap: 10px;
  padding: 10px 12px;
  border-bottom: 1px solid var(--border);
  color: var(--muted);
}

.csslab-head strong {
  color: var(--gold);
}

.csslab-sections {
  height: 340px;
  overflow: auto;
  padding: 10px;
}

.csslab-section {
  border: 1px solid var(--border);
  border-radius: 14px;
  margin-bottom: 10px;
  background: rgba(255,255,255,.035);
  overflow: hidden;
}

.csslab-section summary {
  padding: 10px 12px;
  cursor: pointer;
  color: var(--gold);
  font-weight: 700;
  background: rgba(255,255,255,.035);
}

.control-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(160px, 1fr));
  gap: 10px;
  padding: 12px;
}

.control-grid label {
  display: grid;
  gap: 6px;
  color: var(--muted);
  font-size: 12px;
}

.control-grid input,
.control-grid select {
  width: 100%;
  border: 1px solid var(--border);
  background: var(--code);
  color: var(--text);
  border-radius: 10px;
  padding: 8px;
  outline: none;
}

.control-grid input[type="range"] {
  padding: 0;
}

.control-grid input[type="color"] {
  height: 38px;
  padding: 3px;
}

.control-grid span {
  color: var(--text);
  font-family: Consolas, Monaco, monospace;
  font-size: 12px;
}

.project-tools {
  display: flex;
  gap: 8px;
  padding: 10px;
  border-bottom: 1px solid var(--border);
}

#projectName {
  flex: 1;
  min-width: 0;
}

.recent-projects {
  padding: 12px;
  height: 300px;
  overflow: auto;
  color: var(--muted);
}

.project-card {
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 10px;
  margin-bottom: 8px;
  background: rgba(255,255,255,.04);
}

.project-card strong {
  display: block;
  color: var(--gold);
  margin-bottom: 4px;
}

.project-meta {
  color: var(--muted);
  font-size: 11px;
  margin-bottom: 8px;
}

.project-actions {
  display: flex;
  gap: 6px;
  flex-wrap: wrap;
}

.node {
  padding: 5px 8px;
  margin: 2px 0;
  border-radius: 8px;
  cursor: pointer;
  border: 1px solid transparent;
  color: #dbeafe;
  font-size: 13px;
  display: flex;
  align-items: center;
  gap: 6px;
}

.node:hover { background: rgba(255, 209, 102, .1); border-color: rgba(255, 209, 102, .3); }
.node.selected { background: rgba(255, 209, 102, .18); border-color: rgba(255, 209, 102, .5); color: var(--gold); }
.node.is-hidden-by-search { display: none; }
.node-icon { font-size: 10px; opacity: .5; }

.css-row {
  display: grid;
  grid-template-columns: minmax(120px, 180px) 1fr;
  gap: 8px;
  padding: 6px 0;
  border-bottom: 1px solid rgba(255,255,255,.07);
}

.css-prop { color: var(--gold); }
.css-value { color: var(--text); word-break: break-word; }
.css-group-title { color: var(--gold); margin: 10px 0 6px; font-weight: 700; }

.box-model {
  width: min(100%, 520px);
  margin: 10px auto;
  direction: ltr;
  text-align: center;
  font-family: Tahoma, Arial, sans-serif;
}

.box-layer {
  border: 2px dashed rgba(255,255,255,.28);
  padding: 22px;
  border-radius: 14px;
  position: relative;
  color: #071427;
}

.box-margin { background: rgba(255, 209, 102, .85); }
.box-border { background: rgba(64, 192, 87, .85); }
.box-padding { background: rgba(77, 171, 247, .85); }

.box-content {
  background: rgba(255,255,255,.95);
  border: 2px solid rgba(7,20,39,.25);
  min-height: 58px;
  display: grid;
  place-items: center;
  border-radius: 10px;
}

.box-label { display: block; font-size: 12px; font-weight: 700; margin-bottom: 8px; }

.box-values {
  margin-top: 14px;
  color: var(--text);
  direction: ltr;
  text-align: left;
  font-family: Consolas, Monaco, monospace;
}

.box-model-empty { display: grid; place-items: center; color: var(--muted); }

.console-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 8px 12px;
  border-bottom: 1px solid var(--border);
  color: var(--muted);
}

.console-log { color: var(--text); }
.console-warn { color: #f9c74f; }
.console-error { color: var(--danger); }
.ok { color: var(--ok); }
.error { color: var(--danger); }

.btn-small { padding: 3px 10px; font-size: 12px; border-radius: 8px; }

@media (max-width: 1050px) {
  .workspace { grid-template-columns: 1fr; }
  .CodeMirror { height: 230px; }
}

@media (max-width: 700px) {
  .lab-header { flex-direction: column; align-items: flex-start; }
  .actions { width: 100%; }
  .shortcut { width: 100%; }
}

.modal-backdrop {
  position: fixed;
  inset: 0;
  z-index: 10000;
  display: grid;
  place-items: center;
  padding: 18px;
  background: rgba(0,0,0,.62);
  backdrop-filter: blur(8px);
}

.modal-backdrop[hidden] {
  display: none;
}

.modal {
  width: min(920px, 96vw);
  max-height: min(760px, 92vh);
  overflow: auto;
  border: 1px solid var(--border);
  border-radius: 20px;
  background: var(--panel);
  box-shadow: 0 30px 80px rgba(0,0,0,.45);
}

.modal-head {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
  padding: 16px;
  background: var(--panel-dark);
  border-bottom: 1px solid var(--border);
}

.modal-head h2 {
  margin: 0;
  color: var(--gold);
}

#closeTemplatesBtn {
  width: 38px;
  height: 38px;
  padding: 0;
  border-radius: 50%;
  font-size: 24px;
}

.templates-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(210px, 1fr));
  gap: 12px;
  padding: 16px;
}

.template-card {
  border: 1px solid var(--border);
  border-radius: 16px;
  padding: 14px;
  background: rgba(255,255,255,.045);
  cursor: pointer;
  transition: transform .15s, border-color .15s, background .15s;
}

.template-card:hover {
  transform: translateY(-2px);
  border-color: rgba(255,209,102,.55);
  background: rgba(255,209,102,.08);
}

.template-card strong {
  display: block;
  color: var(--gold);
  margin-bottom: 6px;
}

.template-card p {
  font-size: 12px;
  line-height: 1.7;
}


/* v6 UI Refresh — NTF Hub toolbar + hero */
.toolbar {
  position: sticky;
  top: 0;
  z-index: 100;
  min-height: 88px;
  padding: 14px 24px;
  background: rgba(11, 18, 32, .95);
  backdrop-filter: blur(12px);
  border-bottom: 1px solid rgba(255,255,255,.08);
}

.toolbar-inner {
  max-width: 1500px;
  margin: 0 auto;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 24px;
}

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

.logo {
  width: auto;
  height: 64px;
  max-width: 90px;
  object-fit: contain;
  flex-shrink: 0;
  display: block;
  border: 1px solid rgba(255, 215, 0, .6);
  border-radius: 16px;
  background: rgba(11, 26, 54, .6);
}

.brand-info {
  min-width: 0;
}

.brand-name {
  font-size: 1.15rem;
  font-weight: 800;
  line-height: 1.2;
  color: var(--gold);
}

.brand-tag {
  margin-top: 4px;
  font-size: .85rem;
  color: #9fb2d8;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.back-link {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 10px 16px;
  border-radius: 12px;
  text-decoration: none;
  color: var(--gold);
  border: 1px solid rgba(255, 209, 102, .3);
  background: rgba(255, 209, 102, .08);
  transition: .2s;
  flex-shrink: 0;
}

.back-link:hover {
  transform: translateY(-1px);
  background: rgba(255, 209, 102, .15);
  border-color: var(--gold);
}

.page {
  max-width: 1500px;
  margin: auto;
  padding: 14px 14px 60px;
}

.hero {
  background:
    linear-gradient(135deg, rgba(255, 209, 102, .10), transparent 42%),
    var(--panel);
  border: 1px solid var(--border);
  border-radius: 16px;
  padding: 18px;
  margin-bottom: 12px;
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 18px;
  align-items: center;
  box-shadow: 0 18px 42px rgba(0,0,0,.18);
}

.hero-intro {
  display: flex;
  align-items: center;
  gap: 18px;
}

.hero-logo {
  width: 58px;
  height: 58px;
  display: grid;
  place-items: center;
  flex-shrink: 0;
  border-radius: 18px;
  border: 1px solid rgba(255, 209, 102, .35);
  background: rgba(255, 209, 102, .10);
  font-size: 32px;
}

.hero h1 {
  margin: 0 0 7px;
  color: var(--gold);
  font-size: clamp(1.25rem, 3vw, 2rem);
}

.hero p {
  color: var(--muted);
  line-height: 1.85;
  font-size: .9rem;
  max-width: 760px;
}

.hero-stats {
  display: grid;
  gap: 7px;
  min-width: 230px;
}

.hs {
  background: rgba(255,255,255,.045);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 8px 11px;
  display: flex;
  justify-content: space-between;
  gap: 14px;
  font-size: .82rem;
  color: var(--muted);
}

.hs strong {
  color: var(--gold);
  white-space: nowrap;
}

.lab-controls {
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 14px;
  padding: 10px 12px;
  margin-bottom: 12px;
  display: flex;
  align-items: center;
  gap: 14px;
  flex-wrap: wrap;
  box-shadow: 0 14px 32px rgba(0,0,0,.14);
}

.control-group {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
}

.control-label {
  color: var(--muted);
  font-size: .74rem;
  border-inline-end: 1px solid var(--border);
  padding-inline-end: 8px;
}

.control-btn {
  padding: 8px 13px;
  border-radius: 10px;
  font-size: 13px;
  background: var(--panel-dark);
}

.control-btn.primary {
  background: var(--gold);
  color: #071427;
  border-color: transparent;
}

.control-btn.danger-soft {
  color: var(--danger);
  background: rgba(255, 107, 107, .08);
  border-color: rgba(255, 107, 107, .24);
}

.lab-controls .shortcut {
  margin-inline-start: auto;
}

.lab-controls .mode-toggle {
  min-height: 34px;
  border-radius: 10px;
  background: var(--panel-dark);
}

.lab-controls .import-label {
  min-height: 34px;
  padding: 8px 13px;
  border-radius: 10px;
  background: var(--panel-dark);
  font-size: 13px;
}

.workspace {
  padding: 0;
}

@media (max-width: 900px) {
  .toolbar-inner,
  .hero,
  .hero-intro {
    align-items: flex-start;
  }

  .toolbar-inner,
  .hero {
    grid-template-columns: 1fr;
  }

  .toolbar-inner {
    flex-direction: column;
  }

  .hero {
    display: grid;
  }

  .hero-intro {
    flex-direction: column;
  }

  .hero-stats {
    width: 100%;
    min-width: 0;
  }

  .lab-controls .shortcut {
    width: 100%;
    margin-inline-start: 0;
  }
}


/* v7 Smart Inspector */
.smart-tools {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  padding: 10px 12px;
  border-bottom: 1px solid var(--border);
  background: rgba(255,255,255,.035);
}

#selectorInfo {
  padding: 10px 12px;
  border-bottom: 1px solid var(--border);
  color: var(--muted);
  font-family: Consolas, Monaco, monospace;
  font-size: 12px;
  direction: ltr;
  text-align: left;
  white-space: pre-wrap;
}

.selector-chip {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  margin: 2px 4px 2px 0;
  padding: 4px 8px;
  border-radius: 999px;
  border: 1px solid rgba(255,209,102,.28);
  background: rgba(255,209,102,.08);
  color: var(--gold);
}

.css-source-note {
  margin-top: 8px;
  padding: 8px 10px;
  border: 1px solid rgba(255,209,102,.22);
  border-radius: 10px;
  background: rgba(255,209,102,.06);
  color: var(--muted);
  font-size: 12px;
  line-height: 1.7;
}

/* These styles apply inside iframe through injected CSS too, kept here for reference. */


.ntf-css-target-line {
  background: rgba(255, 209, 102, .18) !important;
}


/* v8 HTML Lab */
.html-lab-head {
  display: flex;
  justify-content: space-between;
  gap: 10px;
  padding: 10px 12px;
  border-bottom: 1px solid var(--border);
  color: var(--muted);
}

.html-lab-head strong {
  color: var(--gold);
}

.html-lab-grid {
  height: 340px;
  overflow: auto;
  padding: 10px;
  display: grid;
  gap: 10px;
}

.html-lab-card {
  border: 1px solid var(--border);
  border-radius: 14px;
  background: rgba(255,255,255,.035);
  overflow: hidden;
}

.html-lab-card h3 {
  margin: 0;
  padding: 10px 12px;
  color: var(--gold);
  font-size: 13px;
  background: rgba(255,255,255,.035);
  border-bottom: 1px solid var(--border);
}

.attr-controls {
  display: grid;
  gap: 10px;
  padding: 12px;
}

.attr-controls label {
  display: grid;
  gap: 6px;
  color: var(--muted);
  font-size: 12px;
}

.attr-controls input,
#elementTextEditor {
  width: 100%;
  border: 1px solid var(--border);
  background: var(--code);
  color: var(--text);
  border-radius: 10px;
  padding: 9px;
  outline: none;
  direction: ltr;
  text-align: left;
  font-family: Consolas, Monaco, monospace;
}

#elementTextEditor {
  min-height: 92px;
  resize: vertical;
  margin: 12px;
  width: calc(100% - 24px);
}

.html-lab-actions,
.html-lab-footer {
  display: flex;
  gap: 8px;
  align-items: center;
  flex-wrap: wrap;
  padding: 10px 12px;
  border-top: 1px solid var(--border);
  color: var(--muted);
}

.html-lab-footer {
  border-top: 1px solid var(--border);
  background: rgba(255,255,255,.035);
}

#htmlOutline,
#a11yReport,
#semanticReport,
#htmlValidator {
  padding: 12px;
  color: var(--muted);
  font-family: Consolas, Monaco, monospace;
  font-size: 12px;
  line-height: 1.8;
  direction: ltr;
  text-align: left;
  white-space: pre-wrap;
}

.html-issue {
  padding: 7px 9px;
  margin-bottom: 7px;
  border-radius: 10px;
  border: 1px solid var(--border);
  background: rgba(255,255,255,.035);
}

.html-issue.warn {
  border-color: rgba(249, 199, 79, .35);
  background: rgba(249, 199, 79, .06);
}

.html-issue.error {
  border-color: rgba(255, 107, 107, .35);
  background: rgba(255, 107, 107, .06);
}

.html-issue.ok {
  border-color: rgba(64, 192, 87, .35);
  background: rgba(64, 192, 87, .06);
}

.html-outline-item {
  display: block;
  padding: 4px 0;
  color: var(--text);
}

.html-outline-level {
  color: var(--gold);
  margin-inline-end: 8px;
}

/* v8.2 HTML Lab Layout Fix */
#tab-htmllab {
  min-height: 520px;
}

#tab-htmllab .html-lab-grid {
  height: min(62vh, 720px);
  min-height: 460px;
  overflow-y: auto;
  overflow-x: hidden;
  display: grid;
  grid-template-columns: minmax(260px, 1fr) minmax(260px, 1fr);
  align-items: start;
  gap: 12px;
}

#tab-htmllab .html-lab-card {
  min-width: 0;
}

#tab-htmllab .attr-controls {
  grid-template-columns: 1fr 1fr;
  align-items: end;
}

#tab-htmllab .attr-controls label {
  min-width: 0;
}

#tab-htmllab .attr-controls input {
  min-width: 0;
  height: 38px;
}

#tab-htmllab #applyAttrsBtn {
  grid-column: 1 / -1;
  justify-self: start;
}

#tab-htmllab #elementTextEditor {
  min-height: 120px;
  display: block;
}

#tab-htmllab #htmlOutline,
#tab-htmllab #a11yReport,
#tab-htmllab #semanticReport,
#tab-htmllab #htmlValidator {
  max-height: 240px;
  overflow: auto;
}

#tab-htmllab .html-lab-footer {
  position: sticky;
  bottom: 0;
  z-index: 5;
  background: var(--panel-dark);
}

@media (max-width: 1100px) {
  #tab-htmllab .html-lab-grid {
    grid-template-columns: 1fr;
  }

  #tab-htmllab .attr-controls {
    grid-template-columns: 1fr;
  }
}

@media (max-width: 720px) {
  #tab-htmllab .html-lab-grid {
    height: auto;
    min-height: 0;
    max-height: none;
  }
}

/* v8.3 HTML Lab Spacing Polish */
#tab-htmllab {
  background: rgba(255,255,255,.018);
}

#tab-htmllab .html-lab-head {
  padding: 14px 16px;
  gap: 16px;
}

#tab-htmllab .html-lab-head strong {
  font-size: 15px;
}

#tab-htmllab #htmlLabTarget {
  line-height: 1.7;
}

#tab-htmllab .html-lab-grid {
  padding: 16px;
  gap: 16px;
  align-items: stretch;
}

#tab-htmllab .html-lab-card {
  border-radius: 18px;
  background: rgba(255,255,255,.045);
  box-shadow: 0 14px 28px rgba(0,0,0,.12);
}

#tab-htmllab .html-lab-card h3 {
  padding: 13px 16px;
  font-size: 14px;
  letter-spacing: .01em;
}

#tab-htmllab .attr-controls {
  padding: 16px;
  gap: 14px;
}

#tab-htmllab .attr-controls label {
  gap: 8px;
  font-size: 12.5px;
  line-height: 1.6;
}

#tab-htmllab .attr-controls input,
#tab-htmllab #elementTextEditor {
  height: 42px;
  padding: 10px 12px;
  border-radius: 12px;
  font-size: 13px;
  line-height: 1.6;
}

#tab-htmllab #elementTextEditor {
  min-height: 150px;
  height: auto;
  margin: 16px;
  width: calc(100% - 32px);
}

#tab-htmllab .html-lab-actions {
  padding: 14px 16px;
  gap: 10px;
}

#tab-htmllab .btn-small {
  padding: 7px 12px;
  border-radius: 10px;
}

#tab-htmllab #htmlOutline,
#tab-htmllab #a11yReport,
#tab-htmllab #semanticReport,
#tab-htmllab #htmlValidator {
  padding: 16px;
  max-height: 300px;
  font-size: 13px;
  line-height: 2;
}

#tab-htmllab .html-outline-item {
  padding: 6px 0;
}

#tab-htmllab .html-issue {
  padding: 10px 12px;
  margin-bottom: 10px;
  border-radius: 12px;
  line-height: 1.8;
}

#tab-htmllab .html-lab-footer {
  padding: 13px 16px;
  gap: 12px;
}

@media (max-width: 1100px) {
  #tab-htmllab .html-lab-grid {
    gap: 14px;
  }
}

@media (max-width: 720px) {
  #tab-htmllab .html-lab-head {
    flex-direction: column;
    align-items: flex-start;
  }

  #tab-htmllab .html-lab-grid {
    padding: 12px;
  }

  #tab-htmllab .attr-controls {
    padding: 14px;
  }
}

/* v8.4 Visual DOM Editor */
.visual-dom-tools {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(160px, 1fr));
  gap: 12px;
  padding: 16px;
}

.visual-dom-tools label {
  display: grid;
  gap: 8px;
  color: var(--muted);
  font-size: 12.5px;
  line-height: 1.6;
}

.visual-dom-tools select {
  width: 100%;
  border: 1px solid var(--border);
  background: var(--code);
  color: var(--text);
  border-radius: 12px;
  padding: 10px 12px;
  outline: none;
}

.visual-dom-note {
  margin: 0 16px 16px;
  padding: 10px 12px;
  border: 1px solid rgba(255,209,102,.22);
  background: rgba(255,209,102,.06);
  color: var(--muted);
  border-radius: 12px;
  line-height: 1.8;
  font-size: 12px;
}

.danger-action {
  color: var(--danger);
  border-color: rgba(255,107,107,.28);
  background: rgba(255,107,107,.08);
}

.node[draggable="true"] {
  user-select: none;
}

.node.dragging {
  opacity: .45;
  border-color: var(--gold);
  background: rgba(255,209,102,.12);
}

.node.drop-target {
  border-color: #40c057;
  background: rgba(64,192,87,.10);
}

.node.drop-before {
  box-shadow: inset 0 3px 0 #40c057;
}

.node.drop-after {
  box-shadow: inset 0 -3px 0 #40c057;
}

/* v8.4.2 HTML Lab Layout Polish after Visual DOM Editor */
#tab-htmllab .html-lab-grid {
  grid-template-columns: repeat(2, minmax(320px, 1fr));
  gap: 18px;
  padding: 18px;
  align-items: start;
  height: min(68vh, 820px);
  min-height: 560px;
}

#tab-htmllab .visual-dom-card {
  grid-column: 1 / -1;
}

#tab-htmllab .visual-dom-tools {
  grid-template-columns: repeat(5, minmax(130px, 1fr));
  gap: 14px;
  padding: 18px;
  align-items: end;
}

#tab-htmllab .visual-dom-tools label {
  min-width: 0;
}

#tab-htmllab .visual-dom-tools select {
  height: 42px;
}

#tab-htmllab .visual-dom-note {
  margin: 0 18px 18px;
}

#tab-htmllab .html-lab-card {
  min-height: auto;
}

#tab-htmllab .attr-controls {
  grid-template-columns: repeat(2, minmax(180px, 1fr));
  gap: 16px;
  padding: 18px;
}

#tab-htmllab #applyAttrsBtn {
  margin-top: 2px;
}

#tab-htmllab #elementTextEditor {
  min-height: 170px;
}

#tab-htmllab .html-lab-card:nth-of-type(4),
#tab-htmllab .html-lab-card:nth-of-type(5),
#tab-htmllab .html-lab-card:nth-of-type(6),
#tab-htmllab .html-lab-card:nth-of-type(7) {
  min-height: 260px;
}

#tab-htmllab #htmlOutline,
#tab-htmllab #a11yReport,
#tab-htmllab #semanticReport,
#tab-htmllab #htmlValidator {
  max-height: 360px;
}

@media (max-width: 1250px) {
  #tab-htmllab .visual-dom-tools {
    grid-template-columns: repeat(3, minmax(150px, 1fr));
  }
}

@media (max-width: 980px) {
  #tab-htmllab .html-lab-grid {
    grid-template-columns: 1fr;
    height: auto;
    min-height: 0;
  }

  #tab-htmllab .visual-dom-tools,
  #tab-htmllab .attr-controls {
    grid-template-columns: 1fr;
  }
}

/* v8.4.3 HTML Lab Declutter — final override */
#tab-htmllab {
  min-height: 720px;
}

#tab-htmllab .html-lab-head {
  padding: 16px 18px !important;
  align-items: flex-start;
}

#tab-htmllab .html-lab-grid {
  display: grid !important;
  grid-template-columns: 1fr !important;
  gap: 22px !important;
  padding: 22px !important;
  height: min(76vh, 980px) !important;
  min-height: 680px !important;
  overflow-y: auto !important;
  overflow-x: hidden !important;
  align-items: start !important;
  scroll-padding: 22px;
}

#tab-htmllab .html-lab-card,
#tab-htmllab .visual-dom-card {
  grid-column: 1 / -1 !important;
  width: 100% !important;
  min-height: unset !important;
  border-radius: 20px !important;
  overflow: visible !important;
}

#tab-htmllab .html-lab-card h3 {
  padding: 16px 20px !important;
  font-size: 15px !important;
}

#tab-htmllab .visual-dom-tools {
  display: grid !important;
  grid-template-columns: repeat(2, minmax(240px, 1fr)) !important;
  gap: 18px !important;
  padding: 20px !important;
  align-items: end !important;
}

#tab-htmllab .visual-dom-tools button {
  min-height: 42px;
}

#tab-htmllab .visual-dom-note {
  margin: 0 20px 20px !important;
  padding: 13px 15px !important;
}

#tab-htmllab .attr-controls {
  display: grid !important;
  grid-template-columns: repeat(2, minmax(240px, 1fr)) !important;
  gap: 18px !important;
  padding: 20px !important;
  align-items: end !important;
}

#tab-htmllab .attr-controls label,
#tab-htmllab .visual-dom-tools label {
  gap: 9px !important;
  line-height: 1.7 !important;
}

#tab-htmllab .attr-controls input,
#tab-htmllab .visual-dom-tools select {
  height: 44px !important;
  font-size: 14px !important;
}

#tab-htmllab #applyAttrsBtn {
  grid-column: 1 / -1 !important;
  width: max-content;
  min-width: 150px;
}

#tab-htmllab #elementTextEditor {
  margin: 20px !important;
  width: calc(100% - 40px) !important;
  min-height: 180px !important;
  font-size: 14px !important;
}

#tab-htmllab .html-lab-actions {
  padding: 16px 20px !important;
}

#tab-htmllab #htmlOutline,
#tab-htmllab #a11yReport,
#tab-htmllab #semanticReport,
#tab-htmllab #htmlValidator {
  padding: 20px !important;
  max-height: none !important;
  min-height: 130px !important;
  font-size: 13.5px !important;
  line-height: 2.05 !important;
}

#tab-htmllab .html-issue {
  margin-bottom: 12px !important;
  padding: 12px 14px !important;
}

#tab-htmllab .html-lab-footer {
  padding: 16px 20px !important;
  position: sticky;
  bottom: 0;
  z-index: 8;
  border-top: 1px solid var(--border);
  background: rgba(11, 29, 56, .98) !important;
  backdrop-filter: blur(10px);
}

@media (max-width: 900px) {
  #tab-htmllab .visual-dom-tools,
  #tab-htmllab .attr-controls {
    grid-template-columns: 1fr !important;
  }

  #tab-htmllab .html-lab-grid {
    height: auto !important;
    min-height: 0 !important;
    padding: 14px !important;
  }

  #tab-htmllab #elementTextEditor {
    margin: 14px !important;
    width: calc(100% - 28px) !important;
  }
}

/* v8.4.4 HTML Formatter */
#tab-htmllab #formatHtmlBtn {
  color: var(--gold);
  border-color: rgba(255,209,102,.35);
  background: rgba(255,209,102,.08);
}

/* v8.5 DOM Tree Tools */
.dom-tools-pro {
  display: grid;
  grid-template-columns: minmax(180px, 1fr) 110px minmax(120px, .7fr) auto auto;
  gap: 8px;
  align-items: center;
}

#domFilterType,
#domFilterValue {
  width: 100%;
  border: 1px solid var(--border);
  background: var(--code);
  color: var(--text);
  border-radius: 10px;
  padding: 9px 10px;
  outline: none;
  direction: ltr;
  text-align: left;
}

.node-toggle {
  width: 18px;
  height: 18px;
  display: inline-grid;
  place-items: center;
  border-radius: 6px;
  color: var(--muted);
  font-size: 10px;
  flex: 0 0 auto;
  cursor: pointer;
}

.node-toggle:hover {
  background: rgba(255,255,255,.08);
  color: var(--gold);
}

.node.is-collapsed-child {
  display: none !important;
}

.node.is-filter-hidden {
  display: none !important;
}

.node-match-mark {
  margin-inline-start: auto;
  color: var(--gold);
  font-size: 10px;
  opacity: .9;
}

.node-count {
  color: var(--muted);
  font-size: 10px;
  opacity: .75;
}

@media (max-width: 900px) {
  .dom-tools-pro {
    grid-template-columns: 1fr 1fr;
  }

  .dom-tools-pro #domSearch {
    grid-column: 1 / -1;
  }
}

/* v8.6 DOM Pro Tools */
.node-quick-input {
  flex: 1;
  min-width: 160px;
  border: 1px solid rgba(255,209,102,.45);
  background: var(--code);
  color: var(--text);
  border-radius: 8px;
  padding: 4px 7px;
  outline: none;
  font-family: Consolas, Monaco, monospace;
  font-size: 12px;
  direction: ltr;
  text-align: left;
}

#tab-htmllab .visual-dom-tools {
  grid-template-columns: repeat(3, minmax(220px, 1fr)) !important;
}

@media (max-width: 1100px) {
  #tab-htmllab .visual-dom-tools {
    grid-template-columns: 1fr !important;
  }
}

/* v8.6.1 DOM Pro Tools visibility */
#tab-htmllab .visual-dom-tools {
  grid-template-columns: repeat(2, minmax(240px, 1fr)) !important;
}

#tab-htmllab #formatHtmlBtn,
#tab-htmllab #renameTagBtn,
#tab-htmllab #wrapElementBtn,
#tab-htmllab #unwrapElementBtn,
#tab-htmllab #copyDomToolBtn {
  min-height: 42px;
}

@media (max-width: 900px) {
  #tab-htmllab .visual-dom-tools {
    grid-template-columns: 1fr !important;
  }
}

/* v8.7 History Engine */
#undoBtn,
#redoBtn {
  min-width: 86px;
}

#undoBtn:disabled,
#redoBtn:disabled {
  opacity: .42;
  cursor: not-allowed;
  filter: grayscale(.25);
}

/* v8.8 Context Menu */
.context-menu {
  position: fixed;
  z-index: 20000;
  min-width: 238px;
  padding: 8px;
  border: 1px solid rgba(255, 209, 102, .28);
  border-radius: 16px;
  background: rgba(7, 20, 39, .98);
  box-shadow: 0 24px 70px rgba(0,0,0,.45);
  backdrop-filter: blur(12px);
  animation: contextPop .12s ease-out;
}

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

.context-menu button {
  width: 100%;
  display: flex;
  justify-content: space-between;
  gap: 12px;
  align-items: center;
  padding: 9px 10px;
  border: 0;
  border-radius: 10px;
  background: transparent;
  color: var(--text);
  text-align: left;
  direction: ltr;
  font-size: 13px;
  font-weight: 700;
}

.context-menu button:hover {
  background: rgba(255, 209, 102, .10);
  color: var(--gold);
  opacity: 1;
}

.context-menu button.danger {
  color: #ff8787;
}

.context-menu button.danger:hover {
  background: rgba(255, 107, 107, .10);
  color: #ffb3b3;
}

.context-menu button span {
  color: var(--muted);
  font-size: 11px;
  font-weight: 400;
}

.context-separator {
  height: 1px;
  margin: 6px 4px;
  background: rgba(255,255,255,.10);
}

@keyframes contextPop {
  from {
    opacity: 0;
    transform: scale(.98) translateY(-2px);
  }
  to {
    opacity: 1;
    transform: scale(1) translateY(0);
  }
}

/* v8.8 Context Menu Fixed */
.context-menu {
  position: fixed;
  z-index: 20000;
  min-width: 238px;
  padding: 8px;
  border: 1px solid rgba(255, 209, 102, .28);
  border-radius: 16px;
  background: rgba(7, 20, 39, .98);
  box-shadow: 0 24px 70px rgba(0,0,0,.45);
  backdrop-filter: blur(12px);
  animation: contextPop .12s ease-out;
  direction: ltr;
}

.context-menu[hidden] {
  display: none !important;
}

.context-menu button {
  width: 100%;
  display: flex;
  justify-content: space-between;
  gap: 12px;
  align-items: center;
  padding: 9px 10px;
  border: 0;
  border-radius: 10px;
  background: transparent;
  color: var(--text, #eef4ff);
  text-align: left;
  direction: ltr;
  font-size: 13px;
  font-weight: 700;
  cursor: pointer;
}

.context-menu button:hover {
  background: rgba(255, 209, 102, .10);
  color: var(--gold, #ffd166);
  opacity: 1;
}

.context-menu button.danger {
  color: #ff8787;
}

.context-menu button.danger:hover {
  background: rgba(255, 107, 107, .10);
  color: #ffb3b3;
}

.context-menu button span {
  color: var(--muted, #a9b7cc);
  font-size: 11px;
  font-weight: 400;
}

.context-separator {
  height: 1px;
  margin: 6px 4px;
  background: rgba(255,255,255,.10);
}

@keyframes contextPop {
  from {
    opacity: 0;
    transform: scale(.98) translateY(-2px);
  }

  to {
    opacity: 1;
    transform: scale(1) translateY(0);
  }
}

/* v9.1 Device Toolbar */
.device-toolbar {
  justify-content: space-between;
  gap: 12px;
  padding: 10px 12px;
}

.device-group {
  display: flex;
  align-items: end;
  gap: 8px;
  flex-wrap: wrap;
}

.device-field {
  display: grid;
  gap: 5px;
  color: var(--muted, #a9b7cc);
  font-size: 11px;
  font-weight: 700;
  line-height: 1.2;
}

.device-field select,
.device-field input {
  height: 34px;
  min-width: 118px;
  border: 1px solid var(--border, rgba(255,255,255,.14));
  background: var(--code, #061225);
  color: var(--text, #eef4ff);
  border-radius: 10px;
  padding: 6px 9px;
  outline: none;
  direction: ltr;
  text-align: left;
}

.device-size-field input {
  width: 92px;
  min-width: 92px;
}

.device-meta {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-inline-start: auto;
  color: var(--muted, #a9b7cc);
  font-family: Consolas, Monaco, monospace;
  font-size: 12px;
  white-space: nowrap;
}

.device-meta span {
  padding: 5px 8px;
  border: 1px solid var(--border, rgba(255,255,255,.14));
  border-radius: 999px;
  background: rgba(255,255,255,.04);
}

.preview-shell {
  min-height: 390px;
}

.preview-shell iframe {
  transition: width .18s ease, height .18s ease;
}

@media (max-width: 760px) {
  .device-toolbar {
    align-items: flex-start;
  }

  .device-group,
  .device-meta {
    width: 100%;
  }

  .device-field {
    flex: 1 1 140px;
  }

  .device-field select,
  .device-field input {
    width: 100%;
  }
}

/* v9.2 Resize Handles + Orientation */
#lockRatioBtn[aria-pressed="true"] {
  color: var(--gold, #ffd166);
  border-color: rgba(255, 209, 102, .45);
  background: rgba(255, 209, 102, .10);
}

.preview-shell {
  position: relative;
}

.viewport-resize-handle {
  width: 18px;
  height: 18px;
  position: sticky;
  left: 100%;
  bottom: 10px;
  margin: -28px 10px 10px auto;
  border-radius: 6px;
  border: 1px solid rgba(255, 209, 102, .55);
  background:
    linear-gradient(135deg, transparent 0 45%, rgba(255,209,102,.9) 45% 55%, transparent 55%),
    rgba(7,20,39,.92);
  cursor: nwse-resize;
  z-index: 20;
  box-shadow: 0 8px 20px rgba(0,0,0,.30);
}

.viewport-resize-handle:hover {
  background:
    linear-gradient(135deg, transparent 0 45%, #ffd166 45% 55%, transparent 55%),
    rgba(255,209,102,.16);
}

body.is-resizing-preview {
  cursor: nwse-resize !important;
  user-select: none;
}

body.is-resizing-preview iframe {
  pointer-events: none;
}

/* v9.3 Breakpoint Inspector */
.breakpoint-inspector {
  display: grid;
  grid-template-columns: auto auto minmax(260px, 1fr);
  gap: 8px;
  padding: 8px;
  border-bottom: 1px solid var(--border, rgba(255,255,255,.14));
  background: rgba(255,255,255,.028);
}

.bp-chip {
  border: 1px solid var(--border, rgba(255,255,255,.14));
  border-radius: 12px;
  padding: 8px 10px;
  background: rgba(255,255,255,.04);
  display: grid;
  gap: 4px;
}

.bp-chip span {
  color: var(--muted, #a9b7cc);
  font-size: 11px;
}

.bp-chip strong {
  color: var(--gold, #ffd166);
  font-family: Consolas, Monaco, monospace;
  font-size: 13px;
}

.bp-media {
  min-width: 0;
}

#bpMediaQueries {
  display: flex;
  gap: 6px;
  flex-wrap: wrap;
  align-items: center;
  color: var(--muted, #a9b7cc);
  font-size: 12px;
}

#bpMediaQueries code {
  direction: ltr;
  border-radius: 999px;
  padding: 4px 8px;
  color: var(--gold, #ffd166);
  background: rgba(255,209,102,.08);
  border: 1px solid rgba(255,209,102,.22);
  font-size: 11px;
}

.bp-muted {
  color: var(--muted, #a9b7cc);
}

@media (max-width: 900px) {
  .breakpoint-inspector {
    grid-template-columns: 1fr;
  }
}

/* v9.4 Media Query Generator */
.media-query-generator {
  display: grid;
  grid-template-columns: 140px 110px 100px 100px auto auto minmax(220px, 1fr);
  gap: 8px;
  align-items: end;
  padding: 8px;
  border-bottom: 1px solid var(--border, rgba(255,255,255,.14));
  background: rgba(255,255,255,.022);
}

.mq-field {
  display: grid;
  gap: 4px;
  color: var(--muted, #a9b7cc);
  font-size: 11px;
  font-weight: 700;
}

.mq-field select,
.mq-field input {
  height: 34px;
  border: 1px solid var(--border, rgba(255,255,255,.14));
  background: var(--code, #061225);
  color: var(--text, #eef4ff);
  border-radius: 10px;
  padding: 6px 9px;
  outline: none;
  direction: ltr;
  text-align: left;
}

#mqPreview {
  min-height: 34px;
  display: flex;
  align-items: center;
  padding: 7px 10px;
  border: 1px solid rgba(255,209,102,.22);
  border-radius: 10px;
  color: var(--gold, #ffd166);
  background: rgba(255,209,102,.06);
  direction: ltr;
  text-align: left;
  overflow-x: auto;
  white-space: nowrap;
}

@media (max-width: 1100px) {
  .media-query-generator {
    grid-template-columns: repeat(2, minmax(130px, 1fr));
  }

  #mqPreview {
    grid-column: 1 / -1;
  }
}

@media (max-width: 650px) {
  .media-query-generator {
    grid-template-columns: 1fr;
  }
}

/* v9.4.1 Media Query Generator Layout Fix */
.media-query-generator {
  grid-template-columns: repeat(auto-fit, minmax(130px, 1fr)) !important;
  align-items: end !important;
  gap: 10px !important;
  padding: 10px !important;
  overflow: hidden !important;
}

.media-query-generator .mq-field {
  min-width: 0 !important;
}

.media-query-generator .mq-field select,
.media-query-generator .mq-field input,
.media-query-generator .device-btn {
  width: 100% !important;
  min-width: 0 !important;
  box-sizing: border-box !important;
}

#generateMqBtn,
#insertCommonMqBtn {
  min-height: 34px !important;
  white-space: normal !important;
  line-height: 1.35 !important;
}

#mqPreview {
  grid-column: 1 / -1 !important;
  width: 100% !important;
  max-width: 100% !important;
  box-sizing: border-box !important;
  overflow-x: auto !important;
  min-width: 0 !important;
}

@media (min-width: 1200px) {
  .media-query-generator {
    grid-template-columns: 150px 110px 110px 110px minmax(150px, auto) minmax(160px, auto) !important;
  }

  #mqPreview {
    grid-column: 1 / -1 !important;
  }
}

@media (max-width: 680px) {
  .media-query-generator {
    grid-template-columns: 1fr !important;
  }
}

/* v9.4.2 Media Query Generator No Overflow — hard override */
.media-query-generator {
  display: flex !important;
  flex-direction: column !important;
  align-items: stretch !important;
  gap: 12px !important;
  padding: 12px !important;
  width: 100% !important;
  max-width: 100% !important;
  box-sizing: border-box !important;
  overflow-x: hidden !important;
}

.media-query-generator .mq-field {
  display: grid !important;
  grid-template-columns: 80px minmax(0, 1fr) !important;
  align-items: center !important;
  gap: 10px !important;
  width: 100% !important;
  min-width: 0 !important;
  box-sizing: border-box !important;
}

.media-query-generator .mq-field span {
  white-space: nowrap !important;
}

.media-query-generator .mq-field select,
.media-query-generator .mq-field input {
  width: 100% !important;
  max-width: 100% !important;
  min-width: 0 !important;
  box-sizing: border-box !important;
}

#generateMqBtn,
#insertCommonMqBtn {
  width: 100% !important;
  max-width: 100% !important;
  min-width: 0 !important;
  box-sizing: border-box !important;
  min-height: 38px !important;
  white-space: normal !important;
}

#mqPreview {
  display: block !important;
  width: 100% !important;
  max-width: 100% !important;
  min-width: 0 !important;
  box-sizing: border-box !important;
  overflow-x: auto !important;
  white-space: nowrap !important;
}

/* cancel any previous grid-column rules */
.media-query-generator > * {
  grid-column: auto !important;
}

@media (max-width: 520px) {
  .media-query-generator .mq-field {
    grid-template-columns: 1fr !important;
    gap: 6px !important;
  }
}

/* v9.5 Multi Device Compare */
#toggleCompareBtn[aria-pressed="true"] {
  color: var(--gold, #ffd166);
  border-color: rgba(255, 209, 102, .45);
  background: rgba(255, 209, 102, .10);
}

.multi-device-compare {
  border-bottom: 1px solid var(--border, rgba(255,255,255,.14));
  background: rgba(255,255,255,.022);
  padding: 12px;
}

.multi-device-compare[hidden] {
  display: none !important;
}

.compare-head {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  align-items: center;
  margin-bottom: 12px;
}

.compare-head strong {
  color: var(--gold, #ffd166);
}

.compare-head span {
  color: var(--muted, #a9b7cc);
  font-size: 12px;
}

.compare-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(220px, 1fr));
  gap: 12px;
  align-items: start;
}

.compare-device {
  min-width: 0;
  border: 1px solid var(--border, rgba(255,255,255,.14));
  border-radius: 16px;
  background: rgba(255,255,255,.04);
  overflow: hidden;
}

.compare-device header {
  display: flex;
  justify-content: space-between;
  gap: 10px;
  padding: 9px 11px;
  border-bottom: 1px solid var(--border, rgba(255,255,255,.14));
  color: var(--muted, #a9b7cc);
  font-size: 12px;
}

.compare-device header strong {
  color: var(--gold, #ffd166);
}

.compare-device iframe {
  display: block;
  border: 0;
  background: #fff;
  transform-origin: top left;
  max-width: none;
}

.compare-device {
  overflow: auto;
  max-height: 460px;
}

@media (max-width: 1100px) {
  .compare-grid {
    grid-template-columns: 1fr;
  }

  .compare-device {
    max-height: 520px;
  }
}

/* v9.5.1 Multi Device Compare Scale-to-Fit */
.compare-device {
  overflow: hidden !important;
  max-height: none !important;
}

.compare-viewport {
  position: relative;
  width: 100%;
  overflow: hidden;
  padding: 9px;
  box-sizing: border-box;
  background:
    linear-gradient(45deg, rgba(255,255,255,.035) 25%, transparent 25%),
    linear-gradient(-45deg, rgba(255,255,255,.035) 25%, transparent 25%),
    rgba(0,0,0,.10);
  background-size: 16px 16px;
}

.compare-frame {
  display: block !important;
  border: 0 !important;
  background: #fff !important;
  max-width: none !important;
  border-radius: 10px;
  box-shadow: 0 14px 32px rgba(0,0,0,.28);
  pointer-events: auto;
}

.compare-viewport::after {
  content: "scale " attr(data-scale);
  position: absolute;
  right: 12px;
  bottom: 10px;
  padding: 3px 6px;
  border-radius: 999px;
  background: rgba(7,20,39,.82);
  color: var(--gold, #ffd166);
  border: 1px solid rgba(255,209,102,.22);
  font-size: 10px;
  font-family: Consolas, Monaco, monospace;
}

/* v9.5.2 Compare Visible Fix */
.multi-device-compare:not([hidden]) {
  display: block !important;
}

.compare-grid {
  align-items: stretch !important;
}

.compare-device {
  min-height: 280px !important;
  overflow: hidden !important;
}

.compare-viewport {
  min-height: 220px !important;
  height: 280px;
  overflow: hidden !important;
  position: relative !important;
}

.compare-frame {
  display: block !important;
  opacity: 1 !important;
  visibility: visible !important;
  position: relative !important;
  transform-origin: top left !important;
}

.compare-viewport::before {
  content: "";
  position: absolute;
  inset: 9px;
  border: 1px dashed rgba(255, 209, 102, .18);
  border-radius: 10px;
  pointer-events: none;
}

/* v9.5.3 Compare Centered Fit */
.multi-device-compare {
  overflow: hidden !important;
}

.compare-grid {
  grid-template-columns: repeat(3, minmax(240px, 1fr)) !important;
}

.compare-device {
  overflow: hidden !important;
  max-height: none !important;
  min-height: 0 !important;
}

.compare-viewport {
  position: relative !important;
  width: 100% !important;
  min-height: 260px !important;
  overflow: hidden !important;
  direction: ltr !important;
  box-sizing: border-box !important;
  padding: 0 !important;
}

.compare-frame {
  position: absolute !important;
  display: block !important;
  border: 0 !important;
  background: #fff !important;
  max-width: none !important;
  margin: 0 !important;
  opacity: 1 !important;
  visibility: visible !important;
  border-radius: 12px !important;
  box-shadow: 0 16px 36px rgba(0,0,0,.30) !important;
}

.compare-viewport::before {
  content: "";
  position: absolute;
  inset: 12px;
  border: 1px dashed rgba(255, 209, 102, .18);
  border-radius: 14px;
  pointer-events: none;
}

.compare-viewport::after {
  content: "scale " attr(data-scale) " • " attr(data-visible);
  position: absolute;
  right: 14px;
  bottom: 12px;
  padding: 4px 8px;
  border-radius: 999px;
  background: rgba(7,20,39,.88);
  color: var(--gold, #ffd166);
  border: 1px solid rgba(255,209,102,.22);
  font-size: 10px;
  font-family: Consolas, Monaco, monospace;
  direction: ltr;
}

@media (max-width: 1100px) {
  .compare-grid {
    grid-template-columns: 1fr !important;
  }
}

/* v9.5 Compare Removed */
#toggleCompareBtn,
#multiDeviceCompare,
.multi-device-compare,
.compare-grid,
.compare-device,
.compare-viewport,
.compare-frame {
  display: none !important;
}

/* v9.6 Responsive Audit */
.responsive-audit {
  border-bottom: 1px solid var(--border, rgba(255,255,255,.14));
  background: rgba(255,255,255,.022);
  padding: 12px;
  display: grid;
  gap: 10px;
}

.audit-head {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  align-items: center;
}

.audit-head strong {
  color: var(--gold, #ffd166);
  display: block;
  margin-bottom: 4px;
}

.audit-head span {
  color: var(--muted, #a9b7cc);
  font-size: 12px;
}

.audit-actions {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
}

.audit-score {
  display: flex;
  gap: 10px;
  align-items: center;
  flex-wrap: wrap;
  border: 1px solid var(--border, rgba(255,255,255,.14));
  border-radius: 12px;
  padding: 9px 11px;
  background: rgba(255,255,255,.04);
}

.audit-score span {
  color: var(--muted, #a9b7cc);
  font-size: 12px;
}

.audit-score strong {
  color: var(--gold, #ffd166);
}

.audit-score em {
  color: var(--muted, #a9b7cc);
  font-style: normal;
  font-size: 12px;
}

.audit-score.ok strong {
  color: #69db7c;
}

.audit-score.warn strong {
  color: #ffd166;
}

.audit-score.error strong {
  color: #ff8787;
}

.audit-results {
  display: grid;
  gap: 8px;
  color: var(--muted, #a9b7cc);
}

.audit-issue {
  border: 1px solid var(--border, rgba(255,255,255,.14));
  border-radius: 14px;
  padding: 10px;
  background: rgba(255,255,255,.04);
  display: grid;
  gap: 6px;
}

.audit-issue.error {
  border-color: rgba(255, 107, 107, .32);
  background: rgba(255, 107, 107, .06);
}

.audit-issue.warn {
  border-color: rgba(255, 209, 102, .32);
  background: rgba(255, 209, 102, .06);
}

.audit-issue.info {
  border-color: rgba(88, 166, 255, .30);
  background: rgba(88, 166, 255, .055);
}

.audit-issue header {
  display: flex;
  justify-content: space-between;
  gap: 10px;
  align-items: center;
}

.audit-issue header strong {
  color: var(--text, #eef4ff);
}

.audit-issue header button {
  border: 1px solid rgba(255,209,102,.24);
  background: rgba(255,209,102,.08);
  color: var(--gold, #ffd166);
  border-radius: 999px;
  padding: 4px 9px;
  cursor: pointer;
}

.audit-issue header button:disabled {
  opacity: .4;
  cursor: not-allowed;
}

.audit-issue p {
  margin: 0;
  color: var(--muted, #a9b7cc);
  line-height: 1.7;
}

.audit-issue code {
  width: max-content;
  max-width: 100%;
  overflow-x: auto;
  color: var(--gold, #ffd166);
  background: rgba(0,0,0,.18);
  border-radius: 8px;
  padding: 4px 7px;
  direction: ltr;
}

.audit-issue small {
  color: #dbeafe;
  line-height: 1.7;
}

.audit-empty {
  border: 1px solid rgba(105,219,124,.28);
  background: rgba(105,219,124,.07);
  color: #b2f2bb;
  border-radius: 12px;
  padding: 10px 12px;
}

@media (max-width: 800px) {
  .audit-head {
    align-items: flex-start;
    flex-direction: column;
  }

  .audit-actions {
    width: 100%;
  }

  .audit-actions .device-btn {
    flex: 1;
  }
}

/* v10 NTF AI Lab */
.ntf-ai-lab {
  display: grid;
  gap: 12px;
  height: 100%;
  min-height: 520px;
  padding: 12px;
  overflow: auto;
  background:
    radial-gradient(circle at top right, rgba(255, 209, 102, .08), transparent 36%),
    rgba(255,255,255,.018);
}

.ntf-ai-lab__head {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 12px;
  border: 1px solid var(--border, rgba(255,255,255,.14));
  background: rgba(255,255,255,.04);
  border-radius: 16px;
  padding: 12px;
}

.ntf-ai-lab__head strong {
  display: block;
  color: var(--gold, #ffd166);
  font-size: 16px;
  margin-bottom: 5px;
}

.ntf-ai-lab__head span {
  color: var(--muted, #a9b7cc);
  font-size: 12px;
  line-height: 1.7;
}

.ntf-ai-lab__status {
  flex-shrink: 0;
  border: 1px solid rgba(255,209,102,.24);
  background: rgba(255,209,102,.08);
  color: var(--gold, #ffd166) !important;
  border-radius: 999px;
  padding: 5px 9px;
  font-size: 11px !important;
}

.ntf-ai-lab__actions {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(145px, 1fr));
  gap: 8px;
}

.ntf-ai-lab__actions .btn-small {
  min-height: 38px;
}

.ntf-ai-lab__prompt {
  display: grid;
  gap: 8px;
  color: var(--muted, #a9b7cc);
  font-size: 12px;
  line-height: 1.7;
}

.ntf-ai-lab__prompt textarea {
  width: 100%;
  min-height: 84px;
  resize: vertical;
  border: 1px solid var(--border, rgba(255,255,255,.14));
  background: var(--code, #061225);
  color: var(--text, #eef4ff);
  border-radius: 12px;
  padding: 10px;
  outline: none;
  line-height: 1.7;
}

.ntf-ai-lab__options {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  color: var(--muted, #a9b7cc);
  font-size: 12px;
}

.ntf-ai-lab__options label {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  border: 1px solid var(--border, rgba(255,255,255,.14));
  border-radius: 999px;
  padding: 7px 10px;
  background: rgba(255,255,255,.035);
}

.ntf-ai-lab__result {
  min-height: 260px;
  border: 1px solid var(--border, rgba(255,255,255,.14));
  border-radius: 16px;
  padding: 12px;
  background: rgba(0,0,0,.16);
  color: var(--muted, #a9b7cc);
  line-height: 1.8;
  overflow: auto;
}

.ntf-ai-response {
  display: grid;
  gap: 10px;
}

.ntf-ai-response__title {
  color: var(--gold, #ffd166);
  font-weight: 900;
}

.ntf-ai-card {
  border: 1px solid var(--border, rgba(255,255,255,.14));
  background: rgba(255,255,255,.04);
  border-radius: 14px;
  padding: 10px;
}

.ntf-ai-card strong {
  color: var(--text, #eef4ff);
}

.ntf-ai-card p {
  margin: 6px 0 0;
  color: var(--muted, #a9b7cc);
}

.ntf-ai-code {
  direction: ltr;
  text-align: left;
  white-space: pre-wrap;
  background: var(--code, #061225);
  color: var(--text, #eef4ff);
  border: 1px solid var(--border, rgba(255,255,255,.14));
  border-radius: 12px;
  padding: 10px;
  overflow: auto;
  font-family: Consolas, Monaco, monospace;
  font-size: 12px;
}

.ntf-ai-error {
  border: 1px solid rgba(255,107,107,.35);
  background: rgba(255,107,107,.07);
  color: #ffb3b3;
  border-radius: 12px;
  padding: 10px;
}

.ntf-ai-loading {
  color: var(--gold, #ffd166);
}

/* v10.1 Templates Fix */
.templates-modal {
  width: min(920px, calc(100vw - 32px));
  max-height: min(760px, calc(100vh - 32px));
  overflow: auto;
  border: 1px solid var(--border, rgba(255,255,255,.14));
  border-radius: 24px;
  background: rgba(7, 20, 39, .98);
  box-shadow: 0 30px 90px rgba(0,0,0,.48);
  padding: 16px;
}

.templates-modal__head {
  display: flex;
  justify-content: space-between;
  gap: 14px;
  align-items: flex-start;
  margin-bottom: 14px;
}

.templates-modal__head strong {
  display: block;
  color: var(--gold, #ffd166);
  font-size: 18px;
}

.templates-modal__head span {
  color: var(--muted, #a9b7cc);
  font-size: 12px;
  line-height: 1.7;
}

.modal-close {
  border: 1px solid var(--border, rgba(255,255,255,.14));
  background: rgba(255,255,255,.06);
  color: var(--text, #eef4ff);
  border-radius: 12px;
  width: 36px;
  height: 36px;
  cursor: pointer;
  font-size: 20px;
}

.templates-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(190px, 1fr));
  gap: 12px;
}

.template-card {
  min-height: 126px;
  display: grid;
  gap: 8px;
  align-content: start;
  border: 1px solid var(--border, rgba(255,255,255,.14));
  border-radius: 18px;
  background: rgba(255,255,255,.045);
  color: var(--text, #eef4ff);
  padding: 14px;
  text-align: start;
  cursor: pointer;
}

.template-card:hover {
  border-color: rgba(255, 209, 102, .38);
  background: rgba(255,209,102,.08);
  transform: translateY(-1px);
}

.template-card strong {
  color: var(--gold, #ffd166);
  font-size: 15px;
}

.template-card span {
  color: var(--muted, #a9b7cc);
  font-size: 12px;
  line-height: 1.7;
}
