:root {
  --ink: #17202a;
  --muted: #5c6875;
  --panel: #ffffff;
  --canvas: #f4f7f8;
  --line: #d7e0e5;
  --teal: #0d766e;
  --teal-dark: #084f4a;
  --coral: #c44d3d;
  --gold: #b57719;
  --blue: #3066be;
  --shadow: 0 18px 42px rgba(24, 36, 48, 0.13);
}

* {
  box-sizing: border-box;
}

html {
  scroll-behavior: smooth;
}

body {
  margin: 0;
  color: var(--ink);
  background:
    radial-gradient(circle at top left, rgba(13, 118, 110, 0.11), transparent 34rem),
    linear-gradient(180deg, #fbfdfd 0%, var(--canvas) 58%, #eef3f5 100%);
  font-family: Arial, Helvetica, sans-serif;
  line-height: 1.5;
}

button,
input,
select {
  font: inherit;
}

a {
  color: inherit;
}

.site-header {
  width: min(1180px, calc(100% - 32px));
  min-height: 76px;
  display: flex;
  align-items: center;
  gap: 24px;
  margin: 0 auto;
}

.brand {
  color: var(--ink);
  text-decoration: none;
  font-weight: 800;
}

.brand {
  display: inline-flex;
  align-items: center;
  margin-right: auto;
  min-width: 0;
}

.brand-title {
  display: inline-block;
  border-radius: 8px;
  color: #fff;
  background:
    linear-gradient(90deg, #0d766e 0 20%, #3066be 20% 40%, #c44d3d 40% 60%, #6a4c93 60% 80%, #2d9c4a 80% 100%);
  padding: 11px 14px;
  letter-spacing: 0;
  line-height: 1.05;
  box-shadow: 0 8px 16px rgba(24, 36, 48, 0.14);
}

.top-nav {
  display: flex;
  gap: 20px;
  color: var(--muted);
}

.top-nav a {
  color: var(--ink);
  font-weight: 800;
  text-decoration-line: underline;
  text-decoration-thickness: 3px;
  text-underline-offset: 7px;
  text-decoration-color: var(--coral);
}

.top-nav a:hover,
.top-nav a:focus-visible {
  color: var(--teal-dark);
  text-decoration-color: var(--teal-dark);
}

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

.converter-hero {
  min-height: calc(100vh - 100px);
  display: grid;
  grid-template-columns: minmax(0, 0.82fr) minmax(340px, 1.18fr);
  grid-template-areas:
    "visual panel"
    "copy panel";
  gap: clamp(24px, 5vw, 64px);
  align-items: center;
  padding: 24px 0 44px;
}

.fibonacci-header {
  grid-area: visual;
  width: 100%;
  max-height: 310px;
  display: block;
  border-radius: 8px;
  box-shadow: var(--shadow);
  object-fit: cover;
}

.hero-copy {
  grid-area: copy;
  position: relative;
  padding: 24px 0;
}

.hero-copy::before {
  display: none;
}

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

h1,
h2 {
  margin: 0;
  line-height: 1.04;
  letter-spacing: 0;
}

h1 {
  max-width: 560px;
  font-size: clamp(2.45rem, 5vw, 5.2rem);
}

.hero-copy p:not(.eyebrow) {
  max-width: 540px;
  color: var(--muted);
  font-size: 1.08rem;
}

.hero-copy p strong {
  color: var(--ink);
}

.converter-panel,
.tools-row,
.reference-card,
.tool-panel,
.spotlight-card,
.cheat-card,
.question-card,
.favorites-panel,
.favorite-item,
.history-list li {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.93);
  box-shadow: var(--shadow);
}

.converter-panel {
  grid-area: panel;
  padding: clamp(18px, 3vw, 30px);
}

.category-bar {
  display: grid;
  grid-template-columns: repeat(5, minmax(0, 1fr));
  gap: 8px;
  margin-bottom: 22px;
}

.category-tab {
  min-height: 44px;
  border: 1px solid transparent;
  border-radius: 8px;
  color: #fff;
  background: var(--tab-bg, var(--teal));
  cursor: pointer;
  font-size: 0.9rem;
  font-weight: 800;
  box-shadow: 0 8px 16px rgba(24, 36, 48, 0.12);
}

.category-tab[aria-selected="true"] {
  color: #fff;
  border-color: #fff;
  outline: 3px solid rgba(23, 32, 42, 0.18);
  transform: translateY(-1px);
}

.category-tab:nth-child(1) {
  --tab-bg: #0d766e;
}

.category-tab:nth-child(2) {
  --tab-bg: #c44d3d;
}

.category-tab:nth-child(3) {
  --tab-bg: #3066be;
}

.category-tab:nth-child(4) {
  --tab-bg: #b57719;
}

.category-tab:nth-child(5) {
  --tab-bg: #6a4c93;
}

.category-tab:nth-child(6) {
  --tab-bg: #1b998b;
}

.category-tab:nth-child(7) {
  --tab-bg: #ef476f;
}

.category-tab:nth-child(8) {
  --tab-bg: #2f4858;
}

.category-tab:nth-child(9) {
  --tab-bg: #7a5c00;
}

.category-tab:nth-child(10) {
  --tab-bg: #0077b6;
}

.category-tab:nth-child(11) {
  --tab-bg: #d00000;
}

.category-tab:nth-child(12) {
  --tab-bg: #2d9c4a;
}

.unit-grid {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 54px minmax(0, 1fr);
  gap: 14px;
  align-items: end;
}

.unit-field {
  display: grid;
  gap: 10px;
}

.unit-field span,
.precision-control span,
.toggle-control span {
  color: var(--muted);
  font-size: 0.78rem;
  font-weight: 900;
  text-transform: uppercase;
}

.unit-field input,
.unit-field select {
  width: 100%;
  min-height: 54px;
  border: 1px solid var(--line);
  border-radius: 8px;
  color: var(--ink);
  background: #fff;
  padding: 0 14px;
}

.unit-field input {
  font-size: clamp(1.5rem, 3vw, 2.45rem);
  font-weight: 800;
}

.unit-field select {
  font-weight: 800;
}

.to-field span,
.to-field input,
.to-field select {
  color: #d00000;
}

.swap-button,
#copyResult {
  width: 54px;
  height: 54px;
  border: 0;
  border-radius: 8px;
  color: #fff;
  background: var(--blue);
  cursor: pointer;
  font-size: 1.45rem;
  font-weight: 900;
}

