:root {
  color-scheme: light;
  --bg: #f4f6f8;
  --panel: #ffffff;
  --ink: #16202a;
  --muted: #617182;
  --line: #d9e1e8;
  --accent: #147d73;
  --accent-dark: #0f5f57;
  --warning: #aa3f23;
  --soft: #eef7f5;
  --surface: #ffffff;
  --surface-subtle: #fbfcfd;
  --segmented-bg: #eef3f2;
  --disabled-bg: #f4f8f7;
  --positive-bg: #edf8f4;
  --negative-bg: #fff3ef;
  --button-ink: #ffffff;
  --danger-dark: #84301a;
  --focus-ring: rgba(20, 125, 115, 0.14);
  --accent-wash: rgba(20, 125, 115, 0.08);
  --accent-border: rgba(20, 125, 115, 0.28);
  --warning-border: rgba(170, 63, 35, 0.35);
  --shadow: rgba(22, 32, 42, 0.14);
  --grid-line: #dfe7ed;
  --glow-primary: rgba(20, 125, 115, 0.12);
  --glow-secondary: rgba(22, 32, 42, 0.08);
  font-family:
    Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI",
    sans-serif;
}

:root[data-theme="midnight"] {
  color-scheme: dark;
  --bg: #101721;
  --panel: #182330;
  --ink: #edf7f5;
  --muted: #a2b5bc;
  --line: #324352;
  --accent: #65d5c5;
  --accent-dark: #8be7d9;
  --warning: #ff9c82;
  --soft: #20383c;
  --surface: #1d2a38;
  --surface-subtle: #151f2b;
  --segmented-bg: #111b26;
  --disabled-bg: #23313d;
  --positive-bg: #183831;
  --negative-bg: #422a2a;
  --button-ink: #0d2624;
  --danger-dark: #d8735c;
  --focus-ring: rgba(101, 213, 197, 0.22);
  --accent-wash: rgba(101, 213, 197, 0.1);
  --accent-border: rgba(101, 213, 197, 0.34);
  --warning-border: rgba(255, 156, 130, 0.42);
  --shadow: rgba(0, 0, 0, 0.36);
  --grid-line: #334552;
  --glow-primary: rgba(101, 213, 197, 0.12);
  --glow-secondary: rgba(113, 103, 183, 0.11);
}

:root[data-theme="lavender"] {
  --bg: #f4f0fb;
  --panel: #fffaff;
  --ink: #2b2438;
  --muted: #756b83;
  --line: #ddd2ea;
  --accent: #8a6fbd;
  --accent-dark: #664e96;
  --soft: #f0e8fa;
  --surface: #fffaff;
  --surface-subtle: #faf6ff;
  --segmented-bg: #eee6f7;
  --disabled-bg: #f3edf8;
  --focus-ring: rgba(138, 111, 189, 0.18);
  --accent-wash: rgba(138, 111, 189, 0.09);
  --accent-border: rgba(138, 111, 189, 0.3);
  --shadow: rgba(75, 56, 104, 0.14);
  --grid-line: #e5dced;
  --glow-primary: rgba(177, 148, 221, 0.22);
  --glow-secondary: rgba(242, 171, 203, 0.16);
}

:root[data-theme="peach"] {
  --bg: #fff2ea;
  --panel: #fffaf6;
  --ink: #3b2925;
  --muted: #806d66;
  --line: #ead5ca;
  --accent: #c96f58;
  --accent-dark: #984c3c;
  --soft: #fbe7dc;
  --surface: #fffaf6;
  --surface-subtle: #fff6f0;
  --segmented-bg: #f8e5da;
  --disabled-bg: #f9ebe4;
  --focus-ring: rgba(201, 111, 88, 0.18);
  --accent-wash: rgba(201, 111, 88, 0.09);
  --accent-border: rgba(201, 111, 88, 0.3);
  --shadow: rgba(111, 70, 58, 0.14);
  --grid-line: #eadbd3;
  --glow-primary: rgba(239, 158, 128, 0.22);
  --glow-secondary: rgba(242, 196, 132, 0.17);
}

