/* PokeRom Dex — phone web app. Mobile-first, light theme, red/white. */
* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  font-family: -apple-system, "Segoe UI", Roboto, sans-serif;
  background: #ffffff;
  color: #1f2937;
  font-size: 15px;
  line-height: 1.45;
  padding-bottom: env(safe-area-inset-bottom);
}
header { background: #dc2626; color: #fff; padding: calc(10px + env(safe-area-inset-top)) 16px 12px; }
header h1 { margin: 0; font-size: 20px; }
.header-logo { width: 28px; height: 28px; vertical-align: -6px; border-radius: 50%; }
header p { margin: 4px 0 0; font-size: 13px; opacity: .92; }
.a2hs {
  display: flex; flex-direction: column; gap: 4px; position: relative;
  background: #fef2f2; border-bottom: 1px solid #fecaca;
  color: #7f1d1d; padding: 12px 40px 12px 16px; font-size: 14px;
}
.a2hs button {
  position: absolute; top: 8px; right: 8px; width: 32px; height: 32px;
  background: none; border: none; color: #991b1b; font-size: 16px; cursor: pointer;
}
.game-bar {
  display: flex; align-items: center; gap: 10px;
  background: #ffffff; padding: 10px 16px; border-bottom: 1px solid #e5e7eb;
}
.game-bar label { font-weight: 700; font-size: 14px; color: #6b7280; }
.game-bar select { flex: 1; margin-bottom: 0; }
.tabs { display: flex; background: #ffffff; position: sticky; top: 0; z-index: 10; border-bottom: 1px solid #e5e7eb; }
.tabs button {
  flex: 1; min-width: 0; min-height: 48px; padding: 10px 2px;
  background: none; border: none; color: #6b7280; font-weight: 700; font-size: 13px;
  cursor: pointer; border-bottom: 3px solid transparent;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.tabs button.active { color: #dc2626; border-bottom-color: #dc2626; }
.tabs button:disabled { color: #d1d5db; cursor: not-allowed; }
main { padding: 14px 16px; max-width: 640px; margin: 0 auto; }
input, select {
  width: 100%; min-height: 48px; padding: 12px;
  border-radius: 10px; border: 1px solid #d1d5db; background: #ffffff; color: #1f2937;
  font-size: 16px; /* 16px stops iOS zooming the field on focus */
  margin-bottom: 10px;
}
.row { display: flex; gap: 10px; }
.row input, .row select { flex: 1; min-width: 0; }
button.go {
  width: 100%; min-height: 50px; padding: 12px; border: none; border-radius: 10px;
  background: #dc2626; color: #fff; font-weight: 700; font-size: 16px;
  cursor: pointer; margin-bottom: 12px;
}
button.go:hover, button.go:active { background: #b91c1c; }
button.go.team-add { width: auto; flex: 0 0 auto; margin-bottom: 10px; padding: 12px 20px; }
.card { background: #ffffff; border: 1px solid #e5e7eb; border-radius: 12px; padding: 14px; margin-bottom: 12px; box-shadow: 0 1px 3px rgba(0, 0, 0, .06); }
.card h2 { margin: 0 0 6px; font-size: 19px; }
.card h3 { margin: 12px 0 4px; font-size: 14px; color: #dc2626; }
.card p { margin: 4px 0; }
.type {
  display: inline-block; padding: 3px 10px; border-radius: 20px;
  background: #fee2e2; color: #991b1b; font-size: 13px; font-weight: 700; margin-right: 4px;
}
/* Pokédex list (pane-dex): full scrollable list, one row per species. */
#dex-list-out { margin-bottom: 12px; }
.dex-row {
  display: grid; grid-template-columns: 56px 1fr 44px; gap: 10px; align-items: center;
  background: #ffffff; border: 1px solid #e5e7eb; border-radius: 10px;
  padding: 6px 10px 6px 4px; margin-bottom: 6px; cursor: pointer; min-height: 56px;
}
.dex-row:active { border-color: #dc2626; }
.dex-row .sprite { width: 56px; height: 56px; float: none; }
.dex-num { color: #6b7280; font-size: 13px; font-weight: 700; margin-right: 6px; }
.dex-info b { font-size: 16px; }
.dex-info .type { margin-top: 2px; }
.dex-add {
  width: 44px; height: 44px; min-height: 44px; padding: 0;
  border: none; border-radius: 50%;
  background: #dc2626; color: #fff; font-size: 24px; font-weight: 700; line-height: 1;
  cursor: pointer;
}
.dex-add:hover, .dex-add:active { background: #b91c1c; }
.dex-add.added { background: #15803d; font-size: 18px; }
.dex-add.added:hover, .dex-add.added:active { background: #15803d; }
.dex-add:disabled { cursor: default; opacity: .95; }
#dex-msg { color: #991b1b; font-weight: 700; font-size: 14px; margin-bottom: 8px; }
#dex-msg:empty { display: none; }
.sprite { width: 96px; height: 96px; image-rendering: pixelated; float: right; }
/* Trainer sprite slot: hidden until integration fills its src (see app.js). */
.trainer-sprite { display: none; width: 96px; height: 96px; float: right; }
.stats { display: grid; grid-template-columns: 1fr 1fr; gap: 2px 14px; margin-top: 8px; }
.stats div { display: flex; justify-content: space-between; border-bottom: 1px solid #e5e7eb; padding: 4px 0; }
.moves { columns: 2; margin: 4px 0; }
.moves li, ul.plain li { margin-bottom: 3px; }
ul.plain { margin: 4px 0; padding-left: 20px; }
.muted { color: #6b7280; font-size: 13px; }
.warn { background: #fffbeb; border: 1px solid #f59e0b; border-radius: 10px; padding: 10px; font-size: 14px; margin-bottom: 12px; color: #92400e; }
.team-member { border-top: 1px solid #e5e7eb; padding: 10px 0; }
.team-member:first-of-type { border-top: none; }
.team-member b { font-size: 16px; }
.pill {
  display: inline-block; background: #f9fafb; border: 1px solid #d1d5db;
  border-radius: 6px; padding: 2px 8px; font-size: 13px; margin: 2px 2px 2px 0;
}
.result-item {
  width: 100%; min-height: 52px; text-align: left; background: #ffffff; color: #1f2937;
  border: 1px solid #d1d5db; border-radius: 10px; padding: 10px; margin-bottom: 8px; cursor: pointer;
  font-size: 15px;
}
.result-item:hover, .result-item:active { border-color: #dc2626; }
.result-item small { color: #6b7280; display: block; font-size: 13px; }
.social-row { display: flex; gap: 10px; flex-wrap: wrap; margin: 8px 0; }
.social-link {
  display: inline-flex; align-items: center; gap: 6px; min-height: 44px;
  padding: 10px 14px; border: 1px solid #e5e7eb; border-radius: 10px;
  color: #1f2937; text-decoration: none; font-weight: 700; font-size: 14px;
}
.social-link:hover, .social-link:active { border-color: #dc2626; color: #dc2626; }
.social-link svg { width: 20px; height: 20px; flex: 0 0 auto; fill: currentColor; }
.footer-social { margin-top: 16px; }
/* Team Builder markup (rendered by team-builder.js) */
.def-row { display: flex; justify-content: space-between; align-items: center; gap: 8px; border-bottom: 1px solid #e5e7eb; padding: 6px 0; font-size: 14px; }
.def-row:last-child { border-bottom: none; }
.def-row .counts { color: #6b7280; font-size: 13px; }
.def-row .weak { color: #dc2626; font-weight: 700; }
.def-row .res { color: #15803d; }
.alert { background: #fef2f2; border: 1px solid #fecaca; border-radius: 10px; padding: 10px; margin: 12px 0; }
.setbox { background: #fff7ed; border: 1px solid #fed7aa; border-radius: 10px; padding: 10px; margin: 10px 0; }
.setbox h4 { margin: 0 0 6px; font-size: 14px; color: #9a3412; }
.setbox .moves { font-weight: 600; }
.alert h4 { margin: 0 0 6px; font-size: 14px; color: #991b1b; }
.alert.good { background: #f0fdf4; border-color: #bbf7d0; }
.alert.good h4 { color: #166534; }
.calc { border-top: 1px solid #e5e7eb; padding-top: 10px; margin-top: 12px; }
.calc h3 { margin: 0 0 4px; font-size: 14px; color: #dc2626; }
.note { color: #6b7280; font-size: 13px; }
footer { padding: 0 16px 20px; color: #6b7280; font-size: 12px; max-width: 640px; margin: 0 auto; }
/* Ask AI chat — floating button (lower right, every tab) + popup panel */
#chat-fab {
  position: fixed;
  right: calc(16px + env(safe-area-inset-right));
  bottom: calc(16px + env(safe-area-inset-bottom));
  z-index: 40;
  display: inline-flex; align-items: center; gap: 8px;
  min-height: 52px; padding: 12px 18px;
  border: none; border-radius: 999px;
  background: #dc2626; color: #fff; font-weight: 700; font-size: 15px;
  box-shadow: 0 4px 14px rgba(185, 28, 28, .35);
  cursor: pointer;
}
#chat-fab:hover, #chat-fab:active { background: #b91c1c; }
#chat-fab[aria-expanded="true"] { background: #991b1b; }
#chat-fab svg { width: 22px; height: 22px; flex: 0 0 auto; fill: currentColor; }
.chat-panel {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 50;
  display: flex; flex-direction: column;
  height: 85vh; height: 85dvh;
  background: #ffffff; border-top: 1px solid #e5e7eb;
  border-radius: 16px 16px 0 0;
  box-shadow: 0 -6px 24px rgba(0, 0, 0, .18);
  padding: 12px 16px calc(10px + env(safe-area-inset-bottom));
}
/* Author display:flex above would otherwise override the hidden attribute. */
.chat-panel[hidden] { display: none; }
.chat-panel-head { display: flex; align-items: flex-start; gap: 10px; flex: 0 0 auto; }
.chat-panel-head h2 { margin: 0; font-size: 18px; flex: 1; }
#chat-close {
  width: 36px; height: 36px; flex: 0 0 auto; padding: 0;
  border: 1px solid #e5e7eb; border-radius: 50%;
  background: #f9fafb; color: #6b7280; font-size: 15px; line-height: 1; cursor: pointer;
}
#chat-close:hover, #chat-close:active { border-color: #dc2626; color: #dc2626; }
.chat-panel-note { margin: 6px 0 10px; flex: 0 0 auto; }
.chat-examples { display: flex; flex-wrap: wrap; gap: 8px; margin-bottom: 12px; flex: 0 0 auto; }
.chat-chip {
  border: 1px solid #fecaca; background: #fef2f2; color: #991b1b;
  border-radius: 999px; padding: 8px 12px; font-size: 13px; font-weight: 600; cursor: pointer;
}
.chat-chip:hover, .chat-chip:active { background: #fee2e2; }
#chat-log { display: flex; flex-direction: column; gap: 8px; margin-bottom: 12px; flex: 1 1 auto; overflow-y: auto; min-height: 0; }
#chat-log:empty { display: none; }
.chat-msg {
  max-width: 88%; padding: 10px 12px; border-radius: 12px; font-size: 14px;
  overflow-wrap: break-word;
}
.chat-msg.user { align-self: flex-end; background: #dc2626; color: #fff; border-bottom-right-radius: 4px; }
.chat-msg.bot { align-self: flex-start; background: #f9fafb; border: 1px solid #e5e7eb; border-bottom-left-radius: 4px; }
.chat-msg.error { background: #fffbeb; border-color: #f59e0b; color: #92400e; }
.chat-msg.pending { color: #6b7280; }
.chat-input-row { flex: 0 0 auto; }
.chat-input-row input { margin-bottom: 0; }
#chat-send { width: auto; flex: 0 0 auto; margin-bottom: 0; padding: 12px 20px; }
#chat-send:disabled { opacity: .6; cursor: wait; }
a { color: #dc2626; }
/* PokeRom Dex Pro: header button, return-from-checkout notice, paywall */
.pro-btn {
  flex: 0 0 auto; min-height: 48px; padding: 10px 14px;
  border: none; border-radius: 10px;
  background: #dc2626; color: #fff; font-weight: 700; font-size: 14px; cursor: pointer;
}
.pro-btn:hover, .pro-btn:active { background: #b91c1c; }
.sub-notice {
  display: flex; align-items: center; gap: 10px;
  background: #f0fdf4; border-bottom: 1px solid #bbf7d0;
  color: #166534; padding: 12px 16px; font-size: 14px; font-weight: 600;
}
.sub-notice[hidden] { display: none; }
.sub-notice span { flex: 1; }
.sub-notice button {
  flex: 0 0 auto; width: 32px; height: 32px;
  background: none; border: none; color: #166534; font-size: 16px; cursor: pointer;
}
.paywall {
  position: fixed; inset: 0; z-index: 60;
  display: flex; align-items: center; justify-content: center;
  background: rgba(31, 41, 55, .55); padding: 16px;
}
/* Author display:flex above would otherwise override the hidden attribute. */
.paywall[hidden] { display: none; }
.paywall-card {
  position: relative; background: #ffffff; border-radius: 16px;
  width: 100%; max-width: 520px; max-height: 90vh; max-height: 90dvh; overflow-y: auto;
  padding: 18px; box-shadow: 0 10px 34px rgba(0, 0, 0, .28);
}
.paywall-card h2 { margin: 0 32px 4px 0; font-size: 20px; }
#paywall-close {
  position: absolute; top: 10px; right: 10px; width: 36px; height: 36px; padding: 0;
  border: 1px solid #e5e7eb; border-radius: 50%;
  background: #f9fafb; color: #6b7280; font-size: 15px; line-height: 1; cursor: pointer;
}
#paywall-close:hover, #paywall-close:active { border-color: #dc2626; color: #dc2626; }
.paywall-cols { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; margin: 12px 0; }
.paywall-col { border: 1px solid #e5e7eb; border-radius: 12px; padding: 10px 12px; }
.paywall-col h3 { margin: 0 0 6px; font-size: 14px; }
.paywall-col ul { margin: 0; font-size: 13px; }
.paywall-col.pro { border-color: #dc2626; background: #fef2f2; }
.paywall-col.pro h3 { color: #dc2626; }
.paywall-email-label { display: block; font-size: 13px; font-weight: 700; color: #6b7280; margin-bottom: 6px; }
.paywall-msg { min-height: 20px; margin: 2px 0 10px; color: #991b1b; font-weight: 600; font-size: 14px; }
.paywall-msg:empty { margin: 0; min-height: 0; }
button.go.secondary { background: #ffffff; color: #dc2626; border: 1px solid #dc2626; }
button.go.secondary:hover, button.go.secondary:active { background: #fef2f2; }
button.go[hidden] { display: none; }
@media (min-width: 700px) {
  .moves { columns: 3; }
  /* On wider screens the chat panel floats over the lower-right corner
     instead of spanning the full width as a bottom sheet. */
  .chat-panel {
    left: auto; width: 440px; max-width: calc(100vw - 32px);
    right: 16px; bottom: 16px;
    border: 1px solid #e5e7eb; border-radius: 16px;
    height: min(620px, 85vh); height: min(620px, 85dvh);
  }
}

/* Home email signup card (beehiiv embed — same form as pokeromhub.com).
   Deep red so the form's white input and amber button pop like they do
   on the hub's dark signup cards. */
.signup-card { background: linear-gradient(135deg, #991b1b, #7f1d1d); border: none; color: #fff; }
.signup-card h3 { color: #fff; font-size: 17px; margin-top: 0; display: flex; align-items: center; gap: 8px; }
.signup-card h3 svg { width: 20px; height: 20px; fill: #fbbf24; flex: 0 0 auto; }
.signup-card p { color: #fee2e2; }
.signup-card .fineprint { font-size: 12.5px; color: #fca5a5; margin-top: 8px; }
.signup-card .beehiiv-form { width: 100%; max-width: 440px; margin: 10px auto 0; background: transparent; border-radius: 12px; overflow: hidden; }
.signup-card .beehiiv-form iframe { display: block; width: 100% !important; max-width: 100% !important; min-width: 0 !important; border: 0; }
