
/* v13 OAuth + dark-theme readability fix
   Loaded after app.css and global-nav.css so it can correct both app and site navigation. */

:root[data-theme="dark"]{
  color-scheme:dark;
  --theme-surface:#0c2141;
  --theme-surface-soft:#091d39;
  --theme-surface-soft-2:#0a203e;
  --theme-surface-muted:#10294d;
  --theme-surface-hover:#112c51;
  --theme-input:#0a1d39;
  --theme-border:#1c3a64;
  --theme-success:#7ce8cf;
  --theme-success-muted:#9fcfc4;
  --theme-warning-bg:#3d2c13;
  --theme-warning-text:#ffd27d;
  --theme-danger-bg:#3c1d29;
  --theme-danger-text:#ff9ca5;
}
@media (prefers-color-scheme:dark){
  :root[data-theme="system"]{
    color-scheme:dark;
    --theme-surface:#0c2141;
    --theme-surface-soft:#091d39;
    --theme-surface-soft-2:#0a203e;
    --theme-surface-muted:#10294d;
    --theme-surface-hover:#112c51;
    --theme-input:#0a1d39;
    --theme-border:#1c3a64;
    --theme-success:#7ce8cf;
    --theme-success-muted:#9fcfc4;
    --theme-warning-bg:#3d2c13;
    --theme-warning-text:#ffd27d;
    --theme-danger-bg:#3c1d29;
    --theme-danger-text:#ff9ca5;
  }
}

