:root {
  --ink-900: #080f1c;
  --ink-800: #0a1322;
  --ink-700: #0f1a2e;
  --ink-600: #16243c;
  --ink-card: #111d33;

  --line: rgba(150, 180, 220, 0.11);
  --line-strong: rgba(150, 180, 220, 0.22);

  --text: #e9eef7;
  --text-dim: #9fb0c8;
  --text-faint: #5f718c;

  /* cool diagnostic azure as the single sharp accent */
  --accent: #6fb6ff;
  --accent-deep: #3d8ee0;
  --accent-glow: rgba(111, 182, 255, 0.16);

  /* muted clay for sos — present, never alarming */
  --sos: #c99078;

  /* RGB triplet companions so derived alphas track the source in one place */
  --accent-rgb: 111, 182, 255;
  --sos-rgb: 201, 144, 120;
  --line-rgb: 150, 180, 220;
  --text-on-accent: #061021;
  --ink-scrim: #000;

  --radius-large: 20px;
  --radius-medium: 15px;
  --radius-small: 11px;

  --font-display: "Fraunces", Georgia, serif;
  --font-body: "Hanken Grotesk", system-ui, sans-serif;
  --font-mono: "JetBrains Mono", ui-monospace, monospace;
}

* {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
  -webkit-tap-highlight-color: transparent;
}

html, body {
  background: var(--ink-800);
  color: var(--text);
  font-family: var(--font-body);
  overscroll-behavior-y: none;
  -webkit-font-smoothing: antialiased;
}

body {
  min-height: 100vh;
  /* layered atmosphere: radial glow + blueprint grid over deep ink */
  background:
    radial-gradient(120% 80% at 50% -10%, rgba(var(--accent-rgb), 0.10), transparent 55%),
    linear-gradient(180deg, var(--ink-700) 0%, var(--ink-800) 38%, var(--ink-900) 100%);
  background-attachment: fixed;
  position: relative;
}

/* faint engineering grid evoking the blueprint motif */
body::before {
  content: "";
  position: fixed;
  inset: 0;
  background-image:
    linear-gradient(var(--line) 1px, transparent 1px),
    linear-gradient(90deg, var(--line) 1px, transparent 1px);
  background-size: 38px 38px;
  -webkit-mask-image: radial-gradient(110% 70% at 50% 0%, var(--ink-scrim) 30%, transparent 78%);
          mask-image: radial-gradient(110% 70% at 50% 0%, var(--ink-scrim) 30%, transparent 78%);
  opacity: 0.5;
  pointer-events: none;
  z-index: 0;
}

.shell {
  position: relative;
  z-index: 1;
  max-width: 480px;
  margin: 0 auto;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

.view { display: none; }
.view.active {
  display: flex;
  flex-direction: column;
  flex: 1;
  padding:
    calc(16px + env(safe-area-inset-top)) 20px
    calc(24px + env(safe-area-inset-bottom));
  animation: viewIn 0.45s cubic-bezier(0.16, 1, 0.3, 1);
}

@keyframes viewIn {
  from { opacity: 0; transform: translateY(8px); }
  to   { opacity: 1; transform: none; }
}

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 30px;
}

.brand { display: flex; align-items: center; gap: 9px; }
.brand .glyph {
  color: var(--accent);
  font-size: 17px;
  line-height: 1;
  text-shadow: 0 0 14px var(--accent-glow);
}
.brand .name {
  font-family: var(--font-mono);
  font-size: 13px;
  letter-spacing: 0.14em;
  color: var(--text-dim);
  text-transform: uppercase;
}

/* credits chip — the balance entry point, kept quiet by design */
.credits {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  padding: 7px 12px;
  border: 1px solid var(--line-strong);
  border-radius: 999px;
  background: rgba(var(--accent-rgb), 0.05);
  cursor: pointer;
  transition: border-color 0.25s, background 0.25s, transform 0.12s;
  flex: none;
}
.credits:active { transform: scale(0.96); }
.credits .dot { color: var(--accent); font-size: 11px; }
.credits .value { font-family: var(--font-mono); font-size: 13px; color: var(--text); }
.credits .unit { font-size: 11px; color: var(--text-faint); letter-spacing: 0.04em; }
.credits.low { border-color: rgba(var(--sos-rgb), 0.4); background: rgba(var(--sos-rgb), 0.07); }
.credits.low .dot,
.credits.low .value { color: var(--sos); }

