:root {
  --bg: #f7f8fa;
  --surface: #ffffff;
  --surface-subtle: #fafafa;
  --ink: #111827;
  --ink-soft: #374151;
  --muted: #6b7280;
  --muted-strong: #4b5563;
  --border: #d7dce4;
  --border-strong: #c7ced8;
  --accent: #0f766e;
  --accent-soft: #eef7f6;
  --success: #166534;
  --warning: #92400e;
  --danger: #991b1b;
  --shadow: 0 1px 2px rgba(17, 24, 39, 0.04), 0 8px 24px rgba(17, 24, 39, 0.05);
  --progress-track: #edf0f3;
  --error-bg: #fef2f2;
  --error-border: #fecaca;
  --success-bg: #f0fdf4;
  --success-border: #bbf7d0;
  --button-hover: #f9fafb;
  --button-hover-border: #b8c0cc;
  --section-progress-bg: #baf3e8;
  --section-progress-border: #5eead4;
  --section-progress-subcard-bg: #e1fbf6;
  --section-progress-subcard-border: #8beee0;
  --section-progress-detail-bg: #f0fffc;
  --section-context-bg: #e2e8f0;
  --section-context-border: #b6c1cf;
  --section-context-subcard-bg: #f1f5f9;
  --section-context-subcard-border: #cbd5e1;
  --section-context-detail-bg: #f8fafc;
  --section-controls-bg: #dbe8d0;
  --section-controls-border: #a8ba99;
  --section-controls-subcard-bg: #eef4e8;
  --section-controls-subcard-border: #c9d8bf;
  --section-controls-detail-bg: #f7faf3;
  --section-results-bg: #cfe6ff;
  --section-results-border: #93c5fd;
  --section-results-subcard-bg: #eaf4ff;
  --section-results-subcard-border: #acd5ff;
  --section-results-detail-bg: #f4f9ff;
  --section-disclaimer-bg: #f4dfc3;
  --section-disclaimer-border: #d6ad7b;
  --section-disclaimer-subcard-bg: #faecd9;
  --section-disclaimer-subcard-border: #e3c59f;
  --section-disclaimer-detail-bg: #fff6ea;
  --section-links-bg: #e7e0d6;
  --section-links-border: #c9bfb0;
  --section-links-subcard-bg: #f1eee9;
  --section-links-subcard-border: #d7cec0;
  --section-links-detail-bg: #f8f6f3;
}

body[data-theme="dark"] {
  --bg: #0f1115;
  --surface: #171a21;
  --surface-subtle: #1f232c;
  --ink: #f3f4f6;
  --ink-soft: #d1d5db;
  --muted: #9ca3af;
  --muted-strong: #c4cad4;
  --border: #2b303b;
  --border-strong: #3d4452;
  --accent: #2dd4bf;
  --accent-soft: rgba(45, 212, 191, 0.12);
  --success: #86efac;
  --warning: #fbbf24;
  --danger: #fca5a5;
  --shadow: 0 1px 2px rgba(0, 0, 0, 0.22), 0 12px 28px rgba(0, 0, 0, 0.18);
  --progress-track: #252a33;
  --error-bg: rgba(127, 29, 29, 0.18);
  --error-border: rgba(252, 165, 165, 0.28);
  --success-bg: rgba(22, 101, 52, 0.18);
  --success-border: rgba(134, 239, 172, 0.26);
  --button-hover: #20242d;
  --button-hover-border: #566071;
  --section-progress-bg: #173b36;
  --section-progress-border: #2c6f65;
  --section-progress-subcard-bg: #1e4b45;
  --section-progress-subcard-border: #3a8177;
  --section-progress-detail-bg: #265d56;
  --section-context-bg: #232b38;
  --section-context-border: #4b5563;
  --section-context-subcard-bg: #2b3443;
  --section-context-subcard-border: #596678;
  --section-context-detail-bg: #344052;
  --section-controls-bg: #29381f;
  --section-controls-border: #587238;
  --section-controls-subcard-bg: #344927;
  --section-controls-subcard-border: #6c8a45;
  --section-controls-detail-bg: #405932;
  --section-results-bg: #17324a;
  --section-results-border: #3b6f98;
  --section-results-subcard-bg: #1f405c;
  --section-results-subcard-border: #4b82ad;
  --section-results-detail-bg: #28506f;
  --section-disclaimer-bg: #3f300f;
  --section-disclaimer-border: rgba(251, 191, 36, 0.36);
  --section-disclaimer-subcard-bg: #554017;
  --section-disclaimer-subcard-border: rgba(251, 191, 36, 0.44);
  --section-disclaimer-detail-bg: #684f1d;
  --section-links-bg: #2d2922;
  --section-links-border: #5b5142;
  --section-links-subcard-bg: #39342b;
  --section-links-subcard-border: #6b604e;
  --section-links-detail-bg: #454034;
}

