:root {
  color-scheme: dark;
  --bg: #0d0f12;
  --ink: #e8eaed;
  --muted: #bdc1c6;
  --dim: #8c919a;
  --panel: #202124;
  --panel-hover: #282a2d;
  --line: #303134;
  --accent: #9bbcff;
  --gold: #d8c690;
  --shadow: 0 28px 120px rgba(0, 0, 0, 0.4);
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100svh;
  min-height: 100dvh;
  width: 100%;
  overflow-x: hidden;
  overflow-y: auto;
  font-family: Georgia, "Times New Roman", serif;
  color: var(--ink);
  background: linear-gradient(140deg, #111315 0%, #0d0f12 38%, #101114 100%);
  display: flex;
  flex-direction: column;
}

.background-layer {
  position: fixed;
  inset: 0;
  min-height: 100svh;
  min-height: 100dvh;
  z-index: 0;
  display: grid;
  place-items: center;
  overflow: hidden;
  pointer-events: none;
}

.source-guard {
  position: fixed;
  inset: 0;
  z-index: 9999;
  display: grid;
  place-items: center;
  padding: 24px;
  color: var(--gold);
  background: #0d0f12;
  text-align: center;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.2s ease-out;
}

.source-guard p {
  width: min(100%, 760px);
  max-height: 100%;
  font-size: var(--source-guard-size, clamp(2rem, 7vw, 5rem));
  line-height: 1.05;
  overflow-wrap: anywhere;
}

body.is-a-little-bitch {
  overflow: hidden;
}

body.is-a-little-bitch .source-guard {
  opacity: 1;
  pointer-events: auto;
}

/* God */
.breathing-orb {
  width: min(90vw, 90vh, 980px);
  /* Keep it within window bounds */
  aspect-ratio: 1;
  border-radius: 67%;
  background: radial-gradient(circle, rgba(69, 97, 197, 0.4) 0 14%, rgba(32, 55, 131, 0.3) 34%, rgba(15, 24, 64, 0.1) 56%, rgba(13, 15, 18, 0) 72%);
  filter: blur(40px);
  /* Softer fade */
  opacity: 1.0;
  transform: scale(0.92);
  transform-origin: center;
  animation: breathe 4s ease-in-out infinite;
}

@media (max-width: 560px) {
  .background-layer {
    place-items: start center;
    padding-top: 18svh;
  }

  .breathing-orb {
    width: min(112vw, 58svh, 520px);
    background: radial-gradient(circle, rgba(92, 124, 230, 0.56) 0 16%, rgba(44, 72, 165, 0.42) 36%, rgba(18, 32, 86, 0.2) 58%, rgba(13, 15, 18, 0) 78%);
    filter: blur(24px);
  }
}

@keyframes breathe {

  0%,
  100% {
    transform: scale(0.92);
    opacity: 0.7;
  }

  50% {
    transform: scale(1.05);
    opacity: 0.9;
  }
}

.shell {
  position: relative;
  z-index: 1;
  flex: 1 0 auto;
  min-height: 0;
  width: 100%;
  min-width: 0;
  max-width: 900px;
  margin: 0 auto;
  display: flex;
  flex-direction: column;
  justify-content: center;
  align-items: center;
  padding: 24px 10px;
}

.converter {
  width: 100%;
  min-width: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: clamp(0.35rem, 2vw, 1rem);
}

.brand {
  margin: 0;
  color: rgba(216, 198, 144, 0.4);
  font-family: Georgia, "Times New Roman", serif;
  font-size: 32px;
  min-height: 1.2em;
  font-weight: 400;
  line-height: 1.2;
  text-align: center;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  width: 100%;
  display: flex;
  align-items: center;
  justify-content: center;
}

.rolodex {
  width: calc(100vw - 20px);
  max-width: none;
  height: 112px;
  display: grid;
  place-items: center;
  overflow: hidden;
}

.welcome-prompt {
  margin: 0;
  text-align: center;
  color: rgba(236, 229, 206, 0.8);
  font-family: Georgia, "Times New Roman", serif;
  font-size: 72px;
  min-height: 0;
  max-height: 100%;
  font-weight: 400;
  line-height: 1.16;
  white-space: nowrap;
  overflow: hidden;
  overflow-wrap: normal;
  text-overflow: ellipsis;
  width: 100%;
  display: block;
  opacity: 1;
  transform: translateY(0);
  transition: opacity 0.45s ease, transform 0.45s ease;
}

.welcome-prompt.is-transitioning {
  opacity: 0;
  transform: translateY(6px);
}



.controls {
  display: grid;
  grid-template-columns: minmax(220px, 1fr) 150px 128px;
  align-items: stretch;
  margin: 12px 0;
  gap: 12px;
  width: 100%;
  max-width: 600px;
}

.field {
  min-width: 0;
}

#value-input {
  width: 100%;
  height: 48px;
  background: var(--panel);
  border: 1px solid var(--line);
  color: var(--ink);
  padding: 12px 16px;
  border-radius: 8px;
  font-size: 1.25rem;
  outline: none;
  transition: border-color 0.2s;
}

