/* A shared research notebook, saved-session invitation and storage feedback. */
.scene-actions:has(.scene-notebook-button) .progress-badge { display: none; }
.scene-notebook-button { position: relative; display: inline-flex; align-items: center; justify-content: center; gap: 9px; min-height: 48px; padding: 9px 13px; border: 1px solid #9eaf8a; border-radius: 14px; color: #36523d; background: rgba(247,251,239,.96); box-shadow: 0 6px 16px rgba(22,24,17,.13); font-family: Arial,sans-serif; font-size: 15px; font-weight: 700; line-height: 1.3; cursor: pointer; touch-action: manipulation; }
.scene-notebook-button:hover { border-color: #6b8659; background: #eaf1df; }
.scene-notebook-button > svg { flex: 0 0 22px; width: 22px; height: 22px; fill: none; stroke: currentColor; stroke-width: 1.7; stroke-linecap: round; stroke-linejoin: round; }
.notebook-button-label { white-space: nowrap; }
.notebook-button-count { display: inline-block; padding: 4px 7px; border: 1px solid #c0cda9; border-radius: 6px; color: #47643a; background: #e6eed8; font-size: 12px; font-weight: 800; line-height: 1.2; white-space: nowrap; }
.hub-stage:has(.scene-notebook-button) .scene-heading { width: min(640px, calc(100vw - 370px)); }
.location-stage:has(.scene-notebook-button) .scene-heading { width: min(470px, calc(100vw - 370px)); }

.research-notebook { position: fixed; inset: 0 0 0 auto; width: min(610px, calc(100vw - 24px)); max-width: 100vw; height: 100vh; height: 100dvh; max-height: 100vh; max-height: 100dvh; margin: 0 0 0 auto; padding: 0; overflow: hidden; border: 0; border-left: 1px solid #c8bda3; border-radius: 18px 0 0 18px; color: #39382a; background: #fffaf0; box-shadow: -18px 0 54px rgba(21,26,18,.25); text-align: left; }
.research-notebook::backdrop { background: rgba(22,27,19,.4); }
.research-notebook *, .resume-research * { box-sizing: border-box; }
.notebook-layout { display: flex; flex-direction: column; height: 100%; min-height: 0; }
.notebook-header { display: flex; flex: 0 0 auto; align-items: flex-start; justify-content: space-between; gap: 16px; padding: 25px 27px 17px; background: #f0e9d7; }
.notebook-header > div { min-width: 0; }
.notebook-eyebrow { display: block; color: #73805b; font-size: 10px; font-weight: 800; line-height: 1.4; letter-spacing: .075em; text-transform: uppercase; }
.notebook-header h2 { margin: 7px 0 0; color: #3f4a32; font: 700 30px/1.13 Georgia,"Times New Roman",serif; letter-spacing: -.02em; }
.notebook-close { display: grid; place-items: center; flex: 0 0 44px; width: 44px; min-height: 44px; padding: 0; border: 1px solid #bfc5aa; border-radius: 10px; color: #536344; background: #fffaf0; font: 400 27px/1 Arial,sans-serif; cursor: pointer; touch-action: manipulation; }
.notebook-close:hover { color: #35533a; border-color: #8ea579; background: #e8efdd; }
.notebook-intro { flex: 0 0 auto; margin: 0; padding: 0 27px 17px; color: #746a55; background: #f0e9d7; font-size: 13px; line-height: 1.5; }
.notebook-tabs { display: grid; flex: 0 0 auto; grid-template-columns: repeat(2,minmax(0,1fr)); gap: 8px; padding: 16px 23px; border-block: 1px solid #d7cfb8; background: #f8f2e4; }
.notebook-tab { display: flex; align-items: center; gap: 8px; min-width: 0; min-height: 51px; padding: 9px 10px; border: 1px solid #cfc8b0; border-radius: 9px; color: #6b624d; background: #fffdf5; font-family: Arial,sans-serif; text-align: left; cursor: pointer; touch-action: manipulation; }
.notebook-tab-number { flex: 0 0 auto; color: #8b816a; font-size: 10px; font-weight: 800; }
.notebook-tab-label { flex: 1; min-width: 0; font-size: 12px; font-weight: 700; line-height: 1.3; }
.notebook-tab-state { flex: 0 0 16px; color: #75895e; font-size: 14px; line-height: 1; text-align: center; }
.notebook-tab:hover { color: #43583a; border-color: #a2b38b; background: #f0f4e7; }
.notebook-tab[aria-pressed="true"] { border-color: #6b8858; color: #365633; background: #e9efdc; box-shadow: inset 0 0 0 1px #6b8858; }
.notebook-tab[aria-pressed="true"] .notebook-tab-number { color: #5d784c; }
.notebook-pages { flex: 1 1 auto; min-height: 0; padding: 24px 27px 28px; overflow-y: auto; overflow-x: hidden; overscroll-behavior: contain; scrollbar-width: thin; scrollbar-gutter: stable; scrollbar-color: #b6aa91 #fffaf0; background: linear-gradient(105deg,#fffcf5,#f9f2e4); }
.notebook-entry { min-width: 0; }
.notebook-entry-heading { padding-bottom: 20px; border-bottom: 1px solid #dfd4bd; }
.notebook-entry-heading h3 { margin: 7px 0 10px; color: #464732; font: 700 29px/1.15 Georgia,"Times New Roman",serif; letter-spacing: -.015em; overflow-wrap: anywhere; }
.notebook-status { display: inline-block; padding: 5px 9px; border: 1px solid #cfc4a9; border-radius: 6px; color: #7b6b4c; background: #f5eddc; font-size: 11px; font-weight: 700; line-height: 1.4; }
.notebook-status.is-complete { border-color: #b4c59b; color: #496b3e; background: #e9f0dc; }
.notebook-status.is-review { border-color: #ceae83; color: #85653e; background: #fbefdc; }
.notebook-empty { margin: 22px 0; padding: 23px; border: 1px dashed #c9c0a8; border-radius: 11px; color: #746b57; background: #f8f3e7; }
.notebook-empty h4 { margin: 0 0 10px; color: #6a6d52; font: 700 23px/1.2 Georgia,"Times New Roman",serif; }
.notebook-empty p { margin: 0; font-size: 14px; line-height: 1.6; }
.notebook-section { margin-top: 24px; }
.notebook-section h4 { margin: 0 0 13px; color: #68744f; font-size: 11px; font-weight: 800; line-height: 1.4; letter-spacing: .07em; text-transform: uppercase; }
.notebook-records { margin: 0; padding: 0; }
.notebook-records dt { margin: 0; color: #4f5039; font-size: 14px; font-weight: 700; line-height: 1.4; }
.notebook-records dd { margin: 6px 0 18px; padding: 0 0 17px; border-bottom: 1px solid #e5dcc7; color: #6b614b; font-size: 15px; line-height: 1.65; overflow-wrap: anywhere; }
.notebook-records dd:last-child { margin-bottom: 0; padding-bottom: 0; border-bottom: 0; }
.notebook-section > p { margin: 0; color: #82755c; font-size: 14px; line-height: 1.55; }
.notebook-placeholder { font-style: italic; }
.notebook-draft-note { margin: 21px 0 0; padding: 13px 15px; border: 1px solid #d4ccb2; border-radius: 9px; color: #776c52; background: #f3edde; font-size: 12px; line-height: 1.55; }
.notebook-draft-note.is-review { border-color: #d2b18a; color: #81603d; background: #fcf0df; }
.notebook-finding { margin-top: 24px; padding: 20px 21px; border: 1px solid #b6c99a; border-left: 4px solid #6e8d55; border-radius: 11px; background: #edf3e2; }
.notebook-finding h4 { margin: 8px 0 11px; color: #3f6036; font: 700 25px/1.2 Georgia,"Times New Roman",serif; }
.notebook-finding p { margin: 0; color: #596c4a; font-size: 14px; line-height: 1.6; }
.notebook-finding.is-locked { border-style: dashed; border-width: 1px; border-color: #c9c1a9; background: #f5f0e3; }
.notebook-finding.is-locked p { color: #81745b; font-size: 13px; }
.notebook-context { margin: 19px 0 0; color: #8a7b60; font-size: 12px; line-height: 1.6; }
.notebook-footer { flex: 0 0 auto; padding: 15px 27px; border-top: 1px solid #d9d1b9; background: #f0ebdc; }
.notebook-footer p { margin: 0; color: #6d755d; font-size: 12px; line-height: 1.45; }
.research-notebook button:focus-visible { outline: 3px solid #3b6855; outline-offset: 3px; }

.resume-research { margin-top: 21px; padding: 20px 23px; border: 1px solid #b3c69b; border-left: 4px solid #658b53; border-radius: 12px; background: #eaf1de; }
.resume-research h2 { margin: 7px 0 10px; color: #3f5e35; font: 700 26px/1.18 Georgia,"Times New Roman",serif; }
.resume-research > p { margin: 0; color: #5b6c4b; font-size: 14px; line-height: 1.55; }
.resume-research .primary-button { margin-top: 16px; }
.resume-research .resume-note { margin-top: 12px; color: #6d7a5e; font-size: 12px; }
.research-welcome .start-save-status { margin: 11px 0 0; color: #758063; font-size: 12px; line-height: 1.5; }
.research-welcome .welcome-actions .secondary-button { min-height: 48px; padding: 11px 19px; border: 1px solid #c5bca5; border-radius: 11px; color: #6b604a; background: #fffaf0; box-shadow: none; font-size: 15px; font-weight: 700; line-height: 1.4; cursor: pointer; }
.research-welcome .welcome-actions .secondary-button:hover:not(:disabled) { color: #495c3d; border-color: #9aaf83; background: #f0f4e8; transform: none; }
.research-welcome .welcome-actions .secondary-button:disabled { opacity: .6; cursor: default; }
.research-save-warning { position: fixed; z-index: 50; right: 18px; bottom: 16px; width: max-content; max-width: min(450px,calc(100vw - 36px)); margin: 0; padding: 12px 16px; border: 1px solid #c8b18d; border-radius: 11px; color: #795f3b; background: #fff4dd; box-shadow: 0 5px 22px rgba(32,29,20,.17); font-size: 13px; line-height: 1.45; }
.research-save-warning[hidden] { display: none; }
.research-save-warning { display: flex; align-items: flex-start; gap: 10px; }
.research-save-warning > span { min-width: 0; }
.save-warning-close { flex: 0 0 36px; min-height: 36px; padding: 4px; border: 1px solid #c8b18d; border-radius: 8px; color: #795f3b; background: #fff9ed; font: 24px/1 Arial,sans-serif; cursor: pointer; }

@media (max-width: 1024px) {
    .scene-notebook-button { min-height: 44px; padding: 8px 11px; gap: 7px; border-radius: 13px; font-size: 14px; }
    .hub-stage:has(.scene-notebook-button) .scene-heading,
    .location-stage:has(.scene-notebook-button) .scene-heading { width: min(470px,calc(100vw - 322px)); }
}
@media (max-width: 700px) {
    .scene-notebook-button { width: 44px; min-height: 44px; padding: 9px; border-radius: 12px; }
    .notebook-button-label { display: none; }
    .notebook-button-count { position: absolute; top: -5px; right: -6px; min-width: 26px; padding: 3px 4px; border-radius: 6px; font-size: 9px; background: #e3edcf; }
    .hub-stage:has(.scene-notebook-button) .scene-heading,
    .location-stage:has(.scene-notebook-button) .scene-heading { width: calc(100vw - 178px); }
    .hub-stage:has(.scene-notebook-button) .scene-heading h1,
    .location-stage:has(.scene-notebook-button) .scene-heading h1 { overflow: hidden; font-size: 16px; white-space: nowrap; text-overflow: ellipsis; }
    .resume-research { padding: 17px 18px; }
    .resume-research h2 { font-size: 24px; }
    .resume-research .primary-button { width: 100%; }
    .research-save-warning { right: 10px; bottom: 10px; max-width: calc(100vw - 20px); padding: 10px 13px; font-size: 12px; }
}
@media (max-width: 600px) {
    .research-notebook { width: 100vw; border-left: 0; border-radius: 0; }
    .notebook-header { gap: 12px; padding: 20px 19px 14px; }
    .notebook-header h2 { font-size: 27px; }
    .notebook-intro { padding: 0 19px 15px; font-size: 12px; }
    .notebook-tabs { gap: 7px; padding: 13px 15px; }
    .notebook-tab { gap: 6px; min-height: 49px; padding: 9px; }
    .notebook-tab-label { font-size: 11px; }
    .notebook-pages { padding: 21px 20px 26px; }
    .notebook-entry-heading h3 { font-size: 27px; }
    .notebook-records dd { font-size: 14px; }
    .notebook-finding { padding: 18px; }
    .notebook-finding h4 { font-size: 24px; }
    .notebook-footer { padding: 12px 20px; }
}
@media (max-width: 390px) {
    .hub-stage:has(.scene-notebook-button) .scene-heading,
    .location-stage:has(.scene-notebook-button) .scene-heading { padding-inline: 9px; }
    .hub-stage:has(.scene-notebook-button) .scene-heading h1,
    .location-stage:has(.scene-notebook-button) .scene-heading h1 { font-size: 14px; }
    .notebook-header { padding-inline: 16px; }
    .notebook-header h2 { font-size: 25px; }
    .notebook-tabs { padding-inline: 12px; }
    .notebook-tab-number { display: none; }
    .notebook-pages { padding-inline: 17px; }
}
@media (max-height: 560px) {
    .notebook-header { padding-top: 15px; padding-bottom: 12px; }
    .notebook-header h2 { font-size: 25px; }
    .notebook-intro { padding-bottom: 11px; font-size: 12px; }
    .notebook-tabs { gap: 6px; padding-top: 10px; padding-bottom: 10px; }
    .notebook-tab { min-height: 43px; padding-block: 7px; }
    .notebook-pages { padding-top: 18px; }
    .notebook-footer { padding-top: 10px; padding-bottom: 10px; }
}
@media (max-height: 430px) {
    .notebook-header { align-items: center; padding-top: 10px; padding-bottom: 8px; }
    .notebook-header .notebook-eyebrow, .notebook-intro { display: none; }
    .notebook-header h2 { margin: 0; font-size: 24px; }
    .notebook-tabs { padding-block: 8px; }
    .notebook-pages { padding-top: 15px; padding-bottom: 19px; }
    .notebook-footer { padding-block: 8px; }
    .notebook-footer p { font-size: 11px; }
}
@media (prefers-reduced-motion: reduce) {
    .scene-notebook-button, .research-notebook, .research-notebook *, .resume-research * { animation: none !important; transition: none !important; scroll-behavior: auto !important; }
}

/* On a phone the whole notebook scrolls; long headings and tabs never
   squeeze the entry into a zero-height nested scroll area. */
@media (max-width: 800px), (max-width: 1100px) and (max-height: 500px) {
    .research-notebook { inset: 0; width: 100%; max-width: 100%; box-sizing: border-box; border-left: 0; border-radius: 0; }
    .notebook-layout { display: block; overflow-y: auto; overflow-x: hidden; overscroll-behavior: contain; -webkit-overflow-scrolling: touch; scroll-padding-top: calc(110px + env(safe-area-inset-top, 0px)); }
    .notebook-header { position: sticky; z-index: 3; top: 0; align-items: flex-start; gap: 12px; padding: calc(16px + env(safe-area-inset-top, 0px)) max(16px, env(safe-area-inset-right, 0px)) 16px max(16px, env(safe-area-inset-left, 0px)); box-shadow: 0 1px 0 #d7cfb8; }
    .notebook-header h2 { margin: 6px 0 0; font-size: 25px; line-height: 1.2; overflow-wrap: anywhere; }
    .notebook-header .notebook-eyebrow { display: block; }
    .notebook-eyebrow { font-size: 12px; line-height: 1.45; letter-spacing: .035em; }
    .notebook-close { min-height: 48px; flex-basis: 48px; width: 48px; }
    .notebook-intro { display: block; padding: 14px max(16px, env(safe-area-inset-right, 0px)) 16px max(16px, env(safe-area-inset-left, 0px)); font-size: 16px; line-height: 1.55; }
    .notebook-tabs { gap: 8px; padding: 14px max(16px, env(safe-area-inset-right, 0px)) 14px max(16px, env(safe-area-inset-left, 0px)); }
    .notebook-tab { gap: 8px; min-height: 48px; padding: 11px 10px; }
    .notebook-tab-number { display: none; }
    .notebook-tab-label { font-size: 14px; line-height: 1.4; overflow-wrap: anywhere; hyphens: auto; }
    .notebook-pages { min-height: 0; padding: 20px max(16px, env(safe-area-inset-right, 0px)) 24px max(16px, env(safe-area-inset-left, 0px)); overflow: visible; scrollbar-gutter: auto; }
    .notebook-entry { overflow-wrap: anywhere; hyphens: auto; }
    .notebook-entry-heading h3 { font-size: 27px; line-height: 1.2; }
    .notebook-status { max-width: 100%; font-size: 14px; }
    .notebook-empty { padding: 18px; }
    .notebook-empty p, .notebook-records dt, .notebook-records dd,
    .notebook-section > p, .notebook-finding p, .notebook-finding.is-locked p { font-size: 16px; line-height: 1.6; }
    .notebook-section h4 { font-size: 13px; line-height: 1.5; letter-spacing: .035em; }
    .notebook-draft-note, .notebook-context { font-size: 14px; line-height: 1.6; }
    .notebook-finding { padding: 18px 16px; }
    .notebook-finding h4 { font-size: 25px; overflow-wrap: anywhere; }
    .notebook-footer { padding: 16px max(16px, env(safe-area-inset-right, 0px)) calc(16px + env(safe-area-inset-bottom, 0px)) max(16px, env(safe-area-inset-left, 0px)); }
    .notebook-footer p { font-size: 14px; line-height: 1.5; overflow-wrap: anywhere; }
    .research-save-warning { right: max(10px, env(safe-area-inset-right, 0px)); bottom: calc(10px + env(safe-area-inset-bottom, 0px)); max-width: calc(100% - 20px - env(safe-area-inset-left, 0px) - env(safe-area-inset-right, 0px)); font-size: 14px; overflow-wrap: anywhere; }
    .save-warning-close { flex-basis: 44px; min-width: 44px; min-height: 44px; }
}
@media (max-width: 1100px) and (max-height: 500px) {
    .notebook-header { align-items: center; padding-top: max(10px, env(safe-area-inset-top, 0px)); padding-bottom: 10px; }
    .notebook-header .notebook-eyebrow { display: none; }
    .notebook-header h2 { margin: 0; font-size: 24px; }
    .notebook-layout { scroll-padding-top: calc(82px + env(safe-area-inset-top, 0px)); }
}
