:root {
  color-scheme: light;
  --bg: #f7f8fb;
  --surface: #ffffff;
  --surface-soft: #eef5f3;
  --ink: #172026;
  --muted: #66737f;
  --line: #dbe2e8;
  --accent: #087f5b;
  --accent-dark: #065f46;
  --accent-soft: #dff5eb;
  --red: #d9480f;
}

* {
  box-sizing: border-box;
}

html {
  scroll-behavior: smooth;
  overflow-x: hidden;
}

body {
  margin: 0;
  background:
    linear-gradient(180deg, rgba(8, 127, 91, 0.08), transparent 330px),
    var(--bg);
  color: var(--ink);
  font-family:
    Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  line-height: 1.5;
  overflow-x: hidden;
}

button,
input,
select {
  font: inherit;
}

button {
  cursor: pointer;
}

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

.site-header {
  position: sticky;
  top: 0;
  z-index: 10;
  display: flex;
  align-items: center;
  justify-content: space-between;
  width: min(1180px, calc(100% - 32px));
  margin: 14px auto 0;
  padding: 10px;
  border: 1px solid rgba(219, 226, 232, 0.82);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.86);
  backdrop-filter: blur(18px);
  box-shadow: 0 10px 35px rgba(23, 32, 38, 0.08);
}

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

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

.brand small {
  color: var(--muted);
  font-size: 0.78rem;
}

.brand-mark {
  display: grid;
  width: 42px;
  height: 42px;
  place-items: center;
  border-radius: 8px;
  background: var(--accent-soft);
  color: var(--accent-dark);
}

.brand-mark svg {
  width: 30px;
  height: 30px;
  fill: none;
  stroke: currentColor;
  stroke-linecap: round;
  stroke-linejoin: round;
  stroke-width: 2.4;
}

.top-nav {
  display: flex;
  align-items: center;
  gap: 6px;
}

.top-nav a {
  padding: 9px 13px;
  border-radius: 999px;
  color: var(--muted);
  font-size: 0.94rem;
}

.top-nav a:hover {
  background: var(--surface-soft);
  color: var(--ink);
}

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

.eyebrow {
  margin: 0 0 8px;
  color: var(--accent-dark);
  font-size: 0.78rem;
  font-weight: 800;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

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

h2 {
  margin-bottom: 0;
  font-size: clamp(1.55rem, 3vw, 2.35rem);
  line-height: 1.15;
}

h3 {
  margin-bottom: 6px;
  font-size: 1.22rem;
}

.calculator-shell,
.info-panel {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
  box-shadow: 0 16px 50px rgba(23, 32, 38, 0.08);
}

.calculator-shell {
  padding: 26px;
}

.section-heading {
  margin-bottom: 18px;
}

.calculator-tools {
  display: flex;
  align-items: end;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 14px;
}

.calculator-tools .eyebrow {
  margin-bottom: 0;
}

.profile-switch {
  width: min(240px, 100%);
}

.profile-switch span {
  margin-bottom: 5px;
  font-size: 0.76rem;
}

.profile-switch select {
  min-height: 38px;
  padding: 0 10px;
  color: var(--muted);
  font-size: 0.88rem;
}

.control-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 14px;
  padding: 16px;
  border-radius: 8px;
  background: #f3f7f8;
}

.year-tabs {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 8px;
  margin-top: 14px;
  padding: 8px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #f8fafb;
}

.year-tab {
  display: grid;
  gap: 2px;
  min-height: 54px;
  padding: 8px 10px;
  border: 1px solid transparent;
  border-radius: 8px;
  background: transparent;
  color: var(--muted);
  font-weight: 800;
}

.year-tab small {
  color: inherit;
  font-size: 0.72rem;
  font-weight: 700;
}

.year-tab:hover,
.year-tab.active {
  border-color: var(--accent);
  background: var(--accent-soft);
  color: var(--accent-dark);
}

label span {
  display: block;
  margin-bottom: 7px;
  color: var(--muted);
  font-size: 0.82rem;
  font-weight: 700;
}

input,
select {
  width: 100%;
  min-height: 46px;
  padding: 0 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
  color: var(--ink);
  outline: none;
}

input:focus,
select:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 4px rgba(8, 127, 91, 0.14);
}

.workspace {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 300px;
  gap: 20px;
  margin-top: 20px;
}

.summary-panel,
.course-panel {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
}

.summary-panel {
  align-self: start;
  padding: 20px;
}

.muted {
  color: var(--muted);
  font-size: 0.92rem;
}

.score-card {
  display: grid;
  place-items: center;
  min-height: 150px;
  margin: 18px 0;
  border-radius: 8px;
  background: var(--accent-dark);
  color: white;
}

.score-card span {
  font-size: 4rem;
  font-weight: 900;
  line-height: 1;
}

.summary-stats {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 8px;
}

.summary-stats div {
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fbfcfd;
}

.summary-stats strong,
.summary-stats span {
  display: block;
}

.summary-stats span {
  color: var(--muted);
  font-size: 0.76rem;
}

.action-stack {
  display: grid;
  margin-top: 16px;
  gap: 10px;
}

.primary-btn,
.secondary-btn,
.ghost-btn {
  min-height: 44px;
  border: 0;
  border-radius: 8px;
  font-weight: 800;
}

.primary-btn {
  background: var(--accent);
  color: white;
}

.primary-btn:hover {
  background: var(--accent-dark);
}

.secondary-btn {
  border: 1px solid var(--line);
  background: var(--surface);
  color: var(--ink);
}