:root[data-theme="sage"] {
  --bg: #edf4ea;
  --panel: #fbfdf8;
  --ink: #263228;
  --muted: #687568;
  --line: #cfddcc;
  --accent: #668a65;
  --accent-dark: #496a49;
  --soft: #e4efe0;
  --surface: #fbfdf8;
  --surface-subtle: #f5f9f2;
  --segmented-bg: #e3eddf;
  --disabled-bg: #ebf2e8;
  --focus-ring: rgba(102, 138, 101, 0.18);
  --accent-wash: rgba(102, 138, 101, 0.09);
  --accent-border: rgba(102, 138, 101, 0.3);
  --shadow: rgba(58, 78, 57, 0.14);
  --grid-line: #d7e2d4;
  --glow-primary: rgba(139, 176, 132, 0.2);
  --glow-secondary: rgba(205, 181, 128, 0.14);
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  background:
    linear-gradient(135deg, var(--glow-primary), transparent 36%),
    linear-gradient(315deg, var(--glow-secondary), transparent 32%),
    var(--bg);
  color: var(--ink);
  transition:
    background-color 180ms ease,
    color 180ms ease;
}

.pull-refresh-indicator {
  display: none;
}

button,
input,
select {
  font: inherit;
}

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

.app-shell {
  align-items: center;
  display: flex;
  justify-content: center;
  min-height: 100vh;
  padding: 24px;
}

@media (hover: none) and (pointer: coarse) {
  .pull-refresh-indicator {
    align-items: center;
    background: var(--surface);
    border: 1px solid var(--line);
    border-radius: 999px;
    box-shadow: 0 8px 24px var(--shadow);
    color: var(--muted);
    display: flex;
    font-size: 0.78rem;
    font-weight: 800;
    gap: 7px;
    left: 50%;
    opacity: 0;
    padding: 7px 11px;
    pointer-events: none;
    position: fixed;
    top: max(8px, env(safe-area-inset-top));
    transform: translate(-50%, -60px);
    transition:
      opacity 120ms ease,
      transform 160ms ease;
    z-index: 100;
  }

  .app-shell {
    transition: transform 160ms ease;
  }

  body.is-pulling .app-shell {
    transform: translateY(var(--pull-distance));
    transition: none;
  }

  body.is-pulling .pull-refresh-indicator {
    opacity: 1;
    transform: translate(-50%, calc(var(--pull-distance) - 50px));
    transition: none;
  }

  body.is-pull-ready .pull-refresh-indicator,
  body.is-refreshing .pull-refresh-indicator {
    color: var(--accent-dark);
  }

  body.is-refreshing .pull-refresh-indicator {
    opacity: 1;
    transform: translate(-50%, 8px);
  }

  body.is-refreshing .pull-refresh-icon {
    animation: pull-refresh-spin 650ms linear infinite;
  }
}

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

.lookup-panel {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 8px;
  box-shadow: 0 24px 70px var(--shadow);
  max-width: 720px;
  padding: 32px;
  width: min(100%, 720px);
  transition:
    background-color 180ms ease,
    border-color 180ms ease,
    box-shadow 180ms ease;
}

.title-row {
  align-items: flex-start;
  display: flex;
  gap: 20px;
  justify-content: space-between;
}

.top-actions {
  align-items: center;
  display: flex;
  flex: 0 0 auto;
  gap: 10px;
}

h1 {
  font-size: clamp(2rem, 5vw, 3.6rem);
  line-height: 1;
  margin: 0;
  max-width: 560px;
}

.brand-title {
  max-width: min(100%, 620px);
}

.brand-logo {
  display: block;
  height: auto;
  max-height: 110px;
  object-fit: contain;
  object-position: left center;
  width: min(100%, 560px);
}