.result-strip {
  min-height: 58px;
  display: flex;
  align-items: center;
  gap: 12px;
  justify-content: space-between;
  margin-top: 20px;
  padding: 12px 12px 12px 16px;
  border-radius: 8px;
  color: #fff;
  background: var(--teal-dark);
  font-weight: 800;
}

#copyResult {
  flex: 0 0 auto;
  width: 44px;
  height: 44px;
  background: rgba(255, 255, 255, 0.18);
}

.tools-row {
  display: grid;
  grid-template-columns: minmax(240px, 1fr) minmax(220px, 0.55fr);
  gap: 16px;
  align-items: center;
  padding: 18px;
  margin-bottom: 54px;
}

.precision-control {
  display: grid;
  grid-template-columns: auto minmax(120px, 1fr) 84px;
  gap: 14px;
  align-items: center;
}

.precision-control input {
  accent-color: var(--teal);
}

.precision-control strong {
  color: var(--teal-dark);
  text-align: right;
}

.toggle-control {
  min-height: 44px;
  display: inline-flex;
  align-items: center;
  gap: 10px;
}

.toggle-control input {
  width: 20px;
  height: 20px;
  accent-color: var(--coral);
}

.feature-section,
.reference-section,
.history-section {
  padding-top: 34px;
}

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

.section-heading h2 {
  font-size: clamp(1.8rem, 3vw, 3rem);
}

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

.reference-card {
  min-height: 124px;
  display: grid;
  align-content: center;
  gap: 8px;
  padding: 18px;
}

.reference-card span {
  color: var(--muted);
  font-size: 0.78rem;
  font-weight: 900;
  text-transform: uppercase;
}

.reference-card strong {
  font-size: 1.18rem;
  overflow-wrap: anywhere;
}

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

.travel-grid {
  grid-template-columns: minmax(0, 1.35fr) minmax(280px, 0.65fr);
}

.tool-panel {
  display: grid;
  align-content: start;
  gap: 16px;
  padding: 18px;
  box-shadow: 0 8px 20px rgba(24, 36, 48, 0.07);
}

