:root {
  color-scheme: dark;
  --bg: #07111d;
  --bg-deep: #030914;
  --surface: #0d1b2b;
  --surface-2: #12263a;
  --surface-3: #172f46;
  --line: #28445f;
  --line-soft: #1b334a;
  --text: #f4f8fc;
  --muted: #9db1c7;
  --cyan: #63d7e8;
  --green: #64e4a9;
  --yellow: #f5c45b;
  --coral: #ff7c6b;
  --blue: #74a7ff;
  --pink: #ef7fb2;
  --nav-height: 68px;
  --action-height: 64px;
  --header-height: 60px;
  font-family: Inter, "Segoe UI", Arial, sans-serif;
  font-size: 16px;
  line-height: 1.45;
}

* {
  box-sizing: border-box;
}

html {
  min-height: 100%;
  background: var(--bg-deep);
}

body {
  min-width: 320px;
  min-height: 100%;
  margin: 0;
  overflow-x: hidden;
  background: var(--bg-deep);
  color: var(--text);
  letter-spacing: 0;
}

button,
input,
select {
  font: inherit;
  letter-spacing: 0;
}

button,
select {
  cursor: pointer;
}

button {
  border: 0;
}

button:focus-visible,
input:focus-visible,
select:focus-visible,
a:focus-visible {
  outline: 3px solid rgba(99, 215, 232, 0.48);
  outline-offset: 2px;
}

[hidden] {
  display: none !important;
}

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

.preview-app {
  width: 100%;
  min-height: 100vh;
  min-height: 100dvh;
  margin: 0 auto;
  background: var(--bg);
}

.app-header {
  position: sticky;
  z-index: 40;
  top: 0;
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto auto;
  align-items: center;
  gap: 10px;
  min-height: var(--header-height);
  padding: 8px 14px;
  border-bottom: 1px solid var(--line-soft);
  background: rgba(7, 17, 29, 0.97);
  backdrop-filter: blur(14px);
}

.app-brand {
  display: flex;
  min-width: 0;
  align-items: center;
  gap: 9px;
  color: var(--text);
  text-decoration: none;
}

.app-brand img {
  width: 36px;
  height: 36px;
  flex: 0 0 36px;
  object-fit: contain;
}

.app-brand span {
  display: flex;
  min-width: 0;
  flex-direction: column;
  line-height: 1.12;
}