* {
  box-sizing: border-box;
}

/* Flexbox layout: header pinned, footer pinned, middle scrolls — works on iOS with overflow-wrap fix */
html, body {
  margin: 0;
  height: 100%;
  overflow: hidden;
}

body {
  color: var(--ink);
  background: var(--bg);
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  font-size: 14px;
  line-height: 1.45;
}

.shell {
  display: flex;
  flex-direction: column;
  height: 100vh;
  height: 100dvh;
  overflow: hidden;
}

.hero {
  flex-shrink: 0;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding: 12px;
  background: var(--surface);
  border-bottom: 1px solid var(--border);
}

.layout {
  flex: 1;
  min-height: 0;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
  overscroll-behavior: contain;
  display: grid;
  gap: 12px;
  padding: 12px;
}

/* Footer */
.app-footer {
  flex-shrink: 0;
}

.panel-links {
  padding: 12px;
}

.hero > div:first-child {
  min-width: 0;
}

.hero h1 {
  margin: 2px 0 0;
  color: var(--ink);
  font-size: 1rem;
  font-weight: 720;
  line-height: 1.2;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.hero p {
  max-width: 180px;
  margin: 0;
  color: var(--muted);
  font-size: 0.82rem;
  line-height: 1.35;
  text-align: right;
}

.top-links {
  display: flex;
  gap: 16px;
  margin-top: 6px;
}

.top-links a {
  font-size: 0.85rem;
}

.header-right-col {
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  gap: 8px;
  flex-shrink: 0;
}

.header-actions {
  display: inline-flex;
  align-items: center;
  flex: 0 0 auto;
  gap: 2px;
  padding: 2px;
  border: 1px solid var(--border);
  border-radius: 999px;
  background: var(--surface-subtle);
  align-self: flex-end;
}

.theme-option {
  position: relative;
  display: inline-flex;
  align-items: center;
  cursor: pointer;
}

.theme-option input {
  position: absolute;
  width: 1px;
  height: 1px;
  opacity: 0;
}

.theme-option span {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 42px;
  min-height: 26px;
  padding: 4px 8px;
  border-radius: 999px;
  color: var(--muted-strong);
  font-size: 0.78rem;
  font-weight: 680;
  line-height: 1;
}

.theme-option input:checked + span {
  background: var(--surface);
  color: var(--ink);
  box-shadow: 0 1px 2px rgba(17, 24, 39, 0.08);
}

.theme-option input:focus-visible + span {
  outline: 2px solid rgba(15, 118, 110, 0.28);
  outline-offset: 2px;
}

.country-panel {
  margin-top: 10px;
}

.country-panel .field {
  display: flex;
  align-items: center;
  gap: 8px;
}

.country-panel .field span {
  white-space: nowrap;
  margin-top: 0;
}

.country-panel .country-select {
  flex: 1;
  min-width: 0;
  padding: 6px 10px;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--surface);
  color: var(--ink);
  font-size: 0.85rem;
  font-weight: 600;
  cursor: pointer;
  appearance: auto;
}

.country-select:focus-visible {
  outline: 2px solid rgba(15, 118, 110, 0.28);
  outline-offset: 2px;
}

