:root {
  --bg: #0b0e10;
  --panel: #14181b;
  --panel-2: #191e22;
  --panel-3: #20262b;
  --border: #2b3339;
  --border-soft: #22292e;
  --text: #e8edf0;
  --muted: #8f9ba3;
  --blue: #22a8e0;
  --blue-hover: #29b5ff;
  --amber: #ffb61e;
  --green: #52c77a;
  --red: #ff6370;
  --warning: #f2c14e;
  --shadow: 0 14px 40px rgba(0, 0, 0, .25);
}

* { box-sizing: border-box; }
html, body { min-height: 100%; }
body {
  margin: 0;
  background:
    radial-gradient(circle at 8% -10%, rgba(34,168,224,.10), transparent 32rem),
    radial-gradient(circle at 90% 0%, rgba(255,182,30,.055), transparent 28rem),
    var(--bg);
  color: var(--text);
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}
button, input { font: inherit; }
button { color: inherit; }

.topbar {
  height: 74px;
  border-bottom: 1px solid var(--border-soft);
  background: rgba(11, 14, 16, .88);
  backdrop-filter: blur(14px);
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 max(22px, calc((100vw - 1480px) / 2));
  position: sticky;
  top: 0;
  z-index: 20;
}
.brand { display: flex; align-items: center; gap: 13px; }
.brand-mark {
  color: var(--amber);
  font-family: "Cascadia Code", "SFMono-Regular", Consolas, monospace;
  font-weight: 800;
  letter-spacing: -.8px;
  font-size: 20px;
  padding: 8px 10px;
  border: 1px solid rgba(255,182,30,.28);
  background: rgba(255,182,30,.06);
  border-radius: 8px;
}
.brand-title { font-size: 18px; font-weight: 750; letter-spacing: .2px; }
.brand-subtitle { color: var(--muted); font-size: 12px; margin-top: 2px; }
.header-status { display: flex; align-items: center; gap: 8px; color: var(--muted); font-size: 13px; }
.status-dot { width: 8px; height: 8px; background: var(--warning); border-radius: 50%; box-shadow: 0 0 0 4px rgba(242,193,78,.08); }
.header-status.online .status-dot { background: var(--green); box-shadow: 0 0 0 4px rgba(82,199,122,.08); }
.header-status.offline .status-dot { background: var(--red); box-shadow: 0 0 0 4px rgba(255,99,112,.08); }

