:root {
  --bg: #0a0a10;
  --bg-2: #0f0f17;
  --card: #14141d;
  --card-2: #1a1a25;
  --input-bg: #0e0e16;
  --border: #232331;
  --border-2: #2d2d3e;
  --text: #f0f0f5;
  --muted: #8a8a99;
  --muted-2: #5a5a68;
  --accent: #d11a3d;
  --accent-2: #ff3a5e;
  --accent-soft: rgba(255, 58, 94, 0.10);
  --accent-border: rgba(255, 58, 94, 0.28);
  --ok: #2ecc71;
  --bad: #e74c3c;
}

* { box-sizing: border-box; margin: 0; padding: 0; }

html, body {
  background: var(--bg);
  color: var(--text);
  font: 13.5px/1.5 -apple-system, "Segoe UI", system-ui, "SF Pro Display", "Inter", sans-serif;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  min-height: 100vh;
}

button { font-family: inherit; cursor: pointer; }
input, textarea, select, button { font-family: inherit; }
a { color: var(--accent-2); text-decoration: none; }

/* ============ HEADER ============ */
header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 12px 14px;
  background: rgba(10, 10, 16, 0.92);
  backdrop-filter: blur(10px);
  border-bottom: 1px solid var(--border);
  position: sticky;
  top: 0;
  z-index: 10;
}
header > * {
  max-width: none;
}
.header-inner {
  width: 100%;
  max-width: 480px;
  margin: 0 auto;
  display: flex;
  align-items: center;
  justify-content: space-between;
}
.brand {
  display: flex;
  align-items: center;
  gap: 11px;
  min-width: 0;
}
.logo {
  width: 38px; height: 38px;
  flex-shrink: 0;
  background: linear-gradient(135deg, var(--accent) 0%, var(--accent-2) 100%);
  border-radius: 9px;
  display: grid;
  place-items: center;
  font-weight: 800;
  font-size: 19px;
  letter-spacing: -0.5px;
  color: white;
  box-shadow:
    0 4px 14px rgba(209, 26, 61, 0.42),
    inset 0 1px 0 rgba(255, 255, 255, 0.18);
}
.brand-text { min-width: 0; }
.title {
  font-weight: 700;
  font-size: 15px;
  letter-spacing: -0.2px;
  line-height: 1.2;
}
.status {
  font-size: 11.5px;
  color: var(--accent-2);
  margin-top: 2px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  max-width: 220px;
}
.status.connected {
  color: var(--ok);
}
.status.connected::before {
  content: '● ';
  font-size: 10px;
}

.icon-btn {
  width: 32px; height: 32px;
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 8px;
  display: grid;
  place-items: center;
  color: var(--muted);
  transition: color 0.12s ease, border-color 0.12s ease, background 0.12s ease;
}
.icon-btn:hover {
  color: var(--text);
  border-color: var(--border-2);
  background: var(--card-2);
}

/* ============ TABS ============ */
.tabs {
  display: flex;
  gap: 0;
  padding: 0 14px;
  border-bottom: 1px solid var(--border);
  background: var(--bg);
  position: sticky;
  top: 63px;
  z-index: 9;
  max-width: 480px;
  margin: 0 auto;
  width: 100%;
}
.tab {
  background: transparent;
  border: 0;
  color: var(--muted);
  padding: 12px 14px 11px;
  font-size: 13px;
  font-weight: 600;
  display: flex;
  align-items: center;
  gap: 6px;
  position: relative;
  transition: color 0.15s ease;
}
.tab:hover {
  color: var(--text);
}
.tab.active {
  color: var(--text);
}
.tab.active::after {
  content: '';
  position: absolute;
  left: 12px;
  right: 12px;
  bottom: -1px;
  height: 2px;
  background: linear-gradient(90deg, var(--accent), var(--accent-2));
  border-radius: 2px 2px 0 0;
}
.tab .badge {
  background: var(--accent);
  color: white;
  font-size: 9.5px;
  padding: 1px 6px;
  border-radius: 9px;
  font-weight: 700;
  line-height: 1.4;
  min-width: 18px;
  text-align: center;
}
.tab-panel { display: none; }
.tab-panel.active {
  display: block;
  animation: fadeIn 0.18s ease;
}
@keyframes fadeIn {
  from { opacity: 0; transform: translateY(-2px); }
  to   { opacity: 1; transform: translateY(0); }
}

/* ============ MAIN ============ */
main {
  padding: 14px;
  display: flex;
  flex-direction: column;
  gap: 10px;
  max-width: 480px;
  margin: 0 auto;
  width: 100%;
}