.eyebrow {
  font-family: var(--font-mono);
  font-size: 11px;
  letter-spacing: 0.20em;
  text-transform: uppercase;
  color: var(--text-faint);
  margin-bottom: 13px;
}
.headline {
  font-family: var(--font-display);
  font-weight: 400;
  font-size: 29px;
  line-height: 1.13;
  letter-spacing: -0.01em;
}
.headline em { font-style: italic; color: var(--accent); font-weight: 500; }
.subline {
  margin-top: 12px;
  font-size: 15px;
  line-height: 1.5;
  color: var(--text-dim);
  max-width: 32ch;
}

.intro { margin-bottom: 28px; }

.hero {
  position: relative;
  overflow: hidden;
  border: 1px solid var(--line-strong);
  border-radius: var(--radius-large);
  padding: 22px 22px 20px;
  background:
    radial-gradient(140% 120% at 100% 0%, rgba(var(--accent-rgb), 0.12), transparent 60%),
    linear-gradient(165deg, var(--ink-600), var(--ink-card));
  cursor: pointer;
  margin-bottom: 30px;
  transition: transform 0.14s ease;
}
.hero:active { transform: scale(0.985); }
.hero::after {
  content: "";
  position: absolute;
  top: 0;
  left: -40%;
  width: 40%;
  height: 100%;
  background: linear-gradient(90deg, transparent, rgba(var(--accent-rgb), 0.10), transparent);
  animation: scan 5.5s ease-in-out infinite;
}
.hero-top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 26px;
}
.phase {
  font-family: var(--font-mono);
  font-size: 11px;
  letter-spacing: 0.16em;
  color: var(--text-faint);
}
.hero .glyph-lg {
  color: var(--accent);
  font-size: 19px;
  text-shadow: 0 0 18px var(--accent-glow);
}
.hero h2 {
  font-family: var(--font-display);
  font-weight: 500;
  font-size: 25px;
  letter-spacing: -0.01em;
  margin-bottom: 7px;
}
.hero .steps {
  font-family: var(--font-mono);
  font-size: 12px;
  color: var(--text-dim);
}

.pill {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 12px 18px;
  border-radius: 999px;
  background: linear-gradient(180deg, var(--accent), var(--accent-deep));
  color: var(--text-on-accent);
  font-weight: 600;
  font-size: 14.5px;
  box-shadow: 0 8px 26px -10px var(--accent-glow);
  border: none;
  cursor: pointer;
  font-family: var(--font-body);
}
.hero .pill { margin-top: 22px; }
.pill .arrow { transition: transform 0.25s; }
.hero:active .pill .arrow { transform: translateX(3px); }
.hero .hint {
  display: none;
  margin-top: 14px;
  font-size: 12.5px;
  color: var(--sos);
}
.hero .hint u { text-underline-offset: 3px; cursor: pointer; }
body.is-low .hero .hint { display: block; }

.sec-head {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  margin-bottom: 14px;
}
.sec-head h3 {
  font-family: var(--font-mono);
  font-weight: 500;
  font-size: 12px;
  letter-spacing: 0.16em;
  text-transform: uppercase;
  color: var(--text-dim);
}
.sec-head a {
  font-size: 12.5px;
  color: var(--accent);
  text-decoration: none;
  cursor: pointer;
}

.list {
  border: 1px solid var(--line);
  border-radius: var(--radius-medium);
  overflow: hidden;
}
.cycle {
  display: flex;
  flex-direction: column;
  padding: 13px 16px 12px;
  border-bottom: 1px solid var(--line);
  transition: background 0.2s;
}
.cycle:last-child { border-bottom: none; }
.cycle-top {
  display: flex;
  align-items: center;
  gap: 13px;
  cursor: pointer;
}
.cycle-top:active { opacity: 0.7; }
.cycle .id {
  font-family: var(--font-mono);
  font-size: 12px;
  color: var(--text-faint);
  flex: none;
}
.cycle .bug { flex: 1; font-size: 14px; color: var(--text); }
.cycle .date {
  font-family: var(--font-mono);
  font-size: 11.5px;
  color: var(--text-faint);
}

/* shared rating component: dim invite a tap, light up when set */
.rating {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-top: 9px;
}
.stars { display: inline-flex; gap: 5px; }
.star {
  font-size: 16px;
  line-height: 1;
  color: var(--text-faint);
  opacity: 0.5;
  cursor: pointer;
  transition: opacity 0.18s, color 0.18s, transform 0.12s;
}
.star:active { transform: scale(0.82); }
.star.full {
  color: var(--accent);
  opacity: 1;
  text-shadow: 0 0 12px var(--accent-glow);
}
.rating.readonly .star { cursor: default; pointer-events: none; }
.rating .label { font-size: 11.5px; color: var(--text-faint); transition: color 0.2s; }
.rating.rated .label { color: var(--text-dim); }

