/* Scoped to the Saga module. Roleverses red + neutral surfaces only. */
.sg-root {
    --sg-red: #ce2842; --sg-deep: #a60a15; --sg-dark-red: #7f080f;
    --sg-ink: #252329; --sg-muted: #746f73; --sg-line: #e7e1e3; --sg-wash: #fff7f8;
    color: var(--sg-ink); font-size: 14px;
}
.sg-root *, .sg-root *::before, .sg-root *::after { box-sizing: border-box; }
.sg-root [hidden] { display: none !important; }
.sg-root h1, .sg-root h2, .sg-root h3, .sg-root h4, .sg-root h5 { color: var(--sg-ink); overflow-wrap: anywhere; }
.sg-root a { color: var(--sg-deep); }
.sg-root button, .sg-root input, .sg-root select, .sg-root textarea { font: inherit; }
.sg-root button { cursor: pointer; }
.sg-root button:disabled { opacity: .45; cursor: default; }
.sg-root input[type="checkbox"], .sg-root input[type="radio"] { accent-color: var(--sg-red); }
.sg-root :focus-visible { outline: 3px solid rgba(206,40,66,.45); outline-offset: 3px; }
.sg-root .form-control:focus, .sg-root .form-select:focus { border-color: var(--sg-red); box-shadow: 0 0 0 .15rem rgba(206,40,66,.12); }
.sg-root .btn { font-size: 13px; border-radius: 8px; min-height: 36px; display: inline-flex; gap: 5px; align-items: center; justify-content: center; white-space: normal; }
.sg-root .btn-primary { background: linear-gradient(120deg,#ce2842,#a60a15 65%,#7f080f); border: 1px solid var(--sg-deep); color: #fff; box-shadow: none; }
.sg-root .btn-sm { min-height: 30px; padding: 4px 9px; font-size: 12px; }
.sg-root .page-item.active .page-link { background: var(--sg-red); color: #fff; }
.sg-root .page-link { color: var(--sg-deep); }
.sg-root .sg-filter label, .sg-root .sg-toolbar label { color: var(--sg-ink); font-size: 14px; font-weight: 600; }
.sg-root .form-text { line-height: 1.65; }
.sg-root .sg-actions { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; }
.sg-actions form { margin: 0; }
.sg-eyebrow { font-size: 12px; font-weight: 700; line-height: 1.6; color: var(--sg-deep); margin-bottom: 10px; }
.sg-accent { color: var(--sg-red); }
.sg-muted { color: var(--sg-muted); font-size: 13px; }
.sg-badge { display: inline-block; color: var(--sg-deep); border: 1px solid #efd5dc; font-size: 13px; font-weight: 600; padding: 4px 9px; border-radius: 5px; line-height: 1.4; }
.sg-notice { border: 1px solid #ead9dd; border-left: 3px solid var(--sg-red); background: var(--sg-wash); border-radius: 7px; padding: 14px 16px; margin-bottom: 18px; color: #000; font-size: 13px; line-height: 1.8; }
.sg-notice a { text-decoration: underline; }
.sg-small-note { margin-top: 18px; font-size: 11px; }
.sg-empty { padding: 50px 25px; text-align: center; color: var(--sg-muted); line-height: 1.8; width: 100%; }
.sg-prose { white-space: pre-line; line-height: 1.95; overflow-wrap: anywhere; color: #000; font-size: 14px; font-weight: 400; }
.sg-section-title { font-size: 12px; text-transform: uppercase; letter-spacing: 1.1px; margin: 24px 0 12px; font-weight: 700; }
.sg-filter { display: flex; gap: 12px; align-items: flex-end; flex-wrap: wrap; }
.sg-filter label { min-width: 180px; }
.sg-filter label:first-child { flex: 1; }
.sg-filter input, .sg-filter select, .sg-toolbar input, .sg-toolbar select { margin-top: 7px; min-height: 40px; }
.sg-admin-heading { display: flex; gap: 18px; align-items: center; justify-content: space-between; flex-wrap: wrap; margin: 10px 0 24px; }
.sg-admin-heading h3, .sg-admin-heading h4, .sg-admin-heading h5 { margin-bottom: 5px; }
.sg-admin-heading p { margin: 0; max-width: 720px; color: var(--sg-muted); line-height: 1.8; }
.sg-admin-nav { display: flex; flex-wrap: wrap; gap: 8px; border-bottom: 1px solid var(--sg-line); padding-bottom: 18px; margin-bottom: 24px; }
.sg-table { margin: 0; }
.sg-table td { vertical-align: middle; padding: 16px; }
.sg-table th { background: #faf8f9; color: var(--sg-muted); font-size: 10px; letter-spacing: .5px; }
.sg-highlight-editor { border: 1px solid var(--sg-line); background: #fcfafb; border-radius: 10px; padding: 20px; margin-bottom: 20px; }
.sg-highlight-editor legend { float: none; width: auto; padding: 0 6px; margin: 0; font-size: 13px; color: var(--sg-deep); }
.sg-row-actions { justify-content: flex-end; margin: -8px 0 12px; }
.sg-cover-preview { width: 120px; max-height: 150px; object-fit: cover; border-radius: 8px; }
.sg-public-wrap { max-width: 1540px; padding-left: 32px; padding-right: 32px; }
.sg-back { display: inline-block; font-size: 12px; margin-bottom: 24px; }
.sg-page-heading { margin: 20px 0 30px; }
.sg-page-heading h1 { font-size: 40px; font-weight: 600; }
.sg-page-heading p { color: var(--sg-muted); }
.sg-hero { display: flex; gap: 26px; align-items: center; margin-bottom: 22px; padding: 26px 30px; border: 1px solid var(--sg-line); border-top: 3px solid var(--sg-red); border-radius: 13px; background: #fff; }
.sg-hero-cover { width: 110px; height: 138px; border-radius: 8px; object-fit: cover; flex-shrink: 0; }
.sg-hero-content { min-width: 0; flex: 1; }
.sg-hero h1 { font-size: clamp(26px, 3vw, 40px); line-height: 1.2; margin: 0 0 12px; letter-spacing: -.8px; }
.sg-hero p { color: var(--sg-muted); line-height: 1.8; max-width: 850px; margin: 0 0 16px; }
.sg-hero-meta { display: flex; flex-wrap: wrap; gap: 12px 20px; align-items: center; color: var(--sg-muted); font-size: 11px; }
.sg-introduction { border: 1px solid var(--sg-line); border-radius: 9px; padding: 14px 18px; margin-bottom: 18px; background: #fff; }
.sg-introduction summary { cursor: pointer; color: var(--sg-deep); font-size: 12px; font-weight: 600; }
.sg-introduction .sg-prose { margin-top: 14px; max-width: 900px; }
.sg-toolbar { display: flex; flex-wrap: wrap; align-items: flex-end; gap: 14px; margin: 22px 0 18px; }
.sg-toolbar .sg-search-label { flex: 1; min-width: 230px; }
.sg-toolbar label:not(.sg-search-label) { min-width: 190px; }
.sg-toolbar .sg-actions { padding-bottom: 2px; }
.sg-workspace { display: grid; grid-template-columns: minmax(0, 1fr) 350px; gap: 20px; align-items: start; }
.sg-map-shell { border: 1px solid var(--sg-line); border-radius: 13px; background: #fff; overflow: hidden; min-width: 0; }
.sg-map-header { display: flex; gap: 12px; justify-content: space-between; align-items: center; padding: 17px 20px; border-bottom: 1px solid var(--sg-line); flex-wrap: wrap; }
.sg-map-header strong { font-size: 13px; }
.sg-map-header .small { font-size: 10px; margin-top: 4px; }
.sg-map-header .sg-actions { gap: 5px; }
.sg-icon-btn { display: inline-flex; align-items: center; justify-content: center; border: 1px solid var(--sg-line); border-radius: 6px; background: #fff; color: var(--sg-deep); min-width: 31px; min-height: 31px; font-size: 12px; padding: 3px 8px; }
.sg-icon-btn:hover { border-color: var(--sg-red); background: var(--sg-wash); }
.sg-viewport { overflow: auto; min-height: 390px; max-height: 600px; background-color: #fcfafb; background-image: radial-gradient(#e9e2e5 .7px, transparent .7px); background-size: 16px 16px; cursor: grab; overscroll-behavior-x: contain; scrollbar-color: #c997a3 #f5f0f2; scrollbar-width: thin; }
.sg-viewport.is-dragging { cursor: grabbing; user-select: none; }
.sg-stage { position: relative; min-height: 1px; }
.sg-board { position: absolute; left: 0; top: 0; transform-origin: 0 0; }
#sg-connections { position: absolute; inset: 0; overflow: visible; }
.sg-axis { stroke: #d196a3; stroke-width: 2; }
.sg-edge { cursor: pointer; outline: none; }
.sg-edge-stroke { fill: none; stroke: var(--sg-red); stroke-width: 1.8; stroke-dasharray: 5 5; opacity: .25; transition: opacity .15s; }
.sg-edge-hit { fill: none; stroke: transparent; stroke-width: 16; pointer-events: stroke; }
.sg-edge.is-active .sg-edge-stroke { opacity: .85; stroke-width: 2.1; }
.sg-edge-label { fill: var(--sg-deep); font-size: 10px; font-weight: 600; paint-order: stroke; stroke: #fcfafb; stroke-width: 5px; opacity: 0; transition: opacity .15s; }
.sg-edge.is-active .sg-edge-label, .sg-edge:hover .sg-edge-label, .sg-edge:focus .sg-edge-label { opacity: 1; }
.sg-edge:hover .sg-edge-stroke, .sg-edge:focus .sg-edge-stroke { stroke-width: 3.5; opacity: 1; }
.sg-marker circle { fill: #fff; stroke: #cc8a9b; stroke-width: 2; }
.sg-marker text { font-size: 9px; font-weight: 700; fill: var(--sg-deep); pointer-events: none; }
.sg-marker.is-selected circle { fill: var(--sg-deep); stroke: var(--sg-deep); }
.sg-marker.is-selected text { fill: #fff; }
.sg-node { position: absolute; width: 220px; height: 266px; border-radius: 11px; border: 1px solid #e1d8dc; background: #fff; padding: 0; text-align: left; box-shadow: 0 5px 18px rgba(40,20,25,.045); transition: opacity .16s,border-color .16s,box-shadow .16s; overflow: hidden; }
.sg-node:hover { border-color: var(--sg-red); box-shadow: 0 6px 22px rgba(166,10,21,.12); }
.sg-node.is-selected { border: 2px solid var(--sg-red); box-shadow: 0 0 0 4px rgba(206,40,66,.1),0 5px 20px rgba(166,10,21,.07); }
.sg-node.is-connected { border-color: #cc8a9b; }
.sg-node.is-muted { opacity: .4; }
.sg-node.is-muted:hover, .sg-node.is-muted:focus-visible { opacity: 1; }
.sg-node.is-match { outline: 2px solid var(--sg-red); outline-offset: 4px; }
.sg-node.is-finale .sg-node-meta { color: var(--sg-dark-red); font-weight: 700; }
.sg-node-cover { display: block; position: relative; height: 124px; background: linear-gradient(135deg,#f7eff1,#ead7dd); overflow: hidden; }
.sg-initials { position: absolute; inset: 0; display: grid; place-items: center; color: #a75d70; font-weight: 600; font-size: 32px; letter-spacing: 4px; }
.sg-node-cover img { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; }
.sg-node-content { display: block; padding: 13px 15px; }
.sg-node-meta { display: flex; align-items: center; justify-content: space-between; color: var(--sg-deep); font-size: 13px; margin-bottom: 8px; }
.sg-node-title { display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; font-size: 14px; color: var(--sg-ink); font-weight: 600; line-height: 1.5; min-height: 42px; }
.sg-node-phase { display: block; font-size: 13px; margin-top: 8px; color: var(--sg-muted); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.sg-legend { display: flex; gap: 12px 18px; flex-wrap: wrap; padding: 13px 17px; font-size: 14px; color: var(--sg-muted); border-top: 1px solid var(--sg-line); }
.sg-legend span { display: inline-flex; align-items: center; gap: 8px; }
.sg-line-solid, .sg-line-dashed { display: inline-block; width: 22px; border-top: 2px solid var(--sg-red); }
.sg-line-dashed { border-top-style: dashed; }
.sg-detail { border: 1px solid var(--sg-line); background: #fff; border-radius: 13px; padding: 24px; min-width: 0; min-height: 380px; max-height: 664px; overflow: auto; scrollbar-width: thin; scrollbar-color: #c997a3 #f5f0f2; }
.sg-detail h2 { font-size: 22px; line-height: 1.4; font-weight: 600; letter-spacing: -.4px; margin-bottom: 12px; }
.sg-detail-tags { display: flex; flex-wrap: wrap; gap: 10px; align-items: center; }
.sg-time-label { padding: 10px 0; color: var(--sg-muted); font-size: 11px; }
.sg-step-navigation { display: flex; align-items: center; justify-content: space-between; gap: 6px; margin: 18px 0; padding-bottom: 18px; border-bottom: 1px solid var(--sg-line); }
.sg-step-navigation .btn { font-size: 13px; min-height: 32px; padding: 5px 10px; font-weight: 400;}
.sg-step-count { font-size: 10px; color: var(--sg-muted); }
.sg-highlight { border-left: 2px solid #e2b2bf; padding: 3px 0 3px 14px; margin: 20px 0; }
.sg-highlight h4 { font-size: 13px; line-height: 1.7; font-weight: 600; }
.sg-highlight .sg-prose { font-size: 16px; font-weight: 400; }
.sg-text-link { display: inline-block; font-size: 11px; margin-top: 10px; text-decoration: underline; }
.sg-link-list { margin-top: 25px; border-top: 1px solid var(--sg-line); }
.sg-connection-item { display: block; width: 100%; text-align: left; padding: 12px; border: 1px solid var(--sg-line); border-radius: 8px; margin: 8px 0; background: #fff; color: var(--sg-ink); }
.sg-connection-item strong, .sg-connection-item span, .sg-connection-item small { display: block; overflow-wrap: anywhere; }
.sg-connection-item strong { color: var(--sg-deep); font-size: 14px; margin-bottom: 4px; }
.sg-connection-item span { font-size: 14px; font-weight: 400; }
.sg-connection-item small { font-size: 13px; color: var(--sg-muted); margin-top: 4px; }
.sg-connection-item:hover { border-color: var(--sg-red); background: var(--sg-wash); }
.sg-connection-chain { display: flex; flex-direction: column; gap: 4px; margin: 24px 0; align-items: stretch; }
.sg-story-chip { border: 1px solid #e1b8c3; border-radius: 8px; background: var(--sg-wash); color: var(--sg-deep); padding: 12px; font-size: 12px; }
.sg-direction { text-align: center; color: var(--sg-red); font-size: 22px; }
.sg-reading-list { max-width: 920px; margin: 0 auto; }
.sg-reading-story { background: #fff; border: 1px solid var(--sg-line); border-radius: 13px; padding: 30px; margin-bottom: 22px; }
.sg-reading-heading { display: flex; gap: 20px; border-bottom: 1px solid var(--sg-line); padding-bottom: 20px; margin-bottom: 20px; }
.sg-reading-number { color: var(--sg-red); font-size: 32px; font-weight: 600; }
.sg-reading-heading h2 { font-size: 23px; margin-bottom: 0; }
.sg-reading-story .sg-prose { font-size: 14px; }
.sg-reading-story .sg-highlight { padding-left: 20px; margin-top: 24px; }
.sg-reading-story .sg-highlight h4 { font-size: 16px; }
.sg-saga-grid { display: grid; grid-template-columns: repeat(3,minmax(0,1fr)); gap: 22px; }
.sg-saga-card { border: 1px solid var(--sg-line); background: #fff; border-radius: 12px; overflow: hidden; display: flex; flex-direction: column; transition: border-color .15s,transform .15s; }
.sg-saga-card:hover { border-color: var(--sg-red); transform: translateY(-3px); }
.sg-saga-cover, .sg-cover-empty { height: 200px; width: 100%; object-fit: cover; }
.sg-cover-empty { display: grid; place-items: center; background: linear-gradient(135deg,#f8eff2,#e9d0d8); font-size: 52px; color: var(--sg-deep); }
.sg-saga-info { padding: 22px; flex: 1; display: flex; flex-direction: column; align-items: flex-start; }
.sg-saga-info h3 { font-size: 22px; margin: 14px 0 10px; }
.sg-saga-info p { font-size: 12px; color: var(--sg-muted); line-height: 1.8; }
.sg-card-footer { display: flex; gap: 16px; justify-content: space-between; width: 100%; padding-top: 14px; margin-top: auto; border-top: 1px solid var(--sg-line); font-size: 11px; }
.sg-workspace:fullscreen { padding: 24px; background: #f8f5f6; overflow: auto; align-content: start; }
.sg-workspace:fullscreen .sg-detail { max-height: calc(100vh - 48px); }
.sg-workspace:fullscreen .sg-viewport { max-height: calc(100vh - 180px); }
@media(max-width:1199px) {
    .sg-workspace { grid-template-columns: minmax(0,1fr) 315px; gap: 14px; }
    .sg-detail { padding: 19px; }
    .sg-map-header { padding: 14px; }
}
@media(max-width:991px) {
    .sg-workspace { grid-template-columns: minmax(0,1fr); }
    .sg-detail { max-height: none; min-height: 0; }
    .sg-public-wrap { padding-left: 20px; padding-right: 20px; }
    .sg-saga-grid { grid-template-columns: repeat(2,minmax(0,1fr)); }
    .sg-workspace:fullscreen .sg-detail { max-height: none; }
    .sg-viewport { max-height: 550px; }
}
@media(max-width:575px) {
    .sg-public-wrap { padding-left: 12px; padding-right: 12px; }
    .sg-hero { padding: 22px 18px; gap: 14px; align-items: flex-start; }
    .sg-hero-cover { width: 62px; height: 82px; }
    .sg-hero h1 { font-size: 25px; }
    .sg-hero p { font-size: 12px; }
    .sg-hero-meta { gap: 8px 12px; font-size: 10px; }
    .sg-toolbar { gap: 12px; }
    .sg-toolbar .sg-search-label { flex-basis: 100%; }
    .sg-toolbar label:not(.sg-search-label) { min-width: 140px; flex: 1; }
    .sg-toolbar .sg-actions { flex: 1; justify-content: flex-end; gap: 5px; }
    .sg-toolbar .btn { padding: 7px 10px; font-size: 11px; }
    .sg-map-header { gap: 10px; }
    .sg-map-header > .sg-actions { width: 100%; justify-content: flex-end; }
    .sg-viewport { min-height: 350px; }
    .sg-legend { gap: 8px 12px; }
    .sg-reading-story { padding: 22px 18px; }
    .sg-reading-heading { gap: 14px; }
    .sg-reading-heading h2 { font-size: 20px; }
    .sg-saga-grid { grid-template-columns: minmax(0,1fr); }
    .sg-filter label { width: 100%; }
    .sg-highlight-editor { padding: 15px; }
}
@media(prefers-reduced-motion:reduce) { .sg-root * { transition: none !important; scroll-behavior: auto !important; } }
.sg-root .form-control, .sg-root .form-select { color: #51494e; }
.sg-root .form-control::placeholder { color: #92888d; opacity: 1; }
.sg-root .text-muted { color: var(--sg-muted) !important; }