.eyebrow,
.section-kicker,
.lane-title,
.meta-label {
  color: var(--muted);
  font-size: 0.68rem;
  font-weight: 680;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.section-kicker {
  margin-bottom: 3px;
}

.panel,
.subpanel {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 8px;
  box-shadow: var(--shadow);
}

.panel {
  min-width: 0;
  padding: 14px;
}

.panel-progress {
  background: var(--section-progress-bg);
  border-color: var(--section-progress-border);
  --section-subcard-bg: var(--section-progress-subcard-bg);
  --section-subcard-border: var(--section-progress-subcard-border);
  --section-detail-bg: var(--section-progress-detail-bg);
  padding: 10px 14px;
}

.panel-context {
  background: var(--section-context-bg);
  border-color: var(--section-context-border);
  --section-subcard-bg: var(--section-context-subcard-bg);
  --section-subcard-border: var(--section-context-subcard-border);
  --section-detail-bg: var(--section-context-detail-bg);
}

.panel-controls {
  background: var(--section-controls-bg);
  border-color: var(--section-controls-border);
  --section-subcard-bg: var(--section-controls-subcard-bg);
  --section-subcard-border: var(--section-controls-subcard-border);
  --section-detail-bg: var(--section-controls-detail-bg);
}

.panel-results {
  background: var(--section-results-bg);
  border-color: var(--section-results-border);
  --section-subcard-bg: var(--section-results-subcard-bg);
  --section-subcard-border: var(--section-results-subcard-border);
  --section-detail-bg: var(--section-results-detail-bg);
}

.panel-links {
  background: var(--section-links-bg);
  border-color: var(--section-links-border);
  --section-subcard-bg: var(--section-links-subcard-bg);
  --section-subcard-border: var(--section-links-subcard-border);
  --section-detail-bg: var(--section-links-detail-bg);
}

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

.panel-head h2,
.subpanel h3 {
  margin: 0;
  color: var(--ink);
  font-size: 1rem;
  font-weight: 720;
  line-height: 1.25;
}

.progress-shell {
  display: grid;
  gap: 5px;
  min-width: 0;
}

.panel-progress .panel-head {
  margin-bottom: 6px;
}

.panel-progress .section-kicker {
  margin-bottom: 1px;
}

.panel-progress h2 {
  font-size: 0.92rem;
}

.progress-track {
  width: 100%;
  height: 4px;
  overflow: hidden;
  border-radius: 999px;
  background: var(--progress-track);
}

.progress-bar {
  width: 0%;
  height: 100%;
  border-radius: inherit;
  background: var(--accent);
  transition: width 220ms ease;
}

.progress-meta {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  min-width: 0;
  color: var(--ink-soft);
  font-size: 0.78rem;
  font-weight: 680;
  line-height: 1.2;
}

.progress-message {
  max-width: 100%;
  max-height: 124px;
  margin: 0;
  overflow: auto;
  color: var(--muted-strong);
  font-size: 0.78rem;
  line-height: 1.3;
  overflow-wrap: anywhere;
  padding-right: 4px;
  scrollbar-width: thin;
  white-space: normal;
  word-break: break-word;
}

.panel-progress.is-complete .progress-message {
  display: none;
}

.progress-shell.error-state {
  padding: 10px;
  border: 1px solid var(--error-border);
  border-radius: 8px;
  background: var(--error-bg);
}

.progress-shell.error-state .progress-message {
  color: var(--danger);
}

.clamp-two {
  display: -webkit-box;
  overflow: hidden;
  line-height: 1.35;
  overflow-wrap: anywhere;
  -webkit-box-orient: vertical;
  -webkit-line-clamp: 2;
}

.chips {
  display: flex;
  flex-wrap: wrap;
  gap: 5px;
  margin: 9px 0;
}

.chip,
.mini-chip,
.pill,
.score-pill {
  display: inline-flex;
  align-items: center;
  min-width: 0;
  border: 1px solid var(--border);
  border-radius: 999px;
  background: var(--surface-subtle);
  color: var(--muted-strong);
  font-size: 0.76rem;
  font-weight: 640;
  line-height: 1.2;
  overflow-wrap: anywhere;
}

.chip,
.mini-chip {
  padding: 4px 7px;
}

.text-block {
  display: block;
  margin-top: 6px;
}

.text-block summary,
.field span {
  display: block;
  color: var(--muted);
  font-size: 0.8rem;
  font-weight: 620;
}

.text-block summary {
  display: flex;
  align-items: center;
  justify-content: space-between;
  min-height: 36px;
  padding: 8px 10px;
  border: 1px solid var(--section-subcard-border);
  border-radius: 8px;
  background: var(--section-subcard-bg);
  color: var(--ink-soft);
  cursor: pointer;
  list-style: none;
}

.text-block summary::-webkit-details-marker {
  display: none;
}

.text-block summary::after {
  content: "Show";
  color: var(--muted);
  font-size: 0.76rem;
  font-weight: 680;
}

.text-block[open] summary {
  margin-bottom: 6px;
  background: var(--section-subcard-bg);
}

.text-block[open] summary::after {
  content: "Hide";
}

textarea,
input,
select {
  width: 100%;
  border: 1px solid var(--border-strong);
  border-radius: 8px;
  background: var(--surface);
  color: var(--ink);
  font: inherit;
}

textarea:focus,
input:focus,
select:focus,
button:focus-visible,
a:focus-visible {
  outline: 2px solid rgba(15, 118, 110, 0.28);
  outline-offset: 2px;
}

textarea {
  min-height: 96px;
  max-height: 180px;
  padding: 10px 11px;
  resize: vertical;
  color: var(--ink-soft);
  font-size: 0.84rem;
  line-height: 1.45;
}

input,
select {
  padding: 9px 10px;
}

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

.checkbox-row {
  display: flex;
  align-items: center;
  gap: 8px;
  margin: 12px 0 16px;
  color: var(--ink);
}

.checkbox-row input {
  width: 16px;
  height: 16px;
}

.helper-text {
  margin: 7px 0 0;
  color: var(--muted);
  font-size: 0.8rem;
  line-height: 1.45;
}

#channelEvidence {
  display: block;
  min-width: 0;
  width: 100%;
  max-width: 100%;
  margin: 6px 0 0;
  overflow: hidden;
  color: var(--muted-strong);
  font-size: 0.72rem;
  font-weight: 640;
  line-height: 1.25;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.wallet-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  margin-bottom: 8px;
}