:root[data-theme="midnight"] .brand-logo {
  filter: invert(1) hue-rotate(180deg);
}

.settings-button {
  align-items: center;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 999px;
  color: var(--ink);
  display: inline-flex;
  height: 38px;
  justify-content: center;
  min-width: 38px;
  padding: 0;
  width: 38px;
}

.settings-button:hover {
  background: var(--soft);
  color: var(--accent-dark);
}

.settings-panel {
  background: var(--surface-subtle);
  border: 1px solid var(--line);
  border-radius: 8px;
  display: grid;
  gap: 16px;
  margin-top: 18px;
  padding: 18px;
}

.settings-panel[hidden] {
  display: none;
}

.settings-group {
  display: grid;
  gap: 10px;
}

.settings-group + .settings-group {
  border-top: 1px solid var(--line);
  padding-top: 16px;
}

.theme-picker {
  display: grid;
  gap: 8px;
  grid-template-columns: repeat(5, minmax(0, 1fr));
}

.theme-option {
  align-items: center;
  background: var(--surface);
  border: 1px solid var(--line);
  color: var(--muted);
  display: grid;
  gap: 8px;
  min-width: 0;
  padding: 10px 8px;
}

.theme-option:hover {
  background: var(--soft);
  color: var(--ink);
}

.theme-option[aria-pressed="true"] {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--focus-ring);
  color: var(--ink);
}

.theme-swatches {
  display: flex;
  justify-content: center;
}

.theme-swatches span {
  background: var(--swatch);
  border: 1px solid rgba(0, 0, 0, 0.12);
  border-radius: 999px;
  height: 18px;
  margin-left: -4px;
  width: 18px;
}

.theme-swatches span:first-child {
  margin-left: 0;
}

.settings-backup-group {
  padding-bottom: 0;
}

.settings-help {
  color: var(--muted);
  font-size: 0.9rem;
  line-height: 1.45;
  margin: 5px 0 0;
}

.settings-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
}

.settings-actions button {
  margin: 0;
  width: auto;
}

.backup-status {
  color: var(--accent-dark);
  font-size: 0.88rem;
  margin: 0;
  min-height: 1.25em;
}

.backup-status.is-error {
  color: var(--warning);
}

.setting-row {
  align-items: center;
  color: var(--ink);
  display: flex;
  gap: 10px;
  margin: 0;
}

.setting-row input {
  min-width: auto;
  width: 18px;
  height: 18px;
}

.network-setting {
  align-items: center;
  display: grid;
  gap: 10px;
  margin: 0;
}

.network-setting select {
  background: var(--soft);
  color: var(--accent-dark);
  font-weight: 800;
  width: fit-content;
}

.lookup-form {
  margin-top: 32px;
}

.app-tabs {
  background: var(--segmented-bg);
  border: 1px solid var(--line);
  border-radius: 8px;
  display: grid;
  gap: 4px;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  margin-top: 28px;
  padding: 4px;
}

.tab-button {
  background: transparent;
  color: var(--muted);
  min-width: 0;
  padding: 11px 14px;
}

.tab-button:hover,
.tab-button.is-active {
  background: var(--surface);
  color: var(--ink);
}

.tab-panel {
  margin-top: 0;
}

label {
  color: var(--muted);
  display: block;
  font-size: 0.95rem;
  font-weight: 700;
  margin-bottom: 10px;
}

.input-row {
  display: grid;
  gap: 12px;
  grid-template-columns: 1fr auto;
}

input {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 8px;
  color: var(--ink);
  min-width: 0;
  padding: 14px 15px;
}

input:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 4px var(--focus-ring);
  outline: none;
}

button {
  background: var(--accent);
  border: 0;
  border-radius: 8px;
  color: var(--button-ink);
  cursor: pointer;
  font-weight: 800;
  min-width: 104px;
  padding: 14px 18px;
}

button:hover {
  background: var(--accent-dark);
}

button:disabled {
  cursor: wait;
  opacity: 0.7;
}

