/* Refract web app — extends style.css's tokens with mobile-first, thumb-driven layout */

html, body.app-body {
  height: 100%;
  overflow-x: hidden;
}
body.app-body {
  display: flex;
  flex-direction: column;
  padding-bottom: env(safe-area-inset-bottom);
}

/* ── Top bar ── */
.app-topbar {
  position: sticky; top: 0; z-index: 30;
  background: rgba(15,17,23,0.92);
  backdrop-filter: blur(10px);
  border-bottom: 0.5px solid var(--border);
}
.app-topbar-inner {
  display: flex; align-items: center; justify-content: space-between;
  max-width: 680px;
  margin: 0 auto;
  padding: 14px 18px;
}
.app-brand { font-size: 16px; gap: 8px; }
.app-topbar-right { display: flex; align-items: center; gap: 10px; }
.credits-chip {
  font-family: var(--mono); font-size: 11px; color: var(--blue);
  background: rgba(79,126,255,0.1); border: 0.5px solid rgba(79,126,255,0.3);
  border-radius: 5px; padding: 4px 9px;
}
.icon-btn {
  background: none; border: none; color: var(--muted); font-size: 16px;
  cursor: pointer; padding: 4px 6px; border-radius: 5px;
}
.icon-btn:hover { color: var(--blue); }

.account-panel {
  position: absolute; top: 54px; right: 14px; z-index: 40;
  background: var(--surface); border: 0.5px solid var(--border); border-radius: 10px;
  padding: 14px 16px; box-shadow: 0 12px 30px -8px rgba(0,0,0,0.5);
  min-width: 200px;
}
.account-email { font-size: 12px; color: var(--body); margin-bottom: 10px; word-break: break-all; }
.text-btn {
  background: none; border: 0.5px solid var(--border); color: var(--muted);
  font-size: 12px; padding: 7px 12px; border-radius: 6px; cursor: pointer; width: 100%;
  margin-bottom: 8px;
}
.text-btn:hover { color: var(--red); border-color: var(--red); }
.text-btn-secondary:hover { color: var(--blue); border-color: var(--blue); }

/* ── Main layout ── */
.app-main {
  flex: 1;
  max-width: 680px;
  width: 100%;
  margin: 0 auto;
  padding: 20px 18px 100px;
  box-sizing: border-box;
}

/* ── Auth screen ── */
.auth-screen { padding-top: 48px; text-align: center; }
.auth-screen h1 { font-size: 30px; margin-bottom: 10px; }
.auth-lede { color: var(--muted); font-size: 15px; margin-bottom: 28px; }
.app-input {
  display: block; width: 100%; margin-bottom: 10px;
  padding: 13px 14px; background: var(--surface); border: 0.5px solid var(--border);
  border-radius: 8px; color: var(--white); font-size: 15px; font-family: var(--sans);
}
.app-input:focus { outline: none; border-color: var(--blue); }
.btn-block { width: 100%; margin-bottom: 10px; }
.app-warning {
  font-size: 13px; color: var(--amber); text-align: left;
  background: rgba(232,160,32,0.08); border: 0.5px solid rgba(232,160,32,0.25);
  border-radius: 6px; padding: 8px 12px; margin-bottom: 10px;
}
.remember-row {
  display: flex; justify-content: space-between; align-items: center;
  margin-bottom: 12px; font-size: 12px;
}
.remember-label { display: flex; align-items: center; gap: 6px; color: var(--muted); cursor: pointer; }
.remember-label input { accent-color: var(--blue); cursor: pointer; }
#forgotPasswordLink { color: var(--blue); text-decoration: none; }
#forgotPasswordLink:hover { text-decoration: underline; }
.auth-switch {
  text-align: center; font-size: 13px; color: var(--muted); margin-top: 14px;
}
.auth-switch a { color: var(--blue); text-decoration: none; font-weight: 500; }
.auth-switch a:hover { text-decoration: underline; }