.tool-panel h3,
.travel-notes h3 {
  margin: 0;
  font-size: 1.18rem;
}

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

.mini-form label,
.portfolio-grid label {
  display: grid;
  gap: 7px;
}

.mini-form span,
.portfolio-grid span,
.result-card span,
.spotlight-card span,
.cheat-card span,
.question-card span {
  color: var(--muted);
  font-size: 0.76rem;
  font-weight: 900;
  text-transform: uppercase;
}

.mini-form input,
.mini-form select,
.portfolio-grid input {
  width: 100%;
  min-height: 46px;
  border: 1px solid var(--line);
  border-radius: 8px;
  color: var(--ink);
  background: #fff;
  padding: 0 12px;
}

.result-card {
  display: grid;
  gap: 5px;
  min-height: 92px;
  padding: 14px;
  border-radius: 8px;
  color: #fff;
  background: var(--teal-dark);
}

.result-card strong {
  font-size: clamp(1.35rem, 2.4vw, 2rem);
  line-height: 1.05;
  overflow-wrap: anywhere;
}

.result-card small {
  color: #dcebed;
}

.travel-notes ul {
  display: grid;
  gap: 10px;
  margin: 0;
  padding-left: 18px;
  color: var(--muted);
}

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

.spotlight-card,
.cheat-card,
.question-card {
  display: grid;
  gap: 8px;
  padding: 18px;
  box-shadow: 0 8px 20px rgba(24, 36, 48, 0.07);
}

.spotlight-card strong,
.cheat-card strong,
.question-card strong {
  font-size: 1.08rem;
}

.spotlight-card small,
.cheat-card p,
.question-card p,
.favorite-item small {
  color: var(--muted);
}

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

.cheat-card ul {
  display: grid;
  gap: 7px;
  margin: 0;
  padding-left: 18px;
  color: var(--muted);
}

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

.question-card {
  min-height: 150px;
  border: 1px solid var(--line);
  color: var(--ink);
  text-align: left;
  cursor: pointer;
}

.question-card:hover,
.favorite-item:hover {
  border-color: var(--teal);
}

.favorites-panel {
  display: grid;
  gap: 14px;
  padding: 18px;
  box-shadow: 0 8px 20px rgba(24, 36, 48, 0.07);
}

#saveFavorite {
  width: max-content;
  min-height: 44px;
  border: 0;
  border-radius: 8px;
  color: #fff;
  background: var(--blue);
  padding: 0 16px;
  cursor: pointer;
  font-weight: 900;
}

.favorites-list {
  display: grid;
  gap: 10px;
}

.favorite-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 12px 14px;
  text-align: left;
  cursor: pointer;
  box-shadow: 0 8px 20px rgba(24, 36, 48, 0.05);
}

.favorite-item strong {
  display: block;
}

.history-list {
  display: grid;
  gap: 10px;
  margin: 0;
  padding: 0;
  list-style: none;
}

.history-list li {
  min-height: 58px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  padding: 14px 16px;
  box-shadow: 0 8px 20px rgba(24, 36, 48, 0.07);
}

.history-list span {
  color: var(--muted);
  font-size: 0.86rem;
  font-weight: 800;
}

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

@media (max-width: 920px) {
  .converter-hero,
  .tools-row,
  .tool-grid,
  .travel-grid,
  .spotlight-grid,
  .cheat-grid,
  .question-grid,
  .reference-grid {
    grid-template-columns: 1fr;
  }

  .converter-hero {
    grid-template-areas:
      "visual"
      "copy"
      "panel";
    min-height: auto;
    padding-top: 8px;
  }

  .fibonacci-header {
    max-height: none;
  }
}

@media (max-width: 680px) {
  .site-header {
    min-height: 68px;
  }

  .brand-title {
    max-width: 245px;
    font-size: 0.9rem;
  }

  .top-nav {
    display: none;
  }

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

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

  .swap-button {
    width: 100%;
  }

  .precision-control {
    grid-template-columns: 1fr;
  }

  .precision-control strong {
    text-align: left;
  }

  .section-heading {
    display: block;
  }

  .history-list li {
    display: grid;
  }

  .mini-form,
  .portfolio-grid {
    grid-template-columns: 1fr;
  }

  #saveFavorite {
    width: 100%;
  }

  .favorite-item {
    display: grid;
  }
}
