:root {
  --bg: #faf9f6;
  --surface: #ffffff;
  --surface-warm: #faf9f6;
  --text: #111111;
  --text-soft: #313130;
  --muted: #7b7b78;
  --line: #dedbd6;
  --line-strong: #d3cec6;
  --accent: #ff5600;
  --accent-dark: #cc4300;
  --blue: #65b5ff;
  --green: #287552;
  --red: #a23e36;
  --radius: 8px;
  --button-radius: 4px;
  --mono: ui-monospace, "SFMono-Regular", Menlo, Consolas, monospace;
  --sans: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

* {
  box-sizing: border-box;
}

html {
  background: var(--bg);
}

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: var(--sans);
  letter-spacing: 0;
}

button,
input,
select {
  font: inherit;
}

button {
  cursor: pointer;
}

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

.app-shell {
  min-height: 100vh;
  padding: 14px;
}

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 20px;
  padding: 18px;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
}

h1 {
  font-size: clamp(31px, 6vw, 52px);
  line-height: 1;
  font-weight: 580;
  letter-spacing: 0;
}

h2 {
  font-size: 22px;
  line-height: 1;
  font-weight: 580;
  letter-spacing: 0;
}

.topbar p {
  color: var(--muted);
  margin-top: 8px;
  font-size: 15px;
  line-height: 1.35;
}

.topbar-actions,
.view-tools,
.small-actions {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
}

.file-button,
.primary-button,
.secondary-button {
  min-height: 42px;
  border-radius: var(--button-radius);
  border: 1px solid var(--text);
  padding: 0 14px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  color: var(--text);
  background: transparent;
  font-size: 14px;
  font-weight: 650;
  transition: background 160ms ease, color 160ms ease, border-color 160ms ease, transform 160ms ease;
}

a.primary-button,
a.secondary-button {
  text-decoration: none;
}

.nav-button {
  white-space: nowrap;
}

.primary-button {
  background: var(--text);
  color: #ffffff;
}

.secondary-button {
  border-color: var(--line-strong);
  background: var(--surface-warm);
}

@media (hover: hover) {
  .file-button:hover,
  .primary-button:hover,
  .secondary-button:hover,
  .compare-add:hover {
    transform: scale(1.04);
  }

  .primary-button:hover {
    background: #ffffff;
    color: var(--text);
  }

  .secondary-button:hover,
  .file-button:hover {
    border-color: var(--accent);
    color: var(--accent-dark);
  }
}

.file-button:active,
.primary-button:active,
.secondary-button:active,
.compare-add:active {
  transform: scale(0.96);
}

svg {
  width: 17px;
  height: 17px;
  fill: none;
  stroke: currentColor;
  stroke-width: 2;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.status-pill {
  min-height: 34px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 0 11px;
  border-radius: var(--button-radius);
  border: 1px solid var(--line);
  color: var(--text-soft);
  background: var(--surface-warm);
  font-family: var(--mono);
  font-size: 12px;
  font-weight: 700;
  white-space: nowrap;
}

.intro-panel {
  display: grid;
  grid-template-columns: minmax(260px, 0.9fr) minmax(0, 1.4fr) auto;
  gap: 14px;
  align-items: start;
  margin-top: 14px;
  padding: 18px;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
}

.intro-copy {
  display: grid;
  gap: 8px;
}

.intro-copy h2 {
  font-size: clamp(26px, 3vw, 38px);
}

.intro-copy p,
.intro-steps span,
.field-help {
  color: var(--text-soft);
  font-size: 14px;
  line-height: 1.45;
}

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

.intro-steps article {
  display: grid;
  gap: 6px;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--surface-warm);
}

.intro-steps strong {
  font-size: 14px;
  line-height: 1.2;
}

.field-help {
  display: block;
}

.workspace {
  display: grid;
  grid-template-columns: 220px 320px 280px minmax(0, 1fr);
  gap: 14px;
  margin-top: 14px;
  align-items: start;
}

.panel,
.results-area {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
}

.panel {
  padding: 16px;
}

