:root {
  color-scheme: dark;
  --bg: #080b10;
  --bg-2: #0c1118;
  --panel: #101720;
  --panel-2: #141d28;
  --line: #223041;
  --line-soft: rgba(133, 162, 194, 0.18);
  --text: #eef6ff;
  --muted: #93a4b8;
  --dim: #65768a;
  --cyan: #46e6d8;
  --green: #66f0a4;
  --amber: #f3c969;
  --red: #ff7171;
  --blue: #7bb7ff;
  --violet: #bfa6ff;
  --shadow: 0 24px 80px rgba(0, 0, 0, 0.42);
  --radius: 8px;
  --radius-sm: 6px;
  --mono: "SFMono-Regular", "Cascadia Code", "Roboto Mono", Consolas, monospace;
  --sans: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

* {
  box-sizing: border-box;
}

html {
  min-height: 100%;
  background: var(--bg);
}

body {
  min-height: 100vh;
  margin: 0;
  color: var(--text);
  font-family: var(--sans);
  line-height: 1.5;
  background:
    linear-gradient(rgba(70, 230, 216, 0.035) 1px, transparent 1px),
    linear-gradient(90deg, rgba(70, 230, 216, 0.035) 1px, transparent 1px),
    radial-gradient(circle at 10% 0%, rgba(70, 230, 216, 0.11), transparent 32rem),
    radial-gradient(circle at 100% 18%, rgba(243, 201, 105, 0.08), transparent 28rem),
    linear-gradient(135deg, #080b10 0%, #0b1018 48%, #07090d 100%);
  background-size: 32px 32px, 32px 32px, auto, auto, auto;
}

a {
  color: inherit;
  text-decoration: none;
}

button,
input,
textarea,
select {
  font: inherit;
}

button {
  cursor: pointer;
}

button:disabled {
  cursor: not-allowed;
  opacity: 0.52;
}

.app-shell {
  width: min(1180px, calc(100% - 32px));
  margin: 0 auto;
  padding: 24px 0 48px;
}

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 18px;
  min-height: 58px;
  margin-bottom: 28px;
  padding: 10px 0;
}

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

.brand-mark {
  display: grid;
  width: 38px;
  height: 38px;
  place-items: center;
  border: 1px solid rgba(70, 230, 216, 0.48);
  border-radius: var(--radius);
  color: var(--cyan);
  background: linear-gradient(135deg, rgba(70, 230, 216, 0.16), rgba(123, 183, 255, 0.08));
  box-shadow: 0 0 28px rgba(70, 230, 216, 0.16);
  font-family: var(--mono);
  font-size: 18px;
  font-weight: 700;
}

.brand-kicker,
.eyebrow,
.metric-label,
.field-label,
.badge,
.pill,
.status-pill {
  font-family: var(--mono);
  text-transform: uppercase;
}

.brand-kicker {
  margin: 0;
  color: var(--muted);
  font-size: 11px;
}

.brand-title {
  margin: 0;
  color: var(--text);
  font-size: 18px;
  font-weight: 720;
}

.nav {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: flex-end;
  gap: 8px;
}

.nav a {
  min-height: 34px;
  padding: 8px 10px;
  border: 1px solid transparent;
  border-radius: var(--radius-sm);
  color: var(--muted);
  font-size: 13px;
  transition: border-color 160ms ease, color 160ms ease, background 160ms ease;
}

.nav a:hover,
.nav a.active {
  border-color: var(--line);
  color: var(--text);
  background: rgba(255, 255, 255, 0.035);
}

.hero,
.tool-hero {
  display: grid;
  grid-template-columns: 1.35fr 0.65fr;
  gap: 20px;
  align-items: stretch;
  margin-bottom: 22px;
}

.hero-main,
.hero-aside,
.panel,
.tool-card,
.result-card,
.advanced-panel,
.input-panel,
.history-panel {
  border: 1px solid var(--line-soft);
  border-radius: var(--radius);
  background: linear-gradient(180deg, rgba(20, 29, 40, 0.92), rgba(12, 17, 24, 0.92));
  box-shadow: var(--shadow);
}

.hero-main,
.hero-aside {
  position: relative;
  overflow: hidden;
  padding: 26px;
}

.hero-main::before,
.input-panel::before,
.scanline::before {
  content: "";
  position: absolute;
  inset: 0;
  pointer-events: none;
  background: linear-gradient(90deg, transparent, rgba(70, 230, 216, 0.06), transparent);
  transform: translateX(-100%);
  animation: scan 4s ease-in-out infinite;
}

@keyframes scan {
  0% { transform: translateX(-100%); }
  52% { transform: translateX(100%); }
  100% { transform: translateX(100%); }
}

.eyebrow {
  margin: 0 0 8px;
  color: var(--cyan);
  font-size: 12px;
}

h1,
h2,
h3 {
  margin: 0;
  line-height: 1.12;
}

h1 {
  max-width: 820px;
  font-size: 46px;
  font-weight: 780;
}

h2 {
  font-size: 24px;
}

h3 {
  font-size: 17px;
}

.lead {
  max-width: 760px;
  margin: 14px 0 0;
  color: #c7d5e6;
  font-size: 17px;
}

.intent {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  margin-top: 18px;
  padding: 9px 11px;
  border: 1px solid rgba(70, 230, 216, 0.28);
  border-radius: var(--radius-sm);
  color: #d9fff9;
  background: rgba(70, 230, 216, 0.07);
  font-family: var(--mono);
  font-size: 12px;
}

.hero-aside {
  display: grid;
  gap: 12px;
  align-content: start;
}

.signal-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 10px 0;
  border-bottom: 1px solid var(--line-soft);
}