#value-input:focus {
  border-color: var(--accent);
}

.unit-picker {
  position: relative;
  min-width: 0;
}

.native-unit-select {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  opacity: 0;
  pointer-events: none;
}

.unit-button {
  width: 100%;
  height: 48px;
  background: var(--panel);
  border: 1px solid var(--line);
  color: var(--ink);
  padding: 12px 16px;
  border-radius: 8px;
  font-size: 1rem;
  cursor: pointer;
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
  min-width: 0;
}

#unit-button-text {
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.unit-button::after {
  content: "";
  width: 8px;
  height: 8px;
  border-right: 2px solid var(--dim);
  border-bottom: 2px solid var(--dim);
  transform: rotate(45deg);
  margin-bottom: 4px;
  transition: transform 0.2s, border-color 0.2s;
}

.unit-button[aria-expanded="true"]::after {
  transform: rotate(-135deg);
  margin-bottom: -4px;
}

.unit-button:hover::after {
  border-color: var(--ink);
}

.unit-button:hover {
  background: var(--panel-hover);
}

.unit-menu {
  position: absolute;
  top: calc(100% + 8px);
  left: 0;
  right: 0;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 12px;
  max-height: 320px;
  overflow: hidden;
  z-index: 100;
  box-shadow: 0 12px 48px rgba(0, 0, 0, 0.5);
  animation: slideIn 0.2s ease-out;
}

@keyframes slideIn {
  from {
    opacity: 0;
    transform: translateY(-10px);
  }

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

.unit-menu-scroll {
  max-height: 300px;
  overflow-y: auto;
}

.unit-option {
  width: 100%;
  padding: 10px 16px;
  background: transparent;
  border: none;
  color: var(--muted);
  text-align: left;
  cursor: pointer;
}

.unit-option:hover,
.unit-option.is-selected {
  background: var(--panel-hover);
  color: var(--ink);
}

.compute-button {
  height: 48px;
  background: var(--accent);
  color: #000;
  border: none;
  padding: 12px 24px;
  border-radius: 8px;
  font-weight: 600;
  font-size: 1rem;
  cursor: pointer;
  transition: opacity 0.2s;
}

.compute-button:hover:not(:disabled) {
  opacity: 0.9;
}

.compute-button:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

@media (max-width: 560px) {
  .brand {
    width: calc(100vw - 20px);
    max-width: none;
    max-height: 2.24em;
    font-size: clamp(12px, 3.75vw, 16px);
    line-height: 1.12;
    overflow-wrap: anywhere;
    overflow: hidden;
    text-overflow: clip;
    text-wrap: balance;
    white-space: normal;
    display: block;
  }

  .rolodex {
    height: 86px;
  }

  .output-stage {
    height: 112px;
  }

  .welcome-prompt {
    max-height: 100%;
    font-size: clamp(24px, 8.7vw, 34px);
    line-height: 1.12;
    white-space: normal;
    overflow-wrap: anywhere;
    text-overflow: clip;
    text-wrap: balance;
  }

  .controls {
    grid-template-columns: minmax(0, 1fr) minmax(116px, 0.72fr);
    max-width: 360px;
    gap: 12px;
  }

  .field,
  .unit-picker {
    width: 100%;
  }

  .compute-button {
    grid-column: 1 / -1;
    width: 100%;
  }
}

@media (max-width: 560px),
(pointer: coarse) {
  .unit-picker {
    min-height: 48px;
  }

  #value-input {
    padding: 10px 12px;
    font-size: clamp(13px, 4vw, 18px);
    line-height: 1.2;
  }

  .native-unit-select {
    position: absolute;
    inset: 0;
    width: 100%;
    height: 48px;
    z-index: 2;
    opacity: 0;
    pointer-events: auto;
  }

  .unit-button {
    position: relative;
    z-index: 1;
    display: flex;
    height: 48px;
    padding: 9px 48px 9px 12px;
    font-size: clamp(13px, 4vw, 18px);
    line-height: 1.05;
    pointer-events: none;
  }

  #unit-button-text {
    min-width: 0;
    overflow: hidden;
    line-height: 1.05;
    text-overflow: ellipsis;
    white-space: nowrap;
  }

  .unit-button::after {
    position: absolute;
    top: 50%;
    right: 17px;
    width: 10px;
    height: 10px;
    margin: 0;
    border-color: var(--ink);
    transform: translateY(-65%) rotate(45deg);
    opacity: 0.82;
  }

  .unit-menu {
    display: none;
  }
}

