/* v1.4.6 Night Mode: soft dark Cambridge study theme. */
.night-mode {
  --bg: #0b1220;
  --paper: #111827;
  --ink: #f8fafc;
  --line: #dbeafe;
  --muted: #cbd5e1;
  --soft: #1f2937;
  --blue: #1e3a8a;
  --green: #14532d;
  --yellow: #78350f;
  --pink: #831843;
  --danger: #fca5a5;
  color-scheme: dark;
}

html.night-mode body,
body.night-mode {
  color: #f8fafc !important;
  background:
    linear-gradient(90deg, rgba(219,234,254,.07) 1px, transparent 1px),
    linear-gradient(rgba(219,234,254,.07) 1px, transparent 1px),
    radial-gradient(circle at 10% 10%, rgba(59,130,246,.18) 0 0, transparent 32%),
    radial-gradient(circle at 88% 5%, rgba(168,85,247,.16) 0 0, transparent 28%),
    #0b1220 !important;
  background-size: 28px 28px, 28px 28px, 100% 100%, 100% 100%, auto !important;
}

.night-mode .night-mode-toggle-button {
  background: #172554 !important;
  border-color: #bfdbfe !important;
  color: #f8fafc !important;
}

.night-mode .night-mode-toggle-button.active {
  background: #fef3c7 !important;
  color: #172033 !important;
  border-color: #fde68a !important;
}

.night-mode .night-mode-toggle-button small {
  color: currentColor !important;
  opacity: .82;
}

.night-mode .hero-card,
.night-mode .footer-card,
.night-mode .empty-state,
.night-mode .button-help-card,
.night-mode .overall-card,
.night-mode .paper-card,
.night-mode .paper-info,
.night-mode .year-card,
.night-mode .tracker-cell,
.night-mode .setup-panel,
.night-mode .notes-modal-panel,
.night-mode .terms-page-card,
.night-mode .terms-content-card,
.night-mode .timer-alert-panel,
.night-mode .timer-panel,
.night-mode .portal-menu,
.night-mode .focus-sounds-card,
.night-mode .focus-sounds-modal-card,
.night-mode .todo-list-card,
.night-mode .export-settings-card,
.night-mode .export-control-card,
.night-mode .update-log-card,
.night-mode .structured-note-section,
.night-mode .structured-block,
.night-mode .legacy-note-box,
.night-mode .collapsible-note-details,
.night-mode .paper-detailed-notes-card {
  background: #111827 !important;
  color: #f8fafc !important;
  border-color: #dbeafe !important;
  box-shadow: 7px 7px 0 rgba(0, 0, 0, .42) !important;
}

.night-mode .paper-card,
.night-mode .structured-note-section,
.night-mode .paper-detailed-notes-card,
.night-mode .todo-list-card,
.night-mode .export-settings-card,
.night-mode .export-control-card,
.night-mode .update-log-card,
.night-mode .focus-sounds-modal-card {
  background: #0f172a !important;
}

.night-mode .badge,
.night-mode .pixel-button,
.night-mode .quick-actions button,
.night-mode .year-quick-actions button,
.night-mode .year-chip-grid button,
.night-mode .portal-menu a,
.night-mode .open-notes-button,
.night-mode .quick-done,
.night-mode .update-log-button,
.night-mode .todo-delete,
.night-mode .todo-list-x,
.night-mode .update-log-x,
.night-mode .focus-sounds-x,
.night-mode .export-settings-x,
.night-mode .export-control-x,
.night-mode .timer-toolbar-button,
.night-mode .portal-toolbar-button,
.night-mode .focus-sounds-toolbar-button,
.night-mode .todo-toolbar-button,
.night-mode .overall-export-button {
  background: #1e293b !important;
  color: #f8fafc !important;
  border-color: #dbeafe !important;
  box-shadow: 4px 4px 0 rgba(0, 0, 0, .42) !important;
}

.night-mode .pixel-button.primary,
.night-mode .portal-toolbar-button,
.night-mode .focus-sounds-toolbar-button,
.night-mode .overall-export-button {
  background: #1e3a8a !important;
}

.night-mode .pixel-button.notes-export,
.night-mode .pixel-button.primary.notes-export,
.night-mode .todo-toolbar-button {
  background: #14532d !important;
}

.night-mode .pixel-button.danger,
.night-mode .todo-delete {
  color: #fecaca !important;
  border-color: #fca5a5 !important;
}

.night-mode input,
.night-mode textarea,
.night-mode select,
.night-mode .input-frame input,
.night-mode .input-frame select,
.night-mode .question-notes-single textarea,
.night-mode .question-notes-single input,
.night-mode .structured-block input,
.night-mode .structured-block textarea,
.night-mode .legacy-note-box textarea,
.night-mode .todo-add-row input,
.night-mode .export-settings-card input,
.night-mode .export-settings-card select,
.night-mode .export-settings-card textarea,
.night-mode .export-control-card input,
.night-mode .export-control-card select,
.night-mode .export-control-card textarea {
  background: #020617 !important;
  color: #f8fafc !important;
  border-color: #93c5fd !important;
  box-shadow: 3px 3px 0 rgba(0, 0, 0, .36) !important;
}

.night-mode input::placeholder,
.night-mode textarea::placeholder {
  color: #94a3b8 !important;
}

