: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: 100vh;
  width: 100vw;
  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;
  z-index: 0;
  display: grid;
  place-items: center;
  overflow: hidden;
  pointer-events: none;
}

/* 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;
}

@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%;
  max-width: 900px;
  margin: 0 auto;
  display: flex;
  flex-direction: column;
  justify-content: center;
  align-items: center;
  padding: 24px 10px;
}

.converter {
  width: 100%;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 1rem;
}

.brand {
  margin: 0;
  color: rgba(216, 198, 144, 0.4);
  font-family: Georgia, "Times New Roman", serif;
  font-size: 32px;
  /* Stable size for measurement */
  min-height: 48px;
  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;
}

.welcome-prompt {
  margin: 0;
  text-align: center;
  color: rgba(236, 229, 206, 0.8);
  font-family: Georgia, "Times New Roman", serif;
  font-size: 72px;
  /* Stable size for measurement */
  min-height: 96px;
  font-weight: 400;
  line-height: 1.2;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  width: 100%;
  display: flex;
  align-items: center;
  justify-content: center;
}



.controls {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  align-items: stretch;
  margin: 12px;
  gap: 12px;
  width: 100%;
  max-width: 600px;
}

.field {
  flex: 1;
  min-width: 120px;
}

#value-input {
  width: 100%;
  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: 140px;
}

.unit-button {
  width: 100%;
  height: 100%;
  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;
}

.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 {
  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: 480px) {
  .controls {
    flex-direction: column;
  }

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

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

.thinking-panel,
.result {
  grid-area: 1 / 1 / 2 / 2;
  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 {
  font-family: Georgia, serif;
  font-size: var(--result-size, 2rem);
  color: var(--gold);
  max-width: 100%;
  overflow-wrap: break-word;
}

.upgrade-pricing-container {
  margin-top: 16px;
  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-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;
}

.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 {
  background: transparent;
  border: none;
  color: var(--gold);
  font-size: 0.85rem;
  line-height: 1.2;
  padding: 3px 10px;
  cursor: pointer;
  text-decoration: none;
  align-self: center;
  font-family: inherit;
  opacity: 0.82;
  transition: color 0.2s, opacity 0.2s;
}

.more-button:hover {
  color: var(--ink);
  opacity: 1;
}

.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: 12px 20px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
  color: var(--dim);
  font-size: 0.875rem;
  background: transparent;
}

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

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

.footer a {
  color: var(--dim);
  text-decoration: underline;
  transition: color 0.2s;
}

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

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

.native-unit-select {
  position: absolute;
  opacity: 0;
  pointer-events: none;
}

;
}

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

.native-unit-select {
  position: absolute;
  opacity: 0;
  pointer-events: none;
}
