/* pay-per-ask-v1 — self-contained per prototype principle. */

* { box-sizing: border-box; }
body { margin: 0; background: var(--bg); color: var(--text); font-family: var(--font-sans); -webkit-font-smoothing: antialiased; }
img, svg { display: block; max-width: 100%; }
button { font: inherit; color: inherit; background: none; border: 0; padding: 0; cursor: pointer; }
a { color: inherit; text-decoration: none; }
textarea, input { font: inherit; color: inherit; background: none; border: 0; outline: 0; }

/* ============ APP SHELL ============ */
.app-shell {
  display: grid;
  grid-template-columns: 260px minmax(0, 680px) 320px;
  gap: 24px;
  max-width: 1280px;
  margin: 0 auto;
  padding: 24px;
}

/* ============ SIDEBAR ============ */
.sidebar { position: sticky; top: 24px; height: calc(100vh - 48px); display: flex; flex-direction: column; justify-content: space-between; }
.brand { display: flex; align-items: center; gap: 14px; font-size: 32px; font-weight: 800; margin-bottom: 36px; color: var(--text); }
.brand img { width: 42px; height: 42px; object-fit: contain; }
.sidebar nav { display: flex; flex-direction: column; gap: 8px; }
.sidebar nav a {
  padding: 14px 18px; color: var(--text-soft); border-radius: 999px; font-weight: 600; font-size: 16px;
  transition: background 0.15s, color 0.15s, box-shadow 0.15s;
}
.sidebar nav a.active, .sidebar nav a:hover { background: var(--surface); color: var(--text); box-shadow: var(--shadow-card); }
.new-post { border-radius: 999px; background: var(--cta-bg); color: var(--cta-text); font-weight: 700; padding: 14px 22px; font-size: 16px; }

/* ============ MAIN ============ */
.main { min-width: 0; }

.topbar {
  display: flex; align-items: center; justify-content: space-between;
  margin-bottom: 18px; min-height: 44px;
}
.topbar h1 { font-size: 28px; margin: 0; font-weight: 700; letter-spacing: -0.01em; }
.topbar-brand { display: none; align-items: center; gap: 8px; color: var(--text); font-weight: 800; font-size: 22px; letter-spacing: -0.01em; }
.topbar-brand img { width: 24px; height: 24px; object-fit: contain; }

.card { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius-md); box-shadow: var(--shadow-card); }

/* ============ AVATAR ============ */
.avatar { width: 42px; height: 42px; border-radius: 50%; display: grid; place-items: center; color: white; font-weight: 800; flex-shrink: 0; user-select: none; }
.avatar.g1 { background: linear-gradient(135deg, var(--primary), var(--ai)); }
.avatar.g2 { background: linear-gradient(135deg, var(--ai), var(--info)); }
.avatar.g3 { background: linear-gradient(135deg, var(--success), var(--ai)); }
.avatar.g4 { background: linear-gradient(135deg, var(--accent), var(--accent-warm)); }
.avatar.g5 { background: linear-gradient(135deg, var(--primary), var(--accent)); }

/* ============ COMPOSER ============ */
.composer {
  padding: 20px;
  margin-bottom: 18px;
}
.composer-h {
  display: flex; align-items: center; justify-content: space-between;
  margin-bottom: 14px;
}
.composer-h h2 { font-size: 18px; font-weight: 700; margin: 0; }
.composer-h .ai-badge {
  display: inline-flex; align-items: center; gap: 4px;
  background: var(--primary-soft);
  color: var(--primary-dark);
  font-size: 11px; font-weight: 700;
  padding: 4px 9px; border-radius: 999px;
  letter-spacing: 0.04em;
}

.composer .to-row {
  display: flex; align-items: center; gap: 10px;
  margin-bottom: 14px;
  font-size: 13px;
  color: var(--text-soft);
}
.composer .picker {
  display: flex; gap: 8px;
  overflow-x: auto;
}
.composer .pick {
  display: flex; flex-direction: column; align-items: center; gap: 4px;
  padding: 4px;
  border-radius: 12px;
  flex-shrink: 0;
  transition: background 0.15s;
}
.composer .pick:hover { background: var(--surface-soft); }
.composer .pick.active {
  background: var(--primary-soft);
}
.composer .pick .avatar { width: 36px; height: 36px; font-size: 14px; }
.composer .pick small { color: var(--text-soft); font-size: 11px; }
.composer .pick.active small { color: var(--primary-dark); font-weight: 700; }