/* ── Input card ── */
.input-card {
  background: var(--surface); border: 0.5px solid var(--border); border-radius: 12px;
  padding: 16px; margin-bottom: 16px;
}
.article-textarea {
  width: 100%; background: var(--bg); border: 0.5px solid var(--border); border-radius: 8px;
  padding: 12px 13px; color: var(--body); font-size: 14px; font-family: var(--sans);
  resize: vertical; line-height: 1.5; margin-bottom: 10px;
}
.article-textarea:focus { outline: none; border-color: var(--blue); }
.url-hint { font-size: 12px; color: var(--blue); margin-bottom: 10px; }
.image-upload-row { margin-bottom: 12px; }
.image-upload-btn {
  background: var(--bg); border: 0.5px solid var(--border); border-radius: 7px;
  color: var(--muted); font-size: 12px; font-family: var(--sans);
  padding: 8px 14px; cursor: pointer; transition: border-color 0.15s, color 0.15s;
}
.image-upload-btn:hover { border-color: var(--blue); color: var(--blue); }
.image-upload-btn:disabled { opacity: 0.5; cursor: default; }

/* Base segmented toggle — this only ever existed in the extension's own
   stylesheet, which the web app doesn't load, so it needs its own copy. */
.mode-toggle {
  display: flex;
  gap: 4px;
  background: var(--bg);
  border: 0.5px solid var(--border);
  border-radius: 9px;
  padding: 4px;
}
.mode-btn {
  flex: 1;
  border: none;
  border-radius: 6px;
  background: transparent;
  color: var(--muted);
  font-family: var(--sans);
  font-weight: 600;
  font-size: 13px;
  cursor: pointer;
  transition: background 0.15s, color 0.15s;
}
.mode-btn.active {
  background: var(--blue);
  color: white;
}

.app-mode-toggle { margin-bottom: 0; }
.app-mode-toggle .mode-btn {
  display: flex; flex-direction: column; align-items: center; gap: 2px;
  padding: 10px 6px;
}
.mode-cost { font-size: 9px; color: var(--muted); font-family: var(--mono); }
.mode-btn.active .mode-cost { color: rgba(255,255,255,0.7); }

/* ── Status / loading ── */
.status-card {
  display: flex; align-items: center; gap: 12px;
  background: var(--surface); border: 0.5px solid var(--border); border-radius: 12px;
  padding: 18px; margin-bottom: 16px;
}
.status-spinner {
  width: 22px; height: 22px; border-radius: 50%;
  border: 2px solid var(--border); border-top-color: var(--blue);
  animation: app-spin 0.8s linear infinite; flex-shrink: 0;
}
@keyframes app-spin { to { transform: rotate(360deg); } }
.status-text { font-size: 14px; color: var(--body); }
.status-card-staged { flex-direction: column; align-items: stretch; gap: 14px; }
.status-card-staged .status-spinner { margin: 0 auto; }
.status-stages { display: flex; flex-direction: column; gap: 5px; }
.status-stage {
  font-size: 13px; color: var(--border); text-align: center;
  padding: 4px 0; transition: color 0.2s;
}
.status-stage.active { color: var(--blue); font-weight: 500; }
.status-stage.done { color: var(--green); }
.status-error {
  background: rgba(224,82,82,0.08); border: 0.5px solid rgba(224,82,82,0.25);
  border-radius: 12px; padding: 16px; margin-bottom: 16px; color: #f0b4b4; font-size: 14px;
}

