:root {
  /* Customization point: update brand colors here. */
  --color-primary: #1d4ed8;
  --color-primary-strong: #1e40af;
  --color-accent: #0f766e;
  --color-bg: #f5f7fb;
  --color-surface: #ffffff;
  --color-surface-muted: #eef4ff;
  --color-text: #172033;
  --color-muted: #5f6f86;
  --color-border: #d8e2f0;
  --color-ad: #e7edf7;
  --color-danger: #b42318;
  --shadow-panel: 0 20px 45px rgba(23, 32, 51, 0.1);
  --radius: 8px;
  --max-width: 1180px;
  color-scheme: light;
}

:root[data-theme="dark"] {
  --color-bg: #101723;
  --color-surface: #172232;
  --color-surface-muted: #1f3047;
  --color-text: #edf4ff;
  --color-muted: #aebcd0;
  --color-border: #31445f;
  --color-ad: #202d40;
  --color-danger: #f97066;
  --shadow-panel: 0 20px 45px rgba(0, 0, 0, 0.25);
  color-scheme: dark;
}

* {
  box-sizing: border-box;
}

html {
  scroll-behavior: smooth;
}

body {
  margin: 0;
  background: var(--color-bg);
  color: var(--color-text);
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  line-height: 1.5;
}

a {
  color: inherit;
}

button,
input,
select {
  font: inherit;
}

button {
  cursor: pointer;
}

.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

.site-header {
  position: sticky;
  top: 0;
  z-index: 5;
  background: color-mix(in srgb, var(--color-surface) 92%, transparent);
  border-bottom: 1px solid var(--color-border);
  backdrop-filter: blur(12px);
}

.nav {
  display: flex;
  align-items: center;
  justify-content: space-between;
  max-width: var(--max-width);
  min-height: 64px;
  margin: 0 auto;
  padding: 0 16px;
  gap: 16px;
}

.brand,
.nav-link,
.site-footer a {
  text-decoration: none;
}

.brand {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  font-weight: 800;
}

.brand-mark {
  display: inline-grid;
  width: 36px;
  height: 36px;
  place-items: center;
  border-radius: var(--radius);
  background: var(--color-primary);
  color: #fff;
  font-size: 0.82rem;
}

.nav-actions {
  display: inline-flex;
  align-items: center;
  gap: 10px;
}

.nav-link {
  display: none;
  color: var(--color-muted);
  font-weight: 700;
}

.theme-toggle,
.secondary-button,
.text-button,
.remove-row,
.add-row {
  border: 1px solid var(--color-border);
  border-radius: var(--radius);
  background: var(--color-surface);
  color: var(--color-text);
}

.theme-toggle {
  width: 42px;
  height: 42px;
  font-size: 1.15rem;
}

.hero {
  background:
    linear-gradient(135deg, rgba(29, 78, 216, 0.96), rgba(15, 118, 110, 0.8)),
    url("data:image/svg+xml,%3Csvg width='240' height='160' viewBox='0 0 240 160' xmlns='http://www.w3.org/2000/svg'%3E%3Cg fill='none' stroke='rgba(255,255,255,.22)' stroke-width='2'%3E%3Cpath d='M18 34h72M18 62h120M18 90h92M150 32l20 20 42-42M158 84h44M158 110h58M158 136h30'/%3E%3Crect x='8' y='16' width='124' height='96' rx='8'/%3E%3Crect x='146' y='70' width='78' height='78' rx='8'/%3E%3C/g%3E%3C/svg%3E");
  background-position: center;
  color: #fff;
}

.hero-content {
  max-width: var(--max-width);
  margin: 0 auto;
  padding: 38px 16px 44px;
}

.eyebrow {
  margin: 0 0 8px;
  font-size: 0.82rem;
  font-weight: 800;
  letter-spacing: 0;
  text-transform: uppercase;
}

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

h1 {
  max-width: 820px;
  font-size: clamp(2rem, 8vw, 4rem);
}

.hero p:last-child {
  max-width: 720px;
  margin: 16px 0 0;
  font-size: 1.05rem;
}

.ad-slot {
  display: grid;
  place-items: center;
  min-height: 92px;
  max-width: var(--max-width);
  margin: 16px auto;
  padding: 14px;
  border: 1px dashed var(--color-border);
  border-radius: var(--radius);
  background: var(--color-ad);
  color: var(--color-muted);
  font-size: 0.88rem;
  text-align: center;
}

.layout {
  display: grid;
  grid-template-columns: 1fr;
  gap: 18px;
  max-width: var(--max-width);
  margin: 18px auto;
  padding: 0 16px;
}

.calculator-panel,
.history-panel,
.content-page,
.info-panel {
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--radius);
  box-shadow: var(--shadow-panel);
}

.calculator-panel,
.history-panel,
.info-panel {
  padding: 18px;
}

.section-heading {
  display: flex;
  align-items: start;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 18px;
}

.section-heading p {
  margin: 6px 0 0;
  color: var(--color-muted);
}

.tab-list {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 8px;
  margin-bottom: 18px;
}

.tab-button {
  min-height: 44px;
  border: 1px solid var(--color-border);
  border-radius: var(--radius);
  background: var(--color-surface-muted);
  color: var(--color-text);
  font-weight: 800;
}

.tab-button[aria-selected="true"] {
  background: var(--color-primary);
  border-color: var(--color-primary);
  color: #fff;
}

.mode-panel[hidden],
.mode-extra[hidden],
.target-section[hidden],
.course-row.template {
  display: none;
}

[data-mode="target"] .rows-header,
[data-mode="target"] .rows,
[data-mode="target"] .add-row {
  display: none;
}

