:root {
  color-scheme: light;
  --bg: #f4f6f8;
  --panel: #ffffff;
  --ink: #16211e;
  --muted: #64706b;
  --line: #dce3e0;
  --teal: #0f766e;
  --blue: #2f5d9f;
  --orange: #c05621;
  --red: #9f343f;
  --olive: #6b7d2a;
  --shadow: 0 18px 50px rgba(22, 33, 30, 0.08);
}

* {
  box-sizing: border-box;
}

html {
  min-width: 320px;
  background: var(--bg);
}

body {
  margin: 0;
  font-family:
    Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI",
    sans-serif;
  color: var(--ink);
  background:
    linear-gradient(180deg, rgba(255, 255, 255, 0.92), rgba(244, 246, 248, 0.98) 36rem),
    var(--bg);
}

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

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

.topbar {
  position: sticky;
  top: 0;
  z-index: 10;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  width: min(1180px, calc(100% - 32px));
  margin: 0 auto;
  padding: 18px 0;
  background: rgba(244, 246, 248, 0.86);
  backdrop-filter: blur(14px);
}

.brand,
.top-links {
  display: flex;
  align-items: center;
}

.brand {
  gap: 12px;
}

.brand-mark {
  display: grid;
  width: 42px;
  height: 42px;
  place-items: center;
  border-radius: 8px;
  color: white;
  background: var(--teal);
  font-size: 0.86rem;
  font-weight: 800;
}

.brand strong,
.brand small {
  display: block;
}

.brand small,
.muted,
.top-links a,
.tool-tab small,
.panel-heading p,
.hero-text {
  color: var(--muted);
}

.top-links {
  gap: 8px;
}

.top-links a,
.ghost-button,
.primary-button,
.download-link {
  min-height: 38px;
  border-radius: 8px;
  padding: 9px 13px;
  border: 1px solid var(--line);
  background: rgba(255, 255, 255, 0.72);
}

main {
  width: min(1180px, calc(100% - 32px));
  margin: 0 auto 56px;
}

.workspace-hero {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(280px, 520px);
  gap: 28px;
  align-items: stretch;
  padding: 34px 0 28px;
}

.hero-copy {
  display: flex;
  min-height: 260px;
  flex-direction: column;
  justify-content: center;
}

.eyebrow {
  margin: 0 0 10px;
  color: var(--teal);
  font-size: 0.78rem;
  font-weight: 800;
  letter-spacing: 0;
  text-transform: uppercase;
}

h1,
h2,
h3,
p {
  margin-top: 0;
}

h1 {
  max-width: 12ch;
  margin-bottom: 16px;
  font-size: clamp(2.2rem, 7vw, 4.8rem);
  line-height: 0.98;
  letter-spacing: 0;
}

h2 {
  margin-bottom: 8px;
  font-size: 1.9rem;
  line-height: 1.1;
  letter-spacing: 0;
}

h3 {
  margin-bottom: 10px;
  font-size: 1rem;
  line-height: 1.25;
}

.hero-text {
  max-width: 60ch;
  font-size: 1.02rem;
  line-height: 1.8;
}

#signal-map {
  width: 100%;
  height: auto;
  align-self: center;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #f7faf9;
  box-shadow: var(--shadow);
}

.tool-layout {
  display: grid;
  grid-template-columns: 360px minmax(0, 1fr);
  gap: 20px;
  align-items: start;
}

.tool-sidebar,
.tool-panel {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel);
  box-shadow: var(--shadow);
}

.tool-sidebar {
  position: sticky;
  top: 86px;
  max-height: calc(100vh - 104px);
  overflow: auto;
  padding: 14px;
}

.sidebar-title,
.panel-heading,
.score-line {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
}

.sidebar-title {
  margin-bottom: 12px;
  padding: 0 4px;
  color: var(--muted);
  font-size: 0.9rem;
}

.sidebar-title strong {
  color: var(--ink);
}

.tool-list {
  display: grid;
  gap: 8px;
}

.category-filter {
  display: flex;
  gap: 8px;
  overflow-x: auto;
  padding: 0 4px 12px;
  border-bottom: 1px solid var(--line);
  margin-bottom: 12px;
}

.category-chip {
  flex: 0 0 auto;
  border: 1px solid var(--line);
  border-radius: 999px;
  padding: 7px 10px;
  color: var(--muted);
  background: #fbfcfc;
  cursor: pointer;
  font-size: 0.82rem;
  font-weight: 800;
}

.category-chip:hover,
.category-chip.active {
  border-color: rgba(15, 118, 110, 0.36);
  color: var(--teal);
  background: #edf8f5;
}

.tool-group {
  display: grid;
  gap: 8px;
}

.tool-group + .tool-group {
  margin-top: 12px;
}

.tool-group h3 {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin: 2px 4px;
  color: var(--muted);
  font-size: 0.78rem;
}

.tool-group h3 span {
  color: var(--teal);
}

.tool-tab {
  width: 100%;
  border: 1px solid transparent;
  border-radius: 8px;
  padding: 13px;
  color: var(--ink);
  text-align: left;
  background: #f8faf9;
  cursor: pointer;
}

.tool-tab:hover,
.tool-tab.active {
  border-color: rgba(15, 118, 110, 0.36);
  background: #edf8f5;
}

.tool-tab span,
.tool-tab strong,
.tool-tab small {
  display: block;
}