/* ── Results: reuse extension's visual language, scaled up for touch ── */
.result-block { margin-bottom: 14px; }
.matrix-wrap {
  background: var(--surface); border: 0.5px solid var(--border); border-radius: 14px; padding: 18px;
}
.matrix-top { display: flex; align-items: center; gap: 14px; padding-bottom: 14px; border-bottom: 0.5px solid var(--border); margin-bottom: 14px; }
.overall-circle {
  width: 76px; height: 76px; border-radius: 50%; border: 4px solid var(--border);
  display: flex; flex-direction: column; align-items: center; justify-content: center; flex-shrink: 0;
}
.overall-number { font-family: var(--mono); font-size: 24px; font-weight: 500; }
.overall-label { font-size: 8px; color: var(--muted); letter-spacing: 0.1em; text-transform: uppercase; }
.overall-title { font-family: var(--serif); font-size: 15px; color: var(--white); line-height: 1.35; margin-bottom: 5px; }
.overall-pub { font-size: 12px; color: var(--muted); margin-bottom: 6px; }
.verdict-badge { display: inline-block; padding: 3px 10px; border-radius: 5px; font-size: 11px; font-weight: 600; }
.matrix-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.matrix-help {
  margin-top: 14px; padding-top: 14px; border-top: 0.5px solid var(--border);
  font-size: 12px; color: var(--muted); line-height: 1.6;
}
.matrix-help b { color: var(--body); font-weight: 600; }
.matrix-cell { background: var(--bg); border: 0.5px solid var(--border); border-radius: 9px; padding: 12px; }
.matrix-cell-label { font-size: 10px; font-weight: 600; color: var(--muted); text-transform: uppercase; letter-spacing: 0.05em; margin-bottom: 5px; }
.matrix-cell-score { font-family: var(--mono); font-size: 22px; font-weight: 500; margin-bottom: 6px; }
.matrix-cell-sub { font-size: 10px; color: var(--muted); }
.matrix-cell-bar { height: 3px; background: var(--border); border-radius: 2px; margin-top: 6px; }
.matrix-cell-bar-fill { height: 100%; border-radius: 2px; }

.section-card { background: var(--surface); border: 0.5px solid var(--border); border-radius: 12px; padding: 16px; margin-bottom: 10px; }
.section-label { font-size: 11px; font-weight: 600; color: var(--blue); letter-spacing: 0.06em; margin-bottom: 10px; }
.mini-summary { font-size: 13px; color: var(--muted); line-height: 1.6; margin-top: 10px; }

