@media (prefers-reduced-motion: no-preference) {
        html {
          scroll-behavior: smooth;
        }
      }

      html,
      body {
        font-family: 'Axiforma', 'Satoshi', 'Plus Jakarta Sans', 'Inter', 'HarmonyOS Sans SC', system-ui, sans-serif;
        background: #f4f5f9;
        color: #181b25;
        -webkit-font-smoothing: antialiased;
        -moz-osx-font-smoothing: grayscale;
      }

      html {
        color-scheme: light;
      }

      html[data-theme='dark'] {
        color-scheme: dark;
      }

      html[data-theme='dark'],
      html[data-theme='dark'] body {
        background: #0f1016;
        color: #e2e4f0;
      }

      body {
        transition: background 0.35s ease, color 0.25s ease;
      }

      #mainTitle {
        letter-spacing: -0.03em;
        color: #171717;
      }

      html[data-theme='dark'] #mainTitle {
        color: #e2e4f0;
      }

      /* =====================================================
       * Flat sidebar (icon-only)
       * ===================================================== */
      .icon-rail {
        width: 64px;
        flex: 0 0 64px;
        overflow-x: hidden;
        overflow-y: visible;
        /* Lift above main/agent-page so the sidebar account dropdown isn't occluded */
        z-index: 30;
      }

      .icon-rail nav {
        overflow-x: hidden;
      }

      .logo-box {
        cursor: pointer;
        background: #171717;
        box-shadow: none;
        transition: transform 0.2s cubic-bezier(0.34, 1.56, 0.64, 1);
      }
      .logo-box:hover {
        transform: scale(1.05);
      }
      .logo-box:active {
        transform: scale(0.94);
      }

      .rail-btn {
        position: relative;
        display: inline-flex;
        align-items: center;
        justify-content: center;
        width: 40px;
        height: 40px;
        border-radius: 12px;
        color: #6b7280;
        cursor: pointer;
        transition: background 0.15s ease, color 0.15s ease;
      }

      .rail-btn:hover {
        background: #f3f4f6;
        color: #171717;
      }

      .rail-btn:active {
        transform: scale(0.94);
      }

      .rail-btn.active {
        background: #171717;
        color: #fff;
        box-shadow: none;
      }

      html[data-theme='dark'] .rail-btn {
        color: #9ca3af;
      }

      html[data-theme='dark'] .rail-btn:hover {
        background: rgba(255, 255, 255, 0.06);
        color: #f3f4f6;
      }

      html[data-theme='dark'] .rail-btn.active {
        background: #f3f4f6;
        color: #111827;
        box-shadow: none;
      }

      .rail-btn .rail-count {
        position: absolute;
        top: -3px;
        right: -3px;
        min-width: 17px;
        height: 17px;
        padding: 0 4.5px;
        border-radius: 999px;
        background: #525252;
        color: #fff;
        font-size: 10px;
        font-weight: 700;
        line-height: 17px;
        text-align: center;
        box-shadow: none;
      }

      .rail-btn.active .rail-count {
        background: #fff;
        color: #171717;
        box-shadow: none;
      }

      html[data-theme='dark'] .rail-btn .rail-count {
        background: #525252;
        color: #fff;
      }

      html[data-theme='dark'] .rail-btn.active .rail-count {
        background: #111827;
        color: #fff;
      }

      .module-tabs {
        display: inline-flex;
        align-items: center;
        gap: 4px;
        padding: 4px;
        border: 1px solid #e5e7eb;
        border-radius: 14px;
        background: #fff;
      }
      .module-tab {
        border: 0;
        background: transparent;
        color: #6b7280;
        border-radius: 10px;
        padding: 7px 12px;
        font-size: 13px;
        font-weight: 650;
        cursor: pointer;
      }
      .module-tab:hover {
        background: #f5f5f5;
        color: #111827;
      }
      .module-tab.is-active {
        background: #171717;
        color: #fff;
      }
      .schedule-page {
        padding: 16px;
      }
      @media (min-width: 768px) {
        .schedule-page {
          padding: 24px 32px 32px;
        }
      }
      .schedule-tabs {
        margin-bottom: 18px;
      }
      .knowledge-page {
        padding: 16px;
      }
      @media (min-width: 768px) {
        .knowledge-page {
          padding: 24px 32px 32px;
        }
      }
      .knowledge-page-head {
        display: flex;
        flex-wrap: wrap;
        align-items: center;
        gap: 12px;
        margin-bottom: 18px;
      }
      .knowledge-filter-row {
        display: flex;
        flex-wrap: wrap;
        align-items: center;
        gap: 8px;
      }
      .knowledge-filter-chip {
        display: inline-flex;
        align-items: center;
        gap: 6px;
        min-height: 32px;
        border: 1px solid #e5e7eb;
        border-radius: 999px;
        background: #fff;
        color: #6b7280;
        padding: 0 12px;
        font-size: 12px;
        font-weight: 650;
        cursor: pointer;
      }
      .knowledge-filter-chip:hover {
        border-color: #d4d4d4;
        background: #f7f7f7;
        color: #171717;
      }
      .knowledge-filter-chip.is-active {
        background: #171717;
        border-color: #171717;
        color: #fff;
      }
      .knowledge-filter-chip small {
        color: inherit;
        opacity: 0.72;
      }
      .knowledge-empty-block {
        border: 1px dashed #e5e7eb;
        border-radius: 16px;
        background: #fff;
        padding: 28px 24px;
        text-align: center;
      }
      .knowledge-empty-title {
        font-size: 14px;
        font-weight: 600;
        color: #171717;
      }
      .knowledge-empty-hint {
        font-size: 12.5px;
        color: #6b7280;
        margin-top: 6px;
      }
      .knowledge-grid {
        display: grid;
        grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
        gap: 10px;
      }
      .knowledge-grid-item {
        display: flex;
        align-items: center;
        gap: 10px;
        padding: 12px 14px;
        border: 1px solid #e5e7eb;
        border-radius: 14px;
        background: #fff;
        text-align: left;
        cursor: pointer;
        transition: border-color 120ms ease, background 120ms ease;
      }
      .knowledge-grid-item:hover {
        border-color: #d4d4d4;
        background: #f7f7f7;
      }
      .knowledge-grid-item-icon {
        width: 32px;
        height: 32px;
        border-radius: 10px;
        background: #f3f4f6;
        color: #6b7280;
        display: flex;
        align-items: center;
        justify-content: center;
        flex: 0 0 auto;
      }
      .knowledge-grid-item-body {
        min-width: 0;
        flex: 1;
      }
      .knowledge-grid-item-title {
        font-size: 13.5px;
        font-weight: 600;
        color: #171717;
        white-space: nowrap;
        overflow: hidden;
        text-overflow: ellipsis;
      }
      .knowledge-grid-item-meta {
        font-size: 11.5px;
        color: #6b7280;
        margin-top: 2px;
      }
      html[data-theme='dark'] .knowledge-empty-block {
        background: rgba(255,255,255,0.03);
        border-color: rgba(255,255,255,0.10);
      }
      html[data-theme='dark'] .knowledge-empty-title { color: #f3f4f6; }
      html[data-theme='dark'] .knowledge-empty-hint { color: #9ca3af; }
      html[data-theme='dark'] .knowledge-grid-item {
        background: rgba(255,255,255,0.04);
        border-color: rgba(255,255,255,0.10);
      }
      html[data-theme='dark'] .knowledge-grid-item:hover {
        background: rgba(255,255,255,0.07);
      }
      html[data-theme='dark'] .knowledge-grid-item-icon {
        background: rgba(255,255,255,0.06);
        color: #d4d4d4;
      }
      html[data-theme='dark'] .knowledge-grid-item-title { color: #f3f4f6; }
      html[data-theme='dark'] .knowledge-grid-item-meta { color: #9ca3af; }
      html[data-theme='dark'] .module-tabs {
        background: rgba(255,255,255,0.04);
        border-color: rgba(255,255,255,0.10);
      }
      html[data-theme='dark'] .module-tab {
        color: #9ca3af;
      }
      html[data-theme='dark'] .module-tab:hover {
        background: rgba(255,255,255,0.06);
        color: #f3f4f6;
      }
      html[data-theme='dark'] .module-tab.is-active {
        background: #f5f5f5;
        color: #111827;
      }
      html[data-theme='dark'] .knowledge-filter-chip {
        background: rgba(255,255,255,0.04);
        border-color: rgba(255,255,255,0.10);
        color: #9ca3af;
      }
      html[data-theme='dark'] .knowledge-filter-chip:hover {
        background: rgba(255,255,255,0.06);
        color: #f3f4f6;
      }
      html[data-theme='dark'] .knowledge-filter-chip.is-active {
        background: #f5f5f5;
        border-color: #f5f5f5;
        color: #111827;
      }

      /* Tooltip */
      .rail-btn::after {
        content: attr(data-tip);
        position: absolute;
        left: calc(100% + 12px);
        top: 50%;
        transform: translateY(-50%) translateX(-5px);
        padding: 6px 11px;
        background: #1a1d26;
        color: #f0f2ff;
        border-radius: 8px;
        font-size: 12px;
        font-weight: 500;
        white-space: nowrap;
        opacity: 0;
        pointer-events: none;
        transition: opacity 0.14s ease, transform 0.14s ease;
        z-index: 100;
        box-shadow: 0 4px 16px rgba(0, 0, 0, 0.25);
        letter-spacing: 0.01em;
      }

      .rail-btn::before {
        content: '';
        position: absolute;
        left: calc(100% + 6px);
        top: 50%;
        transform: translateY(-50%) translateX(-5px);
        border-width: 5px 6px 5px 0;
        border-style: solid;
        border-color: transparent #1a1d26 transparent transparent;
        opacity: 0;
        pointer-events: none;
        transition: opacity 0.14s ease, transform 0.14s ease;
        z-index: 100;
      }

      .rail-btn:hover::before {
        opacity: 1;
        transform: translateY(-50%) translateX(0);
      }

      .rail-btn:hover::after {
        opacity: 1;
        transform: translateY(-50%) translateX(0);
      }

      html[data-theme='dark'] .rail-btn::after {
        background: #2a2d3a;
        color: #e8eaf0;
        border: 1px solid rgba(255,255,255,0.1);
      }

      html[data-theme='dark'] .rail-btn::before {
        border-right-color: #2a2d3a;
      }

      .rail-btn--collapse {
        color: #9ba3b7;
        opacity: 0.7;
      }
      .rail-btn--collapse:hover {
        opacity: 1;
        background: rgba(99, 102, 241, 0.08);
        color: #6366f1;
      }
      html[data-theme='dark'] .rail-btn--collapse {
        color: #5b6280;
      }
      html[data-theme='dark'] .rail-btn--collapse:hover {
        color: #a5b4fc;
      }

      .sidebar-more-group {
        display: none;
        flex-direction: column;
        align-items: center;
        gap: 1.5px;
        width: 100%;
        animation: sidebarExpand 0.2s ease;
      }
      .sidebar-more-group.expanded {
        display: flex;
      }

      @keyframes sidebarExpand {
        from { opacity: 0; transform: translateY(-4px); }
        to   { opacity: 1; transform: translateY(0); }
      }

      .rail-divider {
        width: 24px;
        height: 1px;
        background: linear-gradient(90deg, transparent, #e2e6ef, transparent);
        margin: 8px auto;
      }

      html[data-theme='dark'] .rail-divider {
        background: linear-gradient(90deg, transparent, rgba(255,255,255,0.08), transparent);
      }

      html[data-theme='dark'] #mainStats .flat-card:hover {
        box-shadow: 0 4px 16px rgba(0, 0, 0, 0.5);
      }

      /* =====================================================
       * Top bar (flat)
       * ===================================================== */
      .flat-card {
        background: #fff;
        border: 1px solid #f1f3f9;
        border-radius: 16px;
        box-shadow: 0 1px 2px rgba(16,24,40,0.03), 0 4px 16px rgba(16,24,40,0.03);
        transition: transform 0.2s ease, box-shadow 0.2s ease, border-color 0.2s ease;
      }

      html[data-theme='dark'] .flat-card {
        background: #181a22;
        border-color: rgba(255, 255, 255, 0.06);
        box-shadow: 0 1px 3px rgba(0,0,0,0.2);
      }

      .flat-btn {
        display: inline-flex;
        align-items: center;
        gap: 6px;
        height: 36px;
        padding: 0 14px;
        border: 1px solid #e2e6ef;
        background: #fff;
        color: #3d4458;
        border-radius: 11px;
        font-size: 13px;
        font-weight: 500;
        transition: all 0.2s cubic-bezier(0.22, 1, 0.36, 1);
      }

      .flat-btn:hover {
        border-color: #c8cdd9;
        background: #f8f9fc;
        transform: translateY(-1px);
        box-shadow: 0 2px 8px rgba(16,24,40,0.05);
      }

      .flat-btn:active {
        transform: scale(0.96) translateY(0);
      }

      .flat-btn:disabled {
        cursor: not-allowed;
        opacity: 0.6;
        transform: none;
        box-shadow: none;
      }

      .btn-spinner {
        width: 14px;
        height: 14px;
        flex: 0 0 auto;
        border-radius: 999px;
        border: 2px solid currentColor;
        border-right-color: transparent;
        animation: btnSpin 0.7s linear infinite;
      }

      @keyframes btnSpin {
        to { transform: rotate(360deg); }
      }

      .flat-btn--primary {
        background: #171717;
        border-color: #171717;
        color: #fff;
        box-shadow: none;
      }

      .flat-btn--primary:hover {
        background: #262626;
        border-color: #262626;
        box-shadow: none;
        transform: none;
      }

      html[data-theme='dark'] .flat-btn {
        background: #181a22;
        border-color: rgba(255, 255, 255, 0.09);
        color: #9ba3b7;
      }

      html[data-theme='dark'] .flat-btn:hover {
        background: rgba(255, 255, 255, 0.06);
        border-color: rgba(255, 255, 255, 0.14);
        box-shadow: 0 2px 8px rgba(0,0,0,0.15);
      }

      html[data-theme='dark'] .flat-btn--primary {
        background: #f3f4f6;
        border-color: #f3f4f6;
        color: #111827;
        box-shadow: none;
      }

      html[data-theme='dark'] .flat-btn--primary:hover {
        background: #fff;
        border-color: #fff;
        box-shadow: none;
      }

      html[data-theme='dark'] [data-modal-panel] {
        box-shadow: 0 1px 2px rgba(0,0,0,0.3), 0 20px 60px rgba(0,0,0,0.6);
        background: #181a22 !important;
        border-color: rgba(255,255,255,0.09) !important;
      }

      /* Language switch */
      .lang-switch {
        position: relative;
      }

      .lang-menu {
        position: absolute;
        right: 0;
        top: calc(100% + 6px);
        min-width: 160px;
        padding: 5px;
        background: #fff;
        border: 1px solid #f1f3f9;
        border-radius: 14px;
        box-shadow: 0 12px 40px rgba(16, 24, 40, 0.12);
        opacity: 0;
        transform: translateY(-6px) scale(0.97);
        pointer-events: none;
        transition: opacity 0.2s ease, transform 0.2s cubic-bezier(0.22, 1, 0.36, 1);
        z-index: 40;
      }

      .lang-switch.open .lang-menu {
        opacity: 1;
        transform: translateY(0) scale(1);
        pointer-events: auto;
      }

      html[data-theme='dark'] .lang-menu {
        background: #181a22;
        border-color: rgba(255, 255, 255, 0.09);
        box-shadow: 0 12px 40px rgba(0,0,0,0.5);
      }

      .lang-option {
        display: flex;
        align-items: center;
        gap: 10px;
        width: 100%;
        padding: 8px 10px;
        border-radius: 10px;
        font-size: 13px;
        color: #3d4458;
        cursor: pointer;
        transition: all 0.15s ease;
      }

      .lang-option:hover {
        background: rgba(99, 102, 241, 0.07);
        color: #6366f1;
      }

      .lang-option.active {
        background: rgba(99, 102, 241, 0.1);
        font-weight: 600;
        color: #6366f1;
      }

      html[data-theme='dark'] .lang-option {
        color: #9ba3b7;
      }

      html[data-theme='dark'] .lang-option:hover,
      html[data-theme='dark'] .lang-option.active {
        background: rgba(99, 102, 241, 0.12);
        color: #a5b4fc;
      }

      .flag-svg {
        width: 18px;
        height: 13px;
        border-radius: 2px;
        flex-shrink: 0;
        box-shadow: 0 0 0 1px rgba(0, 0, 0, 0.06);
      }

      /* =====================================================
       * Calendar (animated, polished)
       * ===================================================== */
      .calendar-wrap {
        animation: calFadeIn 0.36s cubic-bezier(0.22, 1, 0.36, 1) both;
      }

      @keyframes calFadeIn {
        from { opacity: 0; transform: translateY(6px); }
        to   { opacity: 1; transform: translateY(0); }
      }

      .calendar-grid {
        display: grid;
        grid-template-columns: repeat(7, minmax(0, 1fr));
        gap: 6px;
      }

      .calendar-date {
        position: relative;
        min-height: 110px;
        padding: 10px;
        border-radius: 12px;
        border: 1px solid transparent;
        background: #fff;
        text-align: left;
        cursor: pointer;
        transition:
          background-color 0.18s ease,
          border-color 0.18s ease,
          transform 0.18s cubic-bezier(0.22, 1, 0.36, 1),
          box-shadow 0.18s ease;
        animation: cellPop 0.32s cubic-bezier(0.22, 1, 0.36, 1) both;
        animation-delay: var(--cell-delay, 0ms);
      }

      @keyframes cellPop {
        from { opacity: 0; transform: translateY(4px) scale(0.98); }
        to   { opacity: 1; transform: translateY(0) scale(1); }
      }

      .calendar-date:hover {
        border-color: #c8cdd9;
        background: #f8f9fc;
        transform: translateY(-2px);
        box-shadow: 0 8px 24px rgba(16, 24, 40, 0.08);
      }

      .calendar-date.is-other-month {
        background: transparent;
        color: #c8cdd9;
      }

      .calendar-date.is-other-month .calendar-date-num {
        color: #c8cdd9;
      }

      .calendar-date.is-today {
        border-color: #6366f1;
        box-shadow: 0 0 0 1px rgba(99, 102, 241,0.15);
      }

      .calendar-date.is-today .calendar-date-num {
        background: linear-gradient(135deg, #6366f1, #8b5cf6);
        color: #fff;
        box-shadow: 0 2px 8px rgba(99, 102, 241,0.3);
      }

      .calendar-date.is-active {
        border-color: #6366f1;
        background: rgba(99, 102, 241, 0.04);
        box-shadow: 0 0 0 1px rgba(99, 102, 241,0.1);
      }

      .calendar-date.is-in-range {
        background: rgba(99, 102, 241, 0.02);
        border-color: rgba(99, 102, 241, 0.12);
      }

      .calendar-date-num {
        display: inline-flex;
        align-items: center;
        justify-content: center;
        height: 24px;
        min-width: 24px;
        padding: 0 6px;
        border-radius: 999px;
        font-size: 12px;
        font-weight: 700;
        color: #3d4458;
        transition: all 0.15s ease;
      }

      html[data-theme='dark'] .calendar-date {
        background: #181a22;
        border-color: rgba(255, 255, 255, 0.05);
      }

      html[data-theme='dark'] .calendar-date:hover {
        background: #1e2030;
        border-color: rgba(99, 102, 241, 0.3);
        box-shadow: 0 8px 24px rgba(0, 0, 0, 0.3);
      }

      html[data-theme='dark'] .calendar-date.is-other-month {
        background: rgba(255,255,255,0.02);
        color: rgba(155, 163, 183, 0.3);
      }

      html[data-theme='dark'] .calendar-date.is-today {
        border-color: #6366f1;
        box-shadow: 0 0 0 1px rgba(99, 102, 241,0.2);
      }

      html[data-theme='dark'] .calendar-date.is-today .calendar-date-num {
        background: linear-gradient(135deg, #6366f1, #8b5cf6);
        color: #fff;
        box-shadow: 0 2px 10px rgba(99, 102, 241,0.4);
      }

      html[data-theme='dark'] .calendar-date.is-active {
        background: rgba(99, 102, 241, 0.1);
        border-color: #6366f1;
        box-shadow: 0 0 0 1px rgba(99, 102, 241,0.15);
      }

      html[data-theme='dark'] .calendar-date.is-in-range {
        background: rgba(99, 102, 241, 0.04);
        border-color: rgba(99, 102, 241, 0.15);
      }

      html[data-theme='dark'] .calendar-date-num {
        color: #9ba3b7;
      }

      /* Item chip inside calendar cell */
      .calendar-item {
        display: block;
        margin-top: 4px;
        padding: 3px 8px;
        border-radius: 7px;
        font-size: 11px;
        line-height: 1.4;
        white-space: nowrap;
        overflow: hidden;
        text-overflow: ellipsis;
        background: #f1f3f9;
        color: #3d4458;
        transition: all 0.15s ease;
        font-weight: 500;
      }

      .calendar-item--todo   { background: #f1f3f9; color: #6e7791; border-left: 2px solid #9ba3b7; }
      .calendar-item--review { background: #fef1f2; color: #be1e3a; border-left: 2px solid #f8718f; }
      .calendar-item--doing  { background: #fff8eb; color: #b45309; border-left: 2px solid #fbbf24; }
      .calendar-item--done   { background: #ecfdf5; color: #047857; border-left: 2px solid #34d399; }

      html[data-theme='dark'] .calendar-item {
        background: rgba(255, 255, 255, 0.06);
        color: #9ba3b7;
      }

      html[data-theme='dark'] .calendar-item--todo   { background: rgba(255,255,255,0.06); color: #7b82a3; border-left-color: #6b7280; }
      html[data-theme='dark'] .calendar-item--review { background: rgba(251, 113, 133, 0.12); color: #fb7185; border-left-color: #fb7185; }
      html[data-theme='dark'] .calendar-item--doing  { background: rgba(251, 191, 36, 0.12); color: #fbbf24; border-left-color: #fbbf24; }
      html[data-theme='dark'] .calendar-item--done   { background: rgba(52, 211, 153, 0.12); color: #34d399; border-left-color: #34d399; }

      /* =====================================================
       * Lists / rows / status indicators
       * ===================================================== */
      .study-row,
      .resource-row {
        transition: all 0.2s ease;
      }

      .study-row:hover,
      .resource-row:hover {
        background-color: #f8f9fc;
        transform: translateX(2px);
      }

      html[data-theme='dark'] .study-row:hover,
      html[data-theme='dark'] .resource-row:hover {
        background-color: rgba(255, 255, 255, 0.04);
      }

      .study-row[data-status='todo']:not(.study-row--selected)   { box-shadow: inset 3.5px 0 0 0 #9ba3b7; }
      .study-row[data-status='doing']:not(.study-row--selected)  { box-shadow: inset 3.5px 0 0 0 #fbbf24; }
      .study-row[data-status='review']:not(.study-row--selected) { box-shadow: inset 3.5px 0 0 0 #f8718f; }
      .study-row[data-status='done']:not(.study-row--selected)   { box-shadow: inset 3.5px 0 0 0 #34d399; }
      .study-row--selected { box-shadow: inset 3.5px 0 0 0 #6366f1; background: rgba(99, 102, 241, 0.04); }

      html[data-theme='dark'] .study-row--selected { background: rgba(99, 102, 241, 0.08); box-shadow: inset 3.5px 0 0 0 #6366f1; }

      .study-row[data-status='done'] { opacity: 0.65; }
      .study-row[data-status='done']:hover { opacity: 0.9; }

      .status-toggle {
        display: inline-flex;
        align-items: center;
        justify-content: center;
        width: 20px;
        height: 20px;
        border-radius: 999px;
        border: 2px solid #c8cdd9;
        background: transparent;
        color: transparent;
        flex-shrink: 0;
        transition: all 0.2s cubic-bezier(0.34, 1.56, 0.64, 1);
      }

      .status-toggle svg,
      .status-toggle i {
        transform: scale(0);
        transition: transform 0.25s cubic-bezier(0.34, 1.56, 0.64, 1);
      }

      .status-toggle.done svg,
      .status-toggle.done i {
        transform: scale(1);
      }

      .status-toggle:hover {
        border-color: #6366f1;
        box-shadow: 0 0 0 3px rgba(99, 102, 241,0.1);
      }

      .status-toggle:active {
        transform: scale(0.82);
      }

      .status-toggle.done {
        background: linear-gradient(135deg, #6366f1, #8b5cf6);
        border-color: transparent;
        color: #fff;
        box-shadow: 0 2px 8px rgba(99, 102, 241,0.3);
      }

      html[data-theme='dark'] .status-toggle {
        border-color: rgba(255, 255, 255, 0.18);
      }

      html[data-theme='dark'] .status-toggle:hover {
        border-color: #6366f1;
        box-shadow: 0 0 0 3px rgba(99, 102, 241,0.15);
      }

      html[data-theme='dark'] .status-toggle.done {
        background: linear-gradient(135deg, #6366f1, #8b5cf6);
        border-color: transparent;
        color: #fff;
        box-shadow: 0 2px 10px rgba(99, 102, 241,0.4);
      }

      /* =====================================================
       * View toggle (segmented)
       * ===================================================== */
      .seg-group {
        display: inline-flex;
        padding: 3px;
        background: #f1f3f9;
        border-radius: 11px;
      }

      .seg-btn {
        height: 30px;
        padding: 0 12px;
        border-radius: 9px;
        font-size: 13px;
        font-weight: 500;
        color: #6e7791;
        cursor: pointer;
        transition: all 0.2s ease;
      }

      .seg-btn:active {
        transform: scale(0.94);
      }

      .seg-btn.active {
        background: #fff;
        color: #181b25;
        box-shadow: 0 1px 3px rgba(16, 24, 40, 0.06);
      }

      html[data-theme='dark'] .seg-group { background: rgba(255, 255, 255, 0.05); }
      html[data-theme='dark'] .seg-btn { color: #7b82a3; }
      html[data-theme='dark'] .seg-btn.active { background: #181a22; color: #e2e4f0; box-shadow: 0 1px 4px rgba(0,0,0,0.3); }

      /* =====================================================
       * Inputs
       * ===================================================== */
      .flat-input {
        height: 38px;
        padding: 0 14px;
        background: #f1f3f9;
        border: 1px solid transparent;
        border-radius: 11px;
        font-size: 13px;
        color: #181b25;
        transition: all 0.2s ease;
        outline: none;
      }

      .flat-input:focus {
        background: #fff;
        border-color: #6366f1;
        box-shadow: 0 0 0 4px rgba(99, 102, 241, 0.1);
      }

      html[data-theme='dark'] .flat-input {
        background: rgba(255, 255, 255, 0.05);
        color: #e2e4f0;
      }

      html[data-theme='dark'] .flat-input:focus {
        background: rgba(255, 255, 255, 0.07);
        border-color: #6366f1;
        box-shadow: 0 0 0 3px rgba(99, 102, 241, 0.2);
      }

      input:not([type='range']):focus-visible,
      textarea:focus-visible,
      select:focus-visible {
        outline: none;
        border-color: #6366f1;
        box-shadow: 0 0 0 3px rgba(99, 102, 241, 0.12);
      }

      html[data-theme='dark'] input:not([type='range']):focus-visible,
      html[data-theme='dark'] textarea:focus-visible,
      html[data-theme='dark'] select:focus-visible {
        border-color: #818cf8;
        box-shadow: 0 0 0 3px rgba(99, 102, 241, 0.18);
      }

      select {
        appearance: none;
        background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='16' height='16' viewBox='0 0 24 24' fill='none' stroke='%23667085' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='m6 9 6 6 6-6'/%3E%3C/svg%3E");
        background-repeat: no-repeat;
        background-position: right 12px center;
        padding-right: 36px;
        cursor: pointer;
        transition: border-color 0.2s ease, box-shadow 0.2s ease;
      }
      select:hover {
        border-color: rgba(99, 102, 241, 0.35);
        box-shadow: 0 0 0 3px rgba(99, 102, 241, 0.08);
      }
      select option {
        color: #181b25;
        background: #fff;
      }
      html[data-theme='dark'] select {
        background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='16' height='16' viewBox='0 0 24 24' fill='none' stroke='%2394a3b8' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='m6 9 6 6 6-6'/%3E%3C/svg%3E");
      }
      html[data-theme='dark'] select option {
        color: #e2e4f0;
        background: #1c1e27;
      }

      /* =====================================================
       * Modals
       * ===================================================== */
      .modal-backdrop {
        opacity: 0;
        transition: opacity 0.25s ease;
      }

      .modal-backdrop.modal-backdrop--open { opacity: 1; }

      [data-modal-panel] {
        transform: translateY(16px) scale(0.96);
        transition: transform 0.35s cubic-bezier(0.22, 1, 0.36, 1);
        box-shadow: 0 1px 2px rgba(16,24,40,0.04), 0 16px 48px rgba(16,24,40,0.12);
      }

      [data-modal-panel].modal-panel--open {
        transform: translateY(0) scale(1);
      }

      [data-modal-panel] h2 {
        letter-spacing: -0.02em;
      }

      .toast-widget {
        transform: translateX(calc(100% + 1.5rem)) scale(0.95);
        opacity: 0;
        transition: transform 0.4s cubic-bezier(0.22, 1, 0.36, 1), opacity 0.25s ease;
      }

      .toast-widget.toast--show {
        transform: translateX(0) scale(1);
        opacity: 1;
      }

      /* =====================================================
       * Detail panel
       * ===================================================== */
      .detail-panel-inner {
        animation: detailFadeIn 0.32s cubic-bezier(0.22, 1, 0.36, 1) both;
      }

      .study-detail-hero {
        display: flex;
        flex-wrap: wrap;
        align-items: flex-start;
        justify-content: space-between;
        gap: 14px;
      }

      .study-detail-title {
        min-width: 0;
        flex: 1 1 180px;
      }

      .study-detail-actions {
        width: 100%;
        display: grid;
        grid-template-columns: repeat(2, minmax(0, 1fr));
        gap: 8px;
      }

      .study-detail-actions .flat-btn {
        width: 100%;
        min-width: 0;
        justify-content: center;
        white-space: nowrap;
        padding-inline: 10px;
      }

      @media (min-width: 1280px) {
        .study-detail-actions {
          width: auto;
          min-width: 224px;
        }
      }

      @keyframes detailFadeIn {
        from { opacity: 0; transform: translateY(8px); }
        to   { opacity: 1; transform: translateY(0); }
      }

      .detail-markdown h1 { font-size: 1.4rem; font-weight: 800; margin: 0.8rem 0 0.4rem; letter-spacing: -0.02em; }
      .detail-markdown h2 { font-size: 1.2rem; font-weight: 700; margin: 0.75rem 0 0.35rem; letter-spacing: -0.01em; }
      .detail-markdown h3 { font-size: 1.05rem; font-weight: 600; margin: 0.6rem 0 0.25rem; }
      .detail-markdown p  { line-height: 1.8; margin: 0.45rem 0; }
      .detail-markdown ul { list-style: disc;    padding-left: 1.25rem; margin: 0.4rem 0; }
      .detail-markdown ol { list-style: decimal; padding-left: 1.25rem; margin: 0.4rem 0; }
      .detail-markdown p code,
      .detail-markdown li code,
      .detail-markdown blockquote code {
        background: #e8eaf5;
        border-radius: 6px;
        padding: 2px 7px;
        font-family: 'JetBrains Mono', monospace;
        font-size: 0.9em;
        color: #6366f1;
        font-weight: 500;
      }
      .detail-markdown pre {
        overflow-x: auto;
        border-radius: 14px;
        background: #131520;
        color: #e2e4f0;
        padding: 1rem 1.1rem;
        font-size: 0.9rem;
        box-shadow: 0 4px 12px rgba(0,0,0,0.15);
      }
      .detail-markdown pre code { background: transparent; padding: 0; color: inherit; font-weight: 400; }
      .detail-markdown blockquote {
        border-left: 3px solid #6366f1;
        padding-left: 0.9rem;
        color: #555d75;
        margin: 0.6rem 0;
        background: rgba(99, 102, 241, 0.03);
        border-radius: 0 8px 8px 0;
        padding: 0.5rem 0.9rem;
      }
      .detail-markdown a {
        color: #6366f1;
        text-decoration: none;
        border-bottom: 1px solid rgba(99, 102, 241, 0.25);
        transition: all 0.15s ease;
        font-weight: 500;
      }
      .detail-markdown a:hover {
        border-color: rgba(99, 102, 241, 0.7);
        color: #5558e3;
      }
      html[data-theme='dark'] .detail-markdown a {
        color: #a5b4fc;
        border-bottom-color: rgba(165, 180, 252, 0.3);
      }
      html[data-theme='dark'] .detail-markdown a:hover {
        border-bottom-color: rgba(165, 180, 252, 0.7);
        color: #c7d2fe;
      }

      html[data-theme='dark'] .detail-markdown p code,
      html[data-theme='dark'] .detail-markdown li code,
      html[data-theme='dark'] .detail-markdown blockquote code {
        background: rgba(99, 102, 241, 0.12);
        color: #a5b4fc;
      }

      html[data-theme='dark'] .detail-markdown blockquote {
        border-left-color: #6366f1;
        color: #9ba3b7;
        background: rgba(99, 102, 241, 0.05);
      }

      /* Scoped dark overrides for tailwind-generated classes that pre-existed */
      html[data-theme='dark'] .bg-white,
      html[data-theme='dark'] .bg-ink-50,
      html[data-theme='dark'] .bg-ink-100 { background-color: #181a22 !important; }
      html[data-theme='dark'] .from-white { --tw-gradient-from: #181a22 !important; }
      html[data-theme='dark'] .to-ink-50\/60 { --tw-gradient-to: rgba(24, 26, 34, 0.6) !important; }
      html[data-theme='dark'] .from-brand-50 { --tw-gradient-from: rgba(99, 102, 241,0.15) !important; }
      html[data-theme='dark'] .from-emerald-50 { --tw-gradient-from: rgba(52,211,153,0.15) !important; }
      html[data-theme='dark'] .from-amber-50 { --tw-gradient-from: rgba(251,191,36,0.15) !important; }
      html[data-theme='dark'] .to-ink-50 { --tw-gradient-to: rgba(24,26,34,0.4) !important; }
      html[data-theme='dark'] .bg-brand-50\/80 { background-color: rgba(99, 102, 241,0.1) !important; }
      html[data-theme='dark'] .shadow-soft { box-shadow: 0 1px 3px rgba(0,0,0,0.3), 0 4px 16px rgba(0,0,0,0.25) !important; }
      html[data-theme='dark'] .border-dashed { border-color: rgba(255,255,255,0.1) !important; }
      html[data-theme='dark'] .bg-ink-900 { background-color: #e2e4f0 !important; color: #0f1016 !important; }
      html[data-theme='dark'] .text-brand-300 { color: #a5b4fc !important; }
      html[data-theme='dark'] .text-emerald-300 { color: #34d399 !important; }
      html[data-theme='dark'] .text-amber-300 { color: #fbbf24 !important; }
      html[data-theme='dark'] .ring-ink-900 { --tw-ring-color: #6366f1 !important; }
      html[data-theme='dark'] .border-ink-100,
      html[data-theme='dark'] .border-ink-200,
      html[data-theme='dark'] .border-red-200 { border-color: rgba(255, 255, 255, 0.07) !important; }
      html[data-theme='dark'] .text-ink-900,
      html[data-theme='dark'] .text-ink-700 { color: #e2e4f0 !important; }
      html[data-theme='dark'] .text-ink-600,
      html[data-theme='dark'] .text-ink-500 { color: #9ba3b7 !important; }
      html[data-theme='dark'] .text-ink-400,
      html[data-theme='dark'] .text-ink-300 { color: #6e7791 !important; }
      html[data-theme='dark'] input,
      html[data-theme='dark'] textarea,
      html[data-theme='dark'] select {
        background-color: rgba(255, 255, 255, 0.05) !important;
        border-color: rgba(255, 255, 255, 0.1) !important;
        color: #e2e4f0 !important;
      }

      html[data-theme='dark'] .bg-slate-100 { background-color: rgba(255, 255, 255, 0.06) !important; }
      html[data-theme='dark'] .bg-amber-100 { background-color: rgba(251, 191, 36, 0.12) !important; }
      html[data-theme='dark'] .bg-rose-100  { background-color: rgba(251, 113, 133, 0.12) !important; }
      html[data-theme='dark'] .bg-emerald-100 { background-color: rgba(52, 211, 153, 0.12) !important; }
      html[data-theme='dark'] .text-slate-600 { color: #9ba3b7 !important; }
      html[data-theme='dark'] .text-amber-700 { color: #fbbf24 !important; }
      html[data-theme='dark'] .text-rose-700  { color: #fb7185 !important; }
      html[data-theme='dark'] .text-emerald-700 { color: #34d399 !important; }

      ::placeholder { color: #9ba3b7; opacity: 1; }
      html[data-theme='dark'] ::placeholder { color: #4a5070; }

      /* Sidebar dark */
      html[data-theme='dark'] .icon-rail {
        background: #0b0c11 !important;
        border-color: rgba(255,255,255,0.06) !important;
      }

      /* Logo dark */
      html[data-theme='dark'] .logo-box {
        background: #23252f !important;
        box-shadow: none;
        color: #ffffff;
      }
      html[data-theme='dark'] .logo-box svg {
        stroke: #ffffff;
      }

      /* Top bar + right panel dark */
      html[data-theme='dark'] main > .border-b,
      html[data-theme='dark'] aside.hidden.lg\\:block {
        background: #0f1016 !important;
        border-color: rgba(255,255,255,0.06) !important;
      }

      ::-webkit-scrollbar { width: 6px; height: 6px; }
      ::-webkit-scrollbar-track { background: transparent; }
      ::-webkit-scrollbar-thumb { background: #d1d9e6; border-radius: 999px; border: 1px solid transparent; background-clip: content-box; }
      ::-webkit-scrollbar-thumb:hover { background: #a5b4fc; }
      html[data-theme='dark'] ::-webkit-scrollbar-thumb { background: rgba(255,255,255,0.1); }
      html[data-theme='dark'] ::-webkit-scrollbar-thumb:hover { background: rgba(165, 180, 252, 0.4); }

      /* List section animation */
      .list-section-enter {
        animation: listSectionIn 0.36s cubic-bezier(0.22, 1, 0.36, 1) both;
      }

      @keyframes listSectionIn {
        from { opacity: 0; transform: translateY(8px); }
        to   { opacity: 1; transform: translateY(0); }
      }

      .empty-state-card {
        animation: listSectionIn 0.4s cubic-bezier(0.22, 1, 0.36, 1) both;
      }

      @keyframes rowFadeIn {
        from { opacity: 0; transform: translateY(4px); }
        to   { opacity: 1; transform: translateY(0); }
      }
      .list-section-enter .study-row,
      .list-section-enter .resource-row {
        animation: rowFadeIn 0.28s cubic-bezier(0.22, 1, 0.36, 1) both;
      }
      .list-section-enter .study-row:nth-child(1),
      .list-section-enter .resource-row:nth-child(1) { animation-delay: 30ms; }
      .list-section-enter .study-row:nth-child(2),
      .list-section-enter .resource-row:nth-child(2) { animation-delay: 55ms; }
      .list-section-enter .study-row:nth-child(3),
      .list-section-enter .resource-row:nth-child(3) { animation-delay: 75ms; }
      .list-section-enter .study-row:nth-child(4),
      .list-section-enter .resource-row:nth-child(4) { animation-delay: 90ms; }
      .list-section-enter .study-row:nth-child(5),
      .list-section-enter .resource-row:nth-child(5) { animation-delay: 100ms; }
      .list-section-enter .study-row:nth-child(n+6),
      .list-section-enter .resource-row:nth-child(n+6) { animation-delay: 110ms; }

      @keyframes titleScopeIn {
        from { opacity: 0.55; transform: translateY(4px); }
        to   { opacity: 1; transform: translateY(0); }
      }

      #mainStats .flat-card {
        transition: transform 0.2s ease, box-shadow 0.2s ease;
      }
      #mainStats .flat-card:hover {
        transform: translateY(-2px);
        box-shadow: 0 4px 16px rgba(16, 24, 40, 0.08);
        border-color: rgba(99, 102, 241, 0.15);
      }

      .search-wrap:focus-within .search-icon {
        color: #6366f1;
      }

      html[data-theme='dark'] .search-wrap:focus-within .search-icon {
        color: #a5b4fc;
      }

      #mainTitle.title-scope-in {
        animation: titleScopeIn 0.32s cubic-bezier(0.22, 1, 0.36, 1) both;
      }

      @media (prefers-reduced-motion: reduce) {
        .calendar-wrap,
        .calendar-date,
        .list-section-enter,
        .empty-state-card,
        .detail-panel-inner,
        #mainTitle.title-scope-in,
        .modal-backdrop,
        [data-modal-panel],
        .toast-widget,
        .btn-spinner,
        .pilot-message--thinking .pilot-avatar::after,
        .agent-page,
        .agent-sidebar,
        .agent-chat-head,
        .agent-message-list,
        .agent-composer,
        .pilot-fab,
        .pomodoro-fab {
          animation: none !important;
          transition: none !important;
        }
      }
      /* =====================================================
       * StudyPilot Panel
       * ===================================================== */
      .pilot-fab {
        position: fixed;
        right: 24px;
        bottom: 24px;
        z-index: 30;
        width: 48px;
        height: 48px;
        border-radius: 12px;
        background: #6366f1;
        color: #fff;
        display: flex;
        align-items: center;
        justify-content: center;
        cursor: pointer;
        border: none;
        box-shadow: 0 2px 8px rgba(99, 102, 241,0.3);
        transition: transform 0.2s ease, box-shadow 0.2s ease, opacity 0.18s ease;
      }
      .pilot-fab:hover { transform: scale(1.05); box-shadow: 0 4px 12px rgba(99, 102, 241,0.4); }
      .pilot-fab:active { transform: scale(0.96); }
      .pilot-fab.pilot-hidden {
        opacity: 0;
        pointer-events: none;
        transform: translateY(12px);
      }

      .pilot-panel {
        position: fixed;
        right: 24px;
        bottom: 24px;
        z-index: 30;
        width: 420px;
        max-width: calc(100vw - 48px);
        height: min(720px, calc(100vh - 48px));
        max-height: calc(100vh - 48px);
        border-radius: 12px;
        background: #fff;
        border: 1px solid #e5e7eb;
        box-shadow: 0 4px 24px rgba(0,0,0,0.08);
        display: flex;
        flex-direction: column;
        overflow: hidden;
        transform: translateY(8px);
        opacity: 0;
        pointer-events: none;
        transition: transform 0.2s ease, opacity 0.15s ease;
      }
      .pilot-panel.pilot-open {
        transform: translateY(0) scale(1);
        opacity: 1;
        pointer-events: auto;
      }

      html[data-theme='dark'] .pilot-panel {
        background: #18181b;
        border-color: rgba(255,255,255,0.08);
        box-shadow: 0 4px 24px rgba(0,0,0,0.3);
      }

      .pilot-header {
        display: flex;
        align-items: center;
        justify-content: space-between;
        padding: 12px 16px;
        border-bottom: 1px solid #f3f4f6;
        flex-shrink: 0;
        background: #fafafa;
      }
      html[data-theme='dark'] .pilot-header { border-color: rgba(255,255,255,0.06); background: #1a1a1a; }

      .pilot-header-title {
        display: flex;
        align-items: center;
        gap: 8px;
        font-size: 14px;
        font-weight: 600;
        color: #111827;
      }
      html[data-theme='dark'] .pilot-header-title { color: #e5e7eb; }

      .pilot-header-icon {
        display: flex;
        align-items: center;
        justify-content: center;
        width: 28px;
        height: 28px;
        border-radius: 8px;
        background: #6366f1;
        color: #fff;
        flex-shrink: 0;
      }

      .pilot-header-tools {
        display: flex;
        align-items: center;
        gap: 6px;
      }

      .pilot-close,
      .pilot-expand {
        width: 28px;
        height: 28px;
        border-radius: 6px;
        display: flex;
        align-items: center;
        justify-content: center;
        color: #9ca3af;
        cursor: pointer;
        background: transparent;
        border: none;
        transition: background 0.15s, color 0.15s;
      }
      .pilot-close:hover,
      .pilot-expand:hover { background: #f3f4f6; color: #374151; }
      html[data-theme='dark'] .pilot-close:hover,
      html[data-theme='dark'] .pilot-expand:hover { background: rgba(255,255,255,0.06); color: #e5e7eb; }

      .pilot-body {
        flex: 1;
        min-height: 0;
        overflow-y: auto;
        padding: 16px;
        display: flex;
        flex-direction: column;
        gap: 16px;
      }

      .pilot-welcome {
        font-size: 13px;
        color: #6b7280;
        line-height: 1.6;
      }
      html[data-theme='dark'] .pilot-welcome { color: #9ca3af; }

      .pilot-actions {
        display: flex;
        gap: 8px;
        flex-wrap: wrap;
      }

      .pilot-action-btn {
        display: inline-flex;
        align-items: center;
        gap: 6px;
        height: 32px;
        padding: 0 14px;
        border-radius: 6px;
        font-size: 13px;
        font-weight: 500;
        cursor: pointer;
        border: 1px solid #e5e7eb;
        background: #fff;
        color: #374151;
        transition: all 0.15s;
      }
      .pilot-action-btn:hover { background: #f9fafb; border-color: #d1d5db; }
      .pilot-action-btn:active { transform: scale(0.97); }

      html[data-theme='dark'] .pilot-action-btn {
        background: rgba(255,255,255,0.05);
        border-color: rgba(255,255,255,0.1);
        color: #d1d5db;
      }
      html[data-theme='dark'] .pilot-action-btn:hover {
        background: rgba(255,255,255,0.08);
        border-color: rgba(255,255,255,0.15);
      }

      .pilot-result {
        font-size: 14px;
        line-height: 1.7;
        color: #374151;
        display: flex;
        flex-direction: column;
        gap: 12px;
        padding: 2px 0;
        min-height: 0;
      }
      .pilot-result:empty { display: none; }
      html[data-theme='dark'] .pilot-result { color: #d1d5db; }

      .pilot-result b, .pilot-result strong { color: #111827; font-weight: 600; }
      html[data-theme='dark'] .pilot-result b, html[data-theme='dark'] .pilot-result strong { color: #f3f4f6; }

      /* ── Pilot message container ── */
      .pilot-message {
        display: flex;
        flex-direction: column;
        align-items: flex-start;
        gap: 4px;
        width: 100%;
      }
      .pilot-message--user {
        align-items: flex-end;
      }
      .pilot-message--user .pilot-bubble {
        animation: agentMsgSlideInRight 0.35s cubic-bezier(0.22, 1, 0.36, 1) both;
      }
      .pilot-message--ai,
      .pilot-message--thinking {
        align-items: flex-start;
        width: 100%;
      }
      .pilot-message--ai .pilot-result-card {
        animation: agentMsgSlideInLeft 0.4s cubic-bezier(0.22, 1, 0.36, 1) both;
      }
      .pilot-message--thinking .pilot-thinking-card {
        animation: agentMsgSlideInLeft 0.4s cubic-bezier(0.22, 1, 0.36, 1) both;
      }
      .pilot-message--thinking .pilot-thinking-card-header {
        animation: agentThinkingPulse 2s ease-in-out infinite;
      }

      /* ── User bubble (keep chat style for user only) ── */
      .pilot-message--user .pilot-bubble {
        max-width: 86%;
        border-radius: 12px;
        border-top-right-radius: 4px;
        padding: 10px 14px;
        background: #f3f4f6;
        color: #1f2937;
        white-space: pre-wrap;
        word-break: break-word;
        font-size: 14px;
        line-height: 1.6;
      }

      html[data-theme='dark'] .pilot-message--user .pilot-bubble {
        background: rgba(255,255,255,0.08);
        color: #e5e7eb;
      }

      /* ── AI Result Card (flat style) ── */
      .pilot-result-card {
        width: 100%;
        border-radius: 8px;
        border: 1px solid #e5e7eb;
        background: #fff;
        overflow: hidden;
      }

      html[data-theme='dark'] .pilot-result-card {
        background: rgba(255,255,255,0.03);
        border-color: rgba(255,255,255,0.08);
      }

      .pilot-result-card-header {
        display: flex;
        align-items: center;
        justify-content: space-between;
        gap: 10px;
        padding: 10px 14px;
        border-bottom: 1px solid #f3f4f6;
        flex-wrap: wrap;
        background: #fafafa;
      }

      html[data-theme='dark'] .pilot-result-card-header {
        border-bottom-color: rgba(255,255,255,0.06);
        background: rgba(255,255,255,0.03);
      }

      .pilot-result-card-status {
        display: inline-flex;
        align-items: center;
        gap: 6px;
      }

      .pilot-result-card-title {
        font-size: 13px;
        font-weight: 600;
        color: #6366f1;
      }

      html[data-theme='dark'] .pilot-result-card-title {
        color: #818cf8;
      }

      .pilot-result-card-badges {
        display: flex;
        align-items: center;
        gap: 6px;
        flex-wrap: wrap;
      }

      .pilot-badge {
        display: inline-flex;
        align-items: center;
        gap: 4px;
        padding: 2px 8px;
        border-radius: 999px;
        font-size: 11px;
        font-weight: 500;
        white-space: nowrap;
        max-width: 180px;
        overflow: hidden;
        text-overflow: ellipsis;
      }

      .pilot-badge--source {
        background: #eff6ff;
        color: #5558e3;
      }

      .pilot-badge--resource {
        background: #f3f4f6;
        color: #4b5563;
      }

      html[data-theme='dark'] .pilot-badge--source {
        background: rgba(99, 102, 241,0.15);
        color: #a5b4fc;
      }

      html[data-theme='dark'] .pilot-badge--resource {
        background: rgba(255,255,255,0.06);
        color: #9ca3af;
      }

      .pilot-result-card-body {
        padding: 12px 14px;
        font-size: 14px;
        line-height: 1.7;
        color: #374151;
      }

      html[data-theme='dark'] .pilot-result-card-body {
        color: #d1d5db;
      }

      /* Reuse detail-markdown styles inside result card body */
      .pilot-result-card-body h1 { font-size: 1.15rem; font-weight: 600; margin: 0.6rem 0 0.3rem; color: #111827; }
      .pilot-result-card-body h2 { font-size: 1rem; font-weight: 600; margin: 0.5rem 0 0.25rem; color: #1f2937; }
      .pilot-result-card-body h3 { font-size: 0.9rem; font-weight: 600; margin: 0.4rem 0 0.2rem; color: #374151; }
      .pilot-result-card-body p  { line-height: 1.7; margin: 0.4rem 0; }
      .pilot-result-card-body ul,
      .pilot-result-card-body ol { padding-left: 1.25rem; margin: 0.35rem 0; }
      .pilot-result-card-body code {
        background: #f3f4f6;
        border-radius: 4px;
        padding: 2px 6px;
        font-family: 'JetBrains Mono', monospace;
        font-size: 0.85em;
        color: #6366f1;
      }
      .pilot-result-card-body pre {
        overflow-x: auto;
        border-radius: 8px;
        background: #1f2937;
        color: #e5e7eb;
        padding: 0.75rem 1rem;
        font-size: 0.85rem;
      }
      .pilot-result-card-body pre code {
        background: transparent;
        padding: 0;
        color: inherit;
      }
      .pilot-result-card-body blockquote {
        border-left: 3px solid #6366f1;
        padding-left: 0.75rem;
        color: #4b5563;
        margin: 0.5rem 0;
        background: #f9fafb;
        border-radius: 0 6px 6px 0;
        padding: 0.5rem 0.75rem;
      }

      html[data-theme='dark'] .pilot-result-card-body h1 { color: #f3f4f6; }
      html[data-theme='dark'] .pilot-result-card-body h2 { color: #e5e7eb; }
      html[data-theme='dark'] .pilot-result-card-body h3 { color: #d1d5db; }
      html[data-theme='dark'] .pilot-result-card-body code {
        background: rgba(255,255,255,0.08);
        color: #a5b4fc;
      }
      html[data-theme='dark'] .pilot-result-card-body blockquote {
        border-left-color: #6366f1;
        color: #9ca3af;
        background: rgba(255,255,255,0.03);
      }

      .pilot-fallback-content {
        line-height: 1.7;
      }
      .pilot-fallback-content b,
      .pilot-fallback-content strong {
        color: #111827;
        font-weight: 600;
      }
      html[data-theme='dark'] .pilot-fallback-content b,
      html[data-theme='dark'] .pilot-fallback-content strong {
        color: #f3f4f6;
      }

      /* ── Thinking Card (flat style) ── */
      .pilot-thinking-card {
        width: 100%;
        border-radius: 8px;
        border: 1px solid #e5e7eb;
        background: #f9fafb;
        padding: 12px 14px;
        display: flex;
        flex-direction: column;
        gap: 8px;
      }

      html[data-theme='dark'] .pilot-thinking-card {
        background: rgba(255,255,255,0.04);
        border-color: rgba(255,255,255,0.08);
      }

      .pilot-thinking-card-header {
        display: flex;
        align-items: center;
        gap: 8px;
      }

      .pilot-thinking-card-title {
        font-weight: 500;
        font-size: 13px;
        color: #4b5563;
      }

      html[data-theme='dark'] .pilot-thinking-card-title {
        color: #d1d5db;
      }

      .pilot-thinking-dot {
        width: 6px;
        height: 6px;
        border-radius: 50%;
        background: #6366f1;
        flex-shrink: 0;
        animation: pilotPulse 1.4s ease-out infinite;
      }

      @keyframes pilotPulse {
        0%, 100% { opacity: 1; }
        50% { opacity: 0.3; }
      }

      .pilot-thinking-card-steps {
        display: flex;
        flex-wrap: wrap;
        gap: 6px;
      }

      .pilot-thinking-chip {
        border-radius: 4px;
        background: #fff;
        border: 1px solid #e5e7eb;
        padding: 3px 8px;
        font-size: 11px;
        color: #4b5563;
      }

      html[data-theme='dark'] .pilot-thinking-chip {
        background: rgba(255,255,255,0.05);
        border-color: rgba(255,255,255,0.1);
        color: #9ca3af;
      }

      .pilot-thinking-card-elapsed {
        font-size: 12px;
        color: #9ca3af;
      }

      html[data-theme='dark'] .pilot-thinking-card-elapsed {
        color: #6b7280;
      }

      .pilot-citations {
        margin: 0 14px;
        padding: 10px 0;
        border-top: 1px solid #f3f4f6;
        display: flex;
        flex-direction: column;
        gap: 6px;
      }

      html[data-theme='dark'] .pilot-citations {
        border-top-color: rgba(255,255,255,0.06);
      }

      /* ── Tool Actions (inside result card) ── */
      .pilot-toolactions {
        margin: 0 14px 12px;
        padding-top: 10px;
        border-top: 1px solid #f3f4f6;
        display: flex;
        flex-direction: column;
        gap: 6px;
      }

      html[data-theme='dark'] .pilot-toolactions {
        border-top-color: rgba(255,255,255,0.06);
      }

      .pilot-toolactions-title {
        font-size: 12px;
        font-weight: 500;
        color: #6b7280;
        margin-bottom: 2px;
      }

      html[data-theme='dark'] .pilot-toolactions-title {
        color: #9ca3af;
      }

      .pilot-toolaction {
        display: flex;
        flex-direction: column;
        width: 100%;
        text-align: left;
        background: #fff;
        border: 1px solid #e5e7eb;
        border-radius: 6px;
        padding: 8px 10px;
        font: inherit;
        cursor: pointer;
        transition: background 0.15s, border-color 0.15s;
      }

      .pilot-toolaction:hover {
        background: #f9fafb;
        border-color: #d1d5db;
      }

      html[data-theme='dark'] .pilot-toolaction {
        background: rgba(255,255,255,0.03);
        border-color: rgba(255,255,255,0.08);
        color: #d1d5db;
      }

      html[data-theme='dark'] .pilot-toolaction:hover {
        background: rgba(255,255,255,0.06);
        border-color: rgba(255,255,255,0.15);
      }

      .pilot-toolaction-label {
        font-size: 13px;
        font-weight: 600;
        color: #1f2937;
      }

      html[data-theme='dark'] .pilot-toolaction-label {
        color: #e5e7eb;
      }

      .pilot-toolaction-reason {
        margin-top: 4px;
        font-size: 12px;
        color: #6b7280;
      }

      html[data-theme='dark'] .pilot-toolaction-reason {
        color: #9ca3af;
      }

      /* ── Citations (inside result card) ── */
      .pilot-citations-title {
        font-size: 12px;
        font-weight: 500;
        color: #6b7280;
        margin-bottom: 2px;
      }

      html[data-theme='dark'] .pilot-citations-title {
        color: #9ca3af;
      }

      .pilot-citation {
        display: block;
        width: 100%;
        text-align: left;
        background: #fff;
        border: 1px solid #e5e7eb;
        border-radius: 6px;
        padding: 8px 10px;
        font: inherit;
        color: #344054;
        cursor: pointer;
        transition: background 0.15s, border-color 0.15s;
      }

      .pilot-citation:hover {
        background: #f9fafb;
        border-color: #d1d5db;
      }

      .pilot-citation--missing {
        cursor: default;
        opacity: 0.7;
      }

      .pilot-citation-title {
        font-size: 13px;
        font-weight: 500;
        color: #1f2937;
        word-break: break-word;
      }

      .pilot-citation-index {
        color: #6366f1;
        margin-right: 4px;
      }

      .pilot-citation-quote {
        margin-top: 4px;
        padding: 6px 8px;
        border-left: 2px solid #e5e7eb;
        background: #f9fafb;
        color: #4b5563;
        font-size: 12px;
        line-height: 1.5;
        white-space: pre-wrap;
        word-break: break-word;
      }

      .pilot-citation-reason {
        margin-top: 4px;
        font-size: 12px;
        color: #6b7280;
      }

      html[data-theme='dark'] .pilot-citation {
        background: rgba(255,255,255,0.03);
        border-color: rgba(255,255,255,0.08);
        color: #d1d5db;
      }

      html[data-theme='dark'] .pilot-citation:hover {
        background: rgba(255,255,255,0.06);
        border-color: rgba(255,255,255,0.15);
      }

      html[data-theme='dark'] .pilot-citation-title {
        color: #e5e7eb;
      }

      html[data-theme='dark'] .pilot-citation-quote {
        background: rgba(255,255,255,0.03);
        border-left-color: #6366f1;
        color: #9ca3af;
      }

      .pilot-draft {
        border: 1px solid #e5e7eb;
        background: #fff;
        border-radius: 8px;
        padding: 14px;
        font-size: 13px;
        color: #374151;
        line-height: 1.6;
      }
      .pilot-draft.hidden { display: none; }
      .pilot-draft-row { margin-bottom: 4px; }
      .pilot-draft-title {
        font-size: 13px;
        font-weight: 700;
        color: #101828;
        margin-bottom: 8px;
      }
      .pilot-draft-note {
        color: #667085;
        margin-bottom: 10px;
      }
      .pilot-draft-card {
        border-radius: 6px;
        background: #f9fafb;
        border: 1px solid #e5e7eb;
        padding: 10px 12px;
        margin-top: 8px;
      }
      .pilot-draft-card-title {
        font-weight: 600;
        color: #111827;
        margin-bottom: 4px;
      }
      .pilot-draft-list {
        margin: 6px 0 0;
        padding-left: 18px;
      }
      .pilot-draft-list li { margin: 2px 0; }
      .pilot-draft-actions {
        display: flex;
        gap: 8px;
        margin-top: 10px;
      }
      .pilot-draft-btn {
        height: 30px;
        padding: 0 12px;
        border-radius: 6px;
        font-size: 12px;
        font-weight: 500;
        border: 1px solid #d1d5db;
        background: #fff;
        color: #374151;
        cursor: pointer;
        transition: all 0.15s;
      }
      .pilot-draft-btn:hover {
        background: #f9fafb;
        border-color: #9ca3af;
      }
      .pilot-draft-btn--confirm {
        border: none;
        color: #fff;
        background: #6366f1;
      }
      .pilot-draft-btn--confirm:hover {
        background: #5558e3;
      }
      html[data-theme='dark'] .pilot-draft {
        border-color: rgba(255,255,255,0.18);
        background: rgba(255,255,255,0.04);
        color: #c8ccde;
      }
      html[data-theme='dark'] .pilot-draft-btn {
        border-color: rgba(255,255,255,0.2);
        background: rgba(255,255,255,0.05);
        color: #e8eaf0;
      }

      .ai-config-status {
        min-height: 20px;
        font-size: 12px;
        line-height: 1.5;
        color: #667085;
      }
      .ai-config-status[data-tone='success'] { color: #047857; }
      .ai-config-status[data-tone='error'] { color: #b42318; }
      html[data-theme='dark'] .ai-config-status { color: #9aa2b8; }
      html[data-theme='dark'] .ai-config-status[data-tone='success'] { color: #34d399; }
      html[data-theme='dark'] .ai-config-status[data-tone='error'] { color: #fda29b; }

      .pilot-input-wrap {
        display: flex;
        gap: 8px;
        flex-shrink: 0;
        padding: 12px 16px;
        border-top: 1px solid #f3f4f6;
        background: #fafafa;
      }
      html[data-theme='dark'] .pilot-input-wrap { border-color: rgba(255,255,255,0.06); background: #1a1a1a; }

      .pilot-input {
        flex: 1;
        height: 38px;
        padding: 0 14px;
        border-radius: 8px;
        font-size: 14px;
        border: 1px solid #e5e7eb;
        background: #fff;
        color: #111827;
        outline: none;
        transition: border-color 0.15s;
      }
      .pilot-input:focus { border-color: #6366f1; }
      html[data-theme='dark'] .pilot-input {
        background: rgba(255,255,255,0.05);
        border-color: rgba(255,255,255,0.1);
        color: #e5e7eb;
      }
      html[data-theme='dark'] .pilot-input:focus {
        border-color: #6366f1;
      }

      .pilot-send-btn {
        height: 38px;
        padding: 0 16px;
        border-radius: 8px;
        font-size: 13px;
        font-weight: 500;
        background: #6366f1;
        color: #fff;
        border: none;
        cursor: pointer;
        transition: background 0.15s;
        white-space: nowrap;
      }
      .pilot-send-btn:hover { background: #5558e3; }
      .pilot-send-btn:active { transform: scale(0.97); }

      @media (max-width: 480px) {
        .pilot-panel { right: 8px; bottom: 8px; width: calc(100vw - 16px); max-height: calc(100vh - 16px); }
        .pilot-fab { right: 12px; bottom: 12px; }
      }

      /* ── Pomodoro Timer ── */

      .pomodoro-fab {
        position: fixed;
        right: 24px;
        bottom: 92px;
        z-index: 30;
        width: 52px;
        height: 52px;
        border-radius: 12px;
        background: linear-gradient(135deg, #f97316, #ef4444);
        color: #fff;
        display: flex;
        align-items: center;
        justify-content: center;
        cursor: pointer;
        border: none;
        box-shadow: 0 4px 20px rgba(249, 115, 22, 0.4);
        transition: transform 0.22s cubic-bezier(0.22, 1, 0.36, 1), box-shadow 0.2s ease, opacity 0.18s ease, filter 0.18s ease;
      }
      .pomodoro-fab:hover { transform: scale(1.08); box-shadow: 0 6px 28px rgba(249, 115, 22, 0.5); }
      .pomodoro-fab:active { transform: scale(0.95); }
      .pomodoro-fab.pomodoro-hidden {
        opacity: 0;
        pointer-events: none;
        transform: translateY(18px) scale(0.82);
        filter: blur(2px);
      }

      .pomodoro-panel {
        position: fixed;
        right: 24px;
        bottom: 24px;
        z-index: 31;
        width: 380px;
        max-width: calc(100vw - 48px);
        height: min(560px, calc(100vh - 48px));
        max-height: calc(100vh - 48px);
        border-radius: 12px;
        background: #fff;
        border: 1px solid #eef1f6;
        box-shadow: 0 8px 40px rgba(16, 24, 40, 0.12), 0 1px 3px rgba(16, 24, 40, 0.06);
        display: flex;
        flex-direction: column;
        overflow: hidden;
        transform: translateY(12px) scale(0.95);
        opacity: 0;
        pointer-events: none;
        transition:
          inset 0.34s cubic-bezier(0.22, 1, 0.36, 1),
          width 0.34s cubic-bezier(0.22, 1, 0.36, 1),
          height 0.34s cubic-bezier(0.22, 1, 0.36, 1),
          transform 0.28s cubic-bezier(0.22, 1, 0.36, 1),
          opacity 0.2s ease,
          background 0.28s ease,
          box-shadow 0.28s ease;
      }
      .pomodoro-panel.pomodoro-open {
        transform: translateY(0) scale(1);
        opacity: 1;
        pointer-events: auto;
      }
      .pomodoro-panel.pomodoro-running {
        right: 24px;
        bottom: 24px;
        width: 420px;
        max-width: calc(100vw - 48px);
        height: min(620px, calc(100vh - 48px));
        max-height: calc(100vh - 48px);
        background:
          radial-gradient(circle at 50% 42%, rgba(249, 115, 22, 0.12), transparent 34%),
          linear-gradient(180deg, #fff8f2 0%, #ffffff 54%, #f8fafc 100%);
        box-shadow: 0 20px 80px rgba(16, 24, 40, 0.2), 0 2px 8px rgba(16, 24, 40, 0.08);
      }
      html[data-theme='dark'] .pomodoro-panel {
        background: #1c1e27;
        border-color: rgba(255,255,255,0.09);
        box-shadow: 0 8px 40px rgba(0,0,0,0.5), 0 1px 3px rgba(0,0,0,0.3);
      }
      html[data-theme='dark'] .pomodoro-panel.pomodoro-running {
        background:
          radial-gradient(circle at 50% 42%, rgba(249, 115, 22, 0.16), transparent 34%),
          linear-gradient(180deg, #211f28 0%, #171922 58%, #12141c 100%);
        box-shadow: 0 24px 90px rgba(0,0,0,0.62), 0 2px 8px rgba(0,0,0,0.32);
      }

      .pomodoro-header {
        display: flex;
        align-items: center;
        justify-content: space-between;
        padding: 14px 16px;
        border-bottom: 1px solid #eef1f6;
        flex-shrink: 0;
        background: linear-gradient(180deg, rgba(249, 115, 22, 0.07), rgba(255, 255, 255, 0));
      }
      html[data-theme='dark'] .pomodoro-header { border-color: rgba(255,255,255,0.08); }
      .pomodoro-panel.pomodoro-running .pomodoro-header {
        background: transparent;
        padding: 12px 16px;
      }
      .pomodoro-header-title {
        display: flex;
        align-items: center;
        gap: 8px;
        font-size: 14px;
        font-weight: 700;
        color: #101828;
      }
      html[data-theme='dark'] .pomodoro-header-title { color: #e4e6f0; }
      .pomodoro-header-icon {
        display: flex;
        align-items: center;
        justify-content: center;
        width: 28px;
        height: 28px;
        border-radius: 8px;
        background: linear-gradient(135deg, #f97316, #ef4444);
        color: #fff;
        flex-shrink: 0;
      }
      .pomodoro-close {
        width: 28px;
        height: 28px;
        border-radius: 8px;
        border: none;
        background: transparent;
        display: flex;
        align-items: center;
        justify-content: center;
        color: #667085;
        cursor: pointer;
        transition: background 0.15s, color 0.15s;
      }
      .pomodoro-close:hover { background: #f1f3f7; color: #101828; }
      html[data-theme='dark'] .pomodoro-close { color: #7880a0; }
      html[data-theme='dark'] .pomodoro-close:hover { background: rgba(255,255,255,0.06); color: #e4e6f0; }

      .pomodoro-body {
        flex: 1;
        min-height: 0;
        display: flex;
        flex-direction: column;
        align-items: center;
        justify-content: center;
        padding: 18px 18px 20px;
        gap: 16px;
        transition: padding 0.28s ease, gap 0.28s ease;
      }
      .pomodoro-panel.pomodoro-running .pomodoro-body {
        padding: 22px 18px 26px;
        gap: 18px;
      }
      .pomodoro-linked-study {
        display: flex;
        align-items: center;
        justify-content: center;
        gap: 6px;
        min-height: 20px;
        max-width: 100%;
        padding: 0 4px;
      }
      .pomodoro-linked-study.hidden { display: none; }
      .pomodoro-linked-icon {
        flex-shrink: 0;
        color: #f97316;
        opacity: 0.7;
      }
      html[data-theme='dark'] .pomodoro-linked-icon { color: #fb923c; opacity: 0.8; }
      .pomodoro-linked-text {
        font-size: 12px;
        font-weight: 500;
        color: #64748b;
        overflow: hidden;
        text-overflow: ellipsis;
        white-space: nowrap;
        max-width: 200px;
      }
      html[data-theme='dark'] .pomodoro-linked-text { color: #7880a0; }

      .pomodoro-status-row {
        display: flex;
        align-items: center;
        justify-content: center;
        gap: 8px;
        min-height: 24px;
        flex-wrap: wrap;
      }

      .pomodoro-ring-wrap {
        position: relative;
        width: 200px;
        height: 200px;
        display: flex;
        align-items: center;
        justify-content: center;
        flex-shrink: 0;
        transition: width 0.34s cubic-bezier(0.22, 1, 0.36, 1), height 0.34s cubic-bezier(0.22, 1, 0.36, 1), transform 0.34s cubic-bezier(0.22, 1, 0.36, 1);
      }
      .pomodoro-panel.pomodoro-running .pomodoro-ring-wrap {
        width: 300px;
        height: 300px;
        animation: pomodoroFocusIn 0.48s cubic-bezier(0.22, 1, 0.36, 1);
      }
      .pomodoro-ring-wrap svg {
        position: absolute;
        width: 100%;
        height: 100%;
        transform: rotate(-90deg);
      }
      .pomodoro-ring-bg {
        fill: none;
        stroke: #eef1f6;
        stroke-width: 8;
      }
      html[data-theme='dark'] .pomodoro-ring-bg { stroke: rgba(255,255,255,0.08); }
      .pomodoro-ring-progress {
        fill: none;
        stroke-width: 8;
        stroke-linecap: round;
        transition: stroke-dashoffset 0.25s linear;
      }
      .pomodoro-panel[data-phase="focus"] .pomodoro-ring-progress { stroke: url(#pomodoroGradientFocus); }
      .pomodoro-panel[data-phase="shortBreak"] .pomodoro-ring-progress { stroke: #22c55e; }
      .pomodoro-panel[data-phase="longBreak"] .pomodoro-ring-progress { stroke: #3b82f6; }

      .pomodoro-timer-display {
        position: absolute;
        font-family: 'JetBrains Mono', 'Courier New', monospace;
        font-size: 48px;
        font-weight: 700;
        color: #101828;
        letter-spacing: 0;
        font-variant-numeric: tabular-nums;
        transition: font-size 0.28s ease, color 0.28s ease;
      }
      .pomodoro-panel.pomodoro-running .pomodoro-timer-display {
        font-size: 68px;
      }
      html[data-theme='dark'] .pomodoro-timer-display { color: #e8eaf0; }

      .pomodoro-phase-label {
        font-size: 13px;
        font-weight: 600;
        color: #667085;
      }
      html[data-theme='dark'] .pomodoro-phase-label { color: #7880a0; }
      .pomodoro-run-state {
        min-width: 58px;
        text-align: center;
        border-radius: 999px;
        padding: 3px 9px;
        font-size: 11px;
        font-weight: 700;
        color: #c2410c;
        background: rgba(249, 115, 22, 0.1);
      }
      .pomodoro-panel[data-phase="shortBreak"] .pomodoro-run-state { color: #15803d; background: rgba(34, 197, 94, 0.12); }
      .pomodoro-panel[data-phase="longBreak"] .pomodoro-run-state { color: #1d4ed8; background: rgba(59, 130, 246, 0.12); }
      html[data-theme='dark'] .pomodoro-run-state { color: #fed7aa; background: rgba(249, 115, 22, 0.16); }
      html[data-theme='dark'] .pomodoro-panel[data-phase="shortBreak"] .pomodoro-run-state { color: #bbf7d0; background: rgba(34, 197, 94, 0.16); }
      html[data-theme='dark'] .pomodoro-panel[data-phase="longBreak"] .pomodoro-run-state { color: #bfdbfe; background: rgba(59, 130, 246, 0.16); }

      .pomodoro-controls {
        display: flex;
        gap: 8px;
        align-items: center;
      }
      .pomodoro-panel.pomodoro-running .pomodoro-controls {
        margin-top: 2px;
      }
      .pomodoro-btn {
        display: inline-flex;
        align-items: center;
        gap: 5px;
        height: 36px;
        padding: 0 16px;
        border-radius: 8px;
        font-size: 13px;
        font-weight: 600;
        cursor: pointer;
        border: none;
        transition: all 0.15s;
      }
      .pomodoro-btn--start {
        background: linear-gradient(135deg, #f97316, #ef4444);
        color: #fff;
        box-shadow: 0 2px 10px rgba(249, 115, 22, 0.3);
      }
      .pomodoro-btn--start:hover { box-shadow: 0 4px 16px rgba(249, 115, 22, 0.45); }
      .pomodoro-btn--start:active { transform: scale(0.97); }
      .pomodoro-btn--pause {
        background: #f1f3f7;
        color: #344054;
        border: 1px solid #e6e8ee;
      }
      .pomodoro-btn--pause:hover { background: #e6e8ee; }
      html[data-theme='dark'] .pomodoro-btn--pause {
        background: rgba(255,255,255,0.06);
        border-color: rgba(255,255,255,0.1);
        color: #c8ccde;
      }
      html[data-theme='dark'] .pomodoro-btn--pause:hover { background: rgba(255,255,255,0.1); }
      .pomodoro-btn--reset {
        background: transparent;
        color: #667085;
        padding: 0;
        width: 36px;
        justify-content: center;
      }
      .pomodoro-btn--reset:hover { background: #f1f3f7; color: #ef4444; }
      html[data-theme='dark'] .pomodoro-btn--reset { color: #7880a0; }
      html[data-theme='dark'] .pomodoro-btn--reset:hover { background: rgba(255,255,255,0.06); color: #ef4444; }

      .pomodoro-stats {
        display: flex;
        gap: 8px;
        align-items: center;
        font-size: 12px;
        color: #667085;
        flex-wrap: wrap;
        justify-content: center;
      }
      .pomodoro-panel.pomodoro-running .pomodoro-stats {
        margin-top: 2px;
      }
      .pomodoro-stats > span {
        min-height: 28px;
        display: inline-flex;
        align-items: center;
        gap: 5px;
        border: 1px solid #eef1f6;
        border-radius: 8px;
        padding: 4px 9px;
        background: #fafbfc;
      }
      html[data-theme='dark'] .pomodoro-stats { color: #7880a0; }
      html[data-theme='dark'] .pomodoro-stats > span {
        border-color: rgba(255,255,255,0.08);
        background: rgba(255,255,255,0.04);
      }
      .pomodoro-stats strong {
        font-weight: 700;
        color: #f97316;
        font-size: 16px;
      }
      html[data-theme='dark'] .pomodoro-stats strong { color: #fb923c; }

      .pomodoro-settings {
        border-top: 1px solid #eef1f6;
        padding: 12px 16px 14px;
        flex-shrink: 0;
        max-height: 210px;
        overflow: hidden;
        opacity: 1;
        transition: max-height 0.24s ease, opacity 0.18s ease, padding 0.24s ease, border-color 0.24s ease;
      }
      .pomodoro-panel.pomodoro-running .pomodoro-settings {
        max-height: 0;
        opacity: 0;
        padding-top: 0;
        padding-bottom: 0;
        border-color: transparent;
        pointer-events: none;
      }
      html[data-theme='dark'] .pomodoro-settings { border-color: rgba(255,255,255,0.08); }
      .pomodoro-settings-title {
        margin-bottom: 9px;
        font-size: 12px;
        font-weight: 700;
        color: #344054;
      }
      html[data-theme='dark'] .pomodoro-settings-title { color: #c8ccde; }
      .pomodoro-settings-grid {
        display: grid;
        grid-template-columns: 1fr 1fr;
        gap: 9px;
      }
      .pomodoro-settings label {
        font-size: 11px;
        font-weight: 500;
        color: #667085;
        display: flex;
        flex-direction: column;
        gap: 3px;
      }
      html[data-theme='dark'] .pomodoro-settings label { color: #7880a0; }
      .pomodoro-settings input {
        height: 32px;
        padding: 0 10px;
        border-radius: 8px;
        border: 1px solid #e6e8ee;
        background: #fff;
        font-size: 13px;
        color: #101828;
        font-family: 'JetBrains Mono', 'Courier New', monospace;
      }
      html[data-theme='dark'] .pomodoro-settings input {
        background: rgba(255,255,255,0.05);
        border-color: rgba(255,255,255,0.1);
        color: #e8eaf0;
      }
      .pomodoro-settings input:focus {
        outline: none;
        border-color: #f97316;
        box-shadow: 0 0 0 3px rgba(249, 115, 22, 0.1);
      }

      @keyframes pomodoroFocusIn {
        0% { transform: scale(0.82); opacity: 0.65; }
        64% { transform: scale(1.04); opacity: 1; }
        100% { transform: scale(1); opacity: 1; }
      }

      @media (max-width: 480px) {
        .pomodoro-panel { right: 8px; bottom: 8px; width: calc(100vw - 16px); max-height: calc(100vh - 16px); }
        .pomodoro-panel.pomodoro-running { right: 8px; bottom: 8px; width: calc(100vw - 16px); height: min(560px, calc(100vh - 16px)); }
        .pomodoro-fab { right: 12px; bottom: 80px; }
        .pomodoro-timer-display { font-size: 40px; }
        .pomodoro-ring-wrap { width: 160px; height: 160px; }
        .pomodoro-panel.pomodoro-running .pomodoro-body { padding: 20px 14px 24px; }
        .pomodoro-panel.pomodoro-running .pomodoro-ring-wrap { width: 250px; height: 250px; }
        .pomodoro-panel.pomodoro-running .pomodoro-timer-display { font-size: 54px; }
        .pomodoro-settings-grid { grid-template-columns: 1fr; }
      }

      /* ── Custom Select Dropdown ── */

      .custom-select { position: relative; width: 100%; }
      .custom-select-trigger {
        width: 100%;
        height: 40px;
        padding: 0 36px 0 12px;
        border-radius: 14px;
        border: 1px solid #e6e8ee;
        background: #fff;
        color: #181b25;
        font-size: 13px;
        cursor: pointer;
        display: flex;
        align-items: center;
        justify-content: space-between;
        transition: border-color 0.2s ease, box-shadow 0.2s ease;
        position: relative;
      }
      .custom-select-trigger:hover {
        border-color: rgba(99, 102, 241, 0.35);
        box-shadow: 0 0 0 3px rgba(99, 102, 241, 0.08);
      }
      .custom-select-trigger--open {
        border-color: #6366f1;
        box-shadow: 0 0 0 3px rgba(99, 102, 241, 0.12);
      }
      .custom-select-text {
        overflow: hidden;
        text-overflow: ellipsis;
        white-space: nowrap;
      }
      .custom-select-arrow {
        position: absolute;
        right: 12px;
        top: 50%;
        transform: translateY(-50%);
        transition: transform 0.22s cubic-bezier(0.22, 1, 0.36, 1);
        color: #667085;
        pointer-events: none;
      }
      .custom-select-trigger--open .custom-select-arrow {
        transform: translateY(-50%) rotate(180deg);
      }
      .custom-select-dropdown {
        position: absolute;
        top: calc(100% + 6px);
        left: 0;
        right: 0;
        z-index: 50;
        background: #fff;
        border: 1px solid #e6e8ee;
        border-radius: 14px;
        box-shadow: 0 8px 24px rgba(16, 24, 40, 0.1), 0 2px 6px rgba(16, 24, 40, 0.06);
        max-height: 240px;
        overflow-y: auto;
        opacity: 0;
        transform: translateY(-6px) scale(0.97);
        pointer-events: none;
        transition: opacity 0.18s ease, transform 0.22s cubic-bezier(0.22, 1, 0.36, 1);
      }
      .custom-select-dropdown--open {
        opacity: 1;
        transform: translateY(0) scale(1);
        pointer-events: auto;
      }
      .custom-select-option {
        display: flex;
        align-items: center;
        gap: 8px;
        padding: 9px 12px;
        font-size: 13px;
        color: #344054;
        cursor: pointer;
        border: none;
        background: transparent;
        width: 100%;
        text-align: left;
        transition: background-color 0.12s ease;
        position: relative;
        border-radius: 0;
      }
      .custom-select-option:first-child { border-radius: 14px 14px 0 0; }
      .custom-select-option:last-child { border-radius: 0 0 14px 14px; }
      .custom-select-option:only-child { border-radius: 14px; }
      .custom-select-option:hover {
        background-color: rgba(99, 102, 241, 0.08);
      }
      .custom-select-option--selected {
        color: #6366f1;
        font-weight: 600;
      }
      .custom-select-option--selected::before {
        content: '';
        position: absolute;
        left: 0;
        top: 7px;
        bottom: 7px;
        width: 3px;
        border-radius: 0 2px 2px 0;
        background: linear-gradient(180deg, #6366f1, #8b5cf6);
      }
      .custom-select-real {
        position: absolute;
        opacity: 0;
        pointer-events: none;
        width: 1px;
        height: 1px;
        border: 0;
        padding: 0;
        margin: 0;
      }
      html[data-theme='dark'] .custom-select-trigger {
        background: rgba(255, 255, 255, 0.05);
        border-color: rgba(255, 255, 255, 0.1);
        color: #e2e4f0;
      }
      html[data-theme='dark'] .custom-select-trigger:hover {
        border-color: rgba(129, 140, 248, 0.45);
        box-shadow: 0 0 0 3px rgba(99, 102, 241, 0.15);
      }
      html[data-theme='dark'] .custom-select-trigger--open {
        border-color: #818cf8;
        box-shadow: 0 0 0 3px rgba(99, 102, 241, 0.18);
      }
      html[data-theme='dark'] .custom-select-arrow { color: #94a3b8; }
      html[data-theme='dark'] .custom-select-dropdown {
        background: #1c1e27;
        border-color: rgba(255, 255, 255, 0.09);
        box-shadow: 0 8px 24px rgba(0, 0, 0, 0.4), 0 2px 6px rgba(0, 0, 0, 0.2);
      }
      html[data-theme='dark'] .custom-select-option { color: #c8ccde; }
      html[data-theme='dark'] .custom-select-option:hover {
        background-color: rgba(129, 140, 248, 0.1);
      }
      html[data-theme='dark'] .custom-select-option--selected { color: #a5b4fc; }

      /* ── Today Dashboard ── */
      .dash-stats {
        display: grid;
        grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
        gap: 12px;
      }
      .dash-stat-card {
        background: #fff;
        border: 1px solid #e2e6ef;
        border-radius: 16px;
        padding: 16px;
        display: flex;
        align-items: center;
        gap: 12px;
        transition: box-shadow 0.2s, border-color 0.2s;
      }
      .dash-stat-card:hover {
        border-color: #c7cafc;
        box-shadow: 0 1px 3px rgba(16,24,40,0.04), 0 8px 24px rgba(16,24,40,0.06);
      }
      .dash-stat-icon {
        flex-shrink: 0;
        width: 40px;
        height: 40px;
        border-radius: 12px;
        display: flex;
        align-items: center;
        justify-content: center;
        font-size: 16px;
      }
      .dash-stat-body { min-width: 0; }
      .dash-stat-value {
        font-size: 1.25rem;
        font-weight: 700;
        color: #181b25;
        line-height: 1.2;
      }
      .dash-stat-label {
        font-size: 0.75rem;
        color: #6e7791;
        margin-top: 2px;
      }
      .dash-section {
        margin-bottom: 28px;
      }
      .dash-section-title {
        font-size: 0.8125rem;
        font-weight: 700;
        color: #3d4458;
        text-transform: uppercase;
        letter-spacing: 0.04em;
        margin-bottom: 14px;
        display: flex;
        align-items: center;
        gap: 8px;
      }
      .dash-section-title::before {
        content: '';
        width: 3px;
        height: 16px;
        background: #6366f1;
        border-radius: 2px;
      }
      .dash-recommended-card {
        background: #fff;
        border: 1px solid #e2e6ef;
        border-radius: 20px;
        padding: 20px;
        position: relative;
        overflow: hidden;
        transition: box-shadow 0.2s, border-color 0.2s;
      }
      .dash-recommended-card::before {
        content: '';
        position: absolute;
        top: 0; left: 0; right: 0;
        height: 3px;
        background: linear-gradient(90deg, #6366f1, #f97316);
      }
      .dash-recommended-card:hover {
        border-color: #c7cafc;
        box-shadow: 0 1px 3px rgba(16,24,40,0.04), 0 8px 24px rgba(16,24,40,0.06);
      }
      .dash-rec-header {
        display: flex;
        align-items: center;
        gap: 8px;
        margin-bottom: 12px;
        padding-top: 4px;
      }
      .dash-rec-badge {
        display: inline-flex;
        align-items: center;
        gap: 4px;
        padding: 3px 10px;
        border-radius: 20px;
        font-size: 0.75rem;
        font-weight: 600;
        background: #f0f1ff;
        color: #6366f1;
      }
      .dash-rec-title {
        font-size: 1.125rem;
        font-weight: 700;
        color: #181b25;
        margin-bottom: 10px;
      }
      .dash-rec-meta {
        display: flex;
        flex-wrap: wrap;
        gap: 6px;
        margin-bottom: 10px;
      }
      .dash-rec-meta span {
        font-size: 0.75rem;
        padding: 2px 8px;
        border-radius: 20px;
        background: #f1f3f9;
        color: #555d75;
        font-weight: 500;
      }
      .dash-rec-reason {
        font-size: 0.75rem;
        color: #6e7791;
        margin-bottom: 14px;
        display: flex;
        align-items: center;
        gap: 4px;
      }
      .dash-rec-actions {
        display: flex;
        flex-wrap: wrap;
        gap: 8px;
      }
      .dash-rec-actions .flat-btn {
        font-size: 0.8125rem;
        padding: 7px 14px;
      }
      .dash-task-item {
        background: #fff;
        border: 1px solid #e2e6ef;
        border-radius: 14px;
        padding: 14px 16px;
        display: flex;
        flex-wrap: wrap;
        align-items: center;
        gap: 10px;
        transition: box-shadow 0.2s, border-color 0.2s;
      }
      .dash-task-item:hover {
        border-color: #c7cafc;
      }
      .dash-task-item + .dash-task-item { margin-top: 8px; }
      .dash-task-info { flex: 1; min-width: 0; }
      .dash-task-title {
        font-size: 0.875rem;
        font-weight: 600;
        color: #181b25;
        margin-bottom: 4px;
        display: flex;
        align-items: center;
        gap: 6px;
        flex-wrap: wrap;
      }
      .dash-task-title .dash-deadline-badge {
        font-size: 0.6875rem;
        padding: 1px 7px;
        border-radius: 10px;
        font-weight: 600;
        white-space: nowrap;
      }
      .dash-deadline-badge.overdue {
        background: #fef2f2; color: #dc2626;
      }
      .dash-deadline-badge.today {
        background: #fffbeb; color: #d97706;
      }
      .dash-deadline-badge.soon {
        background: #fef9c3; color: #ca8a04;
      }
      .dash-task-meta {
        display: flex;
        flex-wrap: wrap;
        gap: 6px;
        font-size: 0.75rem;
        color: #6e7791;
      }
      .dash-task-meta span {
        padding: 1px 6px;
        border-radius: 8px;
        background: #f1f3f9;
      }
      .dash-task-actions {
        display: flex;
        align-items: center;
        gap: 6px;
        flex-shrink: 0;
      }
      .dash-task-actions button {
        width: 34px; height: 34px;
        border-radius: 10px;
        border: 1px solid #e2e6ef;
        background: #fff;
        color: #6e7791;
        cursor: pointer;
        display: flex;
        align-items: center;
        justify-content: center;
        transition: all 0.15s;
      }
      .dash-task-actions button:hover {
        background: #f0f1ff;
        border-color: #c7cafc;
        color: #6366f1;
      }
      .dash-rhythm {
        background: #f8f9fc;
        border: 1px solid #e2e6ef;
        border-radius: 16px;
        padding: 16px 20px;
        display: flex;
        align-items: flex-start;
        gap: 12px;
      }
      .dash-rhythm-icon {
        flex-shrink: 0;
        width: 32px; height: 32px;
        border-radius: 8px;
        background: #e0e2fe;
        color: #6366f1;
        display: flex;
        align-items: center;
        justify-content: center;
      }
      .dash-rhythm-text {
        font-size: 0.8125rem;
        line-height: 1.6;
        color: #555d75;
      }
      .dash-empty {
        text-align: center;
        padding: 48px 20px;
      }
      .dash-empty-icon {
        width: 64px; height: 64px;
        margin: 0 auto 16px;
        border-radius: 20px;
        background: #f0f1ff;
        display: flex;
        align-items: center;
        justify-content: center;
        color: #6366f1;
      }
      .dash-empty-title {
        font-size: 1rem;
        font-weight: 700;
        color: #3d4458;
        margin-bottom: 6px;
      }
      .dash-empty-text {
        font-size: 0.875rem;
        color: #6e7791;
        margin-bottom: 16px;
      }
      /* Dark mode */
      html[data-theme='dark'] .dash-stat-card {
        background: #1c1e27;
        border-color: rgba(255,255,255,0.08);
      }
      html[data-theme='dark'] .dash-stat-card:hover {
        border-color: rgba(129,140,248,0.3);
      }
      html[data-theme='dark'] .dash-stat-value { color: #e2e4f0; }
      html[data-theme='dark'] .dash-stat-label { color: #94a3b8; }
      html[data-theme='dark'] .dash-section-title { color: #c8ccde; }
      html[data-theme='dark'] .dash-recommended-card {
        background: #1c1e27;
        border-color: rgba(255,255,255,0.08);
      }
      html[data-theme='dark'] .dash-rec-title { color: #e2e4f0; }
      html[data-theme='dark'] .dash-rec-meta span {
        background: rgba(255,255,255,0.06);
        color: #94a3b8;
      }
      html[data-theme='dark'] .dash-rec-reason { color: #94a3b8; }
      html[data-theme='dark'] .dash-rec-badge {
        background: rgba(99, 102, 241,0.15);
        color: #a5b4fc;
      }
      html[data-theme='dark'] .dash-task-item {
        background: #1c1e27;
        border-color: rgba(255,255,255,0.08);
      }
      html[data-theme='dark'] .dash-task-title { color: #e2e4f0; }
      html[data-theme='dark'] .dash-task-meta span {
        background: rgba(255,255,255,0.06);
        color: #94a3b8;
      }
      html[data-theme='dark'] .dash-task-actions button {
        background: rgba(255,255,255,0.04);
        border-color: rgba(255,255,255,0.1);
        color: #94a3b8;
      }
      html[data-theme='dark'] .dash-task-actions button:hover {
        background: rgba(99, 102, 241,0.12);
        border-color: rgba(129,140,248,0.3);
        color: #a5b4fc;
      }
      html[data-theme='dark'] .dash-rhythm {
        background: rgba(255,255,255,0.03);
        border-color: rgba(255,255,255,0.08);
      }
      html[data-theme='dark'] .dash-rhythm-text { color: #94a3b8; }
      html[data-theme='dark'] .dash-rhythm-icon {
        background: rgba(99, 102, 241,0.15);
        color: #a5b4fc;
      }
      html[data-theme='dark'] .dash-empty-icon {
        background: rgba(99, 102, 241,0.1);
        color: #a5b4fc;
      }
      html[data-theme='dark'] .dash-empty-title { color: #c8ccde; }
      html[data-theme='dark'] .dash-empty-text { color: #94a3b8; }

      /* ── Workbench Home ── */
      .workbench-home {
        padding: 24px;
      }
      @media (min-width: 1280px) {
        .workbench-home { padding: 32px; }
      }
      .workbench-hero {
        display: grid;
        grid-template-columns: minmax(0, 1.6fr) minmax(260px, 0.8fr);
        gap: 16px;
        align-items: stretch;
        margin-bottom: 16px;
      }
      .workbench-hero-main,
      .workbench-priority,
      .workbench-section,
      .workbench-stat {
        background: #fff;
        border: 1px solid #e2e6ef;
        box-shadow: 0 1px 3px rgba(16,24,40,0.04), 0 8px 24px rgba(16,24,40,0.06);
      }
      .workbench-hero-main {
        border-radius: 24px;
        padding: 24px;
        position: relative;
        overflow: hidden;
      }
      .workbench-hero-main::before {
        content: '';
        position: absolute;
        inset: 0 0 auto 0;
        height: 4px;
        background: linear-gradient(90deg, #6366f1, #0ea5e9, #10b981);
      }
      .workbench-kicker {
        display: inline-flex;
        align-items: center;
        border-radius: 999px;
        background: #f0f1ff;
        color: #5558e3;
        padding: 4px 10px;
        font-size: 0.72rem;
        font-weight: 800;
      }
      .workbench-hero h2 {
        margin-top: 10px;
        max-width: 720px;
        color: #181b25;
        font-size: 1.6rem;
        line-height: 1.2;
        font-weight: 800;
        letter-spacing: -0.02em;
      }
      .workbench-hero-actions {
        display: flex;
        flex-wrap: wrap;
        gap: 10px;
        margin-top: 14px;
      }
      .workbench-priority {
        border-radius: 24px;
        padding: 18px;
        display: flex;
        flex-direction: column;
        min-height: 180px;
      }
      .workbench-panel-label,
      .workbench-section-head h3 {
        color: #282d3c;
        font-weight: 800;
      }
      .workbench-panel-label {
        display: flex;
        align-items: center;
        gap: 8px;
        font-size: 0.8rem;
      }
      .workbench-priority-card {
        margin-top: 16px;
        flex: 1;
        width: 100%;
        border: 1px solid #dbeafe;
        border-radius: 18px;
        background: linear-gradient(135deg, #eff6ff, #ecfdf5);
        padding: 16px;
        text-align: left;
        color: #181b25;
        transition: transform 0.18s, border-color 0.18s;
      }
      .workbench-priority-card:hover {
        transform: translateY(-1px);
        border-color: #93c5fd;
      }
      .workbench-priority-card span {
        display: block;
        font-size: 1rem;
        font-weight: 800;
      }
      .workbench-priority-card small {
        display: block;
        margin-top: 8px;
        color: #555d75;
        font-size: 0.78rem;
      }
      .workbench-priority-empty {
        margin-top: 16px;
        border: 1px dashed #c8cdd9;
        border-radius: 18px;
        padding: 18px;
        color: #6e7791;
        line-height: 1.55;
        font-size: 0.88rem;
      }
      .workbench-stats {
        display: grid;
        grid-template-columns: repeat(4, minmax(0, 1fr));
        gap: 12px;
        margin-bottom: 16px;
      }
      .workbench-stat {
        border-radius: 18px;
        padding: 16px;
        display: flex;
        align-items: center;
        gap: 12px;
      }
      .workbench-stat-icon {
        width: 42px;
        height: 42px;
        border-radius: 14px;
        display: flex;
        align-items: center;
        justify-content: center;
      }
      .workbench-stat.tone-amber .workbench-stat-icon { background: #fffbeb; color: #d97706; }
      .workbench-stat.tone-green .workbench-stat-icon { background: #ecfdf5; color: #059669; }
      .workbench-stat.tone-brand .workbench-stat-icon { background: #f0f1ff; color: #5558e3; }
      .workbench-stat.tone-blue .workbench-stat-icon { background: #eff6ff; color: #2563eb; }
      .workbench-stat-value {
        color: #181b25;
        font-size: 1.2rem;
        line-height: 1.2;
        font-weight: 800;
      }
      .workbench-stat-label {
        margin-top: 2px;
        color: #6e7791;
        font-size: 0.75rem;
      }
      .workbench-grid {
        display: grid;
        grid-template-columns: minmax(0, 1.25fr) minmax(320px, 0.9fr);
        gap: 16px;
      }
      .workbench-section {
        border-radius: 20px;
        padding: 18px;
        min-width: 0;
        background: #fff;
        border: 1px solid #f1f3f9;
      }
      .workbench-section-main {
        grid-row: span 2;
      }
      .workbench-section--agent {
        background: linear-gradient(135deg, #f8f9fc 0%, #f0f1ff 100%);
        border-color: #e0e2fe;
      }
      html[data-theme='dark'] .workbench-section {
        background: #181a22;
        border-color: rgba(255,255,255,0.06);
      }
      html[data-theme='dark'] .workbench-section--agent {
        background: linear-gradient(135deg, #181a22 0%, #1a1b2e 100%);
        border-color: rgba(99, 102, 241,0.15);
      }
      .workbench-section-head {
        display: flex;
        justify-content: space-between;
        align-items: center;
        gap: 12px;
        margin-bottom: 12px;
      }
      .workbench-section-head h3 {
        display: flex;
        align-items: center;
        gap: 6px;
        font-size: 0.9rem;
        font-weight: 700;
        color: #282d3c;
        letter-spacing: -0.01em;
      }

      .workbench-list {
        display: grid;
        gap: 8px;
      }
      .workbench-mini-row {
        width: 100%;
        min-height: 58px;
        border: 1px solid #e2e6ef;
        border-radius: 14px;
        background: #fff;
        padding: 10px 12px;
        display: flex;
        align-items: center;
        gap: 10px;
        text-align: left;
        transition: border-color 0.16s, background 0.16s;
      }
      .workbench-mini-row:hover {
        border-color: #c7cafc;
        background: #f8f9fc;
        transform: translateX(2px);
      }
      .workbench-mini-main {
        min-width: 0;
        flex: 1;
        display: grid;
        gap: 2px;
      }
      .workbench-mini-title {
        overflow: hidden;
        text-overflow: ellipsis;
        white-space: nowrap;
        color: #181b25;
        font-size: 0.86rem;
        font-weight: 700;
      }
      .workbench-mini-meta {
        overflow: hidden;
        text-overflow: ellipsis;
        white-space: nowrap;
        color: #6e7791;
        font-size: 0.74rem;
      }
      .workbench-mini-dot {
        width: 10px;
        height: 10px;
        border-radius: 50%;
        background: #9ba3b7;
      }
      .workbench-mini-dot.doing { background: #f59e0b; }
      .workbench-mini-dot.review { background: #f43f5e; }
      .workbench-mini-dot.done { background: #10b981; }
      .workbench-mini-icon {
        width: 32px;
        height: 32px;
        border-radius: 10px;
        background: #f1f3f9;
        color: #5558e3;
        display: flex;
        align-items: center;
        justify-content: center;
        flex-shrink: 0;
      }
      .workbench-mini-count {
        min-width: 24px;
        height: 24px;
        border-radius: 999px;
        background: #f1f3f9;
        color: #6e7791;
        display: inline-flex;
        align-items: center;
        justify-content: center;
        font-size: 0.72rem;
        font-weight: 800;
      }
      .workbench-suggestions {
        display: grid;
        gap: 10px;
      }
      .workbench-suggestion {
        display: grid;
        grid-template-columns: 34px minmax(0, 1fr);
        gap: 10px;
        padding: 12px;
        border: 1px solid #e2e6ef;
        border-radius: 14px;
        background: #fff;
        transition: transform 0.15s, box-shadow 0.15s;
      }
      .workbench-suggestion:hover {
        transform: translateY(-1px);
        box-shadow: 0 4px 12px rgba(16,24,40,0.06);
      }
      .workbench-suggestion-icon {
        width: 34px;
        height: 34px;
        border-radius: 12px;
        background: linear-gradient(135deg, #f0f1ff, #fff);
        color: #5558e3;
        display: flex;
        align-items: center;
        justify-content: center;
      }
      .workbench-suggestion-title {
        color: #181b25;
        font-size: 0.84rem;
        font-weight: 800;
      }
      .workbench-suggestion-text {
        margin-top: 3px;
        color: #6e7791;
        font-size: 0.76rem;
        line-height: 1.5;
      }
      .workbench-suggestion-action {
        margin-top: 10px;
      }
      .workbench-agenda {
        display: grid;
        grid-template-columns: repeat(5, minmax(0, 1fr));
        gap: 8px;
      }
      .workbench-agenda-day {
        min-height: 68px;
        border: 1px solid #e2e6ef;
        border-radius: 14px;
        background: #fff;
        padding: 10px;
        display: grid;
        align-content: center;
        gap: 4px;
        text-align: center;
        transition: all 0.15s;
        cursor: pointer;
      }
      .workbench-agenda-day:hover {
        border-color: #c7cafc;
        transform: translateY(-1px);
        box-shadow: 0 2px 8px rgba(16,24,40,0.04);
      }
      .workbench-agenda-day.today {
        border-color: #a7f3d0;
        background: #ecfdf5;
      }
      .workbench-agenda-day span {
        color: #6e7791;
        font-size: 0.72rem;
      }
      .workbench-agenda-day b {
        color: #181b25;
        font-size: 1.15rem;
      }
      .workbench-domain-grid {
        display: grid;
        grid-template-columns: repeat(2, minmax(0, 1fr));
        gap: 8px;
      }
      .workbench-domain {
        min-height: 78px;
        border: 1px solid #e2e6ef;
        border-radius: 14px;
        background: #fff;
        padding: 12px;
        display: grid;
        gap: 5px;
        text-align: left;
        transition: all 0.15s;
      }
      .workbench-domain:hover {
        border-color: #c7cafc;
        background: #f8f9fc;
        transform: translateY(-1px);
        box-shadow: 0 2px 8px rgba(16,24,40,0.04);
      }
      .workbench-domain i {
        color: #5558e3;
      }
      .workbench-domain span {
        color: #181b25;
        font-size: 0.84rem;
        font-weight: 800;
      }
      .workbench-domain small {
        color: #6e7791;
        font-size: 0.72rem;
      }
      .workbench-empty-line {
        border: 1px dashed #c8cdd9;
        border-radius: 14px;
        padding: 14px;
        color: #6e7791;
        font-size: 0.82rem;
        line-height: 1.5;
      }
      @media (max-width: 1024px) {
        .workbench-hero,
        .workbench-grid {
          grid-template-columns: 1fr;
        }
        .workbench-section-main { grid-row: auto; }
        .workbench-stats { grid-template-columns: repeat(2, minmax(0, 1fr)); }
      }
      @media (max-width: 640px) {
        .workbench-home { padding: 16px; }
        .workbench-hero-main { padding: 20px; }
        .workbench-hero h2 { font-size: 1.45rem; }
        .workbench-stats,
        .workbench-agenda,
        .workbench-domain-grid {
          grid-template-columns: 1fr;
        }
      }
      html[data-theme='dark'] .workbench-hero-main,
      html[data-theme='dark'] .workbench-priority,
      html[data-theme='dark'] .workbench-section,
      html[data-theme='dark'] .workbench-stat,
      html[data-theme='dark'] .workbench-mini-row,
      html[data-theme='dark'] .workbench-agenda-day,
      html[data-theme='dark'] .workbench-domain {
        background: #1c1e27;
        border-color: rgba(255,255,255,0.08);
      }
      html[data-theme='dark'] .workbench-kicker {
        background: rgba(99, 102, 241,0.15);
        color: #a5b4fc;
      }
      html[data-theme='dark'] .workbench-hero h2,
      html[data-theme='dark'] .workbench-panel-label,
      html[data-theme='dark'] .workbench-section-head h3,
      html[data-theme='dark'] .workbench-stat-value,
      html[data-theme='dark'] .workbench-mini-title,
      html[data-theme='dark'] .workbench-suggestion-title,
      html[data-theme='dark'] .workbench-agenda-day b,
      html[data-theme='dark'] .workbench-domain span {
        color: #e2e4f0;
      }
      html[data-theme='dark'] .workbench-hero p,
      html[data-theme='dark'] .workbench-priority-card small,
      html[data-theme='dark'] .workbench-stat-label,
      html[data-theme='dark'] .workbench-section-head p,
      html[data-theme='dark'] .workbench-mini-meta,
      html[data-theme='dark'] .workbench-suggestion-text,
      html[data-theme='dark'] .workbench-agenda-day span,
      html[data-theme='dark'] .workbench-domain small,
      html[data-theme='dark'] .workbench-empty-line {
        color: #94a3b8;
      }
      html[data-theme='dark'] .workbench-priority-card {
        background: linear-gradient(135deg, rgba(37,99,235,0.18), rgba(16,185,129,0.12));
        border-color: rgba(147,197,253,0.2);
      }
      html[data-theme='dark'] .workbench-priority-empty,
      html[data-theme='dark'] .workbench-empty-line {
        border-color: rgba(255,255,255,0.14);
      }
      html[data-theme='dark'] .workbench-mini-row:hover,
      html[data-theme='dark'] .workbench-domain:hover {
        background: rgba(255,255,255,0.04);
        border-color: rgba(129,140,248,0.3);
      }
      html[data-theme='dark'] .workbench-suggestion {
        background: rgba(255,255,255,0.03);
        border-color: rgba(255,255,255,0.08);
      }
      html[data-theme='dark'] .workbench-suggestion-icon,
      html[data-theme='dark'] .workbench-mini-icon,
      html[data-theme='dark'] .workbench-mini-count {
        background: rgba(255,255,255,0.06);
      }
      html[data-theme='dark'] .workbench-agenda-day.today {
        background: rgba(16,185,129,0.1);
        border-color: rgba(16,185,129,0.28);
      }

      /* ── Knowledge Card ── */
      .knowledge-card-section summary {
        list-style: none;
      }
      .knowledge-card-section summary::-webkit-details-marker {
        display: none;
      }
      .knowledge-card-section summary::after {
        content: '';
        display: inline-block;
        width: 16px; height: 16px;
        margin-left: auto;
        background: currentColor;
        mask: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='24' height='24' viewBox='0 0 24 24' fill='none' stroke='currentColor' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpolyline points='6 9 12 15 18 9'%3E%3C/polyline%3E%3C/svg%3E") center/cover no-repeat;
        -webkit-mask: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='24' height='24' viewBox='0 0 24 24' fill='none' stroke='currentColor' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpolyline points='6 9 12 15 18 9'%3E%3C/polyline%3E%3C/svg%3E") center/cover no-repeat;
        transition: transform 0.2s;
        opacity: 0.5;
      }
      .knowledge-card-section[open] summary::after {
        transform: rotate(180deg);
      }
      html[data-theme='dark'] .knowledge-card-section {
        background: rgba(255,255,255,0.02);
        border-color: rgba(255,255,255,0.08);
      }
      html[data-theme='dark'] .knowledge-card-section summary { color: #c8ccde; }

      /* ============================================================
         Copilot — dedicated page
         ============================================================ */

      /* Shell overrides: collapse right detail panel & top toolbar on agent page */
      body[data-area="agent"] #appShell {
        grid-template-columns: 64px minmax(0, 1fr) !important;
      }
      body[data-area="agent"] #appShell > aside:last-child {
        display: none !important;
      }
      body[data-area="agent"] main > div.border-b {
        display: none;
      }
      body[data-area="agent"] main > div:nth-child(2) {
        padding: 0;
      }
      body[data-area="agent"] main > div:nth-child(2) > #mainContent {
        height: 100vh;
      }
      body[data-area="agent"] .pilot-fab,
      body[data-area="agent"] .pomodoro-fab {
        opacity: 0;
        pointer-events: none;
        transform: translateY(22px) scale(0.82);
        filter: blur(2px);
      }

      .agent-page {
        display: grid;
        grid-template-columns: 264px minmax(0, 1fr);
        height: 100vh;
        background: #f7f8fb;
        color: #282d3c;
        animation: agentPageIn 0.32s cubic-bezier(0.22, 1, 0.36, 1) both;
      }
      @keyframes agentPageIn {
        from { opacity: 0; transform: translateY(10px); }
        to { opacity: 1; transform: translateY(0); }
      }
      @keyframes agentPanelSlideIn {
        from { opacity: 0; transform: translateX(-12px); }
        to { opacity: 1; transform: translateX(0); }
      }
      @keyframes agentContentLiftIn {
        from { opacity: 0; transform: translateY(12px); }
        to { opacity: 1; transform: translateY(0); }
      }
      @keyframes agentMsgSlideInRight {
        from { opacity: 0; transform: translateX(20px) scale(0.96); }
        to { opacity: 1; transform: translateX(0) scale(1); }
      }
      @keyframes agentMsgSlideInLeft {
        from { opacity: 0; transform: translateX(-16px) scale(0.96); }
        to { opacity: 1; transform: translateX(0) scale(1); }
      }
      @keyframes agentThinkingPulse {
        0%, 100% { opacity: 0.6; }
        50% { opacity: 1; }
      }
      @keyframes agentSendRipple {
        0% { transform: scale(1); opacity: 0.5; }
        100% { transform: scale(2.5); opacity: 0; }
      }
      @keyframes agentDrawerSlideIn {
        from { opacity: 0; transform: translateX(30px); }
        to { opacity: 1; transform: translateX(0); }
      }
      @keyframes agentSpin {
        to { transform: rotate(360deg); }
      }
      @keyframes agentToolbarStagger {
        from { opacity: 0; transform: translateY(4px); }
        to { opacity: 1; transform: translateY(0); }
      }

      /* Left chat sidebar */
      .agent-sidebar {
        display: flex;
        flex-direction: column;
        min-height: 0;
        background: #fafbfd;
        border-right: 1px solid #ecedf2;
        animation: agentPanelSlideIn 0.38s cubic-bezier(0.22, 1, 0.36, 1) 0.04s both;
      }
      .agent-new-chat {
        margin: 14px 14px 8px;
        display: inline-flex;
        align-items: center;
        justify-content: center;
        gap: 6px;
        height: 36px;
        border-radius: 10px;
        font-size: 13px;
        font-weight: 600;
        color: #fff;
        background: #181b25;
        transition: background 0.15s, transform 0.05s;
      }
      .agent-new-chat:hover { background: #2c3243; }
      .agent-new-chat:active { transform: translateY(1px); }
      .agent-sidebar-scroll {
        flex: 1;
        min-height: 0;
        overflow-y: auto;
        padding: 4px 10px 14px;
      }
      .agent-sidebar-section {
        margin-top: 14px;
      }
      .agent-sidebar-section-title {
        font-size: 11px;
        font-weight: 600;
        letter-spacing: 0.04em;
        text-transform: uppercase;
        color: #9ba3b7;
        padding: 0 6px 6px;
      }
      .agent-session {
        width: 100%;
        display: flex;
        align-items: center;
        gap: 10px;
        padding: 8px 10px;
        border-radius: 10px;
        text-align: left;
        background: transparent;
        border: 1px solid transparent;
        transition: background 0.15s, border-color 0.15s;
      }
      .agent-session:hover {
        background: #f1f3f9;
      }
      .agent-session--active {
        background: #fff;
        border-color: #e2e6ef;
        box-shadow: 0 1px 2px rgba(16,24,40,0.03);
      }
      .agent-session-icon {
        width: 26px;
        height: 26px;
        border-radius: 8px;
        background: #eef0f6;
        color: #555d75;
        display: inline-flex;
        align-items: center;
        justify-content: center;
        flex-shrink: 0;
      }
      .agent-session--active .agent-session-icon {
        background: #181b25;
        color: #fff;
      }
      .agent-session-body { min-width: 0; flex: 1; }
      .agent-session-title {
        font-size: 13px;
        font-weight: 600;
        color: #282d3c;
        white-space: nowrap;
        overflow: hidden;
        text-overflow: ellipsis;
      }
      .agent-session-meta {
        font-size: 11px;
        color: #9ba3b7;
        margin-top: 1px;
      }

      .agent-context-chips {
        display: flex;
        flex-direction: column;
        gap: 5px;
        padding: 0 4px;
      }
      .agent-chat-chip {
        display: inline-flex;
        align-items: center;
        gap: 6px;
        padding: 4px 8px;
        border-radius: 8px;
        background: #fff;
        border: 1px solid #ecedf2;
        font-size: 11px;
        line-height: 1.5;
        max-width: 100%;
        min-width: 0;
      }
      .agent-chat-chip-label {
        color: #9ba3b7;
        font-weight: 500;
        flex-shrink: 0;
      }
      .agent-chat-chip-value {
        color: #282d3c;
        font-weight: 600;
        overflow: hidden;
        text-overflow: ellipsis;
        white-space: nowrap;
        min-width: 0;
      }
      .agent-chat-chip--accent {
        background: #f0f1ff;
        border-color: #d6d8fc;
      }
      .agent-chat-chip--accent .agent-chat-chip-value {
        color: #4547c0;
      }
      .agent-chat-context-empty {
        font-size: 11px;
        color: #9ba3b7;
        padding: 4px 6px;
      }

      /* Right chat shell */
      .agent-chat-shell {
        display: flex;
        flex-direction: column;
        min-width: 0;
        min-height: 0;
        background: #f7f8fb;
      }
      .agent-chat-head {
        display: flex;
        align-items: center;
        justify-content: space-between;
        gap: 12px;
        padding: 12px 20px;
        border-bottom: 1px solid #ecedf2;
        background: rgba(255,255,255,0.6);
        backdrop-filter: blur(6px);
        -webkit-backdrop-filter: blur(6px);
        animation: agentContentLiftIn 0.34s cubic-bezier(0.22, 1, 0.36, 1) 0.08s both;
      }
      .agent-chat-head-left {
        display: flex;
        align-items: center;
        gap: 10px;
        min-width: 0;
      }
      .agent-chat-head-icon {
        width: 30px;
        height: 30px;
        border-radius: 9px;
        background: #181b25;
        color: #fff;
        display: inline-flex;
        align-items: center;
        justify-content: center;
        flex-shrink: 0;
      }
      .agent-chat-head-text { min-width: 0; }
      .agent-chat-head-title {
        font-size: 14px;
        font-weight: 600;
        color: #181b25;
        line-height: 1.2;
      }
      .agent-chat-head-meta {
        font-size: 11px;
        color: #9ba3b7;
        margin-top: 1px;
      }
      .agent-chat-head-actions {
        display: flex;
        align-items: center;
        gap: 6px;
      }
      .agent-chat-head-clear {
        display: inline-flex;
        align-items: center;
        gap: 5px;
        padding: 6px 10px;
        border-radius: 8px;
        background: transparent;
        border: 1px solid transparent;
        font-size: 12px;
        color: #6e7791;
        transition: background 0.15s, color 0.15s, border-color 0.15s;
      }
      .agent-chat-head-clear:hover {
        background: #fff1f2;
        color: #e11d48;
        border-color: #fecdd3;
      }

      .agent-message-list {
        flex: 1;
        min-height: 0;
        overflow-y: auto;
        padding: 24px 24px 24px;
        display: flex;
        flex-direction: column;
        gap: 14px;
        scroll-behavior: smooth;
        animation: agentContentLiftIn 0.38s cubic-bezier(0.22, 1, 0.36, 1) 0.12s both;
      }
      .agent-message-list .pilot-message {
        max-width: 100%;
      }
      .agent-message-list .pilot-message--user {
        justify-content: flex-end;
      }
      .agent-message-list .pilot-message--user .pilot-bubble {
        max-width: min(72%, 640px);
        background: #181b25;
        color: #fff;
        border-radius: 16px 16px 4px 16px;
        padding: 9px 14px;
        font-size: 14px;
        line-height: 1.55;
        word-break: break-word;
      }
      .agent-message-list .pilot-message--ai .pilot-result-card,
      .agent-message-list .pilot-message--thinking .pilot-thinking-card {
        max-width: min(86%, 760px);
        background: #fff;
        border: 1px solid #ecedf2;
        border-radius: 16px 16px 16px 4px;
        box-shadow: 0 1px 2px rgba(16,24,40,0.03);
      }
      .agent-message-list .pilot-result-card-body {
        font-size: 14px;
        line-height: 1.6;
      }

      .agent-chat-empty {
        margin: auto;
        max-width: 420px;
        text-align: center;
        color: #6e7791;
        display: flex;
        flex-direction: column;
        align-items: center;
        gap: 10px;
        padding: 32px 16px;
      }
      .agent-chat-empty-icon {
        width: 44px;
        height: 44px;
        border-radius: 12px;
        background: #fff;
        border: 1px solid #ecedf2;
        display: inline-flex;
        align-items: center;
        justify-content: center;
        color: #6366f1;
      }
      .agent-chat-empty-title {
        font-size: 14px;
        font-weight: 600;
        color: #282d3c;
      }
      .agent-chat-empty-hint {
        font-size: 12px;
        line-height: 1.55;
        color: #6e7791;
      }

      .agent-composer {
        padding: 12px 20px 18px;
        background: rgba(255,255,255,0.6);
        border-top: 1px solid #ecedf2;
        backdrop-filter: blur(6px);
        -webkit-backdrop-filter: blur(6px);
        animation: agentContentLiftIn 0.38s cubic-bezier(0.22, 1, 0.36, 1) 0.16s both;
      }
      .agent-composer-input {
        width: 100%;
        min-height: 48px;
        max-height: 220px;
        resize: none;
        border: 1px solid #e2e6ef;
        background: #fff;
        border-radius: 14px;
        padding: 12px 14px;
        font-size: 14px;
        line-height: 1.55;
        color: #181b25;
        outline: none;
        transition: border-color 0.15s, box-shadow 0.15s;
        font-family: inherit;
      }
      .agent-composer-input::placeholder { color: #9ba3b7; }
      .agent-composer-input:focus {
        border-color: #181b25;
        box-shadow: 0 0 0 3px rgba(24,27,37,0.06);
      }
      .agent-attachment-tray {
        display: flex;
        flex-wrap: wrap;
        gap: 8px;
        margin-bottom: 8px;
      }
      .agent-attachment-tray.hidden {
        display: none;
      }
      .agent-attachment-chip,
      .pilot-message-attachment {
        display: inline-flex;
        align-items: center;
        gap: 6px;
        max-width: min(100%, 320px);
        border: 1px solid rgba(99, 102, 241,0.18);
        background: rgba(255,255,255,0.9);
        color: #4547c0;
        border-radius: 8px;
        padding: 6px 8px;
        font-size: 12px;
        line-height: 1.2;
      }
      .agent-attachment-name,
      .pilot-message-attachment span {
        min-width: 0;
        overflow: hidden;
        text-overflow: ellipsis;
        white-space: nowrap;
      }
      .agent-attachment-size,
      .pilot-message-attachment small {
        color: #8a92a8;
        flex-shrink: 0;
      }
      .agent-attachment-remove {
        display: inline-flex;
        align-items: center;
        justify-content: center;
        width: 18px;
        height: 18px;
        border-radius: 6px;
        color: #8a92a8;
        flex-shrink: 0;
      }
      .agent-attachment-remove:hover {
        background: rgba(99, 102, 241,0.12);
        color: #5558e3;
      }
      .pilot-message-attachments {
        display: flex;
        flex-wrap: wrap;
        justify-content: flex-end;
        gap: 6px;
        max-width: min(72%, 640px);
      }
      .agent-composer-foot {
        display: flex;
        align-items: center;
        justify-content: space-between;
        gap: 12px;
        margin-top: 8px;
        padding: 0 2px;
      }
      .agent-composer-hint {
        font-size: 11px;
        color: #9ba3b7;
      }
      .agent-composer-send {
        display: inline-flex;
        align-items: center;
        gap: 6px;
        padding: 7px 14px;
        border-radius: 10px;
        background: #181b25;
        color: #fff;
        font-size: 13px;
        font-weight: 600;
        transition: background 0.15s, transform 0.05s;
      }
      .agent-composer-send:hover { background: #2c3243; }
      .agent-composer-send:active { transform: translateY(1px); }
      .agent-composer-send:disabled {
        opacity: 0.4;
        cursor: not-allowed;
      }

      /* Mobile: collapse sidebar, full-width chat */
      @media (max-width: 768px) {
        .agent-page {
          grid-template-columns: minmax(0, 1fr);
        }
        .agent-sidebar {
          display: none;
        }
        .agent-message-list {
          padding: 16px 14px;
        }
        .agent-composer {
          padding: 10px 14px 14px;
        }
        .agent-chat-head {
          padding: 10px 14px;
        }
        .agent-chat-head-clear span { display: none; }
        .agent-message-list .pilot-message--user .pilot-bubble {
          max-width: 86%;
        }
        .agent-message-list .pilot-message--ai .pilot-result-card,
        .agent-message-list .pilot-message--thinking .pilot-thinking-card {
          max-width: 95%;
        }
      }

      /* Dark theme */
      html[data-theme='dark'] body[data-area="agent"] .agent-page,
      html[data-theme='dark'] .agent-page {
        background: #11141d;
        color: #e5e7f0;
      }
      html[data-theme='dark'] .agent-sidebar {
        background: #161a25;
        border-right-color: rgba(255,255,255,0.06);
      }
      html[data-theme='dark'] .agent-new-chat {
        background: #6366f1;
      }
      html[data-theme='dark'] .agent-new-chat:hover {
        background: #5558e3;
      }
      html[data-theme='dark'] .agent-sidebar-section-title {
        color: #6e7791;
      }
      html[data-theme='dark'] .agent-session:hover {
        background: rgba(99, 102, 241, 0.06);
      }
      html[data-theme='dark'] .agent-session--active {
        background: #1e2330;
        border-color: rgba(99, 102, 241,0.2);
      }
      html[data-theme='dark'] .agent-session-icon {
        background: rgba(255,255,255,0.06);
        color: #c8ccde;
      }
      html[data-theme='dark'] .agent-session--active .agent-session-icon {
        background: #6366f1;
        color: #fff;
      }
      html[data-theme='dark'] .agent-session-title {
        color: #e5e7f0;
      }
      html[data-theme='dark'] .agent-chat-shell {
        background: #11141d;
      }
      html[data-theme='dark'] .agent-chat-head,
      html[data-theme='dark'] .agent-composer {
        background: rgba(22,26,37,0.7);
        border-color: rgba(255,255,255,0.06);
      }
      html[data-theme='dark'] .agent-chat-head-title {
        color: #c7c8fc;
      }
      html[data-theme='dark'] .agent-chat-head-icon {
        background: #6366f1;
      }
      html[data-theme='dark'] .agent-chat-head-clear {
        color: #9ba3b7;
      }
      html[data-theme='dark'] .agent-chat-head-clear:hover {
        background: rgba(239,68,68,0.12);
        color: #f87171;
        border-color: rgba(239,68,68,0.2);
      }
      html[data-theme='dark'] .agent-chat-chip {
        background: rgba(99, 102, 241, 0.06);
        border-color: rgba(99, 102, 241,0.2);
      }
      html[data-theme='dark'] .agent-chat-chip-label {
        color: #6e7791;
      }
      html[data-theme='dark'] .agent-chat-chip-value {
        color: #e5e7f0;
      }
      html[data-theme='dark'] .agent-chat-chip--accent {
        background: rgba(99, 102, 241,0.18);
        border-color: rgba(99, 102, 241,0.4);
      }
      html[data-theme='dark'] .agent-chat-chip--accent .agent-chat-chip-value {
        color: #c7cafc;
      }
      html[data-theme='dark'] .agent-message-list .pilot-message--user .pilot-bubble {
        background: #6366f1;
      }
      html[data-theme='dark'] .agent-message-list .pilot-message--ai .pilot-result-card,
      html[data-theme='dark'] .agent-message-list .pilot-message--thinking .pilot-thinking-card {
        background: #1e2330;
        border-color: rgba(255,255,255,0.06);
      }
      html[data-theme='dark'] .agent-composer-input {
        background: #1e2330;
        border-color: rgba(99, 102, 241,0.2);
        color: #e5e7f0;
      }
      html[data-theme='dark'] .agent-composer-input:focus {
        border-color: #6366f1;
        box-shadow: 0 0 0 3px rgba(99, 102, 241,0.18);
      }
      html[data-theme='dark'] .agent-composer-send {
        background: #6366f1;
      }
      html[data-theme='dark'] .agent-composer-send:hover {
        background: #5558e3;
      }
      html[data-theme='dark'] .agent-chat-empty-icon {
        background: #1e2330;
        border-color: rgba(99, 102, 241,0.2);
      }
      html[data-theme='dark'] .agent-chat-empty-title {
        color: #e5e7f0;
      }

      /* === Cherry-Studio style additions === */
      .agent-sidebar-tabs {
        display: flex;
        gap: 0;
        padding: 10px 12px 0;
        border-bottom: 1px solid #ecedf2;
      }
      .agent-sidebar-tab {
        flex: 1;
        display: flex;
        align-items: center;
        justify-content: center;
        gap: 6px;
        padding: 10px 8px;
        font-size: 13px;
        font-weight: 500;
        color: #6b7280;
        background: transparent;
        border: none;
        border-bottom: 2px solid transparent;
        cursor: pointer;
        transition: color 0.15s, border-color 0.15s;
      }
      .agent-sidebar-tab:hover { color: #181b25; }
      .agent-sidebar-tab.is-active {
        color: #181b25;
        border-bottom-color: #181b25;
      }
      html[data-theme='dark'] .agent-sidebar-tabs { border-bottom-color: rgba(255,255,255,0.06); }
      html[data-theme='dark'] .agent-sidebar-tab { color: #8a92a8; }
      html[data-theme='dark'] .agent-sidebar-tab:hover,
      html[data-theme='dark'] .agent-sidebar-tab.is-active { color: #c7c8fc; border-bottom-color: #c7c8fc; }

      .agent-sidebar-empty {
        padding: 12px;
        text-align: center;
        font-size: 12px;
        color: #94a3b8;
      }

      .agent-topic-list {
        display: flex;
        flex-direction: column;
        gap: 4px;
      }
      .agent-topic-item {
        display: flex;
        align-items: center;
        gap: 8px;
        padding: 8px 10px;
        border-radius: 8px;
        cursor: pointer;
        position: relative;
        transition: background 0.15s;
      }
      .agent-topic-item:hover { background: #eef0f5; }
      .agent-topic-item.is-active { background: #e5e7ee; }
      .agent-topic-item-icon {
        width: 24px;
        height: 24px;
        flex-shrink: 0;
        border-radius: 6px;
        display: flex; align-items: center; justify-content: center;
        background: #ffffff;
        border: 1px solid #ecedf2;
        color: #475569;
      }
      .agent-topic-item.is-active .agent-topic-item-icon {
        background: #181b25; color: #fff; border-color: #181b25;
      }
      .agent-topic-item-body { flex: 1; min-width: 0; }
      .agent-topic-item-title {
        font-size: 13px;
        font-weight: 500;
        color: #181b25;
        white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
      }
      .agent-topic-item-meta { font-size: 11px; color: #94a3b8; margin-top: 1px; }
      .agent-topic-item-del {
        flex-shrink: 0;
        width: 20px; height: 20px;
        border-radius: 4px;
        display: none;
        align-items: center; justify-content: center;
        color: #94a3b8;
        background: transparent;
        border: none;
        cursor: pointer;
      }
      .agent-topic-item:hover .agent-topic-item-del,
      .agent-topic-item.is-active .agent-topic-item-del { display: flex; }
      .agent-topic-item-del:hover { background: rgba(239,68,68,0.12); color: #ef4444; }
      html[data-theme='dark'] .agent-topic-item:hover { background: rgba(99, 102, 241, 0.06); }
      html[data-theme='dark'] .agent-topic-item.is-active { background: rgba(255,255,255,0.06); }
      html[data-theme='dark'] .agent-topic-item-icon { background: rgba(99, 102, 241, 0.06); border-color: rgba(99, 102, 241,0.2); color: #c8ccde; }
      html[data-theme='dark'] .agent-topic-item.is-active .agent-topic-item-icon { background: #c7c8fc; color: #181b25; border-color: #c7c8fc; }
      html[data-theme='dark'] .agent-topic-item-title { color: #e5e7f0; }
      html[data-theme='dark'] .agent-topic-item-meta { color: #6e7791; }

      .agent-assistant-card {
        display: flex;
        gap: 10px;
        align-items: center;
        padding: 10px;
        border-radius: 10px;
        border: 1px solid #ecedf2;
        background: #ffffff;
        cursor: pointer;
      }
      .agent-assistant-card.is-active { border-color: #181b25; background: #f4f5f8; }
      .agent-assistant-card-icon {
        width: 32px; height: 32px;
        border-radius: 8px;
        background: var(--assistant-accent, linear-gradient(135deg, #6366f1, #8b5cf6));
        color: #fff;
        display: flex; align-items: center; justify-content: center;
        flex-shrink: 0;
      }
      .agent-assistant-card-title { font-size: 13px; font-weight: 600; color: #181b25; }
      .agent-assistant-card-meta { font-size: 11px; color: #94a3b8; margin-top: 2px; }
      html[data-theme='dark'] .agent-assistant-card { background: rgba(255,255,255,0.03); border-color: rgba(99, 102, 241,0.2); }
      html[data-theme='dark'] .agent-assistant-card.is-active { background: rgba(255,255,255,0.06); border-color: #6366f1; }
      html[data-theme='dark'] .agent-assistant-card-title { color: #e5e7f0; }
      html[data-theme='dark'] .agent-assistant-card-meta { color: #6e7791; }
      .agent-assistant-list {
        display: flex;
        flex-direction: column;
        gap: 6px;
      }
      .agent-assistant-card-body { min-width: 0; flex: 1; }
      .agent-assistant-card-title { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
      .agent-assistant-card:hover { background: #f7f8fb; }
      html[data-theme='dark'] .agent-assistant-card:hover { background: rgba(99, 102, 241, 0.08); }
      .agent-assistant-card--custom { border-style: dashed; }
      .agent-assistant-card-edit {
        width: 26px; height: 26px;
        border-radius: 6px;
        display: flex; align-items: center; justify-content: center;
        background: transparent;
        border: none;
        color: #94a3b8;
        cursor: pointer;
        flex-shrink: 0;
      }
      .agent-assistant-card-edit:hover { background: #eef0f5; color: #181b25; }
      html[data-theme='dark'] .agent-assistant-card-edit:hover { background: rgba(99, 102, 241,0.2); color: #c7c8fc; }

      /* Header refresh: badges */
      .agent-chat-head-left {
        display: flex;
        align-items: center;
        gap: 8px;
        flex: 1;
        min-width: 0;
      }
      .agent-head-icon-btn {
        width: 30px; height: 30px;
        border-radius: 8px;
        display: flex; align-items: center; justify-content: center;
        background: transparent;
        border: none;
        color: #475569;
        cursor: pointer;
        transition: background 0.15s, color 0.15s;
      }
      .agent-head-icon-btn:hover { background: #eef0f5; color: #181b25; }
      .agent-head-icon-btn.is-active { background: #181b25; color: #fff; }
      html[data-theme='dark'] .agent-head-icon-btn { color: #9ba3b7; }
      html[data-theme='dark'] .agent-head-icon-btn:hover { background: rgba(255,255,255,0.06); color: #c7c8fc; }
      html[data-theme='dark'] .agent-head-icon-btn.is-active { background: #c7c8fc; color: #181b25; }

      .agent-head-badge {
        display: inline-flex;
        align-items: center;
        gap: 6px;
        padding: 5px 10px;
        border-radius: 999px;
        background: #f4f5f8;
        border: 1px solid #ecedf2;
        font-size: 12px;
        font-weight: 500;
        color: #181b25;
        cursor: default;
        max-width: 100%;
        min-width: 0;
      }
      .agent-head-badge--model {
        cursor: pointer;
        font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
        font-size: 12px;
      }
      .agent-head-badge--model:hover { background: #eaecf2; }
      button.agent-head-badge {
        border: 1px solid #ecedf2;
        font-family: inherit;
      }
      .agent-head-badge--assistant {
        cursor: pointer;
        max-width: 220px;
      }
      .agent-head-badge--assistant span {
        white-space: nowrap;
        overflow: hidden;
        text-overflow: ellipsis;
        min-width: 0;
      }
      .agent-head-badge--assistant:hover { background: #eaecf2; }
      html[data-theme='dark'] .agent-head-badge--assistant:hover { background: rgba(99, 102, 241,0.2); }
      .agent-head-badge-tag {
        font-size: 10px;
        padding: 1px 6px;
        border-radius: 4px;
        background: #181b25;
        color: #fff;
        margin-left: 2px;
      }
      .agent-head-arrow { color: #94a3b8; font-size: 14px; }
      html[data-theme='dark'] .agent-head-badge {
        background: rgba(99, 102, 241, 0.06);
        border-color: rgba(99, 102, 241,0.2);
        color: #e5e7f0;
      }
      html[data-theme='dark'] .agent-head-badge--model:hover { background: rgba(99, 102, 241,0.2); }
      html[data-theme='dark'] .agent-head-badge-tag { background: #6366f1; }
      html[data-theme='dark'] .agent-head-arrow { color: #6e7791; }

      .agent-hello-card {
        max-width: 760px;
        margin: 0 auto 8px;
        padding: 14px 18px;
        background: #ffffff;
        border: 1px solid #ecedf2;
        border-radius: 12px;
        color: #475569;
        font-size: 14px;
      }
      html[data-theme='dark'] .agent-hello-card {
        background: rgba(255,255,255,0.02);
        border-color: rgba(255,255,255,0.06);
        color: #9ba3b7;
      }

      /* Composer + bottom toolbar */
      .agent-composer {
        flex-direction: column;
        padding: 12px 16px 16px;
        gap: 0;
      }
      .agent-composer-input {
        min-height: 56px;
        max-height: 220px;
        border-radius: 12px 12px 0 0;
        border-bottom: none;
      }
      .agent-composer--expanded .agent-composer-input {
        min-height: 220px;
        max-height: 480px;
      }
      .agent-composer-input:focus {
        box-shadow: 0 0 0 3px rgba(24,27,37,0.06);
      }
      .agent-composer-toolbar {
        display: flex;
        align-items: center;
        justify-content: space-between;
        gap: 10px;
        padding: 8px 10px;
        background: #ffffff;
        border: 1px solid #ecedf2;
        border-top: 1px solid #ecedf2;
        border-radius: 0 0 12px 12px;
        flex-wrap: wrap;
      }
      .agent-tool-group {
        display: flex;
        align-items: center;
        gap: 2px;
        flex-wrap: wrap;
        min-width: 0;
      }
      .agent-tool-right {
        display: flex;
        align-items: center;
        gap: 6px;
        flex-shrink: 0;
      }
      .agent-tool-btn {
        width: 30px; height: 30px;
        border-radius: 8px;
        display: inline-flex;
        align-items: center;
        justify-content: center;
        background: transparent;
        border: none;
        color: #6b7280;
        cursor: pointer;
        position: relative;
        transition: background 0.15s, color 0.15s;
      }
      .agent-tool-btn:hover { background: #eef0f5; color: #181b25; }
      .agent-tool-btn.is-active { color: #6366f1; background: rgba(99, 102, 241,0.12); }
      .agent-tool-thinking { width: auto; padding: 0 8px; gap: 4px; }
      .agent-tool-tag {
        font-size: 10px;
        padding: 1px 5px;
        border-radius: 4px;
        background: rgba(99, 102, 241,0.12);
        color: #6366f1;
        font-weight: 600;
      }
      .agent-tool-thinking.is-active .agent-tool-tag { background: #6366f1; color: #fff; }
      .agent-tool-sep {
        width: 1px; height: 18px;
        background: #ecedf2;
        margin: 0 4px;
      }
      html[data-theme='dark'] .agent-composer-toolbar {
        background: rgba(22,26,37,0.7);
        border-color: rgba(255,255,255,0.06);
      }
      html[data-theme='dark'] .agent-tool-btn { color: #8a92a8; }
      html[data-theme='dark'] .agent-tool-btn:hover { background: rgba(255,255,255,0.06); color: #c7c8fc; }
      html[data-theme='dark'] .agent-tool-btn.is-active { background: rgba(99, 102, 241,0.2); color: #a5b4fc; }
      html[data-theme='dark'] .agent-tool-tag { background: rgba(99, 102, 241,0.2); color: #a5b4fc; }
      html[data-theme='dark'] .agent-tool-sep { background: rgba(99, 102, 241,0.2); }

      .agent-composer-send-circle {
        width: 34px; height: 34px;
        border-radius: 50%;
        display: inline-flex;
        align-items: center;
        justify-content: center;
        background: #181b25;
        color: #fff;
        border: none;
        cursor: pointer;
        transition: background 0.2s ease, transform 0.15s cubic-bezier(0.34, 1.56, 0.64, 1), box-shadow 0.2s ease;
        position: relative;
        overflow: hidden;
      }
      .agent-composer-send-circle::before {
        content: '';
        position: absolute;
        inset: 0;
        border-radius: 50%;
        background: rgba(255,255,255,0.25);
        transform: scale(0);
        transition: transform 0.4s ease;
      }
      .agent-composer-send-circle:hover {
        background: #2c3243;
        transform: scale(1.08);
        box-shadow: 0 4px 14px rgba(24,27,37,0.35);
      }
      .agent-composer-send-circle:active {
        transform: scale(0.92);
        transition: transform 0.08s ease;
      }
      .agent-composer-send-circle:active::before {
        transform: scale(2.5);
        opacity: 0;
        transition: transform 0.5s ease, opacity 0.5s ease;
      }
      .agent-composer-send-circle.is-sending {
        pointer-events: none;
        opacity: 0.7;
      }
      .agent-composer-send-circle.is-sending i {
        animation: agentSpin 0.8s linear infinite;
      }
      html[data-theme='dark'] .agent-composer-send-circle { background: #a5b4fc; color: #111; }
      html[data-theme='dark'] .agent-composer-send-circle:hover { background: #fff; box-shadow: 0 4px 14px rgba(0,0,0,0.35); }

      /* Settings drawer */
      .agent-page--settings-open { grid-template-columns: 260px minmax(0, 1fr) 360px; }
      .agent-settings-drawer {
        background: #ffffff;
        border-left: 1px solid #ecedf2;
        display: flex;
        flex-direction: column;
        height: 100vh;
        overflow: hidden;
        animation: agentDrawerSlideIn 0.35s cubic-bezier(0.22, 1, 0.36, 1) both;
      }
      .agent-settings-head {
        padding: 18px 20px 14px;
        display: flex;
        align-items: flex-start;
        justify-content: space-between;
        gap: 10px;
        border-bottom: 1px solid #ecedf2;
      }
      .agent-settings-title {
        font-size: 14px;
        font-weight: 600;
        color: #181b25;
      }
      .agent-settings-desc {
        font-size: 12px;
        color: #94a3b8;
        margin-top: 4px;
        max-width: 280px;
      }
      .agent-settings-body {
        flex: 1;
        overflow-y: auto;
        padding: 16px 20px 20px;
        display: flex;
        flex-direction: column;
        gap: 14px;
      }
      .agent-settings-field {
        display: flex;
        flex-direction: column;
        gap: 6px;
      }
      .agent-settings-label {
        font-size: 12px;
        font-weight: 600;
        color: #475569;
      }
      .agent-settings-input {
        width: 100%;
        padding: 8px 10px;
        font-size: 13px;
        border: 1px solid #ecedf2;
        border-radius: 8px;
        background: #ffffff;
        color: #181b25;
        outline: none;
        transition: border-color 0.15s, box-shadow 0.15s;
      }
      .agent-settings-input:focus {
        border-color: #181b25;
        box-shadow: 0 0 0 3px rgba(24,27,37,0.06);
      }
      .agent-settings-hint {
        font-size: 11px;
        color: #94a3b8;
      }
      .agent-settings-keyrow {
        display: flex;
        align-items: center;
        gap: 6px;
      }
      .agent-settings-keyrow .agent-settings-input { flex: 1; }
      .agent-settings-actions {
        display: flex;
        gap: 8px;
        margin-top: 4px;
      }
      .agent-settings-btn {
        padding: 8px 14px;
        font-size: 13px;
        font-weight: 500;
        border-radius: 8px;
        border: 1px solid #ecedf2;
        background: #ffffff;
        color: #181b25;
        cursor: pointer;
        transition: background 0.15s;
      }
      .agent-settings-btn:hover { background: #f4f5f8; }
      .agent-settings-btn--primary {
        background: #181b25;
        color: #fff;
        border-color: #181b25;
      }
      .agent-settings-btn--primary:hover { background: #2c3243; }
      html[data-theme='dark'] .agent-settings-drawer {
        background: #161a25;
        border-left-color: rgba(255,255,255,0.06);
      }
      html[data-theme='dark'] .agent-settings-head { border-bottom-color: rgba(255,255,255,0.06); }
      html[data-theme='dark'] .agent-settings-title { color: #c7c8fc; }
      html[data-theme='dark'] .agent-settings-desc { color: #6e7791; }
      html[data-theme='dark'] .agent-settings-label { color: #9ba3b7; }
      html[data-theme='dark'] .agent-settings-input {
        background: rgba(99, 102, 241, 0.06);
        border-color: rgba(99, 102, 241,0.2);
        color: #e5e7f0;
      }
      html[data-theme='dark'] .agent-settings-input:focus {
        border-color: #6366f1;
        box-shadow: 0 0 0 3px rgba(99, 102, 241,0.2);
      }
      html[data-theme='dark'] .agent-settings-hint { color: #6e7791; }
      html[data-theme='dark'] .agent-settings-btn {
        background: rgba(99, 102, 241, 0.06);
        border-color: rgba(99, 102, 241,0.2);
        color: #e5e7f0;
      }
      html[data-theme='dark'] .agent-settings-btn:hover { background: rgba(99, 102, 241,0.2); }
      html[data-theme='dark'] .agent-settings-btn--primary { background: #6366f1; border-color: #6366f1; }
      html[data-theme='dark'] .agent-settings-btn--primary:hover { background: #5558e3; }

      /* Modal overlay */
      .agent-modal-overlay {
        position: fixed; inset: 0;
        background: rgba(15,23,42,0.45);
        display: flex; align-items: center; justify-content: center;
        z-index: 1000;
        backdrop-filter: blur(2px);
      }
      .agent-modal {
        width: min(420px, 92vw);
        max-height: 80vh;
        background: #ffffff;
        border-radius: 14px;
        border: 1px solid #ecedf2;
        box-shadow: 0 20px 60px rgba(15,23,42,0.18);
        display: flex; flex-direction: column;
        overflow: hidden;
      }
      .agent-modal-head {
        display: flex; align-items: center; justify-content: space-between;
        padding: 14px 16px 12px;
        font-size: 14px; font-weight: 600; color: #181b25;
        border-bottom: 1px solid #ecedf2;
      }
      .agent-modal-desc {
        padding: 10px 16px 4px;
        font-size: 12px; color: #94a3b8;
      }
      .agent-modal-list {
        flex: 1;
        overflow-y: auto;
        padding: 8px 12px 12px;
        display: flex; flex-direction: column;
        gap: 2px;
      }
      .agent-modal--custom-assistant {
        width: min(560px, 94vw);
        max-height: 86vh;
      }
      .agent-modal-body {
        flex: 1;
        overflow-y: auto;
        padding: 12px 16px 4px;
        display: flex; flex-direction: column;
        gap: 14px;
      }
      .agent-modal-actions {
        display: flex; gap: 8px;
        padding: 10px 16px 14px;
        border-top: 1px solid #ecedf2;
        background: #fafbfc;
      }
      html[data-theme='dark'] .agent-modal-actions {
        border-top-color: rgba(255,255,255,0.06);
        background: rgba(255,255,255,0.02);
      }
      .agent-custom-prompt {
        font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
        font-size: 12px;
        line-height: 1.5;
        min-height: 180px;
        resize: vertical;
      }
      .agent-modal-list-item {
        display: flex;
        align-items: center;
        gap: 8px;
        padding: 8px 10px;
        border-radius: 8px;
        background: transparent;
        border: none;
        text-align: left;
        color: #181b25;
        cursor: pointer;
        font-size: 13px;
        width: 100%;
      }
      .agent-modal-list-item:hover { background: #f4f5f8; }
      .agent-modal-list-item.is-active { background: #181b25; color: #fff; }
      .agent-modal-list-item.is-active i { color: #fff; }
      .agent-modal-list-item .truncate {
        flex: 1;
        white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
      }
      .agent-modal-tag {
        font-size: 10px;
        padding: 1px 6px;
        border-radius: 4px;
        background: #eef0f5;
        color: #475569;
      }
      .agent-modal-empty {
        padding: 24px;
        text-align: center;
        color: #94a3b8;
        font-size: 13px;
      }
      html[data-theme='dark'] .agent-modal {
        background: #161a25;
        border-color: rgba(99, 102, 241,0.2);
      }
      html[data-theme='dark'] .agent-modal-head { color: #c7c8fc; border-bottom-color: rgba(255,255,255,0.06); }
      html[data-theme='dark'] .agent-modal-desc { color: #6e7791; }
      html[data-theme='dark'] .agent-modal-list-item { color: #e5e7f0; }
      html[data-theme='dark'] .agent-modal-list-item:hover { background: rgba(99, 102, 241, 0.06); }
      html[data-theme='dark'] .agent-modal-list-item.is-active { background: #6366f1; }
      html[data-theme='dark'] .agent-modal-tag { background: rgba(255,255,255,0.06); color: #c8ccde; }
      html[data-theme='dark'] .agent-modal-empty { color: #6e7791; }

      /* Collapsed sidebar */
      body.agent-sidebar-collapsed .agent-sidebar {
        width: 0;
        opacity: 0;
        overflow: hidden;
        border-right-width: 0;
        padding: 0;
        transition: width 0.35s cubic-bezier(0.22, 1, 0.36, 1), opacity 0.2s ease, border-right-width 0.2s ease;
      }
      body.agent-sidebar-collapsed .agent-page { grid-template-columns: minmax(0, 1fr); }
      body.agent-sidebar-collapsed .agent-page--settings-open { grid-template-columns: minmax(0, 1fr) 360px; }
      .agent-sidebar {
        width: 260px;
        transition: width 0.35s cubic-bezier(0.22, 1, 0.36, 1), opacity 0.2s ease, border-right-width 0.2s ease;
      }

      /* Mobile adjustments */
      @media (max-width: 900px) {
        .agent-page--settings-open {
          grid-template-columns: 260px minmax(0, 1fr);
        }
        .agent-settings-drawer {
          position: fixed;
          top: 0; right: 0;
          width: min(360px, 92vw);
          height: 100vh;
          z-index: 999;
          box-shadow: -20px 0 40px rgba(15,23,42,0.2);
        }
      }
      @media (max-width: 768px) {
        .agent-tool-btn { width: 28px; height: 28px; }
        .agent-tool-thinking { padding: 0 6px; }
        .agent-composer-send-circle { width: 32px; height: 32px; }
        .agent-head-badge { font-size: 11px; padding: 4px 8px; }
        .agent-head-badge-tag { display: none; }
      }

/* ============================================================
 * Copilot / Agent — minimalist flat theme (light + dark)
 * ============================================================ */

/* Flat color tokens */
:root {
  --cp-bg: #f7f8fb;
  --cp-surface: #ffffff;
  --cp-surface-2: #fafbfd;
  --cp-border: #ecedf2;
  --cp-border-2: #e5e7eb;
  --cp-text: #171717;
  --cp-text-2: #404040;
  --cp-text-3: #737373;
  --cp-text-muted: #9ba3b7;
  --cp-accent: #262626;
  --cp-accent-hover: #3a3a3a;
  --cp-primary: #525252;
  --cp-primary-hover: #404040;
}

html[data-theme='dark'] {
  --cp-bg: #11141d;
  --cp-surface: #161a25;
  --cp-surface-2: #1e2330;
  --cp-border: rgba(255,255,255,0.06);
  --cp-border-2: rgba(255,255,255,0.08);
  --cp-text: #e5e7f0;
  --cp-text-2: #c8ccde;
  --cp-text-3: #9ba3b7;
  --cp-text-muted: #6e7791;
  --cp-accent: #525252;
  --cp-accent-hover: #6b7280;
  --cp-primary: #525252;
  --cp-primary-hover: #6b7280;
}

/* Agent page background */
body[data-area="agent"] {
  background: var(--cp-bg);
}

/* Surfaces */
.agent-page,
.agent-message-list {
  background: var(--cp-bg);
}
.agent-sidebar {
  background: var(--cp-surface-2);
  border-right-color: var(--cp-border);
}
.agent-chat-head,
.agent-composer {
  background: rgba(255,255,255,0.6);
  border-color: var(--cp-border);
}
html[data-theme='dark'] .agent-chat-head,
html[data-theme='dark'] .agent-composer {
  background: rgba(22,26,37,0.7);
}

/* Brand / header */
.agent-sidebar-brand-icon,
.copilot-name-icon,
.agent-hello-avatar {
  background: var(--cp-surface);
  border: 1px solid var(--cp-border-2);
  color: var(--cp-text);
}
.agent-sidebar-brand-title,
.agent-head-title span {
  color: var(--cp-text);
}
.agent-sidebar-brand-subtitle,
.agent-head-title small {
  color: var(--cp-text-muted);
}

/* Buttons & entries */
.agent-new-chat {
  background: var(--cp-accent);
  color: #fff;
  border: 1px solid var(--cp-accent);
  border-radius: 8px;
}
.agent-new-chat:hover {
  background: var(--cp-accent-hover);
}
.agent-memory-entry {
  background: var(--cp-surface);
  border: 1px solid var(--cp-border-2);
  color: var(--cp-text);
  border-radius: 8px;
}
.agent-memory-entry:hover {
  background: var(--cp-surface-2);
}

/* Topic list */
.agent-topic-item {
  background: transparent;
  border: 1px solid transparent;
  border-radius: 8px;
}
.agent-topic-item:hover {
  background: rgba(0,0,0,0.03);
}
html[data-theme='dark'] .agent-topic-item:hover {
  background: rgba(255,255,255,0.04);
}
.agent-topic-item.is-active {
  background: var(--cp-surface);
  border-color: var(--cp-border-2);
}
.agent-topic-item-icon {
  background: var(--cp-surface);
  border: 1px solid var(--cp-border);
  color: var(--cp-text-2);
}
.agent-topic-item.is-active .agent-topic-item-icon {
  background: var(--cp-accent);
  color: #fff;
  border-color: var(--cp-accent);
}
.agent-topic-item-title {
  color: var(--cp-text);
}
.agent-topic-item-meta {
  color: var(--cp-text-muted);
}
.agent-topic-item-del:hover {
  background: rgba(239,68,68,0.12);
  color: #ef4444;
}

/* Head badges & tools */
.agent-head-badge {
  background: var(--cp-surface);
  border: 1px solid var(--cp-border);
  color: var(--cp-text);
  border-radius: 999px;
}
.agent-head-badge--model:hover,
.agent-head-badge--assistant:hover {
  background: var(--cp-surface-2);
}
.agent-head-badge-tag {
  background: var(--cp-accent);
  color: #fff;
}
html[data-theme='dark'] .agent-head-badge-tag {
  background: var(--cp-primary);
}
.agent-head-arrow {
  color: var(--cp-text-muted);
}
.agent-head-icon-btn {
  color: var(--cp-text-3);
  border-radius: 8px;
}
.agent-head-icon-btn:hover {
  background: rgba(0,0,0,0.04);
  color: var(--cp-text);
}
html[data-theme='dark'] .agent-head-icon-btn:hover {
  background: rgba(255,255,255,0.06);
}
.agent-head-icon-btn.is-active {
  background: var(--cp-accent);
  color: #fff;
}
html[data-theme='dark'] .agent-head-icon-btn.is-active {
  background: var(--cp-accent);
  color: #11141d;
}

/* Composer */
.agent-composer-input {
  background: var(--cp-surface);
  border: 1px solid var(--cp-border);
  color: var(--cp-text);
  border-radius: 12px 12px 0 0;
}
.agent-composer-input:focus {
  border-color: var(--cp-primary);
  box-shadow: 0 0 0 3px rgba(115, 115, 115,0.12);
}
html[data-theme='dark'] .agent-composer-input:focus {
  box-shadow: 0 0 0 3px rgba(115, 115, 115,0.2);
}
.agent-composer-toolbar {
  background: var(--cp-surface);
  border: 1px solid var(--cp-border);
  border-top: 1px solid var(--cp-border);
  border-radius: 0 0 12px 12px;
}
.agent-tool-btn {
  color: var(--cp-text-3);
  border-radius: 8px;
}
.agent-tool-btn:hover {
  background: rgba(0,0,0,0.04);
  color: var(--cp-text);
}
html[data-theme='dark'] .agent-tool-btn:hover {
  background: rgba(255,255,255,0.06);
}
.agent-tool-btn.is-active {
  color: var(--cp-primary);
  background: rgba(115, 115, 115,0.12);
}
.agent-tool-sep {
  background: var(--cp-border);
}

/* Send button */
.agent-composer-send-circle {
  background: var(--cp-accent);
  color: #fff;
  border-radius: 50%;
}
.agent-composer-send-circle:hover {
  background: var(--cp-accent-hover);
}
html[data-theme='dark'] .agent-composer-send-circle {
  background: var(--cp-primary);
}
html[data-theme='dark'] .agent-composer-send-circle:hover {
  background: var(--cp-primary-hover);
}
.agent-composer-stop-circle {
  background: #ef4444;
  color: #fff;
}
.agent-composer-stop-circle:hover {
  background: #dc2626;
}

/* Chat chips */
.agent-chat-chip {
  background: var(--cp-surface);
  border: 1px solid var(--cp-border);
}
.agent-chat-chip-label {
  color: var(--cp-text-muted);
}
.agent-chat-chip-value {
  color: var(--cp-text);
}
.agent-chat-chip--accent {
  background: rgba(115, 115, 115,0.08);
  border-color: rgba(115, 115, 115,0.25);
}
.agent-chat-chip--accent .agent-chat-chip-value {
  color: var(--cp-primary);
}

/* Hello & empty states */
.agent-hello-card {
  width: min(560px, 100%);
  margin: auto;
  padding: 0 18px;
  background: transparent;
  border: 0;
  border-radius: 0;
  color: var(--cp-text-3);
  text-align: center;
  box-shadow: none;
}
.agent-hello-body {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 18px;
}
.agent-hello-kicker {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  margin-bottom: 10px;
  color: var(--cp-text-muted);
  font-size: 12px;
  font-weight: 600;
}
.agent-hello-title {
  max-width: 520px;
  color: var(--cp-text);
  font-size: 21px;
  font-weight: 650;
  line-height: 1.45;
  letter-spacing: 0;
}
.agent-suggestion-chips {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 8px;
}
.agent-suggestion-chip {
  min-height: 34px;
  padding: 0 13px;
  border-radius: 999px;
  background: rgba(255,255,255,0.72);
  border: 1px solid var(--cp-border);
  color: var(--cp-text-2);
  font-size: 13px;
  font-weight: 600;
  box-shadow: none;
}
.agent-suggestion-chip:hover {
  background: var(--cp-surface);
  border-color: #d4d4d4;
  color: var(--cp-text);
  transform: translateY(-1px);
}
html[data-theme='dark'] .agent-suggestion-chip {
  background: rgba(255,255,255,0.04);
  border-color: var(--cp-border-2);
}
html[data-theme='dark'] .agent-suggestion-chip:hover {
  background: rgba(255,255,255,0.07);
  border-color: rgba(255,255,255,0.14);
}
.agent-chat-empty-icon {
  background: var(--cp-surface);
  border: 1px solid var(--cp-border-2);
}
.agent-chat-empty-title {
  color: var(--cp-text);
}
.agent-chat-empty-hint {
  color: var(--cp-text-muted);
}

/* Session sidebar items (legacy) */
.agent-session:hover {
  background: rgba(0,0,0,0.03);
}
html[data-theme='dark'] .agent-session:hover {
  background: rgba(255,255,255,0.04);
}
.agent-session--active {
  background: var(--cp-surface);
  border-color: var(--cp-border-2);
}
.agent-session-icon {
  background: var(--cp-surface);
  border: 1px solid var(--cp-border);
  color: var(--cp-text-2);
}
.agent-session--active .agent-session-icon {
  background: var(--cp-accent);
  color: #fff;
}
.agent-session-title {
  color: var(--cp-text);
}
.agent-session-meta {
  color: var(--cp-text-muted);
}

/* Pilot panel (floating) */
.pilot-panel {
  background: var(--cp-surface);
  border: 1px solid var(--cp-border-2);
  box-shadow: 0 4px 24px rgba(0,0,0,0.08);
  border-radius: 12px;
}
html[data-theme='dark'] .pilot-panel {
  box-shadow: 0 4px 24px rgba(0,0,0,0.3);
}
.pilot-header {
  background: var(--cp-surface-2);
  border-color: var(--cp-border);
}
.pilot-header-title {
  color: var(--cp-text);
}
.pilot-header-icon {
  background: var(--cp-accent);
  color: #fff;
}
.pilot-close,
.pilot-expand {
  color: var(--cp-text-muted);
}
.pilot-close:hover,
.pilot-expand:hover {
  background: rgba(0,0,0,0.04);
  color: var(--cp-text);
}
html[data-theme='dark'] .pilot-close:hover,
html[data-theme='dark'] .pilot-expand:hover {
  background: rgba(255,255,255,0.06);
}

/* Pilot FAB */
.pilot-fab {
  background: var(--cp-accent);
  color: #fff;
  border-radius: 12px;
  box-shadow: 0 2px 8px rgba(24,27,37,0.25);
  border: 1px solid var(--cp-accent);
}
.pilot-fab:hover {
  background: var(--cp-accent-hover);
  box-shadow: 0 4px 14px rgba(24,27,37,0.35);
}
html[data-theme='dark'] .pilot-fab {
  background: var(--cp-primary);
  border-color: var(--cp-primary);
  box-shadow: 0 2px 8px rgba(115, 115, 115,0.35);
}
html[data-theme='dark'] .pilot-fab:hover {
  background: var(--cp-primary-hover);
  box-shadow: 0 4px 14px rgba(115, 115, 115,0.45);
}

/* Welcome & actions in pilot panel */
.pilot-welcome {
  color: var(--cp-text-muted);
}
.pilot-action-btn {
  background: var(--cp-surface);
  border: 1px solid var(--cp-border-2);
  color: var(--cp-text-2);
  border-radius: 6px;
}
.pilot-action-btn:hover {
  background: var(--cp-surface-2);
  border-color: var(--cp-border);
}

/* Result cards */
.pilot-result {
  color: var(--cp-text-2);
}
.pilot-result b,
.pilot-result strong {
  color: var(--cp-text);
}
.pilot-result-card {
  background: var(--cp-surface);
  border: 1px solid var(--cp-border);
  border-radius: 10px;
}
.pilot-result-card-header {
  background: var(--cp-surface-2);
  border-color: var(--cp-border);
}
.pilot-result-card-title {
  color: var(--cp-text);
}
.pilot-result-card-body {
  color: var(--cp-text-2);
}
.pilot-result-card-body h1 { color: var(--cp-text); }
.pilot-result-card-body h2 { color: var(--cp-text); }
.pilot-result-card-body h3 { color: var(--cp-text-2); }
.pilot-result-card-body code {
  background: rgba(0,0,0,0.05);
  color: #b91c1c;
}
html[data-theme='dark'] .pilot-result-card-body code {
  background: rgba(255,255,255,0.06);
  color: #f87171;
}
.pilot-result-card-body blockquote {
  border-left-color: var(--cp-primary);
  background: rgba(115, 115, 115,0.06);
  color: var(--cp-text-2);
}

/* Messages in agent chat */
.agent-message-list .pilot-message--user .pilot-bubble {
  background: var(--cp-accent);
  color: #fff;
  border-radius: 10px;
}
html[data-theme='dark'] .agent-message-list .pilot-message--user .pilot-bubble {
  background: var(--cp-primary);
}
.agent-message-list .pilot-message--ai .pilot-result-card,
.agent-message-list .pilot-message--thinking .pilot-thinking-card {
  background: var(--cp-surface);
  border: 1px solid var(--cp-border);
  border-radius: 10px;
}

/* Message meta */
.pilot-message-meta {
  color: var(--cp-text-muted);
}
.pilot-message-name {
  color: var(--cp-text);
}
.pilot-message-name-sep {
  color: var(--cp-border-2);
}
.pilot-message-vendor {
  color: var(--cp-text-muted);
}
.pilot-message-time {
  color: var(--cp-text-muted);
}

/* Chat layout — flat left-aligned flow */
.agent-message-list {
  padding: 24px 28px;
}
.agent-message-list .pilot-message {
  margin: 0 0 28px;
  padding: 0;
  display: block;
  background: transparent;
  border: none;
  box-shadow: none;
  max-width: 880px;
}
.agent-message-list .pilot-message--user,
.agent-message-list .pilot-message--ai {
  justify-content: flex-start;
}
.agent-message-list .pilot-message--ai .pilot-result-card,
.agent-message-list .pilot-message--thinking .pilot-thinking-card,
.agent-message-list .pilot-message--user .pilot-bubble {
  background: transparent;
  border: none;
  box-shadow: none;
  border-radius: 0;
  max-width: none;
  padding: 0;
  color: inherit;
}

.agent-message-list .pilot-message-meta,
.agent-message-list .pilot-message-meta--user {
  display: flex;
  flex-direction: row;
  justify-content: flex-start;
  align-items: center;
  gap: 10px;
  color: var(--cp-text);
  margin: 0 0 10px;
}
.agent-message-list .pilot-message-avatar {
  width: 28px;
  height: 28px;
  border-radius: 8px;
  border: 1px solid var(--cp-border);
  background: var(--cp-surface);
  color: var(--cp-text);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}
.agent-message-list .pilot-message-avatar--user {
  background: rgba(115, 115, 115,0.1);
  border-color: rgba(115, 115, 115,0.25);
  color: var(--cp-primary);
  overflow: hidden;
}
.agent-message-list .pilot-message-avatar--user img.pilot-user-avatar-img {
  width: 100%;
  height: 100%;
  border-radius: inherit;
  object-fit: cover;
  display: block;
}
.agent-message-list .pilot-message-name {
  font-size: 14px;
  font-weight: 700;
  color: var(--cp-text);
}
.agent-message-list .pilot-message-time {
  font-size: 11px;
  color: var(--cp-text-muted);
  font-weight: 500;
}
.agent-message-list .pilot-message-vendor,
.agent-message-list .pilot-message-name-sep {
  font-size: 12px;
  color: var(--cp-text-3);
  font-weight: 500;
}

/* Body text */
.pilot-ai-body,
.pilot-user-body {
  padding-left: 38px;
  color: var(--cp-text-2);
  font-size: 14px;
  line-height: 1.75;
}
.pilot-user-text {
  white-space: pre-wrap;
  word-break: break-word;
  color: var(--cp-text-2);
}

/* AI markdown */
.pilot-ai-answer {
  color: var(--cp-text);
}
.pilot-ai-answer h1 {
  font-size: 22px;
  font-weight: 800;
  color: var(--cp-text);
  margin: 18px 0 12px;
  letter-spacing: 0.2px;
}
.pilot-ai-answer h2 {
  font-size: 17px;
  font-weight: 750;
  color: var(--cp-text);
  margin: 20px 0 10px;
}
.pilot-ai-answer h3 {
  font-size: 15px;
  font-weight: 700;
  color: var(--cp-text-2);
  margin: 14px 0 8px;
}
.pilot-ai-answer p { margin: 6px 0; }
.pilot-ai-answer ul,
.pilot-ai-answer ol { padding-left: 1.4rem; margin: 6px 0; }
.pilot-ai-answer li { margin: 3px 0; }
.pilot-ai-answer hr {
  border: none;
  border-top: 1px solid var(--cp-border);
  margin: 18px 0;
}
.pilot-ai-answer blockquote {
  border-left: 3px solid #10b981;
  background: rgba(16,185,129,0.06);
  margin: 10px 0;
  padding: 8px 12px;
  color: var(--cp-text-2);
  border-radius: 0 6px 6px 0;
}
.pilot-ai-answer code {
  background: rgba(0,0,0,0.05);
  border-radius: 4px;
  padding: 1px 5px;
  font-size: 0.9em;
  color: #b91c1c;
}
html[data-theme='dark'] .pilot-ai-answer code {
  background: rgba(255,255,255,0.06);
  color: #f87171;
}
.pilot-ai-answer pre {
  background: #0f172a;
  color: #e2e8f0;
  padding: 12px 14px;
  border-radius: 8px;
  overflow-x: auto;
  margin: 10px 0;
  font-size: 13px;
  line-height: 1.55;
}
.pilot-ai-answer pre code {
  background: transparent;
  color: inherit;
  padding: 0;
  font-size: inherit;
}
.pilot-ai-answer table {
  width: 100%;
  border-collapse: collapse;
  margin: 12px 0;
  font-size: 13px;
}
.pilot-ai-answer th,
.pilot-ai-answer td {
  border: 1px solid var(--cp-border);
  padding: 8px 12px;
  text-align: left;
  vertical-align: top;
}
.pilot-ai-answer th {
  background: var(--cp-surface-2);
  font-weight: 700;
  color: var(--cp-text);
}
.pilot-ai-answer tr:nth-child(2n) td {
  background: rgba(0,0,0,0.02);
}
html[data-theme='dark'] .pilot-ai-answer tr:nth-child(2n) td {
  background: rgba(255,255,255,0.02);
}

/* Thinking block */
.pilot-thinking-block {
  margin: 0 0 14px;
}
.pilot-thinking-summary {
  list-style: none;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  gap: 8px;
  font-size: 12px;
  font-weight: 600;
  color: var(--cp-text-3);
  padding: 5px 10px;
  border: 1px solid var(--cp-border-2);
  border-radius: 999px;
  background: var(--cp-surface-2);
  user-select: none;
  transition: background 0.15s ease, border-color 0.15s ease;
}
.pilot-thinking-summary:hover {
  background: var(--cp-surface);
  border-color: var(--cp-border);
}
.pilot-thinking-summary::-webkit-details-marker { display: none; }
.pilot-thinking-bulb { color: #f59e0b; }
.pilot-thinking-caret {
  color: var(--cp-text-muted);
  transition: transform 0.18s ease;
}
.pilot-thinking-block[open] .pilot-thinking-caret {
  transform: rotate(90deg);
}
.pilot-thinking-content {
  margin-top: 8px;
  padding: 10px 12px;
  border-left: 2px solid var(--cp-border-2);
  background: var(--cp-surface-2);
  border-radius: 0 6px 6px 0;
  font-size: 12.5px;
  line-height: 1.7;
  color: var(--cp-text-muted);
  white-space: pre-wrap;
  word-break: break-word;
}
.pilot-thinking-placeholder {
  color: var(--cp-text-muted);
  font-style: italic;
}

/* Streaming indicators */
.pilot-stream-cursor {
  display: inline-block;
  width: 7px;
  height: 14px;
  margin-left: 2px;
  vertical-align: -2px;
  background: var(--cp-text);
  border-radius: 1px;
  animation: pilotStreamBlink 1s steps(2, end) infinite;
}
@keyframes pilotStreamBlink {
  to { opacity: 0; }
}
.pilot-stream-waiting {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 6px 0;
}
.pilot-stream-waiting .pilot-stream-dot {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: var(--cp-text-muted);
  animation: pilotStreamDot 1.2s ease-in-out infinite;
}
.pilot-stream-waiting .pilot-stream-dot:nth-child(2) { animation-delay: 0.15s; }
.pilot-stream-waiting .pilot-stream-dot:nth-child(3) { animation-delay: 0.3s; }
@keyframes pilotStreamDot {
  0%, 80%, 100% { opacity: 0.25; transform: translateY(0); }
  40% { opacity: 1; transform: translateY(-2px); }
}
.pilot-thinking-block.is-streaming .pilot-thinking-bulb {
  animation: pilotThinkingPulse 1.4s ease-in-out infinite;
}
@keyframes pilotThinkingPulse {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.45; }
}

/* Message actions */
.pilot-msg-actions {
  margin-top: 10px;
  display: flex;
  gap: 4px;
  opacity: 0;
  transition: opacity 0.18s ease;
}
.agent-message-list .pilot-message:hover .pilot-msg-actions {
  opacity: 1;
}
.pilot-msg-action {
  width: 26px;
  height: 26px;
  border-radius: 6px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  background: transparent;
  border: 1px solid transparent;
  color: var(--cp-text-3);
  cursor: pointer;
  transition: background 0.15s ease, color 0.15s ease, border-color 0.15s ease;
}
.pilot-msg-action:hover {
  background: var(--cp-surface-2);
  color: var(--cp-text);
  border-color: var(--cp-border-2);
}

/* Error states */
.pilot-error-text {
  color: #ef4444;
  font-weight: 600;
  margin: 0 0 6px;
}
.pilot-error-detail {
  margin-top: 4px;
  color: var(--cp-text-3);
}
.pilot-error-detail > summary {
  list-style: none;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: 12px;
  font-weight: 600;
  color: var(--cp-text-3);
  padding: 2px 0;
  user-select: none;
}
.pilot-error-detail > summary::-webkit-details-marker { display: none; }
.pilot-error-caret {
  transition: transform 0.18s ease;
}
.pilot-error-detail[open] .pilot-error-caret {
  transform: rotate(180deg);
}
.pilot-error-detail pre {
  margin: 6px 0 0;
  padding: 8px 10px;
  border-left: 2px solid var(--cp-border-2);
  background: var(--cp-surface-2);
  font-size: 12px;
  line-height: 1.6;
  color: var(--cp-text-3);
  white-space: pre-wrap;
  word-break: break-word;
  border-radius: 0;
}

/* Interrupted tag */
.pilot-interrupted-tag {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  margin-top: 6px;
  padding: 2px 8px;
  border-radius: 999px;
  background: rgba(239,68,68,0.08);
  border: 1px solid rgba(239,68,68,0.2);
  color: #ef4444;
  font-size: 11px;
  font-weight: 600;
}

/* Copilot name gate */
.copilot-name-gate {
  min-height: calc(100vh - 64px);
  display: grid;
  place-items: center;
  padding: 32px 16px;
  background: var(--cp-bg);
}
.copilot-name-card {
  width: min(420px, 100%);
  border: 1px solid var(--cp-border-2);
  border-radius: 12px;
  background: var(--cp-surface);
  padding: 28px;
}
.copilot-name-card h2 {
  margin: 16px 0 6px;
  color: var(--cp-text);
  font-size: 22px;
  font-weight: 750;
}
.copilot-name-card p {
  margin: 0 0 20px;
  color: var(--cp-text-3);
  font-size: 14px;
  line-height: 1.6;
}
.copilot-name-card label {
  display: grid;
  gap: 8px;
  color: var(--cp-text-2);
  font-size: 13px;
  font-weight: 650;
}
.copilot-name-card input,
.copilot-doc-editor textarea {
  width: 100%;
  border: 1px solid var(--cp-border-2);
  border-radius: 8px;
  background: var(--cp-surface);
  color: var(--cp-text);
  outline: none;
}
.copilot-name-card input {
  height: 42px;
  padding: 0 12px;
}
.copilot-name-card input:focus,
.copilot-doc-editor textarea:focus {
  border-color: var(--cp-accent);
}
html[data-theme='dark'] .copilot-name-card input:focus,
html[data-theme='dark'] .copilot-doc-editor textarea:focus {
  border-color: var(--cp-primary);
}
.copilot-name-card button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  width: 100%;
  height: 42px;
  margin-top: 18px;
  border-radius: 8px;
  background: var(--cp-accent);
  color: #fff;
  font-weight: 700;
}
html[data-theme='dark'] .copilot-name-card button {
  background: var(--cp-primary);
}

/* Memory modal */
.copilot-memory-modal {
  width: min(820px, calc(100vw - 28px));
}
.copilot-doc-tabs {
  display: flex;
  gap: 6px;
  border-bottom: 1px solid var(--cp-border-2);
  padding: 0 16px 10px;
}
.copilot-doc-tab {
  border: 1px solid var(--cp-border-2);
  border-radius: 8px;
  padding: 7px 10px;
  background: var(--cp-surface);
  color: var(--cp-text-3);
  font-size: 12px;
  font-weight: 700;
}
.copilot-doc-tab.is-active {
  background: var(--cp-accent);
  color: #fff;
  border-color: var(--cp-accent);
}
html[data-theme='dark'] .copilot-doc-tab.is-active {
  background: var(--cp-primary);
  border-color: var(--cp-primary);
}
.copilot-doc-editor {
  display: none;
  padding: 16px;
  gap: 8px;
}
.copilot-doc-editor.is-active {
  display: grid;
}
.copilot-doc-editor span {
  color: var(--cp-text-3);
  font-size: 12px;
  font-weight: 700;
}
.copilot-doc-editor textarea {
  min-height: 360px;
  padding: 12px;
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  font-size: 13px;
  line-height: 1.55;
  resize: vertical;
}

/* Memory suggestions */
.pilot-memory-suggestions {
  margin-top: 14px;
  border-top: 1px solid var(--cp-border-2);
  padding-top: 12px;
}
.pilot-memory-title {
  margin-bottom: 8px;
  color: var(--cp-text-2);
  font-size: 12px;
  font-weight: 800;
}
.pilot-memory-suggestion {
  border: 1px solid var(--cp-border-2);
  border-radius: 8px;
  background: var(--cp-surface-2);
  padding: 10px;
}
.pilot-memory-suggestion + .pilot-memory-suggestion {
  margin-top: 8px;
}
.pilot-memory-head {
  display: flex;
  gap: 8px;
  align-items: baseline;
  justify-content: space-between;
  color: var(--cp-text);
  font-size: 12px;
  font-weight: 800;
}
.pilot-memory-reason {
  color: var(--cp-text-3);
  font-weight: 500;
}
.pilot-memory-suggestion pre {
  margin: 8px 0;
  white-space: pre-wrap;
  word-break: break-word;
  color: var(--cp-text-2);
  font-size: 12px;
}
.pilot-memory-actions {
  display: flex;
  gap: 8px;
}
.pilot-memory-actions button {
  border: 1px solid var(--cp-border-2);
  border-radius: 8px;
  background: var(--cp-surface);
  color: var(--cp-text);
  padding: 6px 10px;
  font-size: 12px;
  font-weight: 700;
}
.pilot-memory-actions button:first-child {
  background: var(--cp-accent);
  color: #fff;
  border-color: var(--cp-accent);
}
html[data-theme='dark'] .pilot-memory-actions button:first-child {
  background: var(--cp-primary);
  border-color: var(--cp-primary);
}

/* Copilot quick prompts */
.copilot-quick-row {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-bottom: 8px;
}
.copilot-quick-btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  border: 1px solid var(--cp-border-2);
  background: var(--cp-surface);
  color: var(--cp-text-2);
  border-radius: 999px;
  padding: 4px 10px;
  font-size: 11.5px;
  font-weight: 650;
  cursor: pointer;
}
.copilot-quick-btn:hover {
  background: var(--cp-surface-2);
  color: var(--cp-text);
}

/* Copilot action cards */
.pilot-action-cards {
  margin-top: 12px;
  border-top: 1px solid var(--cp-border-2);
  padding-top: 12px;
}
.pilot-action-cards-title {
  margin-bottom: 8px;
  color: var(--cp-text-2);
  font-size: 12px;
  font-weight: 800;
}
.pilot-action-card {
  border: 1px solid var(--cp-border-2);
  border-radius: 10px;
  background: var(--cp-surface-2);
  padding: 10px 12px;
}
.pilot-action-card + .pilot-action-card {
  margin-top: 8px;
}
.pilot-action-card.is-resolved {
  opacity: 0.65;
}
.pilot-action-head {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
}
.pilot-action-type {
  font-size: 11px;
  font-weight: 700;
  color: var(--cp-text-3);
  background: var(--cp-surface);
  border: 1px solid var(--cp-border-2);
  border-radius: 999px;
  padding: 2px 8px;
}
.pilot-action-title {
  font-size: 13px;
  font-weight: 700;
  color: var(--cp-text);
  flex: 1;
  min-width: 0;
}
.pilot-action-status {
  font-size: 11px;
  font-weight: 700;
  padding: 2px 8px;
  border-radius: 999px;
}
.pilot-action-status--applied {
  background: #e6f9ed;
  color: #047857;
}
.pilot-action-status--dismissed {
  background: #f3f4f6;
  color: #6b7280;
}
html[data-theme='dark'] .pilot-action-status--applied {
  background: rgba(16,185,129,0.18);
  color: #6ee7b7;
}
html[data-theme='dark'] .pilot-action-status--dismissed {
  background: rgba(255,255,255,0.06);
  color: #d4d4d4;
}
.pilot-action-summary {
  margin-top: 6px;
  font-size: 12.5px;
  color: var(--cp-text-2);
  line-height: 1.5;
}
.pilot-action-details {
  margin-top: 6px;
  font-size: 12px;
  color: var(--cp-text-3);
  display: flex;
  flex-direction: column;
  gap: 2px;
}
.pilot-action-list {
  margin-top: 6px;
  padding-left: 16px;
  font-size: 12px;
  color: var(--cp-text-2);
  list-style: disc;
}
.pilot-action-list li small {
  color: var(--cp-text-3);
  margin-left: 6px;
}
.pilot-action-more {
  list-style: none;
  margin-left: -8px;
  font-style: italic;
  color: var(--cp-text-3);
}
.pilot-action-buttons {
  margin-top: 10px;
  display: flex;
  gap: 8px;
}
.pilot-action-buttons button {
  border: 1px solid var(--cp-border-2);
  border-radius: 8px;
  background: var(--cp-surface);
  color: var(--cp-text);
  padding: 6px 12px;
  font-size: 12px;
  font-weight: 700;
  cursor: pointer;
}
.pilot-action-confirm {
  background: var(--cp-accent, #171717);
  color: #fff;
  border-color: var(--cp-accent, #171717);
}
html[data-theme='dark'] .pilot-action-confirm {
  background: #f5f5f5;
  color: #111827;
  border-color: #f5f5f5;
}
.pilot-action-ignore:hover {
  background: var(--cp-surface-2);
}

/* Settings drawer */
.agent-settings-drawer {
  background: var(--cp-surface);
  border-left-color: var(--cp-border);
}
.agent-settings-head {
  border-bottom-color: var(--cp-border);
}
.agent-settings-title {
  color: var(--cp-text);
}
.agent-settings-desc,
.agent-settings-hint {
  color: var(--cp-text-muted);
}
.agent-settings-label {
  color: var(--cp-text-3);
}
.agent-settings-input {
  background: var(--cp-surface);
  border-color: var(--cp-border-2);
  color: var(--cp-text);
}
.agent-settings-input:focus {
  border-color: var(--cp-primary);
  box-shadow: 0 0 0 3px rgba(115, 115, 115,0.12);
}
html[data-theme='dark'] .agent-settings-input:focus {
  box-shadow: 0 0 0 3px rgba(115, 115, 115,0.2);
}
.agent-settings-btn {
  background: var(--cp-surface);
  border-color: var(--cp-border-2);
  color: var(--cp-text);
}
.agent-settings-btn:hover {
  background: var(--cp-surface-2);
}
.agent-settings-btn--primary {
  background: var(--cp-accent);
  color: #fff;
  border-color: var(--cp-accent);
}
.agent-settings-btn--primary:hover {
  background: var(--cp-accent-hover);
}
html[data-theme='dark'] .agent-settings-btn--primary {
  background: var(--cp-primary);
  border-color: var(--cp-primary);
}
html[data-theme='dark'] .agent-settings-btn--primary:hover {
  background: var(--cp-primary-hover);
}

/* Modal overlay */
.agent-modal-overlay {
  background: rgba(15,23,42,0.45);
}
.agent-modal {
  background: var(--cp-surface);
  border-color: var(--cp-border-2);
}
.agent-modal-head {
  color: var(--cp-text);
  border-bottom-color: var(--cp-border);
}
.agent-modal-desc {
  color: var(--cp-text-muted);
}
.agent-modal-actions {
  border-top-color: var(--cp-border);
  background: var(--cp-surface-2);
}
.agent-modal-list-item {
  color: var(--cp-text);
}
.agent-modal-list-item:hover {
  background: var(--cp-surface-2);
}
.agent-modal-list-item.is-active {
  background: var(--cp-accent);
  color: #fff;
}
html[data-theme='dark'] .agent-modal-list-item.is-active {
  background: var(--cp-primary);
}
.agent-modal-tag {
  background: var(--cp-surface-2);
  color: var(--cp-text-3);
}
.agent-modal-empty {
  color: var(--cp-text-muted);
}

/* Assistant cards */
.agent-assistant-card {
  background: var(--cp-surface);
  border: 1px solid var(--cp-border);
  border-radius: 10px;
}
.agent-assistant-card:hover {
  background: var(--cp-surface-2);
}
.agent-assistant-card.is-active {
  background: var(--cp-surface-2);
  border-color: var(--cp-primary);
}
.agent-assistant-card-title {
  color: var(--cp-text);
}
.agent-assistant-card-meta {
  color: var(--cp-text-muted);
}
.agent-assistant-card-edit:hover {
  background: var(--cp-surface-2);
  color: var(--cp-text);
}

/* Attachment & suggestion chips */
.agent-suggestion-chip,
.agent-attachment-chip {
  background: var(--cp-surface);
  border: 1px solid var(--cp-border-2);
  color: var(--cp-text-2);
}
.agent-hello-card .agent-suggestion-chip {
  background: rgba(255,255,255,0.72);
  border-color: var(--cp-border);
}
html[data-theme='dark'] .agent-hello-card .agent-suggestion-chip {
  background: rgba(255,255,255,0.04);
  border-color: var(--cp-border-2);
}

/* Remove aggressive shadows globally for flat look */
.workbench-card,
.flat-card,
.list-section,
.detail-panel,
.calendar-cell {
  box-shadow: none;
}

/* Responsive */
@media (max-width: 760px) {
  .agent-page {
    grid-template-columns: minmax(0, 1fr);
  }
  .agent-sidebar {
    display: none;
  }
}

/* ============================================================
   Model vendor marks — restored after polish-v2 block deletion.
   Constrains the vendor avatar SVG to 22×22 (or 18×18 for --sm)
   with brand color background; without this the inline SVG
   blows up to its container's max width.
   ============================================================ */
.model-vendor-mark {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 22px;
  height: 22px;
  border-radius: 6px;
  color: #fff;
  flex-shrink: 0;
  line-height: 1;
  overflow: hidden;
}
.model-vendor-mark svg {
  width: 14px;
  height: 14px;
  display: block;
}
.model-vendor-mark--sm {
  width: 18px;
  height: 18px;
  border-radius: 5px;
}
.model-vendor-mark--sm svg {
  width: 12px;
  height: 12px;
}
/* Inline SVG mode — colored brand bg + white glyph */
.model-vendor-mark--deepseek  { background: #4D6BFE; }
.model-vendor-mark--anthropic { background: #D97757; }
.model-vendor-mark--openai    { background: #0F1115; }
.model-vendor-mark--google    { background: #1A73E8; }
.model-vendor-mark--moonshot  { background: #1F1F1F; }
.model-vendor-mark--generic   { background: #525252; }

/* PNG logo mode — render the actual brand image on a neutral white
   badge so the logo's own colors aren't washed out by a same-hue bg
   (e.g. blue DeepSeek whale on blue #4D6BFE badge would disappear). */
.model-vendor-mark--logo {
  background: #ffffff !important;
  border: 1px solid #e5e5e5;
}
.model-vendor-mark--logo img {
  width: 100%;
  height: 100%;
  object-fit: contain;
  padding: 2px;
  display: block;
}
html[data-theme='dark'] .model-vendor-mark--logo {
  background: #f5f5f5 !important;
  border-color: rgba(0,0,0,0.05);
}

/* When used as the AI message avatar, force 28×28 to match the
   meta row text height instead of the default 22×22. */
.agent-message-list .pilot-message-avatar.model-vendor-mark {
  width: 28px;
  height: 28px;
  border-radius: 8px;
  overflow: hidden;
}
.agent-message-list .pilot-message-avatar.model-vendor-mark svg {
  width: 16px;
  height: 16px;
}

/* ============================================================
   Sidebar layout fundamentals — restored after polish-v2 delete.
   Brand row, memory entry, topic items: flex containers + icon
   size caps. Without these the brand icon balloons full width
   and topic items stack icon-above-text.
   ============================================================ */

/* Brand row at top of sidebar — icon left, name+subtitle stacked right */
.agent-sidebar-brand {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 14px 12px 10px;
}
.agent-sidebar-brand-icon {
  width: 32px;
  height: 32px;
  border-radius: 8px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  background: var(--cp-surface);
  border: 1px solid var(--cp-border-2);
  color: var(--cp-text);
}
.agent-sidebar-brand-icon svg,
.agent-sidebar-brand-icon i {
  width: 16px !important;
  height: 16px !important;
}
.agent-sidebar-brand-title {
  font-size: 14px;
  font-weight: 700;
  color: var(--cp-text);
  line-height: 1.2;
}
.agent-sidebar-brand-subtitle {
  font-size: 12px;
  color: var(--cp-text-muted);
  line-height: 1.2;
  margin-top: 2px;
}

/* "Copilot 记忆" entry — full-width flex row, icon left + label */
.agent-memory-entry {
  display: flex;
  align-items: center;
  gap: 8px;
  width: 100%;
  padding: 8px 12px;
  margin: 0 0 6px;
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
}
.agent-memory-entry svg,
.agent-memory-entry i {
  width: 16px !important;
  height: 16px !important;
  flex-shrink: 0;
}

/* "新建话题" full-width button */
.agent-new-chat {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  width: 100%;
  padding: 10px 12px;
  margin: 0 0 8px;
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
}
.agent-new-chat svg,
.agent-new-chat i {
  width: 16px !important;
  height: 16px !important;
}

/* Topic list items — flex row: icon column + body + del button */
.agent-topic-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 10px;
  margin: 2px 0;
  cursor: pointer;
}
.agent-topic-item-icon {
  width: 28px;
  height: 28px;
  border-radius: 6px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}
.agent-topic-item-icon svg,
.agent-topic-item-icon i {
  width: 14px !important;
  height: 14px !important;
}
.agent-topic-item-body {
  flex: 1;
  min-width: 0;
}
.agent-topic-item-title {
  font-size: 13px;
  font-weight: 600;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.agent-topic-item-meta {
  font-size: 11px;
  color: var(--cp-text-muted);
  margin-top: 2px;
}
.agent-topic-item-del {
  width: 24px;
  height: 24px;
  border-radius: 6px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  color: var(--cp-text-muted);
  background: transparent;
  border: none;
  cursor: pointer;
  opacity: 0;
  transition: opacity 0.12s ease, background 0.12s ease, color 0.12s ease;
}
.agent-topic-item:hover .agent-topic-item-del,
.agent-topic-item.is-active .agent-topic-item-del {
  opacity: 1;
}

/* "当前上下文" section under topic list */
.agent-sidebar-section {
  padding: 10px 12px 0;
}
.agent-sidebar-section-title {
  font-size: 11px;
  font-weight: 600;
  color: var(--cp-text-muted);
  text-transform: none;
  letter-spacing: 0.02em;
  margin-bottom: 6px;
}
.agent-context-chips {
  display: flex;
  flex-direction: column;
  gap: 6px;
}
.agent-chat-chip {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 6px 10px;
  border-radius: 6px;
  font-size: 12px;
}
.agent-chat-chip-label {
  font-size: 11px;
}

/* ============================================================
   Composer stop button — restored size + send/stop visibility swap.
   The bg-color-only rule alone left the button as a tiny icon with
   no width/height. Now it's a proper 34×34 red circle and only
   shows when .agent-composer.is-streaming is set.
   ============================================================ */
.agent-composer-stop-circle {
  display: none;
  width: 34px;
  height: 34px;
  border-radius: 50%;
  background: #ef4444;
  color: #fff;
  border: none;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: background 0.15s ease, transform 0.12s ease;
}
.agent-composer-stop-circle:hover {
  background: #dc2626;
  transform: scale(1.06);
}
.agent-composer-stop-circle:active { transform: scale(0.94); }
.agent-composer-stop-circle svg,
.agent-composer-stop-circle i {
  width: 14px !important;
  height: 14px !important;
}
/* When the composer is streaming, hide send and show stop */
.agent-composer.is-streaming .agent-composer-send-circle { display: none; }
.agent-composer.is-streaming .agent-composer-stop-circle { display: inline-flex; }

/* Thinking-level chip ("详细")
   Light: 黑底白字（中性）
   Dark : 紫底白字（与暗模式黑紫主基调一致） */
.agent-tool-thinking.is-active .agent-tool-tag {
  background: var(--cp-text) !important;
  color: #fff !important;
}
html[data-theme='dark'] .agent-tool-tag {
  background: rgba(99,102,241,0.18) !important;
  color: #c7c8fc !important;
}
html[data-theme='dark'] .agent-tool-thinking.is-active .agent-tool-tag {
  background: #6366f1 !important;
  color: #fff !important;
}

/* ============================================================
 * Phase 5 — Global visual降噪 / 黑白灰统一 (ima-style)
 * Overrides only. 旧色保留作兼容，这里把高曝光视觉收敛为中性。
 * ============================================================ */
:root {
  --ui-bg: #f5f5f5;
  --ui-surface: #ffffff;
  --ui-surface-soft: #f8f8f8;
  --ui-border: #e5e5e5;
  --ui-border-strong: #d4d4d4;
  --ui-text: #171717;
  --ui-muted: #737373;
  --ui-weak: #a3a3a3;
  --ui-primary: #171717;
  --ui-primary-hover: #262626;
}
html[data-theme='dark'] {
  --ui-bg: #0f1016;
  --ui-surface: #181a22;
  --ui-surface-soft: rgba(255,255,255,0.04);
  --ui-border: rgba(255,255,255,0.08);
  --ui-border-strong: rgba(255,255,255,0.16);
  --ui-text: #f3f4f6;
  --ui-muted: #a3a3a3;
  --ui-weak: #6b7280;
  --ui-primary: #f3f4f6;
  --ui-primary-hover: #ffffff;
}

/* ---- Rail tooltip: 调成中性深灰 ---- */
.rail-btn::after {
  background: #171717 !important;
  color: #fff !important;
  box-shadow: 0 4px 12px rgba(0,0,0,0.18) !important;
}
.rail-btn::before {
  border-right-color: #171717 !important;
}
.rail-btn--collapse:hover {
  background: rgba(0,0,0,0.05) !important;
  color: #171717 !important;
}
html[data-theme='dark'] .rail-btn--collapse:hover {
  background: rgba(255,255,255,0.06) !important;
  color: #f3f4f6 !important;
}

/* ---- 顶部主按钮 hover transform 去掉 ---- */
.flat-btn:hover {
  transform: none !important;
  box-shadow: none !important;
  border-color: var(--ui-border-strong) !important;
  background: #f7f7f7 !important;
}
html[data-theme='dark'] .flat-btn:hover {
  background: rgba(255,255,255,0.06) !important;
  border-color: rgba(255,255,255,0.14) !important;
  box-shadow: none !important;
}

/* ---- 语言菜单 hover/active 改成黑灰 ---- */
.lang-option:hover {
  background: #f4f4f5 !important;
  color: #171717 !important;
}
.lang-option.active {
  background: #f4f4f5 !important;
  color: #171717 !important;
}
html[data-theme='dark'] .lang-option:hover,
html[data-theme='dark'] .lang-option.active {
  background: rgba(255,255,255,0.06) !important;
  color: #f3f4f6 !important;
}

/* ---- userMenuDropdown hover ---- */
#userMenuAiSettingsBtn:hover {
  background: #f4f4f5 !important;
  color: #171717 !important;
}

/* ---- 主要表单输入 focus 颜色 ---- */
input.flat-input:focus,
input[type="text"]:focus,
input[type="email"]:focus,
input[type="number"]:focus,
input[type="password"]:focus,
input[type="url"]:focus,
input[type="date"]:focus,
textarea:focus,
select:focus {
  outline: none;
  border-color: #171717 !important;
  box-shadow: 0 0 0 3px rgba(23,23,23,0.06) !important;
}
html[data-theme='dark'] input.flat-input:focus,
html[data-theme='dark'] input[type="text"]:focus,
html[data-theme='dark'] input[type="email"]:focus,
html[data-theme='dark'] input[type="number"]:focus,
html[data-theme='dark'] input[type="password"]:focus,
html[data-theme='dark'] input[type="url"]:focus,
html[data-theme='dark'] input[type="date"]:focus,
html[data-theme='dark'] textarea:focus,
html[data-theme='dark'] select:focus {
  border-color: rgba(255,255,255,0.4) !important;
  box-shadow: 0 0 0 3px rgba(255,255,255,0.08) !important;
}

/* ---- custom-select trigger 收敛颜色 ---- */
.custom-select-trigger:hover {
  border-color: var(--ui-border-strong) !important;
  box-shadow: 0 0 0 3px rgba(23,23,23,0.04) !important;
}
.custom-select-trigger--open {
  border-color: #171717 !important;
  box-shadow: 0 0 0 3px rgba(23,23,23,0.08) !important;
}
.custom-select-option:hover {
  background-color: #f4f4f5 !important;
}
.custom-select-option--selected {
  color: #171717 !important;
}
.custom-select-option--selected::before {
  background: #171717 !important;
}
html[data-theme='dark'] .custom-select-trigger:hover {
  border-color: rgba(255,255,255,0.25) !important;
  box-shadow: 0 0 0 3px rgba(255,255,255,0.06) !important;
}
html[data-theme='dark'] .custom-select-trigger--open {
  border-color: rgba(255,255,255,0.4) !important;
  box-shadow: 0 0 0 3px rgba(255,255,255,0.1) !important;
}
html[data-theme='dark'] .custom-select-option:hover {
  background-color: rgba(255,255,255,0.06) !important;
}
html[data-theme='dark'] .custom-select-option--selected {
  color: #f3f4f6 !important;
}

/* ---- 日历今日 / 选中 / 范围: 改为黑灰 ---- */
.calendar-date.is-today {
  border-color: #171717 !important;
  box-shadow: none !important;
}
.calendar-date.is-today .calendar-date-num {
  background: #171717 !important;
  color: #fff !important;
  box-shadow: none !important;
}
.calendar-date.is-active {
  border-color: #171717 !important;
  background: rgba(23,23,23,0.04) !important;
  box-shadow: none !important;
}
.calendar-date.is-in-range {
  background: rgba(23,23,23,0.02) !important;
  border-color: rgba(23,23,23,0.10) !important;
}
.calendar-date:hover {
  transform: none !important;
  box-shadow: none !important;
  border-color: var(--ui-border-strong) !important;
  background: #fafafa !important;
}
html[data-theme='dark'] .calendar-date.is-today {
  border-color: #f3f4f6 !important;
  box-shadow: none !important;
}
html[data-theme='dark'] .calendar-date.is-today .calendar-date-num {
  background: #f3f4f6 !important;
  color: #111827 !important;
  box-shadow: none !important;
}
html[data-theme='dark'] .calendar-date.is-active {
  background: rgba(255,255,255,0.06) !important;
  border-color: rgba(255,255,255,0.3) !important;
  box-shadow: none !important;
}
html[data-theme='dark'] .calendar-date.is-in-range {
  background: rgba(255,255,255,0.03) !important;
  border-color: rgba(255,255,255,0.1) !important;
}
html[data-theme='dark'] .calendar-date:hover {
  transform: none !important;
  box-shadow: none !important;
  background: rgba(255,255,255,0.04) !important;
  border-color: rgba(255,255,255,0.18) !important;
}

/* ---- Today dashboard: 去掉紫色 accent ---- */
.dash-section-title::before {
  background: #171717 !important;
}
.dash-recommended-card::before {
  background: #171717 !important;
}
.dash-rec-badge {
  background: #f4f4f5 !important;
  color: #171717 !important;
}
.dash-stat-card:hover {
  border-color: var(--ui-border-strong) !important;
  box-shadow: none !important;
}
html[data-theme='dark'] .dash-section-title::before {
  background: #f3f4f6 !important;
}
html[data-theme='dark'] .dash-recommended-card::before {
  background: #f3f4f6 !important;
}
html[data-theme='dark'] .dash-rec-badge {
  background: rgba(255,255,255,0.08) !important;
  color: #f3f4f6 !important;
}

/* ---- study-row 选中态: 黑色细边 ---- */
.study-row--selected {
  box-shadow: inset 3px 0 0 0 #171717 !important;
  background: #fafafa !important;
}
html[data-theme='dark'] .study-row--selected {
  background: rgba(255,255,255,0.04) !important;
  box-shadow: inset 3px 0 0 0 #f3f4f6 !important;
}

/* ---- 通用 brand 类 (Tailwind brand-50/100/600) 中和 ---- */
.bg-brand-50, .bg-brand-50\/80, .bg-brand-50\/60 {
  background-color: #f4f4f5 !important;
}
.bg-brand-100 {
  background-color: #ededee !important;
}
.bg-brand-500, .bg-brand-600 {
  background-color: #171717 !important;
}
.text-brand-500, .text-brand-600, .text-brand-700 {
  color: #171717 !important;
}
.text-brand-400 {
  color: #525252 !important;
}
.border-brand-200, .border-brand-300, .border-brand-500 {
  border-color: var(--ui-border-strong) !important;
}
.ring-brand-500, .ring-brand-400 {
  --tw-ring-color: #171717 !important;
}
.hover\:bg-brand-50:hover {
  background-color: #f4f4f5 !important;
}
.hover\:bg-brand-100:hover {
  background-color: #ededee !important;
}
.hover\:text-brand-600:hover {
  color: #171717 !important;
}
.hover\:file\:bg-brand-100:hover::file-selector-button,
.file\:bg-brand-50::file-selector-button {
  background-color: #f4f4f5 !important;
  color: #171717 !important;
}
.from-brand-50 {
  --tw-gradient-from: #f4f4f5 !important;
}
.to-ink-50 {
  --tw-gradient-to: #f5f5f5 !important;
}
html[data-theme='dark'] .bg-brand-50,
html[data-theme='dark'] .bg-brand-50\/80,
html[data-theme='dark'] .bg-brand-50\/60 {
  background-color: rgba(255,255,255,0.06) !important;
}
html[data-theme='dark'] .text-brand-500,
html[data-theme='dark'] .text-brand-600,
html[data-theme='dark'] .text-brand-700 {
  color: #f3f4f6 !important;
}
html[data-theme='dark'] .text-brand-400 {
  color: #a3a3a3 !important;
}

/* ---- focus:border-brand-500 (input/textarea) 收敛 ---- */
.focus\:border-brand-500:focus,
.focus\:border-brand-400:focus {
  border-color: #171717 !important;
}
html[data-theme='dark'] .focus\:border-brand-500:focus,
html[data-theme='dark'] .focus\:border-brand-400:focus {
  border-color: rgba(255,255,255,0.4) !important;
}

/* ---- agent-tool-btn 激活/tag 颜色 ---- */
.agent-tool-btn.is-active {
  color: #171717 !important;
  background: #ededee !important;
}
.agent-tool-tag {
  background: #ededee !important;
  color: #404040 !important;
}
.agent-tool-thinking.is-active .agent-tool-tag {
  background: #171717 !important;
  color: #fff !important;
}
html[data-theme='dark'] .agent-tool-btn.is-active {
  background: rgba(255,255,255,0.10) !important;
  color: #f3f4f6 !important;
}
html[data-theme='dark'] .agent-tool-tag {
  background: rgba(255,255,255,0.08) !important;
  color: #d4d4d4 !important;
}
html[data-theme='dark'] .agent-tool-thinking.is-active .agent-tool-tag {
  background: #f3f4f6 !important;
  color: #111827 !important;
}

/* ---- agent assistant card icon: 默认彩色渐变 → 中性 ---- */
.agent-assistant-card-icon {
  background: #171717 !important;
}
html[data-theme='dark'] .agent-assistant-card-icon {
  background: #f3f4f6 !important;
  color: #111827 !important;
}

/* ---- agent-head-badge 颜色 ---- */
.agent-head-badge-tag {
  background: #171717 !important;
  color: #fff !important;
}
html[data-theme='dark'] .agent-head-badge-tag {
  background: #f3f4f6 !important;
  color: #111827 !important;
}

/* ---- 用户气泡: 不要紫色 (仅作用于非 agent flow 的 legacy 浮窗) ---- */
body:not([data-area="agent"]) .pilot-message--user .pilot-bubble {
  background: #171717 !important;
  color: #fff !important;
}
html[data-theme='dark'] body:not([data-area="agent"]) .pilot-message--user .pilot-bubble {
  background: rgba(255,255,255,0.12) !important;
  color: #f3f4f6 !important;
}

/* ---- agent-composer-input focus 颜色 ---- */
.agent-composer-input:focus {
  box-shadow: 0 0 0 3px rgba(23,23,23,0.06) !important;
  border-color: #d4d4d4 !important;
}
html[data-theme='dark'] .agent-composer-input {
  background: rgba(255,255,255,0.04) !important;
  border-color: rgba(255,255,255,0.10) !important;
  color: #f3f4f6 !important;
}
html[data-theme='dark'] .agent-composer-input:focus {
  border-color: rgba(255,255,255,0.3) !important;
  box-shadow: 0 0 0 3px rgba(255,255,255,0.06) !important;
}

/* ---- pilot-input legacy ---- */
.pilot-input:focus {
  border-color: #171717 !important;
}

/* ---- agent session/topic active ---- */
html[data-theme='dark'] .agent-session--active {
  background: rgba(255,255,255,0.06) !important;
  border-color: rgba(255,255,255,0.12) !important;
}
html[data-theme='dark'] .agent-session--active .agent-session-icon {
  background: #f3f4f6 !important;
  color: #111827 !important;
}
html[data-theme='dark'] .agent-session:hover {
  background: rgba(255,255,255,0.04) !important;
}
html[data-theme='dark'] .agent-chat-head-title {
  color: #f3f4f6 !important;
}
html[data-theme='dark'] .agent-chat-head-icon {
  background: #f3f4f6 !important;
  color: #111827 !important;
}
html[data-theme='dark'] .agent-chat-chip {
  background: rgba(255,255,255,0.04) !important;
  border-color: rgba(255,255,255,0.10) !important;
}
html[data-theme='dark'] .agent-chat-chip--accent {
  background: rgba(255,255,255,0.08) !important;
  border-color: rgba(255,255,255,0.18) !important;
}
html[data-theme='dark'] .agent-chat-chip--accent .agent-chat-chip-value {
  color: #f3f4f6 !important;
}
html[data-theme='dark'] .agent-chat-empty-icon {
  background: rgba(255,255,255,0.04) !important;
  border-color: rgba(255,255,255,0.10) !important;
}
html[data-theme='dark'] .agent-composer-send-circle {
  background: #f3f4f6 !important;
  color: #111827 !important;
}
html[data-theme='dark'] .agent-composer-send-circle:hover {
  background: #ffffff !important;
  box-shadow: 0 4px 14px rgba(0,0,0,0.35) !important;
}

/* ---- agent topic item icon active: 用中性深灰 ---- */
html[data-theme='dark'] .agent-topic-item-icon {
  background: rgba(255,255,255,0.06) !important;
  border-color: rgba(255,255,255,0.10) !important;
  color: #d4d4d4 !important;
}
html[data-theme='dark'] .agent-topic-item.is-active .agent-topic-item-icon {
  background: #f3f4f6 !important;
  color: #111827 !important;
  border-color: #f3f4f6 !important;
}

/* ---- assistant card 激活态 / hover dark ---- */
html[data-theme='dark'] .agent-assistant-card {
  background: rgba(255,255,255,0.04) !important;
  border-color: rgba(255,255,255,0.10) !important;
}
html[data-theme='dark'] .agent-assistant-card.is-active {
  background: rgba(255,255,255,0.07) !important;
  border-color: rgba(255,255,255,0.25) !important;
}
html[data-theme='dark'] .agent-assistant-card-edit:hover {
  background: rgba(255,255,255,0.08) !important;
  color: #f3f4f6 !important;
}

/* ---- head badge / head arrow ---- */
html[data-theme='dark'] .agent-head-badge {
  background: rgba(255,255,255,0.04) !important;
  border-color: rgba(255,255,255,0.10) !important;
  color: #f3f4f6 !important;
}
html[data-theme='dark'] .agent-head-badge--assistant:hover,
html[data-theme='dark'] .agent-head-badge--model:hover {
  background: rgba(255,255,255,0.08) !important;
}
html[data-theme='dark'] .agent-head-arrow {
  color: #9ca3af !important;
}

/* ---- agent_chat_chip 标签的语言切换组 hover ---- */
html[data-theme='dark'] .agent-tool-btn:hover {
  background: rgba(255,255,255,0.06) !important;
  color: #f3f4f6 !important;
}
html[data-theme='dark'] .agent-tool-sep {
  background: rgba(255,255,255,0.10) !important;
}
html[data-theme='dark'] .agent-head-icon-btn:hover {
  background: rgba(255,255,255,0.06) !important;
  color: #f3f4f6 !important;
}
html[data-theme='dark'] .agent-head-icon-btn.is-active {
  background: #f3f4f6 !important;
  color: #111827 !important;
}

/* ---- agent topic ---- */
html[data-theme='dark'] .agent-topic-item.is-active {
  background: rgba(255,255,255,0.06) !important;
  border-color: rgba(255,255,255,0.10) !important;
}

/* ---- pilot 内引用色 / 进度色 ---- */
.pilot-citation-link,
.pilot-citation-tag,
.pilot-mem-link {
  color: #171717 !important;
}
html[data-theme='dark'] .pilot-citation-link,
html[data-theme='dark'] .pilot-citation-tag,
html[data-theme='dark'] .pilot-mem-link {
  color: #f3f4f6 !important;
}

/* ---- 番茄钟 ring 渐变保留橙色; 但避免紫色发光 ---- */

/* ---- 知识图谱 legend / progress 三色渐变改单色 ---- */
.pilot-progress-bar {
  background: linear-gradient(90deg, #171717, #525252, #a3a3a3) !important;
}

/* ---- 详情栏头部图标圆角化、中性化 ---- */
aside .bg-gradient-to-br.from-brand-50 {
  background: #f4f4f5 !important;
}
aside .text-brand-500 {
  color: #171717 !important;
}
html[data-theme='dark'] aside .bg-gradient-to-br.from-brand-50 {
  background: rgba(255,255,255,0.06) !important;
}
html[data-theme='dark'] aside .text-brand-500 {
  color: #f3f4f6 !important;
}

/* ---- copilot 快捷按钮统一: 收敛 hover 边框 ---- */
.copilot-quick-btn {
  background: #ffffff !important;
  border: 1px solid var(--ui-border) !important;
  color: #404040 !important;
}
.copilot-quick-btn:hover {
  background: #f7f7f7 !important;
  border-color: var(--ui-border-strong) !important;
  color: #171717 !important;
}
html[data-theme='dark'] .copilot-quick-btn {
  background: rgba(255,255,255,0.04) !important;
  border-color: rgba(255,255,255,0.10) !important;
  color: #d4d4d4 !important;
}
html[data-theme='dark'] .copilot-quick-btn:hover {
  background: rgba(255,255,255,0.08) !important;
  border-color: rgba(255,255,255,0.18) !important;
  color: #f3f4f6 !important;
}

/* ---- pilot action card 按钮统一 ---- */
.pilot-action-card {
  background: #ffffff !important;
  border-color: var(--ui-border) !important;
}
.pilot-action-type {
  background: #f4f4f5 !important;
  color: #404040 !important;
}
.pilot-action-status.is-applied {
  background: #ecfdf5 !important;
  color: #047857 !important;
}
.pilot-action-status.is-dismissed {
  background: #f4f4f5 !important;
  color: #737373 !important;
}
html[data-theme='dark'] .pilot-action-card {
  background: rgba(255,255,255,0.04) !important;
  border-color: rgba(255,255,255,0.10) !important;
}
html[data-theme='dark'] .pilot-action-type {
  background: rgba(255,255,255,0.08) !important;
  color: #d4d4d4 !important;
}

/* ---- toast: 中性深色 ---- */
.toast-widget {
  background: #171717 !important;
  color: #fff !important;
  box-shadow: 0 8px 24px rgba(0,0,0,0.25) !important;
}

/* ---- 模态背景: 不要紫 ---- */
.modal-backdrop {
  background: rgba(15,16,22,0.45) !important;
}
html[data-theme='dark'] .modal-backdrop {
  background: rgba(0,0,0,0.6) !important;
}

/* ---- 卡片 hover 收敛 ---- */
.flat-card:hover {
  border-color: var(--ui-border-strong) !important;
  box-shadow: none !important;
}
html[data-theme='dark'] .flat-card:hover {
  border-color: rgba(255,255,255,0.14) !important;
  box-shadow: none !important;
}

/* ---- 主体页脚: ring-ink-900 改不要紫 ---- */
.ring-ink-900 {
  --tw-ring-color: #171717 !important;
}
html[data-theme='dark'] .ring-ink-900 {
  --tw-ring-color: rgba(255,255,255,0.6) !important;
}

/* ---- 横向滚动条防御 ---- */
html, body {
  overflow-x: hidden;
}

/* ============================================================
 * 侧栏账户菜单 (fixed positioned, 不受 rail overflow 裁切)
 * ============================================================ */
.sidebar-account-wrap {
  width: 100%;
  display: flex;
  justify-content: center;
}
.sidebar-account-menu {
  position: fixed;
  z-index: 200;
  min-width: 208px;
  padding: 6px;
  background: #ffffff;
  border: 1px solid var(--ui-border, #e5e5e5);
  border-radius: 14px;
  box-shadow: 0 12px 32px rgba(16,24,40,0.12), 0 2px 8px rgba(16,24,40,0.06);
}
.sidebar-account-menu.hidden { display: none; }
.sidebar-account-menu-head {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 10px 12px;
}
.sidebar-account-avatar {
  width: 36px;
  height: 36px;
  border-radius: 10px;
  background: #f4f4f5;
  color: #171717;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  overflow: hidden;
}
.sidebar-account-meta { min-width: 0; flex: 1; }
.sidebar-account-name {
  font-size: 13px;
  font-weight: 600;
  color: #171717;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.sidebar-account-status {
  font-size: 11.5px;
  color: #737373;
  margin-top: 2px;
}
.sidebar-account-menu-sep {
  height: 1px;
  background: var(--ui-border, #e5e5e5);
  margin: 2px 4px 4px;
}
.sidebar-account-menu-item {
  display: flex;
  align-items: center;
  gap: 10px;
  width: 100%;
  padding: 9px 10px;
  background: transparent;
  border: none;
  border-radius: 8px;
  color: #262626;
  font-size: 13px;
  font-weight: 500;
  cursor: pointer;
  transition: background 0.12s ease, color 0.12s ease;
  text-align: left;
}
.sidebar-account-menu-item:hover {
  background: #f4f4f5;
  color: #171717;
}
.sidebar-account-menu-item--danger {
  color: #b91c1c;
}
.sidebar-account-menu-item--danger:hover {
  background: rgba(239,68,68,0.08);
  color: #991b1b;
}
html[data-theme='dark'] .sidebar-account-menu {
  background: #181a22;
  border-color: rgba(255,255,255,0.10);
  box-shadow: 0 16px 36px rgba(0,0,0,0.5), 0 2px 10px rgba(0,0,0,0.3);
}
html[data-theme='dark'] .sidebar-account-avatar {
  background: rgba(255,255,255,0.08);
  color: #f3f4f6;
}
html[data-theme='dark'] .sidebar-account-name { color: #f3f4f6; }
html[data-theme='dark'] .sidebar-account-status { color: #a3a3a3; }
html[data-theme='dark'] .sidebar-account-menu-sep { background: rgba(255,255,255,0.10); }
html[data-theme='dark'] .sidebar-account-menu-item { color: #d4d4d4; }
html[data-theme='dark'] .sidebar-account-menu-item:hover {
  background: rgba(255,255,255,0.08);
  color: #f3f4f6;
}
html[data-theme='dark'] .sidebar-account-menu-item--danger { color: #fca5a5; }
html[data-theme='dark'] .sidebar-account-menu-item--danger:hover {
  background: rgba(239,68,68,0.15);
  color: #fecaca;
}

/* ============================================================
 * 个人设置卡片 (modal)
 * ============================================================ */
.profile-modal-panel {
  max-height: 92vh;
}
.profile-modal-body {
  overflow-y: auto;
  max-height: calc(92vh - 64px);
}
.profile-head {
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 4px 0 18px;
  border-bottom: 1px solid var(--ui-border, #e5e5e5);
  margin-bottom: 18px;
}
.profile-avatar {
  width: 48px;
  height: 48px;
  border-radius: 14px;
  background: #f4f4f5;
  color: #171717;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  overflow: hidden;
}
.profile-avatar img.auth-avatar-img,
.sidebar-account-avatar img.auth-avatar-img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  border-radius: inherit;
  display: block;
}
.rail-btn img.auth-avatar-img {
  width: 100%;
  height: 100%;
  border-radius: 8px;
  object-fit: cover;
  display: block;
}
.profile-head-meta { min-width: 0; flex: 1; }
.profile-head-name {
  font-size: 15px;
  font-weight: 700;
  color: #171717;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.profile-head-sub {
  font-size: 12.5px;
  color: #737373;
  margin-top: 2px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.profile-head-status {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  margin-top: 8px;
  font-size: 11.5px;
  color: #047857;
  background: #ecfdf5;
  padding: 2px 8px;
  border-radius: 999px;
}
.profile-status-dot {
  width: 6px;
  height: 6px;
  border-radius: 999px;
  background: #10b981;
}
.profile-section { margin-bottom: 18px; }
.profile-section:last-of-type { margin-bottom: 12px; }
.profile-section-title {
  font-size: 11px;
  font-weight: 700;
  color: #737373;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  margin-bottom: 10px;
}
.profile-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 10px 12px;
  background: #fafafa;
  border: 1px solid var(--ui-border, #e5e5e5);
  border-radius: 12px;
  margin-bottom: 8px;
}
.profile-row:last-child { margin-bottom: 0; }
.profile-row-label {
  font-size: 12.5px;
  color: #737373;
  flex-shrink: 0;
}
.profile-row-value {
  font-size: 13px;
  color: #171717;
  font-weight: 500;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  text-align: right;
  max-width: 60%;
}
.profile-segmented {
  display: inline-flex;
  align-items: center;
  gap: 0;
  padding: 3px;
  background: #ffffff;
  border: 1px solid var(--ui-border, #e5e5e5);
  border-radius: 10px;
}
.profile-segmented-btn {
  border: none;
  background: transparent;
  color: #737373;
  border-radius: 7px;
  padding: 5px 12px;
  font-size: 12px;
  font-weight: 600;
  cursor: pointer;
  transition: background 0.12s ease, color 0.12s ease;
}
.profile-segmented-btn:hover { color: #171717; }
.profile-segmented-btn.is-active {
  background: #171717;
  color: #ffffff;
}
.profile-link-btn {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  width: 100%;
  padding: 12px 14px;
  background: #fafafa;
  border: 1px solid var(--ui-border, #e5e5e5);
  border-radius: 12px;
  color: #171717;
  cursor: pointer;
  text-align: left;
  transition: background 0.12s ease, border-color 0.12s ease;
}
.profile-link-btn:hover {
  background: #f4f4f5;
  border-color: var(--ui-border-strong, #d4d4d4);
}
.profile-link-btn-body {
  display: flex;
  flex-direction: column;
  gap: 2px;
  min-width: 0;
  flex: 1;
}
.profile-link-btn-title {
  font-size: 13px;
  font-weight: 600;
  color: #171717;
}
.profile-link-btn-hint {
  font-size: 11.5px;
  color: #737373;
}
.profile-row--linked { align-items: center; }
.profile-row-value--stack {
  display: flex;
  align-items: center;
  gap: 8px;
  max-width: none;
  white-space: normal;
  text-align: right;
  justify-content: flex-end;
}
.profile-row-sub {
  font-size: 11.5px;
  color: #737373;
  font-weight: 400;
  max-width: 220px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.profile-link-btn-action {
  font-size: 12px;
  font-weight: 600;
  padding: 5px 12px;
  border-radius: 8px;
  border: 1px solid var(--ui-border, #e5e5e5);
  background: #ffffff;
  color: #171717;
  cursor: pointer;
  transition: background 0.12s ease, border-color 0.12s ease;
}
.profile-link-btn-action:hover { background: #f4f4f5; }
.profile-link-btn-action--danger {
  color: #b91c1c;
  border-color: #fecaca;
}
.profile-link-btn-action--danger:hover {
  background: #fef2f2;
  border-color: #fca5a5;
}
.profile-footer {
  margin-top: 18px;
  padding-top: 16px;
  border-top: 1px solid var(--ui-border, #e5e5e5);
}
.profile-logout-btn {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  width: 100%;
  justify-content: center;
  padding: 10px 14px;
  background: #ffffff;
  border: 1px solid #fca5a5;
  border-radius: 11px;
  color: #b91c1c;
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  transition: background 0.12s ease, border-color 0.12s ease, color 0.12s ease;
}
.profile-logout-btn:hover {
  background: #fef2f2;
  border-color: #f87171;
  color: #991b1b;
}

html[data-theme='dark'] .profile-head {
  border-bottom-color: rgba(255,255,255,0.10);
}
html[data-theme='dark'] .profile-avatar {
  background: rgba(255,255,255,0.08);
  color: #f3f4f6;
}
html[data-theme='dark'] .profile-head-name { color: #f3f4f6; }
html[data-theme='dark'] .profile-head-sub { color: #a3a3a3; }
html[data-theme='dark'] .profile-head-status {
  color: #6ee7b7;
  background: rgba(16,185,129,0.12);
}
html[data-theme='dark'] .profile-section-title { color: #a3a3a3; }
html[data-theme='dark'] .profile-row {
  background: rgba(255,255,255,0.03);
  border-color: rgba(255,255,255,0.08);
}
html[data-theme='dark'] .profile-row-label { color: #a3a3a3; }
html[data-theme='dark'] .profile-row-value { color: #f3f4f6; }
html[data-theme='dark'] .profile-segmented {
  background: rgba(255,255,255,0.04);
  border-color: rgba(255,255,255,0.10);
}
html[data-theme='dark'] .profile-segmented-btn { color: #a3a3a3; }
html[data-theme='dark'] .profile-segmented-btn:hover { color: #f3f4f6; }
html[data-theme='dark'] .profile-segmented-btn.is-active {
  background: #f3f4f6;
  color: #111827;
}
html[data-theme='dark'] .profile-link-btn {
  background: rgba(255,255,255,0.03);
  border-color: rgba(255,255,255,0.08);
  color: #f3f4f6;
}
html[data-theme='dark'] .profile-link-btn:hover {
  background: rgba(255,255,255,0.06);
  border-color: rgba(255,255,255,0.16);
}
html[data-theme='dark'] .profile-link-btn-title { color: #f3f4f6; }
html[data-theme='dark'] .profile-link-btn-hint { color: #a3a3a3; }
html[data-theme='dark'] .profile-footer {
  border-top-color: rgba(255,255,255,0.10);
}
html[data-theme='dark'] .profile-logout-btn {
  background: rgba(255,255,255,0.03);
  border-color: rgba(239,68,68,0.40);
  color: #fca5a5;
}
html[data-theme='dark'] .profile-logout-btn:hover {
  background: rgba(239,68,68,0.12);
  border-color: rgba(239,68,68,0.6);
  color: #fecaca;
}

/* ---- agent-new-chat dark: 用中性灰而非紫色 ---- */
html[data-theme='dark'] .agent-new-chat {
  background: #f3f4f6 !important;
  border-color: #f3f4f6 !important;
  color: #111827 !important;
}
html[data-theme='dark'] .agent-new-chat:hover {
  background: #ffffff !important;
  border-color: #ffffff !important;
  color: #111827 !important;
}

/* ---- 搜索框 focus 中性化 ---- */
.search-wrap input:focus {
  border-color: #171717 !important;
  box-shadow: 0 0 0 3px rgba(23,23,23,0.06) !important;
}
.search-wrap .search-icon { color: #737373 !important; }
html[data-theme='dark'] .search-wrap input:focus {
  border-color: rgba(255,255,255,0.4) !important;
  box-shadow: 0 0 0 3px rgba(255,255,255,0.08) !important;
}

/* ---- 资料/任务详情面板顶部图标圆形圈 ---- */
aside .ring-1.ring-black\/5 {
  --tw-ring-color: rgba(0,0,0,0.05) !important;
}

/* ---- 模态面板内 file: 按钮样式 ---- */
input[type="file"]::file-selector-button {
  background: #f4f4f5 !important;
  color: #171717 !important;
  border: 0 !important;
}
input[type="file"]:hover::file-selector-button {
  background: #ededee !important;
}

/* ---- "切换登录/注册" 链接 ---- */
#authSwitchBtn,
.auth-switch-link {
  color: #171717 !important;
  text-decoration-color: #d4d4d4 !important;
}
html[data-theme='dark'] #authSwitchBtn,
html[data-theme='dark'] .auth-switch-link {
  color: #f3f4f6 !important;
}

/* ---- modal 顶部 chevron / x 按钮 hover (移除 brand 色) ---- */
.modal-backdrop button:hover[class*="hover:bg-brand"] {
  background-color: #f4f4f5 !important;
  color: #171717 !important;
}

.site-legal {
  position: fixed;
  right: 14px;
  bottom: 10px;
  z-index: 25;
  padding: 4px 7px;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.78);
  border: 1px solid rgba(229, 229, 229, 0.72);
  backdrop-filter: blur(10px);
  text-align: right;
  font-size: 12px;
  color: #71717a;
  line-height: 1.2;
}

.site-legal a {
  color: inherit;
  text-decoration: none;
}

.site-legal a:hover {
  color: #171717;
  text-decoration: underline;
}

html[data-theme='dark'] .site-legal {
  color: #a3a3a3;
  background: rgba(24, 26, 34, 0.78);
  border-color: rgba(255, 255, 255, 0.1);
}

html[data-theme='dark'] .site-legal a:hover {
  color: #f3f4f6;
}

@media (max-width: 640px) {
  .site-legal {
    right: 50%;
    bottom: 8px;
    transform: translateX(50%);
    max-width: calc(100vw - 24px);
    white-space: nowrap;
  }
}

/* Phase 1: streak badge + goal rings */
.dash-section--streak {
  padding: 8px 0 4px;
}
.dash-streak-row {
  display: flex;
  align-items: center;
  gap: 12px;
  flex-wrap: wrap;
}
.streak-badge {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 6px 12px;
  border-radius: 999px;
  background: linear-gradient(135deg, #fef3c7 0%, #fde68a 100%);
  color: #b45309;
  font-size: 0.8125rem;
  font-weight: 600;
  border: 1px solid #fcd34d;
}
.streak-badge--inactive {
  background: #f4f4f5;
  color: #71717a;
  border-color: #e4e4e7;
}
.goal-rings {
  display: flex;
  align-items: center;
  gap: 14px;
  flex-wrap: wrap;
}
.goal-ring {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 4px 8px;
}
.goal-ring-svg {
  width: 44px;
  height: 44px;
}
.goal-ring-track {
  stroke: #e4e4e7;
}
.goal-ring-fill {
  stroke: #6366f1;
  stroke-linecap: round;
  transition: stroke-dashoffset 0.5s ease;
}
.goal-ring[data-goal-progress="100"] .goal-ring-fill,
.goal-ring:not([data-goal-progress="0"]) .goal-ring-fill {
  stroke: #6366f1;
}
.goal-ring-body {
  display: flex;
  flex-direction: column;
  line-height: 1.1;
}
.goal-ring-value {
  font-size: 0.875rem;
  font-weight: 600;
  color: #18181b;
  font-variant-numeric: tabular-nums;
}
.goal-ring-label {
  font-size: 0.6875rem;
  color: #71717a;
}
.sidebar-streak {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 4px 8px;
  border-radius: 999px;
  background: rgba(245, 158, 11, 0.08);
  color: #b45309;
  font-size: 0.75rem;
  font-weight: 600;
}
.sidebar-streak-num {
  font-variant-numeric: tabular-nums;
}
html[data-theme='dark'] .streak-badge {
  background: linear-gradient(135deg, rgba(245,158,11,0.2), rgba(245,158,11,0.1));
  color: #fbbf24;
  border-color: rgba(245,158,11,0.35);
}
html[data-theme='dark'] .streak-badge--inactive {
  background: #27272a;
  color: #a1a1aa;
  border-color: #3f3f46;
}
html[data-theme='dark'] .goal-ring-track {
  stroke: #3f3f46;
}
html[data-theme='dark'] .goal-ring-value {
  color: #f4f4f5;
}
html[data-theme='dark'] .goal-ring-label {
  color: #a1a1aa;
}
html[data-theme='dark'] .sidebar-streak {
  background: rgba(245, 158, 11, 0.15);
  color: #fbbf24;
}

/* Phase 2: command palette */
.cmd-palette-backdrop {
  background: rgba(15, 15, 18, 0.55);
  backdrop-filter: blur(4px);
  display: flex;
  align-items: flex-start;
  justify-content: center;
  padding-top: 12vh;
}
.cmd-palette-backdrop.hidden {
  display: none !important;
}
.cmd-palette-panel {
  width: min(640px, 92vw);
  background: #fff;
  border-radius: 14px;
  box-shadow: 0 24px 64px -16px rgba(0,0,0,0.35);
  display: flex;
  flex-direction: column;
  overflow: hidden;
  border: 1px solid #e4e4e7;
}
.cmd-palette-header {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 12px 14px;
  border-bottom: 1px solid #e4e4e7;
}
.cmd-palette-search-icon {
  color: #a1a1aa;
}
.cmd-palette-input {
  flex: 1;
  border: none;
  outline: none;
  font-size: 1rem;
  background: transparent;
  color: #18181b;
}
.cmd-palette-input::placeholder {
  color: #a1a1aa;
}
.cmd-palette-close {
  background: transparent;
  border: none;
  cursor: pointer;
  color: #a1a1aa;
  padding: 4px;
  border-radius: 6px;
}
.cmd-palette-close:hover {
  background: #f4f4f5;
  color: #52525b;
}
.cmd-palette-hint {
  font-size: 0.75rem;
  color: #6366f1;
  padding: 0 14px;
  min-height: 18px;
  border-bottom: 1px solid #f4f4f5;
}
.cmd-palette-hint:empty {
  border-bottom: none;
}
.cmd-palette-list {
  max-height: 50vh;
  overflow-y: auto;
  padding: 6px;
}
.cmd-palette-empty {
  padding: 24px 12px;
  text-align: center;
  color: #a1a1aa;
  font-size: 0.875rem;
}
.cmd-palette-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 10px;
  border-radius: 8px;
  cursor: pointer;
  transition: background 0.12s ease;
}
.cmd-palette-item.is-active {
  background: rgba(99, 102, 241, 0.1);
}
.cmd-palette-item-icon {
  display: inline-flex;
  width: 26px;
  height: 26px;
  align-items: center;
  justify-content: center;
  border-radius: 6px;
  background: #f4f4f5;
  color: #52525b;
  flex-shrink: 0;
}
.cmd-palette-item.is-active .cmd-palette-item-icon {
  background: #6366f1;
  color: white;
}
.cmd-palette-item-body {
  display: flex;
  flex-direction: column;
  flex: 1;
  min-width: 0;
}
.cmd-palette-item-label {
  font-size: 0.875rem;
  color: #18181b;
  font-weight: 500;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.cmd-palette-item-sub {
  font-size: 0.75rem;
  color: #71717a;
}
.cmd-palette-footer {
  display: flex;
  gap: 14px;
  padding: 8px 14px;
  border-top: 1px solid #e4e4e7;
  font-size: 0.7rem;
  color: #a1a1aa;
  background: #fafafa;
}
.cmd-palette-footer kbd {
  display: inline-block;
  padding: 0 6px;
  background: #fff;
  border: 1px solid #d4d4d8;
  border-radius: 4px;
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  font-size: 0.7rem;
  margin-right: 4px;
  color: #52525b;
}
html[data-theme='dark'] .cmd-palette-panel {
  background: #18181b;
  border-color: #3f3f46;
}
html[data-theme='dark'] .cmd-palette-input {
  color: #f4f4f5;
}
html[data-theme='dark'] .cmd-palette-input::placeholder {
  color: #71717a;
}
html[data-theme='dark'] .cmd-palette-header,
html[data-theme='dark'] .cmd-palette-footer {
  border-color: #27272a;
}
html[data-theme='dark'] .cmd-palette-footer {
  background: #18181b;
  color: #71717a;
}
html[data-theme='dark'] .cmd-palette-footer kbd {
  background: #27272a;
  border-color: #3f3f46;
  color: #d4d4d8;
}
html[data-theme='dark'] .cmd-palette-hint {
  border-bottom-color: #27272a;
  color: #a78bfa;
}
html[data-theme='dark'] .cmd-palette-item-label {
  color: #f4f4f5;
}
html[data-theme='dark'] .cmd-palette-item-sub {
  color: #a1a1aa;
}
html[data-theme='dark'] .cmd-palette-item-icon {
  background: #27272a;
  color: #a1a1aa;
}
html[data-theme='dark'] .cmd-palette-item.is-active {
  background: rgba(99, 102, 241, 0.18);
}
html[data-theme='dark'] .cmd-palette-empty {
  color: #71717a;
}

/* Phase 3: review mode overlay */
.review-card.dash-stat-card {
  cursor: pointer;
  position: relative;
  transition: transform 0.15s ease, box-shadow 0.15s ease;
}
.review-card.dash-stat-card:hover {
  transform: translateY(-1px);
  box-shadow: 0 6px 20px -8px rgba(99,102,241,0.3);
}
.review-card-cta {
  position: absolute;
  right: 12px;
  bottom: 8px;
  font-size: 0.7rem;
  color: #6366f1;
  font-weight: 600;
}
.review-card--empty {
  opacity: 0.55;
}
.review-overlay {
  display: flex;
  flex-direction: column;
  background: linear-gradient(180deg, rgba(99,102,241,0.06) 0%, transparent 220px);
  min-height: 100%;
  padding: 8px 4px;
}
.review-overlay-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 8px 12px;
}
.review-overlay-head-left {
  display: flex;
  align-items: center;
  gap: 12px;
}
.review-overlay-kicker {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: 0.8125rem;
  color: #6366f1;
  font-weight: 600;
}
.review-overlay-progress {
  font-size: 0.875rem;
  color: #71717a;
  font-variant-numeric: tabular-nums;
}
.review-overlay-exit {
  background: transparent;
  border: 1px solid #e4e4e7;
  border-radius: 8px;
  padding: 6px;
  cursor: pointer;
  color: #71717a;
}
.review-overlay-exit:hover {
  background: #f4f4f5;
  color: #18181b;
}
.review-card {
  background: #fff;
  border: 1px solid #e4e4e7;
  border-radius: 14px;
  padding: 24px;
  margin: 0 auto;
  max-width: 720px;
  width: 100%;
  box-shadow: 0 6px 24px -12px rgba(0,0,0,0.12);
}
.review-card-title {
  font-size: 1.5rem;
  font-weight: 600;
  color: #18181b;
  margin-bottom: 12px;
}
.review-card-context {
  border-top: 1px solid #f4f4f5;
  padding-top: 14px;
  color: #3f3f46;
  font-size: 0.9375rem;
}
.review-card-context-empty {
  border-top: 1px solid #f4f4f5;
  padding-top: 14px;
  color: #a1a1aa;
  font-size: 0.875rem;
  font-style: italic;
}
.review-resource {
  margin-bottom: 12px;
}
.review-resource-title {
  font-weight: 600;
  color: #18181b;
  margin-bottom: 6px;
}
.review-points {
  list-style: disc;
  padding-left: 22px;
  margin: 0 0 8px 0;
}
.review-points li {
  margin-bottom: 4px;
  color: #3f3f46;
}
.review-questions {
  margin-top: 8px;
}
.review-section-title {
  font-size: 0.75rem;
  color: #71717a;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  margin-bottom: 4px;
}
.review-questions ul {
  list-style: decimal;
  padding-left: 22px;
}
.review-questions li {
  margin-bottom: 4px;
  color: #3f3f46;
}
.review-answer {
  margin-top: 16px;
  padding-top: 16px;
  border-top: 1px dashed #d4d4d8;
  color: #18181b;
}
.review-answer-note {
  background: #fef3c7;
  border-radius: 8px;
  padding: 10px 12px;
  margin-bottom: 10px;
  color: #78350f;
}
.review-answer-summary {
  margin-bottom: 8px;
  font-size: 0.9375rem;
  color: #18181b;
}
.review-answer-empty {
  color: #a1a1aa;
  font-style: italic;
}
.review-card-actions {
  margin-top: 20px;
}
.review-show-answer-btn {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  width: 100%;
  padding: 12px 18px;
  background: #6366f1;
  color: white;
  border: none;
  border-radius: 10px;
  font-size: 1rem;
  font-weight: 600;
  cursor: pointer;
  transition: background 0.15s ease;
}
.review-show-answer-btn:hover {
  background: #4f46e5;
}
.review-show-answer-btn kbd {
  background: rgba(255,255,255,0.18);
  padding: 2px 8px;
  border-radius: 4px;
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  font-size: 0.8rem;
}
.review-rating-title {
  font-size: 0.875rem;
  color: #52525b;
  margin-bottom: 10px;
}
.review-rating-row {
  display: grid;
  grid-template-columns: repeat(5, 1fr);
  gap: 8px;
}
.review-rating-btn {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
  padding: 12px 4px;
  border-radius: 10px;
  border: 1px solid #e4e4e7;
  background: white;
  cursor: pointer;
  transition: all 0.15s ease;
}
.review-rating-btn:hover {
  transform: translateY(-2px);
  box-shadow: 0 6px 16px -8px rgba(0,0,0,0.18);
}
.review-rating-num {
  font-size: 1.25rem;
  font-weight: 700;
  font-variant-numeric: tabular-nums;
}
.review-rating-label {
  font-size: 0.7rem;
  color: #71717a;
}
.review-rating-btn--q1 .review-rating-num { color: #dc2626; }
.review-rating-btn--q2 .review-rating-num { color: #ea580c; }
.review-rating-btn--q3 .review-rating-num { color: #ca8a04; }
.review-rating-btn--q4 .review-rating-num { color: #16a34a; }
.review-rating-btn--q5 .review-rating-num { color: #2563eb; }
.review-overlay-footer {
  display: flex;
  gap: 18px;
  justify-content: center;
  margin-top: 18px;
  font-size: 0.7rem;
  color: #a1a1aa;
}
.review-overlay-footer kbd {
  background: #fff;
  border: 1px solid #e4e4e7;
  border-radius: 4px;
  padding: 1px 6px;
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  font-size: 0.7rem;
  color: #52525b;
  margin: 0 2px;
}
html[data-theme='dark'] .review-card {
  background: #18181b;
  border-color: #3f3f46;
}
html[data-theme='dark'] .review-card-title,
html[data-theme='dark'] .review-resource-title,
html[data-theme='dark'] .review-answer-summary {
  color: #f4f4f5;
}
html[data-theme='dark'] .review-card-context,
html[data-theme='dark'] .review-points li,
html[data-theme='dark'] .review-questions li {
  color: #d4d4d8;
}
html[data-theme='dark'] .review-card-context,
html[data-theme='dark'] .review-card-context-empty {
  border-top-color: #27272a;
}
html[data-theme='dark'] .review-answer {
  border-top-color: #3f3f46;
  color: #f4f4f5;
}
html[data-theme='dark'] .review-answer-note {
  background: rgba(245,158,11,0.15);
  color: #fbbf24;
}
html[data-theme='dark'] .review-rating-btn {
  background: #27272a;
  border-color: #3f3f46;
}
html[data-theme='dark'] .review-rating-label {
  color: #a1a1aa;
}
html[data-theme='dark'] .review-overlay-exit {
  border-color: #3f3f46;
  color: #a1a1aa;
}
html[data-theme='dark'] .review-overlay-exit:hover {
  background: #27272a;
  color: #f4f4f5;
}
html[data-theme='dark'] .review-overlay-footer kbd {
  background: #27272a;
  border-color: #3f3f46;
  color: #d4d4d8;
}

.ai-settings-default-notice {
  font-size: 12px;
  color: #737373;
  background: #fafafa;
  border: 1px solid var(--ui-border, #e5e5e5);
  border-radius: 8px;
  padding: 8px 10px;
  margin-bottom: 12px;
  line-height: 1.55;
}
html[data-theme='dark'] .ai-settings-default-notice {
  background: rgba(255, 255, 255, 0.04);
  border-color: rgba(255, 255, 255, 0.08);
  color: #a3a3a3;
}
.ai-settings-reset-link {
  font-size: 12px;
  color: #737373;
  background: transparent;
  border: none;
  text-decoration: underline;
  cursor: pointer;
  padding: 0 4px;
}
.ai-settings-reset-link:hover { color: #404040; }
html[data-theme='dark'] .ai-settings-reset-link { color: #a3a3a3; }
html[data-theme='dark'] .ai-settings-reset-link:hover { color: #f4f4f5; }
