:root {
  --bg: #0b1220;
  --bg-soft: #121b2e;
  --panel: #16213a;
  --border: #253352;
  --text: #e8ecf6;
  --text-dim: #9aa8c7;
  --accent: #ffc512;
  --accent-dim: #6b5100;
  --danger: #ff6b6b;
  --radius: 10px;
  font-size: 16px;
}

* {
  box-sizing: border-box;
}

/* Any element with the `hidden` attribute must actually be hidden — author
   rules setting `display` on a class (e.g. `.btn { display: inline-block }`)
   otherwise beat the UA stylesheet's default regardless of specificity,
   since [hidden] there is just `display: none` with normal specificity too.
   This bit us three separate times (a stuck modal, a visible disabled
   button, a stuck oauth panel) before being fixed here once, globally. */
[hidden] {
  display: none !important;
}

body {
  margin: 0;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  background: var(--bg);
  color: var(--text);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  line-height: 1.5;
}

a {
  color: var(--accent);
  text-decoration: none;
}

a:hover {
  text-decoration: underline;
}

.nav {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 20px clamp(20px, 5vw, 64px);
  border-bottom: 1px solid var(--border);
}

/* The homepage nav (brand + About + Log in + Get started) is the widest
   nav on the site — at ~340px and below it no longer fits on one line and
   the "Get started" button clips past the viewport edge. Wrapping is the
   same fallback used for the sidebar-header buttons in the dashboard. */
@media (max-width: 400px) {
  .nav {
    flex-wrap: wrap;
    row-gap: 10px;
  }
}

.brand {
  display: flex;
  align-items: center;
  gap: 10px;
  font-weight: 700;
  font-size: 1.25rem;
  color: var(--text);
}

.brand .dot {
  height: 26px;
  width: auto;
  display: block;
}

.nav-links {
  display: flex;
  gap: 20px;
  align-items: center;
}

.btn {
  display: inline-block;
  padding: 10px 18px;
  border-radius: var(--radius);
  border: 1px solid var(--border);
  background: var(--panel);
  color: var(--text);
  cursor: pointer;
  font-size: 0.95rem;
  font-weight: 600;
}

.btn[hidden] {
  display: none;
}

.btn:hover {
  border-color: var(--accent);
  text-decoration: none;
}

.btn-primary {
  background: var(--accent);
  border-color: var(--accent);
  color: #201400;
}

.btn-primary:hover {
  filter: brightness(1.08);
}

.btn-danger {
  border-color: var(--danger);
  color: var(--danger);
  background: transparent;
}

.hero {
  max-width: 760px;
  margin: 0 auto;
  padding: clamp(48px, 10vw, 120px) 24px;
  text-align: center;
}

.hero h1 {
  font-size: clamp(2.2rem, 5vw, 3.4rem);
  margin: 0 0 16px;
  letter-spacing: -0.02em;
}

.hero p.lead {
  color: var(--text-dim);
  font-size: 1.15rem;
  margin: 0 0 32px;
}

.hero-actions {
  display: flex;
  gap: 12px;
  justify-content: center;
  flex-wrap: wrap;
}

.features {
  width: 100%;
  max-width: 960px;
  margin: 0 auto;
  padding: 40px 24px 100px;
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: 20px;
  /* .features is a grid container that's also a flex item of body's
     column flex layout — without an explicit width, auto-fit's column
     count can resolve against the grid's own max-content size instead of
     the flex-stretched width, so it never collapses to fewer columns on
     narrow screens. box-sizing: border-box (global) keeps the padding
     inside this 100%, so it still matches body's width exactly. */
}

.feature-card {
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 22px;
}

.feature-card h3 {
  margin: 0 0 8px;
  font-size: 1.05rem;
}

.feature-card p {
  margin: 0;
  color: var(--text-dim);
  font-size: 0.92rem;
}

.feature-card.live {
  border-color: var(--accent-dim);
  box-shadow: 0 0 0 1px var(--accent-dim) inset;
}

