/* Writing Editor (Story 6772). Pinned head zone over one scrolling area holding only the chosen tab. */

html, body { margin: 0; height: 100%; }
body.we-page { background: #F4F1EA; color: #1F2328; font-family: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
               display: flex; flex-direction: column; height: 100vh; height: 100dvh; overflow: hidden; }
#lwIconBand { flex: 0 0 auto; }

.we-shell { flex: 1 1 auto; min-height: 0; display: flex; flex-direction: column; overflow: hidden; width: 100%; }
.we-headzone { flex: 0 0 auto; }
.we-scroll { flex: 1 1 auto; min-height: 0; overflow-y: auto; -webkit-overflow-scrolling: touch; }

/* ---- header ---- */
.ct-header.we-head { display: flex; align-items: center; gap: 8px; padding: 8px 12px; background: #3C3C3C; color: #FFFFFF; }
.we-titles { flex: 1 1 auto; min-width: 0; display: flex; flex-direction: column; }
.we-titles h1 { margin: 0; font-size: 17px; font-weight: 600; line-height: 1.25; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.we-path { --pcr-ink: #D8D8D8; --pcr-ink-hover: #FFFFFF; font-size: 12px; }
.we-headbtn { flex: 0 0 auto; background: transparent; border: 1px solid #6B6B6B; color: #FFFFFF; border-radius: 6px;
              width: 34px; height: 30px; font-size: 14px; cursor: pointer; }
.we-doc { flex: 0 0 auto; border: 0; border-radius: 12px; padding: 4px 10px; font-size: 12px; cursor: pointer; max-width: 40vw;
          overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.we-doc.ok   { background: #DCFCE7; color: #14532D; }
.we-doc.warn { background: #FEF3C7; color: #78350F; }
.we-doc.none { background: #E5E7EB; color: #374151; }

.we-more { background: #FFFFFF; border-bottom: 1px solid #DDD6C8; padding: 8px 12px 4px; }
.we-shell.we-rolled .we-more { display: none; }
.we-facts { font-size: 13px; color: #4B5563; line-height: 1.5; margin-bottom: 6px; overflow-wrap: anywhere; }
.we-facts b { color: #1F2328; font-weight: 600; }
.we-morebtns { display: flex; flex-wrap: wrap; gap: 6px; margin-bottom: 8px; }
.we-tools { display: none; border-top: 1px dashed #DDD6C8; padding-top: 8px; }
.we-tools.on { display: block; }
.we-row { display: flex; flex-wrap: wrap; align-items: center; gap: 6px; margin-bottom: 8px; }
.we-row > .ps-select, .we-row > select { flex: 1 1 220px; min-width: 0; }
.we-find { flex: 1 1 160px; min-width: 0; box-sizing: border-box; padding: 7px 9px; border: 1px solid #C9C2B4; border-radius: 6px;
           font-size: 15px; background: #FFFFFF; color: #1F2328; }
.we-row > .voice-mic-wrap { flex: 1 1 160px; min-width: 0; display: block; }
.we-row > .voice-mic-wrap input { width: 100%; box-sizing: border-box; }
.we-count { font-size: 13px; color: #4B5563; min-width: 3em; }
.we-hint { font-size: 12px; color: #6B7280; flex: 1 1 200px; }
.we-check { font-size: 14px; display: inline-flex; align-items: center; gap: 4px; }

.we-btn { background: #FFFFFF; border: 1px solid #C9C2B4; color: #1F2328; border-radius: 6px; padding: 6px 11px; font-size: 14px;
          cursor: pointer; line-height: 1.2; }
.we-btn:hover { background: #F7F4EE; }
.we-btn.primary { background: #0F5132; border-color: #0F5132; color: #FFFFFF; }
.we-btn.primary:hover { background: #0B3D26; }
.we-btn.danger { color: #991B1B; border-color: #E5B4B4; }
.we-btn:disabled { opacity: 0.55; cursor: default; }
.we-btn.small { padding: 3px 8px; font-size: 13px; }

.we-tabs { display: flex; gap: 2px; background: #2E2E2E; padding: 0 8px; overflow-x: auto; }
.we-tab { background: transparent; color: #D1D5DB; border: 0; padding: 9px 12px; font-size: 14px; cursor: pointer; white-space: nowrap;
          border-bottom: 3px solid transparent; }
.we-tab.active { color: #FFFFFF; border-bottom-color: #F59E0B; font-weight: 600; }

/* ---- panes ---- */
.we-pane { display: none; padding: 10px 12px 40px; max-width: 860px; margin: 0 auto; box-sizing: border-box; }
.we-pane.active { display: block; }
/* Story 6795: where the page sits on a wide screen (Left, Middle, Right, Stretch), remembered per device */
body.we-lay-left .we-pane { margin-left: 0; margin-right: auto; }
body.we-lay-right .we-pane { margin-left: auto; margin-right: 0; }
body.we-lay-stretch .we-pane { max-width: none; }
.we-lay { margin-left: auto; display: flex; align-items: center; gap: 1px; padding-left: 8px; flex: 0 0 auto; }
.we-lay button { background: transparent; border: 0; color: #9CA3AF; padding: 4px 4px; cursor: pointer; line-height: 0; border-radius: 4px; }
.we-lay button:hover { color: #FFFFFF; }
.we-lay button.on { color: #F59E0B; }
@media (max-width: 640px) { .we-lay { display: none; } }
.we-status { font-size: 13px; color: #4B5563; margin: 2px 0 10px; }
.we-status:empty { display: none; }

/* ---- the text ---- */
.we-doctext { background: #FFFDF8; border: 1px solid #E5DECF; border-radius: 8px; padding: 6px 0; font-family: Georgia, "Times New Roman", serif; }
.we-sec { border-bottom: 1px solid #EFE8DA; }
.we-sec:last-child { border-bottom: 0; }
.we-sechead { display: flex; align-items: center; gap: 8px; padding: 8px 14px; cursor: pointer; font-family: system-ui, -apple-system, "Segoe UI", sans-serif;
              font-size: 13px; color: #6B5B3E; background: #FAF6EC; user-select: none; }
.we-sechead .we-sectitle { flex: 1 1 auto; font-weight: 600; color: #3F3524; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.we-sec.collapsed .we-secbody { display: none; }
.we-p { position: relative; padding: 3px 14px; font-size: 17px; line-height: 1.55; white-space: pre-wrap; overflow-wrap: anywhere; cursor: text;
        min-height: 1.2em; border-left: 3px solid transparent; }
.we-p:hover { background: #FBF5E6; }
.we-p.center { text-align: center; }
.we-p.indent { text-indent: 1.6em; }
.we-p.empty { min-height: 0.9em; }
.we-p.flash { background: #FEF08A; transition: background 1.2s; }
.we-p.editing { background: #FFFFFF; border-left-color: #0F5132; cursor: default; white-space: normal; }
.we-pb { display: block; font-family: system-ui, sans-serif; font-size: 11px; color: #9C8B6A; text-align: center; letter-spacing: 0.08em;
         border-top: 1px dashed #D8CDB4; margin: 6px 14px 2px; padding-top: 2px; }
mark.we-hit { background: #FDE68A; color: inherit; padding: 0; }
mark.we-hit.on { background: #F59E0B; }
.we-edit textarea { width: 100%; box-sizing: border-box; font: inherit; font-size: 17px; line-height: 1.55; padding: 8px; border: 1px solid #9CA3AF;
                    border-radius: 6px; resize: vertical; min-height: 5em; background: #FFFFFF; color: #1F2328; }
.we-edit .we-row { margin: 6px 0 4px; }
.we-edit .we-hint { font-family: system-ui, sans-serif; }

/* ---- compare ---- */
.we-same { font-family: system-ui, sans-serif; font-size: 13px; color: #6B7280; border: 1px dashed #D1C7B1; border-radius: 6px; padding: 7px 10px;
           margin: 8px 0; cursor: pointer; background: #FFFDF8; }
.we-same-text { margin: 8px 0; background: #FFFDF8; border: 1px solid #E5DECF; border-radius: 6px; font-family: Georgia, serif; }
.we-same-text .we-p { cursor: default; }
.we-blk { border: 1px solid #E2C9C9; border-left: 4px solid #B91C1C; border-radius: 8px; margin: 10px 0; background: #FFFFFF; }
.we-blk.done { border-left-color: #15803D; border-color: #BFE3C8; }
.we-blkhead { display: flex; align-items: center; gap: 8px; padding: 7px 10px; cursor: pointer; font-size: 13px; color: #4B5563; background: #FCF6F6; border-radius: 8px 8px 0 0; }
.we-blk.done .we-blkhead { background: #F2FBF4; }
.we-blkhead .we-blktitle { flex: 1 1 auto; font-weight: 600; color: #1F2328; min-width: 0; }
.we-blk.collapsed .we-blkbody { display: none; }
.we-sides { display: flex; flex-direction: column; gap: 0; }
.we-sides.wide { flex-direction: row; }
.we-side { flex: 1 1 0; min-width: 0; border-top: 1px solid #F1E4E4; }
.we-sides.wide .we-side + .we-side { border-left: 1px solid #F1E4E4; }
.we-sidehead { font-size: 12px; font-weight: 600; padding: 5px 10px; color: #FFFFFF; background: #6B7280; }
.we-side.mine .we-sidehead { background: #374151; }
.we-side.theirs .we-sidehead { background: #7C5E10; }
.we-side .we-p { font-family: Georgia, serif; font-size: 16px; cursor: default; }
.we-side .we-none { font-size: 13px; color: #9CA3AF; padding: 8px 10px; font-style: italic; }
.we-side.mine mark { background: #FECACA; color: #7F1D1D; padding: 0 1px; border-radius: 2px; }
.we-side.theirs mark { background: #BBF7D0; color: #14532D; padding: 0 1px; border-radius: 2px; }
.we-blkacts { display: flex; flex-wrap: wrap; gap: 6px; padding: 8px 10px; border-top: 1px solid #F1E4E4; }

/* ---- changes and versions ---- */
.we-card { background: #FFFFFF; border: 1px solid #E5DECF; border-radius: 8px; margin: 8px 0; }
.we-card.undone { border-left: 4px solid #9CA3AF; }
.we-card.current { border-left: 4px solid #15803D; }
.we-cardhead { display: flex; align-items: center; gap: 8px; padding: 8px 10px; cursor: pointer; }
.we-cardtitle { flex: 1 1 auto; min-width: 0; font-weight: 600; font-size: 15px; overflow-wrap: anywhere; }
.we-card.undone .we-cardtitle { color: #6B7280; font-weight: 500; }
.we-card.collapsed .we-cardbody { display: none; }
.we-cardbody { padding: 0 10px 10px; font-size: 14px; color: #374151; }
.we-meta { font-size: 13px; color: #6B7280; margin: 2px 0 6px; overflow-wrap: anywhere; }
.we-badge { font-size: 11px; font-weight: 700; letter-spacing: 0.04em; padding: 2px 7px; border-radius: 10px; background: #E5E7EB; color: #374151;
            text-transform: uppercase; white-space: nowrap; }
.we-badge.merge { background: #FEF3C7; color: #78350F; }
.we-badge.edit, .we-badge.insert { background: #DBEAFE; color: #1E3A8A; }
.we-badge.delete { background: #FEE2E2; color: #7F1D1D; }
.we-badge.replace, .we-badge.reload { background: #EDE9FE; color: #4C1D95; }
.we-badge.cur { background: #DCFCE7; color: #14532D; }
.we-tick { color: #15803D; font-weight: 700; }
.we-prev { font-family: Georgia, serif; font-size: 14px; line-height: 1.45; margin: 4px 0; padding: 6px 8px; border-radius: 6px; white-space: pre-wrap; overflow-wrap: anywhere; }
.we-prev.before { background: #FEF2F2; }
.we-prev.after { background: #F0FDF4; }
.we-acts { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 8px; }
.we-more-btn { display: block; margin: 12px auto; }
.we-caret { width: 1em; display: inline-block; color: #6B7280; }

@media (max-width: 640px) {
    .we-pane { padding: 8px 6px 40px; }
    .we-p { font-size: 16px; padding: 3px 10px; }
    .we-titles h1 { font-size: 15px; }
    .we-doc { max-width: 30vw; }
}

/* Story 6775: the always-visible add and choose buttons in the panes. */
.we-addrow { margin: 0 0 10px; }
#weCmpChoose { margin: 0 0 10px; }

/* ==== Story 6794: the book -- the page you type into, the format bar, the margin, the Book tab, the scratch pad ==== */

/* the page: a paragraph is drawn with its own format (alignment, indents, spacing, font, size) inline */
.we-page-ed { outline: none; padding: 10px 22px 18px; white-space: pre-wrap; overflow-wrap: anywhere; color: #1F2328; min-height: 2em;
              font-family: "Times New Roman", Georgia, serif; font-size: 12pt; caret-color: #0F5132; }
.we-page-ed p.we-pp { margin: 0; min-height: 1.2em; tab-size: 4; }
.we-page-ed p.we-pp.pb { border-top: 1px dashed #D8CDB4; padding-top: 18px; position: relative; }
.we-page-ed p.we-pp.pb::before { content: "NEW CHAPTER"; position: absolute; top: 2px; left: 0; right: 0; text-align: center; text-indent: 0;
                                 font-family: system-ui, sans-serif; font-size: 10px; letter-spacing: 0.08em; color: #9C8B6A; }
.we-page-ed p.we-pp.flash { background: #FEF08A; transition: background 1.2s; }
.we-page-ed mark.we-hl { color: inherit; padding: 0; }
.we-hl1 { background: #FFF200; } .we-hl2 { background: #7CF57C; } .we-hl3 { background: #6FE8F0; }
.we-hl4 { background: #F59AE8; } .we-hl5 { background: #FF8A8A; } .we-hl6 { background: #D4D4D4; }
.we-page-ed .we-hit { background: #FDE68A; outline: 1px solid #F59E0B; }
.we-page-ed .we-hit.on { background: #F59E0B; }

/* margin notes in the text: a colored underline and wash in the color of their kind */
.we-nt { border-bottom: 2px solid var(--we-c, #2563EB); background: var(--we-cw, rgba(37,99,235,0.08)); cursor: pointer; }
.we-flag { color: var(--we-c, #6B7280); font-size: 11px; vertical-align: super; cursor: pointer; padding: 0 1px; }
.we-c-blue { --we-c: #2563EB; --we-cw: rgba(37,99,235,0.10); }
.we-c-orange { --we-c: #EA580C; --we-cw: rgba(234,88,12,0.10); }
.we-c-purple { --we-c: #7C3AED; --we-cw: rgba(124,58,237,0.10); }
.we-c-teal { --we-c: #0D9488; --we-cw: rgba(13,148,136,0.10); }
.we-c-green { --we-c: #15803D; --we-cw: rgba(21,128,61,0.10); }
.we-c-red { --we-c: #DC2626; --we-cw: rgba(220,38,38,0.10); }
.we-c-gray { --we-c: #6B7280; --we-cw: rgba(107,114,128,0.10); }
.we-c-slate { --we-c: #475569; --we-cw: rgba(71,85,105,0.10); }
.we-nt.done { border-bottom-style: dotted; background: transparent; }

/* chapter heads */
.we-secwords { white-space: nowrap; }
.we-state { font-size: 11px; font-weight: 700; padding: 1px 7px; border-radius: 10px; color: #FFFFFF; background: var(--we-c, #6B7280); white-space: nowrap; }
.we-notecount { font-size: 11px; padding: 1px 7px; border-radius: 10px; background: #E0E7FF; color: #3730A3; white-space: nowrap; }

/* the format bar */
.we-fbarwrap { background: #FFFFFF; border-bottom: 1px solid #DDD6C8; padding: 4px 8px; display: flex; flex-wrap: wrap; align-items: center; gap: 6px; }
.we-fbarwrap[hidden] { display: none; }
.we-fbarroll { background: transparent; border: 0; font-size: 13px; color: #4B5563; cursor: pointer; padding: 4px 2px; }
.we-savestate { font-size: 12px; padding: 2px 8px; border-radius: 10px; margin-left: auto; order: 2; }
.we-savestate.saved { background: #DCFCE7; color: #14532D; }
.we-savestate.dirty, .we-savestate.saving { background: #FEF3C7; color: #78350F; }
.we-savestate.failed { background: #FEE2E2; color: #7F1D1D; }
.we-fbar { order: 3; flex: 1 1 100%; display: flex; flex-wrap: wrap; align-items: center; gap: 4px; }
.we-fbar[hidden] { display: none; }
.we-fb { background: #FFFFFF; border: 1px solid #D6CFC0; border-radius: 5px; min-width: 30px; height: 30px; padding: 0 7px; font-size: 14px;
         cursor: pointer; color: #1F2328; }
.we-fb:hover { background: #F7F4EE; }
.we-fb.on { background: #1F2937; color: #FFFFFF; border-color: #1F2937; }
.we-fb:disabled { opacity: 0.4; cursor: default; }
.we-fbsep { width: 1px; height: 22px; background: #E5DECF; margin: 0 3px; }
.we-fbar .ps-select, .we-fbar select { flex: 0 1 140px; min-width: 96px; }
.we-fbhl { position: relative; display: inline-block; }
.we-hlicon { background: #FFF200; padding: 0 3px; border-radius: 2px; }
.we-fb[data-c="2"] .we-hlicon { background: #7CF57C; } .we-fb[data-c="3"] .we-hlicon { background: #6FE8F0; }
.we-fb[data-c="4"] .we-hlicon { background: #F59AE8; } .we-fb[data-c="5"] .we-hlicon { background: #FF8A8A; }
.we-fb[data-c="6"] .we-hlicon { background: #D4D4D4; }
.we-hlmenu { position: absolute; top: 34px; left: 0; z-index: 30; display: flex; gap: 4px; padding: 6px; background: #FFFFFF; border: 1px solid #D6CFC0;
             border-radius: 8px; box-shadow: 0 6px 18px rgba(0,0,0,0.15); }
.we-hlmenu[hidden] { display: none; }
.we-sw { width: 26px; height: 26px; border: 1px solid #A8A29E; border-radius: 5px; cursor: pointer; }

/* tabs carry a count */
.we-tabcount { font-size: 11px; background: #F59E0B; color: #1F2328; border-radius: 9px; padding: 0 6px; margin-left: 3px; }
.we-tabcount:empty { display: none; }

/* compare: who changed it, the phrases inside a paragraph */
.we-side-badge { font-size: 11px; font-weight: 700; padding: 1px 7px; border-radius: 10px; white-space: nowrap; }
.we-side-badge.theirs { background: #DCFCE7; color: #14532D; }
.we-side-badge.mine { background: #E5E7EB; color: #374151; }
.we-side-badge.conflict { background: #FEE2E2; color: #7F1D1D; }
.we-side-badge.move { background: #E0E7FF; color: #3730A3; }
.we-hunks { margin: 2px 10px 8px; display: flex; flex-direction: column; gap: 4px; }
.we-hunk { display: flex; flex-wrap: wrap; align-items: center; gap: 6px; font-size: 13px; background: #FAFAF9; border: 1px solid #EEE8DC; border-radius: 6px; padding: 4px 6px; }
.we-hunk-old { background: #FECACA; color: #7F1D1D; border-radius: 3px; padding: 0 3px; overflow-wrap: anywhere; }
.we-hunk-new { background: #BBF7D0; color: #14532D; border-radius: 3px; padding: 0 3px; overflow-wrap: anywhere; }
.we-hunk-arrow { color: #6B7280; }
#weTakeTheirs { margin: 0 0 10px; }

/* bands (Notes, Book) */
.we-band { background: #FFFFFF; border: 1px solid #E5DECF; border-radius: 8px; margin: 8px 0; }
.we-bandhead { display: flex; align-items: center; gap: 8px; padding: 8px 10px; cursor: pointer; font-size: 14px; background: #FAF6EC; border-radius: 8px 8px 0 0; }
.we-band.collapsed .we-bandhead { border-radius: 8px; }
.we-bandtitle { flex: 1 1 auto; font-weight: 600; min-width: 0; }
.we-band.collapsed .we-bandbody { display: none; }
.we-bandbody { padding: 6px 10px 10px; }

/* margin notes on the Notes tab */
.we-note { border-left: 4px solid var(--we-c, #2563EB); background: #FFFFFF; border-top: 1px solid #F1ECE2; padding: 8px 10px; }
.we-note.done { border-left-color: #15803D; }
.we-note.done .we-notebody, .we-note.done .we-quote { color: #6B7280; }
.we-notehead { display: flex; flex-wrap: wrap; align-items: center; gap: 6px; }
.we-notehead .we-meta { margin: 0; }
.we-kind { font-size: 11px; font-weight: 700; padding: 1px 8px; border-radius: 10px; color: #FFFFFF; background: var(--we-c, #2563EB); }
.we-quote { font-family: Georgia, serif; font-size: 14px; margin: 6px 0 2px; padding-left: 8px; border-left: 2px solid #E5DECF; color: #374151; white-space: pre-wrap; }
.we-notebody { font-size: 14px; margin: 4px 0; white-space: pre-wrap; overflow-wrap: anywhere; }
.we-suggest { font-size: 14px; margin: 4px 0; background: #F0FDF4; border-radius: 6px; padding: 4px 8px; white-space: pre-wrap; }

/* the Book tab */
.we-stats { display: flex; flex-wrap: wrap; gap: 10px; margin: 4px 0 10px; }
.we-stat { flex: 1 1 140px; background: #FAF6EC; border-radius: 8px; padding: 8px 10px; }
.we-stat b { display: block; font-size: 22px; color: #1F2328; }
.we-stat span { font-size: 12px; color: #6B7280; }
.we-bars { display: flex; align-items: flex-end; gap: 4px; height: 86px; padding-top: 4px; overflow-x: auto; }
.we-bar { flex: 0 0 34px; display: flex; flex-direction: column; align-items: center; justify-content: flex-end; height: 100%; }
.we-bar span { display: block; width: 70%; background: #15803D; border-radius: 3px 3px 0 0; }
.we-bar.neg span { background: #9CA3AF; }
.we-bar em { font-style: normal; font-size: 10px; color: #6B7280; margin-top: 2px; }
.we-board { display: flex; flex-direction: column; gap: 4px; }
.we-chcard { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; padding: 7px 8px; border: 1px solid #EEE8DC; border-radius: 6px; background: #FFFFFF; }
.we-chcard.dragging { opacity: 0.6; box-shadow: 0 6px 16px rgba(0,0,0,0.18); }
.we-chnum { font-weight: 700; color: #6B5B3E; min-width: 1.6em; }
.we-chtitle { flex: 1 1 200px; min-width: 0; font-weight: 600; overflow-wrap: anywhere; }
.we-chcard .we-meta { margin: 0; }
.we-chcard .we-acts { margin-top: 0; }
.we-grip { cursor: grab; touch-action: none; user-select: none; font-size: 16px; color: #6B7280; padding: 0 4px; }
#weArrange.on { background: #1F2937; color: #FFFFFF; border-color: #1F2937; }

/* the scratch pad: beside the page on a wide screen, over it on a phone */
.we-scratch { position: fixed; top: 0; right: 0; bottom: 0; width: 340px; max-width: 90vw; z-index: 40; background: #FFFDF8;
              border-left: 1px solid #DDD6C8; box-shadow: -6px 0 18px rgba(0,0,0,0.10); display: flex; flex-direction: column; }
.we-scratch[hidden] { display: none; }
.we-scratchhead { display: flex; align-items: center; gap: 8px; padding: 8px 10px; background: #3C3C3C; color: #FFFFFF; }
.we-scratchhead .we-meta { color: #D1D5DB; margin: 0; flex: 1 1 auto; }
.we-scratchtitle { font-weight: 600; }
.we-scratchtext { flex: 1 1 auto; border: 0; padding: 10px 12px; font-family: Georgia, serif; font-size: 15px; line-height: 1.5; resize: none;
                  background: #FFFDF8; color: #1F2328; outline: none; }
@media (min-width: 1100px) {
    body.we-scratch-on .we-shell { padding-right: 340px; box-sizing: border-box; }
}
@media (max-width: 640px) {
    .we-page-ed { padding: 8px 12px 14px; }
    .we-fbar .ps-select, .we-fbar select { flex: 1 1 120px; }
}
.we-badge.type { background: #DBEAFE; color: #1E3A8A; }
.we-badge.move { background: #E0E7FF; color: #3730A3; }
.we-badge.suggest, .we-badge.take { background: #FEF3C7; color: #78350F; }