.secondary-button,
.ghost-button,
.danger-button {
  background: var(--surface);
  border: 1px solid var(--line);
  color: var(--ink);
  min-width: auto;
  padding: 10px 12px;
}

.secondary-button:hover,
.ghost-button:hover {
  background: var(--soft);
  color: var(--accent-dark);
}

.ghost-button {
  color: var(--muted);
}

.danger-button {
  background: var(--warning);
  border-color: var(--warning);
  color: #ffffff;
}

.danger-button:hover {
  background: var(--danger-dark);
}

.privacy-note {
  color: var(--muted);
  font-size: 0.92rem;
  line-height: 1.5;
  margin: 14px 0 0;
}

.privacy-note strong {
  color: var(--ink);
}

.result-card,
.price-card,
.saved-card,
.portfolio-card,
.calculator-card,
.profit-card {
  background: var(--surface-subtle);
  border: 1px solid var(--line);
  border-radius: 8px;
  margin-top: 28px;
  padding: 24px;
}

.price-card {
  margin-top: 16px;
}

.saved-card {
  margin-top: 16px;
}

.portfolio-card {
  margin-top: 28px;
}

.calculator-card,
.profit-card {
  display: grid;
  gap: 22px;
}

.portfolio-create-card {
  margin-top: 16px;
  padding: 14px;
}

.add-portfolio-toggle {
  align-items: center;
  background: transparent;
  border: 0;
  color: var(--ink);
  display: flex;
  justify-content: space-between;
  min-width: 0;
  padding: 4px;
  text-align: left;
  width: 100%;
}

.add-portfolio-toggle:hover {
  background: var(--surface);
}

.add-portfolio-toggle span:first-child {
  font-size: 1.05rem;
  font-weight: 850;
}

#portfolio-form-caret {
  color: var(--accent-dark);
  font-size: 1.3rem;
  font-weight: 900;
}

.result-card.is-error,
.price-card.is-error {
  border-color: var(--warning-border);
}

.result-label {
  color: var(--muted);
  font-size: 0.88rem;
  font-weight: 800;
  margin: 0 0 8px;
  text-transform: uppercase;
}

.balance-value {
  font-size: clamp(1.7rem, 5vw, 3.2rem);
  font-weight: 850;
  line-height: 1.05;
  margin: 0;
  overflow-wrap: anywhere;
}

.result-card.is-error .balance-value {
  color: var(--warning);
  font-size: clamp(1.25rem, 4vw, 1.8rem);
}

.usd-value {
  color: var(--accent-dark);
  font-size: clamp(1.15rem, 4vw, 1.7rem);
  font-weight: 800;
  margin: 10px 0 0;
}

.result-wallet-name {
  font-size: 1.05rem;
  font-weight: 850;
  margin: 12px 0 0;
}

.address-value {
  color: var(--muted);
  font-family: "SFMono-Regular", Consolas, "Liberation Mono", monospace;
  font-size: 0.9rem;
  margin: 12px 0 0;
  overflow-wrap: anywhere;
}

.save-wallet-form {
  border-top: 1px solid var(--line);
  margin-top: 18px;
  padding-top: 18px;
}

.price-value {
  font-size: clamp(1.25rem, 4vw, 2rem);
  font-weight: 850;
  line-height: 1.05;
  margin: 0;
}

.price-stat-grid {
  display: grid;
  gap: 10px;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  margin-top: 16px;
}

.price-stat-grid[hidden] {
  display: none;
}

.price-stat-card {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 8px;
  display: grid;
  gap: 5px;
  padding: 12px;
}

.price-stat-card span {
  color: var(--muted);
  font-size: 0.72rem;
  font-weight: 850;
  text-transform: uppercase;
}

.price-stat-card strong {
  color: var(--ink);
  font-size: 1rem;
  overflow-wrap: anywhere;
}

.price-stat-card.is-up {
  background: var(--positive-bg);
  border-color: var(--accent-border);
}