.output-stage {
  width: 100%;
  min-width: 0;
  position: relative;
  display: grid;
  grid-template-columns: 1fr;
  grid-template-rows: 1fr;
  justify-items: center;
  align-items: start;
  text-align: center;
  height: 140px;
  overflow: visible;
}

.thinking-panel,
.result {
  grid-area: 1 / 1 / 2 / 2;
  width: 100%;
  min-width: 0;
  max-width: 100%;
  display: flex;
  flex-direction: column;
  align-items: center;
  transition: opacity 0.3s ease-in-out, transform 0.3s ease-out;
}

.thinking-panel[hidden],
.result[hidden] {
  display: flex !important;
  opacity: 0;
  pointer-events: none;
  visibility: hidden;
  transform: translateY(8px);
}

.result-value {
  display: block;
  width: 100%;
  font-family: Georgia, serif;
  font-size: var(--result-size, 2rem);
  line-height: 1.05;
  color: var(--gold);
  max-width: 100%;
  overflow-wrap: anywhere;
  text-align: center;
}

.snooper-deterrant {
  margin-bottom: 8px;
  color: var(--ink);
  font-size: 1rem;
  line-height: 1.35;
}

.upgrade-pricing-container {
  margin-top: 16px;
  width: 100%;
  max-width: 100%;
  display: flex;
  flex-direction: column;
  align-items: center;
  opacity: 0;
  max-height: 0;
  overflow: hidden;
  transition: opacity 0.8s ease-out, max-height 0.8s ease-in-out;
}

.upgrade-pricing-container.is-visible {
  opacity: 1;
  max-height: none;
  overflow: visible;
}


.usage-limits-text {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
  text-align: center;
}

.usage-limits-info {
  color: var(--muted);
  font-size: 0.9rem;
}

.usage-limits-info span+span {
  margin-left: 0.25em;
}

.usage-limits-upsell {
  color: var(--dim);
  font-size: 0.8rem;
  font-style: italic;
}

.pricing-tiers {
  display: flex;
  gap: 20px;
  margin-top: 12px;
  width: 100%;
  max-width: 850px;
  justify-content: center;
  align-items: flex-start;
}