.night-mode .hero-description,
.night-mode .saved-line,
.night-mode .button-help-card,
.night-mode .year-card p,
.night-mode .cell-meta,
.night-mode .note-badge,
.night-mode .footer-card p,
.night-mode .empty-state p,
.night-mode .muted,
.night-mode .paper-title-row p,
.night-mode .picker-card em,
.night-mode .paper-select-row em,
.night-mode .portal-toolbar-button small,
.night-mode .portal-menu p,
.night-mode .portal-menu a span,
.night-mode .todo-list-intro,
.night-mode .todo-empty,
.night-mode .update-log-intro,
.night-mode .update-log-privacy,
.night-mode .focus-sounds-subtitle,
.night-mode .focus-sounds-note,
.night-mode .focus-sounds-status,
.night-mode .export-summary,
.night-mode .export-control-summary,
.night-mode .export-control-muted,
.night-mode .export-control-intro,
.night-mode .export-settings-hint,
.night-mode .copyright-footer-line,
.night-mode .eyebrow {
  color: #cbd5e1 !important;
}

.night-mode h1,
.night-mode h2,
.night-mode h3,
.night-mode h4,
.night-mode strong,
.night-mode .main-title,
.night-mode .paper-title-row h2,
.night-mode .tracker-cell-top,
.night-mode .status-line,
.night-mode .footer-card h2,
.night-mode .empty-state h2,
.night-mode label,
.night-mode .structured-block label,
.night-mode .question-notes-single>label,
.night-mode .legacy-note-box summary,
.night-mode .collapsible-note-details summary,
.night-mode .copyright-footer-line a {
  color: #f8fafc !important;
}

.night-mode .progress-bar,
.night-mode .year-card-top span,
.night-mode .note-badge,
.night-mode .picker-card,
.night-mode .year-picker-card,
.night-mode .focus-sound-toggle,
.night-mode .todo-list-item,
.night-mode .update-log-entry,
.night-mode .export-settings-section,
.night-mode .export-control-section,
.night-mode .export-control-preset,
.night-mode .export-control-pill,
.night-mode .export-preset-button,
.night-mode .export-choice-card,
.night-mode .export-checkbox-row,
.night-mode .optional-note-details,
.night-mode .collapsible-note-details summary {
  background: #1e293b !important;
  color: #f8fafc !important;
  border-color: rgba(219, 234, 254, .55) !important;
}

.night-mode .progress-bar-fill {
  background: repeating-linear-gradient(90deg, #60a5fa 0 10px, #38bdf8 10px 20px) !important;
}

.night-mode .tracker-cell.done,
.night-mode .picker-card.active,
.night-mode .focus-sound-toggle.active,
.night-mode .export-preset-button.active,
.night-mode .export-control-preset.active,
.night-mode .export-control-pill.active,
.night-mode .export-choice-card.active,
.night-mode .year-chip-grid button.active,
.night-mode .todo-list-item.done {
  background: #164e63 !important;
  border-color: #bfdbfe !important;
}

.night-mode .check-icon,
.night-mode .empty-circle,
.night-mode .paper-tag,
.night-mode .picker-card i,
.night-mode .paper-select-row i {
  border-color: #dbeafe !important;
  color: #f8fafc !important;
  background: #334155 !important;
}

.night-mode .note-badge.active,
.night-mode .collapsible-note-details[open] summary em {
  color: #dcfce7 !important;
  background: #14532d !important;
  border-color: #86efac !important;
}

.night-mode .modal-progress-strip,
.night-mode .year-chooser,
.night-mode .legacy-box,
.night-mode .update-log-scroll,
.night-mode .export-settings-scroll,
.night-mode .export-control-checkbox-panel,
.night-mode .export-control-summary {
  background: rgba(15, 23, 42, .72) !important;
  border-color: rgba(219, 234, 254, .45) !important;
}

.night-mode .setup-backdrop,
.night-mode .notes-modal-backdrop,
.night-mode .timer-alert-backdrop,
.night-mode .update-log-backdrop,
.night-mode .todo-list-backdrop,
.night-mode .focus-sounds-backdrop,
.night-mode .export-settings-backdrop,
.night-mode .export-control-backdrop {
  background: rgba(2, 6, 23, .78) !important;
  backdrop-filter: blur(5px);
}

.night-mode .portal-menu:before {
  background: #111827 !important;
  border-color: #dbeafe !important;
}

.night-mode .footer-version-button {
  color: #dbeafe !important;
  border-color: rgba(219, 234, 254, .5) !important;
  background: #0f172a !important;
}

.night-mode img.headline-cat,
.night-mode .headline-cat,
.night-mode .timer-cat-image,
.night-mode .setup-header img,
.night-mode .terms-page-header img,
.night-mode .overall-topline img {
  filter: drop-shadow(6px 7px rgba(0, 0, 0, .48)) brightness(.94) contrast(1.05) !important;
}

@media (max-width: 720px) {
  .night-mode-toggle-button {
    width: 100%;
  }
}

/* v1.4.7: Night Mode button sits below the copyright line, outside the Support Website block. */
.footer-card > .footer-night-mode-slot {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  margin: 10px 0 0;
  padding: 0 2px;
  min-width: 0;
}

.footer-card > .footer-night-mode-slot .night-mode-toggle-button {
  min-width: 170px;
  max-width: 240px;
  justify-content: center;
  text-align: center;
}

.footer-card > .footer-night-mode-slot .night-mode-toggle-button span {
  display: block;
}

.footer-card > .footer-night-mode-slot .night-mode-toggle-button small {
  display: block;
  margin-top: 2px;
  font-size: 10px;
  line-height: 1.2;
}

.night-mode .footer-card > .footer-night-mode-slot {
  border-color: rgba(148, 163, 184, .18);
}

@media (max-width: 760px) {
  .footer-card > .footer-night-mode-slot {
    width: 100%;
    align-items: stretch;
  }

  .footer-card > .footer-night-mode-slot .night-mode-toggle-button {
    width: 100%;
    max-width: none;
  }
}