.signal-row:last-child {
  border-bottom: 0;
}

.signal-label {
  color: var(--muted);
  font-size: 13px;
}

.signal-value {
  color: var(--text);
  font-family: var(--mono);
  font-size: 13px;
}

.tools-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 14px;
}

.tool-card {
  display: grid;
  min-height: 190px;
  padding: 18px;
  transition: transform 160ms ease, border-color 160ms ease, background 160ms ease;
}

.tool-card:hover {
  transform: translateY(-2px);
  border-color: rgba(70, 230, 216, 0.34);
  background: linear-gradient(180deg, rgba(22, 35, 48, 0.96), rgba(12, 17, 24, 0.96));
}

.tool-card-head,
.section-head,
.result-head,
.row-between {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.tool-card p,
.panel p,
.result-card p,
.advanced-panel p {
  color: var(--muted);
}

.tool-card p {
  margin: 10px 0 16px;
  font-size: 14px;
}

.badge,
.pill,
.status-pill {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 24px;
  padding: 3px 8px;
  border: 1px solid var(--line);
  border-radius: 999px;
  color: var(--muted);
  background: rgba(255, 255, 255, 0.035);
  font-size: 10px;
  white-space: nowrap;
}

.badge.local { color: var(--green); border-color: rgba(102, 240, 164, 0.32); }
.badge.api { color: var(--blue); border-color: rgba(123, 183, 255, 0.35); }
.badge.beta { color: var(--amber); border-color: rgba(243, 201, 105, 0.35); }
.badge.advanced { color: var(--violet); border-color: rgba(191, 166, 255, 0.35); }
.status-pill.measured { color: var(--green); border-color: rgba(102, 240, 164, 0.32); }
.status-pill.estimated { color: var(--amber); border-color: rgba(243, 201, 105, 0.35); }
.status-pill.api-source { color: var(--blue); border-color: rgba(123, 183, 255, 0.35); }
.status-pill.unavailable { color: var(--dim); border-color: rgba(147, 164, 184, 0.24); }
.status-pill.bad { color: var(--red); border-color: rgba(255, 113, 113, 0.36); }

.btn,
.ghost-btn,
.icon-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  min-height: 40px;
  border: 1px solid rgba(70, 230, 216, 0.34);
  border-radius: var(--radius-sm);
  color: #06100f;
  background: linear-gradient(135deg, var(--cyan), #9af5c5);
  font-weight: 720;
  transition: transform 140ms ease, border-color 140ms ease, background 140ms ease;
}

.btn {
  padding: 9px 13px;
}

.btn:hover,
.ghost-btn:hover,
.icon-btn:hover {
  transform: translateY(-1px);
}

.ghost-btn,
.icon-btn {
  color: var(--text);
  background: rgba(255, 255, 255, 0.035);
}

.ghost-btn {
  padding: 9px 12px;
}

.icon-btn {
  width: 40px;
  padding: 0;
}

.btn-row,
.toolbar {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.section {
  margin-top: 18px;
}

.panel,
.input-panel,
.history-panel {
  position: relative;
  padding: 18px;
}

.input-panel {
  overflow: hidden;
}

.grid-2 {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 14px;
}

.grid-3 {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 14px;
}

.metric-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 12px;
}

.metric {
  min-height: 94px;
  padding: 14px;
  border: 1px solid var(--line-soft);
  border-radius: var(--radius);
  background: rgba(255, 255, 255, 0.032);
}

.metric-label {
  display: flex;
  align-items: center;
  gap: 6px;
  min-height: 18px;
  color: var(--muted);
  font-size: 10px;
}

.metric-value {
  margin-top: 8px;
  overflow-wrap: anywhere;
  color: var(--text);
  font-family: var(--mono);
  font-size: 23px;
  font-weight: 760;
}

.metric .status-pill {
  margin-top: 8px;
}

.metric-note {
  margin-top: 4px;
  color: var(--dim);
  font-size: 12px;
}

.form-grid {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 10px;
}

.field {
  display: grid;
  gap: 7px;
}

.field-label {
  color: var(--muted);
  font-size: 11px;
}

input[type="text"],
input[type="password"],
input[type="number"],
textarea,
select {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  color: var(--text);
  background: rgba(3, 7, 11, 0.7);
  outline: none;
}

input,
select {
  min-height: 42px;
  padding: 9px 11px;
}

textarea {
  min-height: 220px;
  resize: vertical;
  padding: 12px;
}

input:focus,
textarea:focus,
select:focus {
  border-color: rgba(70, 230, 216, 0.6);
  box-shadow: 0 0 0 3px rgba(70, 230, 216, 0.08);
}

.advanced-toggle {
  width: 100%;
  margin-top: 14px;
  justify-content: space-between;
}

.advanced-panel {
  display: none;
  margin-top: 12px;
  padding: 18px;
}

.advanced-panel.open {
  display: block;
}

.tooltip {
  position: relative;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 17px;
  height: 17px;
  border: 1px solid rgba(147, 164, 184, 0.52);
  border-radius: 999px;
  color: var(--cyan);
  font-family: var(--mono);
  font-size: 11px;
  line-height: 1;
}

.tooltip::after {
  content: attr(data-tip);
  position: absolute;
  z-index: 20;
  left: 50%;
  bottom: calc(100% + 9px);
  width: min(260px, 78vw);
  padding: 10px 11px;
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  color: var(--text);
  background: #101720;
  box-shadow: var(--shadow);
  font-family: var(--sans);
  font-size: 12px;
  font-weight: 520;
  line-height: 1.35;
  text-transform: none;
  transform: translateX(-50%) translateY(4px);
  opacity: 0;
  pointer-events: none;
  transition: opacity 140ms ease, transform 140ms ease;
}

.tooltip:hover::after,
.tooltip:focus::after {
  opacity: 1;
  transform: translateX(-50%) translateY(0);
}

.kv {
  display: grid;
  grid-template-columns: minmax(130px, 0.42fr) minmax(0, 1fr);
  gap: 0;
  border: 1px solid var(--line-soft);
  border-radius: var(--radius);
  overflow: hidden;
}

.kv div {
  padding: 10px 12px;
  border-bottom: 1px solid var(--line-soft);
}

.kv div:nth-last-child(-n + 2) {
  border-bottom: 0;
}

.kv .k {
  color: var(--muted);
  background: rgba(255, 255, 255, 0.026);
  font-family: var(--mono);
  font-size: 12px;
}

.kv .v {
  overflow-wrap: anywhere;
  color: var(--text);
  font-family: var(--mono);
  font-size: 12px;
}

.result-card {
  padding: 16px;
}

.result-card.good { border-color: rgba(102, 240, 164, 0.32); }
.result-card.warn { border-color: rgba(243, 201, 105, 0.34); }
.result-card.bad { border-color: rgba(255, 113, 113, 0.36); }

.empty,
.limit-note,
.error-box,
.success-box {
  padding: 12px;
  border-radius: var(--radius-sm);
  color: var(--muted);
  background: rgba(255, 255, 255, 0.032);
}

.limit-note {
  border: 1px solid rgba(243, 201, 105, 0.22);
}

.error-box {
  border: 1px solid rgba(255, 113, 113, 0.34);
  color: #ffd6d6;
}

.success-box {
  border: 1px solid rgba(102, 240, 164, 0.32);
  color: #d9ffe9;
}

.mini-list {
  display: grid;
  gap: 8px;
  margin: 12px 0 0;
  padding: 0;
  list-style: none;
}

.mini-list li {
  padding: 10px;
  border: 1px solid var(--line-soft);
  border-radius: var(--radius-sm);
  color: var(--muted);
  background: rgba(255, 255, 255, 0.025);
}

.lexicon-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 9px;
  margin-top: 12px;
}