.price-stat-card.is-up strong {
  color: var(--accent-dark);
}

.price-stat-card.is-down {
  background: var(--negative-bg);
  border-color: var(--warning-border);
}

.price-stat-card.is-down strong {
  color: var(--warning);
}

.price-source {
  color: var(--muted);
  font-size: 0.9rem;
  margin: 10px 0 0;
}

.saved-header {
  align-items: flex-start;
  display: flex;
  gap: 16px;
  justify-content: space-between;
}

.saved-summary-button {
  background: transparent;
  border: 0;
  color: var(--ink);
  cursor: pointer;
  min-width: 0;
  padding: 8px;
  text-align: left;
  width: 100%;
}

.saved-summary-button:hover {
  background: var(--soft);
}

.saved-tools {
  align-items: end;
  display: flex;
  gap: 10px;
  justify-content: flex-end;
}

.saved-card-body {
  margin-top: 18px;
}

.saved-card-body[hidden] {
  display: none;
}

.sort-label {
  color: var(--muted);
  font-size: 0.8rem;
  margin: 0;
}

.sort-select {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 8px;
  color: var(--ink);
  min-height: 43px;
  padding: 9px 10px;
}

h2 {
  font-size: 1.35rem;
  margin: 0;
}

h3 {
  font-size: 1.15rem;
  margin: 0;
}

.saved-addresses {
  margin-top: 18px;
}

.empty-state,
.saved-status {
  color: var(--muted);
  margin: 0;
}

.saved-status {
  margin-bottom: 12px;
}

.saved-list {
  display: grid;
  gap: 12px;
}

.saved-wallet {
  align-items: center;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 8px;
  display: grid;
  gap: 16px;
  grid-template-columns: 1fr auto;
  padding: 16px;
}

.saved-wallet-main {
  display: grid;
  gap: 5px;
  min-width: 0;
}

.wallet-name {
  font-size: 1rem;
  font-weight: 850;
  margin: 0;
}

.wallet-name-row {
  align-items: center;
  display: flex;
  gap: 8px;
}

.edit-name-button {
  background: transparent;
  border: 0;
  color: var(--accent-dark);
  font-size: 0.85rem;
  font-weight: 800;
  min-width: auto;
  opacity: 0;
  padding: 4px 6px;
}

.wallet-name-row:hover .edit-name-button,
.edit-name-button:focus {
  opacity: 1;
}

.edit-name-button:hover {
  background: var(--soft);
}

.edit-name-form {
  display: grid;
  gap: 8px;
  grid-template-columns: 1fr auto auto;
}

.edit-name-form input {
  padding: 10px 12px;
}

.saved-wallet-main strong {
  font-size: 1.18rem;
}

.saved-wallet-main span {
  color: var(--accent-dark);
  font-weight: 800;
}

.saved-wallet-main code {
  color: var(--muted);
  font-family: "SFMono-Regular", Consolas, "Liberation Mono", monospace;
  font-size: 0.85rem;
  overflow-wrap: anywhere;
}

.saved-wallet-main small {
  color: var(--muted);
}

.saved-wallet-actions {
  display: flex;
  gap: 8px;
}

.remove-confirmation {
  align-items: center;
  display: flex;
  gap: 8px;
}

.remove-confirmation span {
  color: var(--warning);
  font-weight: 850;
}

.portfolio-form {
  border-top: 1px solid var(--line);
  margin-top: 14px;
  padding-top: 14px;
}

.portfolio-list {
  display: grid;
  gap: 14px;
  margin-top: 18px;
}

.portfolio-item {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 8px;
  display: grid;
  gap: 12px;
  padding: 12px;
  transition:
    border-color 140ms ease,
    box-shadow 140ms ease,
    transform 140ms ease,
    opacity 140ms ease;
}

.portfolio-item.is-rail-dragging {
  opacity: 0.92;
  pointer-events: none;
  position: fixed;
  z-index: 20;
}