.wallet-actions {
  display: inline-flex;
  align-items: center;
  gap: 6px;
}

.button-inline {
  width: auto;
  padding: 7px 10px;
}

.wallet-summary {
  min-width: 0;
  padding: 8px 10px;
  border: 1px solid var(--section-subcard-border);
  border-radius: 8px;
  background: var(--section-subcard-bg);
  color: var(--ink-soft);
  font-size: 0.84rem;
  font-weight: 620;
  line-height: 1.35;
  overflow-wrap: anywhere;
}

.panel-controls {
  padding: 12px;
}

.panel-controls .panel-head {
  margin-bottom: 10px;
}

.panel-controls .section-kicker {
  margin-bottom: 1px;
}

.panel-controls .field span,
.panel-controls .meta-label {
  font-size: 0.72rem;
}

.panel-controls select {
  min-width: 0;
  padding: 7px 9px;
  font-size: 0.86rem;
}

.panel-controls .helper-text {
  margin-top: 5px;
  font-size: 0.76rem;
  line-height: 1.3;
}

.panel-controls .chips {
  gap: 4px;
  overflow: hidden;
}

.panel-controls .chip {
  max-width: 100%;
  padding: 3px 6px;
  font-size: 0.72rem;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.panel-controls .wallet-head {
  margin-bottom: 6px;
}

.panel-disclaimer {
  padding: 10px 12px;
  border-color: var(--section-disclaimer-border);
  background: var(--section-disclaimer-bg);
  --section-subcard-bg: var(--section-disclaimer-subcard-bg);
  --section-subcard-border: var(--section-disclaimer-subcard-border);
  --section-detail-bg: var(--section-disclaimer-detail-bg);
}

.panel-disclaimer p {
  margin: 5px 0 0;
  color: var(--muted-strong);
  font-size: 0.76rem;
  line-height: 1.4;
}

.panel-links {
  padding: 12px;
}

.policy-links,
.card-source-links {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 6px;
}

/* Footer policy links always in one scrollable row on any screen */
.app-footer .policy-links {
  flex-wrap: nowrap;
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
  white-space: nowrap;
  padding: 4px 0;
  scrollbar-width: none;
  gap: 6px;
}
.app-footer .policy-links::-webkit-scrollbar { display: none; }
.app-footer .policy-link {
  flex-shrink: 0;
  display: inline-flex;
  align-items: center;
  min-height: 28px;
}

.policy-link,
.card-source-links a {
  width: auto;
  padding: 0;
  border: 0;
  background: transparent;
  color: var(--accent);
  font-size: 0.78rem;
  font-weight: 680;
  text-decoration: none;
  white-space: nowrap;
}

.policy-link:hover,
.policy-link.is-active,
.card-source-links a:hover {
  background: transparent;
  text-decoration: underline;
}

.card-referral {
  margin-top: 10px;
  padding: 8px 10px;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--surface-subtle);
}