.results-area {
  grid-column: 1 / -1;
  min-width: 0;
  overflow: hidden;
}

.panel-heading,
.results-header,
.compare-heading {
  display: flex;
  justify-content: space-between;
  align-items: start;
  gap: 12px;
}

.panel-heading {
  display: block;
  margin-bottom: 16px;
}

.step {
  display: block;
  color: var(--accent);
  font-family: var(--mono);
  font-size: 11px;
  font-weight: 760;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  margin-bottom: 6px;
}

.segmented {
  display: grid;
  grid-template-columns: 1fr 1fr;
  border: 1px solid var(--line);
  border-radius: var(--button-radius);
  overflow: hidden;
  margin-bottom: 14px;
  background: var(--surface-warm);
}

.profile-tab {
  border: 0;
  background: transparent;
  color: var(--muted);
  min-height: 40px;
  font-size: 14px;
  font-weight: 700;
}

.profile-tab.active {
  background: var(--text);
  color: #ffffff;
}

.field {
  display: grid;
  gap: 7px;
  margin-bottom: 12px;
}

.field span,
legend,
.toggle {
  color: var(--muted);
  font-size: 12px;
  font-weight: 760;
}

input[type="number"],
input[type="text"],
select {
  width: 100%;
  min-height: 42px;
  border-radius: var(--button-radius);
  border: 1px solid var(--line-strong);
  background: #ffffff;
  color: var(--text);
  padding: 0 11px;
  outline: none;
}

select[multiple] {
  min-height: 156px;
  padding: 8px;
}

input:focus,
select:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(255, 86, 0, 0.14);
}

.control-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0 10px;
}

.check-group {
  border: 1px solid var(--line);
  border-radius: var(--button-radius);
  padding: 10px;
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
  margin: 0 0 12px;
  background: var(--surface-warm);
}

.check-group label,
.toggle {
  display: inline-flex;
  align-items: center;
  gap: 7px;
}

input[type="checkbox"] {
  accent-color: var(--accent);
  width: 16px;
  height: 16px;
}

.weights {
  display: grid;
  gap: 14px;
}

.weight-row {
  display: grid;
  gap: 8px;
}

.weight-row header {
  display: flex;
  justify-content: space-between;
  color: var(--text);
  font-size: 14px;
  font-weight: 720;
}

.weight-row header span:last-child {
  color: var(--muted);
  font-family: var(--mono);
  font-weight: 650;
}

input[type="range"] {
  width: 100%;
  accent-color: var(--accent);
}

.score-note {
  border-top: 1px solid var(--line);
  border-bottom: 1px solid var(--line);
  padding: 14px 0;
  margin: 16px 0;
  color: var(--muted);
  font-size: 13px;
  line-height: 1.35;
}

.score-note strong {
  color: var(--text);
  font-size: 28px;
  line-height: 1;
  margin-right: 5px;
}

.results-header {
  padding: 16px 18px;
  border-bottom: 1px solid var(--line);
}

.table-wrap {
  overflow: auto;
  max-height: min(62vh, 720px);
}

table {
  width: 100%;
  border-collapse: collapse;
  min-width: 980px;
}

th,
td {
  border-bottom: 1px solid var(--line);
  padding: 11px 10px;
  text-align: left;
  vertical-align: middle;
  font-size: 13px;
}

th {
  position: sticky;
  top: 0;
  z-index: 1;
  background: var(--surface-warm);
  color: var(--muted);
  font-family: var(--mono);
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.06em;
}

tbody tr:hover {
  background: #fff8f4;
}

.rank {
  width: 44px;
  font-family: var(--mono);
  color: var(--muted);
}

.school-name {
  display: grid;
  gap: 4px;
  min-width: 230px;
}

.school-name strong {
  font-size: 15px;
  line-height: 1.15;
}

.school-name span,
.minor {
  color: var(--muted);
  font-size: 12px;
  line-height: 1.35;
}

.fit {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 46px;
  height: 30px;
  border-radius: var(--button-radius);
  background: #111111;
  color: #ffffff;
  font-family: var(--mono);
  font-weight: 800;
}