.portfolio-card-top {
  align-items: center;
  display: grid;
  gap: 8px;
  grid-template-columns: auto 1fr;
}

.drag-handle {
  align-items: center;
  background: transparent;
  border: 0;
  border-radius: 6px;
  cursor: grab;
  display: grid;
  gap: 3px;
  justify-content: center;
  min-width: 34px;
  padding: 8px 7px;
  touch-action: none;
  user-select: none;
}

.drag-handle:hover {
  background: var(--soft);
}

.drag-handle:active {
  cursor: grabbing;
}

.drag-handle span {
  background: var(--muted);
  border-radius: 999px;
  display: block;
  height: 2px;
  width: 17px;
}

.portfolio-placeholder {
  background: var(--accent-wash);
  border: 1px dashed var(--accent-border);
  border-radius: 8px;
}

.portfolio-summary {
  align-items: start;
  display: grid;
  gap: 16px;
  grid-template-columns: 1fr auto;
}

.portfolio-summary-button {
  background: transparent;
  border: 0;
  color: var(--ink);
  cursor: pointer;
  min-width: 0;
  padding: 4px;
  text-align: left;
  width: 100%;
}

.portfolio-summary-button:hover {
  background: var(--soft);
}

.portfolio-summary p {
  color: var(--muted);
  margin: 5px 0 0;
}

.portfolio-total {
  display: grid;
  gap: 4px;
  justify-items: end;
}

.portfolio-total strong {
  font-size: 1.35rem;
}

.portfolio-total span {
  color: var(--accent-dark);
  font-weight: 850;
}

.portfolio-wallet-picker {
  border-top: 1px solid var(--line);
  display: grid;
  gap: 10px;
  padding-top: 14px;
}

.portfolio-wallet-picker[hidden] {
  display: none;
}

.portfolio-actions {
  display: flex;
  gap: 8px;
}

.portfolio-wallet-chip {
  align-items: center;
  background: var(--surface-subtle);
  border: 1px solid var(--line);
  border-radius: 8px;
  display: flex;
  gap: 10px;
  justify-content: space-between;
  padding: 12px;
}

.portfolio-wallet-chip span {
  color: var(--accent-dark);
  font-weight: 800;
}

.portfolio-wallet-choice {
  align-items: center;
  background: var(--surface-subtle);
  border: 1px solid var(--line);
  border-radius: 8px;
  color: var(--ink);
  display: grid;
  gap: 10px;
  grid-template-columns: auto 1fr;
  margin: 0;
  padding: 12px;
}

.portfolio-wallet-choice input {
  min-width: auto;
  width: 18px;
  height: 18px;
}

.portfolio-wallet-choice span {
  display: grid;
  gap: 4px;
  min-width: 0;
}

.portfolio-wallet-choice code {
  color: var(--muted);
  font-family: "SFMono-Regular", Consolas, "Liberation Mono", monospace;
  font-size: 0.82rem;
  overflow-wrap: anywhere;
}

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

.profit-top,
.profit-summary-grid {
  display: grid;
  gap: 14px;
  grid-template-columns: repeat(2, minmax(0, 1fr));
}

.calculator-control {
  min-width: 0;
}

.calculator-source-toggle {
  background: var(--segmented-bg);
  border: 1px solid var(--line);
  border-radius: 8px;
  display: grid;
  gap: 4px;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  padding: 4px;
}

.source-toggle-button {
  background: transparent;
  color: var(--muted);
  min-width: 0;
  padding: 10px 8px;
}

.source-toggle-button:hover,
.source-toggle-button.is-active {
  background: var(--surface);
  color: var(--ink);
}

.source-detail-select {
  margin-top: 10px;
}

.calculator-control select,
.calculator-control input,
.price-input-row input {
  width: 100%;
}

.calculator-control input:disabled {
  background: var(--disabled-bg);
  color: var(--ink);
  opacity: 1;
}

.calculator-price-row {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 8px;
  display: grid;
  gap: 12px;
  padding: 18px;
}