.form-grid,
.target-grid,
.converter-grid {
  display: grid;
  grid-template-columns: 1fr;
  gap: 14px;
}

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

label {
  color: var(--color-muted);
  font-size: 0.92rem;
  font-weight: 750;
}

input,
select {
  width: 100%;
  min-height: 48px;
  border: 1px solid var(--color-border);
  border-radius: var(--radius);
  background: var(--color-surface);
  color: var(--color-text);
  padding: 0 12px;
}

input:focus,
select:focus,
button:focus-visible,
a:focus-visible {
  outline: 3px solid color-mix(in srgb, var(--color-primary) 42%, transparent);
  outline-offset: 2px;
}

.rows-header,
.course-row {
  display: grid;
  grid-template-columns: 1.35fr 0.95fr 0.85fr 44px;
  gap: 8px;
  align-items: end;
}

.rows-header {
  display: none;
  color: var(--color-muted);
  font-size: 0.84rem;
  font-weight: 800;
  margin-bottom: 8px;
  padding: 0 4px;
}

.rows {
  display: grid;
  gap: 10px;
}

.course-row {
  padding: 12px;
  border: 1px solid var(--color-border);
  border-radius: var(--radius);
  background: var(--color-surface-muted);
}

.course-row .field {
  gap: 6px;
}

.course-row label {
  font-size: 0.78rem;
}

.credit-field,
.semester-field {
  display: none;
}

[data-mode="weighted"] .credit-field,
[data-mode="cumulative"] .credit-field,
[data-mode="cumulative"] .semester-field {
  display: grid;
}

[data-mode="cumulative"] .rows-header,
[data-mode="weighted"] .rows-header {
  display: grid;
}

.remove-row {
  width: 40px;
  height: 40px;
  color: var(--color-danger);
  font-weight: 900;
}

.add-row,
.secondary-button {
  min-height: 42px;
  padding: 0 14px;
  font-weight: 800;
}

.add-row {
  margin-top: 12px;
  background: var(--color-primary);
  border-color: var(--color-primary);
  color: #fff;
}

.result-actions {
  display: grid;
  gap: 14px;
  margin-top: 18px;
  padding: 14px;
  border: 1px solid var(--color-border);
  border-radius: var(--radius);
  background: var(--color-surface-muted);
}

.result {
  min-height: 54px;
  font-size: clamp(1.2rem, 7vw, 2rem);
  font-weight: 850;
}

.result-detail {
  margin: 4px 0 0;
  color: var(--color-muted);
}

.button-group {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
}

.secondary-button:hover,
.text-button:hover,
.theme-toggle:hover,
.remove-row:hover {
  border-color: var(--color-primary);
}

.status {
  min-height: 24px;
  margin: 10px 0 0;
  color: var(--color-muted);
}

.side-column {
  display: grid;
  gap: 18px;
  align-content: start;
}

.history-panel ol {
  display: grid;
  gap: 10px;
  margin: 0;
  padding-left: 22px;
}

.history-panel li {
  color: var(--color-muted);
}

.text-button {
  min-height: 36px;
  padding: 0 10px;
  color: var(--color-muted);
  font-weight: 800;
}

.scale-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.94rem;
}

.scale-table th,
.scale-table td {
  padding: 10px;
  border-bottom: 1px solid var(--color-border);
  text-align: left;
}

.scale-table th {
  color: var(--color-muted);
}

.content-section,
.faq-section {
  max-width: var(--max-width);
  margin: 20px auto;
  padding: 0 16px;
}

.content-page {
  max-width: 900px;
  margin: 22px auto;
  padding: 24px 18px;
}

.content-page p,
.content-page li,
.content-section p,
.faq-section p {
  color: var(--color-muted);
}

.content-section h2,
.faq-section h2,
.content-page h1,
.content-page h2,
.content-page h3 {
  margin-top: 22px;
}

.content-page h1:first-child,
.content-page h2:first-child,
.content-section h2:first-child,
.faq-section h2:first-child {
  margin-top: 0;
}

.content-grid {
  display: grid;
  grid-template-columns: 1fr;
  gap: 16px;
}

.info-card {
  padding: 16px;
  border: 1px solid var(--color-border);
  border-radius: var(--radius);
  background: var(--color-surface);
}

details {
  border: 1px solid var(--color-border);
  border-radius: var(--radius);
  background: var(--color-surface);
  padding: 14px 16px;
  margin: 10px 0;
}

summary {
  cursor: pointer;
  font-weight: 800;
}

.site-footer {
  max-width: var(--max-width);
  margin: 30px auto 0;
  padding: 24px 16px 34px;
  color: var(--color-muted);
}

.footer-links {
  display: flex;
  flex-wrap: wrap;
  gap: 14px;
  margin-top: 8px;
}

@media (min-width: 620px) {
  .nav-link {
    display: inline-flex;
  }

  .tab-list {
    grid-template-columns: repeat(4, 1fr);
  }

  .form-grid,
  .target-grid,
  .converter-grid {
    grid-template-columns: repeat(2, 1fr);
  }

  .course-row label {
    display: none;
  }
}

@media (max-width: 619px) {
  .rows-header {
    display: none !important;
  }

  .course-row {
    grid-template-columns: 1fr;
  }

  .remove-row {
    justify-self: end;
  }
}

@media (min-width: 920px) {
  .layout {
    grid-template-columns: minmax(0, 1fr) 320px;
    align-items: start;
  }

  .calculator-panel {
    padding: 22px;
  }

  .result-actions {
    grid-template-columns: minmax(0, 1fr) auto;
    align-items: center;
  }

  .content-grid {
    grid-template-columns: repeat(3, 1fr);
  }
}
