/* ============================================================
   ReaderWrites — Public Stylesheet
   Book-like reading experience with polish
   ============================================================ */

/* ── Reset / scope ── */
.rw-story-wrap *,
.rw-story-wrap *::before,
.rw-story-wrap *::after { box-sizing: border-box; }

/* ── Design tokens ── */
.rw-story-wrap {
    --rw-ink:       #1a1a1a;
    --rw-mid:       #4b5563;
    --rw-muted:     #9ca3af;
    --rw-rule:      #e5e7eb;
    --rw-accent:    #6366f1;
    --rw-accent2:   #3b82f6;
    --rw-gold:      #f59e0b;
    --rw-success:   #059669;
    --rw-danger:    #dc2626;
    --rw-serif:     Georgia, 'Times New Roman', serif;
    --rw-sans:      system-ui, -apple-system, sans-serif;
}

/* ============================================================
   Reading Progress Bar (fixed, top of viewport)
   ============================================================ */
.rw-reading-progress {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    height: 3px;
    z-index: 9999;
    background: transparent;
    pointer-events: none;
}

.rw-reading-progress-bar {
    height: 100%;
    width: 0%;
    background: linear-gradient(90deg, var(--rw-accent, #6366f1), var(--rw-accent2, #3b82f6));
    transition: width .1s linear;
}

/* ============================================================
   Story Wrapper
   ============================================================ */
.rw-story-wrap {
    max-width: 700px;
    margin: 0 auto;
    font-family: Georgia, 'Times New Roman', serif;
    color: #1a1a1a;
}

/* ============================================================
   Story Header — with cover image
   ============================================================ */
.rw-story-cover {
    position: relative;
    border-radius: 12px;
    overflow: hidden;
    margin-bottom: 28px;
    min-height: 280px;
}

.rw-cover-img {
    width: 100%;
    height: 340px;
    object-fit: cover;
    display: block;
}

.rw-cover-overlay {
    position: absolute;
    inset: 0;
    background: linear-gradient(to bottom, transparent 30%, rgba(0,0,0,.7) 100%);
}

.rw-cover-text {
    position: absolute;
    bottom: 0;
    left: 0;
    right: 0;
    padding: 28px 32px;
}

.rw-story-title {
    font-family: Georgia, 'Times New Roman', serif;
    font-size: clamp(24px, 5vw, 38px);
    font-weight: normal;
    line-height: 1.2;
    color: #fff;
    margin: 0 0 8px;
    text-shadow: 0 1px 4px rgba(0,0,0,.3);
}

.rw-story-header-plain .rw-story-title {
    color: #1a1a1a;
    margin: 0 0 6px;
    font-size: clamp(22px, 4vw, 34px);
}

.rw-story-genre {
    font-family: system-ui, sans-serif;
    font-size: 12px;
    font-weight: 700;
    letter-spacing: 2.5px;
    text-transform: uppercase;
    color: rgba(255,255,255,.75);
    margin: 0;
}

.rw-story-header-plain .rw-story-genre {
    color: #9ca3af;
    margin-bottom: 0;
}

.rw-story-header-plain {
    padding-bottom: 8px;
}

/* ── Meta bar ── */
.rw-story-meta { margin-bottom: 32px; }

.rw-stats-row {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 8px;
    margin-bottom: 14px;
}

.rw-stat {
    font-family: system-ui, sans-serif;
    font-size: 13px;
    color: #4b5563;
}

.rw-stat-divider { color: #d1d5db; }
.rw-stat--live    { color: #059669; font-weight: 600; }
.rw-stat--complete { color: #6366f1; font-weight: 600; }

/* ── Progress bar ── */
.rw-progress-wrap {
    display: flex;
    align-items: center;
    gap: 10px;
    margin-bottom: 14px;
}

.rw-progress-track {
    flex: 1;
    height: 5px;
    background: #e5e7eb;
    border-radius: 99px;
    overflow: hidden;
}

.rw-progress-fill {
    height: 100%;
    background: linear-gradient(90deg, #6366f1, #3b82f6);
    border-radius: 99px;
    transition: width .6s ease;
}

.rw-progress-label {
    font-family: system-ui, sans-serif;
    font-size: 11px;
    color: #9ca3af;
    white-space: nowrap;
}

/* ── Export row ── */
.rw-export-row { margin-top: 6px; }

.rw-btn--export {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    font-family: system-ui, sans-serif;
    font-size: 13px;
    font-weight: 600;
    color: #6366f1;
    background: #ede9fe;
    border: 1px solid #c4b5fd;
    border-radius: 8px;
    padding: 7px 14px;
    text-decoration: none;
    transition: all .2s;
}

.rw-btn--export:hover { background: #ddd6fe; color: #4338ca; }

/* ============================================================
   Story Body
   ============================================================ */
.rw-story-body {
    padding-top: 8px;
    margin-bottom: 56px;
}

/* ── Fade-in animation ── */
.rw-fade-in {
    opacity: 0;
    transform: translateY(16px);
    transition: opacity .5s ease, transform .5s ease;
}

.rw-fade-in.rw-visible {
    opacity: 1;
    transform: translateY(0);
}

/* ── Segment base ── */
.rw-segment {
    padding: 36px 0;
    border-bottom: 1px solid #f0f0f0;
}

.rw-segment:last-of-type { border-bottom: none; }

/* ── Opening segment ── */
.rw-segment--opening {
    padding-top: 8px;
}

/* ── Drop cap ── */
.rw-drop-cap p:first-child::first-letter {
    float: left;
    font-size: 4.2em;
    line-height: 0.78;
    margin: 5px 8px 0 0;
    font-family: Georgia, serif;
    color: #6366f1;
}

/* ── Featured segment ── */
.rw-segment--featured {
    background: #fffbeb;
    border-left: 3px solid #f59e0b;
    padding: 32px 28px;
    border-radius: 6px;
    margin: 8px -4px;
    border-bottom: none;
}

.rw-featured-flag {
    font-family: system-ui, sans-serif;
    font-size: 11px;
    font-weight: 700;
    letter-spacing: 1px;
    text-transform: uppercase;
    color: #b45309;
    margin-bottom: 14px;
}

/* ── Chapter mark ── */
.rw-chapter-mark {
    display: flex;
    align-items: center;
    gap: 12px;
    margin-bottom: 20px;
}

.rw-chapter-mark::before,
.rw-chapter-mark::after {
    content: '';
    flex: 1;
    height: 1px;
    background: #e5e7eb;
}

.rw-chapter-num {
    font-family: system-ui, sans-serif;
    font-size: 11px;
    font-weight: 700;
    color: #9ca3af;
    letter-spacing: 1px;
    min-width: 24px;
    text-align: center;
}

/* ── Segment text ── */
.rw-segment-text {
    font-size: 18px;
    line-height: 1.82;
    color: #1a1a1a;
}

.rw-segment-text p       { margin: 0 0 1.1em; }
.rw-segment-text p:last-child { margin-bottom: 0; }

/* ── Segment footer ── */
.rw-segment-footer {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-top: 18px;
    gap: 8px;
    flex-wrap: wrap;
}

.rw-attribution {
    display: flex;
    align-items: center;
    gap: 8px;
    font-family: system-ui, sans-serif;
    font-size: 13px;
    color: #6b7280;
}

.rw-avatar {
    border-radius: 50%;
    flex-shrink: 0;
}

.rw-attr-name { font-weight: 500; color: #374151; }

/* ── Badges ── */
.rw-badge {
    display: inline-flex;
    align-items: center;
    gap: 3px;
    background: #ede9fe;
    color: #5b21b6;
    font-size: 10px;
    font-weight: 700;
    padding: 2px 7px;
    border-radius: 20px;
    font-family: system-ui, sans-serif;
    cursor: default;
    letter-spacing: .2px;
}

/* ── Vote button ── */
.rw-vote-btn {
    display: inline-flex;
    align-items: center;
    gap: 5px;
    background: #f9fafb;
    border: 1px solid #e5e7eb;
    border-radius: 20px;
    padding: 5px 12px;
    font-size: 13px;
    font-family: system-ui, sans-serif;
    cursor: pointer;
    transition: all .2s;
    color: #374151;
}

.rw-vote-btn:hover:not(:disabled) {
    background: #ede9fe;
    border-color: #a78bfa;
    color: #5b21b6;
}

.rw-vote-btn.rw-voted,
.rw-vote-btn:disabled {
    background: #ede9fe;
    border-color: #a78bfa;
    color: #6d28d9;
    cursor: default;
}

.rw-vote-count { font-weight: 700; }

/* ── Story end ── */
.rw-story-end {
    text-align: center;
    padding: 48px 0 24px;
    border-top: 1px solid #e5e7eb;
    margin-top: 16px;
}

.rw-end-mark {
    font-family: system-ui, sans-serif;
    font-size: 14px;
    letter-spacing: 4px;
    color: #9ca3af;
    margin-bottom: 16px;
}

.rw-end-cta {
    font-family: system-ui, sans-serif;
    font-size: 14px;
    color: #6b7280;
}

.rw-end-cta a { color: #6366f1; font-weight: 600; text-decoration: none; }
.rw-end-cta a:hover { text-decoration: underline; }

/* ============================================================
   Contribute Section
   ============================================================ */
.rw-contribute-section {
    background: #fafafa;
    border: 1px solid #e5e7eb;
    border-radius: 12px;
    padding: 36px;
    margin-top: 40px;
}

.rw-contribute-title {
    font-family: system-ui, sans-serif;
    font-size: 20px;
    font-weight: 700;
    color: #1a1a1a;
    margin: 0 0 8px;
}

.rw-contribute-sub {
    font-family: system-ui, sans-serif;
    font-size: 14px;
    color: #6b7280;
    margin: 0 0 24px;
    line-height: 1.5;
}

/* ============================================================
   Submission Form
   ============================================================ */
.rw-rules-box {
    background: #fff;
    border-left: 3px solid #6366f1;
    border-radius: 4px;
    padding: 12px 16px;
    margin-bottom: 18px;
    font-family: system-ui, sans-serif;
    font-size: 13px;
    color: #374151;
    line-height: 1.5;
}

.rw-field { margin-bottom: 18px; }

.rw-contribution-text {
    all: revert !important;
    width: 100% !important;
    box-sizing: border-box !important;
    padding: 16px !important;
    border: 2px solid #d1d5db !important;
    border-radius: 10px !important;
    font-family: Georgia, serif !important;
    font-size: 17px !important;
    line-height: 1.7 !important;
    color: #1a1a1a !important;
    background: #fff !important;
    resize: vertical !important;
    transition: border-color .2s !important;
    display: block !important;
    min-height: 160px !important;
}

.rw-contribution-text:focus {
    outline: none !important;
    border-color: #6366f1 !important;
    box-shadow: 0 0 0 3px rgba(99,102,241,.12) !important;
}

/* ── Word counter ── */
.rw-counter-row {
    display: flex;
    align-items: center;
    gap: 12px;
    margin-top: 8px;
}

.rw-word-counter {
    display: flex;
    align-items: baseline;
    gap: 4px;
    font-family: system-ui, sans-serif;
    font-size: 13px;
    color: #6b7280;
    flex-shrink: 0;
}

.rw-word-count-number { font-weight: 800; font-size: 15px; color: #111; transition: color .2s; }
.rw-counter-sep,
.rw-counter-max       { color: #d1d5db; }
.rw-counter-label     { color: #9ca3af; }
.rw-counter-status    { font-weight: 600; font-size: 12px; }

.rw-wc-ok   .rw-word-count-number,
.rw-counter-status.ok   { color: #059669; }
.rw-wc-warn .rw-word-count-number,
.rw-counter-status.warn { color: #d97706; }
.rw-wc-over .rw-word-count-number,
.rw-counter-status.over { color: #dc2626; }

.rw-counter-bar-wrap {
    flex: 1;
    height: 4px;
    background: #e5e7eb;
    border-radius: 99px;
    overflow: hidden;
}

.rw-counter-bar {
    height: 100%;
    width: 0%;
    border-radius: 99px;
    background: #d1d5db;
    transition: width .15s ease, background .2s;
}

.rw-counter-bar.ok   { background: #34d399; }
.rw-counter-bar.warn { background: #fbbf24; }
.rw-counter-bar.over { background: #f87171; }

/* ── Legal ── */
.rw-field--legal { }

.rw-legal-label {
    display: flex;
    gap: 10px;
    align-items: flex-start;
    font-family: system-ui, sans-serif;
    font-size: 12px;
    color: #6b7280;
    line-height: 1.6;
    cursor: pointer;
}

.rw-legal-label input[type="checkbox"] {
    margin-top: 2px;
    flex-shrink: 0;
    width: 15px;
    height: 15px;
    accent-color: #6366f1;
}

/* ── Submit button row ── */
.rw-field--actions {
    display: flex;
    align-items: center;
    gap: 14px;
    flex-wrap: wrap;
}

.rw-submit-hint {
    font-family: system-ui, sans-serif;
    font-size: 12px;
    color: #9ca3af;
    font-style: italic;
}

/* ── Buttons ── */
.rw-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    padding: 11px 24px;
    border-radius: 8px;
    font-family: system-ui, sans-serif;
    font-size: 15px;
    font-weight: 600;
    cursor: pointer;
    text-decoration: none;
    border: none;
    transition: all .2s;
    line-height: 1;
}

.rw-btn--primary {
    background: linear-gradient(135deg, #6366f1, #3b82f6);
    color: #fff;
}

.rw-btn--primary:hover:not(:disabled) {
    opacity: .9;
    transform: translateY(-1px);
    box-shadow: 0 4px 12px rgba(99,102,241,.3);
}

.rw-btn--primary:disabled {
    background: #e5e7eb;
    color: #9ca3af;
    cursor: not-allowed;
    box-shadow: none;
    transform: none;
}

.rw-btn--outline {
    background: transparent;
    color: #6366f1;
    border: 2px solid #6366f1;
}

.rw-btn--outline:hover { background: #ede9fe; }

/* ── Message ── */
.rw-submission-message {
    margin-top: 14px;
    padding: 13px 18px;
    border-radius: 8px;
    font-family: system-ui, sans-serif;
    font-size: 14px;
    font-weight: 500;
    line-height: 1.5;
}

.rw-submission-message--success { background: #d1fae5; color: #065f46; }
.rw-submission-message--error   { background: #fee2e2; color: #991b1b; }

/* ── Login prompt ── */
.rw-login-prompt {
    text-align: center;
    padding: 32px;
    background: #f9fafb;
    border: 2px dashed #d1d5db;
    border-radius: 10px;
}

.rw-login-prompt p {
    font-family: system-ui, sans-serif;
    font-size: 15px;
    color: #6b7280;
    margin: 0 0 20px;
}

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

/* ============================================================
   Contributors Sidebar Widget
   ============================================================ */
.rw-contributors-list {
    list-style: none;
    margin: 0;
    padding: 0;
}

.rw-contributor-item {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 9px 0;
    border-bottom: 1px solid #f3f4f6;
}

.rw-contributor-item:last-child { border-bottom: none; }
.rw-contributor-avatar          { border-radius: 50%; flex-shrink: 0; }

.rw-contributor-info {
    display: flex;
    flex-direction: column;
    gap: 2px;
    font-family: system-ui, sans-serif;
    min-width: 0;
}

.rw-contributor-name  { font-size: 14px; font-weight: 600; color: #111; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.rw-contributor-count { font-size: 11px; color: #9ca3af; }
.rw-contributor-badges { display: flex; gap: 3px; flex-wrap: wrap; margin-top: 2px; }

/* ============================================================
   Responsive
   ============================================================ */
@media (max-width: 640px) {
    .rw-story-wrap        { --rw-body-font: 17px; }
    .rw-segment-text      { font-size: 17px; }
    .rw-cover-img         { height: 220px; }
    .rw-contribute-section { padding: 24px 18px; }
    .rw-stats-row         { gap: 5px; }
    .rw-stat-divider      { display: none; }
    .rw-stat              { font-size: 12px; }
    .rw-btn               { width: 100%; justify-content: center; }
    .rw-login-actions     { flex-direction: column; }
    .rw-segment-footer    { flex-direction: column; align-items: flex-start; }
    .rw-chapter-mark      { margin-bottom: 14px; }
    .rw-drop-cap p:first-child::first-letter { font-size: 3.5em; }
    .rw-field--actions    { flex-direction: column; align-items: flex-start; }
}

/* Vote pulse */
@keyframes rw-pulse {
    0%   { transform: scale(1); }
    50%  { transform: scale(1.18); }
    100% { transform: scale(1); }
}
.rw-vote-pulse { animation: rw-pulse .3s ease; }

/* ============================================================
   Congrats Banner
   ============================================================ */
.rw-congrats-banner {
    display: flex;
    align-items: center;
    gap: 14px;
    background: linear-gradient(135deg, #ede9fe, #dbeafe);
    border: 1px solid #c4b5fd;
    border-radius: 10px;
    padding: 16px 18px;
    margin-bottom: 28px;
    position: relative;
    animation: rw-slide-down .4s ease;
}

@keyframes rw-slide-down {
    from { opacity: 0; transform: translateY(-10px); }
    to   { opacity: 1; transform: translateY(0); }
}

.rw-congrats-icon { font-size: 28px; flex-shrink: 0; }

.rw-congrats-text {
    display: flex;
    flex-direction: column;
    gap: 2px;
    font-family: system-ui, sans-serif;
}

.rw-congrats-text strong {
    font-size: 15px;
    color: #4338ca;
}

.rw-congrats-text span {
    font-size: 13px;
    color: #6b7280;
}

.rw-congrats-close {
    position: absolute;
    top: 10px;
    right: 12px;
    background: none;
    border: none;
    font-size: 18px;
    color: #9ca3af;
    cursor: pointer;
    padding: 0;
    line-height: 1;
}

.rw-congrats-close:hover { color: #374151; }

/* ============================================================
   Contributor Name Button (triggers card)
   ============================================================ */
.rw-contributor-trigger {
    background: none;
    border: none;
    padding: 0;
    cursor: pointer;
    font-weight: 500;
    color: #374151;
    font-family: system-ui, sans-serif;
    font-size: 13px;
    text-decoration: underline;
    text-decoration-color: transparent;
    transition: text-decoration-color .2s, color .2s;
}

.rw-contributor-trigger:hover {
    color: #6366f1;
    text-decoration-color: #6366f1;
}

/* ============================================================
   Contributor Card Popup
   ============================================================ */
.rw-contributor-card {
    position: absolute;
    z-index: 9000;
    background: #fff;
    border: 1px solid #e5e7eb;
    border-radius: 12px;
    box-shadow: 0 8px 30px rgba(0,0,0,.12);
    padding: 18px;
    width: 240px;
    display: flex;
    gap: 14px;
    align-items: flex-start;
    animation: rw-card-in .18s ease;
}

@keyframes rw-card-in {
    from { opacity: 0; transform: scale(.95) translateY(4px); }
    to   { opacity: 1; transform: scale(1) translateY(0); }
}

.rw-contributor-card::before {
    content: '';
    position: absolute;
    top: -6px;
    left: 20px;
    width: 12px;
    height: 12px;
    background: #fff;
    border-left: 1px solid #e5e7eb;
    border-top: 1px solid #e5e7eb;
    transform: rotate(45deg);
}

.rw-card-avatar img { border-radius: 50%; }

.rw-card-body { flex: 1; min-width: 0; }

.rw-card-name {
    font-family: system-ui, sans-serif;
    font-size: 14px;
    font-weight: 700;
    color: #111;
    margin: 0 0 2px;
}

.rw-card-rank {
    font-family: system-ui, sans-serif;
    font-size: 12px;
    font-weight: 600;
    margin: 0 0 6px;
}

.rw-card-stats {
    display: flex;
    gap: 6px;
    align-items: center;
    font-family: system-ui, sans-serif;
    font-size: 12px;
    color: #6b7280;
    margin-bottom: 8px;
}

.rw-card-badges { display: flex; flex-wrap: wrap; gap: 4px; }

/* ============================================================
   Profile Page
   ============================================================ */
.rw-profile-wrap {
    max-width: 700px;
    margin: 0 auto;
    font-family: system-ui, sans-serif;
}

.rw-profile-header {
    display: flex;
    gap: 24px;
    align-items: flex-start;
    padding: 32px;
    background: linear-gradient(135deg, #f5f3ff, #eff6ff);
    border-radius: 12px;
    margin-bottom: 24px;
}

.rw-profile-avatar-img { border-radius: 50%; }

.rw-profile-identity { flex: 1; }

.rw-profile-name {
    font-size: 24px;
    font-weight: 700;
    color: #111;
    margin: 0 0 6px;
    font-family: system-ui, sans-serif;
}

.rw-profile-rank {
    font-size: 14px;
    font-weight: 700;
    letter-spacing: .3px;
}

.rw-profile-you {
    font-size: 13px;
    color: #9ca3af;
    margin-left: 6px;
}

.rw-rank-progress-wrap {
    margin-top: 12px;
}

.rw-rank-progress-track {
    height: 6px;
    background: #e5e7eb;
    border-radius: 99px;
    overflow: hidden;
    margin-bottom: 5px;
}

.rw-rank-progress-fill {
    height: 100%;
    border-radius: 99px;
    transition: width .6s ease;
}

.rw-rank-progress-label {
    font-size: 12px;
    color: #6b7280;
}

.rw-rank-max {
    font-size: 13px;
    color: #f59e0b;
    font-weight: 600;
    margin-top: 8px;
}

/* Stats row */
.rw-profile-stats {
    display: grid;
    grid-template-columns: repeat(5, 1fr);
    gap: 12px;
    margin-bottom: 28px;
}

.rw-pstat {
    background: #fff;
    border: 1px solid #e5e7eb;
    border-radius: 8px;
    padding: 14px 10px;
    text-align: center;
}

.rw-pstat-value {
    display: block;
    font-size: 22px;
    font-weight: 800;
    color: #111;
    line-height: 1;
    margin-bottom: 4px;
}

.rw-pstat-label {
    display: block;
    font-size: 11px;
    color: #9ca3af;
    text-transform: uppercase;
    letter-spacing: .5px;
}

/* Profile sections */
.rw-profile-section { margin-bottom: 32px; }

.rw-profile-section-title {
    font-size: 13px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: .8px;
    color: #6366f1;
    margin: 0 0 16px;
    padding-bottom: 8px;
    border-bottom: 1px solid #f0f0f0;
}

/* Badge shelf */
.rw-badge-shelf {
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
}

.rw-badge-card {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 4px;
    background: #ede9fe;
    border: 1px solid #c4b5fd;
    border-radius: 10px;
    padding: 14px 12px;
    width: 100px;
    text-align: center;
    cursor: default;
    transition: transform .2s;
}

.rw-badge-card:hover { transform: translateY(-2px); }

.rw-badge-card--locked {
    background: #f9fafb;
    border-color: #e5e7eb;
    opacity: .5;
}

.rw-badge-card-icon { font-size: 24px; }

.rw-badge-card-name {
    font-size: 11px;
    font-weight: 700;
    color: #5b21b6;
    line-height: 1.3;
}

.rw-badge-card--locked .rw-badge-card-name { color: #9ca3af; }

.rw-badge-card-desc {
    font-size: 10px;
    color: #7c3aed;
    line-height: 1.3;
}

.rw-badge-card--locked .rw-badge-card-desc { color: #d1d5db; }

/* Published contributions */
.rw-profile-contributions { display: flex; flex-direction: column; gap: 12px; }

.rw-profile-contrib {
    background: #fafafa;
    border: 1px solid #e5e7eb;
    border-radius: 8px;
    padding: 16px;
}

.rw-profile-contrib--featured {
    background: #fffbeb;
    border-color: #fde68a;
}

.rw-profile-contrib-featured {
    font-size: 11px;
    font-weight: 700;
    color: #b45309;
    text-transform: uppercase;
    letter-spacing: .5px;
    margin-bottom: 6px;
}

.rw-profile-contrib-story a {
    font-size: 13px;
    font-weight: 700;
    color: #6366f1;
    text-decoration: none;
}

.rw-profile-contrib-story a:hover { text-decoration: underline; }

.rw-profile-contrib-text {
    font-family: Georgia, serif;
    font-size: 14px;
    color: #374151;
    line-height: 1.6;
    margin: 6px 0 8px;
    font-style: italic;
}

.rw-profile-contrib-meta {
    display: flex;
    gap: 6px;
    font-size: 12px;
    color: #9ca3af;
}

.rw-profile-empty p {
    color: #6b7280;
    font-size: 14px;
}

.rw-profile-empty a { color: #6366f1; }

.rw-profile-pending-note {
    background: #fef3c7;
    border: 1px solid #fde68a;
    border-radius: 8px;
    padding: 12px 16px;
    font-size: 13px;
    color: #92400e;
    margin-top: 8px;
}

/* ============================================================
   Leaderboard
   ============================================================ */
.rw-leaderboard-wrap {
    max-width: 600px;
    font-family: system-ui, sans-serif;
}

.rw-leaderboard-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 16px;
    padding-bottom: 10px;
    border-bottom: 2px solid #f0f0f0;
}

.rw-leaderboard-title {
    font-size: 16px;
    font-weight: 700;
    color: #111;
    margin: 0;
}

.rw-leaderboard-period {
    font-size: 12px;
    background: #ede9fe;
    color: #5b21b6;
    padding: 3px 10px;
    border-radius: 20px;
    font-weight: 600;
}

.rw-leaderboard-list { display: flex; flex-direction: column; gap: 2px; }

.rw-leaderboard-row {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 10px 14px;
    border-radius: 8px;
    transition: background .15s;
}

.rw-leaderboard-row:hover { background: #f9fafb; }

.rw-leaderboard-row--you { background: #f5f3ff; }

.rw-lb-pos {
    font-size: 18px;
    min-width: 32px;
    text-align: center;
    flex-shrink: 0;
}

.rw-lb-avatar-img { border-radius: 50%; }

.rw-lb-identity {
    flex: 1;
    display: flex;
    flex-direction: column;
    gap: 1px;
    min-width: 0;
}

.rw-lb-name {
    font-size: 14px;
    font-weight: 600;
    color: #111;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.rw-lb-you {
    display: inline-block;
    background: #ede9fe;
    color: #5b21b6;
    font-size: 10px;
    font-weight: 700;
    padding: 1px 6px;
    border-radius: 20px;
    margin-left: 4px;
    vertical-align: middle;
}

.rw-lb-rank {
    font-size: 11px;
    font-weight: 600;
}

.rw-lb-stats {
    text-align: right;
    flex-shrink: 0;
}

.rw-lb-count { font-size: 18px; font-weight: 800; color: #111; display: block; }
.rw-lb-count-label { font-size: 11px; color: #9ca3af; }

.rw-lb-badges { display: flex; gap: 3px; flex-wrap: wrap; max-width: 100px; }

.rw-leaderboard-empty { color: #6b7280; font-family: system-ui, sans-serif; font-size: 14px; }

/* Responsive */
@media (max-width: 600px) {
    .rw-profile-header  { flex-direction: column; align-items: center; text-align: center; padding: 24px 16px; }
    .rw-profile-stats   { grid-template-columns: repeat(3, 1fr); }
    .rw-pstat-value     { font-size: 18px; }
    .rw-badge-shelf     { justify-content: center; }
    .rw-lb-badges       { display: none; }
    .rw-congrats-banner { flex-wrap: wrap; }
}

/* ============================================================
   Follow Button
   ============================================================ */
.rw-follow-row {
    display: flex;
    align-items: center;
    gap: 12px;
    flex-wrap: wrap;
    margin-bottom: 14px;
}

.rw-follow-btn {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    background: #fff;
    border: 2px solid #6366f1;
    color: #6366f1;
    font-family: system-ui, sans-serif;
    font-size: 14px;
    font-weight: 700;
    padding: 8px 18px;
    border-radius: 8px;
    cursor: pointer;
    transition: all .2s;
}

.rw-follow-btn:hover {
    background: #6366f1;
    color: #fff;
}

.rw-follow-btn.rw-following {
    background: #ede9fe;
    border-color: #a78bfa;
    color: #5b21b6;
}

.rw-follow-btn.rw-following:hover {
    background: #fee2e2;
    border-color: #fca5a5;
    color: #991b1b;
}

.rw-follow-guest {
    display: flex;
    gap: 8px;
    flex: 1;
    max-width: 420px;
}

.rw-follow-email {
    flex: 1;
    padding: 8px 12px;
    border: 2px solid #d1d5db;
    border-radius: 8px;
    font-family: system-ui, sans-serif;
    font-size: 14px;
    transition: border-color .2s;
}

.rw-follow-email:focus {
    outline: none;
    border-color: #6366f1;
}

.rw-follow-guest-btn {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    background: #6366f1;
    color: #fff;
    border: none;
    font-family: system-ui, sans-serif;
    font-size: 14px;
    font-weight: 700;
    padding: 8px 16px;
    border-radius: 8px;
    cursor: pointer;
    transition: opacity .2s;
    white-space: nowrap;
}

.rw-follow-guest-btn:hover { opacity: .9; }

.rw-follower-count {
    font-family: system-ui, sans-serif;
    font-size: 13px;
    color: #9ca3af;
}

.rw-follow-msg {
    font-family: system-ui, sans-serif;
    font-size: 13px;
    font-weight: 600;
    padding: 6px 12px;
    border-radius: 6px;
}

.rw-follow-msg--ok    { background: #d1fae5; color: #065f46; }
.rw-follow-msg--error { background: #fee2e2; color: #991b1b; }

/* ============================================================
   Share Button & Panel
   ============================================================ */
.rw-share-wrap {
    position: relative;
}

.rw-share-trigger {
    background: none;
    border: 1px solid #e5e7eb;
    border-radius: 20px;
    padding: 5px 12px;
    font-family: system-ui, sans-serif;
    font-size: 13px;
    font-weight: 600;
    color: #6b7280;
    cursor: pointer;
    transition: all .2s;
}

.rw-share-trigger:hover {
    background: #f9fafb;
    border-color: #d1d5db;
    color: #374151;
}

.rw-share-panel {
    position: absolute;
    bottom: calc(100% + 8px);
    right: 0;
    background: #fff;
    border: 1px solid #e5e7eb;
    border-radius: 10px;
    box-shadow: 0 4px 16px rgba(0,0,0,.1);
    padding: 8px;
    display: flex;
    gap: 6px;
    z-index: 100;
    white-space: nowrap;
    animation: rw-card-in .15s ease;
}

.rw-share-link {
    display: inline-flex;
    align-items: center;
    padding: 7px 12px;
    border-radius: 6px;
    font-family: system-ui, sans-serif;
    font-size: 13px;
    font-weight: 700;
    text-decoration: none;
    cursor: pointer;
    border: none;
    transition: background .15s;
}

a.rw-share-link { background: #f3f4f6; color: #374151; }
a.rw-share-link:hover { background: #e5e7eb; }

button.rw-share-link { background: #f3f4f6; color: #374151; }
button.rw-share-link:hover { background: #e5e7eb; }

.rw-share-copied { background: #d1fae5 !important; color: #065f46 !important; }

/* ============================================================
   Story So Far Panel
   ============================================================ */
.rw-story-so-far {
    border: 1px solid #e5e7eb;
    border-radius: 10px;
    overflow: hidden;
    margin-bottom: 32px;
    background: #fff;
    box-shadow: 0 2px 8px rgba(0,0,0,.04);
}

.rw-ssf-toggle {
    width: 100%;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    padding: 16px 20px;
    background: #f5f3ff;
    border: none;
    cursor: pointer;
    font-family: system-ui, sans-serif;
    text-align: left;
    transition: background .2s;
}

.rw-ssf-toggle:hover { background: #ede9fe; }
.rw-ssf-toggle[aria-expanded="true"] { background: #ede9fe; }

.rw-ssf-toggle-left {
    display: flex;
    align-items: center;
    gap: 10px;
    flex: 1;
}

.rw-ssf-icon { font-size: 18px; flex-shrink: 0; }

.rw-ssf-title {
    font-size: 14px;
    font-weight: 700;
    color: #4338ca;
}

.rw-ssf-count {
    font-size: 12px;
    color: #6b7280;
    background: #fff;
    border: 1px solid #e5e7eb;
    padding: 2px 8px;
    border-radius: 99px;
}

.rw-ssf-chevron {
    font-size: 11px;
    color: #6366f1;
    transition: transform .3s ease;
    flex-shrink: 0;
}

.rw-ssf-toggle[aria-expanded="true"] .rw-ssf-chevron {
    transform: rotate(180deg);
}

/* Body */
.rw-ssf-body {
    border-top: 1px solid #e5e7eb;
}

.rw-ssf-body[hidden] { display: none; }

/* Summary */
.rw-ssf-summary {
    padding: 24px 24px 20px;
    border-bottom: 1px solid #f0f0f0;
}

.rw-ssf-summary-label {
    font-family: system-ui, sans-serif;
    font-size: 10px;
    font-weight: 700;
    letter-spacing: 2px;
    text-transform: uppercase;
    color: #6366f1;
    margin-bottom: 12px;
}

.rw-ssf-summary-text {
    font-family: Georgia, serif;
    font-size: 16px;
    line-height: 1.75;
    color: #374151;
    font-style: italic;
}

.rw-ssf-summary-date {
    font-family: system-ui, sans-serif;
    font-size: 11px;
    color: #9ca3af;
    margin-top: 10px;
}

/* Recent passages */
.rw-ssf-recent { padding: 20px 24px; }

.rw-ssf-recent-label {
    font-family: system-ui, sans-serif;
    font-size: 10px;
    font-weight: 700;
    letter-spacing: 2px;
    text-transform: uppercase;
    color: #6b7280;
    margin-bottom: 16px;
}

.rw-ssf-passage {
    display: flex;
    gap: 14px;
    padding: 14px 0;
    border-bottom: 1px solid #f3f4f6;
}

.rw-ssf-passage--last {
    border-bottom: 2px solid #6366f1;
    padding-bottom: 16px;
}

.rw-ssf-passage-num {
    font-family: system-ui, sans-serif;
    font-size: 11px;
    font-weight: 700;
    color: #9ca3af;
    min-width: 24px;
    padding-top: 3px;
    text-align: center;
}

.rw-ssf-passage-content { flex: 1; }

.rw-ssf-passage-text {
    font-family: Georgia, serif;
    font-size: 15px;
    line-height: 1.72;
    color: #374151;
}

.rw-ssf-passage-text p { margin: 0 0 .8em; }
.rw-ssf-passage-text p:last-child { margin: 0; }

.rw-ssf-passage-attr {
    font-family: system-ui, sans-serif;
    font-size: 12px;
    color: #9ca3af;
    margin-top: 8px;
    font-style: italic;
}

/* Continue prompt */
.rw-ssf-continue-prompt {
    display: flex;
    align-items: flex-start;
    gap: 10px;
    margin-top: 16px;
    padding: 14px 16px;
    background: #f0fdf4;
    border: 1px solid #bbf7d0;
    border-radius: 8px;
    font-family: system-ui, sans-serif;
    font-size: 14px;
    color: #065f46;
    line-height: 1.5;
}

.rw-ssf-continue-icon { font-size: 16px; flex-shrink: 0; }

/* Close button */
.rw-ssf-close {
    display: block;
    width: 100%;
    padding: 12px;
    background: #f9fafb;
    border: none;
    border-top: 1px solid #f0f0f0;
    font-family: system-ui, sans-serif;
    font-size: 12px;
    color: #9ca3af;
    cursor: pointer;
    transition: background .2s;
}

.rw-ssf-close:hover { background: #f3f4f6; color: #6b7280; }