/* ============ CARDS ============ */
.card {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 14px 14px 12px;
}
.card + .card {
  margin-top: 0;
}
.card-label {
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 1.4px;
  text-transform: uppercase;
  color: var(--muted-2);
  margin-bottom: 11px;
  display: flex;
  align-items: center;
  gap: 6px;
}
.card-label-count {
  background: var(--accent-soft);
  color: var(--accent-2);
  padding: 1px 7px;
  border-radius: 8px;
  font-size: 10px;
  letter-spacing: 0.5px;
}
.card-hint {
  font-size: 11.5px;
  color: var(--muted);
  margin-top: 8px;
  line-height: 1.5;
}
.card-hint b {
  color: var(--text);
  font-weight: 600;
}

/* ============ FIELDS ============ */
.field {
  display: block;
  margin-bottom: 10px;
  font-size: 12px;
  color: var(--muted);
  font-weight: 500;
}
.field:last-child { margin-bottom: 0; }
.field > input,
.field > textarea,
.field > select {
  display: block;
  width: 100%;
  margin-top: 5px;
  background: var(--input-bg);
  border: 1px solid var(--border);
  color: var(--text);
  padding: 9px 11px;
  border-radius: 8px;
  font-size: 13px;
  font-weight: 400;
  transition: border-color 0.12s ease, box-shadow 0.12s ease, background 0.12s ease;
}
.field > input:hover,
.field > textarea:hover {
  border-color: var(--border-2);
}
.field > input:focus,
.field > textarea:focus,
.field > select:focus {
  outline: none;
  border-color: var(--accent-2);
  box-shadow: 0 0 0 3px rgba(255, 58, 94, 0.10);
  background: var(--bg-2);
}
.field > textarea {
  resize: vertical;
  min-height: 50px;
  font-family: inherit;
}
.field > input::placeholder,
.field > textarea::placeholder {
  color: var(--muted-2);
}
.hint {
  display: block;
  font-size: 11px;
  color: var(--muted-2);
  font-weight: 400;
  margin-top: 5px;
  line-height: 1.4;
}

.row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
}

/* ============ INPUT WITH ACTION (clone-from-mint) ============ */
.input-with-action {
  display: flex;
  gap: 8px;
}
.input-with-action input {
  flex: 1;
  background: var(--input-bg);
  border: 1px solid var(--border);
  color: var(--text);
  padding: 9px 11px;
  border-radius: 8px;
  font-size: 13px;
  font-family: ui-monospace, "SF Mono", "Cascadia Code", monospace;
  transition: border-color 0.12s ease, box-shadow 0.12s ease;
}
.input-with-action input:hover {
  border-color: var(--border-2);
}
.input-with-action input:focus {
  outline: none;
  border-color: var(--accent-2);
  box-shadow: 0 0 0 3px rgba(255, 58, 94, 0.10);
}
.input-with-action input::placeholder {
  color: var(--muted-2);
  font-family: inherit;
}
.input-with-action .btn {
  flex-shrink: 0;
  padding: 9px 16px;
}

/* ============ IMAGE DROPZONE ============ */
.image-field input[type="file"] {
  position: absolute;
  opacity: 0;
  pointer-events: none;
  width: 0; height: 0;
}
.image-drop {
  margin-top: 5px;
  background: var(--input-bg);
  border: 1.5px dashed var(--border-2);
  border-radius: 8px;
  padding: 22px 14px;
  cursor: pointer;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 10px;
  text-align: center;
  transition: border-color 0.15s ease, background 0.15s ease;
  min-height: 86px;
}
.image-drop:hover {
  border-color: var(--accent-2);
  background: var(--bg-2);
}
.image-drop.has-image {
  border-style: solid;
  border-color: var(--border);
  flex-direction: row;
  text-align: left;
  padding: 12px 14px;
  min-height: 0;
}
.image-thumb {
  width: 48px; height: 48px;
  flex-shrink: 0;
  background-size: cover;
  background-position: center;
  border-radius: 7px;
  background-color: transparent;
  display: none;
}
.image-drop.has-image .image-thumb {
  display: block;
}
.image-text {
  font-size: 12.5px;
  color: var(--muted);
  font-weight: 500;
}
.image-drop.has-image .image-text {
  color: var(--text);
  flex: 1;
  overflow: hidden;
  white-space: nowrap;
  text-overflow: ellipsis;
}