.lexicon-term {
  padding: 10px;
  border: 1px solid var(--line-soft);
  border-radius: var(--radius-sm);
}

.lexicon-term strong {
  display: block;
  color: var(--text);
  font-family: var(--mono);
  font-size: 12px;
}

.lexicon-term span {
  display: block;
  margin-top: 5px;
  color: var(--muted);
  font-size: 12px;
}

.gauge-row {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 12px;
}

.gauge {
  display: grid;
  min-height: 150px;
  place-items: center;
  padding: 14px;
  border: 1px solid var(--line-soft);
  border-radius: var(--radius);
  background: rgba(255, 255, 255, 0.026);
}

.gauge-ring {
  display: grid;
  width: 104px;
  height: 104px;
  place-items: center;
  border-radius: 50%;
  background:
    radial-gradient(circle at center, #101720 0 58%, transparent 59%),
    conic-gradient(var(--gauge-color, var(--cyan)) calc(var(--gauge-value, 0) * 1%), rgba(255, 255, 255, 0.08) 0);
}

.gauge-number {
  color: var(--text);
  font-family: var(--mono);
  font-size: 20px;
  font-weight: 780;
}

.gauge span {
  margin-top: 9px;
  color: var(--muted);
  font-family: var(--mono);
  font-size: 11px;
  text-transform: uppercase;
}

.chart-box {
  height: 220px;
  border: 1px solid var(--line-soft);
  border-radius: var(--radius);
  overflow: hidden;
  background: rgba(3, 7, 11, 0.45);
}

canvas {
  display: block;
  width: 100%;
  height: 100%;
}

.progress {
  width: 100%;
  height: 10px;
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.055);
}

