* {
  box-sizing: border-box;
}

:root {
  /* Midnight (default) */
  --page-bg: #131314;
  --text-primary: #e8eaed;
  --text-secondary: #9aa0a6;
  --text-tertiary: #80868b;
  --border: #3c4043;
  --input-bg: #131314;
  --option-bg: #202124;
  --accent: #8ab4f8;
  --accent-line: #e8998d;
  --accent-line-fill-top: rgba(232, 153, 141, 0.35);
  --accent-line-fill-bottom: rgba(232, 153, 141, 0);
  --pill-active-bg: #3c4043;
  --tooltip-bg: #2d2e30;
  --hover-overlay: rgba(255, 255, 255, 0.06);
  --chart-grid: rgba(255, 255, 255, 0.08);
  --shadow: rgba(0, 0, 0, 0.4);
  --page-font: "Google Sans", "Roboto", Arial, Helvetica, sans-serif;
  --select-arrow: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' width='24' height='24' viewBox='0 0 24 24'><path fill='%239aa0a6' d='M7 10l5 5 5-5z'/></svg>");
  --select-arrow-muted: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' width='16' height='16' viewBox='0 0 24 24'><path fill='%2380868b' d='M7 10l5 5 5-5z'/></svg>");
  font-family: var(--page-font);
}

/* Daylight — clean, bright, blue accent */
:root[data-theme="daylight"] {
  --page-bg: #ffffff;
  --text-primary: #202124;
  --text-secondary: #5f6368;
  --text-tertiary: #80868b;
  --border: #dadce0;
  --input-bg: #ffffff;
  --option-bg: #ffffff;
  --accent: #1a73e8;
  --accent-line: #1a73e8;
  --accent-line-fill-top: rgba(26, 115, 232, 0.18);
  --accent-line-fill-bottom: rgba(26, 115, 232, 0);
  --pill-active-bg: #e8f0fe;
  --tooltip-bg: #ffffff;
  --hover-overlay: rgba(32, 33, 36, 0.05);
  --chart-grid: rgba(32, 33, 36, 0.08);
  --shadow: rgba(60, 64, 67, 0.2);
  --select-arrow: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' width='24' height='24' viewBox='0 0 24 24'><path fill='%235f6368' d='M7 10l5 5 5-5z'/></svg>");
  --select-arrow-muted: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' width='16' height='16' viewBox='0 0 24 24'><path fill='%2380868b' d='M7 10l5 5 5-5z'/></svg>");
}