.price-input-row {
  align-items: center;
  display: grid;
  gap: 10px;
  grid-template-columns: auto 1fr;
}

.price-input-row span {
  color: var(--accent-dark);
  font-size: 1.35rem;
  font-weight: 850;
}

.price-slider {
  accent-color: var(--accent);
  min-height: 32px;
  padding: 0;
  width: 100%;
}

.price-slider::-webkit-slider-runnable-track {
  min-height: 8px;
}

.price-slider::-webkit-slider-thumb {
  min-height: 22px;
  min-width: 22px;
}

.price-slider::-moz-range-track {
  min-height: 8px;
}

.price-slider::-moz-range-thumb {
  min-height: 22px;
  min-width: 22px;
}

.calculator-output {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 8px;
  display: grid;
  padding: 22px;
}

.calculator-value {
  font-size: clamp(2.4rem, 7vw, 5rem);
  font-weight: 900;
  line-height: 1;
  margin: 0;
  overflow-wrap: anywhere;
  white-space: normal;
}

.calculator-context {
  color: var(--muted);
  font-size: 1rem;
  margin: 12px 0 0;
}

.profit-steps-list {
  display: grid;
  gap: 12px;
}

.profit-add-target {
  justify-self: start;
}

.profit-step {
  align-items: center;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 8px;
  display: grid;
  gap: 12px;
  grid-template-columns: auto minmax(110px, 1fr) auto auto minmax(110px, 1fr) auto;
  padding: 14px;
}

.profit-step-field {
  margin: 0;
  position: relative;
}

.profit-step input {
  width: 100%;
}

.profit-step-word {
  color: var(--muted);
  font-weight: 850;
  white-space: nowrap;
}

.profit-step-unit {
  color: var(--ink);
  font-weight: 900;
  white-space: nowrap;
}

.profit-step-quick-fill {
  align-items: center;
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  grid-column: 1 / -1;
}

.profit-step-quick-fill > span {
  color: var(--muted);
  font-size: 0.82rem;
  font-weight: 800;
  margin-right: 2px;
}

.profit-percent-button {
  min-height: 36px;
  padding: 7px 12px;
}

.profit-step-price-field input {
  padding-left: 34px;
}

.profit-step-dollar {
  color: var(--accent-dark);
  font-weight: 900;
  left: 14px;
  position: absolute;
  top: 50%;
  transform: translateY(-50%);
}

.profit-step-remove {
  padding: 12px 14px;
}

.profit-step-context {
  color: var(--muted);
  font-size: 0.9rem;
  font-weight: 800;
  grid-column: 1 / -1;
  margin: 0 0 -2px;
}

.profit-step-status {
  color: var(--muted);
  font-size: 0.9rem;
  font-weight: 700;
  grid-column: 1 / -1;
  margin: -2px 0 0;
}

.profit-step-status.is-adjusted {
  color: var(--accent-dark);
}

.profit-step-results {
  border-top: 1px solid var(--line);
  display: grid;
  gap: 8px;
  grid-column: 1 / -1;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  padding-top: 12px;
}

.profit-step-results[hidden],
.profit-step-status[hidden] {
  display: none;
}

.profit-result-chip {
  background: var(--surface-subtle);
  border: 1px solid var(--line);
  border-radius: 8px;
  display: grid;
  gap: 3px;
  padding: 10px;
}

.profit-result-chip small {
  color: var(--muted);
  font-size: 0.74rem;
  font-weight: 800;
  text-transform: uppercase;
}

.profit-result-chip strong {
  color: var(--ink);
  font-size: 0.98rem;
  overflow-wrap: anywhere;
}

.profit-big-value {
  font-size: clamp(1.7rem, 4.5vw, 2.65rem);
  font-weight: 900;
  line-height: 1;
  margin: 0;
  overflow-wrap: anywhere;
}

.profit-chart-card {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 14px;
}

