/* Responsive shell and optional light theme */
html{color-scheme:dark}
html[data-theme="light"]{
  color-scheme:light;
  --bg:#f4f6f2;
  --panel:#ffffff;
  --panel2:#eef2ec;
  --line:rgba(24,42,31,.13);
  --muted:#68756d;
  --soft:#34453b;
  --white:#142219;
  --lime:#6f9200;
  --blue:#2d729f;
  --orange:#a85a1f;
  --red:#b64242;
  --green:#277c4b;
  --shadow:0 18px 50px rgba(27,47,34,.08);
}

.theme-toggle{min-height:36px;display:inline-flex;align-items:center;gap:7px;padding:0 11px;border:1px solid var(--line);border-radius:999px;background:var(--panel);color:var(--soft);font-size:12px}
.theme-toggle svg{width:16px;height:16px}
.theme-toggle:hover{border-color:rgba(141,184,0,.48)}
.mobile-only-nav{display:none!important}

html[data-theme="light"] body{background:#f4f6f2}
html[data-theme="light"] .rail{background:rgba(255,255,255,.94);box-shadow:10px 0 35px rgba(27,47,34,.04)}
html[data-theme="light"] .logo img,
html[data-theme="light"] .co-header img{filter:invert(1)}
html[data-theme="light"] .eyebrow{color:#849087}
html[data-theme="light"] .nav button{color:#607067}
html[data-theme="light"] .nav button:hover,
html[data-theme="light"] .nav button.active{background:#edf3e7;color:#17251b}
html[data-theme="light"] .profile{color:#36483d}
html[data-theme="light"] .avatar{background:linear-gradient(135deg,#cfe5f2,#dcedae);color:#142219}
html[data-theme="light"] .card{background:#fff;border-color:rgba(24,42,31,.12)}
html[data-theme="light"] .summary:after{border-color:rgba(111,146,0,.14);box-shadow:0 0 0 28px rgba(111,146,0,.035),0 0 0 56px rgba(111,146,0,.02)}
html[data-theme="light"] .breadcrumb strong,
html[data-theme="light"] .pipe-name,
html[data-theme="light"] .page-head h1,
html[data-theme="light"] .section-title h2,
html[data-theme="light"] .card h2,
html[data-theme="light"] .card h3{color:#142219}
html[data-theme="light"] .brief-item,
html[data-theme="light"] .quick-link,
html[data-theme="light"] .checkline{color:#435249}
html[data-theme="light"] .stat span,
html[data-theme="light"] .metric span,
html[data-theme="light"] .pipe-name span,
html[data-theme="light"] .deal-summary span{color:#728078}
html[data-theme="light"] .tag{background:#eff4ec;color:#4e6256}
html[data-theme="light"] .tag.blue{background:#e8f3fa;color:#2d729f}
html[data-theme="light"] .tag.warn{background:#fff0e5;color:#9a4f18}
html[data-theme="light"] .stage{background:#f7f9f6;color:#627168}
html[data-theme="light"] .stage.active{background:#edf4df;color:#5e7b00}
html[data-theme="light"] .status.teal{background:#e4f3ea;color:#246a43}
html[data-theme="light"] .status.gold{background:#fff0dd;color:#925816}
html[data-theme="light"] .status.gray{background:#eef1ee;color:#66736b}
html[data-theme="light"] .prototype-banner{background:#fff7ef;color:#6e5949;border-color:#efd4ba}
html[data-theme="light"] .prototype-banner b{color:#9a531d}
html[data-theme="light"] .privacy-banner,
html[data-theme="light"] .reason-box,
html[data-theme="light"] .share-preview,
html[data-theme="light"] .visibility-preview,
html[data-theme="light"] .co-review{background:#f2f7eb}
html[data-theme="light"] .mismatch{background:#fff6ee}
html[data-theme="light"] .detail-metric,
html[data-theme="light"] .readiness-steps,
html[data-theme="light"] .reveal-list div{background:#f7f9f6}
html[data-theme="light"] .why{background:#fff8f3;border-color:#efd6c4}
html[data-theme="light"] .why h3{color:#9a4f18}
html[data-theme="light"] .why ul{color:#705b4d}
html[data-theme="light"] .btn-primary,
html[data-theme="light"] .chat-send,
html[data-theme="light"] .co-send{background:#17251b;color:#fff}
html[data-theme="light"] .btn-secondary,
html[data-theme="light"] .role-switch,
html[data-theme="light"] .text-action{color:#24352a}
html[data-theme="light"] .icon-btn,
html[data-theme="light"] .help,
html[data-theme="light"] .theme-toggle{background:#fff;color:#34453b}
html[data-theme="light"] .chat-trigger{background:#eff5e6;color:#405c27}
html[data-theme="light"] .workspace-backdrop,
html[data-theme="light"] .onboarding-backdrop,
html[data-theme="light"] .modal-backdrop,
html[data-theme="light"] .chat-modal{background:rgba(28,38,31,.46)}
html[data-theme="light"] .workspace-modal,
html[data-theme="light"] .modal,
html[data-theme="light"] .chat-panel,
html[data-theme="light"] .onboarding-shell.conversation-onboarding,
html[data-theme="light"] .co-profile,
html[data-theme="light"] .co-footer,
html[data-theme="light"] .co-compose,
html[data-theme="light"] .co-import-card{background:#fff;border-color:rgba(24,42,31,.14)}
html[data-theme="light"] .workspace-modal p,
html[data-theme="light"] .modal p,
html[data-theme="light"] .chat-head p,
html[data-theme="light"] .co-progress-label,
html[data-theme="light"] .co-context,
html[data-theme="light"] .co-footer-copy,
html[data-theme="light"] .co-hint{color:#65736b}
html[data-theme="light"] .chat-context{background:#eef5e7;color:#3c5927}
html[data-theme="light"] .chat-message.assistant,
html[data-theme="light"] .co-bubble,
html[data-theme="light"] .co-source-card,
html[data-theme="light"] .co-profile-card{background:#f5f7f4;color:#24352a;border-color:rgba(24,42,31,.12)}
html[data-theme="light"] .chat-message.user,
html[data-theme="light"] .co-message.user .co-bubble{background:#1b2b20;color:#fff}
html[data-theme="light"] .co-bubble strong{color:#142219}
html[data-theme="light"] .co-message.user .co-bubble strong{color:#fff}
html[data-theme="light"] .co-chip,
html[data-theme="light"] .co-close,
html[data-theme="light"] .co-profile-toggle,
html[data-theme="light"] .co-mic{background:#f3f6f1;color:#405c27;border-color:rgba(24,42,31,.16)}
html[data-theme="light"] .co-chip:hover,
html[data-theme="light"] .co-chip.selected{background:#edf5e3;color:#405c27}
html[data-theme="light"] .co-compose textarea,
html[data-theme="light"] .chat-compose input,
html[data-theme="light"] .co-import-card input[type="url"]{background:#f7f9f6;color:#142219;border-color:rgba(24,42,31,.17)}
html[data-theme="light"] .co-profile-card b,
html[data-theme="light"] .co-profile-head h2,
html[data-theme="light"] .co-profile-identity b,
html[data-theme="light"] .co-context b{color:#142219}
html[data-theme="light"] .co-completeness{background:conic-gradient(var(--lime) var(--complete),#dfe5df 0)}
html[data-theme="light"] .co-completeness:before{background:#fff}
html[data-theme="light"] .co-data-row b{color:#36473d}
html[data-theme="light"] .co-data-row b.empty{color:#88938d}
html[data-theme="light"] .co-privacy-line{border-color:rgba(24,42,31,.09)}
html[data-theme="light"] .co-privacy-line span{color:#5d6d63}
html[data-theme="light"] .co-import-overlay{background:rgba(36,48,40,.48)}
html[data-theme="light"] .settings-form .field input:not([type="checkbox"]):not([type="file"]),
html[data-theme="light"] .settings-form .field select,
html[data-theme="light"] .filterbar .search,
html[data-theme="light"] .filterbar select,
html[data-theme="light"] .custom-select-trigger{background:#fff;color:#1c2d22;border-color:rgba(24,42,31,.16);box-shadow:0 1px 2px rgba(27,47,34,.05)}
html[data-theme="light"] .custom-select-menu{background:#fff;border-color:rgba(24,42,31,.14);box-shadow:0 20px 50px rgba(27,47,34,.15)}
html[data-theme="light"] .custom-select-option{color:#405047}
html[data-theme="light"] .custom-select-option:hover,
html[data-theme="light"] .custom-select-option:focus-visible{background:#eff4ec;color:#142219}
html[data-theme="light"] .custom-select-option[aria-selected="true"]{background:#eaf3dd;color:#506b00}

@media(max-width:720px){
  body{overflow-x:hidden}
  .app{display:block;padding-bottom:78px}
  .rail{inset:auto 0 0 0;width:100%;height:74px;padding:7px 8px max(7px,env(safe-area-inset-bottom));border-right:0;border-top:1px solid var(--line);display:block;z-index:45;overflow:hidden}
  .rail .logo,.rail .eyebrow,.rail .rail-bottom{display:none}
  .rail>.nav{display:flex;align-items:stretch;gap:4px;width:100%;height:100%;overflow-x:auto;scrollbar-width:none}
  .rail>.nav::-webkit-scrollbar{display:none}
  .rail>.nav button{display:flex;min-width:68px;flex:1;flex-direction:column;justify-content:center;gap:4px;padding:6px 7px;border-radius:12px;font-size:10px;white-space:nowrap;text-align:center}
  .rail>.nav button span{display:block}
  .rail>.nav button svg{width:18px;height:18px}
  .rail>.nav button.active:before{display:none}
  .rail>.nav .mobile-only-nav{display:flex!important}
  .main{margin-left:0;width:100%;padding:16px 14px 28px}
  .topbar{align-items:flex-start;gap:12px;margin-bottom:22px}
  .breadcrumb{padding-top:10px;white-space:nowrap}
  .top-actions{min-width:0;overflow-x:auto;padding-bottom:3px;scrollbar-width:none}
  .top-actions::-webkit-scrollbar{display:none}
  .top-actions>*{flex:none}
  .theme-toggle span,.icon-btn,.help{display:none}
  .theme-toggle{width:38px;justify-content:center;padding:0}
  .page-head{display:grid;gap:16px;margin-bottom:22px}
  .page-head h1{font-size:clamp(32px,10vw,42px);line-height:1}
  .page-head .btn-primary,.page-head .btn-secondary{width:100%;min-height:46px}
  .prototype-banner{margin-top:-4px;margin-bottom:20px}
  .card{border-radius:20px}
  .summary,.brief,.pipeline,.quick,.detail,.why,.journey-card,.home-flow{padding:20px}
  .network-grid,.thesis-grid,.relationship-layout,.capital-grid{gap:12px}
  .match-card,.thesis-card,.relationship-panel,.access-log,.capital-main,.capital-side{padding:18px}
  .card-actions,.relationship-actions,.feed-actions{flex-direction:column;align-items:stretch}
  .card-actions button,.relationship-actions button,.feed-actions button{width:100%}
  .stat-row{display:grid;grid-template-columns:repeat(3,1fr);gap:10px}
  .stat strong{font-size:22px}
  .stat span{font-size:10px}
  .stage-path{overflow-x:auto;flex-wrap:nowrap;padding-bottom:4px}
  .stage-path span{white-space:nowrap}
  .capital-metrics{grid-template-columns:repeat(2,minmax(0,1fr))}
  .privacy-banner{padding:16px}
  .chat-modal{padding:0;z-index:55}
  .chat-panel{width:100%;height:100dvh;border-radius:0;border:0}
  .modal-backdrop,.workspace-backdrop{padding:8px;z-index:55}
  .modal,.workspace-modal{max-height:calc(100dvh - 16px);border-radius:18px}
  .onboarding-backdrop{z-index:60}
  .onboarding-shell.conversation-onboarding{height:100dvh}
  .co-compose{grid-template-columns:minmax(0,1fr) 48px}
  .co-send{grid-column:1/-1;height:44px}
  .co-hint{display:none}
  .co-footer{padding-bottom:max(11px,env(safe-area-inset-bottom))}
  .toast{left:14px;right:14px;bottom:92px;text-align:center}
}

@media(max-width:390px){
  .main{padding-left:11px;padding-right:11px}
  .rail>.nav button{min-width:63px}
  .role-switch{max-width:122px;overflow:hidden;text-overflow:ellipsis;white-space:nowrap}
  .chat-trigger{padding-left:10px;padding-right:10px}
  .stat-row{grid-template-columns:1fr 1fr}
  .co-header{gap:10px}
  .co-progress{gap:4px}
  .co-profile-toggle{padding:7px 8px}
}

/* Explicit surface layer prevents mobile Safari from mixing dark surfaces with light tokens. */
html[data-theme="light"],
html[data-theme="light"] body,
html[data-theme="light"] body.theme-light,
html[data-theme="light"] .app,
html[data-theme="light"] .main,
html[data-theme="light"] .view,
html[data-theme="light"] .mvp-home{
  background-color:#f4f6f2!important;
  background-image:none!important;
  color:#142219!important;
}

html[data-theme="light"] .card,
html[data-theme="light"] .summary,
html[data-theme="light"] .brief,
html[data-theme="light"] .journey-card,
html[data-theme="light"] .relationship-panel,
html[data-theme="light"] .quick,
html[data-theme="light"] .match-card,
html[data-theme="light"] .thesis-card,
html[data-theme="light"] .access-log,
html[data-theme="light"] .capital-main,
html[data-theme="light"] .capital-side,
html[data-theme="light"] .settings-form{
  background:#fff!important;
  border-color:rgba(24,42,31,.13)!important;
  color:#142219!important;
  box-shadow:0 16px 40px rgba(27,47,34,.07)!important;
}

html[data-theme="light"] .page-head h1,
html[data-theme="light"] .page-head h2,
html[data-theme="light"] .summary h2,
html[data-theme="light"] .brief h2,
html[data-theme="light"] .journey-card h3,
html[data-theme="light"] .relationship-panel h2,
html[data-theme="light"] .quick h2,
html[data-theme="light"] .match-card h3,
html[data-theme="light"] .thesis-card h3,
html[data-theme="light"] .settings-form h2,
html[data-theme="light"] .section-title h2,
html[data-theme="light"] .stat strong,
html[data-theme="light"] .metric b{
  color:#142219!important;
}

html[data-theme="light"] .page-head p,
html[data-theme="light"] .summary p,
html[data-theme="light"] .journey-card p,
html[data-theme="light"] .disclosure-copy,
html[data-theme="light"] .loc,
html[data-theme="light"] .source-note{
  color:#617067!important;
}

html[data-theme="light"] .brief-item,
html[data-theme="light"] .quick-link,
html[data-theme="light"] .readiness-list>div,
html[data-theme="light"] .evidence-row,
html[data-theme="light"] .audit-event,
html[data-theme="light"] .thesis-facts span{
  color:#405047!important;
  border-color:rgba(24,42,31,.11)!important;
}

html[data-theme="light"] .stat span,
html[data-theme="light"] .metric span,
html[data-theme="light"] .last-confirmed,
html[data-theme="light"] .provenance{
  color:#6d7a72!important;
}

html[data-theme="light"] .summary:after{
  border-color:rgba(111,146,0,.16)!important;
  box-shadow:0 0 0 28px rgba(111,146,0,.045),0 0 0 56px rgba(111,146,0,.025)!important;
}

html[data-theme="light"] .btn-primary{
  background:#17321f!important;
  color:#fff!important;
  box-shadow:0 8px 22px rgba(23,50,31,.16)!important;
}

html[data-theme="light"] .rail{
  background:#fff!important;
  border-color:rgba(24,42,31,.13)!important;
}

@media(max-width:720px){
  html[data-theme="light"] body,
  html[data-theme="light"] .app,
  html[data-theme="light"] .main,
  html[data-theme="light"] .view{
    background:#f4f6f2!important;
  }
  html[data-theme="light"] .card{
    background:#fff!important;
  }
  html[data-theme="light"] .rail>.nav button.active{
    background:#eef5e7!important;
    color:#203629!important;
  }
}