/* Terminal — phosphor-green CRT */
:root[data-theme="terminal"] {
  --page-bg: radial-gradient(ellipse at top, #0d160d 0%, #000000 70%);
  --text-primary: #39ff88;
  --text-secondary: #2bb85c;
  --text-tertiary: #1f8a44;
  --border: #1f4d2b;
  --input-bg: #050c05;
  --option-bg: #08150a;
  --accent: #39ff88;
  --accent-line: #39ff88;
  --accent-line-fill-top: rgba(57, 255, 136, 0.28);
  --accent-line-fill-bottom: rgba(57, 255, 136, 0);
  --pill-active-bg: #12331c;
  --tooltip-bg: #08150a;
  --hover-overlay: rgba(57, 255, 136, 0.08);
  --chart-grid: rgba(57, 255, 136, 0.12);
  --shadow: rgba(0, 0, 0, 0.6);
  --page-font: "Courier New", "Courier", monospace;
  --select-arrow: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' width='24' height='24' viewBox='0 0 24 24'><path fill='%2339ff88' d='M7 10l5 5 5-5z'/></svg>");
  --select-arrow-muted: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' width='16' height='16' viewBox='0 0 24 24'><path fill='%231f8a44' d='M7 10l5 5 5-5z'/></svg>");
}

/* Sunset — moody gradient, warm accent */
:root[data-theme="sunset"] {
  --page-bg: linear-gradient(160deg, #1a1025 0%, #2d1b3d 45%, #3d1f2e 100%);
  --text-primary: #fbe9f4;
  --text-secondary: #c9a6c2;
  --text-tertiary: #9b7a97;
  --border: #4a2f52;
  --input-bg: rgba(255, 255, 255, 0.03);
  --option-bg: #2d1b3d;
  --accent: #ff9d6c;
  --accent-line: #ff8a5c;
  --accent-line-fill-top: rgba(255, 138, 92, 0.35);
  --accent-line-fill-bottom: rgba(255, 138, 92, 0);
  --pill-active-bg: #3d2645;
  --tooltip-bg: #2d1b3d;
  --hover-overlay: rgba(255, 255, 255, 0.06);
  --chart-grid: rgba(255, 255, 255, 0.07);
  --shadow: rgba(0, 0, 0, 0.5);
  --select-arrow: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' width='24' height='24' viewBox='0 0 24 24'><path fill='%23c9a6c2' d='M7 10l5 5 5-5z'/></svg>");
  --select-arrow-muted: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' width='16' height='16' viewBox='0 0 24 24'><path fill='%239b7a97' d='M7 10l5 5 5-5z'/></svg>");
}

/* Mint — fresh, light, teal accent */
:root[data-theme="mint"] {
  --page-bg: #f2fbf7;
  --text-primary: #0b3d2e;
  --text-secondary: #3d7566;
  --text-tertiary: #6b9c8f;
  --border: #c7e6dc;
  --input-bg: #ffffff;
  --option-bg: #ffffff;
  --accent: #0d9488;
  --accent-line: #12b886;
  --accent-line-fill-top: rgba(18, 184, 134, 0.2);
  --accent-line-fill-bottom: rgba(18, 184, 134, 0);
  --pill-active-bg: #d3f2e8;
  --tooltip-bg: #ffffff;
  --hover-overlay: rgba(11, 61, 46, 0.05);
  --chart-grid: rgba(11, 61, 46, 0.08);
  --shadow: rgba(11, 61, 46, 0.15);
  --select-arrow: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' width='24' height='24' viewBox='0 0 24 24'><path fill='%233d7566' d='M7 10l5 5 5-5z'/></svg>");
  --select-arrow-muted: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' width='16' height='16' viewBox='0 0 24 24'><path fill='%236b9c8f' d='M7 10l5 5 5-5z'/></svg>");
}

html, body {
  margin: 0;
  padding: 0;
  background: var(--page-bg);
  color: var(--text-primary);
  min-height: 100vh;
}

body,
.input-group,
.range-btn,
.tz-select,
.theme-toggle-btn,
.theme-swatch {
  transition: background-color 0.25s ease, color 0.25s ease, border-color 0.25s ease,
    box-shadow 0.25s ease;
}

body {
  padding: 20px 16px 32px;
  font-family: var(--page-font);
}

:root[data-theme="terminal"] body {
  letter-spacing: 0.3px;
}

.card {
  width: 100%;
  max-width: 1000px;
  margin: 0 auto;
}

/* Theme switcher */
.theme-switcher {
  position: fixed;
  top: 16px;
  right: 16px;
  z-index: 20;
  display: flex;
  align-items: center;
  gap: 8px;
}

.theme-toggle-btn {
  width: 40px;
  height: 40px;
  flex-shrink: 0;
  border-radius: 50%;
  border: 1px solid var(--border);
  background: var(--input-bg);
  color: var(--text-primary);
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  box-shadow: 0 2px 8px var(--shadow);
}

.theme-toggle-btn svg {
  width: 20px;
  height: 20px;
}

.theme-toggle-btn:hover {
  background: var(--hover-overlay);
}

.theme-options {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 6px 8px;
  border-radius: 24px;
  border: 1px solid var(--border);
  background: var(--input-bg);
  box-shadow: 0 2px 8px var(--shadow);
  overflow: hidden;
  max-width: 0;
  padding-left: 0;
  padding-right: 0;
  border-width: 0;
  opacity: 0;
  transform: translateX(8px);
  transition: max-width 0.25s ease, opacity 0.2s ease, transform 0.25s ease,
    padding 0.25s ease, border-width 0.25s ease;
  pointer-events: none;
}

.theme-switcher.open .theme-options {
  max-width: 260px;
  padding: 6px 10px;
  border-width: 1px;
  opacity: 1;
  transform: translateX(0);
  pointer-events: auto;
}

.theme-swatch {
  width: 26px;
  height: 26px;
  flex-shrink: 0;
  border-radius: 50%;
  border: 2px solid transparent;
  background: var(--swatch-color);
  cursor: pointer;
  padding: 0;
  box-shadow: inset 0 0 0 1px rgba(0, 0, 0, 0.15);
}

.theme-swatch:hover {
  transform: scale(1.12);
}

.theme-swatch.active {
  border-color: var(--text-primary);
}

/* Headline */
.headline {
  /* Right padding keeps text clear of the fixed theme switcher up top. */
  padding: 4px 64px 16px 4px;
}

.equals-line {
  margin: 0 0 4px;
  font-size: 15px;
  font-weight: 400;
  color: var(--text-secondary);
}

:root[data-theme="terminal"] .equals-line {
  text-transform: uppercase;
  letter-spacing: 1px;
}

.headline h1 {
  margin: 0 0 8px;
  font-size: 30px;
  line-height: 1.2;
  font-weight: 400;
  color: var(--text-primary);
}

:root[data-theme="terminal"] .headline h1 {
  text-shadow: 0 0 8px rgba(57, 255, 136, 0.55);
}

.timestamp {
  margin: 0;
  font-size: 13px;
  color: var(--text-tertiary);
  min-height: 16px;
  display: flex;
  align-items: center;
  gap: 4px;
  flex-wrap: wrap;
}

.tz-select {
  border: none;
  background: transparent;
  color: var(--text-tertiary);
  font-size: 13px;
  font-family: inherit;
  padding: 2px 18px 2px 4px;
  margin: 0;
  outline: none;
  appearance: none;
  -webkit-appearance: none;
  background-image: var(--select-arrow-muted);
  background-repeat: no-repeat;
  background-position: right 0 center;
  cursor: pointer;
  max-width: 200px;
}

.tz-select option {
  background: var(--option-bg);
  color: var(--text-primary);
}

/* Content */
.content-row {
  display: flex;
  flex-direction: column;
  gap: 24px;
  padding: 0 4px;
}

.left-column {
  width: 100%;
}

.converter {
  position: relative;
  display: flex;
  flex-direction: column;
  gap: 12px;
  width: 100%;
}

.swap-btn {
  position: absolute;
  top: 50%;
  right: 16px;
  transform: translateY(-50%);
  width: 32px;
  height: 32px;
  border-radius: 50%;
  border: 1px solid var(--border);
  background: var(--input-bg);
  color: var(--text-primary);
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  z-index: 2;
  box-shadow: 0 2px 6px var(--shadow);
  transition: box-shadow 0.2s ease, border-color 0.2s ease;
}

.swap-btn:hover {
  border-color: var(--accent-line);
  box-shadow: 0 2px 6px var(--shadow), 0 0 10px 2px var(--accent-line);
}

@keyframes swap-pulse {
  0% {
    transform: rotate(0deg) scale(1);
  }
  50% {
    transform: rotate(180deg) scale(0.8);
  }
  100% {
    transform: rotate(360deg) scale(1);
  }
}

.swap-btn.pulsing svg {
  animation: swap-pulse 0.35s ease;
}

.input-group {
  display: flex;
  align-items: center;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--input-bg);
  height: 52px;
  overflow: hidden;
}

.input-group input {
  flex: 1 1 40%;
  height: 100%;
  border: none;
  background: transparent;
  color: var(--text-primary);
  font-family: inherit;
  font-size: 16px;
  padding: 0 14px;
  min-width: 0;
  outline: none;
}

.input-group .divider {
  width: 1px;
  height: 60%;
  background: var(--border);
  flex-shrink: 0;
}

.input-group select {
  flex: 1 1 60%;
  height: 100%;
  border: none;
  background: transparent;
  color: var(--text-primary);
  font-family: inherit;
  font-size: 16px;
  padding: 0 14px;
  outline: none;
  appearance: none;
  -webkit-appearance: none;
  background-image: var(--select-arrow);
  background-repeat: no-repeat;
  background-position: right 12px center;
  cursor: pointer;
}

.input-group select option {
  background: var(--option-bg);
  color: var(--text-primary);
}

/* Chart panel */
.chart-panel {
  min-width: 0;
}

.range-buttons {
  display: flex;
  gap: 6px;
  margin-bottom: 12px;
  overflow-x: auto;
  scrollbar-width: none;
  -ms-overflow-style: none;
}

.range-buttons::-webkit-scrollbar {
  display: none;
}

.range-btn {
  flex: 0 0 auto;
  border: none;
  background: transparent;
  color: var(--text-secondary);
  font-family: inherit;
  font-size: 14px;
  font-weight: 500;
  padding: 8px 14px;
  border-radius: 16px;
  cursor: pointer;
}

.range-btn:hover {
  background: var(--hover-overlay);
}

.range-btn.active {
  background: var(--pill-active-bg);
  color: var(--accent);
}

:root[data-theme="terminal"] .range-btn.active {
  text-shadow: 0 0 6px rgba(57, 255, 136, 0.8);
}

.chart-wrap {
  position: relative;
  height: 260px;
  width: 100%;
}

/* Larger screens: converter and chart side by side */
@media (min-width: 900px) {
  body {
    padding: 40px 16px;
    min-height: 100vh;
    display: flex;
    flex-direction: column;
    justify-content: center;
  }

  .headline {
    /* Confined to the 420px left column now, so no overlap risk from the
       fixed theme switcher — no need to reserve right padding for it. */
    padding: 4px 4px 20px 4px;
  }

  .equals-line {
    font-size: 17px;
  }

  .headline h1 {
    font-size: 44px;
    margin: 0 0 10px;
  }

  .content-row {
    flex-direction: row;
    align-items: flex-start;
    gap: 32px;
  }

  .left-column {
    max-width: 420px;
  }

  .converter {
    gap: 14px;
  }

  .input-group {
    height: 56px;
  }

  .input-group input,
  .input-group select {
    font-size: 17px;
    padding: 0 18px;
  }

  .chart-panel {
    flex: 1 1 480px;
  }

  .chart-wrap {
    height: 320px;
  }
}