.referral-link {
  display: block;
  color: var(--accent);
  font-size: 0.82rem;
  font-weight: 680;
  text-decoration: none;
}

.referral-link:hover {
  text-decoration: underline;
}

.referral-disclosure {
  margin-top: 4px;
  color: var(--muted);
  font-size: 0.7rem;
  line-height: 1.3;
}

.referral-disclosure-text {
  margin: 0 0 10px 0;
  color: var(--muted);
  font-size: 0.72rem;
  line-height: 1.35;
}

#referralResults {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.referral-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  padding: 8px 10px;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--surface);
}

.referral-item-info {
  flex: 1;
  min-width: 0;
}

.referral-item-name {
  font-size: 0.82rem;
  font-weight: 680;
  color: var(--ink);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.referral-item-issuer {
  font-size: 0.72rem;
  color: var(--muted);
}

.referral-item-actions {
  display: flex;
  align-items: center;
  gap: 6px;
  flex-shrink: 0;
}

.referral-commission {
  font-size: 0.72rem;
  color: var(--accent);
  font-weight: 600;
  white-space: nowrap;
}

.referral-apply-btn {
  display: inline-flex;
  align-items: center;
  padding: 4px 10px;
  border: 1px solid var(--accent);
  border-radius: 6px;
  background: var(--accent);
  color: var(--bg);
  font-size: 0.75rem;
  font-weight: 680;
  text-decoration: none;
  cursor: pointer;
}

.referral-apply-btn:hover {
  opacity: 0.85;
}

.policy-content {
  max-height: 220px;
  margin-top: 10px;
  padding-top: 8px;
  border-top: 1px solid var(--border);
  overflow: auto;
  scrollbar-width: thin;
}

.policy-content h3 {
  margin: 0 0 6px;
  color: var(--ink);
  font-size: 0.9rem;
}

.policy-content p {
  margin: 0 0 7px;
  color: var(--ink-soft);
  font-size: 0.78rem;
  line-height: 1.42;
}

.panel-controls .button-inline {
  padding: 6px 9px;
  font-size: 0.8rem;
}

.panel-controls .wallet-summary {
  font-size: 0.8rem;
  line-height: 1.3;
}

@media (min-width: 520px) {
  .panel-controls .field {
    display: grid;
    grid-template-columns: minmax(0, 132px) minmax(0, 1fr);
    align-items: center;
    gap: 10px;
    min-width: 0;
  }
}

.wallet-grid {
  display: grid;
  gap: 4px;
  margin-top: 8px;
}

.wallet-card {
  display: grid;
  grid-template-columns: 18px minmax(0, 1fr) auto;
  align-items: center;
  column-gap: 9px;
  min-width: 0;
  padding: 8px 9px;
  border: 1px solid transparent;
  border-radius: 7px;
  background: var(--section-subcard-bg);
  cursor: pointer;
}

.wallet-card:hover {
  border-color: var(--section-subcard-border);
  background: var(--section-subcard-bg);
}

.wallet-card input {
  width: 16px;
  height: 16px;
  margin: 0;
  accent-color: var(--accent);
}

.wallet-card span {
  color: var(--ink);
  font-size: 0.86rem;
  font-weight: 680;
  line-height: 1.25;
}

.wallet-card small {
  color: var(--muted);
  font-size: 0.76rem;
  line-height: 1.25;
  text-align: right;
}

button {
  appearance: none;
  border: 1px solid var(--border-strong);
  border-radius: 8px;
  padding: 8px 12px;
  cursor: pointer;
  background: var(--surface);
  color: var(--ink);
  font: inherit;
  font-size: 0.84rem;
  font-weight: 680;
  transition: border-color 120ms ease, background 120ms ease, color 120ms ease;
}

button:hover {
  border-color: var(--button-hover-border);
  background: var(--button-hover);
}

button.primary {
  width: 100%;
  border-color: var(--accent);
  background: var(--accent);
  color: #ffffff;
}

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

.hidden {
  display: none;
}

.lane-title {
  margin: 2px 0 8px;
}

.recommendation-card {
  display: block;
  margin-bottom: 10px;
  padding: 0;
  border: 1px solid var(--section-subcard-border);
  border-radius: 8px;
  background: var(--section-subcard-bg);
  box-shadow: var(--shadow);
  overflow: hidden;
}

.recommendation-summary {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 6px 10px;
  padding: 12px;
  cursor: pointer;
  list-style: none;
}

.recommendation-summary::-webkit-details-marker {
  display: none;
}

.recommendation-title {
  display: flex;
  align-items: flex-start;
  flex-wrap: wrap;
  gap: 6px;
  min-width: 0;
}

.pill,
.score-pill {
  justify-content: center;
  padding: 6px 9px;
}

.pill {
  max-width: 100%;
  border-color: rgba(15, 118, 110, 0.2);
  background: var(--accent-soft);
  color: var(--accent);
}

.score-pill {
  color: var(--muted-strong);
}

.recommendation-value {
  grid-row: span 2;
  align-self: start;
  color: var(--ink);
  font-size: 0.98rem;
  font-weight: 760;
  line-height: 1.2;
  text-align: right;
  white-space: nowrap;
}

.recommendation-support {
  min-width: 0;
  color: var(--muted);
  font-size: 0.8rem;
  font-weight: 620;
  line-height: 1.35;
  overflow-wrap: anywhere;
}

.recommendation-body {
  padding: 0 12px 12px;
  border-top: 1px solid var(--section-subcard-border);
  background: var(--section-subcard-bg);
}

.winner-reason {
  margin: 8px 0 0;
  color: var(--ink-soft);
  font-size: 0.87rem;
  line-height: 1.5;
}

.winner-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-top: 12px;
}