.major-hit {
  color: var(--green);
  font-weight: 760;
}

.major-offered {
  color: var(--accent-dark);
  font-weight: 760;
}

.major-neutral {
  color: var(--text-soft);
}

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

.compare-add {
  border: 1px solid var(--text);
  background: #ffffff;
  border-radius: var(--button-radius);
  width: 34px;
  height: 34px;
  display: inline-grid;
  place-items: center;
  color: var(--text);
  transition: background 160ms ease, color 160ms ease, transform 160ms ease;
}

.compare-add.selected {
  background: var(--accent);
  color: #ffffff;
  border-color: var(--accent);
}

.compare-panel {
  border-top: 1px solid var(--line);
  padding: 16px 18px 18px;
}

.compare-list {
  display: block;
  margin-top: 14px;
}

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

.compare-table {
  min-width: 720px;
  width: 100%;
  border-collapse: collapse;
}

.compare-table th,
.compare-table td {
  border-bottom: 1px solid var(--line);
  padding: 12px;
  vertical-align: top;
  font-size: 13px;
  line-height: 1.35;
}

.compare-table thead th {
  position: static;
  color: var(--text);
  background: #ffffff;
  font-family: var(--sans);
  font-size: 14px;
  text-transform: none;
  letter-spacing: 0;
}

.compare-table tbody th {
  width: 160px;
  color: var(--muted);
  font-family: var(--mono);
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  background: #ffffff;
}

.compare-table tr:last-child th,
.compare-table tr:last-child td {
  border-bottom: 0;
}

.empty-state {
  padding: 30px;
  color: var(--muted);
  text-align: center;
}

.about-shell {
  display: grid;
  grid-template-columns: 230px minmax(0, 860px);
  gap: 18px;
  margin-top: 14px;
  align-items: start;
}

.about-menu {
  position: sticky;
  top: 14px;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 14px;
  display: grid;
  gap: 6px;
}

.about-menu a {
  min-height: 38px;
  display: flex;
  align-items: center;
  padding: 0 10px;
  border-radius: var(--button-radius);
  color: var(--text);
  text-decoration: none;
  font-size: 14px;
  font-weight: 700;
}

.about-menu a:hover {
  background: var(--surface-warm);
  color: var(--accent-dark);
}

.about-content {
  display: grid;
  gap: 14px;
}

.about-section {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: clamp(18px, 3vw, 32px);
  scroll-margin-top: 18px;
}

.about-intro {
  border-color: var(--text);
}

.about-section h2 {
  max-width: 720px;
  font-size: clamp(28px, 4vw, 44px);
  line-height: 1;
  margin-bottom: 16px;
}

.about-copy {
  display: grid;
  gap: 13px;
  max-width: 720px;
}

.about-copy p {
  color: var(--text-soft);
  font-size: 17px;
  line-height: 1.55;
}

.about-copy a {
  color: var(--accent-dark);
  font-weight: 700;
}

.score-factors {
  display: grid;
  grid-template-columns: repeat(5, minmax(0, 1fr));
  gap: 8px;
  margin-top: 18px;
}

.score-factors div {
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--surface-warm);
  padding: 12px;
  display: grid;
  gap: 8px;
}

.score-factors strong {
  font-size: 14px;
  line-height: 1.1;
}

.score-factors span {
  color: var(--muted);
  font-size: 13px;
  line-height: 1.35;
}

.definition-stack {
  display: grid;
  gap: 12px;
}

.definition-group {
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--surface-warm);
  padding: 16px;
}

.definition-group h3 {
  margin-bottom: 12px;
  font-size: 20px;
  line-height: 1.1;
}

.definition-group dl {
  margin: 0;
  display: grid;
}

.definition-group dl div {
  display: grid;
  grid-template-columns: minmax(130px, 0.34fr) minmax(0, 1fr);
  gap: 14px;
  padding: 12px 0;
  border-top: 1px solid var(--line);
}