.profit-chart {
  display: block;
  height: auto;
  width: 100%;
}

.profit-chart-grid {
  stroke: var(--grid-line);
  stroke-width: 1;
}

.profit-chart-line {
  fill: none;
  stroke: var(--accent);
  stroke-linecap: round;
  stroke-linejoin: round;
  stroke-width: 4;
}

.profit-chart-point {
  fill: var(--accent-dark);
}

.profit-chart-label {
  fill: var(--muted);
  font-size: 13px;
  font-weight: 700;
}

@media (max-width: 620px) {
  .app-shell {
    align-items: stretch;
    padding: 12px;
  }

  .lookup-panel {
    padding: 22px;
  }

  .input-row,
  .calculator-top,
  .profit-top,
  .profit-summary-grid,
  .profit-step {
    grid-template-columns: 1fr;
  }

  .profit-step-word {
    margin-top: 4px;
  }

  .profit-step-results {
    grid-template-columns: 1fr;
  }

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

  .title-row {
    align-items: center;
    display: flex;
    gap: 14px;
  }

  .title-row > div:first-child {
    flex: 1 1 auto;
    min-width: 0;
  }

  .app-tabs {
    grid-template-columns: repeat(2, minmax(0, 1fr));
    margin-top: 22px;
  }

  .tab-button {
    padding: 11px 8px;
  }

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

  .top-actions {
    align-items: center;
  }

  button {
    width: 100%;
  }

  .saved-header,
  .saved-tools,
  .saved-wallet,
  .saved-wallet-actions,
  .remove-confirmation,
  .edit-name-form,
  .portfolio-card-top,
  .portfolio-summary,
  .portfolio-actions {
    grid-template-columns: 1fr;
  }

  .saved-header,
  .saved-tools,
  .saved-wallet-actions,
  .remove-confirmation {
    display: grid;
  }

  .edit-name-button {
    opacity: 1;
  }

  .portfolio-total {
    justify-items: start;
  }

  .portfolio-actions,
  .portfolio-wallet-chip {
    display: grid;
  }
}

@media (max-width: 480px) and (orientation: portrait) {
  .app-shell {
    padding: 8px;
  }

  .lookup-panel {
    padding: 18px;
  }

  .app-tabs {
    margin-top: 18px;
  }

  .portfolio-card {
    margin-top: 20px;
    padding: 18px;
  }

  .portfolio-list {
    gap: 10px;
    margin-top: 14px;
  }

  .portfolio-item {
    gap: 10px;
    padding: 10px;
    position: relative;
  }

  .portfolio-card-top {
    display: block;
  }

  .drag-handle {
    height: 34px;
    min-width: 40px;
    padding: 7px 10px;
    position: absolute;
    right: 10px;
    top: 10px;
    width: 40px;
  }

  .portfolio-summary {
    align-content: center;
    gap: 10px;
  }

  .portfolio-summary-button {
    padding: 8px;
  }

  .portfolio-summary > div:first-child {
    padding-right: 46px;
  }

  .portfolio-total strong {
    font-size: clamp(1.12rem, 5.7vw, 1.35rem);
    overflow-wrap: anywhere;
  }

  .wallet-name-row {
    display: grid;
    grid-template-columns: minmax(0, 1fr) auto;
    width: 100%;
  }

  .edit-name-button {
    justify-self: end;
    width: auto;
  }

  .saved-wallet-main code {
    font-size: clamp(0.68rem, 2.9vw, 0.78rem);
    letter-spacing: -0.03em;
    overflow-x: auto;
    overflow-wrap: normal;
    scrollbar-width: none;
    white-space: nowrap;
  }

  .saved-wallet-main code::-webkit-scrollbar {
    display: none;
  }
}

@media (prefers-reduced-motion: reduce) {
  body,
  .lookup-panel,
  .app-shell,
  .pull-refresh-indicator {
    transition: none;
  }

  body.is-refreshing .pull-refresh-icon {
    animation: none;
  }
}