.rate-panel { display: none; margin-top: 10px; gap: 8px; }
.rate-panel.open { display: flex; }
.rate-panel textarea {
  flex: 1;
  resize: none;
  height: 38px;
  padding: 9px 11px;
  border: 1px solid var(--line-strong);
  border-radius: 9px;
  background: var(--ink-800);
  color: var(--text);
  font-family: var(--font-body);
  font-size: 13px;
  outline: none;
  transition: border-color 0.2s;
}
.rate-panel textarea:focus { border-color: var(--accent-deep); }
.rate-panel .save {
  flex: none;
  padding: 0 14px;
  border: none;
  border-radius: 9px;
  background: rgba(var(--accent-rgb), 0.14);
  color: var(--accent);
  font-family: var(--font-mono);
  font-size: 12px;
  cursor: pointer;
  transition: background 0.2s;
}
.rate-panel .save:active { background: rgba(var(--accent-rgb), 0.24); }
.saved-comment {
  margin-top: 8px;
  font-size: 12.5px;
  color: var(--text-faint);
  line-height: 1.45;
  cursor: pointer;
}
.saved-comment:active { color: var(--text-dim); }

.empty {
  border: 1px dashed var(--line-strong);
  border-radius: var(--radius-medium);
  padding: 26px 18px;
  text-align: center;
  color: var(--text-faint);
  font-size: 13.5px;
  line-height: 1.55;
}

.field { margin-bottom: 20px; }
.field label {
  display: block;
  font-family: var(--font-mono);
  font-size: 11px;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--text-dim);
  margin-bottom: 9px;
}
.field textarea,
.field select {
  width: 100%;
  background: var(--ink-card);
  color: var(--text);
  border: 1px solid var(--line-strong);
  border-radius: var(--radius-medium);
  font-family: var(--font-body);
  font-size: 15px;
  outline: none;
  transition: border-color 0.2s, box-shadow 0.2s;
}
.field textarea {
  padding: 14px;
  min-height: 92px;
  resize: vertical;
  line-height: 1.5;
}
.field textarea::placeholder { color: var(--text-faint); }
.field textarea:focus,
.field select:focus {
  border-color: var(--accent-deep);
  box-shadow: 0 0 0 3px var(--accent-glow);
}
.field select {
  padding: 14px;
  height: 50px;
  cursor: pointer;
  appearance: none;
  -webkit-appearance: none;
  /* chevron arrow drawn with two linear-gradient triangles */
  background-image:
    linear-gradient(45deg, transparent 50%, var(--accent) 50%),
    linear-gradient(135deg, var(--accent) 50%, transparent 50%);
  background-position: calc(100% - 20px) 21px, calc(100% - 14px) 21px;
  background-size: 6px 6px, 6px 6px;
  background-repeat: no-repeat;
}
.field select.placeholder { color: var(--text-faint); }
.field select option { color: var(--text); background: var(--ink-700); }

.result-head { margin-bottom: 24px; }
.group-tag {
  font-family: var(--font-mono);
  font-size: 11px;
  letter-spacing: 0.16em;
  color: var(--text-faint);
  margin: 22px 0 12px;
}
.group-tag:first-of-type { margin-top: 4px; }
.card {
  border: 1px solid var(--line);
  border-radius: var(--radius-medium);
  padding: 18px;
  background: rgba(17, 29, 51, 0.55);
  margin-bottom: 12px;
}
.card.accent {
  border-color: rgba(var(--accent-rgb), 0.3);
  background: linear-gradient(165deg, var(--ink-600), var(--ink-card));
}
.card .card-top {
  display: flex;
  align-items: baseline;
  gap: 9px;
  margin-bottom: 9px;
}
.card .card-top .move-id {
  font-family: var(--font-mono);
  font-size: 12px;
  color: var(--accent);
  flex: none;
}
.card h4 {
  font-family: var(--font-display);
  font-weight: 500;
  font-size: 17px;
  line-height: 1.25;
}
.card p { font-size: 14.5px; line-height: 1.55; color: var(--text-dim); }
.card.future p {
  color: var(--text);
  font-style: italic;
  font-family: var(--font-display);
  font-size: 16px;
}

.rate-box {
  border: 1px solid var(--line-strong);
  border-radius: var(--radius-medium);
  padding: 18px;
  margin: 22px 0 4px;
  background: rgba(var(--accent-rgb), 0.04);
}
.rate-box .rate-box-title {
  font-family: var(--font-mono);
  font-size: 11px;
  letter-spacing: 0.16em;
  text-transform: uppercase;
  color: var(--text-dim);
  margin-bottom: 13px;
}
.rate-box .stars { gap: 8px; }
.rate-box .star { font-size: 22px; }