.app-brand strong {
  overflow: hidden;
  font-size: 0.98rem;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.app-brand small {
  margin-top: 3px;
  color: var(--muted);
  font-size: 0.72rem;
  font-weight: 700;
}

.preview-badge {
  padding: 4px 8px;
  border: 1px solid rgba(245, 196, 91, 0.45);
  border-radius: 999px;
  background: rgba(245, 196, 91, 0.12);
  color: #ffe39c;
  font-size: 0.68rem;
  font-weight: 900;
  text-transform: uppercase;
}

.icon-button {
  display: inline-grid;
  width: 42px;
  height: 42px;
  flex: 0 0 42px;
  place-items: center;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
  color: var(--text);
}

.icon-button svg {
  width: 20px;
  height: 20px;
}

.icon-button:active {
  background: var(--surface-3);
}

.safety-strip {
  display: grid;
  grid-template-columns: auto minmax(0, 1fr) auto;
  align-items: center;
  gap: 8px;
  min-height: 38px;
  padding: 6px 14px;
  border-bottom: 1px solid rgba(255, 124, 107, 0.34);
  background: #341819;
  color: #ffd4cd;
  font-size: 0.75rem;
  font-weight: 750;
}

.safety-strip svg {
  width: 16px;
  height: 16px;
  color: var(--coral);
}

.safety-strip span {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.safety-strip button {
  padding: 4px 0;
  background: transparent;
  color: #ffd977;
  font-size: 0.74rem;
  font-weight: 900;
}

.app-main {
  width: 100%;
  max-width: 760px;
  margin: 0 auto;
  padding: 0 14px calc(var(--nav-height) + 24px + env(safe-area-inset-bottom));
}

.app-screen {
  display: none;
  min-height: calc(100dvh - var(--header-height) - 38px - var(--nav-height));
  padding: 18px 0 28px;
}

.app-screen.is-active {
  display: block;
  animation: screen-in 160ms ease-out;
}

@keyframes screen-in {
  from {
    opacity: 0;
    transform: translateY(4px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

.screen-heading {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  align-items: start;
  gap: 14px;
  margin-bottom: 16px;
}

.screen-heading.compact {
  align-items: center;
}

.screen-heading h1 {
  margin: 2px 0 3px;
  font-size: 1.62rem;
  line-height: 1.15;
}

.screen-heading p:not(.step-label) {
  margin: 0;
  color: var(--muted);
  font-size: 0.9rem;
}

.step-label,
.eyebrow {
  margin: 0;
  color: var(--cyan);
  font-size: 0.68rem;
  font-weight: 900;
  text-transform: uppercase;
}

.selected-count-button {
  display: grid;
  min-width: 62px;
  min-height: 58px;
  place-content: center;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
  color: var(--text);
  text-align: center;
}

.selected-count-button span {
  font-size: 1.24rem;
  font-weight: 900;
  line-height: 1;
}

.selected-count-button small {
  margin-top: 4px;
  color: var(--muted);
  font-size: 0.64rem;
  font-weight: 800;
}

.filter-surface,
.plot-surface,
.quick-read,
.ranking-control,
.ranking-card {
  border: 1px solid var(--line-soft);
  border-radius: 8px;
  background: var(--surface);
}

.filter-surface {
  padding: 12px;
}

.search-control {
  position: relative;
  display: grid;
  grid-template-columns: auto minmax(0, 1fr) auto;
  align-items: center;
  gap: 8px;
  height: 48px;
  padding: 0 10px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: #071321;
}

.search-control > svg {
  width: 19px;
  height: 19px;
  color: var(--muted);
}

.search-control input {
  width: 100%;
  min-width: 0;
  border: 0;
  outline: 0;
  background: transparent;
  color: var(--text);
  font-size: 0.95rem;
}

.search-control input::placeholder {
  color: #71879d;
}

.search-clear {
  display: grid;
  width: 30px;
  height: 30px;
  place-items: center;
  border-radius: 6px;
  background: var(--surface-2);
  color: var(--muted);
}

.search-clear svg {
  width: 16px;
  height: 16px;
}

.format-switch,
.two-way-switch {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 4px;
  margin-top: 10px;
  padding: 4px;
  border: 1px solid var(--line-soft);
  border-radius: 8px;
  background: #071321;
}

.format-switch button,
.two-way-switch button {
  min-height: 38px;
  border-radius: 5px;
  background: transparent;
  color: var(--muted);
  font-size: 0.82rem;
  font-weight: 850;
}

.format-switch button.is-active,
.two-way-switch button.is-active {
  background: var(--cyan);
  color: #06131d;
}

.filter-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
  gap: 10px;
  margin-top: 10px;
}

.filter-row label,
.sheet-select,
.ranking-control {
  display: flex;
  min-width: 0;
  flex-direction: column;
  gap: 5px;
}

.filter-row label > span,
.sheet-select > span,
.ranking-control > span {
  color: var(--muted);
  font-size: 0.7rem;
  font-weight: 900;
  text-transform: uppercase;
}

.filter-row select,
.sheet-select select,
.ranking-control select {
  width: 100%;
  min-width: 0;
  height: 44px;
  padding: 0 34px 0 10px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: #071321;
  color: var(--text);
  font-size: 0.86rem;
  font-weight: 800;
}

.list-toolbar,
.section-row,
.plot-context,
.plot-foot {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
}

.list-toolbar {
  min-height: 48px;
  padding: 8px 2px 4px;
}

.list-toolbar strong {
  font-size: 0.84rem;
}

.text-button {
  padding: 7px 2px;
  background: transparent;
  color: var(--cyan);
  font-size: 0.78rem;
  font-weight: 850;
}

.cell-list {
  display: grid;
  gap: 8px;
}

.cell-card {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 12px;
  min-height: 92px;
  padding: 12px;
  border: 1px solid var(--line-soft);
  border-radius: 8px;
  background: var(--surface);
}

.cell-card.is-selected {
  border-color: rgba(100, 228, 169, 0.7);
  box-shadow: inset 3px 0 0 var(--green);
}

.cell-main {
  min-width: 0;
}

.cell-title {
  display: flex;
  min-width: 0;
  align-items: center;
  gap: 7px;
}

.cell-title h2 {
  overflow: hidden;
  margin: 0;
  font-size: 1rem;
  line-height: 1.25;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.format-tag,
.current-tag,
.context-badge,
.rank-position,
.status-tag {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border-radius: 999px;
  font-weight: 900;
  white-space: nowrap;
}

.format-tag {
  padding: 3px 6px;
  border: 1px solid rgba(116, 167, 255, 0.35);
  background: rgba(116, 167, 255, 0.12);
  color: #bcd3ff;
  font-size: 0.62rem;
}

.cell-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 5px 10px;
  margin-top: 7px;
  color: var(--muted);
  font-size: 0.74rem;
}

.cell-meta span {
  display: inline-flex;
  align-items: center;
  gap: 4px;
}

.cell-meta svg {
  width: 13px;
  height: 13px;
}

.cell-current-preview {
  overflow: hidden;
  margin-top: 8px;
  color: #bdd0e3;
  font-size: 0.72rem;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.cell-action {
  display: flex;
  min-width: 70px;
  flex-direction: column;
  align-items: flex-end;
  justify-content: center;
  gap: 6px;
}

.cell-action button {
  display: inline-flex;
  min-width: 70px;
  min-height: 40px;
  align-items: center;
  justify-content: center;
  gap: 5px;
  border: 1px solid rgba(99, 215, 232, 0.45);
  border-radius: 6px;
  background: rgba(99, 215, 232, 0.12);
  color: var(--cyan);
  font-size: 0.78rem;
  font-weight: 900;
}

.cell-action button.is-added {
  border-color: rgba(100, 228, 169, 0.55);
  background: rgba(100, 228, 169, 0.15);
  color: var(--green);
}

.cell-action button svg {
  width: 16px;
  height: 16px;
}

.cell-action small {
  max-width: 76px;
  color: var(--muted);
  font-size: 0.62rem;
  font-weight: 750;
  text-align: right;
}

.empty-state,
.error-state {
  padding: 32px 18px;
  border: 1px dashed var(--line);
  border-radius: 8px;
  color: var(--muted);
  text-align: center;
}

.empty-state svg,
.error-state svg {
  width: 30px;
  height: 30px;
  margin-bottom: 8px;
  color: var(--cyan);
}

.empty-state strong,
.error-state strong {
  display: block;
  margin-bottom: 5px;
  color: var(--text);
}

.loading-list {
  display: grid;
  gap: 8px;
}

.loading-list span {
  height: 92px;
  border: 1px solid var(--line-soft);
  border-radius: 8px;
  background: linear-gradient(90deg, var(--surface) 20%, var(--surface-2) 50%, var(--surface) 80%);
  background-size: 200% 100%;
  animation: loading-shimmer 1.3s linear infinite;
}

@keyframes loading-shimmer {
  from {
    background-position: 100% 0;
  }
  to {
    background-position: -100% 0;
  }
}

.selected-chip-row {
  display: flex;
  gap: 7px;
  margin: -2px -14px 12px;
  padding: 2px 14px 6px;
  overflow-x: auto;
  overscroll-behavior-inline: contain;
  scrollbar-width: none;
}

.selected-chip-row::-webkit-scrollbar {
  display: none;
}

.selected-chip {
  display: inline-flex;
  min-width: max-content;
  min-height: 34px;
  align-items: center;
  gap: 7px;
  padding: 6px 9px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: var(--surface);
  color: var(--text);
  font-size: 0.73rem;
  font-weight: 800;
}

.selected-chip i,
.legend-swatch {
  width: 9px;
  height: 9px;
  flex: 0 0 9px;
  border-radius: 50%;
}

.selected-chip button {
  display: grid;
  width: 22px;
  height: 22px;
  place-items: center;
  border-radius: 50%;
  background: var(--surface-3);
  color: var(--muted);
}

.selected-chip button svg {
  width: 13px;
  height: 13px;
}

.metric-switch {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 4px;
  margin-bottom: 10px;
  padding: 4px;
  border: 1px solid var(--line-soft);
  border-radius: 8px;
  background: var(--surface);
}

.metric-switch button {
  display: flex;
  min-width: 0;
  min-height: 54px;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 4px;
  border-radius: 5px;
  background: transparent;
  color: var(--muted);
  font-size: 0.68rem;
  font-weight: 850;
}

.metric-switch button svg {
  width: 18px;
  height: 18px;
}

.metric-switch button.is-active {
  background: var(--surface-3);
  color: var(--cyan);
  box-shadow: inset 0 -2px 0 var(--cyan);
}

.surface-button {
  background: var(--surface-2);
}

.plot-heading-actions {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 8px;
}

.results-heading-actions {
  display: flex;
  align-items: center;
  justify-content: flex-end;
}

.simple-screenshot-option {
  display: inline-flex;
  min-height: 42px;
  align-items: center;
  gap: 7px;
  padding: 0 11px;
  border: 1px solid rgba(99, 215, 232, 0.38);
  border-radius: 6px;
  background: rgba(99, 215, 232, 0.08);
  color: var(--text);
  font-size: 0.72rem;
  font-weight: 800;
  white-space: nowrap;
}

.simple-screenshot-option input {
  width: 17px;
  height: 17px;
  margin: 0;
  accent-color: var(--cyan);
}

.simple-screenshot-button {
  display: inline-flex;
  min-height: 42px;
  align-items: center;
  justify-content: center;
  gap: 7px;
  padding: 0 13px;
  border: 1px solid rgba(99, 215, 232, 0.72);
  border-radius: 6px;
  background: linear-gradient(90deg, #67d8e8, #7ce5b2);
  color: #04101d;
  font-size: 0.74rem;
  font-weight: 900;
  white-space: nowrap;
  cursor: pointer;
}

.simple-screenshot-button:hover {
  filter: brightness(1.06);
}

.simple-screenshot-button:disabled {
  cursor: wait;
  opacity: 0.65;
}

.simple-screenshot-button svg {
  width: 17px;
  height: 17px;
}

.plot-surface {
  overflow: hidden;
}

.plot-context {
  min-height: 46px;
  padding: 9px 11px 5px;
}

.plot-context > div {
  display: flex;
  min-width: 0;
  align-items: baseline;
  gap: 5px;
}

.plot-context strong {
  font-size: 0.88rem;
}

.plot-context span:not(.context-badge) {
  color: var(--muted);
  font-size: 0.72rem;
}

.context-badge {
  padding: 4px 7px;
  background: rgba(245, 196, 91, 0.14);
  color: #ffe197;
  font-size: 0.62rem;
}

.mobile-chart {
  width: 100%;
  height: 340px;
  min-height: 340px;
}

.plot-foot {
  min-height: 42px;
  padding: 5px 11px 8px;
  border-top: 1px solid var(--line-soft);
}

.plot-foot span {
  overflow: hidden;
  color: var(--muted);
  font-size: 0.7rem;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.quick-read {
  margin-top: 12px;
  padding: 12px;
}

.quick-read h2 {
  margin: 2px 0 0;
  font-size: 1.05rem;
}

.quick-read-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 8px;
  margin-top: 10px;
}

.quick-card {
  min-width: 0;
  min-height: 84px;
  padding: 10px;
  border: 1px solid var(--line-soft);
  border-radius: 6px;
  background: #071321;
}

.quick-card span {
  display: block;
  color: var(--muted);
  font-size: 0.65rem;
  font-weight: 850;
  text-transform: uppercase;
}

.quick-card strong {
  display: block;
  overflow: hidden;
  margin-top: 6px;
  color: var(--text);
  font-size: 1.02rem;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.quick-card small {
  display: block;
  overflow: hidden;
  margin-top: 3px;
  color: var(--cyan);
  font-size: 0.68rem;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.ranking-control {
  margin-bottom: 12px;
  padding: 11px;
}

.ranking-control select {
  height: 48px;
  font-size: 0.94rem;
}

.ranking-notice {
  margin-bottom: 10px;
  padding: 10px 11px;
  border-left: 3px solid var(--yellow);
  border-radius: 4px;
  background: rgba(245, 196, 91, 0.1);
  color: #ffe4a3;
  font-size: 0.76rem;
}

.ranking-cards {
  display: grid;
  gap: 8px;
}

.ranking-card {
  display: grid;
  grid-template-columns: auto 72px minmax(0, 1fr);
  align-items: start;
  gap: 11px;
  padding: 12px;
}

.rank-position {
  width: 34px;
  height: 34px;
  background: var(--surface-3);
  color: var(--cyan);
  font-size: 0.9rem;
}

.ranking-card:first-child .rank-position {
  background: var(--yellow);
  color: #211803;
}

.ranking-card-photo {
  display: grid;
  width: 72px;
  height: 82px;
  overflow: hidden;
  place-items: center;
  border: 1px solid rgba(99, 215, 232, 0.32);
  border-radius: 6px;
  background: #f3f7fb;
}

.ranking-card-photo img {
  width: 100%;
  height: 100%;
  object-fit: contain;
}

.ranking-card-photo.is-missing {
  background: #071321;
}

.ranking-photo-placeholder {
  display: grid;
  width: 100%;
  height: 100%;
  place-items: center;
  color: var(--muted);
}

.ranking-photo-placeholder svg {
  width: 28px;
  height: 28px;
}

.ranking-card-main {
  min-width: 0;
}

.ranking-card-title {
  display: flex;
  min-width: 0;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
}

.ranking-card-title h2 {
  overflow: hidden;
  margin: 0;
  font-size: 0.98rem;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.current-tag {
  padding: 4px 7px;
  background: rgba(116, 167, 255, 0.12);
  color: #bed3ff;
  font-size: 0.65rem;
}

.rank-metric-value {
  display: flex;
  align-items: baseline;
  gap: 6px;
  margin-top: 7px;
}

.rank-metric-value strong {
  font-size: 1.35rem;
  line-height: 1;
}

.rank-metric-value span {
  color: var(--muted);
  font-size: 0.68rem;
}

.rank-details {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 6px;
  margin-top: 10px;
}

.rank-detail {
  min-width: 0;
  padding: 7px;
  border: 1px solid var(--line-soft);
  border-radius: 5px;
  background: #071321;
}

.rank-detail span {
  display: block;
  overflow: hidden;
  color: var(--muted);
  font-size: 0.58rem;
  font-weight: 800;
  text-overflow: ellipsis;
  text-transform: uppercase;
  white-space: nowrap;
}

.rank-detail strong {
  display: block;
  overflow: hidden;
  margin-top: 3px;
  font-size: 0.76rem;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.status-tag {
  margin-top: 9px;
  padding: 4px 7px;
  background: rgba(100, 228, 169, 0.12);
  color: var(--green);
  font-size: 0.62rem;
}

.status-tag.warn {
  background: rgba(245, 196, 91, 0.12);
  color: var(--yellow);
}

.selection-action {
  position: fixed;
  z-index: 55;
  right: 10px;
  bottom: calc(var(--nav-height) + 9px + env(safe-area-inset-bottom));
  left: 10px;
  display: grid;
  max-width: 720px;
  min-height: var(--action-height);
  grid-template-columns: 46px minmax(0, 1fr);
  align-items: center;
  gap: 8px;
  margin: 0 auto;
  padding: 8px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: rgba(13, 27, 43, 0.98);
  box-shadow: 0 14px 44px rgba(0, 0, 0, 0.42);
  backdrop-filter: blur(12px);
}

.selection-action .icon-button {
  width: 46px;
  height: 46px;
}

.primary-action {
  display: inline-flex;
  min-height: 48px;
  align-items: center;
  justify-content: center;
  gap: 9px;
  padding: 0 16px;
  border-radius: 7px;
  background: var(--cyan);
  color: #04121b;
  font-size: 0.9rem;
  font-weight: 950;
}

.primary-action svg {
  width: 18px;
  height: 18px;
}

.primary-action.full-width {
  width: 100%;
  margin-top: 12px;
}

.bottom-nav {
  position: fixed;
  z-index: 50;
  right: 0;
  bottom: 0;
  left: 0;
  display: grid;
  min-height: calc(var(--nav-height) + env(safe-area-inset-bottom));
  grid-template-columns: repeat(3, 1fr);
  padding: 5px max(8px, env(safe-area-inset-right)) env(safe-area-inset-bottom) max(8px, env(safe-area-inset-left));
  border-top: 1px solid var(--line);
  background: rgba(5, 13, 23, 0.98);
  backdrop-filter: blur(14px);
}

.bottom-nav button {
  display: flex;
  min-width: 0;
  min-height: 58px;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 3px;
  border-radius: 7px;
  background: transparent;
  color: var(--muted);
  font-size: 0.66rem;
  font-weight: 850;
}

.bottom-nav button svg {
  width: 20px;
  height: 20px;
}

.bottom-nav button.is-active {
  background: var(--surface-2);
  color: var(--cyan);
}

.sheet-backdrop {
  position: fixed;
  z-index: 80;
  inset: 0;
  background: rgba(0, 0, 0, 0.66);
  backdrop-filter: blur(2px);
}

.bottom-sheet {
  position: fixed;
  z-index: 90;
  right: 0;
  bottom: 0;
  left: 0;
  max-width: 760px;
  max-height: min(82dvh, 720px);
  margin: 0 auto;
  padding: 8px 14px calc(18px + env(safe-area-inset-bottom));
  overflow-y: auto;
  border: 1px solid var(--line);
  border-bottom: 0;
  border-radius: 8px 8px 0 0;
  background: var(--surface);
  box-shadow: 0 -18px 56px rgba(0, 0, 0, 0.55);
  animation: sheet-up 180ms ease-out;
}

@keyframes sheet-up {
  from {
    transform: translateY(100%);
  }
  to {
    transform: translateY(0);
  }
}

.sheet-handle {
  width: 44px;
  height: 4px;
  margin: 0 auto 10px;
  border-radius: 999px;
  background: #4b6278;
}

.sheet-heading,
.drawer-heading {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 12px;
}

.sheet-heading h2,
.drawer-heading h2 {
  margin: 2px 0 0;
  font-size: 1.2rem;
}

.sheet-heading p:not(.eyebrow) {
  margin: 3px 0 0;
  color: var(--muted);
  font-size: 0.78rem;
}

.current-choices {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 8px;
}

.current-choice {
  display: flex;
  min-height: 60px;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  border: 1px solid var(--line);
  border-radius: 7px;
  background: #071321;
  color: var(--text);
  font-weight: 900;
}

.current-choice small {
  margin-top: 2px;
  color: var(--muted);
  font-size: 0.62rem;
}

.current-choice.is-selected {
  border-color: var(--green);
  background: rgba(100, 228, 169, 0.12);
  color: var(--green);
}

.selected-sheet-list {
  display: grid;
  gap: 7px;
}

.selected-sheet-item,
.legend-item {
  display: grid;
  grid-template-columns: auto minmax(0, 1fr) auto;
  align-items: center;
  gap: 9px;
  min-height: 50px;
  padding: 8px 9px;
  border: 1px solid var(--line-soft);
  border-radius: 6px;
  background: #071321;
}

.selected-sheet-item > span,
.legend-item > span {
  width: 10px;
  height: 10px;
  border-radius: 50%;
}

.selected-sheet-item strong,
.legend-item strong {
  display: block;
  overflow: hidden;
  font-size: 0.83rem;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.selected-sheet-item small,
.legend-item small {
  display: block;
  margin-top: 2px;
  color: var(--muted);
  font-size: 0.68rem;
}

.selected-sheet-item button {
  display: grid;
  width: 34px;
  height: 34px;
  place-items: center;
  border-radius: 6px;
  background: var(--surface-2);
  color: var(--muted);
}

.selected-sheet-item button svg {
  width: 16px;
  height: 16px;
}

.sheet-form {
  display: grid;
  gap: 14px;
}

.sheet-form fieldset {
  margin: 0;
  padding: 0;
  border: 0;
}

.sheet-form legend {
  margin-bottom: 6px;
  color: var(--muted);
  font-size: 0.7rem;
  font-weight: 900;
  text-transform: uppercase;
}

.two-way-switch {
  grid-template-columns: repeat(2, 1fr);
  margin-top: 0;
}

.sheet-select small,
.toggle-row small {
  color: var(--muted);
  font-size: 0.7rem;
}

.toggle-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  align-items: center;
  gap: 14px;
  min-height: 62px;
  padding: 9px 0;
  border-top: 1px solid var(--line-soft);
}

.toggle-row span {
  display: flex;
  min-width: 0;
  flex-direction: column;
  gap: 3px;
}

.toggle-row strong {
  font-size: 0.85rem;
}

.toggle-row input {
  width: 22px;
  height: 22px;
  accent-color: var(--cyan);
}

.legend-list {
  display: grid;
  gap: 7px;
}

.legend-item {
  grid-template-columns: auto minmax(0, 1fr);
}

.menu-drawer {
  position: fixed;
  z-index: 100;
  top: 0;
  right: 0;
  bottom: 0;
  width: min(88vw, 360px);
  padding: 18px 14px calc(20px + env(safe-area-inset-bottom));
  border-left: 1px solid var(--line);
  background: #091624;
  box-shadow: -20px 0 60px rgba(0, 0, 0, 0.52);
  animation: drawer-in 170ms ease-out;
}

@keyframes drawer-in {
  from {
    transform: translateX(100%);
  }
  to {
    transform: translateX(0);
  }
}

.menu-drawer nav {
  display: grid;
  gap: 6px;
}

.menu-drawer nav button,
.menu-drawer nav a {
  display: flex;
  min-height: 48px;
  align-items: center;
  gap: 10px;
  padding: 0 11px;
  border: 1px solid var(--line-soft);
  border-radius: 7px;
  background: var(--surface);
  color: var(--text);
  font-size: 0.84rem;
  font-weight: 800;
  text-align: left;
  text-decoration: none;
}

.menu-drawer nav svg {
  width: 18px;
  height: 18px;
  color: var(--cyan);
}

.drawer-note {
  margin-top: 18px;
  padding: 12px;
  border: 1px solid rgba(100, 228, 169, 0.28);
  border-radius: 7px;
  background: rgba(100, 228, 169, 0.08);
}

.drawer-note strong {
  color: var(--green);
  font-size: 0.82rem;
}

.drawer-note p {
  margin: 5px 0 0;
  color: var(--muted);
  font-size: 0.74rem;
}

.toast {
  position: fixed;
  z-index: 120;
  right: 14px;
  bottom: calc(var(--nav-height) + 16px + env(safe-area-inset-bottom));
  left: 14px;
  max-width: 520px;
  margin: 0 auto;
  padding: 11px 13px;
  border: 1px solid var(--line);
  border-radius: 7px;
  background: #152c40;
  color: var(--text);
  box-shadow: 0 15px 38px rgba(0, 0, 0, 0.42);
  font-size: 0.8rem;
  font-weight: 750;
  text-align: center;
}

.loading-overlay {
  position: fixed;
  z-index: 130;
  inset: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 12px;
  background: rgba(3, 9, 20, 0.82);
  backdrop-filter: blur(4px);
}

.spinner {
  width: 38px;
  height: 38px;
  border: 4px solid var(--line);
  border-top-color: var(--cyan);
  border-radius: 50%;
  animation: spin 780ms linear infinite;
}

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

.loading-overlay strong {
  font-size: 0.84rem;
}

@media (min-width: 761px) {
  body {
    padding: 22px 0;
    background: #020710;
  }

  .preview-app {
    max-width: 760px;
    min-height: calc(100vh - 44px);
    border: 1px solid var(--line);
    box-shadow: 0 24px 80px rgba(0, 0, 0, 0.55);
  }

  .app-header {
    top: 22px;
  }

  .bottom-nav {
    right: auto;
    left: 50%;
    width: 760px;
    transform: translateX(-50%);
  }

  .selection-action {
    left: 50%;
    width: 720px;
    transform: translateX(-50%);
  }
}

@media (max-width: 370px) {
  .app-main {
    padding-right: 10px;
    padding-left: 10px;
  }

  .selected-chip-row {
    margin-right: -10px;
    margin-left: -10px;
    padding-right: 10px;
    padding-left: 10px;
  }

  .screen-heading h1 {
    font-size: 1.42rem;
  }

  .filter-row {
    grid-template-columns: 1fr;
  }

  .metric-switch button span {
    font-size: 0.62rem;
  }

  .mobile-chart {
    height: 315px;
    min-height: 315px;
  }

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

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

@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    scroll-behavior: auto !important;
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
  }
}

/* BatteryRealData Compare visual refresh v3 */
.app-header {
  grid-template-columns: minmax(120px, 210px) minmax(0, 1fr) auto;
}

.app-brand {
  width: min(100%, 210px);
}

.app-brand img {
  width: 100%;
  height: auto;
  max-height: 54px;
  flex: 0 1 auto;
  object-fit: contain;
}

.compare-primary-nav {
  display: none;
  min-width: 0;
  align-items: center;
  justify-content: center;
  gap: 2px;
}

.compare-primary-nav a {
  padding: 8px 7px;
  border-radius: 6px;
  color: var(--muted);
  font-size: 0.68rem;
  font-weight: 850;
  text-decoration: none;
  white-space: nowrap;
}

.compare-primary-nav a:hover,
.compare-primary-nav a:focus-visible,
.compare-primary-nav a.active {
  background: var(--surface-2);
  color: var(--text);
}

.compare-primary-nav a.live {
  background: #f15b3a;
  color: #fff;
}

.compare-header-actions {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 8px;
}

.compare-lab-banner {
  position: relative;
  display: flex;
  min-height: 148px;
  align-items: flex-end;
  overflow: hidden;
  margin-bottom: 18px;
  padding: 18px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background-color: #071321;
  background-image: url("/assets/img/battery-cell-comparison-lab-banner.png");
  background-position: center;
  background-size: cover;
}

.compare-lab-banner::before {
  position: absolute;
  inset: 0;
  background: rgba(3, 9, 20, 0.66);
  content: "";
}

.compare-lab-copy {
  position: relative;
  z-index: 1;
  max-width: 680px;
}

.compare-lab-copy p {
  margin: 0 0 5px;
  color: var(--cyan);
  font-size: 0.7rem;
  font-weight: 900;
  text-transform: uppercase;
}

.compare-lab-copy h1 {
  max-width: 620px;
  margin: 0;
  font-size: clamp(1.18rem, 4.8vw, 1.65rem);
  line-height: 1.08;
}

.purpose-filter-bar {
  display: grid;
  gap: 10px;
  margin-top: 12px;
  padding: 11px;
  border: 1px solid var(--line-soft);
  border-radius: 8px;
  background: var(--surface);
}

.purpose-filter-intro {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 10px;
}

.purpose-filter-intro span {
  color: var(--green);
  font-size: 0.66rem;
  font-weight: 900;
  text-transform: uppercase;
}

.purpose-filter-intro strong {
  font-size: 0.78rem;
}

.purpose-filter-buttons {
  display: grid;
  grid-template-columns: repeat(5, minmax(72px, 1fr));
  gap: 6px;
  overflow-x: auto;
  padding-bottom: 2px;
}

.purpose-filter-buttons button {
  min-height: 52px;
  padding: 7px 8px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: #071321;
  color: var(--text);
  text-align: left;
}

.purpose-filter-buttons button span,
.purpose-filter-buttons button small {
  display: block;
}

.purpose-filter-buttons button span {
  font-size: 0.78rem;
  font-weight: 900;
}

.purpose-filter-buttons button small {
  margin-top: 2px;
  color: var(--muted);
  font-size: 0.62rem;
  font-weight: 750;
}

.purpose-filter-buttons button[data-category="power"] {
  border-color: rgba(255, 124, 107, 0.48);
}

.purpose-filter-buttons button[data-category="balanced"] {
  border-color: rgba(99, 215, 232, 0.48);
}

.purpose-filter-buttons button[data-category="runtime"] {
  border-color: rgba(100, 228, 169, 0.48);
}

.purpose-filter-buttons button[data-category="tabless"] {
  border-color: rgba(167, 139, 250, 0.5);
}

.purpose-filter-buttons button.is-active {
  border-color: var(--cyan);
  background: var(--cyan);
  color: #04121b;
}

.purpose-filter-buttons button.is-active small {
  color: #153746;
}

.cell-card {
  grid-template-columns: 74px minmax(0, 1fr);
  align-items: center;
  border-left-width: 3px;
}

.cell-card.type-power {
  border-left-color: var(--coral);
}

.cell-card.type-balanced {
  border-left-color: var(--cyan);
}

.cell-card.type-runtime {
  border-left-color: var(--green);
}

.cell-card.type-unknown {
  border-left-color: var(--muted);
}

.cell-card.is-tabless {
  box-shadow: inset 0 0 0 1px rgba(167, 139, 250, 0.16);
}

.cell-card.is-selected {
  box-shadow: inset 3px 0 0 var(--green), inset 0 0 0 1px rgba(100, 228, 169, 0.18);
}

.cell-photo {
  display: grid;
  width: 74px;
  height: 82px;
  grid-row: span 2;
  place-items: center;
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: #f4f7f8;
}

.cell-photo img {
  width: 100%;
  height: 100%;
  object-fit: contain;
}

.cell-photo-placeholder {
  display: grid;
  width: 100%;
  height: 100%;
  place-items: center;
  background: var(--surface-2);
  color: var(--muted);
}

.cell-photo-placeholder svg {
  width: 30px;
  height: 30px;
}

.cell-purpose-row {
  display: flex;
  flex-wrap: wrap;
  gap: 5px;
  margin: 6px 0;
}

.purpose-tag,
.tabless-tag {
  display: inline-flex;
  align-items: center;
  min-height: 22px;
  padding: 3px 6px;
  border: 1px solid var(--line);
  border-radius: 4px;
  font-size: 0.62rem;
  font-weight: 900;
}

.purpose-tag.type-power {
  border-color: rgba(255, 124, 107, 0.52);
  background: rgba(255, 124, 107, 0.12);
  color: #ffb2a7;
}

.purpose-tag.type-balanced {
  border-color: rgba(99, 215, 232, 0.52);
  background: rgba(99, 215, 232, 0.11);
  color: #9feaf4;
}

.purpose-tag.type-runtime {
  border-color: rgba(100, 228, 169, 0.52);
  background: rgba(100, 228, 169, 0.11);
  color: #9bf0ca;
}

.purpose-tag.type-unknown {
  color: var(--muted);
}

.tabless-tag {
  border-color: rgba(167, 139, 250, 0.52);
  background: rgba(167, 139, 250, 0.12);
  color: #d5c8ff;
}

.cell-action {
  grid-column: 1 / -1;
}

@media (min-width: 1360px) {
  .compare-primary-nav {
    display: flex;
  }

  .app-header .icon-button {
    display: none;
  }
}

@media (max-width: 760px) {
  #screen-plot .screen-heading,
  #screen-results .screen-heading {
    grid-template-columns: minmax(0, 1fr);
  }

  .plot-heading-actions,
  .results-heading-actions {
    width: 100%;
    justify-content: flex-start;
  }

  .app-header {
    grid-template-columns: minmax(105px, 138px) minmax(0, 1fr) auto;
    gap: 6px;
    padding: 7px 8px;
  }

  .app-brand {
    width: min(100%, 138px);
  }

  .app-brand img {
    max-height: 46px;
  }

  .compare-header-actions {
    gap: 5px;
  }

  .view-mode-switch {
    display: inline-grid !important;
    padding: 3px;
  }

  .view-mode-switch a {
    min-width: 50px;
    padding: 6px 5px;
    font-size: 0.66rem;
  }

  .compare-header-actions .icon-button {
    width: 38px;
    height: 38px;
    flex-basis: 38px;
  }

  .compare-lab-banner {
    min-height: 124px;
    padding: 14px;
    background-position: 58% center;
  }

  .purpose-filter-intro {
    align-items: flex-start;
    flex-direction: column;
    gap: 2px;
  }

  .purpose-filter-buttons {
    grid-template-columns: repeat(5, 92px);
  }

  .cell-card {
    grid-template-columns: 68px minmax(0, 1fr);
    gap: 10px;
  }

  .cell-photo {
    width: 68px;
    height: 78px;
  }
}

@media (max-width: 390px) {
  .app-header {
    grid-template-columns: 116px minmax(0, 1fr) 36px;
  }

  .app-brand {
    width: 116px;
  }

  .view-mode-switch a {
    min-width: 44px;
    font-size: 0.61rem;
  }

  .compare-header-actions .icon-button {
    width: 36px;
    height: 36px;
    flex-basis: 36px;
  }

  .ranking-card {
    grid-template-columns: 30px 58px minmax(0, 1fr);
    gap: 8px;
    padding: 10px;
  }

  .rank-position {
    width: 30px;
    height: 30px;
  }

  .ranking-card-photo {
    width: 58px;
    height: 68px;
  }
}