@keyframes fadeIn {
  from {
    opacity: 0;
    transform: translateY(10px);
  }

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

.tier {
  background: var(--panel);
  border: 1px solid var(--line);
  padding: 16px;
  border-radius: 12px;
  text-align: left;
  display: flex;
  flex-direction: column;
  gap: 8px;
  /* Fixed width to prevent expanding */
  flex: 0 0 250px;
}

@media (max-width: 820px) {
  .usage-limits-info span {
    display: block;
  }

  .usage-limits-info span+span {
    margin-left: 0;
  }

  .pricing-tiers {
    flex-direction: column;
    align-items: stretch;
    gap: 12px;
    max-width: 360px;
  }

  .tier {
    flex: 0 1 auto;
    width: 100%;
  }
}

.tier h3 {
  margin: 0;
  font-size: 1rem;
  font-weight: 600;
}

.tier ul {
  margin: 0;
  padding: 0;
  list-style: none;
  font-size: 0.85rem;
  color: var(--muted);
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.tier ul li::before {
  content: "\2022";
  margin-right: 8px;
  color: var(--dim);
}

.more-button {
  position: relative;
  isolation: isolate;
  background: linear-gradient(90deg, #ff4d6d 0%, #ffb703 10%, #7bd88f 20%, #4cc9f0 30%, #c77dff 40%, #ff4d6d 50%, #ffb703 60%, #7bd88f 70%, #4cc9f0 80%, #c77dff 90%, #ff4d6d 100%);

  background-size: 200% 100%;

  border: 1px solid rgba(255, 255, 255, 0.42);
  color: #0d0f12;
  font-size: 0.85rem;
  line-height: 1.2;
  font-weight: 700;
  padding: 7px 12px;
  border-radius: 999px;
  cursor: pointer;
  text-decoration: none;
  align-self: center;
  font-family: inherit;
  box-shadow: 0 0 18px rgba(199, 125, 255, 0.46), 0 0 32px rgba(76, 201, 240, 0.18);
  animation: seamlessGradient 3s linear infinite;
  transition: transform 0.2s, box-shadow 0.2s, filter 0.2s;
}

@keyframes seamlessGradient {
  0% {
    background-position: 0% 50%;
  }

  100% {
    background-position: 100% 50%;
  }
}

.more-button::before {
  position: absolute;
  inset: -4px;
  z-index: -1;
  content: "";
  background: inherit;
  border-radius: inherit;
  filter: blur(12px);
  opacity: 0.58;
}

.more-button:hover,
.more-button:focus-visible {
  transform: translateY(-1px);
  filter: saturate(1.18);
  box-shadow: 0 0 24px rgba(255, 183, 3, 0.48), 0 0 42px rgba(199, 125, 255, 0.32);
}

.more-button:focus-visible {
  outline: 2px solid var(--ink);
  outline-offset: 3px;
}

@keyframes rainbowShift {
  from {
    background-position: 0% 0;
  }

  to {
    background-position: 50% 0;
  }
}

.tier-free {
  border-color: #4a4a4a;
}

.tier-pro {
  border-color: #9bbcff;
  background: rgba(155, 188, 255, 0.05);
}

.tier-pro h3 {
  color: #9bbcff;
}

.tier-max {
  border: 2px solid var(--gold);
  background: rgba(216, 198, 144, 0.05);
  box-shadow: 0 0 20px rgba(216, 198, 144, 0.1);
}

.tier-max h3 {
  color: var(--gold);
}

.is-muted {
  opacity: 0.3;
}

.thinking-panel {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 12px;
}

.spinner {
  width: 24px;
  height: 24px;
  border: 3px solid rgba(155, 188, 255, 0.2);
  border-top-color: var(--accent);
  border-radius: 50%;
  animation: spin 1s linear infinite;
}

@keyframes spin {
  to {
    transform: rotate(360deg);
  }
}

p {
  margin: 0;
}

.footer {
  position: relative;
  z-index: 1;
  padding: 18px 20px calc(20px + env(safe-area-inset-bottom));
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 12px;
  color: var(--dim);
  font-size: 1rem;
  background: transparent;
}

.footer-links {
  display: flex;
  align-items: center;
  gap: 12px;
}

.separator {
  color: var(--line);
  font-weight: 300;
}

.footer a {
  color: var(--ink);
  text-decoration: none;
  transition: color 0.2s, border-color 0.2s, background 0.2s, transform 0.2s;
}

.footer a:hover,
.footer a:focus-visible {
  color: var(--ink);
}

.footer-cta {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 44px;
  padding: 10px 18px;
  border: 1px solid rgba(216, 198, 144, 0.45);
  border-radius: 999px;
  background: rgba(216, 198, 144, 0.08);
  font-size: 1.08rem;
}

.footer-cta:hover,
.footer-cta:focus-visible {
  border-color: var(--gold);
  background: rgba(216, 198, 144, 0.15);
  transform: translateY(-1px);
}

.footer-cta:focus-visible {
  outline: 2px solid var(--gold);
  outline-offset: 3px;
}

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