:root {
  --bg: #0f1013;
  --surface: #15181d;
  --surface-strong: #171a20;
  --surface-soft: #1d2128;
  --line: rgba(255, 255, 255, 0.08);
  --line-strong: rgba(255, 255, 255, 0.12);
  --text: #f4f6f8;
  --muted: #a2acb8;
  --muted-strong: #c8d0da;
  --brand: #e8d38a;
  --brand-strong: #d9be63;
  --ok: #7ed7a0;
  --warn: #f0c97a;
  --danger: #ef9696;
  --shadow: none;
  --radius: 22px;
  --radius-sm: 16px;
  font-family: "Avenir Next", "Segoe UI", sans-serif;
}

* {
  box-sizing: border-box;
}

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

body {
  margin: 0;
  color: var(--text);
  min-height: 100vh;
  background: var(--bg);
}

.app-shell {
  width: min(100%, 820px);
  margin: 0 auto;
  padding: 28px 16px 112px;
}

.card {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 20px;
}

.card + .card,
.card + .editor,
.editor > .card + .card {
  margin-top: 16px;
}

.hero {
  padding-top: 22px;
}

.app-meta-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin: 16px 2px 32px;
}

.app-version {
  flex: 0 0 auto;
  color: var(--muted);
  font-size: 0.72rem;
  font-weight: 400;
  letter-spacing: 0.04em;
}

.eyebrow {
  margin: 0 0 6px;
  font-size: 0.72rem;
  letter-spacing: 0.18em;
  text-transform: uppercase;
  color: #d9c480;
}

h1,
h2,
h3 {
  margin: 0;
  line-height: 1.05;
}

h1 {
  font-size: clamp(2.3rem, 7vw, 3.4rem);
  max-width: none;
  letter-spacing: -0.045em;
}

h2 {
  font-size: clamp(1.6rem, 5vw, 2.4rem);
}

h3 {
  font-size: 1.1rem;
}

.upload-zone {
  display: grid;
  gap: 7px;
  margin-top: 20px;
  padding: 18px 18px 19px;
  border-radius: 18px;
  border: 1px solid var(--line-strong);
  background: #171a20;
  transition: border-color 180ms ease, background 180ms ease, transform 180ms ease;
}

.upload-zone:active {
  transform: translateY(1px);
}

.upload-zone:hover {
  border-color: rgba(232, 211, 138, 0.2);
  background: #1a1e25;
}

.upload-zone input {
  display: none;
}

.upload-title {
  font-size: 1rem;
  font-weight: 700;
  color: var(--muted-strong);
}

.upload-copy {
  color: var(--muted);
  font-size: 0.92rem;
}

.status {
  margin: 14px 0 0;
  padding: 12px 14px;
  border-radius: 16px;
  border: 1px solid rgba(239, 150, 150, 0.22);
  background: rgba(239, 150, 150, 0.08);
  color: #ffb6b6;
  line-height: 1.45;
}

.hidden {
  display: none !important;
}

.summary-headline {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.pokemon-level {
  display: inline-flex;
  align-items: center;
  margin: 0;
  padding: 9px 13px;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.04);
  border: 1px solid var(--line);
  color: var(--muted-strong);
  font-size: 0.88rem;
  font-weight: 700;
  white-space: nowrap;
}

.pokemon-level.auto-raised {
  background: rgba(134, 239, 172, 0.12);
  border-color: rgba(134, 239, 172, 0.2);
  color: var(--ok);
}

.summary-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 12px;
  margin: 16px 0 0;
}

.summary-grid div {
  padding: 12px;
  border-radius: 16px;
  background: #181c22;
  border: 1px solid rgba(255, 255, 255, 0.06);
}

.summary-grid dt {
  margin-bottom: 6px;
  font-size: 0.8rem;
  color: var(--muted);
}

.summary-grid dd {
  margin: 0;
  font-weight: 700;
}

.section-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 16px;
}

.field-stack,
.ev-grid {
  display: grid;
  gap: 12px;
}

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

label {
  display: grid;
  gap: 8px;
}