/* ============ AI BUTTON ============ */
.ai-btn {
  width: 100%;
  background: var(--card-2);
  border: 1px solid var(--border);
  color: var(--text);
  padding: 9px 14px;
  border-radius: 8px;
  font-size: 12.5px;
  font-weight: 600;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  margin-top: 10px;
  margin-bottom: 12px;
  transition: border-color 0.12s ease, background 0.12s ease;
}
.ai-btn:hover:not(:disabled) {
  border-color: var(--accent-border);
  background: var(--bg-2);
}
.ai-btn:disabled {
  opacity: 0.55;
  cursor: not-allowed;
}
.ai-icon {
  font-size: 14px;
  filter: saturate(1.2);
}

/* ============ FEE NOTE ============ */
.fee-note {
  background: var(--accent-soft);
  border: 1px solid var(--accent-border);
  border-radius: 8px;
  padding: 9px 12px;
  font-size: 11.5px;
  color: var(--muted);
  margin: 4px 0 12px;
  line-height: 1.5;
}
.fee-note b, .fee-note span {
  color: var(--accent-2);
  font-family: ui-monospace, monospace;
  font-weight: 600;
}

/* ============ BUTTONS ============ */
.btn {
  background: var(--card-2);
  border: 1px solid var(--border);
  color: var(--text);
  padding: 8px 14px;
  border-radius: 8px;
  font-size: 12.5px;
  font-weight: 600;
  transition: filter 0.1s ease, transform 0.05s ease, border-color 0.12s ease, background 0.12s ease;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
}
.btn:hover:not(:disabled) {
  border-color: var(--border-2);
  background: #20202d;
}
.btn:active:not(:disabled) {
  transform: translateY(1px);
}
.btn:disabled {
  opacity: 0.55;
  cursor: not-allowed;
}
.btn.primary {
  background: linear-gradient(135deg, var(--accent), var(--accent-2));
  border-color: transparent;
  color: white;
  box-shadow: 0 4px 14px rgba(209, 26, 61, 0.30);
}
.btn.primary:hover:not(:disabled) {
  filter: brightness(1.06);
  box-shadow: 0 6px 20px rgba(209, 26, 61, 0.42);
  background: linear-gradient(135deg, var(--accent), var(--accent-2));
}
.btn.primary.big {
  padding: 12px 18px;
  font-size: 13.5px;
  font-weight: 700;
  letter-spacing: 0.4px;
}
.btn.danger {
  background: rgba(231, 76, 60, 0.13);
  border-color: rgba(231, 76, 60, 0.32);
  color: var(--bad);
}
.btn.danger:hover:not(:disabled) {
  background: rgba(231, 76, 60, 0.20);
  border-color: rgba(231, 76, 60, 0.5);
}
.btn.ghost {
  background: transparent;
}
.btn.small {
  padding: 6px 11px;
  font-size: 11.5px;
}
.launch-btn {
  display: block;
  width: 100%;
  margin-top: 4px;
}

/* ============ RESULTS ============ */
.result {
  margin-top: 12px;
  padding: 10px 12px;
  border-radius: 8px;
  font-size: 12px;
  line-height: 1.55;
  word-break: break-all;
}
.result.success {
  background: rgba(46, 204, 113, 0.12);
  border: 1px solid rgba(46, 204, 113, 0.30);
  color: var(--ok);
}
.result.error {
  background: rgba(231, 76, 60, 0.12);
  border: 1px solid rgba(231, 76, 60, 0.30);
  color: var(--bad);
}
.result.info {
  background: var(--accent-soft);
  border: 1px solid var(--accent-border);
  color: var(--accent-2);
}
.result a {
  color: inherit;
  text-decoration: underline;
}

/* ============ POSITIONS ============ */
.actions-row {
  display: flex;
  justify-content: flex-end;
  margin-bottom: 10px;
}
.positions-list {
  display: flex;
  flex-direction: column;
  gap: 8px;
}
.position-row {
  display: grid;
  grid-template-columns: 1fr auto auto;
  gap: 12px;
  align-items: center;
  padding: 11px 12px;
  background: var(--input-bg);
  border: 1px solid var(--border);
  border-radius: 8px;
  transition: border-color 0.12s ease;
}
.position-row:hover {
  border-color: var(--border-2);
}
.pos-meta {
  display: flex;
  flex-direction: column;
  gap: 2px;
  min-width: 0;
}
.pos-symbol {
  font-weight: 700;
  font-size: 13px;
}
.pos-amounts {
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  gap: 2px;
}
.pos-value {
  color: var(--ok);
  font-family: ui-monospace, monospace;
  font-weight: 600;
  font-size: 12.5px;
}
.pos-tokens {
  color: var(--muted-2);
  font-family: ui-monospace, monospace;
  font-size: 10.5px;
}
.empty-state {
  text-align: center;
  padding: 36px 16px;
  color: var(--muted-2);
  font-size: 12px;
  background: var(--input-bg);
  border: 1px dashed var(--border);
  border-radius: 8px;
}