.composer textarea {
  width: 100%;
  min-height: 88px;
  font-size: 15px;
  line-height: 1.6;
  resize: vertical;
  padding: 4px 0;
}

.composer .reward {
  display: flex; align-items: center; gap: 12px;
  margin-top: 14px;
  padding: 12px 14px;
  background: var(--surface-soft);
  border-radius: 12px;
}
.composer .reward .lbl {
  font-size: 13px; color: var(--text-soft); font-weight: 600;
  flex: 1;
}
.composer .reward input {
  width: 70px;
  text-align: right;
  font-size: 18px;
  font-weight: 800;
  color: var(--text);
  font-variant-numeric: tabular-nums;
}
.composer .reward .unit { color: var(--text-soft); font-weight: 700; font-size: 13px; }

/* AI preview chip — appears as user types */
.ai-preview {
  margin-top: 14px;
  padding: 12px 14px;
  border: 1px dashed var(--primary);
  border-radius: 12px;
  background: linear-gradient(180deg, var(--surface), var(--primary-soft));
  font-size: 13px;
  color: var(--text);
  display: none;
}
.ai-preview.show { display: block; animation: fadeIn 0.18s; }
.ai-preview .row {
  display: flex; justify-content: space-between; align-items: center;
  margin-top: 6px;
}
.ai-preview .row b { font-weight: 700; }
.ai-preview .head {
  display: flex; align-items: center; gap: 6px;
  font-weight: 700; font-size: 12px; color: var(--primary-dark);
  text-transform: uppercase; letter-spacing: 0.06em;
  margin-bottom: 8px;
}
.ai-preview .rec.pass { color: var(--success); }
.ai-preview .rec.revise { color: var(--warning); }

@keyframes fadeIn { from { opacity: 0; transform: translateY(-2px); } to { opacity: 1; transform: none; } }

.composer .send-row {
  display: flex; gap: 10px; align-items: center;
  margin-top: 16px;
}
.composer .send-row .hint {
  flex: 1; font-size: 12px; color: var(--text-soft);
}
.composer .send-btn {
  padding: 12px 22px;
  border-radius: 999px;
  background: linear-gradient(135deg, var(--primary), var(--primary-dark));
  color: white;
  font-weight: 800; font-size: 14px;
  transition: opacity 0.15s;
}
.composer .send-btn:disabled { opacity: 0.5; cursor: default; }

/* ============ TABS ============ */
.tabs {
  display: flex;
  border-bottom: 1px solid var(--line);
  margin-bottom: 4px;
}
.tabs .tab {
  flex: 1;
  padding: 14px 8px;
  text-align: center;
  color: var(--text-soft);
  font-weight: 600;
  font-size: 15px;
  border-bottom: 2px solid transparent;
  margin-bottom: -1px;
  white-space: nowrap;
  transition: color 0.15s, border-color 0.15s, background 0.15s;
}
.tabs .tab.active { color: var(--text); border-bottom-color: var(--text); }
.tabs .tab:hover:not(.active) { color: var(--text); background: var(--surface-soft); }