label span {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  font-size: 0.92rem;
  color: var(--muted-strong);
}

label strong {
  color: var(--text);
  font-size: 0.98rem;
}

input,
select,
button {
  font: inherit;
}

input,
select {
  width: 100%;
  appearance: none;
  border: 1px solid var(--line);
  background: #171a20;
  color: var(--text);
  border-radius: 14px;
  padding: 14px 16px;
  min-height: 52px;
  transition: border-color 180ms ease, background 180ms ease;
}

input[type="range"] {
  padding: 0;
  min-height: auto;
  height: 34px;
  appearance: none;
  border: 0;
  background: transparent;
}

input[type="range"]::-webkit-slider-runnable-track {
  height: 8px;
  border-radius: 999px;
  background: linear-gradient(
    90deg,
    var(--brand-strong) 0%,
    var(--brand-strong) var(--range-fill, 0%),
    #2a2f38 var(--range-fill, 0%),
    #2a2f38 100%
  );
}

input[type="range"]::-webkit-slider-thumb {
  appearance: none;
  margin-top: -6px;
  width: 18px;
  height: 18px;
  border-radius: 50%;
  border: 2px solid #f5ecd1;
  background: var(--brand-strong);
  box-shadow: none;
}

input[type="range"]::-moz-range-track {
  height: 8px;
  border-radius: 999px;
  border: 0;
  background: linear-gradient(
    90deg,
    var(--brand-strong) 0%,
    var(--brand-strong) var(--range-fill, 0%),
    #2a2f38 var(--range-fill, 0%),
    #2a2f38 100%
  );
}

input[type="range"]::-moz-range-thumb {
  width: 18px;
  height: 18px;
  border-radius: 50%;
  border: 2px solid #f5ecd1;
  background: var(--brand-strong);
  box-shadow: none;
}

input:focus,
select:focus,
button:focus {
  outline: 2px solid rgba(232, 211, 138, 0.35);
  outline-offset: 2px;
}

.ev-total-wrap {
  display: flex;
  justify-content: flex-end;
}

.ev-total {
  padding: 10px 12px;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.04);
  border: 1px solid var(--line);
  font-size: 0.88rem;
  font-weight: 700;
}

.ev-total.error {
  background: rgba(252, 165, 165, 0.14);
  color: var(--danger);
}

.notes p:last-child {
  margin-bottom: 0;
  color: var(--muted);
  line-height: 1.55;
}

.action-bar {
  position: fixed;
  left: 0;
  right: 0;
  bottom: 0;
  padding: 12px 16px calc(12px + env(safe-area-inset-bottom));
  background: var(--bg);
  border-top: 1px solid rgba(255, 255, 255, 0.06);
}

#save-button {
  width: min(100%, 820px);
  display: block;
  margin: 0 auto;
  border: 1px solid rgba(255, 255, 255, 0.08);
  border-radius: 16px;
  padding: 16px 18px;
  font-weight: 800;
  letter-spacing: 0.01em;
  color: #18120a;
  background: #dcbc67;
  box-shadow: none;
}

.update-link {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  margin: 0;
  padding: 0;
  border: 0;
  background: transparent;
  color: var(--muted);
  font-size: 0.86rem;
  font-weight: 700;
}

.update-link svg {
  display: none;
  width: 15px;
  height: 15px;
  fill: none;
  stroke: currentColor;
  stroke-width: 2;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.update-link.busy svg {
  display: block;
  animation: spin 900ms linear infinite;
}

.update-link.hide-icon svg {
  display: none;
}

.update-link.available {
  color: var(--brand);
}

.update-link:disabled {
  opacity: 0.7;
}

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

#save-button:disabled {
  opacity: 0.45;
  box-shadow: none;
}

code {
  font-family: "SF Mono", "Menlo", monospace;
  font-size: 0.95em;
  color: #f0dfa9;
}

@media (min-width: 720px) {
  .app-shell {
    padding-inline: 24px;
    padding-top: 36px;
  }

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

  .summary-grid {
    grid-template-columns: repeat(4, minmax(0, 1fr));
  }
}