.mini-chip {
  color: var(--success);
  background: var(--success-bg);
  border-color: var(--success-border);
}

.owned-lane {
  margin-top: 4px;
}

.result-grid {
  display: grid;
  gap: 10px;
}

.subpanel {
  border-color: var(--section-subcard-border);
  background: var(--section-subcard-bg);
  padding: 12px;
  box-shadow: none;
}

.subpanel h3 {
  margin-bottom: 7px;
  font-size: 0.9rem;
}

.expandable-subpanel {
  padding: 0;
}

.expandable-subpanel summary {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  min-height: 44px;
  padding: 12px;
  cursor: pointer;
  list-style: none;
}

.expandable-subpanel summary::-webkit-details-marker {
  display: none;
}

.expandable-subpanel summary h3 {
  margin: 0;
}

.expandable-subpanel summary span {
  flex: 0 0 auto;
  color: var(--accent);
  font-size: 0.76rem;
  font-weight: 720;
}

.expandable-subpanel[open] summary {
  border-bottom: 1px solid var(--section-subcard-border);
}

.expandable-subpanel[open] summary span {
  font-size: 0;
}

.expandable-subpanel[open] summary span::after {
  content: "Hide";
  font-size: 0.76rem;
}

.expandable-subpanel > div {
  padding: 12px;
}