.progress span {
  display: block;
  width: 0%;
  height: 100%;
  background: linear-gradient(90deg, var(--cyan), var(--green));
  transition: width 160ms ease;
}

.tabs {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin: 14px 0;
}

.tab {
  min-height: 34px;
  padding: 7px 10px;
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  color: var(--muted);
  background: rgba(255, 255, 255, 0.026);
}

.tab.active {
  color: var(--cyan);
  border-color: rgba(70, 230, 216, 0.45);
}

.dropzone {
  display: grid;
  min-height: 190px;
  place-items: center;
  padding: 20px;
  border: 1px dashed rgba(70, 230, 216, 0.42);
  border-radius: var(--radius);
  color: var(--muted);
  text-align: center;
  background: rgba(70, 230, 216, 0.035);
}

.preview {
  max-width: 100%;
  max-height: 360px;
  border-radius: var(--radius);
  border: 1px solid var(--line-soft);
}

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

.swatch {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  min-height: 32px;
  padding: 6px 8px;
  border: 1px solid var(--line-soft);
  border-radius: var(--radius-sm);
  color: var(--muted);
  font-family: var(--mono);
  font-size: 11px;
}

.swatch i {
  width: 18px;
  height: 18px;
  border-radius: 4px;
  border: 1px solid rgba(255, 255, 255, 0.22);
}

.password-field {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto auto;
  gap: 8px;
}

.meter {
  height: 12px;
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.055);
}

.meter span {
  display: block;
  height: 100%;
  width: 0;
  background: var(--red);
  transition: width 180ms ease, background 180ms ease;
}

.toast-host {
  position: fixed;
  right: 18px;
  bottom: 18px;
  z-index: 60;
  display: grid;
  gap: 8px;
  width: min(360px, calc(100vw - 36px));
}

.toast {
  padding: 11px 12px;
  border: 1px solid rgba(70, 230, 216, 0.28);
  border-radius: var(--radius-sm);
  color: var(--text);
  background: rgba(16, 23, 32, 0.96);
  box-shadow: var(--shadow);
  font-size: 13px;
}

.hidden {
  display: none !important;
}

.mono {
  font-family: var(--mono);
}

.muted {
  color: var(--muted);
}

.danger {
  color: var(--red);
}

.ok {
  color: var(--green);
}

.warn {
  color: var(--amber);
}

.info {
  color: var(--cyan);
}

@media (max-width: 980px) {
  .hero,
  .tool-hero,
  .grid-2,
  .grid-3 {
    grid-template-columns: 1fr;
  }

  .tools-grid,
  .metric-grid,
  .gauge-row {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .topbar {
    align-items: flex-start;
    flex-direction: column;
  }

  .nav {
    justify-content: flex-start;
  }

  h1 {
    font-size: 36px;
  }
}

@media (max-width: 640px) {
  .app-shell {
    width: min(100% - 22px, 1180px);
    padding-top: 12px;
  }

  .hero-main,
  .hero-aside,
  .panel,
  .input-panel,
  .history-panel,
  .advanced-panel {
    padding: 14px;
  }

  .tools-grid,
  .metric-grid,
  .gauge-row,
  .lexicon-grid {
    grid-template-columns: 1fr;
  }

  .form-grid,
  .password-field {
    grid-template-columns: 1fr;
  }

  .kv {
    grid-template-columns: 1fr;
  }

  .kv .k {
    border-bottom: 0;
  }

  .kv .v {
    border-bottom: 1px solid var(--line-soft);
  }

  h1 {
    font-size: 30px;
  }

  .lead {
    font-size: 15px;
  }
}