/* feedback view */
.rb-title {
  font-family: var(--font-mono);
  font-size: 11px;
  letter-spacing: 0.16em;
  text-transform: uppercase;
  color: var(--text-dim);
  margin-bottom: 13px;
}
.feedback-hint {
  font-family: var(--font-mono);
  font-size: 12px;
  color: var(--text-faint);
  margin-top: 10px;
  min-height: 1.4em;
}

.search { position: relative; margin-bottom: 16px; }
.search input {
  width: 100%;
  padding: 13px 14px 13px 40px;
  background: var(--ink-card);
  border: 1px solid var(--line-strong);
  border-radius: var(--radius-medium);
  color: var(--text);
  font-family: var(--font-body);
  font-size: 14.5px;
  outline: none;
  transition: border-color 0.2s;
}
.search input::placeholder { color: var(--text-faint); }
.search input:focus { border-color: var(--accent-deep); }
.search .mag {
  position: absolute;
  left: 15px;
  top: 50%;
  transform: translateY(-50%);
  color: var(--text-faint);
  font-size: 14px;
}

.pager {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-top: 16px;
}
.pager button {
  font-family: var(--font-mono);
  font-size: 12px;
  letter-spacing: 0.06em;
  background: var(--ink-card);
  color: var(--text-dim);
  border: 1px solid var(--line-strong);
  border-radius: 10px;
  padding: 9px 14px;
  cursor: pointer;
  transition: opacity 0.2s, background 0.2s;
}
.pager button:active { background: rgba(var(--accent-rgb), 0.08); }
.pager button:disabled { opacity: 0.35; cursor: default; }
.pager .indicator {
  font-family: var(--font-mono);
  font-size: 12px;
  color: var(--text-faint);
}

.plan {
  border: 1px solid var(--accent);
  border-radius: var(--radius-large);
  padding: 22px;
  background: linear-gradient(165deg, var(--ink-600), var(--ink-card));
  position: relative;
  overflow: hidden;
  margin-top: 18px;
  margin-bottom: 14px;
}
/* decorative glyph in the plan card corner; U+27E1 (WHITE CONCAVE-SIDED
   DIAMOND) — CSS content uses the unicode-escape form, not the HTML entity */
.plan::after {
  content: "\27E1";
  position: absolute;
  top: 16px;
  right: 18px;
  color: var(--accent);
  font-size: 18px;
  text-shadow: 0 0 16px var(--accent-glow);
}
.plan .plan-name {
  font-family: var(--font-mono);
  font-size: 12px;
  letter-spacing: 0.12em;
  color: var(--accent);
  margin-bottom: 14px;
}
.plan .plan-credits {
  font-family: var(--font-display);
  font-weight: 500;
  font-size: 30px;
}
.plan .plan-credits span {
  font-size: 16px;
  color: var(--text-dim);
  font-family: var(--font-body);
  font-weight: 400;
}
.plan .plan-price {
  font-family: var(--font-mono);
  font-size: 18px;
  color: var(--text);
  margin: 4px 0 16px;
}
.plan ul {
  list-style: none;
  display: flex;
  flex-direction: column;
  gap: 9px;
}
.plan li {
  font-size: 13.5px;
  line-height: 1.45;
  color: var(--text-dim);
  padding-left: 18px;
  position: relative;
}
.plan li::before {
  content: "◇";
  position: absolute;
  left: 0;
  color: var(--accent);
  font-size: 10px;
  top: 3px;
}

/* sticky action bar with fade-to-ink gradient hiding scroll content */
.action {
  position: sticky;
  bottom: 0;
  margin-top: auto;
  padding-top: 16px;
  padding-bottom: env(safe-area-inset-bottom);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  background: linear-gradient(180deg, transparent, var(--ink-800) 38%);
}
.action .pill { flex: 1; justify-content: center; }
.action .ghost {
  flex: 1;
  justify-content: center;
  background: var(--ink-card);
  color: var(--text);
  border: 1px solid var(--line-strong);
  box-shadow: none;
}
.cost-note {
  font-family: var(--font-mono);
  font-size: 11px;
  color: var(--text-faint);
  text-align: center;
  margin-top: 10px;
}

.sos-link {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  flex: none;
  font-size: 12px;
  color: var(--text-faint);
  cursor: pointer;
  transition: color 0.2s;
  white-space: nowrap;
}
.sos-link:active { color: var(--sos); }
.sos-link .pulse {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: var(--sos);
  box-shadow: 0 0 0 0 rgba(var(--sos-rgb), 0.5);
  animation: pulse 3.2s ease-out infinite;
}

