/* WELTKERN® Mastermind v2 */
@font-face { font-family: 'TWK Lausanne'; src: url('fonts/TWKLausanne-300.woff') format('woff'); font-weight: 300; font-style: normal; font-display: swap; }
@font-face { font-family: 'TWK Lausanne'; src: url('fonts/TWKLausanne-600.woff') format('woff'); font-weight: 600; font-style: normal; font-display: swap; }

* { margin: 0; padding: 0; box-sizing: border-box; font-style: normal !important; }
body { font-family: 'TWK Lausanne', -apple-system, BlinkMacSystemFont, system-ui, sans-serif; background: #fff; color: #1d1d1f; font-size: 15px; line-height: 1.6; font-weight: 300; -webkit-font-smoothing: antialiased; }
strong, b, h1, h2, h3, h4 { font-weight: 600; }
em, i { font-weight: 600; }
button { font-family: inherit; }

/* ============ LAYOUT ============ */
.app { display: grid; grid-template-columns: 280px 1fr var(--rcol, 0px); min-height: 100vh; transition: grid-template-columns 0.25s ease; }
.app.with-rcol { --rcol: 440px; }
.app.with-rcol.rcol-lg { --rcol: 640px; }
.app.with-rcol.rcol-xl { --rcol: min(1000px, calc(100vw - 320px)); }

/* ============ SIDEBAR ============ */
.sidebar { background: #fafafa; border-right: 1px solid #e5e5e7; padding: 32px 22px; overflow-y: auto; max-height: 100vh; position: sticky; top: 0; }
.brand { font-size: 14.3px; font-weight: 600; background: #fff; color: #1d1d1f; padding: 9px 13px; border-radius: 8px; cursor: pointer; display: inline-block; border: 1px solid #e5e5e7; margin-bottom: 22px; transition: all 0.15s; user-select: none; }
.brand:hover { background: #fafafa; border-color: #d8d8dc; }
.lang { display: inline-flex; background: #f0f0f2; border-radius: 6px; padding: 2px; margin-bottom: 18px; margin-left: 8px; vertical-align: top; }
.lang button { background: transparent; border: 0; padding: 8px 12px; font-size: 12px; font-weight: 600; cursor: pointer; border-radius: 4px; color: #6e6e73; }
.lang button.on { background: #fff; color: #1d1d1f; box-shadow: 0 1px 2px rgba(0,0,0,0.06); }
.search { width: 100%; background: #fff; border: 1px solid #e5e5e7; padding: 7px 12px; font-size: 13px; border-radius: 6px; margin-bottom: 18px; outline: none; font-family: inherit; }
.search:focus { border-color: #1d1d1f; }
.vol { margin-bottom: 4px; }
.vol-h { display: flex; justify-content: space-between; align-items: center; padding: 8px 4px; cursor: pointer; font-size: 12px; font-weight: 600; user-select: none; }
.vol-h:hover { color: #000; }
.chev { font-size: 9px; color: #86868b; transition: transform 0.2s; }
.vol.open .chev { transform: rotate(90deg); }
.chap-list { display: none; padding: 4px 0 10px 4px; }
.vol.open .chap-list { display: block; }
.chap { display: block; padding: 6px 0 6px 12px; color: #6e6e73; font-size: 12.5px; cursor: pointer; border-left: 1px solid #e5e5e7; margin-left: 2px; line-height: 1.4; }
.chap:hover { color: #1d1d1f; border-left-color: #86868b; }
.chap.on { color: #1d1d1f; font-weight: 600; border-left-color: #1d1d1f; border-left-width: 2px; }

/* ============ MAIN / ARTICLE ============ */
.main { padding: 60px 80px 120px; max-width: 880px; margin: 0 auto; width: 100%; min-width: 0; }
.main.home-mode { padding: 0; max-width: none; margin: 0; }
h1.ch-heading { font-size: 44px; line-height: 1.05; font-weight: 600; letter-spacing: -0.025em; margin-bottom: 36px; outline: none; }
.ch-sub { font-size: 17px; color: #6e6e73; margin-bottom: 80px; line-height: 1.45; outline: none; }
.content h2 { font-size: 26px; line-height: 1.2; font-weight: 600; letter-spacing: -0.015em; margin: 80px 0 22px; padding-top: 36px; border-top: 1px solid #e5e5e7; }
.block:first-of-type h2:first-child { border-top: 0; padding-top: 0; margin-top: 36px; }
.content h3 { font-size: 18px; font-weight: 600; margin: 36px 0 12px; }
.content p { margin-bottom: 18px; }
.content ul, .content ol { margin: 8px 0 18px; padding-left: 24px; }
.content li { margin-bottom: 6px; }
.content blockquote { margin: 22px 0; padding: 18px 24px; background: #fafafa; border-left: 3px solid #1d1d1f; border-radius: 0 6px 6px 0; }
.callout { background: #fafafa; border: 1px solid #e5e5e7; border-radius: 10px; padding: 18px 22px; margin: 20px 0; }
.callout-l { font-size: 10px; letter-spacing: 0.06em; text-transform: uppercase; color: #86868b; margin-bottom: 8px; font-weight: 600; }
.callout p:last-child { margin-bottom: 0; }
.content table { width: 100%; border-collapse: collapse; margin: 22px 0; font-size: 13.5px; border-radius: 8px; overflow: hidden; }
.content th { text-align: left; padding: 12px 14px; background: #1d1d1f; color: #fff; font-weight: 600; font-size: 12px; }
.content td { padding: 12px 14px; border-bottom: 1px solid #f0f0f2; vertical-align: top; }
.content tr:nth-child(even) td { background: #fafafa; }
.content tr:last-child td { border-bottom: 0; }
details { margin: 14px 0; border: 1px solid #e5e5e7; border-radius: 10px; background: #fff; overflow: hidden; }
summary { padding: 14px 20px; cursor: pointer; font-weight: 600; font-size: 14px; user-select: none; list-style: none; display: flex; align-items: center; gap: 12px; }
summary::-webkit-details-marker { display: none; }
summary::before { content: '+'; font-size: 20px; color: #86868b; font-weight: 300; width: 14px; }
details[open] summary::before { content: '−'; }
.dbody { padding: 14px 24px 20px; border-top: 1px solid #f0f0f2; }

/* legacy viz */
.viz { background: #fafafa; border: 1px solid #e5e5e7; border-radius: 10px; padding: 22px; margin: 24px 0; }
.viz-t { font-size: 11px; letter-spacing: 0.05em; text-transform: uppercase; color: #86868b; margin-bottom: 16px; font-weight: 600; }
.bar { display: flex; align-items: center; gap: 14px; margin-bottom: 10px; font-size: 13px; }
.bar-l { width: 200px; flex-shrink: 0; font-weight: 500; }
.bar-tr { flex: 1; height: 22px; background: #e5e5e7; border-radius: 4px; overflow: hidden; }
.bar-f { height: 100%; background: #1d1d1f; }
.bar-f.acc { background: #86868b; }
.bar-v { font-weight: 600; min-width: 80px; text-align: right; font-size: 13px; }
.mx { width: 100%; border-collapse: collapse; font-size: 12px; }
.mx th, .mx td { padding: 10px 8px; text-align: center; border: 1px solid #e5e5e7; }
.mx th { background: #1d1d1f; color: #fff; font-weight: 600; }
.mx td:first-child { text-align: left; font-weight: 600; background: #fafafa; }
.mx .ck { color: #1d1d1f; font-weight: 700; font-size: 14px; }
.mx .cx { color: #c7c7cc; font-size: 14px; }
.mx .pt { color: #6e6e73; font-size: 10px; }
.mx tr.hl td { background: #1d1d1f !important; color: #fff !important; }
.mx tr.hl td:first-child { background: #000 !important; }
.mx tr.hl .ck { color: #fff; }

/* ============ CHART FRAMEWORK ============ */
.chart { background: #fafafa; border-radius: 12px; padding: 28px 32px; margin: 36px 0; }
.chart-t { font-size: 11px; letter-spacing: 0.06em; text-transform: uppercase; color: #86868b; font-weight: 600; margin-bottom: 4px; }
.chart-h { font-size: 17px; font-weight: 600; margin-bottom: 24px; line-height: 1.3; }
.chart-note { font-size: 11px; color: #86868b; margin-top: 18px; line-height: 1.5; }
.chart-axis { font-size: 10px; color: #86868b; font-weight: 600; letter-spacing: 0.04em; text-transform: uppercase; margin-bottom: 10px; }
.hbar { display: flex; align-items: center; gap: 14px; margin-bottom: 14px; font-size: 13px; }
.hbar-label { width: 170px; font-weight: 600; flex-shrink: 0; line-height: 1.3; }
.hbar-track { flex: 1; height: 26px; background: #e5e5e7; border-radius: 5px; position: relative; }
.hbar-fill { height: 100%; background: #1d1d1f; border-radius: 5px; }
.hbar-fill.alt { background: #6e6e73; }
.hbar-fill.light { background: #c7c7cc; }
.hbar-fill.target { background: repeating-linear-gradient(45deg, #1d1d1f, #1d1d1f 6px, #3a3a3c 6px, #3a3a3c 12px); }
.hbar-meta { font-size: 11px; color: #86868b; min-width: 95px; text-align: right; flex-shrink: 0; }
.scn-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 14px; margin-top: 8px; }
.scn-card { background: #fff; border-radius: 10px; padding: 18px 20px; border: 1px solid #e5e5e7; }
.scn-card.normal { background: #1d1d1f; color: #fff; border-color: #1d1d1f; }
.scn-card.normal .scn-row b { color: #fff; }
.scn-card.normal .scn-row span { color: #c7c7cc; }
.scn-name { font-size: 11px; letter-spacing: 0.06em; text-transform: uppercase; font-weight: 600; color: #86868b; margin-bottom: 4px; }
.scn-card.normal .scn-name { color: #c7c7cc; }
.scn-tag { font-size: 18px; font-weight: 600; margin-bottom: 18px; line-height: 1.2; }
.scn-row { display: flex; flex-direction: column; gap: 2px; margin-bottom: 12px; font-size: 13px; }
.scn-row span { font-size: 10px; color: #86868b; letter-spacing: 0.04em; text-transform: uppercase; font-weight: 600; }
.scn-row:last-child { margin-bottom: 0; }
.stack { display: flex; height: 48px; border-radius: 8px; overflow: hidden; margin-bottom: 18px; }
.stack-seg { display: flex; align-items: center; justify-content: center; color: #fff; font-size: 11px; font-weight: 600; padding: 0 6px; text-align: center; overflow: hidden; }
.stack-seg.g1 { background: #1d1d1f; } .stack-seg.g2 { background: #4a4a4d; } .stack-seg.g3 { background: #6e6e73; } .stack-seg.g4 { background: #98989d; } .stack-seg.g5 { background: #c7c7cc; color: #1d1d1f; }
.stack-legend { display: grid; grid-template-columns: 1fr 1fr; gap: 10px 24px; font-size: 12px; margin-top: 8px; }
.stack-legend-item { display: flex; align-items: center; gap: 10px; line-height: 1.3; }
.stack-legend-sw { width: 12px; height: 12px; border-radius: 3px; flex-shrink: 0; }
.stack-legend-name { font-weight: 600; }
.stack-legend-pct { color: #86868b; }
.cmp-2col { display: grid; grid-template-columns: 1fr 1fr; gap: 28px; }
.cmp-2col .cmp-col-t { font-size: 13px; font-weight: 600; margin-bottom: 8px; text-align: center; }
.cmp-2col .cmp-col-sub { font-size: 11px; color: #86868b; margin-bottom: 14px; text-align: center; }
.cmp-vstack { display: flex; flex-direction: column; border-radius: 8px; overflow: hidden; height: 320px; }
.cmp-vstack .cmp-seg { display: flex; align-items: center; justify-content: center; padding: 0 8px; color: #fff; font-size: 11px; font-weight: 600; text-align: center; line-height: 1.2; }
.cmp-vstack .cmp-seg.s1 { background: #1d1d1f; } .cmp-vstack .cmp-seg.s2 { background: #3a3a3c; } .cmp-vstack .cmp-seg.s3 { background: #6e6e73; } .cmp-vstack .cmp-seg.s4 { background: #98989d; } .cmp-vstack .cmp-seg.s5 { background: #c7c7cc; color: #1d1d1f; } .cmp-vstack .cmp-seg.s6 { background: #e5e5e7; color: #1d1d1f; }
.nested-outer { border: 2px solid #1d1d1f; border-radius: 10px; padding: 32px 28px 28px; position: relative; }
.nested-mid { border: 2px solid #1d1d1f; border-radius: 8px; padding: 26px 24px 22px; margin-top: 24px; position: relative; background: rgba(29,29,31,0.04); }
.nested-inner { border: 2px solid #1d1d1f; border-radius: 6px; padding: 18px 20px; margin-top: 20px; background: rgba(29,29,31,0.12); position: relative; }
.nested-lbl { position: absolute; top: -10px; left: 22px; background: #fafafa; padding: 0 8px; font-size: 11px; letter-spacing: 0.08em; text-transform: uppercase; font-weight: 600; }
.nested-v { font-size: 22px; font-weight: 600; line-height: 1.1; }
.nested-pct { font-size: 11px; color: #86868b; margin-top: 4px; letter-spacing: 0.04em; text-transform: uppercase; font-weight: 600; }
.tl { position: relative; padding: 8px 0 0; }
.tl-line { position: absolute; left: 0; right: 0; top: 22px; height: 2px; background: #e5e5e7; }
.tl-points { display: grid; grid-template-columns: repeat(5, 1fr); position: relative; }
.tl-pt { display: flex; flex-direction: column; align-items: flex-start; gap: 10px; padding-right: 8px; }
.tl-dot { width: 14px; height: 14px; border-radius: 50%; background: #1d1d1f; border: 3px solid #fafafa; box-shadow: 0 0 0 2px #1d1d1f; }
.tl-phase { font-size: 10px; letter-spacing: 0.06em; text-transform: uppercase; font-weight: 600; color: #86868b; }
.tl-name { font-size: 13px; font-weight: 600; line-height: 1.3; }
.tl-value { font-size: 18px; font-weight: 600; line-height: 1.1; }
.tl-meta { font-size: 11px; color: #86868b; line-height: 1.4; }

/* ============ BLOCKS + EDITOR ============ */
.block { position: relative; border-radius: 8px; transition: background 0.12s; }
body.editor .block:hover { background: #fcfcfd; box-shadow: 0 0 0 1px #f0f0f2; }
/* Extend the hover-active zone across both margins so the toolbar stays reachable */
body.editor .block::before { content: ''; position: absolute; top: 0; bottom: 0; right: 100%; width: 60px; }
body.editor .block::after { content: ''; position: absolute; top: 0; bottom: 0; left: 100%; width: 90px; }
.block.dragging { opacity: 0.35; }
.block.drop-above { box-shadow: 0 -3px 0 0 #1d1d1f !important; }
.block.drop-below { box-shadow: 0 3px 0 0 #1d1d1f !important; }
.block-tools { position: absolute; top: 4px; right: -8px; transform: translateX(100%); display: flex; flex-direction: column; gap: 4px; z-index: 5; opacity: 0; visibility: hidden; pointer-events: none; transition: opacity 0.12s ease, visibility 0s linear 0.25s; }
body.editor .block:hover > .block-tools, body.editor .block.editing > .block-tools { opacity: 1; visibility: visible; pointer-events: auto; transition-delay: 0s; }
.bt-btn { width: 28px; height: 28px; border-radius: 7px; border: 1px solid #e5e5e7; background: #fff; color: #6e6e73; cursor: pointer; font-size: 12px; display: flex; align-items: center; justify-content: center; padding: 0; transition: all 0.12s; }
.bt-btn:hover { background: #1d1d1f; color: #fff; border-color: #1d1d1f; }
.bt-btn.drag { cursor: grab; }
.bt-btn.drag:active { cursor: grabbing; }
.bt-btn.danger:hover { background: #c00; border-color: #c00; }
.bt-move { display: flex; gap: 4px; align-items: stretch; }
.bt-arrows { display: flex; flex-direction: column; gap: 2px; }
.bt-arrow { width: 24px; height: 13px; border-radius: 5px; border: 1px solid #e5e5e7; background: #fff; color: #6e6e73; cursor: pointer; font-size: 10px; line-height: 1; display: flex; align-items: center; justify-content: center; padding: 0; transition: all 0.12s; }
.bt-arrow:hover { background: #1d1d1f; color: #fff; border-color: #1d1d1f; }
.bt-arrow:disabled { opacity: 0.3; cursor: default; background: #fff; color: #6e6e73; border-color: #e5e5e7; }
.block.editing { background: #fff !important; box-shadow: 0 0 0 2px #1d1d1f !important; padding: 16px; }
.block.editing .block-content { outline: none; }
.edit-bar { display: flex; gap: 8px; justify-content: flex-end; margin-top: 14px; padding-top: 12px; border-top: 1px solid #f0f0f2; }
.edit-bar button { border: 1px solid #e5e5e7; background: #fff; padding: 7px 16px; border-radius: 7px; cursor: pointer; font-size: 12px; font-weight: 600; }
.edit-bar button.pri { background: #1d1d1f; color: #fff; border-color: #1d1d1f; }
.edit-bar button.pri:hover { background: #000; }
.edit-bar button:hover { background: #fafafa; }
.edit-bar button.pri:hover { background: #000; }
.insert-bar { display: flex; justify-content: center; gap: 8px; padding: 6px 0; opacity: 0; transition: opacity 0.15s; min-height: 36px; align-items: center; }
body.editor .insert-bar:hover { opacity: 1; }
body.editor .block:hover + .insert-bar { opacity: 0.6; }
.insert-bar button { background: #fff; border: 1px dashed #c7c7cc; border-radius: 6px; padding: 5px 13px; font-size: 11px; color: #6e6e73; cursor: pointer; font-weight: 600; letter-spacing: 0.04em; text-transform: uppercase; }
.insert-bar button:hover { border-color: #1d1d1f; color: #1d1d1f; background: #fafafa; }
.imgblock img { display: block; width: 100%; height: auto; border-radius: 6px; }
.note-dot { position: absolute; top: 8px; left: -22px; width: 10px; height: 10px; border-radius: 50%; background: #1d1d1f; cursor: pointer; display: none; }
body.editor .note-dot { display: block; opacity: 0.25; }
body.editor .note-dot.has { opacity: 1; }
body.editor .note-dot:hover { opacity: 1; transform: scale(1.2); }

/* ============ BENTO HOME ============ */
.home-wrap { padding: 32px 40px 40px; min-height: 100vh; display: flex; flex-direction: column; }
.bento-grid { display: grid; grid-template-columns: 1fr 1fr; grid-template-rows: 1fr 1fr; gap: 18px; flex: 1; min-height: 0; }
.bento-grid.expanded { grid-template-columns: 1fr; grid-template-rows: 1fr; }
.vol-bento { background: #f5f5f7; border-radius: 22px; padding: 38px; cursor: pointer; transition: background 0.2s; position: relative; overflow: hidden; display: flex; flex-direction: column; justify-content: space-between; }
.vol-bento:hover { background: #ececef; }
.vol-bento.open { background: #f5f5f7; cursor: default; padding: 32px 36px; overflow: auto; display: block; }
.v-title { font-size: 44px; font-weight: 600; line-height: 1.05; letter-spacing: -0.025em; margin-bottom: 14px; outline: none; }
.vol-bento.open .v-title { font-size: 32px; margin-bottom: 8px; }
.v-desc { font-size: 16px; color: #6e6e73; line-height: 1.45; margin-bottom: 18px; max-width: 90%; outline: none; }
.vol-bento.open .v-desc { font-size: 14px; margin-bottom: 22px; max-width: 720px; }
.v-count { font-size: 11px; letter-spacing: 0.06em; text-transform: uppercase; color: #6e6e73; font-weight: 600; }
.vol-bento.open .v-count { display: none; }
.home-vol-back { display: inline-block; margin-bottom: 16px; font-size: 11px; letter-spacing: 0.06em; text-transform: uppercase; color: #86868b; cursor: pointer; font-weight: 600; }
.home-vol-back:hover { color: #1d1d1f; }
.chap-grid { display: grid; grid-template-columns: repeat(4, 1fr); gap: 12px; margin-top: 20px; }
.chap-bento { background: #fff; border-radius: 12px; padding: 26px 32px; cursor: pointer; transition: all 0.18s; display: flex; flex-direction: column; gap: 14px; box-shadow: 0 1px 2px rgba(0,0,0,0.03); position: relative; }
.chap-bento:hover { transform: translateY(-2px); box-shadow: 0 6px 16px rgba(0,0,0,0.06); }
.chap-title { font-size: 13px; font-weight: 600; line-height: 1.3; min-height: 34px; }
.chap-img-wrap { aspect-ratio: 5 / 3; background: #f0f0f2; border-radius: 8px; overflow: hidden; position: relative; transition: background 0.15s; }
body.editor .chap-img-wrap { cursor: pointer; }
body.editor .chap-img-wrap:hover { background: #e5e5e7; }
.chap-img-wrap:has(img) { background: transparent !important; }
.chap-img-wrap img { display: block; width: 100%; height: 100%; object-fit: contain; object-position: left center; }
.img-empty { position: absolute; inset: 0; display: flex; align-items: center; justify-content: center; color: #a1a1a6; font-size: 11px; letter-spacing: 0.04em; text-transform: uppercase; font-weight: 600; }
body.editor .chap-img-wrap:hover .img-empty::before { content: '+ '; }
.img-actions { position: absolute; top: 6px; right: 6px; display: flex; gap: 4px; opacity: 0; transition: opacity 0.15s; }
body.editor .chap-img-wrap:hover .img-actions { opacity: 1; }
.img-actions button { background: rgba(0,0,0,0.65); color: #fff; border: 0; border-radius: 4px; padding: 3px 6px; font-size: 10px; cursor: pointer; }
.chap-add { border: 1px dashed #c7c7cc; background: transparent; box-shadow: none; align-items: center; justify-content: center; color: #86868b; font-size: 12px; font-weight: 600; min-height: 120px; }
.chap-add:hover { border-color: #1d1d1f; color: #1d1d1f; transform: none; box-shadow: none; }

/* ============ RIGHT PANEL ============ */
.rpanel { background: #fff; border-left: 1px solid #e5e5e7; display: none; flex-direction: column; height: 100vh; position: sticky; top: 0; overflow: hidden; }
.app.with-rcol .rpanel { display: flex; }
.rtabs { display: flex; border-bottom: 1px solid #e5e5e7; background: #fafafa; align-items: center; }
.rtab { flex: 1; padding: 12px 14px; background: transparent; border: 0; cursor: pointer; font-size: 12px; font-weight: 600; color: #86868b; letter-spacing: 0.04em; text-transform: uppercase; border-bottom: 2px solid transparent; }
.rtab:hover { color: #1d1d1f; }
.rtab.on { color: #1d1d1f; border-bottom-color: #1d1d1f; background: #fff; }
.rtab-ctrl { background: transparent; border: 0; cursor: pointer; font-size: 14px; color: #86868b; padding: 6px 10px; }
.rtab-ctrl:hover { color: #1d1d1f; }
.rhead { padding: 16px 22px; border-bottom: 1px solid #e5e5e7; display: flex; align-items: flex-start; gap: 10px; }
.rhead-main { flex: 1; min-width: 0; }
.rhead-t { font-size: 13px; font-weight: 600; line-height: 1.3; }
.rhead-s { font-size: 11px; color: #86868b; margin-top: 3px; }
.rhead-x { flex-shrink: 0; width: 24px; height: 24px; border-radius: 6px; border: 1px solid #e5e5e7; background: #fff; color: #6e6e73; cursor: pointer; font-size: 16px; line-height: 1; display: flex; align-items: center; justify-content: center; padding: 0; }
.rhead-x:hover { background: #1d1d1f; color: #fff; border-color: #1d1d1f; }
.rscope { display: flex; gap: 4px; padding: 8px 22px; border-bottom: 1px solid #e5e5e7; background: #fafafa; }
.scope-btn { flex: 1; padding: 6px 10px; border: 1px solid #e5e5e7; background: #fff; border-radius: 6px; cursor: pointer; font-size: 11px; font-weight: 600; color: #6e6e73; letter-spacing: 0.03em; }
.scope-btn:hover { color: #1d1d1f; border-color: #c7c7cc; }
.scope-btn.on { background: #1d1d1f; color: #fff; border-color: #1d1d1f; }
.rtoolbar { padding: 10px 22px; border-bottom: 1px solid #e5e5e7; background: #fafafa; display: none; gap: 8px; align-items: center; font-size: 11px; }
.rtoolbar.show { display: flex; }
.rtoolbar select { font-size: 11px; padding: 4px 8px; border: 1px solid #e5e5e7; border-radius: 6px; background: #fff; font-family: inherit; cursor: pointer; }
.rtoolbar .status { margin-left: auto; color: #86868b; font-size: 10px; letter-spacing: 0.04em; text-transform: uppercase; font-weight: 600; }
.rtoolbar .status.ok { color: #0a7a3b; }
.rtoolbar .status.warn { color: #c47800; }
.rtoolbar .status.err { color: #c00; }
.rmsgs { flex: 1; overflow-y: auto; padding: 16px 22px; display: flex; flex-direction: column; gap: 14px; }
.msg { font-size: 13px; line-height: 1.5; }
.msg.u { background: #f0f0f2; padding: 10px 14px; border-radius: 12px; align-self: flex-end; max-width: 85%; white-space: pre-wrap; word-break: break-word; }
.msg.a { color: #3a3a3c; padding: 0 4px; white-space: pre-wrap; word-break: break-word; }
.msg.a.pending::after { content: ' ●●●'; color: #86868b; animation: cpulse 1.4s infinite; }
@keyframes cpulse { 50% { opacity: 0.3; } }
.msg .actions { display: flex; gap: 6px; margin-top: 8px; }
.msg .actions button { background: #fff; border: 1px solid #e5e5e7; border-radius: 6px; padding: 5px 12px; font-size: 11px; font-weight: 600; cursor: pointer; }
.msg .actions button.accept { background: #1d1d1f; color: #fff; border-color: #1d1d1f; }
.msg .actions button.accept:hover { background: #000; }
.msg .tag { display: inline-flex; gap: 6px; padding: 4px 10px; border-radius: 6px; font-size: 11px; font-weight: 600; margin-top: 8px; }
.msg .tag.ok { background: #e8f5ec; color: #0a7a3b; }
.msg .tag.muted { background: #f0f0f2; color: #6e6e73; }
.msg .tag.err { background: #fde8e8; color: #c00; }
.rinput { border-top: 1px solid #e5e5e7; padding: 14px 22px 18px; }
.rinput textarea { width: 100%; border: 1px solid #e5e5e7; border-radius: 10px; padding: 10px 12px; font-family: inherit; font-size: 13px; resize: none; outline: none; min-height: 64px; line-height: 1.5; }
.rinput textarea:focus { border-color: #1d1d1f; }
.rinput .hint { font-size: 10px; color: #86868b; margin-top: 6px; display: flex; justify-content: space-between; align-items: center; }
.rinput .send { background: #1d1d1f; color: #fff; border: 0; border-radius: 6px; padding: 5px 12px; font-size: 11px; font-weight: 600; cursor: pointer; }
.rinput .send:disabled { background: #c7c7cc; cursor: not-allowed; }
.welcome { padding: 6px 2px; color: #6e6e73; font-size: 13px; line-height: 1.55; }
.welcome h4 { font-size: 14px; font-weight: 600; color: #1d1d1f; margin-bottom: 8px; }
.suggestions { display: flex; flex-direction: column; gap: 6px; margin-top: 14px; }
.suggestion { background: #fafafa; border: 1px solid #e5e5e7; border-radius: 8px; padding: 9px 12px; font-size: 12px; cursor: pointer; text-align: left; line-height: 1.4; }
.suggestion:hover { background: #f0f0f2; border-color: #c7c7cc; }
.reopen-chat { position: fixed; bottom: 28px; right: 28px; background: #1d1d1f; color: #fff; border: 0; border-radius: 24px; padding: 11px 18px; font-size: 13px; font-weight: 600; cursor: pointer; box-shadow: 0 6px 20px rgba(0,0,0,0.15); z-index: 900; display: none; }

/* ============ AUTH GATE ============ */
.gate { position: fixed; inset: 0; background: #fff; z-index: 2000; display: none; align-items: center; justify-content: center; padding: 40px; }
.gate.on { display: flex; }
.gate-box { max-width: 360px; width: 100%; text-align: center; }
.gate-box h1 { font-size: 26px; font-weight: 600; letter-spacing: -0.02em; margin-bottom: 6px; }
.gate-sub { font-size: 14px; color: #6e6e73; margin-bottom: 32px; }
.pin-input { font-size: 34px; letter-spacing: 0.5em; text-align: center; width: 230px; padding: 12px 0 12px 0.5em; border: 0; border-bottom: 2px solid #e5e5e7; outline: none; font-family: inherit; font-weight: 600; }
.pin-input:focus { border-bottom-color: #1d1d1f; }
.gate-pass { width: 100%; padding: 12px 14px; border: 1px solid #e5e5e7; border-radius: 8px; font-size: 14px; outline: none; font-family: inherit; display: none; }
.gate-pass:focus { border-color: #1d1d1f; }
.gate.editor-mode .pin-input { display: none; }
.gate.editor-mode .gate-pass { display: block; }
.gate-btn { width: 100%; margin-top: 22px; padding: 12px; background: #1d1d1f; color: #fff; border: 0; border-radius: 8px; font-size: 14px; font-weight: 600; cursor: pointer; }
.gate-btn:hover { background: #000; }
.gate-err { color: #c00; font-size: 13px; margin-top: 14px; min-height: 18px; }
.gate-switch { margin-top: 26px; font-size: 12px; color: #86868b; cursor: pointer; text-decoration: underline; text-underline-offset: 3px; }
.gate-switch:hover { color: #1d1d1f; }

/* ============ MODALS / SETTINGS ============ */
.modal-bg { display: none; position: fixed; inset: 0; background: rgba(0,0,0,0.4); z-index: 1000; align-items: center; justify-content: center; backdrop-filter: blur(8px); }
.modal-bg.on { display: flex; }
.modal { background: #fff; border-radius: 14px; padding: 28px; max-width: 540px; width: 90%; max-height: 84vh; overflow-y: auto; box-shadow: 0 20px 60px rgba(0,0,0,0.2); }
.modal h3 { font-size: 17px; margin-bottom: 6px; }
.modal .lbl { font-size: 11px; letter-spacing: 0.06em; text-transform: uppercase; color: #86868b; margin: 20px 0 8px; font-weight: 600; }
.modal input[type="text"] { width: 100%; padding: 10px 12px; border: 1px solid #e5e5e7; border-radius: 8px; font-size: 13px; outline: none; font-family: inherit; }
.modal input:focus { border-color: #1d1d1f; }
.modal .help { font-size: 11px; color: #86868b; line-height: 1.5; margin-top: 6px; }
.modal textarea { width: 100%; min-height: 110px; padding: 12px; border: 1px solid #e5e5e7; border-radius: 8px; font-family: inherit; font-size: 14px; outline: none; resize: vertical; }
.modal textarea:focus { border-color: #1d1d1f; }
.mact { display: flex; gap: 8px; justify-content: flex-end; margin-top: 16px; }
.mact button { border: 1px solid #e5e5e7; background: #fff; padding: 8px 18px; border-radius: 8px; cursor: pointer; font-size: 13px; font-weight: 500; }
.mact button:hover { background: #fafafa; }
.mact button.pri { background: #1d1d1f; color: #fff; border-color: #1d1d1f; }
.mact button.dng { color: #c00; border-color: #f0c0c0; }
.version-item { display: flex; justify-content: space-between; align-items: center; padding: 8px 12px; background: #fafafa; border-radius: 6px; font-size: 12px; gap: 10px; margin-bottom: 6px; }
.version-item button { background: #fff; border: 1px solid #e5e5e7; border-radius: 5px; padding: 4px 10px; font-size: 11px; font-weight: 600; cursor: pointer; flex-shrink: 0; }
.version-item button:hover { background: #1d1d1f; color: #fff; border-color: #1d1d1f; }
.settings-btn { position: fixed; bottom: 28px; left: 28px; background: #fff; border: 1px solid #e5e5e7; border-radius: 50%; width: 42px; height: 42px; cursor: pointer; font-size: 15px; z-index: 900; display: none; align-items: center; justify-content: center; box-shadow: 0 4px 12px rgba(0,0,0,0.08); }
body.editor .settings-btn { display: flex; }
.settings-btn:hover { background: #fafafa; }
.save-pill { position: fixed; top: 16px; right: 16px; background: #1d1d1f; color: #fff; border-radius: 16px; padding: 6px 14px; font-size: 11px; font-weight: 600; z-index: 1500; opacity: 0; transition: opacity 0.2s; pointer-events: none; }
.save-pill.show { opacity: 1; }
.save-pill.err { background: #c00; }

@media (max-width: 1100px) { .chap-grid { grid-template-columns: repeat(3, 1fr); } }
@media (max-width: 900px) {
  .app { grid-template-columns: 1fr; }
  .app.with-rcol { --rcol: 0px; }
  .sidebar { position: relative; max-height: none; }
  .main { padding: 30px 24px 80px; }
  h1.ch-heading { font-size: 30px; }
  .bento-grid { grid-template-columns: 1fr; grid-template-rows: auto; }
  .vol-bento { min-height: 180px; padding: 26px; }
  .v-title { font-size: 30px; }
  .chap-grid { grid-template-columns: 1fr 1fr; gap: 10px; }
  .home-wrap { padding: 24px 20px 60px; }
  .scn-grid, .cmp-2col, .stack-legend { grid-template-columns: 1fr; }
  .tl-points { grid-template-columns: 1fr; gap: 18px; }
  .tl-line { display: none; }
  .hbar-label { width: 110px; font-size: 12px; }
  .block-tools { right: 4px; transform: none; flex-direction: row; top: -12px; }
}