.definition-group dt {
  color: var(--text);
  font-weight: 760;
  line-height: 1.25;
}

.definition-group dd {
  margin: 0;
  color: var(--text-soft);
  line-height: 1.45;
}

.author-section {
  border-color: var(--accent);
}

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

  .profile-panel,
  .weights-panel {
    grid-column: span 1;
  }

  .filters-panel {
    grid-column: 1 / -1;
  }

  .intro-panel {
    grid-template-columns: 1fr;
  }

  .about-shell {
    grid-template-columns: 1fr;
  }

  .about-menu {
    position: static;
    display: flex;
    overflow-x: auto;
    gap: 8px;
  }

  .about-menu .step {
    display: none;
  }

  .about-menu a {
    flex: 0 0 auto;
    border: 1px solid var(--line);
    background: var(--surface-warm);
  }

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

@media (max-width: 640px) {
  .app-shell {
    padding: 8px;
  }

  .topbar {
    align-items: stretch;
    flex-direction: column;
    padding: 14px;
  }

  .topbar-actions,
  .view-tools,
  .small-actions {
    width: 100%;
  }

  .file-button,
  .primary-button,
  .secondary-button,
  .status-pill {
    flex: 1 1 auto;
  }

  .workspace {
    grid-template-columns: 1fr;
    gap: 10px;
    margin-top: 10px;
  }

  .profile-panel,
  .filters-panel,
  .weights-panel,
  .results-area {
    grid-column: 1;
  }

  .panel,
  .results-header,
  .compare-panel {
    padding: 14px;
  }

  .control-grid,
  .check-group,
  .compare-list,
  .metric-grid,
  .intro-steps,
  .score-factors {
    grid-template-columns: 1fr;
  }

  .about-section {
    padding: 18px;
  }

  .about-section h2 {
    font-size: 30px;
  }

  .about-copy p {
    font-size: 16px;
  }

  .definition-group {
    padding: 14px;
  }

  .definition-group dl div {
    grid-template-columns: 1fr;
    gap: 5px;
    padding: 11px 0;
  }

  .results-header,
  .compare-heading {
    flex-direction: column;
  }

  .view-tools {
    align-items: stretch;
  }

  .toggle {
    min-height: 42px;
    padding: 0 10px;
    border: 1px solid var(--line);
    border-radius: var(--button-radius);
    background: var(--surface-warm);
  }

  .table-wrap {
    max-height: none;
    overflow: visible;
    padding: 10px;
  }

  .table-wrap table,
  .table-wrap tbody,
  .table-wrap tr,
  .table-wrap td {
    display: block;
    width: 100%;
  }

  .table-wrap table {
    min-width: 0;
  }

  .table-wrap thead {
    display: none;
  }

  .table-wrap tbody {
    display: grid;
    gap: 10px;
  }

  .table-wrap tbody tr {
    border: 1px solid var(--line);
    border-radius: var(--radius);
    padding: 12px;
    background: var(--surface-warm);
  }

  .table-wrap tbody tr:hover {
    background: var(--surface-warm);
  }

  .table-wrap td {
    border: 0;
    padding: 7px 0;
    display: flex;
    justify-content: space-between;
    gap: 16px;
    align-items: center;
    font-size: 14px;
  }

  .table-wrap td::before {
    content: attr(data-label);
    color: var(--muted);
    font-family: var(--mono);
    font-size: 11px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.05em;
  }

  .school-cell {
    display: block;
    padding-top: 2px;
  }

  .school-cell::before {
    content: none;
  }

  .rank {
    width: auto;
  }

  .fit-cell,
  .compare-cell {
    justify-content: space-between;
  }

  .compare-add {
    width: 42px;
    height: 42px;
  }

  .school-name {
    min-width: 0;
  }

  .compare-table {
    min-width: 680px;
  }
}

@media (max-width: 425px) {
  h1 {
    font-size: 34px;
  }

  .topbar p {
    font-size: 14px;
  }

  .file-button,
  .primary-button,
  .secondary-button {
    width: 100%;
  }
}