.footer { margin-top: auto; padding-top: 30px; }
.footer-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding-top: 18px;
  border-top: 1px solid var(--line);
}
.language { display: flex; gap: 4px; }
.language button {
  font-family: var(--font-mono);
  font-size: 11px;
  letter-spacing: 0.08em;
  background: none;
  border: none;
  color: var(--text-faint);
  padding: 5px 8px;
  border-radius: 7px;
  cursor: pointer;
  transition: color 0.2s, background 0.2s;
}
.language button.active {
  color: var(--text);
  background: rgba(var(--line-rgb), 0.09);
}
.balance-link {
  font-size: 12.5px;
  color: var(--text-dim);
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  gap: 6px;
}
.balance-link .dot {
  width: 4px;
  height: 4px;
  border-radius: 50%;
  background: var(--accent);
}
.footer .sos-link { margin-top: 16px; }
.legal {
  margin-top: 14px;
  font-size: 10.5px;
  color: var(--text-faint);
  letter-spacing: 0.02em;
  line-height: 1.6;
}
.legal a {
  color: inherit;
  text-decoration: none;
  border-bottom: 1px solid var(--line-strong);
}

.backdrop {
  position: fixed;
  inset: 0;
  z-index: 50;
  background: rgba(4, 8, 16, 0.6);
  backdrop-filter: blur(3px);
  display: none;
  align-items: flex-end;
  justify-content: center;
}
.backdrop.open { display: flex; animation: fade 0.25s ease; }
.sheet {
  width: 100%;
  max-width: 480px;
  background: linear-gradient(180deg, var(--ink-700), var(--ink-800));
  border-top: 1px solid var(--line-strong);
  border-radius: 22px 22px 0 0;
  padding: 10px 22px calc(24px + env(safe-area-inset-bottom));
  animation: sheetIn 0.32s cubic-bezier(0.16, 1, 0.3, 1);
}
.sheet .grip {
  width: 38px;
  height: 4px;
  border-radius: 99px;
  background: var(--line-strong);
  margin: 0 auto 20px;
}
.sheet h3 {
  font-family: var(--font-display);
  font-weight: 500;
  font-size: 22px;
  margin-bottom: 8px;
}
.sheet .lead {
  font-size: 14px;
  color: var(--text-dim);
  line-height: 1.5;
  margin-bottom: 18px;
}
.hotline {
  display: flex;
  align-items: center;
  gap: 13px;
  padding: 15px 16px;
  border: 1px solid var(--line-strong);
  border-radius: var(--radius-medium);
  margin-bottom: 10px;
  text-decoration: none;
  color: var(--text);
  background: rgba(var(--sos-rgb), 0.05);
  transition: background 0.2s;
}
.hotline:active { background: rgba(var(--sos-rgb), 0.12); }
.hotline .ring {
  width: 38px;
  height: 38px;
  flex: none;
  border-radius: 50%;
  border: 1px solid var(--sos);
  display: grid;
  place-items: center;
  color: var(--sos);
  font-size: 16px;
}
.hotline .hotline-text b { display: block; font-size: 15px; font-weight: 600; }
.hotline .hotline-text span { font-family: var(--font-mono); font-size: 13px; color: var(--text-dim); }
.reassure {
  margin: 16px 0 18px;
  font-size: 14px;
  line-height: 1.55;
  color: var(--text);
}
.reassure b { color: var(--sos); font-weight: 600; }
.sheet .close {
  width: 100%;
  padding: 14px;
  border: 1px solid var(--line-strong);
  border-radius: var(--radius-medium);
  background: var(--ink-card);
  color: var(--text);
  font-family: var(--font-body);
  font-size: 15px;
  font-weight: 600;
  cursor: pointer;
}

@keyframes scan {
  0%, 100% { left: -45%; }
  50%       { left: 105%; }
}
@keyframes pulse {
  0%   { box-shadow: 0 0 0 0 rgba(var(--sos-rgb), 0.45); }
  70%  { box-shadow: 0 0 0 9px rgba(var(--sos-rgb), 0); }
  100% { box-shadow: 0 0 0 0 rgba(var(--sos-rgb), 0); }
}
@keyframes fade {
  from { opacity: 0; }
  to   { opacity: 1; }
}
@keyframes sheetIn {
  from { transform: translateY(100%); }
  to   { transform: none; }
}

@media (prefers-reduced-motion: reduce) {
  * { animation: none !important; }
}