.muted-text { color: var(--muted); font-size: 12px; margin-bottom: 12px; }
.mono { font-family: ui-monospace, monospace; }
.mono.small { font-size: 10.5px; }

/* ============ SETTINGS ============ */
.settings-info {
  margin-top: 18px;
  padding-top: 14px;
  border-top: 1px solid var(--border);
}
.info-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 6px 0;
  font-size: 11.5px;
}
.info-row span:first-child {
  color: var(--muted-2);
  text-transform: uppercase;
  letter-spacing: 0.6px;
  font-size: 10px;
  font-weight: 600;
}
.info-row span:last-child {
  color: var(--text);
  font-size: 11.5px;
}

/* ============ RPC ONBOARDING BANNER ============ */
.rpc-banner {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 12px;
  background: linear-gradient(135deg, rgba(255, 199, 0, 0.08), rgba(255, 121, 0, 0.05));
  border: 1px solid rgba(255, 199, 0, 0.25);
  border-radius: 10px;
  margin-bottom: 4px;
}
.rpc-banner-icon {
  font-size: 18px;
  line-height: 1;
  flex-shrink: 0;
}
.rpc-banner-body {
  flex: 1;
  min-width: 0;
}
.rpc-banner-title {
  font-size: 12.5px;
  font-weight: 600;
  color: var(--text);
  margin-bottom: 2px;
}
.rpc-banner-text {
  font-size: 11.5px;
  color: var(--muted);
  line-height: 1.35;
}
.rpc-banner .btn {
  flex-shrink: 0;
  white-space: nowrap;
}

/* ============ RPC STATUS (inline validation under field) ============ */
.rpc-status {
  margin-top: 6px;
  padding: 6px 10px;
  border-radius: 6px;
  font-size: 11.5px;
  line-height: 1.3;
}
.rpc-status-checking {
  background: rgba(170, 170, 170, 0.08);
  color: var(--muted);
  border: 1px solid rgba(170, 170, 170, 0.18);
}
.rpc-status-ok {
  background: rgba(60, 200, 130, 0.08);
  color: #4ade80;
  border: 1px solid rgba(60, 200, 130, 0.28);
}
.rpc-status-bad {
  background: rgba(239, 68, 68, 0.08);
  color: #f87171;
  border: 1px solid rgba(239, 68, 68, 0.28);
}

/* ============ HELIUS SIGNUP GUIDE ============ */
.helius-guide {
  margin: 14px 0;
  padding: 10px 12px;
  background: rgba(255, 255, 255, 0.02);
  border: 1px solid var(--border);
  border-radius: 8px;
}
.helius-guide summary {
  cursor: pointer;
  font-size: 12.5px;
  font-weight: 600;
  color: var(--text);
  user-select: none;
  outline: none;
}
.helius-guide summary::marker { color: var(--muted-2); }
.helius-guide[open] summary { margin-bottom: 10px; }
.helius-steps {
  margin: 0 0 10px;
  padding-left: 20px;
  font-size: 12px;
  line-height: 1.5;
  color: var(--muted);
}
.helius-steps li { margin-bottom: 6px; }
.helius-steps li b { color: var(--text); }
.helius-steps a {
  color: #ff5b8a;
  text-decoration: none;
}
.helius-steps a:hover { text-decoration: underline; }
.helius-guide .hint {
  display: block;
  font-size: 11px;
  color: var(--muted-2);
  margin-bottom: 10px;
  line-height: 1.4;
}

/* ============ POPUP-CONTEXT TWEAKS ============ */
@media (max-width: 480px) {
  header { padding: 11px 12px; }
  .logo { width: 34px; height: 34px; font-size: 17px; }
  .title { font-size: 14px; }
  .tabs { padding: 0 12px; }
  .tab { padding: 11px 12px 10px; font-size: 12.5px; }
  main { padding: 12px; gap: 10px; }
  .card { padding: 12px 12px 11px; }
  .row { grid-template-columns: 1fr; gap: 0; }
  .row .field:first-child { margin-bottom: 10px; }
  .btn.primary.big { padding: 11px 14px; font-size: 13px; }
}
