@import url('https://fonts.googleapis.com/css2?family=Fraunces:opsz,wght@9..144,400;9..144,700&family=Overpass+Mono:wght@400;600;700&family=Source+Sans+3:wght@400;500;600&display=swap');

:root {
  --bg: #0e1117;
  --bg2: #151921;
  --bg3: #1c2030;
  --surface: #212636;
  --border: #2e3446;
  --border2: #3a4158;
  --text: #d4d2e0;
  --text2: #8a89a0;
  --text3: #5e5d74;
  --amber: #f0b840;
  --amber2: #d49a20;
  --amber-dim: #7a6220;
  --red: #f06860;
  --green: #50d898;
  --blue: #58a0f0;
  --purple: #a880e0;
  --glow: rgba(240, 184, 64, 0.08);
  --glow2: rgba(240, 184, 64, 0.18);
  --radius: 10px;
  --font-display: 'Fraunces', serif;
  --font-body: 'Source Sans 3', sans-serif;
  --font-mono: 'Overpass Mono', monospace;
}

*,
*::before,
*::after {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
}

html {
  font-size: 16px;
}

body {
  display: flex;
  flex-direction: column;
  background: var(--bg);
  color: var(--text);
  font-family: var(--font-body);
  line-height: 1.55;
  min-height: 100vh;
  -webkit-font-smoothing: antialiased;
}

/* Noise overlay */
body::before {
  content: '';
  position: fixed;
  inset: 0;
  pointer-events: none;
  z-index: 9999;
  opacity: 0.025;
  background-image: url("data:image/svg+xml,%3Csvg viewBox='0 0 200 200' xmlns='http://www.w3.org/2000/svg'%3E%3Cfilter id='n'%3E%3CfeTurbulence baseFrequency='0.85' numOctaves='3' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23n)'/%3E%3C/svg%3E");
  background-size: 200px 200px;
}

/* Layout */
.container {
  width: 100%;
  max-width: 720px;
  margin: 0 auto;
  padding: 0 1.25rem;
  flex: 1;
}

/* Header */
.header {
  padding: 3.5rem 0 2.5rem;
  text-align: center;
  position: relative;
}

.header h1 {
  font-family: var(--font-display);
  font-size: 2.5rem;
  font-weight: 700;
  color: var(--amber);
  letter-spacing: -0.02em;
  line-height: 1.15;
}

.header p {
  color: var(--text2);
  font-size: 0.95rem;
  margin-top: 0.6rem;
}

.badge {
  display: inline-block;
  font-family: var(--font-mono);
  font-size: 0.7rem;
  font-weight: 600;
  color: var(--amber-dim);
  background: var(--bg3);
  border: 1px solid var(--border);
  padding: 0.2rem 0.6rem;
  border-radius: 99px;
  margin-top: 0.8rem;
  letter-spacing: 0.02em;
}

.badge strong {
  color: var(--amber);
}

/* Scale Selector (custom radio) */
.scale-selector {
  display: flex;
  gap: 6px;
  margin: 2rem 0 1.2rem;
  background: var(--bg2);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 5px;
}

.scale-selector input[type="radio"] {
  position: absolute;
  opacity: 0;
  width: 0;
  height: 0;
}

.scale-selector label {
  flex: 1;
  text-align: center;
  padding: 0.55rem 0.5rem;
  font-family: var(--font-mono);
  font-size: 0.78rem;
  font-weight: 600;
  color: var(--text3);
  border-radius: 7px;
  cursor: pointer;
  transition: all 0.2s ease;
  user-select: none;
  letter-spacing: 0.02em;
  position: relative;
}

.scale-selector label:hover {
  color: var(--text2);
  background: var(--bg3);
}

.scale-selector input[type="radio"]:checked+label {
  color: var(--bg);
  background: var(--amber);
  box-shadow: 0 2px 12px rgba(240, 184, 64, 0.25);
}

.scale-selector label .label-icon {
  display: block;
  font-size: 1rem;
  margin-bottom: 0.15rem;
  font-style: normal;
}

/* Weight / Length / Area / Volume specific colors when active */
.scale-selector input#scale-weight:checked+label {
  background: var(--blue);
  color: var(--bg);
  box-shadow: 0 2px 12px rgba(88, 160, 240, 0.25);
}

.scale-selector input#scale-length:checked+label {
  background: var(--red);
  color: var(--bg);
  box-shadow: 0 2px 12px rgba(240, 104, 96, 0.25);
}

.scale-selector input#scale-area:checked+label {
  background: var(--green);
  color: var(--bg);
  box-shadow: 0 2px 12px rgba(80, 216, 152, 0.25);
}

.scale-selector input#scale-volume:checked+label {
  background: var(--purple);
  color: var(--bg);
  box-shadow: 0 2px 12px rgba(168, 128, 224, 0.25);
}

/* Input area */
.input-group {
  display: flex;
  gap: 0;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
  transition: border-color 0.2s;
}

.input-group:focus-within {
  border-color: var(--amber);
  box-shadow: 0 0 0 3px var(--glow);
}

.input-value {
  flex: 1;
  background: transparent;
  border: none;
  padding: 1rem 1.2rem;
  font-family: var(--font-mono);
  font-size: 1.2rem;
  font-weight: 600;
  color: var(--text);
  outline: none;
  min-width: 0;
}

.input-value::placeholder {
  color: var(--text3);
  font-weight: 400;
}

.input-divider {
  width: 1px;
  background: var(--border);
  align-self: stretch;
  margin: 0.6rem 0;
}