.calculation-panel {
  display: grid;
  gap: 7px;
  margin-top: 10px;
  padding: 10px;
  border: 1px solid var(--section-subcard-border);
  border-radius: 8px;
  background: var(--section-detail-bg);
}

.calculation-panel h4 {
  margin: 2px 0 0;
  color: var(--ink);
  font-size: 0.78rem;
  font-weight: 760;
  line-height: 1.25;
}

.calculation-row,
.card-detail-item {
  display: grid;
  grid-template-columns: minmax(80px, 0.6fr) minmax(0, 1fr);
  gap: 8px;
  align-items: start;
  color: var(--muted);
  font-size: 0.76rem;
  line-height: 1.35;
}

.calculation-row strong,
.card-detail-item strong {
  color: var(--ink-soft);
  font-weight: 680;
  overflow-wrap: anywhere;
}

.remarks-list {
  display: grid;
  gap: 5px;
  margin: 0;
  padding-left: 16px;
  color: var(--ink-soft);
  font-size: 0.77rem;
  line-height: 1.4;
}

.card-detail-grid {
  display: grid;
  gap: 7px;
  margin-top: 10px;
  padding-top: 10px;
  border-top: 1px solid var(--section-subcard-border);
}

.card-source-links {
  padding-top: 8px;
  border-top: 1px solid var(--section-subcard-border);
}

.alt-support {
  margin-top: 3px;
  color: var(--muted);
  font-size: 0.78rem;
  line-height: 1.35;
}

.lounge-group-title {
  margin: 10px 0 6px;
  color: var(--ink);
  font-size: 0.78rem;
  font-weight: 760;
  line-height: 1.25;
}

.lounge-show-more {
  width: 100%;
  margin: 2px 0 10px;
  padding: 7px 10px;
  font-size: 0.78rem;
}

.lounge-more-list {
  display: grid;
  gap: 0;
}

.lounge-more-list.hidden {
  display: none;
}

.benefit-card {
  display: grid;
  gap: 8px;
  min-width: 0;
  margin-bottom: 10px;
  padding: 10px;
  border: 1px solid var(--section-subcard-border);
  border-radius: 8px;
  background: var(--section-subcard-bg);
}

.benefit-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 10px;
  min-width: 0;
}

.benefit-head strong {
  min-width: 0;
  color: var(--ink);
  font-size: 0.88rem;
  line-height: 1.25;
  overflow-wrap: anywhere;
}

.benefit-head > span {
  flex: 0 0 auto;
  color: var(--ink);
  font-size: 0.84rem;
  font-weight: 760;
  line-height: 1.2;
  text-align: right;
}

.benefit-route {
  margin: 0;
  color: var(--ink-soft);
  font-size: 0.8rem;
  font-weight: 620;
  line-height: 1.35;
  overflow-wrap: anywhere;
}

.status-pill {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  max-width: 132px;
  padding: 4px 7px;
  border: 1px solid var(--border);
  border-radius: 999px;
  background: var(--surface);
  color: var(--muted-strong);
  font-size: 0.7rem;
  font-weight: 720;
  line-height: 1.1;
  white-space: normal;
}

.status-eligible {
  border-color: var(--success-border);
  background: var(--success-bg);
  color: var(--success);
}

.status-spend-required {
  border-color: rgba(146, 64, 14, 0.25);
  background: rgba(146, 64, 14, 0.08);
  color: var(--warning);
}

.benefit-spend-row {
  padding-top: 6px;
  border-top: 1px solid var(--section-subcard-border);
}

.rule-links {
  display: grid;
  gap: 8px;
}

.rule-link {
  color: var(--accent);
  font-size: 0.84rem;
  font-weight: 680;
  overflow-wrap: anywhere;
  text-decoration: none;
}

.rule-link:hover {
  text-decoration: underline;
}

#warnings {
  margin: 0;
  padding-left: 17px;
  color: var(--ink-soft);
  font-size: 0.84rem;
}

#warnings li + li {
  margin-top: 6px;
}