.app-shell { width: min(1480px, calc(100% - 36px)); margin: 22px auto 42px; }
.panel { background: var(--panel); border: 1px solid var(--border-soft); border-radius: 10px; box-shadow: var(--shadow); }
.toolbar { min-height: 70px; display: flex; align-items: center; gap: 20px; padding: 12px 14px; margin-bottom: 16px; }
.selector-group { display: flex; align-items: center; gap: 10px; }
.selector-label { font-size: 12px; color: var(--muted); font-weight: 650; text-transform: uppercase; letter-spacing: .6px; }
.segmented { display: inline-flex; padding: 3px; border-radius: 8px; background: #0e1214; border: 1px solid var(--border-soft); }
.segment { border: 0; background: transparent; color: #aab4ba; min-width: 70px; padding: 8px 13px; border-radius: 6px; cursor: pointer; font-size: 13px; font-weight: 650; transition: .15s ease; }
.segment:hover { color: #fff; }
.segment.active { background: var(--panel-3); color: #fff; box-shadow: inset 0 0 0 1px #303941; }
.toolbar-spacer { flex: 1; }
.button { border: 1px solid transparent; min-height: 39px; border-radius: 7px; padding: 0 14px; cursor: pointer; font-weight: 700; font-size: 13px; display: inline-flex; align-items: center; gap: 10px; justify-content: center; transition: .15s ease; }
.button.primary { background: var(--blue); color: #061016; }
.button.primary:hover { background: var(--blue-hover); transform: translateY(-1px); }
.button.primary:disabled { opacity: .55; cursor: wait; transform: none; }
.button.secondary { background: var(--panel-3); border-color: #303940; color: #d8e0e4; }
.button.secondary:hover { border-color: #3d4a52; background: #242b30; }
.kbd { color: rgba(6,16,22,.68); font-size: 10px; border-left: 1px solid rgba(6,16,22,.22); padding-left: 9px; }
.file-button { user-select: none; }

.workspace { display: grid; grid-template-columns: minmax(0, 1fr) 310px; gap: 16px; align-items: stretch; }
.editor-column { min-height: 610px; position: relative; overflow: hidden; display: flex; flex-direction: column; }
.side-column { display: flex; flex-direction: column; gap: 16px; }
.panel-header { min-height: 62px; border-bottom: 1px solid var(--border-soft); display: flex; align-items: center; justify-content: space-between; gap: 14px; padding: 11px 14px; }
.panel-header.compact { min-height: 52px; }
.panel-header h2 { margin: 0; font-size: 14px; font-weight: 760; }
.panel-header p { margin: 4px 0 0; color: var(--muted); font-size: 11px; }
.editor-header { min-height: 52px; }
.file-meta { display: flex; align-items: center; gap: 9px; min-width: 0; }
.file-icon { font-family: Consolas, monospace; font-size: 11px; font-weight: 800; color: var(--blue); background: rgba(34,168,224,.08); border: 1px solid rgba(34,168,224,.22); padding: 4px 6px; border-radius: 4px; }
.filename-input { width: min(360px, 42vw); background: transparent; color: #dfe6ea; border: 1px solid transparent; border-radius: 5px; padding: 6px 8px; outline: none; font-size: 13px; }
.filename-input:hover, .filename-input:focus { border-color: var(--border); background: #101416; }
.icon-button { border: 1px solid var(--border); border-radius: 6px; background: var(--panel-2); color: #b8c2c8; padding: 7px 9px; cursor: pointer; font-size: 11px; }
.icon-button:hover { color: #fff; border-color: #3a454d; }
.editor { flex: 1; min-height: 520px; }
.editor-footer { height: 28px; background: #101416; border-top: 1px solid var(--border-soft); display: flex; align-items: center; justify-content: flex-end; gap: 18px; padding: 0 11px; color: #849097; font-family: Consolas, monospace; font-size: 10px; }
.drop-overlay { display: none; position: absolute; inset: 52px 0 28px 0; background: rgba(14,18,20,.91); border: 2px dashed var(--blue); color: #d9f2fc; z-index: 15; align-items: center; justify-content: center; font-size: 18px; font-weight: 750; pointer-events: none; }
.editor-column.dragging .drop-overlay { display: flex; }

.reference-list { padding: 8px; }
.ref-item { padding: 11px 10px; border-radius: 7px; border: 1px solid transparent; display: grid; grid-template-columns: 1fr auto; gap: 4px 9px; }
.ref-item + .ref-item { margin-top: 4px; }
.ref-item:hover { background: var(--panel-2); border-color: var(--border-soft); }
.ref-title { font-size: 12px; font-weight: 720; text-transform: capitalize; }
.ref-version { font-family: Consolas, monospace; font-size: 10px; color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.ref-build { color: #77848b; font-size: 10px; }
.ref-state { align-self: center; grid-row: 1 / span 2; grid-column: 2; width: 8px; height: 8px; border-radius: 50%; background: var(--red); }
.ref-item.available .ref-state { background: var(--green); }
.skeleton { height: 48px; border-radius: 6px; margin: 4px 0; background: linear-gradient(90deg, #171c1f, #20262a, #171c1f); background-size: 240% 100%; animation: shimmer 1.4s infinite linear; }
@keyframes shimmer { to { background-position: -240% 0; } }
.info-copy { padding: 14px; color: var(--muted); font-size: 12px; line-height: 1.55; }
.info-copy p { margin: 0 0 9px; }
.info-copy p:last-child { margin-bottom: 0; }

.results { margin-top: 16px; overflow: hidden; }
.results-header { min-height: 66px; }
.results-stats { display: flex; gap: 8px; flex-wrap: wrap; justify-content: flex-end; }
.stat-pill { border: 1px solid var(--border); background: #101416; border-radius: 999px; padding: 5px 8px; color: var(--muted); font-size: 10px; font-weight: 680; }
.stat-pill.good { color: var(--green); border-color: rgba(82,199,122,.25); }
.stat-pill.bad { color: var(--red); border-color: rgba(255,99,112,.25); }
.stat-pill.warning { color: var(--warning); border-color: rgba(242,193,78,.25); }
.stat-pill.info { color: var(--blue); border-color: rgba(34,168,224,.25); }
.results-body { min-height: 112px; }
.empty-state { display: flex; align-items: center; justify-content: center; gap: 13px; color: var(--muted); padding: 24px; text-align: left; }
.empty-state strong { color: #cfd8dd; font-size: 13px; }
.empty-state p { margin: 3px 0 0; font-size: 11px; }
.empty-icon { width: 34px; height: 34px; border-radius: 50%; display: grid; place-items: center; border: 1px solid var(--border); color: #748087; }
.result-group + .result-group { border-top: 1px solid var(--border-soft); }
.result-group-header {
  width: 100%;
  border: 0;
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 16px;
  padding: 10px 13px;
  background: #101416;
  color: inherit;
  text-align: left;
}
.collapsible-header { cursor: pointer; }
.collapsible-header:hover { background: #151a1d; }
.result-heading-main { min-width: 0; display: flex; align-items: center; gap: 10px; }
.result-heading-meta { display: flex; align-items: center; justify-content: flex-end; gap: 12px; flex-wrap: wrap; }
.result-target-stats { display: flex; align-items: center; gap: 6px; flex-wrap: wrap; justify-content: flex-end; }
.result-target { font-size: 12px; font-weight: 750; text-transform: capitalize; }
.result-target small { color: var(--muted); font-weight: 500; margin-left: 8px; }
.result-badge { font-size: 10px; font-weight: 800; text-transform: uppercase; letter-spacing: .4px; white-space: nowrap; }
.result-badge.success { color: var(--green); }
.result-badge.failure { color: var(--red); }
.collapse-chevron {
  width: 7px;
  height: 7px;
  flex: 0 0 7px;
  border-right: 2px solid #77848b;
  border-bottom: 2px solid #77848b;
  transform: rotate(45deg);
  transition: transform .14s ease;
  margin-top: -3px;
}
.result-group.collapsed > .result-group-header .collapse-chevron,
.severity-group.collapsed > .severity-header .collapse-chevron {
  transform: rotate(-45deg);
  margin-top: 0;
}
.result-group.collapsed > .result-group-body { display: none; }

.severity-group { border-top: 1px solid #1d2327; }
.severity-header {
  width: 100%;
  border: 0;
  background: #121719;
  color: inherit;
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 13px 8px 22px;
  cursor: pointer;
  text-align: left;
}
.severity-header:hover { background: #171d20; }
.severity-title {
  font-size: 10px;
  line-height: 1;
  font-weight: 850;
  text-transform: uppercase;
  letter-spacing: .45px;
}
.severity-title.error { color: var(--red); }
.severity-title.warning { color: var(--warning); }
.severity-title.info, .severity-title.hidden { color: var(--blue); }
.severity-count {
  min-width: 24px;
  height: 20px;
  padding: 0 7px;
  border: 1px solid var(--border);
  border-radius: 999px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  color: #9ca8ae;
  background: #0e1214;
  font-family: Consolas, monospace;
  font-size: 10px;
}
.severity-group.collapsed > .severity-body { display: none; }
.diagnostic { width: 100%; border: 0; border-top: 1px solid #1d2327; background: transparent; color: inherit; text-align: left; display: grid; grid-template-columns: 74px 84px minmax(0,1fr) 82px; align-items: center; gap: 8px; padding: 10px 13px; cursor: pointer; }
.diagnostic:hover { background: var(--panel-2); }
.diag-severity { font-size: 10px; font-weight: 850; text-transform: uppercase; }
.diag-severity.error { color: var(--red); }
.diag-severity.warning { color: var(--warning); }
.diag-severity.info, .diag-severity.hidden { color: var(--blue); }
.diag-code { color: #aeb8be; font-family: Consolas, monospace; font-size: 11px; }
.diag-message { font-size: 11px; color: #c9d1d6; line-height: 1.4; overflow-wrap: anywhere; }
.diag-location { color: #7f8b92; font-family: Consolas, monospace; font-size: 10px; text-align: right; }
.no-diagnostics { padding: 18px 14px; color: var(--green); font-size: 12px; }
.api-error { padding: 16px; color: #ffc4c9; background: rgba(255,99,112,.045); font-size: 12px; line-height: 1.5; }

.toast-host { position: fixed; right: 18px; bottom: 18px; z-index: 50; display: flex; flex-direction: column; gap: 8px; }
.toast { background: #1c2226; border: 1px solid #343e45; color: #dce4e8; box-shadow: var(--shadow); border-radius: 7px; padding: 10px 12px; font-size: 12px; min-width: 240px; animation: toast-in .18s ease-out; }
.toast.error { border-color: rgba(255,99,112,.42); }
@keyframes toast-in { from { opacity: 0; transform: translateY(7px); } }

@media (max-width: 980px) {
  .workspace { grid-template-columns: 1fr; }
  .side-column { display: grid; grid-template-columns: 1fr 1fr; }
  .toolbar { flex-wrap: wrap; }
  .toolbar-spacer { display: none; flex-basis: 100%; }
}
@media (max-width: 680px) {
  .app-shell { width: min(100% - 18px, 1480px); margin-top: 10px; }
  .topbar { padding: 0 12px; }
  .brand-subtitle { display: none; }
  .toolbar { gap: 11px; }
  .selector-group { width: 100%; justify-content: space-between; }
  .segmented { flex: 1; }
  .segment { flex: 1; min-width: 0; }
  .button { flex: 1; }
  .side-column { grid-template-columns: 1fr; }
  .diagnostic { grid-template-columns: 64px 70px 1fr; }
  .diag-location { grid-column: 3; text-align: left; }
  .kbd { display: none; }
}

@media (max-width: 760px) {
  .result-group-header { align-items: flex-start; }
  .result-heading-meta { gap: 7px; }
  .result-target-stats { width: 100%; }
  .result-target small { display: block; margin: 3px 0 0; }
}


/* v0.8 bulk validation */
.bulk-file-bar {
  border-bottom: 1px solid var(--border-soft);
  background: #101416;
  padding: 8px 10px;
}
.bulk-file-summary {
  color: var(--muted);
  font-size: 10px;
  margin: 0 0 7px 2px;
}
.bulk-file-list {
  display: flex;
  gap: 6px;
  overflow-x: auto;
  padding-bottom: 2px;
}
.bulk-file-chip {
  flex: 0 0 auto;
  max-width: 260px;
  border: 1px solid var(--border);
  background: var(--panel-2);
  color: #aeb8be;
  border-radius: 6px;
  padding: 6px 9px;
  font-family: Consolas, monospace;
  font-size: 10px;
  cursor: pointer;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.bulk-file-chip:hover { border-color: #3d4a52; color: #e0e7ea; }
.bulk-file-chip.active {
  border-color: rgba(34,168,224,.52);
  background: rgba(34,168,224,.09);
  color: #d8f2fc;
}
.bulk-file-chip.failed {
  box-shadow: inset 0 -2px 0 rgba(255,99,112,.72);
}
.bulk-file-chip.warning-only {
  box-shadow: inset 0 -2px 0 rgba(242,193,78,.72);
}
.bulk-file-chip.passed {
  box-shadow: inset 0 -2px 0 rgba(82,199,122,.62);
}
.bulk-file-result + .bulk-file-result { border-top: 1px solid var(--border-soft); }
.bulk-file-result-header {
  width: 100%;
  border: 0;
  background: #0e1214;
  color: inherit;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 11px 13px;
  cursor: pointer;
  text-align: left;
}
.bulk-file-result-header:hover { background: #151a1d; }
.bulk-file-result-title {
  min-width: 0;
  display: flex;
  align-items: center;
  gap: 9px;
}
.bulk-file-result-name {
  font-family: Consolas, monospace;
  font-size: 11px;
  color: #d8e0e4;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.bulk-file-result-meta {
  display: flex;
  gap: 6px;
  align-items: center;
  justify-content: flex-end;
  flex-wrap: wrap;
}
.bulk-file-result.collapsed > .bulk-file-result-body { display: none; }
.bulk-file-result.collapsed > .bulk-file-result-header .collapse-chevron {
  transform: rotate(-45deg);
  margin-top: 0;
}
.bulk-limit {
  color: #7f8b92;
  font-size: 10px;
  margin-left: 4px;
}
@media (max-width: 680px) {
  .bulk-file-result-header { align-items: flex-start; }
  .bulk-file-result-meta { max-width: 55%; }
}