.input-unit {
  width: 100px;
  background: transparent;
  border: none;
  padding: 1rem 1rem;
  font-family: var(--font-mono);
  font-size: 1rem;
  font-weight: 600;
  color: var(--amber);
  outline: none;
  text-align: center;
}

.input-unit::placeholder {
  color: var(--text3);
  font-weight: 400;
}

/* Results area */
.results {
  margin-top: 2rem;
  display: none;
}

.results.visible {
  display: block;
}

.results-intro {
  text-align: center;
  margin-bottom: 1.8rem;
}

.results-intro .si-value {
  font-family: var(--font-mono);
  font-size: 1.1rem;
  font-weight: 600;
  color: var(--amber);
}

.results-intro .si-value small {
  font-size: 0.75rem;
  color: var(--text2);
  font-weight: 400;
}

.fun-sentence {
  background: var(--bg2);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1.2rem 1.5rem;
  text-align: center;
  font-size: 1.05rem;
  line-height: 1.6;
  margin-bottom: 2rem;
  color: var(--text);
}

.fun-sentence strong {
  color: var(--amber);
  font-weight: 600;
}

/* Comparison cards */
.section-title {
  font-family: var(--font-mono);
  font-size: 0.7rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  color: var(--text3);
  margin-bottom: 0.8rem;
  padding-bottom: 0.5rem;
  border-bottom: 1px solid var(--border);
}

.card {
  display: flex;
  align-items: center;
  gap: 1rem;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1rem 1.2rem;
  margin-bottom: 0.5rem;
  position: relative;
  transition: border-color 0.15s, transform 0.1s;
}

.card:hover {
  border-color: var(--border2);
  transform: translateY(-1px);
}

.card-icon {
  width: 44px;
  height: 44px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--bg2);
  border-radius: 8px;
  font-size: 1.4rem;
  flex-shrink: 0;
}

.card-body {
  flex: 1;
  min-width: 0;
}

.card-name {
  font-weight: 600;
  font-size: 0.92rem;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.card-cat {
  font-family: var(--font-mono);
  font-size: 0.65rem;
  color: var(--text3);
  text-transform: uppercase;
  letter-spacing: 0.06em;
}

.card-right {
  text-align: right;
  flex-shrink: 0;
}

.card-factor {
  font-family: var(--font-mono);
  font-size: 1.05rem;
  font-weight: 700;
  color: var(--amber);
}

.card-desc {
  font-size: 0.72rem;
  color: var(--text2);
  max-width: 160px;
  text-align: right;
}

.card-closest {
  position: absolute;
  top: 0;
  right: 0;
  font-family: var(--font-mono);
  font-size: 0.55rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  padding: 0.15rem 0.5rem;
  border-radius: 0 var(--radius) 0 6px;
}

/* Color per type */
.card-closest.weight {
  background: var(--blue);
  color: var(--bg);
}

.card-closest.length {
  background: var(--red);
  color: var(--bg);
}

.card-closest.area {
  background: var(--green);
  color: var(--bg);
}

.card-closest.volume {
  background: var(--purple);
  color: var(--bg);
}

/* Source link */
.card-source {
  display: inline-block;
  font-size: 0.6rem;
  color: var(--text3);
  text-decoration: none;
  font-family: var(--font-mono);
  margin-top: 0.1rem;
  opacity: 0;
  transition: opacity 0.15s;
}

.card:hover .card-source {
  opacity: 1;
}

.card-source:hover {
  color: var(--amber-dim);
  text-decoration: underline;
}

/* Empty state */
.empty-state {
  text-align: center;
  padding: 3rem 1rem;
  color: var(--text3);
}

.empty-state .big {
  font-size: 2.5rem;
  margin-bottom: 0.5rem;
}

/* Footer */
.footer {
  text-align: center;
  padding: 3rem 0;
  margin-top: 3rem;
  border-top: 1px solid var(--border);
  font-size: 0.75rem;
  color: var(--text3);
  font-family: var(--font-mono);
}

.footer a {
  color: var(--text2);
  text-decoration: none;
}

.footer a:hover {
  color: var(--amber);
}

/* Animations */
@keyframes fadeUp {
  from {
    opacity: 0;
    transform: translateY(8px);
  }

  to {
    opacity: 1;
    transform: translateY(0);
  }
}

.card {
  animation: fadeUp 0.3s ease-out both;
}

.card:nth-child(1) {
  animation-delay: 0.00s;
}

.card:nth-child(2) {
  animation-delay: 0.04s;
}

.card:nth-child(3) {
  animation-delay: 0.08s;
}

.card:nth-child(4) {
  animation-delay: 0.12s;
}

.card:nth-child(5) {
  animation-delay: 0.16s;
}

.card:nth-child(6) {
  animation-delay: 0.20s;
}

.card:nth-child(7) {
  animation-delay: 0.24s;
}

.card:nth-child(8) {
  animation-delay: 0.28s;
}

/* Responsive */
@media (max-width: 540px) {
  .header h1 {
    font-size: 1.8rem;
  }

  .scale-selector label {
    padding: 0.5rem 0.25rem;
    font-size: 0.7rem;
  }

  .scale-selector label .label-icon {
    font-size: 0.85rem;
  }

  .input-value {
    font-size: 1rem;
    padding: 0.85rem 1rem;
  }

  .input-unit {
    width: 80px;
    font-size: 0.9rem;
  }

  .card {
    flex-wrap: wrap;
    gap: 0.6rem;
  }

  .card-right {
    width: 100%;
    text-align: left;
    display: flex;
    gap: 0.5rem;
    align-items: baseline;
  }

  .card-desc {
    text-align: left;
    max-width: none;
  }
}