.status {
  max-width: 100%;
  padding: 2px 4px 8px;
  color: var(--muted);
  font-size: 0.82rem;
  text-align: center;
  overflow-wrap: anywhere;
  white-space: normal;
  word-break: break-word;
}

/* ---- App-specific: Transaction Detail Form ---- */

/* Labels for form fields */
.form-label {
  display: block;
  color: var(--muted);
  font-size: 0.8rem;
  font-weight: 620;
  margin-bottom: 3px;
}

/* Form actions row */
.form-actions {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-top: 14px;
}

.form-actions button {
  flex: 1;
}

/* Panel containing the transaction detail form */
.panel-form {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 8px;
  box-shadow: var(--shadow);
  min-width: 0;
  padding: 14px;
}

.panel-form .field-grid {
  display: grid;
  gap: 10px;
  grid-template-columns: repeat(2, minmax(0, 1fr));
}

.panel-form .field {
  display: flex;
  flex-direction: column;
}

.panel-form .field span {
  display: block;
  color: var(--muted);
  font-size: 0.8rem;
  font-weight: 620;
}

.panel-form input,
.panel-form select,
.panel-form textarea {
  width: 100%;
  border: 1px solid var(--border-strong);
  border-radius: 8px;
  background: var(--surface);
  color: var(--ink);
  font: inherit;
  padding: 9px 10px;
}

.panel-form input:focus,
.panel-form select:focus,
.panel-form textarea:focus {
  outline: 2px solid rgba(15, 118, 110, 0.28);
  outline-offset: 2px;
}

.panel-form .checkbox-row {
  display: flex;
  align-items: center;
  gap: 8px;
  margin: 12px 0 16px;
  color: var(--ink);
}

.panel-form .checkbox-row input {
  width: 16px;
  height: 16px;
  padding: 0;
}

.panel-form .helper-text {
  margin: 7px 0 0;
  color: var(--muted);
  font-size: 0.8rem;
  line-height: 1.45;
}

/* ---- Responsive: < 640px ---- */
@media (max-width: 640px) {
  .hero {
    flex-direction: column;
    align-items: stretch;
    gap: 8px;
  }

  .hero > div:first-child {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    justify-content: space-between;
    gap: 6px;
  }

  .hero h1 {
    font-size: 0.92rem;
  }

  .top-links {
    margin-top: 0;
  }

  .header-right-col {
    flex-direction: row;
    align-items: center;
    justify-content: space-between;
    gap: 6px;
  }

  .country-panel {
    margin-top: 0;
    flex: 1;
    min-width: 0;
  }

  .country-panel .field {
    flex-direction: row;
  }

  .country-panel .field span {
    font-size: 0.72rem;
  }

  /* Sticky optimize button */
  .form-actions {
    position: sticky;
    bottom: 0;
    z-index: 10;
    margin: 10px -14px -14px;
    padding: 10px 14px 14px;
    background: var(--surface);
    border-top: 1px solid var(--border);
    border-radius: 0 0 8px 8px;
  }

  .form-actions button {
    min-height: 44px;
    font-size: 0.92rem;
  }

  /* Bigger tap targets */
  input,
  select,
  button,
  .policy-link,
  .wallet-card,
  .referral-apply-btn {
    min-height: 44px;
  }

  input,
  select {
    font-size: 16px; /* prevents iOS zoom on focus */
  }

  .wallet-grid,
  .context-summary {
    grid-template-columns: 1fr;
  }

  .wallet-card {
    grid-template-columns: 18px minmax(0, 1fr);
  }

  .wallet-card small {
    grid-column: 2;
    text-align: left;
  }

  .pill {
    max-width: 100%;
  }

  .field-grid,
  .panel-form .field-grid {
    grid-template-columns: 1fr;
  }

  .recommendation-value {
    font-size: 0.9rem;
  }
}

/* ---- Responsive: very narrow < 400px ---- */
@media (max-width: 400px) {
  .hero > div:first-child {
    flex-direction: column;
    align-items: flex-start;
  }

  .header-right-col {
    flex-direction: column;
    align-items: stretch;
  }

  .country-panel .field {
    flex-direction: column;
    align-items: stretch;
  }
}