/* ============ ASK CARDS ============ */
.ask { padding: 18px 20px; margin-bottom: 14px; }
.ask-head { display: flex; align-items: center; gap: 12px; }
.ask-head .who { flex: 1; min-width: 0; }
.ask-head .who b { display: block; font-weight: 700; font-size: 14px; }
.ask-head .who small { display: block; color: var(--text-soft); font-size: 12px; margin-top: 2px; }
.ask-head .badge {
  font-size: 11px; font-weight: 800; letter-spacing: 0.06em;
  padding: 5px 10px; border-radius: 999px;
  text-transform: uppercase;
  display: inline-flex; align-items: center; gap: 6px;
}
.ask-head .badge::before { content: ""; width: 6px; height: 6px; border-radius: 50%; }
.ask-head .badge.pending { background: rgba(59,130,246,0.12); color: var(--secondary); }
.ask-head .badge.pending::before { background: var(--secondary); }
.ask-head .badge.review { background: rgba(245,158,11,0.14); color: #b45309; }
.ask-head .badge.review::before { background: var(--warning); }
.ask-head .badge.resolved { background: rgba(16,185,129,0.14); color: #047857; }
.ask-head .badge.resolved::before { background: var(--success); }
.ask-head .badge.filtered { background: rgba(239,68,68,0.12); color: var(--error); }
.ask-head .badge.filtered::before { background: var(--error); }

.ask-q {
  margin-top: 12px;
  padding: 12px 14px;
  background: var(--surface-soft);
  border-radius: 12px;
  font-size: 14px;
  line-height: 1.65;
  position: relative;
}
.ask-q::before {
  content: "Q";
  position: absolute;
  top: 12px; left: 14px;
  background: var(--text);
  color: white;
  font-size: 10px;
  font-weight: 800;
  width: 18px; height: 18px;
  border-radius: 50%;
  display: grid; place-items: center;
}
.ask-q .text {
  padding-left: 26px;
  white-space: pre-wrap;
}

.ask-meta {
  margin-top: 10px;
  display: flex; justify-content: space-between;
  font-size: 12px;
  color: var(--text-soft);
}
.ask-meta .reward b { color: var(--text); font-weight: 700; }

/* Answer block (for review / resolved) */
.ask-a {
  margin-top: 14px;
  padding: 14px;
  background: linear-gradient(180deg, var(--surface), var(--primary-soft));
  border-radius: 12px;
  font-size: 14px; line-height: 1.65;
  position: relative;
}
.ask-a::before {
  content: "A";
  position: absolute;
  top: 12px; left: 14px;
  background: var(--primary);
  color: white;
  font-size: 10px;
  font-weight: 800;
  width: 18px; height: 18px;
  border-radius: 50%;
  display: grid; place-items: center;
}
.ask-a .text {
  padding-left: 26px;
  white-space: pre-wrap;
}
.ask-a small {
  display: block;
  margin-top: 8px; padding-left: 26px;
  color: var(--text-soft);
  font-size: 12px;
}

/* AI quality scorecard (in review state) */
.ai-score {
  margin-top: 14px;
  padding: 16px;
  border-radius: 14px;
  border: 1px solid var(--line);
  background: var(--surface);
}
.ai-score .h {
  display: flex; align-items: center; justify-content: space-between;
  font-weight: 700; font-size: 13px;
  margin-bottom: 12px;
}
.ai-score .h .left { display: flex; align-items: center; gap: 8px; }
.ai-score .ai-tag {
  background: var(--primary);
  color: white;
  font-size: 10px;
  font-weight: 800;
  padding: 3px 7px;
  border-radius: 999px;
  letter-spacing: 0.06em;
}
.ai-score .h .rec {
  font-size: 11px; font-weight: 800;
  padding: 4px 9px; border-radius: 999px;
  text-transform: uppercase;
}
.ai-score .h .rec.pass { background: rgba(16,185,129,0.14); color: #047857; }
.ai-score .h .rec.revise { background: rgba(245,158,11,0.14); color: #b45309; }

.score-row { display: flex; align-items: center; gap: 12px; margin-bottom: 8px; }
.score-row .k { font-size: 12px; color: var(--text-soft); width: 88px; font-weight: 600; }
.score-row .bar {
  flex: 1; height: 6px; border-radius: 999px;
  background: var(--surface-soft);
  overflow: hidden;
}
.score-row .bar .fill {
  height: 100%; border-radius: 999px;
}
.score-row .v {
  font-size: 12px; font-weight: 800;
  width: 36px; text-align: right;
  font-variant-numeric: tabular-nums;
}
.fill.high { background: var(--success); }
.fill.mid { background: var(--warning); }
.fill.low { background: var(--error); }
.v.high { color: var(--success); }
.v.mid { color: #b45309; }
.v.low { color: var(--error); }

.ai-note {
  margin-top: 10px;
  font-size: 12px;
  color: var(--text-soft);
  line-height: 1.55;
  padding: 8px 10px;
  background: var(--surface-soft);
  border-radius: 8px;
}

.ask-actions {
  margin-top: 14px;
  display: flex; gap: 10px;
}
.ask-actions button {
  flex: 1;
  padding: 12px;
  border-radius: 999px;
  font-weight: 700; font-size: 14px;
}
.ask-actions .accept {
  background: linear-gradient(135deg, var(--primary), var(--primary-dark));
  color: white;
}
.ask-actions .revise {
  background: var(--surface);
  border: 1px solid var(--line);
  color: var(--text);
}
.ask-actions .revise:hover { background: var(--surface-soft); }

/* Filter explanation card */
.ask-filter {
  margin-top: 12px;
  padding: 12px 14px;
  border-radius: 12px;
  background: rgba(239,68,68,0.06);
  border: 1px solid rgba(239,68,68,0.18);
  font-size: 13px;
  line-height: 1.6;
}
.ask-filter .h {
  display: flex; align-items: center; gap: 6px;
  font-weight: 800; font-size: 12px;
  color: var(--error);
  margin-bottom: 6px;
  text-transform: uppercase; letter-spacing: 0.04em;
}
.ask-filter p { margin: 0; color: var(--text); }
.ask-filter small { display: block; margin-top: 6px; color: var(--text-soft); }
.ask-actions .edit {
  background: var(--surface);
  border: 1px solid var(--line);
}

.resolved-meta {
  margin-top: 12px;
  font-size: 12px; color: var(--success);
  display: flex; align-items: center; gap: 6px;
  font-weight: 700;
}

/* ============ RIGHT PANEL ============ */
.right-panel { display: flex; flex-direction: column; gap: 18px; }
.right-panel .card { padding: 20px; }
.right-panel h2 { font-size: 16px; margin: 0 0 12px; font-weight: 700; }

.wallet-snap {
  background: linear-gradient(135deg, var(--primary), var(--primary-dark));
  color: white;
}
.wallet-snap h2 { color: rgba(255,255,255,0.85); margin-bottom: 8px; }
.wallet-snap .bal { font-size: 22px; font-weight: 800; letter-spacing: -0.01em; font-variant-numeric: tabular-nums; }
.wallet-snap .bal small { font-size: 12px; font-weight: 700; opacity: 0.85; margin-left: 4px; }
.wallet-snap .usd { color: rgba(255,255,255,0.78); font-size: 12px; margin-top: 4px; }

/* Creators prices list */
.prices { list-style: none; padding: 0; margin: 0; display: flex; flex-direction: column; gap: 12px; }
.prices li { display: flex; align-items: center; gap: 12px; }
.prices .meta { flex: 1; min-width: 0; }
.prices .meta b { display: block; font-weight: 700; font-size: 13px; }
.prices .meta small { color: var(--text-soft); font-size: 12px; }
.prices .price {
  font-weight: 800; font-size: 14px;
  font-variant-numeric: tabular-nums;
  color: var(--text);
}
.prices .price small { font-size: 11px; font-weight: 600; opacity: 0.7; margin-left: 2px; }

/* Tips card */
.tips {
  background: linear-gradient(180deg, var(--surface), var(--primary-soft));
}
.tips ul { list-style: none; padding: 0; margin: 0; display: grid; gap: 8px; }
.tips li {
  display: flex; gap: 8px; font-size: 13px; line-height: 1.55;
}
.tips li::before { content: "·"; font-weight: 800; color: var(--primary); }

/* ============ MOBILE NAV ============ */
.mobile-nav { display: none; }

/* ============ RESPONSIVE ============ */
@media (max-width: 980px) {
  .app-shell {
    grid-template-columns: 1fr;
    padding: 12px;
    padding-bottom: 96px;
    gap: 12px;
  }
  .sidebar, .right-panel { display: none; }
  .topbar {
    position: sticky; top: 0; z-index: 10;
    background: rgba(248, 250, 252, 0.85);
    backdrop-filter: blur(16px);
    -webkit-backdrop-filter: blur(16px);
    padding: 12px 4px; margin: 0 0 12px;
  }
  .topbar h1 { display: none; }
  .topbar-brand { display: inline-flex; }

  .mobile-nav {
    position: fixed; left: 12px; right: 12px;
    bottom: calc(12px + env(safe-area-inset-bottom));
    display: grid; grid-template-columns: repeat(5, 1fr);
    align-items: center;
    background: rgba(255, 255, 255, 0.92);
    border: 1px solid var(--line); border-radius: 24px;
    box-shadow: var(--shadow-card); padding: 10px;
    backdrop-filter: blur(16px); -webkit-backdrop-filter: blur(16px);
    z-index: 20;
  }
  .mobile-nav a { text-align: center; font-size: 12px; color: var(--text-soft); padding: 8px 4px; }
  .mobile-nav a.active { color: var(--text); font-weight: 600; }
  .mobile-nav .compose-btn {
    width: 46px; height: 46px;
    margin: auto; padding: 0;
    border-radius: 50%;
    background: var(--cta-bg); color: var(--cta-text);
    display: grid; place-items: center; line-height: 1;
  }
}