.tool-tab span {
  margin-bottom: 6px;
  color: var(--teal);
  font-size: 0.75rem;
  font-weight: 800;
}

.tool-tab strong {
  margin-bottom: 5px;
  line-height: 1.25;
}

.tool-tab small {
  line-height: 1.45;
}

.tool-panel {
  min-width: 0;
  padding: 24px;
}

.panel-heading {
  margin-bottom: 22px;
  align-items: flex-start;
}

.ghost-button,
.primary-button,
.download-link {
  cursor: pointer;
  font-weight: 800;
}

.ghost-button {
  flex: 0 0 auto;
  color: var(--teal);
}

.primary-button {
  width: 100%;
  border-color: var(--teal);
  color: white;
  background: var(--teal);
}

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

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

.field:has(textarea),
.field:has(input[type="file"]),
.primary-button {
  grid-column: 1 / -1;
}

.field span {
  color: #40504a;
  font-size: 0.9rem;
  font-weight: 800;
}

.field small {
  color: var(--muted);
  line-height: 1.45;
}

input,
select,
textarea {
  width: 100%;
  min-width: 0;
  border: 1px solid #cfd9d5;
  border-radius: 8px;
  padding: 11px 12px;
  color: var(--ink);
  background: #fbfcfc;
}

textarea {
  resize: vertical;
  line-height: 1.55;
}

input:focus,
select:focus,
textarea:focus,
button:focus-visible,
a:focus-visible {
  outline: 3px solid rgba(47, 93, 159, 0.2);
  outline-offset: 2px;
}

.result-box {
  display: grid;
  gap: 16px;
  min-height: 180px;
  border-top: 1px solid var(--line);
  padding-top: 18px;
}

.score-line {
  border: 1px solid #d7e8e3;
  border-radius: 8px;
  padding: 15px;
  background: #f4fbf8;
}

.score-line strong {
  color: var(--teal);
  font-size: 2.8rem;
  line-height: 1;
}

.score-line span {
  flex: 1;
  font-weight: 800;
}

.score-line small {
  color: var(--muted);
}

.result-list,
.prompt-grid {
  display: grid;
  gap: 12px;
}

.issue,
.prompt-card,
.result-section,
.pdf-action-panel {
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 15px;
  background: #fbfcfc;
}

.issue span {
  display: inline-block;
  margin-bottom: 8px;
  border-radius: 999px;
  padding: 3px 9px;
  color: white;
  font-size: 0.72rem;
  font-weight: 800;
  background: var(--blue);
}

.issue.high span,
.issue.critical span {
  background: var(--red);
}

.issue.medium span {
  background: var(--orange);
}

.issue.low span {
  background: var(--olive);
}

.issue p,
.issue strong,
.prompt-card p,
.result-section li {
  line-height: 1.65;
}

.issue p {
  margin-bottom: 8px;
  color: var(--muted);
}

.issue strong {
  display: block;
}

.code-output {
  overflow: auto;
  max-width: 100%;
  border: 1px solid #cfd9d5;
  border-radius: 8px;
  padding: 16px;
  background: #111a17;
  color: #e9f5ef;
  line-height: 1.55;
  white-space: pre-wrap;
}

.prompt-grid {
  grid-template-columns: repeat(2, minmax(0, 1fr));
}

.prompt-card p {
  margin-bottom: 0;
  color: var(--muted);
}

.result-section ul {
  margin: 0;
  padding-left: 20px;
}

.table-wrap {
  overflow-x: auto;
  border: 1px solid var(--line);
  border-radius: 8px;
}

table {
  width: 100%;
  min-width: 680px;
  border-collapse: collapse;
  background: #fbfcfc;
}

th,
td {
  border-bottom: 1px solid var(--line);
  padding: 11px 12px;
  text-align: left;
  vertical-align: top;
}

th {
  background: #eef4f2;
  font-size: 0.86rem;
}

tr:last-child td {
  border-bottom: 0;
}

.download-link {
  justify-self: start;
  color: var(--teal);
}

.pdf-action-panel {
  display: grid;
  gap: 12px;
}

.pdf-action-panel .primary-button {
  width: auto;
  justify-self: start;
}

.pdf-action-panel .download-link[hidden] {
  display: none;
}

#pdf-status {
  margin-bottom: 0;
}

#pdf-status[data-state="ok"] {
  color: var(--teal);
  font-weight: 800;
}

#pdf-status[data-state="error"] {
  color: var(--red);
  font-weight: 800;
}

@media (max-width: 920px) {
  .workspace-hero,
  .tool-layout {
    grid-template-columns: 1fr;
  }

  .hero-copy {
    min-height: auto;
  }

  h1 {
    max-width: 14ch;
  }

  .tool-sidebar {
    position: static;
    max-height: none;
  }

  .tool-list {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .tool-group {
    align-content: start;
  }
}

@media (max-width: 640px) {
  .topbar,
  main {
    width: min(100% - 22px, 1180px);
  }

  .topbar,
  .panel-heading,
  .score-line {
    align-items: stretch;
    flex-direction: column;
  }

  .top-links {
    width: 100%;
    overflow-x: auto;
  }

  .top-links a {
    flex: 0 0 auto;
  }

  .workspace-hero {
    padding-top: 22px;
  }

  h1 {
    font-size: 2.55rem;
  }

  .tool-list,
  .tool-form,
  .prompt-grid {
    grid-template-columns: 1fr;
  }

  .tool-panel {
    padding: 16px;
  }
}