:root[data-theme="dark"] input,
:root[data-theme="dark"] textarea,
:root[data-theme="dark"] select{
  color:var(--ink);
  background-color:var(--theme-input);
  border-color:var(--line);
  caret-color:var(--ink);
}
:root[data-theme="dark"] input::placeholder,
:root[data-theme="dark"] textarea::placeholder{color:#7f93af;opacity:1}
@media (prefers-color-scheme:dark){
  :root[data-theme="system"] input,
  :root[data-theme="system"] textarea,
  :root[data-theme="system"] select{
    color:var(--ink);
    background-color:var(--theme-input);
    border-color:var(--line);
    caret-color:var(--ink);
  }
  :root[data-theme="system"] input::placeholder,
  :root[data-theme="system"] textarea::placeholder{color:#7f93af;opacity:1}
}

/* Shared site navigation must follow the Web theme too. */
:root[data-theme="dark"] .global-header{
  background:rgba(7,23,45,.96)!important;
  border-color:var(--line)!important;
}
:root[data-theme="dark"] .global-brand{color:var(--navy)!important}
:root[data-theme="dark"] .global-nav-links a,
:root[data-theme="dark"] .global-mobile-menu>a{color:var(--muted)!important}
:root[data-theme="dark"] .global-nav-links a:hover,
:root[data-theme="dark"] .global-mobile-menu>a:hover{background:var(--theme-surface-muted)!important;color:#82adff!important}
:root[data-theme="dark"] .global-nav-button-secondary,
:root[data-theme="dark"] .global-menu-toggle,
:root[data-theme="dark"] .global-mobile-menu{
  background:var(--theme-surface)!important;
  color:var(--ink)!important;
  border-color:var(--line)!important;
}
:root[data-theme="dark"] .global-menu-toggle span{background:var(--ink)!important}
@media (prefers-color-scheme:dark){
  :root[data-theme="system"] .global-header{
    background:rgba(7,23,45,.96)!important;
    border-color:var(--line)!important;
  }
  :root[data-theme="system"] .global-brand{color:var(--navy)!important}
  :root[data-theme="system"] .global-nav-links a,
  :root[data-theme="system"] .global-mobile-menu>a{color:var(--muted)!important}
  :root[data-theme="system"] .global-nav-links a:hover,
  :root[data-theme="system"] .global-mobile-menu>a:hover{background:var(--theme-surface-muted)!important;color:#82adff!important}
  :root[data-theme="system"] .global-nav-button-secondary,
  :root[data-theme="system"] .global-menu-toggle,
  :root[data-theme="system"] .global-mobile-menu{
    background:var(--theme-surface)!important;
    color:var(--ink)!important;
    border-color:var(--line)!important;
  }
  :root[data-theme="system"] .global-menu-toggle span{background:var(--ink)!important}
}

/* Primary raised surfaces which had hard-coded #fff backgrounds. */
:root[data-theme="dark"] :is(
  .card,.quick-btn,.stat,.schedule-item,.mini-app-feature i,.project-card,.day,
  .chat-input,.suggestion,.app-feature-card,.modal,.modal-head,.modal-actions,
  .detail-section,.search-result,.app-feature-drawer,.drawer-close,.web-seo-summary,
  .date-pill,.profile-avatar,.week-day,.task-filter-bar input,.task-filter-bar select,
  .task-row,.smart-inbox-summary>div,.smart-candidate,.space-card,.dependency-choice,
  .setting-fields select,.archive-completed-summary>div,.completed-archive-row,
  .event-comment,.event-comment-compose input,.saved-filter-chip
){
  background:var(--theme-surface)!important;
  color:var(--ink);
  border-color:var(--line)!important;
}
@media (prefers-color-scheme:dark){
  :root[data-theme="system"] :is(
    .card,.quick-btn,.stat,.schedule-item,.mini-app-feature i,.project-card,.day,
    .chat-input,.suggestion,.app-feature-card,.modal,.modal-head,.modal-actions,
    .detail-section,.search-result,.app-feature-drawer,.drawer-close,.web-seo-summary,
    .date-pill,.profile-avatar,.week-day,.task-filter-bar input,.task-filter-bar select,
    .task-row,.smart-inbox-summary>div,.smart-candidate,.space-card,.dependency-choice,
    .setting-fields select,.archive-completed-summary>div,.completed-archive-row,
    .event-comment,.event-comment-compose input,.saved-filter-chip
  ){
    background:var(--theme-surface)!important;
    color:var(--ink);
    border-color:var(--line)!important;
  }
}

/* Inset / grouped surfaces which were light gray/blue in dark mode. */
:root[data-theme="dark"] :is(
  .todo,.mini-app-feature,.doc-result,.upload-card,.detail-event,.detail-todo,.detail-file,
  .project-next-line,.google-profile,.sync-detail,.checklist-preview-empty,
  .space-project-list>button,.choice-row span,.file-picker-row,.category-add input,
  .setting-card select,.google-auto-sync,.document-type-result,.document-structure-preview>div,
  .saved-filter-bar,.field input,.field textarea,.field select,.switch-field,.analysis-progress,
  .drawer-point,.advanced-item-fields details,.calendar-mode-switch,.space-stats span,
  .preview-check,.event-comments-panel,.apk-editor-body,.archive-actions button,.lap-list span,
  .sync-status,.activity-row.unread,.day.muted,.item-tags>span,.priority,.event-existing-files span,
  .task-row.blocked,.milestone-row.blocked .detail-event
){
  background:var(--theme-surface-soft)!important;
  color:var(--ink);
  border-color:var(--line)!important;
}
@media (prefers-color-scheme:dark){
  :root[data-theme="system"] :is(
    .todo,.mini-app-feature,.doc-result,.upload-card,.detail-event,.detail-todo,.detail-file,
    .project-next-line,.google-profile,.sync-detail,.checklist-preview-empty,
    .space-project-list>button,.choice-row span,.file-picker-row,.category-add input,
    .setting-card select,.google-auto-sync,.document-type-result,.document-structure-preview>div,
    .saved-filter-bar,.field input,.field textarea,.field select,.switch-field,.analysis-progress,
    .drawer-point,.advanced-item-fields details,.calendar-mode-switch,.space-stats span,
    .preview-check,.event-comments-panel,.apk-editor-body,.archive-actions button,.lap-list span,
    .sync-status,.activity-row.unread,.day.muted,.item-tags>span,.priority,.event-existing-files span,
    .task-row.blocked,.milestone-row.blocked .detail-event
  ){
    background:var(--theme-surface-soft)!important;
    color:var(--ink);
    border-color:var(--line)!important;
  }
}

/* Hover/readability surfaces. */
:root[data-theme="dark"] .nav-btn:hover{background:var(--theme-surface-hover)!important;color:var(--navy)!important}
:root[data-theme="dark"] .mini-app-feature:hover{background:var(--blue-soft)!important}
:root[data-theme="dark"] .msg{background:var(--blue-soft)!important;color:var(--ink)!important}
:root[data-theme="dark"] .msg.user{background:var(--blue)!important;color:#fff!important}
:root[data-theme="dark"] .focus-ring{
  background:radial-gradient(circle,var(--theme-surface) 57%,transparent 58%),conic-gradient(var(--blue) 0 72%,#14335b 72%)!important;
}
@media (prefers-color-scheme:dark){
  :root[data-theme="system"] .nav-btn:hover{background:var(--theme-surface-hover)!important;color:var(--navy)!important}
  :root[data-theme="system"] .mini-app-feature:hover{background:var(--blue-soft)!important}
  :root[data-theme="system"] .msg{background:var(--blue-soft)!important;color:var(--ink)!important}
  :root[data-theme="system"] .msg.user{background:var(--blue)!important;color:#fff!important}
  :root[data-theme="system"] .focus-ring{
    background:radial-gradient(circle,var(--theme-surface) 57%,transparent 58%),conic-gradient(var(--blue) 0 72%,#14335b 72%)!important;
  }
}

/* Success/warning/danger chips used fixed dark text intended for a white page. */
:root[data-theme="dark"] :is(.analysis-notice b,.drawer-release b,.sync-status.connected,.status.done,.web-available,.insight-row i,.activity-mini-row i,.search-kind.project){
  color:var(--theme-success)!important;
}
:root[data-theme="dark"] :is(.analysis-notice span,.drawer-release span){color:var(--theme-success-muted)!important}
:root[data-theme="dark"] .priority.p3{background:var(--theme-warning-bg)!important;color:var(--theme-warning-text)!important}
:root[data-theme="dark"] .priority.p4{background:var(--theme-danger-bg)!important;color:var(--theme-danger-text)!important}
:root[data-theme="dark"] .space-conflicts article{background:var(--theme-danger-bg)!important;border-color:#6b3443!important}
:root[data-theme="dark"] .todo-kind{color:#b7aaff!important}
@media (prefers-color-scheme:dark){
  :root[data-theme="system"] :is(.analysis-notice b,.drawer-release b,.sync-status.connected,.status.done,.web-available,.insight-row i,.activity-mini-row i,.search-kind.project){
    color:var(--theme-success)!important;
  }
  :root[data-theme="system"] :is(.analysis-notice span,.drawer-release span){color:var(--theme-success-muted)!important}
  :root[data-theme="system"] .priority.p3{background:var(--theme-warning-bg)!important;color:var(--theme-warning-text)!important}
  :root[data-theme="system"] .priority.p4{background:var(--theme-danger-bg)!important;color:var(--theme-danger-text)!important}
  :root[data-theme="system"] .space-conflicts article{background:var(--theme-danger-bg)!important;border-color:#6b3443!important}
  :root[data-theme="system"] .todo-kind{color:#b7aaff!important}
}

/* Generic components which relied on the browser default white input background. */
:root[data-theme="dark"] :is(.comment-compose input,.space-invite input,.category-add input,.search-filter-grid input,.search-filter-grid select){
  background:var(--theme-input)!important;color:var(--ink)!important;border-color:var(--line)!important;
}
@media (prefers-color-scheme:dark){
  :root[data-theme="system"] :is(.comment-compose input,.space-invite input,.category-add input,.search-filter-grid input,.search-filter-grid select){
    background:var(--theme-input)!important;color:var(--ink)!important;border-color:var(--line)!important;
  }
}

/* OAuth diagnostics */
.oauth-origin-box{
  margin:14px 0 10px;padding:13px 14px;border:1px solid var(--line);border-radius:14px;
  background:#f8fbff;display:grid;gap:8px
}
.oauth-origin-box>div{display:flex;align-items:center;gap:10px;flex-wrap:wrap}
.oauth-origin-box span{font-size:10px;font-weight:900;color:var(--muted)}
.oauth-origin-box code{
  padding:6px 8px;border-radius:8px;background:#fff;color:var(--blue);font-size:11px;
  overflow-wrap:anywhere;border:1px solid var(--line)
}
.oauth-origin-box small{font-size:10px;line-height:1.6;color:var(--muted)}
.oauth-origin-box small b{color:var(--navy)}
.oauth-help{
  margin:0 0 12px;padding:12px 14px;border-radius:13px;border:1px solid #f2c6cc;
  background:#fff7f8;color:#a12b39;font-size:11px;line-height:1.65
}
:root[data-theme="dark"] .oauth-origin-box,
:root[data-theme="dark"] .oauth-origin-box code{background:var(--theme-surface-soft)!important;border-color:var(--line)!important}
:root[data-theme="dark"] .oauth-origin-box code{color:#82adff!important}
:root[data-theme="dark"] .oauth-help{background:var(--theme-danger-bg)!important;color:var(--theme-danger-text)!important;border-color:#6b3443!important}
@media (prefers-color-scheme:dark){
  :root[data-theme="system"] .oauth-origin-box,
  :root[data-theme="system"] .oauth-origin-box code{background:var(--theme-surface-soft)!important;border-color:var(--line)!important}
  :root[data-theme="system"] .oauth-origin-box code{color:#82adff!important}
  :root[data-theme="system"] .oauth-help{background:var(--theme-danger-bg)!important;color:var(--theme-danger-text)!important;border-color:#6b3443!important}
}