.badge {
  display: inline-block;
  font-size: 0.7rem;
  font-weight: 700;
  letter-spacing: 0.05em;
  text-transform: uppercase;
  padding: 2px 8px;
  border-radius: 999px;
  margin-bottom: 8px;
}

.badge.live {
  background: var(--accent-dim);
  color: var(--accent);
}

.badge.soon {
  background: var(--bg-soft);
  color: var(--text-dim);
  border: 1px solid var(--border);
}

.auth-wrap {
  max-width: 400px;
  margin: 80px auto;
  padding: 32px;
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: var(--radius);
}

.auth-wrap h1 {
  font-size: 1.5rem;
  margin: 0 0 6px;
}

.auth-wrap p.sub {
  color: var(--text-dim);
  margin: 0 0 24px;
  font-size: 0.9rem;
}

.oauth-buttons {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.oauth-btn {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  padding: 10px;
}

.oauth-icon {
  width: 18px;
  height: 18px;
  flex-shrink: 0;
}

.divider {
  display: flex;
  align-items: center;
  text-align: center;
  color: var(--text-dim);
  font-size: 0.8rem;
  margin: 20px 0;
}

.divider::before,
.divider::after {
  content: "";
  flex: 1;
  border-bottom: 1px solid var(--border);
}

.divider span {
  padding: 0 12px;
}

label {
  display: block;
  font-size: 0.85rem;
  color: var(--text-dim);
  margin: 14px 0 6px;
}

input, textarea, select {
  width: 100%;
  padding: 10px 12px;
  border-radius: 8px;
  border: 1px solid var(--border);
  background: var(--bg-soft);
  color: var(--text);
  font-size: 0.95rem;
  font-family: inherit;
}

input:focus, textarea:focus, select:focus {
  outline: none;
  border-color: var(--accent);
}

textarea {
  resize: vertical;
  min-height: 70px;
}

form .btn-primary {
  width: 100%;
  margin-top: 20px;
  padding: 12px;
}

.form-msg {
  margin-top: 14px;
  font-size: 0.88rem;
  color: var(--danger);
  min-height: 1.2em;
}

.form-msg.ok {
  color: #6fd58a;
}

.auth-wrap .switch {
  margin-top: 18px;
  text-align: center;
  font-size: 0.88rem;
  color: var(--text-dim);
}

/* Dashboard */
.app-shell {
  display: grid;
  grid-template-columns: 320px 1fr;
  flex: 1;
  min-height: 0;
}

/* The 320px fixed sidebar column leaves next to nothing for .main on any
   phone-width screen (it was measured squeezing .main down to ~40px wide)
   — stack sidebar above main instead of splitting columns below tablet
   width, the same "give up on side-by-side" fallback used for the nav. */
@media (max-width: 860px) {
  .app-shell {
    grid-template-columns: 1fr;
  }
  .sidebar {
    border-right: none;
    border-bottom: 1px solid var(--border);
  }
}

.sidebar {
  border-right: 1px solid var(--border);
  padding: 24px;
  display: flex;
  flex-direction: column;
  gap: 20px;
}

.sidebar-header {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 12px;
}

.analyze-box {
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 16px;
}

.analyze-box h3 {
  margin: 0 0 4px;
  font-size: 0.95rem;
}

.analyze-box p {
  margin: 0 0 12px;
  color: var(--text-dim);
  font-size: 0.82rem;
}

.profile-list {
  list-style: none;
  margin: 0;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: 8px;
  overflow-y: auto;
}

.profile-item {
  padding: 12px;
  border-radius: 8px;
  border: 1px solid transparent;
  cursor: pointer;
  background: var(--bg-soft);
}

.profile-item:hover {
  border-color: var(--border);
}

.profile-item.active {
  border-color: var(--accent);
}

.profile-item .name {
  font-weight: 600;
  font-size: 0.9rem;
}

.profile-item .url {
  font-size: 0.76rem;
  color: var(--text-dim);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.status-pill {
  display: inline-block;
  font-size: 0.68rem;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  padding: 1px 7px;
  border-radius: 999px;
  margin-top: 4px;
}

.status-pill.processing { background: #3a3212; color: #e8c85a; }
.status-pill.complete { background: #12321a; color: #6fd58a; }
.status-pill.failed { background: #3a1414; color: var(--danger); }
.status-pill.pending { background: var(--bg-soft); color: var(--text-dim); }

.main {
  padding: 32px clamp(20px, 4vw, 56px);
  overflow-y: auto;
}

.empty-state {
  color: var(--text-dim);
  margin-top: 80px;
  text-align: center;
}

.profile-editor {
  max-width: 720px;
}

.profile-editor h2 {
  margin: 0 0 4px;
}

.profile-editor .source {
  color: var(--text-dim);
  font-size: 0.85rem;
  margin-bottom: 24px;
}

.field-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0 20px;
}

.field-grid .full {
  grid-column: 1 / -1;
}

.editor-actions {
  display: flex;
  gap: 10px;
  margin-top: 24px;
}

.hint {
  color: var(--text-dim);
  font-size: 0.75rem;
  margin-top: 4px;
}

/* Footer */
#localtide-footer {
  background: transparent;
  border-top: 1px solid var(--border);
  margin-top: 40px;
}

.footer-inner {
  max-width: 1100px;
  margin: 0 auto;
  padding: 20px clamp(20px, 5vw, 64px);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  flex-wrap: wrap;
}

.footer-brand {
  color: var(--text-dim);
  font-size: 0.85rem;
}

.footer-links {
  display: flex;
  align-items: center;
  gap: 20px;
}

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

.footer-link-btn {
  background: none;
  border: none;
  color: var(--accent);
  font-size: 0.85rem;
  cursor: pointer;
  padding: 0;
  font-family: inherit;
}

.footer-link-btn:hover {
  text-decoration: underline;
}

/* Modal */
.modal-overlay {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(5, 8, 16, 0.7);
  align-items: center;
  justify-content: center;
  padding: 20px;
  z-index: 100;
}

/* `display: flex` here would win over the [hidden] UA rule's display:none
   in the cascade (author styles beat UA styles regardless of specificity),
   which is exactly what made the modal stuck open — only apply flex when
   the hidden attribute is actually absent. */
.modal-overlay:not([hidden]) {
  display: flex;
}

.modal {
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  width: 100%;
  max-width: 440px;
  padding: 24px;
}

.modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 12px;
}

.modal-header h3 {
  margin: 0;
}

.modal-close {
  background: none;
  border: none;
  color: var(--text-dim);
  font-size: 1.4rem;
  line-height: 1;
  cursor: pointer;
}

.disclaimer {
  color: var(--text-dim);
  font-size: 0.78rem;
  margin: 14px 0 0;
}

.check-email-box {
  text-align: center;
  padding: 8px 0;
}

.check-email-box h2 {
  font-size: 1.2rem;
  margin: 0 0 10px;
}

.check-email-box p {
  color: var(--text-dim);
  font-size: 0.92rem;
  line-height: 1.5;
}

/* Feature requests */
.fr-wrap {
  max-width: 720px;
  margin: 0 auto;
  padding: 40px 24px;
}

.fr-wrap h1 {
  margin: 0 0 4px;
}

.fr-wrap p.sub {
  color: var(--text-dim);
  margin: 0 0 28px;
}

.fr-new-box {
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 20px;
  margin-bottom: 32px;
}

.fr-new-box h3 {
  margin: 0 0 4px;
}

.fr-similar {
  background: var(--bg-soft);
  border: 1px solid var(--accent-dim);
  border-radius: 8px;
  padding: 14px;
  margin-top: 14px;
  font-size: 0.88rem;
}

.fr-similar ul {
  margin: 8px 0 12px;
  padding-left: 18px;
}

.fr-similar li {
  margin-bottom: 8px;
}

.fr-list {
  list-style: none;
  margin: 0;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.fr-item {
  display: flex;
  gap: 14px;
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 14px 16px;
  align-items: flex-start;
}

.fr-vote {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  min-width: 56px;
  padding: 8px 6px;
  border-radius: 8px;
  border: 1px solid var(--border);
  background: var(--bg-soft);
  color: var(--text);
  cursor: pointer;
}

.fr-vote:hover {
  border-color: var(--accent);
}

.fr-vote.voted {
  border-color: var(--accent);
  background: var(--accent-dim);
  color: var(--accent);
}

.fr-vote-count {
  font-weight: 700;
  font-size: 1.05rem;
}

.fr-vote-label {
  font-size: 0.65rem;
  text-transform: uppercase;
  color: var(--text-dim);
}

.fr-body {
  flex: 1;
}

.fr-title-row {
  display: flex;
  align-items: center;
  gap: 10px;
}

.fr-title {
  font-weight: 600;
}

.fr-desc {
  margin: 6px 0 0;
  color: var(--text-dim);
  font-size: 0.88rem;
}

.status-pill.planned { background: #1a2a4a; color: #7fa8ff; }
.status-pill.shipped { background: #12321a; color: #6fd58a; }
.status-pill.declined { background: var(--bg-soft); color: var(--text-dim); }
.status-pill.open { background: #3a3212; color: #e8c85a; }
.status-pill.resolved { background: #12321a; color: #6fd58a; }
.status-pill.urgent { background: #3a1414; color: var(--danger); }

/* Admin help */
.admin-wrap {
  max-width: 820px;
  margin: 0 auto;
  padding: 40px 24px;
}

.admin-wrap h1 {
  margin: 0 0 16px;
}

.help-list {
  list-style: none;
  margin: 20px 0 0;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: 14px;
}

.help-item {
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 16px;
}

.help-item.urgent {
  border-color: var(--danger);
}

.urgency-check {
  display: flex;
  gap: 20px;
  margin: 14px 0 0;
  font-size: 0.88rem;
}

.urgency-check label {
  display: flex;
  align-items: center;
  gap: 6px;
  margin: 0;
  color: var(--text);
  font-size: inherit;
  cursor: pointer;
}

.urgency-check input {
  width: auto;
}

.help-item-header {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-bottom: 8px;
}

.help-email {
  font-weight: 600;
}

.help-date {
  color: var(--text-dim);
  font-size: 0.78rem;
  margin-left: auto;
}

.help-message {
  margin: 0 0 8px;
  white-space: pre-wrap;
}

.help-item details {
  margin-bottom: 10px;
}

.help-item summary {
  cursor: pointer;
  color: var(--text-dim);
  font-size: 0.82rem;
}

.help-item pre {
  background: var(--bg-soft);
  border-radius: 8px;
  padding: 10px;
  font-size: 0.78rem;
  overflow-x: auto;
}

.ai-solution {
  background: var(--bg-soft);
  border-left: 3px solid var(--accent);
  padding: 10px 14px;
  border-radius: 6px;
  margin-bottom: 10px;
  font-size: 0.9rem;
}

.help-actions {
  display: flex;
  gap: 10px;
}

/* Quick login (PIN/passkey) on login.html */
#quick-login .switch {
  margin-top: 16px;
  text-align: center;
  font-size: 0.88rem;
}

#pin-input {
  text-align: center;
  letter-spacing: 0.3em;
  font-size: 1.2rem;
}

/* Security settings page */
.security-wrap {
  max-width: 640px;
  margin: 0 auto;
  padding: 40px 24px;
}

.security-wrap h1 {
  margin: 0 0 4px;
}

.security-wrap h2 {
  margin: 32px 0 12px;
  font-size: 1.1rem;
}

.security-wrap > p.sub {
  color: var(--text-dim);
  margin: 0 0 28px;
}

.security-box {
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 20px;
  margin-bottom: 16px;
}

.security-box h3 {
  margin: 0 0 6px;
}

.security-box form {
  display: flex;
  gap: 10px;
  align-items: flex-start;
  margin-top: 12px;
  flex-wrap: wrap;
}

.security-box form input {
  width: auto;
  flex: 1;
  min-width: 140px;
}

.credential-list {
  list-style: none;
  margin: 0;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.credential-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 12px 16px;
}

.credential-label {
  font-weight: 600;
}

/* Sidebar header actions (app.html) — compact buttons since three of them
   have to fit across the 320px sidebar alongside the brand above them. */
.sidebar-header-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  width: 100%;
}

.sidebar-header-actions .btn {
  padding: 6px 10px;
  font-size: 0.82rem;
}

/* Promo redeem widget (app.html sidebar) */
.promo-box {
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 12px 16px;
}

.promo-box summary {
  cursor: pointer;
  font-size: 0.88rem;
  color: var(--text-dim);
}

.promo-box form {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 10px;
}

.promo-box form input {
  flex: 1;
}

.promo-box form .form-msg {
  flex-basis: 100%;
}

.uppercase-input {
  text-transform: uppercase;
}

.promo-code-row {
  display: flex;
  gap: 8px;
}

.promo-code-row input {
  flex: 1;
}

/* Admin stats + promo code management */
.admin-stats {
  display: flex;
  gap: 16px;
  margin-bottom: 24px;
}

.stat-tile {
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 16px 24px;
}

.stat-value {
  font-size: 1.8rem;
  font-weight: 700;
}

.stat-label {
  color: var(--text-dim);
  font-size: 0.8rem;
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

.admin-wrap h2 {
  margin: 32px 0 12px;
  font-size: 1.1rem;
}

.admin-box {
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 20px;
  margin-bottom: 16px;
}

.promo-list {
  list-style: none;
  margin: 0 0 12px;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

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

.promo-code {
  font-weight: 700;
  font-family: monospace;
  letter-spacing: 0.05em;
}

/* Legal pages */
.legal-wrap {
  max-width: 720px;
  margin: 0 auto;
  padding: 48px 24px 80px;
}

.legal-wrap h1 {
  margin: 0 0 4px;
}

.legal-updated {
  color: var(--text-dim);
  font-size: 0.85rem;
  margin: 0 0 28px;
}

.legal-wrap h2 {
  margin: 32px 0 10px;
  font-size: 1.1rem;
}

.legal-wrap p,
.legal-wrap li {
  color: var(--text-dim);
  line-height: 1.65;
}

.legal-wrap ul {
  padding-left: 20px;
  margin: 10px 0;
}

.legal-wrap li {
  margin-bottom: 6px;
}

.legal-wrap strong {
  color: var(--text);
}

/* Credit balance stat (app.html sidebar) */
.credit-stat {
  display: block;
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 8px 16px;
  font-size: 0.85rem;
  font-weight: 600;
  text-decoration: none;
  color: var(--text);
}

/* Billing page */
.billing-wrap {
  max-width: 640px;
  margin: 0 auto;
  padding: 40px 24px;
}

.billing-wrap h1 {
  margin: 0 0 4px;
}

.billing-wrap > p.sub {
  color: var(--text-dim);
  margin: 0 0 28px;
}

.billing-wrap h2 {
  margin: 32px 0 12px;
  font-size: 1.1rem;
}

.billing-box {
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 20px;
}

.plan-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
}

.plan-name {
  font-size: 1.3rem;
  font-weight: 700;
}

.credit-count {
  font-size: 1.3rem;
  font-weight: 700;
}

.billing-actions {
  display: flex;
  gap: 10px;
  margin-top: 16px;
}

.transaction-list {
  list-style: none;
  margin: 0;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

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

.transaction-reason {
  font-weight: 600;
}

.transaction-amount {
  font-weight: 700;
  font-family: monospace;
}

.transaction-amount.positive {
  color: var(--success, #2e9c5c);
}

.transaction-amount.negative {
  color: var(--text-dim);
}