.secondary-btn:hover,
.ghost-btn:hover {
  background: var(--surface-soft);
}

.ghost-btn {
  background: transparent;
  color: var(--red);
}

.compact {
  min-height: 38px;
  padding: 0 12px;
}

.course-panel {
  overflow: hidden;
}

.course-panel-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 18px;
  border-bottom: 1px solid var(--line);
}

.table-wrap {
  overflow-x: clip;
}

table {
  width: 100%;
  border-collapse: collapse;
  table-layout: fixed;
}

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

th {
  background: #f8fafb;
  color: var(--muted);
  font-size: 0.78rem;
  letter-spacing: 0.04em;
  text-transform: uppercase;
}

.subject-col,
.subject-cell {
  width: auto;
}

.credit-col,
.credit-cell {
  width: 66px;
}

.grade-col,
.grade-cell {
  width: 292px;
}

.points-col {
  width: 68px;
}

.remove-col {
  width: 38px;
}

td input,
td select {
  min-height: 38px;
}

.code-input {
  max-width: 110px;
}

.credit-input {
  max-width: 76px;
}

.custom-course-fields,
.course-title-stack {
  display: grid;
  gap: 3px;
  min-width: 0;
}

.course-code {
  color: var(--muted);
  font-size: 0.72rem;
  font-weight: 800;
  letter-spacing: 0.04em;
  line-height: 1.1;
}

.course-title {
  display: block;
  font-size: 0.95rem;
  line-height: 1.25;
  overflow-wrap: anywhere;
}

.grade-tabs {
  display: grid;
  grid-template-columns: repeat(5, minmax(34px, 1fr));
  gap: 5px;
}

.grade-tab {
  min-height: 30px;
  padding: 0 5px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: white;
  color: var(--muted);
  font-size: 0.86rem;
  font-weight: 900;
}

.grade-tab:hover,
.grade-tab.active {
  border-color: var(--accent);
  background: var(--accent);
  color: white;
}

.point-badge {
  display: inline-flex;
  min-width: 48px;
  justify-content: center;
  padding: 5px 8px;
  border-radius: 999px;
  background: var(--accent-soft);
  color: var(--accent-dark);
  font-size: 0.86rem;
  font-weight: 800;
}

.remove-row {
  width: 30px;
  height: 30px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: white;
  color: var(--red);
  font-weight: 900;
}

.info-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 24px;
  margin: 24px 0;
}

.info-panel {
  padding: 26px;
}

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

.scale-item {
  display: grid;
  grid-template-columns: 1fr auto auto;
  gap: 10px;
  align-items: center;
  padding: 10px 0;
  border-bottom: 1px solid var(--line);
}

.scale-item:last-child {
  border-bottom: 0;
}

.grade-chip {
  min-width: 44px;
  padding: 4px 9px;
  border-radius: 999px;
  background: var(--accent-soft);
  color: var(--accent-dark);
  text-align: center;
  font-weight: 900;
}

.steps {
  margin: 0;
  padding-left: 20px;
  color: var(--muted);
}

.steps li + li {
  margin-top: 12px;
}

footer {
  padding: 28px 16px 40px;
  color: var(--muted);
  text-align: center;
}

@media (max-width: 920px) {
  .top-nav {
    display: none;
  }

  .workspace,
  .info-grid {
    grid-template-columns: 1fr;
  }

  .summary-panel {
    position: static;
  }
}

@media (max-width: 620px) {
  main,
  .site-header {
    width: min(100% - 18px, 1180px);
  }

  .brand small {
    display: none;
  }

  .calculator-tools {
    align-items: stretch;
    flex-direction: column;
    gap: 10px;
  }

  .profile-switch {
    width: 100%;
  }

  .control-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 10px;
    padding: 12px;
  }

  .department-control {
    grid-column: 1 / -1;
  }

  .year-tabs {
    grid-template-columns: repeat(4, minmax(0, 1fr));
    gap: 5px;
    padding: 5px;
  }

  .year-tab {
    min-height: 48px;
    padding: 7px 4px;
    font-size: 0.86rem;
  }

  .calculator-shell,
  .info-panel {
    padding: 16px;
    border-radius: 8px;
  }

  .course-panel-header {
    align-items: flex-start;
    padding: 14px;
  }

  table,
  thead,
  tbody,
  tr,
  th,
  td {
    display: block;
  }

  thead {
    position: absolute;
    width: 1px;
    height: 1px;
    overflow: hidden;
    clip: rect(0 0 0 0);
    white-space: nowrap;
  }

  tbody {
    display: grid;
  }

  tr {
    display: grid;
    grid-template-columns: minmax(0, 1fr) auto auto;
    gap: 8px 10px;
    padding: 11px 12px;
    border-bottom: 1px solid var(--line);
  }

  td {
    width: auto;
    padding: 0;
    border-bottom: 0;
  }

  .subject-cell,
  .grade-cell {
    grid-column: 1 / -1;
    width: 100%;
    min-width: 0;
  }

  .credit-cell {
    width: auto;
    color: var(--muted);
    font-size: 0.82rem;
    font-weight: 800;
  }

  .credit-cell::before {
    content: "Credit ";
    font-weight: 700;
  }

  .points-col {
    width: auto;
    justify-self: start;
  }

  .remove-col {
    width: auto;
    justify-self: end;
  }

  .grade-tabs {
    grid-template-columns: repeat(5, minmax(0, 1fr));
    gap: 5px;
  }

  .grade-tab {
    min-width: 0;
  }
}