.lean-track { position: relative; height: 5px; background: linear-gradient(to right, #4f7eff, #7a8499, #e05252); border-radius: 3px; margin-bottom: 6px; }
.lean-dot { position: absolute; top: 50%; width: 13px; height: 13px; background: white; border-radius: 50%; border: 2px solid var(--bg); transform: translate(-50%,-50%); }
.lean-labels { display: flex; justify-content: space-between; font-size: 10px; color: var(--muted); }
.lean-value { text-align: center; font-size: 14px; font-weight: 500; color: var(--white); margin-top: 8px; }

.purpose-badge { display: inline-block; padding: 4px 11px; border-radius: 5px; font-size: 11px; font-weight: 600; margin-bottom: 8px; }
.claims-row { display: flex; gap: 24px; margin-bottom: 12px; }
.claim-stat { text-align: center; }
.claim-number { font-family: var(--mono); font-size: 24px; font-weight: 500; }
.claim-label { font-size: 10px; color: var(--muted); text-transform: uppercase; letter-spacing: 0.05em; }

.bar-row { margin-bottom: 10px; }
.bar-meta { display: flex; justify-content: space-between; margin-bottom: 4px; font-size: 12px; }
.bar-name { color: var(--muted); }
.bar-track { height: 4px; background: var(--border); border-radius: 2px; }
.bar-fill { height: 100%; border-radius: 2px; }

.flag-item { display: flex; gap: 8px; align-items: flex-start; padding: 9px 11px; border-radius: 8px; margin-bottom: 6px; font-size: 12.5px; line-height: 1.5; }
.flag-warn { background: rgba(224,82,82,0.08); border: 0.5px solid rgba(224,82,82,0.25); color: #f0b4b4; }
.flag-good { background: rgba(52,196,138,0.08); border: 0.5px solid rgba(52,196,138,0.25); color: #a8dfc6; }
.flag-neutral { background: rgba(122,132,153,0.08); border: 0.5px solid var(--border); color: var(--muted); }

.loaded-terms { display: flex; flex-wrap: wrap; gap: 5px; margin-top: 8px; }
.loaded-term { padding: 3px 8px; background: rgba(232,160,32,0.1); border: 0.5px solid rgba(232,160,32,0.3); border-radius: 4px; font-size: 11px; color: var(--amber); font-family: var(--mono); }

.funding-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; margin-bottom: 12px; }
.funding-item { background: var(--bg); border: 0.5px solid var(--border); border-radius: 7px; padding: 10px 11px; }
.funding-label { font-size: 9px; color: var(--muted); text-transform: uppercase; letter-spacing: 0.05em; margin-bottom: 4px; }
.funding-value { font-size: 12px; color: var(--body); }

.advice-card {
  background: linear-gradient(135deg, rgba(79,126,255,0.08), rgba(108,99,255,0.06));
  border: 0.5px solid rgba(79,126,255,0.2); border-radius: 12px; padding: 16px; margin-bottom: 14px;
}
.advice-label { font-size: 11px; color: var(--blue); font-weight: 600; margin-bottom: 8px; }
.advice-text { font-family: var(--serif); font-size: 15px; color: var(--white); line-height: 1.7; }
.expand-toggle-btn {
  width: 100%; padding: 12px; margin-bottom: 14px;
  background: var(--surface); border: 0.5px solid var(--border); border-radius: 9px;
  color: var(--blue); font-size: 13px; font-weight: 600; font-family: var(--sans);
  cursor: pointer;
}
.expand-toggle-btn:hover { border-color: var(--blue); }

.consensus-card { background: var(--surface); border: 0.5px solid var(--border); border-radius: 12px; padding: 14px 16px; margin-bottom: 12px; }
.consensus-top { display: flex; justify-content: space-between; align-items: center; margin-bottom: 10px; }
.consensus-label { font-size: 11px; font-weight: 600; color: var(--muted); }
.consensus-badge { font-size: 10px; font-weight: 700; padding: 3px 9px; border-radius: 5px; border: 0.5px solid; }
.model-badges { display: flex; gap: 6px; margin-bottom: 6px; }
.model-badge { flex: 1; text-align: center; padding: 9px 5px; border-radius: 8px; border: 0.5px solid var(--border); }
.model-badge.failed { background: rgba(224,82,82,0.06); border-color: rgba(224,82,82,0.2); }
.model-name { display: block; font-size: 10px; font-weight: 600; margin-bottom: 3px; }
.model-score { display: block; font-family: var(--mono); font-size: 17px; font-weight: 500; }
.contested-note { font-size: 11px; color: var(--amber); margin-top: 6px; }

/* Deep verify claim cards */
.dv-header-card { display: flex; align-items: center; gap: 16px; margin-bottom: 16px; }
.dv-score-circle { width: 64px; height: 64px; border-radius: 50%; border: 4px solid; display: flex; flex-direction: column; align-items: center; justify-content: center; flex-shrink: 0; }
.dv-score-num { font-family: var(--mono); font-size: 22px; font-weight: 500; }
.dv-score-lbl { font-size: 8px; color: var(--muted); text-transform: uppercase; }
.dv-stats { display: flex; gap: 20px; }
.dv-stat { text-align: center; }
.dv-stat-num { font-family: var(--mono); font-size: 20px; font-weight: 500; }
.dv-stat-lbl { font-size: 9px; color: var(--muted); text-transform: uppercase; }
.dv-claim { border: 0.5px solid; border-radius: 12px; padding: 14px 16px; margin-bottom: 10px; }
.dv-claim-header { display: flex; align-items: center; gap: 8px; margin-bottom: 8px; flex-wrap: wrap; }
.dv-verdict-label { font-size: 11px; font-weight: 700; letter-spacing: 0.04em; }
.dv-claim-type { font-size: 10px; color: var(--muted); border: 0.5px solid var(--border); border-radius: 3px; padding: 2px 6px; margin-left: auto; }
.dv-claim-text { font-family: var(--serif); font-size: 14px; color: var(--body); line-height: 1.55; margin-bottom: 8px; font-style: italic; }
.dv-explanation { font-size: 13px; color: var(--muted); line-height: 1.55; margin-bottom: 6px; }
.dv-accuracy-note { font-size: 12px; color: var(--amber); background: rgba(232,160,32,0.08); border: 0.5px solid rgba(232,160,32,0.2); border-radius: 5px; padding: 6px 9px; margin: 6px 0; }
.dv-source { display: flex; align-items: center; gap: 8px; margin-top: 8px; padding-top: 8px; border-top: 0.5px solid rgba(255,255,255,0.06); flex-wrap: wrap; font-size: 12px; color: var(--muted); }
.dv-source a { color: var(--blue); text-decoration: none; font-weight: 500; }

.export-btn, .reset-btn {
  width: 100%; padding: 13px; border-radius: 9px; font-size: 14px; font-weight: 600;
  font-family: var(--sans); cursor: pointer; margin-bottom: 8px;
}
.export-btn { background: var(--blue); color: white; border: none; }
.reset-btn { background: none; border: 0.5px solid var(--border); color: var(--muted); }

/* ── Upgrade ── */
.upgrade-area { margin-top: 6px; }
.upgrade-heading { display: flex; align-items: center; gap: 10px; margin-bottom: 14px; }
.error-icon-inline { font-size: 20px; color: var(--amber); }
.plan-list { display: flex; flex-direction: column; gap: 8px; }
.plan-row {
  display: flex; align-items: center; gap: 12px; width: 100%; padding: 14px 16px;
  background: var(--surface); border: 0.5px solid var(--border); border-radius: 10px;
  cursor: pointer; text-align: left; font-family: var(--sans);
}
.plan-row:hover { border-color: var(--blue); }
.plan-row:disabled { opacity: 0.5; }
.plan-name { font-family: var(--serif); font-size: 15px; color: var(--white); flex: 0 0 76px; }
.plan-detail { font-size: 12px; color: var(--muted); flex: 1; }
.plan-price { font-family: var(--mono); font-size: 15px; color: var(--blue); font-weight: 500; }

/* ── Sticky action bar ── */
/* Mobile default: a full-bleed bar pinned to the bottom of the viewport,
   always reachable with a thumb no matter how far you've scrolled into
   results. */
.action-bar {
  position: sticky; bottom: 0; z-index: 20;
  margin: 0 -18px 16px;
  background: rgba(15,17,23,0.95); backdrop-filter: blur(10px);
  border-top: 0.5px solid var(--border);
}
.action-bar-inner {
  max-width: 680px;
  margin: 0 auto;
  padding: 12px 18px calc(12px + env(safe-area-inset-bottom));
}
.action-bar .btn { margin-bottom: 0; }
.action-bar .btn:disabled { background: var(--surface2); color: var(--muted); cursor: not-allowed; }

/* Tablet and up: a mouse doesn't need a viewport-anchored button — let it
   sit in normal flow, right under the input card where it visually
   belongs, instead of pinned far away at the bottom of a tall window. */
@media (min-width: 640px) {
  .action-bar {
    position: static;
    margin: 0 0 20px;
    background: none;
    backdrop-filter: none;
    border-top: none;
  }
  .action-bar-inner { padding: 0; max-width: none; }
  /* No longer need space reserved for a full-bleed bar pinned to the
     viewport bottom — the button's back in normal flow now. */
  .app-main { padding-bottom: 40px; }
}

.hidden { display: none !important; }

/* ── Tablet and up: a touch more breathing room, still one column — this
   is a focused tool, not a marketing page, so it stays vertical at any
   width rather than spreading into multiple columns. ── */
@media (min-width: 640px) {
  .app-main { padding-top: 32px; padding-left: 28px; padding-right: 28px; }
  .app-topbar-inner { padding-left: 28px; padding-right: 28px; }
  .action-bar-inner { padding-left: 28px; padding-right: 28px; }
  .auth-screen { padding-top: 64px; }
  .auth-screen h1 { font-size: 34px; }
}

/* ── Desktop: cap line length for comfortable reading, centre with visible
   page edges either side so it doesn't feel like a mobile page stretched
   thin across a big monitor. ── */
@media (min-width: 900px) {
  .app-topbar-inner, .app-main, .action-bar-inner { max-width: 760px; }
  .input-card { padding: 20px; }
  .article-textarea { font-size: 15px; }
}

/* Keep the account popover from ever running off the right edge on very
   narrow phones. */
@media (max-width: 380px) {
  .account-panel { right: 8px; left: 8px; min-width: unset; }
}
