    :root {
      --bg: #0f0f13; --surface: #1a1a24; --surface2: #22223a; --border: #2e2e4a;
      --accent: #7c6af7; --accent2: #a78bfa; --green: #34d399; --red: #f87171; --yellow: #fbbf24;
      --text: #f0f0ff; --text2: #9090b8; --text3: #5a5a80; --radius: 14px; --radius-sm: 8px;
      --header-bg: linear-gradient(135deg, #1e1b4b 0%, #312e81 100%);
      --header-border: rgba(124,106,247,0.2);
      --badge-bg: rgba(124,106,247,0.2); --badge-border: rgba(124,106,247,0.4); --badge-text: #a78bfa;
      --chip-bg: rgba(124,106,247,0.1); --chip-border: rgba(124,106,247,0.3); --chip-sel-bg: var(--accent);
      --modal-bg: rgba(0,0,0,0.85);
      --fab-shadow: rgba(124,106,247,0.5);
    }
    [data-theme="light"] {
      --bg: #f8f9fa; --surface: #ffffff; --surface2: #eef1f5; --border: #dde1e7;
      --accent: #1a73e8; --accent2: #4a90d9; --green: #0d9e4f; --red: #d93025; --yellow: #e8710a;
      --text: #202124; --text2: #5f6368; --text3: #9aa0a6;
      --header-bg: linear-gradient(135deg, #1a73e8 0%, #4a90d9 100%);
      --header-border: rgba(26,115,232,0.3);
      --badge-bg: rgba(255,255,255,0.2); --badge-border: rgba(255,255,255,0.35); --badge-text: #fff;
      --chip-bg: rgba(26,115,232,0.06); --chip-border: rgba(26,115,232,0.2); --chip-sel-bg: #1a73e8;
      --modal-bg: rgba(0,0,0,0.45);
      --fab-shadow: rgba(26,115,232,0.45);
    }
    [data-theme="light"] .logo-text h1,
    [data-theme="light"] .logo-text span { color: #fff; }
    [data-theme="light"] .tab { background: rgba(255,255,255,0.2); border-color: rgba(255,255,255,0.3); color: rgba(255,255,255,0.8); }
    [data-theme="light"] .tab.active { background: var(--accent); color: #fff; border-color: var(--accent); box-shadow: 0 2px 12px var(--fab-shadow); }
    [data-theme="light"] .profile-card, [data-theme="light"] .staff-card, [data-theme="light"] .dash-stat {
      box-shadow: 0 1px 4px rgba(0,0,0,0.06);
    }
    [data-theme="light"] .view-as-bar { background: rgba(217,48,37,0.08); border-color: rgba(217,48,37,0.2); }
    [data-theme="light"] .view-as-bar label { color: #d93025; }
    [data-theme="light"] .view-as-bar button { border-color: rgba(217,48,37,0.3); color: #d93025; }
    @keyframes skeleton-shimmer { 0% { background-position: -200% 0; } 100% { background-position: 200% 0; } }
    .skeleton { background: linear-gradient(90deg, var(--surface2) 25%, var(--border) 50%, var(--surface2) 75%); background-size: 200% 100%; animation: skeleton-shimmer 1.5s ease-in-out infinite; border-radius: var(--radius-sm); color: transparent !important; pointer-events: none; user-select: none; }
    .skeleton * { visibility: hidden; }
    .skeleton-line { height: 14px; margin: 6px 0; border-radius: 6px; }
    .skeleton-card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 16px; margin-bottom: 10px; }
    .skeleton-card .skeleton-line:first-child { width: 60%; height: 18px; }
    .skeleton-card .skeleton-line:nth-child(2) { width: 85%; }
    .skeleton-card .skeleton-line:nth-child(3) { width: 40%; }
    .offline-banner { position: fixed; top: 0; left: 0; right: 0; z-index: 99999; background: linear-gradient(135deg, #dc2626, #b91c1c); color: white; text-align: center; padding: 6px 12px; font-size: 12px; font-weight: 600; transform: translateY(-100%); transition: transform 0.3s ease; }
    .offline-banner.show { transform: translateY(0); }
    * { box-sizing: border-box; margin: 0; padding: 0; -webkit-tap-highlight-color: transparent; }
    body { font-family: 'Inter', sans-serif; background: var(--bg); color: var(--text); min-height: 100vh; overscroll-behavior: none; }
    .header { background: var(--header-bg); padding: 16px 20px 20px; position: relative; z-index: 100; border-bottom: 1px solid var(--header-border); transition: background 0.3s; }
    .header-top { display: flex; align-items: center; justify-content: space-between; margin-bottom: 14px; }
    .logo { display: flex; align-items: center; gap: 10px; }
    .logo-icon { width: 36px; height: 36px; border-radius: 10px; background: linear-gradient(135deg, var(--accent), var(--accent2)); display: flex; align-items: center; justify-content: center; font-size: 18px; }
    .logo-text h1 { font-size: 16px; font-weight: 700; letter-spacing: 0.3px; }
    .logo-text span { font-size: 11px; color: var(--accent2); }
    .badge { background: var(--badge-bg); border: 1px solid var(--badge-border); color: var(--badge-text); font-size: 11px; font-weight: 600; padding: 4px 10px; border-radius: 20px; }
    .theme-toggle { width: 32px; height: 32px; border-radius: 50%; border: 1px solid rgba(255,255,255,0.3); background: rgba(255,255,255,0.15); color: white; font-size: 16px; cursor: pointer; display: flex; align-items: center; justify-content: center; transition: all 0.2s; flex-shrink: 0; }
    .theme-toggle:active { transform: scale(0.9); }
    .header-right { display: flex; align-items: center; gap: 8px; }
    .tab-bar { display: flex; gap: 6px; overflow-x: auto; scrollbar-width: none; padding-bottom: 2px; }
    .tab-bar::-webkit-scrollbar { display: none; }
    .tab { flex-shrink: 0; padding: 7px 12px; border-radius: 20px; font-size: 11px; font-weight: 600; cursor: pointer; transition: all 0.2s; border: 1px solid var(--border); background: transparent; color: var(--text2); white-space: nowrap; display: inline-flex; align-items: center; gap: 4px; }
    .tab.active { background: var(--accent); border-color: var(--accent); color: white; box-shadow: 0 0 16px var(--fab-shadow); }
    .tab-icon { flex-shrink: 0; font-size: 13px; line-height: 1; }
    .tab-label { overflow: hidden; text-overflow: ellipsis; }
    .content { padding: 16px; max-width: 600px; margin: 0 auto; transition: opacity 0.3s, transform 0.3s; }
    .tab-content-enter { animation: zoomFadeIn 0.3s cubic-bezier(0.16, 1, 0.3, 1) forwards; }
    .search-wrap { position: relative; margin-bottom: 16px; }
    .search-wrap input[type="text"] { width: 100%; padding: 12px 16px 12px 42px; background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); color: var(--text); font-size: 14px; outline: none; transition: border-color 0.2s; }
    .search-wrap input:focus { border-color: var(--accent); }
    .search-wrap .icon { position: absolute; left: 14px; top: 50%; transform: translateY(-50%); color: var(--text3); font-size: 14px; line-height: 1; pointer-events: none; }
    .profile-card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 14px 16px; margin-bottom: 10px; cursor: pointer; transition: all 0.2s; display: flex; align-items: center; gap: 12px; }
    .profile-card:hover, .profile-card:active { border-color: var(--accent); transform: scale(0.98); background: var(--surface2); }
    .avatar { width: 44px; height: 44px; border-radius: 12px; background: linear-gradient(135deg, var(--accent), #ec4899); display: flex; align-items: center; justify-content: center; font-size: 18px; font-weight: 700; flex-shrink: 0; }
    .profile-info { flex: 1; min-width: 0; }
    .name-row { display: flex; align-items: center; justify-content: space-between; margin-bottom: 6px; }
    .profile-name { font-weight: 700; font-size: 15px; color: var(--text); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
    .status-dot { width: 8px; height: 8px; border-radius: 50%; background: #10b981; }
    .status-dot.pause { background: #f59e0b; }
    .status-dot.drop { background: #ef4444; }
    .birth-year { font-weight: 400; color: var(--text3); font-size: 13px; }
    .roles-wrap { display: flex; flex-wrap: wrap; gap: 6px; }
    .fab { position: fixed; bottom: 20px; right: 20px; width: 56px; height: 56px; border-radius: 50%; background: linear-gradient(135deg, var(--accent), var(--accent2)); border: none; cursor: pointer; display: flex; align-items: center; justify-content: center; font-size: 24px; color: white; box-shadow: 0 4px 20px var(--fab-shadow); transition: transform 0.2s, box-shadow 0.2s; z-index: 200; }
    .fab:active { transform: scale(0.9) translateY(2px); box-shadow: 0 2px 10px var(--fab-shadow); }
    /* MODALS */
    @keyframes fadeInModal { from { opacity: 0; } to { opacity: 1; } }
    @keyframes zoomFadeIn { 
      0% { opacity: 0; transform: scale(0.95) translateY(10px); } 
      100% { opacity: 1; transform: scale(1) translateY(0); } 
    }
    @keyframes modalBloop {
      0% { opacity: 0; transform: scale(0.9) translateY(30px); }
      70% { transform: scale(1.02) translateY(-5px); }
      100% { opacity: 1; transform: scale(1) translateY(0); }
    }
    .modal-overlay { position: fixed; inset: 0; background: var(--modal-bg); z-index: 500; display: none; align-items: flex-end; animation: fadeInModal 0.2s; backdrop-filter: blur(2px); -webkit-backdrop-filter: blur(2px); }
    @media (min-width: 1024px) { .modal-overlay { backdrop-filter: none; -webkit-backdrop-filter: none; } }
    .modal-overlay.open { display: flex; }
    .modal { width: 100%; background: var(--surface); border-radius: 20px 20px 0 0; padding: 20px; max-height: 90vh; overflow-y: auto; animation: modalBloop 0.4s cubic-bezier(0.16, 1, 0.3, 1) forwards; }
    .modal-handle { width: 40px; height: 4px; background: var(--border); border-radius: 2px; margin: 0 auto 16px; }
    .modal-title { font-size: 16px; font-weight: 700; margin-bottom: 16px; }
    .form-group { margin-bottom: 16px; }
    .form-group label { display: block; font-size: 12px; font-weight: 600; color: var(--text2); margin-bottom: 6px; }
    .form-group input, .form-group select { width: 100%; padding: 12px 14px; background: var(--bg); border: 1px solid var(--border); border-radius: var(--radius); color: var(--text); font-size: 14px; font-family: inherit; transition: border-color 0.2s; }
    .form-group input:focus, .form-group select:focus { border-color: var(--accent); outline: none; }
    .form-btn { width: 100%; padding: 14px; background: linear-gradient(135deg, var(--accent), var(--accent2)); color: white; border: none; border-radius: var(--radius); font-size: 15px; font-weight: 600; cursor: pointer; margin-top: 10px; transition: transform 0.15s, opacity 0.2s; }
    .form-btn:active { transform: scale(0.97); }
    .form-btn:disabled { opacity: 0.6; cursor: not-allowed; }
    .role-badge { display: inline-flex; align-items: center; padding: 4px 10px; border-radius: 20px; font-size: 11px; font-weight: 600; transition: transform 0.2s; }
    .role-badge:active { transform: scale(0.95); }
    .role-admin { background: linear-gradient(135deg, rgba(124,106,247,0.25), rgba(167,139,250,0.2)); color: #8b5cf6; border: 1px solid rgba(139,92,246,0.5); box-shadow: 0 0 6px rgba(139,92,246,0.15); }
    .role-ndd { background: linear-gradient(135deg, rgba(16,185,129,0.2), rgba(52,211,153,0.15)); color: #059669; border: 1px solid rgba(16,185,129,0.45); box-shadow: 0 0 6px rgba(16,185,129,0.12); }
    .role-tvv { background: rgba(251,191,36,0.15); color: var(--yellow); border: 1px solid rgba(251,191,36,0.3); }
    .role-default { background: var(--surface2); color: var(--text2); border: 1px solid var(--border); }
    .section-header { display: flex; align-items: center; justify-content: space-between; margin-bottom: 12px; }
    .section-title { font-size: 13px; font-weight: 600; color: var(--text2); text-transform: uppercase; letter-spacing: 0.8px; }
    .section-count { background: var(--surface2); border: 1px solid var(--border); font-size: 11px; font-weight: 600; padding: 2px 8px; border-radius: 10px; color: var(--accent2); }
    .detail-view {
      display: none;
    }
    .detail-view.active { display: block; }
    .back-btn { display: flex; align-items: center; gap: 8px; background: var(--surface); border: 1px solid var(--border); color: var(--text2); font-size: 13px; font-weight: 500; padding: 8px 14px; border-radius: 20px; cursor: pointer; margin-bottom: 16px; width: fit-content; }
    .profile-detail-header { background: linear-gradient(135deg, var(--surface) 0%, var(--surface2) 100%); border: 1px solid var(--border); border-radius: var(--radius); padding: 20px; margin-bottom: 16px; text-align: center; }
    .profile-detail-avatar { width: 72px; height: 72px; border-radius: 20px; background: linear-gradient(135deg, var(--accent), #ec4899); display: flex; align-items: center; justify-content: center; font-size: 32px; font-weight: 700; margin: 0 auto 12px; box-shadow: 0 8px 24px rgba(124,106,247,0.3); }
    .profile-detail-name { font-size: 20px; font-weight: 700; margin-bottom: 4px; }
    .profile-detail-meta { font-size: 13px; color: var(--text2); }
    .form-tabs { display: flex; gap: 6px; flex-wrap: wrap; margin-bottom: 16px; padding-bottom: 6px; }
    .form-tabs::-webkit-scrollbar { display: none; }
    .form-tab { flex-shrink: 0; padding: 6px 10px; border-radius: 8px; font-size: 11px; font-weight: 600; cursor: pointer; border: 1px solid var(--border); background: var(--surface); color: var(--text2); transition: all 0.2s; white-space: nowrap; }
    .form-tab.active { background: var(--accent); border-color: var(--accent); color: white; }

    .form-card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); margin-bottom: 10px; overflow: hidden; display: none; }
    .form-card.active { display: block; }
    .form-card-header { display: flex; align-items: center; justify-content: space-between; padding: 14px 16px; border-bottom: 1px solid var(--border); }
    .form-card-title { font-size: 13px; font-weight: 700; }
    .form-card-meta { font-size: 11px; color: var(--text3); }
    .form-card-body { padding: 16px; display: flex; flex-direction: column; gap: 14px; }
    label { font-size: 12px; font-weight: 600; color: var(--text2); margin-bottom: 6px; display: block; }
    input[type="text"], input[type="tel"], input[type="date"], textarea, select { width: 100%; padding: 10px 12px; background: var(--surface2); border: 1px solid var(--border); border-radius: var(--radius-sm); color: var(--text); font-size: 14px; font-family: inherit; outline: none; transition: border-color 0.2s; }
    input:focus, textarea:focus, select:focus { border-color: var(--accent); }
    textarea { resize: vertical; min-height: 80px; }
    select { appearance: none; -webkit-appearance: none; cursor: pointer; }
    select option { background: var(--surface); color: var(--text); }
    .chips { display: flex; flex-wrap: wrap; gap: 8px; }
    .chip { padding: 6px 12px; border-radius: 20px; font-size: 12px; font-weight: 500; border: 1px solid var(--border); background: var(--surface2); color: var(--text2); cursor: pointer; transition: all 0.2s; }
    .chip.selected { background: var(--chip-sel-bg); border-color: var(--accent); color: white; }
    .record-item { background: var(--surface2); border: 1px solid var(--border); border-radius: var(--radius-sm); padding: 12px 14px; display: flex; align-items: flex-start; gap: 12px; }
    .record-number { width: 28px; height: 28px; border-radius: 8px; background: rgba(124,106,247,0.15); border: 1px solid rgba(124,106,247,0.3); display: flex; align-items: center; justify-content: center; font-size: 12px; font-weight: 700; color: var(--accent2); flex-shrink: 0; }
    .record-content { flex: 1; }
    .record-date { font-size: 11px; color: var(--text3); margin-bottom: 4px; }
    .record-title { font-size: 13px; font-weight: 600; margin-bottom: 2px; }
    .record-preview { font-size: 12px; color: var(--text2); }
    .add-record-btn { width: 100%; padding: 12px; background: rgba(124,106,247,0.1); border: 2px dashed rgba(124,106,247,0.3); border-radius: var(--radius-sm); color: var(--accent2); font-size: 13px; font-weight: 600; cursor: pointer; transition: all 0.2s; display: flex; align-items: center; justify-content: center; gap: 8px; }
    .add-record-btn:active { background: rgba(124,106,247,0.2); }
    .sync-sheet-btn { width: 100%; padding: 12px; background: linear-gradient(135deg,var(--accent),var(--accent2)); border: none; border-radius: var(--radius-sm); color: white; font-size: 13px; font-weight: 700; cursor: pointer; transition: all 0.2s; display: flex; align-items: center; justify-content: center; gap: 8px; margin-top: 8px; }
    .sync-sheet-btn:active { opacity: 0.85; transform: scale(0.98); }
    .save-btn { width: 100%; padding: 14px; background: linear-gradient(135deg, var(--accent), var(--accent2)); border: none; border-radius: var(--radius); color: white; font-size: 14px; font-weight: 700; cursor: pointer; margin-top: 8px; box-shadow: 0 4px 16px rgba(124,106,247,0.4); transition: opacity 0.2s, transform 0.1s; }
    .save-btn:active { opacity: 0.85; transform: scale(0.98); }
    .modal-overlay { position: fixed; inset: 0; background: var(--modal-bg); z-index: 500; display: none; align-items: flex-end; animation: fadeIn 0.2s; }
    .modal-overlay.open { display: flex; }
    .modal { width: 100%; background: var(--surface); border-radius: 20px 20px 0 0; padding: 20px; max-height: 90vh; overflow-y: auto; animation: slideUp 0.3s ease-out; }
    @keyframes fadeIn { from { opacity: 0; } to { opacity: 1; } }
    @keyframes slideUp { from { transform: translateY(100%); } to { transform: translateY(0); } }
    .modal-handle { width: 40px; height: 4px; background: var(--border); border-radius: 2px; margin: 0 auto 16px; }
    .modal-title { font-size: 16px; font-weight: 700; margin-bottom: 16px; }
    .toast { position: fixed; bottom: 90px; left: 50%; transform: translateX(-50%) translateY(20px); background: var(--surface2); border: 1px solid var(--border); padding: 10px 20px; border-radius: 20px; font-size: 13px; font-weight: 600; opacity: 0; transition: all 0.3s; pointer-events: none; z-index: 999999; white-space: nowrap; }
    .toast.show { opacity: 1; transform: translateX(-50%) translateY(0); }
    .skeleton { background: linear-gradient(90deg, var(--surface) 25%, var(--surface2) 50%, var(--surface) 75%); background-size: 200% 100%; animation: shimmer 1.2s infinite; border-radius: var(--radius-sm); }
    @keyframes shimmer { 0% { background-position: 200% 0; } 100% { background-position: -200% 0; } }

    /* ── Top loading bar ── */
    .top-loading-bar { position: fixed; top: 0; left: 0; width: 0; height: 3px; background: linear-gradient(90deg, var(--accent), #22d3ee, var(--accent)); z-index: 99999; transition: width 0.3s ease; pointer-events: none; border-radius: 0 2px 2px 0; box-shadow: 0 0 8px rgba(56,189,248,0.4); }
    .top-loading-bar.loading { width: 70%; animation: loadPulse 1.5s ease-in-out infinite; }
    .top-loading-bar.done { width: 100%; opacity: 0; transition: width 0.2s ease, opacity 0.4s ease 0.2s; }
    @keyframes loadPulse { 0%,100% { width: 70%; } 50% { width: 85%; } }
    .empty-state { text-align: center; padding: 48px 20px; }
    .empty-icon { font-size: 56px; margin-bottom: 12px; }
    .empty-title { font-size: 16px; font-weight: 600; margin-bottom: 8px; }
    .empty-sub { font-size: 13px; color: var(--text2); }
    .grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
    .field-group { display: flex; flex-direction: column; gap: 6px; }
    .delete-profile-btn { width: 100%; padding: 12px; background: rgba(248,113,113,0.1); border: 1px solid rgba(248,113,113,0.3); border-radius: var(--radius); color: var(--red); font-size: 13px; font-weight: 600; cursor: pointer; margin-top: 20px; transition: all 0.2s; }
    .delete-profile-btn:active { background: rgba(248,113,113,0.25); }
    .record-delete { background: none; border: none; color: var(--text3); font-size: 16px; cursor: pointer; padding: 4px; flex-shrink: 0; transition: color 0.2s; }
    .record-delete:hover { color: var(--red); }
    .staff-card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 14px 16px; margin-bottom: 10px; display: flex; align-items: center; gap: 12px; }
    .staff-avatar { width: 44px; height: 44px; border-radius: 12px; background: linear-gradient(135deg, #34d399, #059669); display: flex; align-items: center; justify-content: center; font-size: 18px; font-weight: 700; flex-shrink: 0; color: white; }
    .staff-role-badge { display: inline-block; font-size: 10px; font-weight: 700; padding: 2px 8px; border-radius: 10px; text-transform: uppercase; letter-spacing: 0.5px; }
    .role-admin { background: linear-gradient(135deg, rgba(124,106,247,0.25), rgba(167,139,250,0.2)); color: #8b5cf6; border: 1px solid rgba(139,92,246,0.5); box-shadow: 0 0 6px rgba(139,92,246,0.15); }
    .role-ndd { background: linear-gradient(135deg, rgba(16,185,129,0.2), rgba(52,211,153,0.15)); color: #059669; border: 1px solid rgba(16,185,129,0.45); box-shadow: 0 0 6px rgba(16,185,129,0.12); }
    .role-tvv { background: rgba(251,191,36,0.15); color: var(--yellow); border: 1px solid rgba(251,191,36,0.3); }
    .role-default { background: var(--surface2); color: var(--text2); border: 1px solid var(--border); }
    .role-yjyn { background: linear-gradient(135deg, #fbbf24, #f59e0b); color: #fff; border: 1px solid #d97706; box-shadow: 0 1px 4px rgba(245,158,11,0.35); text-shadow: 0 1px 1px rgba(0,0,0,0.15); }
    .role-tjn { background: linear-gradient(135deg, #10b981, #059669); color: #fff; border: 1px solid #047857; box-shadow: 0 1px 4px rgba(16,185,129,0.35); text-shadow: 0 1px 1px rgba(0,0,0,0.15); }
    .role-gyjn { background: linear-gradient(135deg, #3b82f6, #2563eb); color: #fff; border: 1px solid #1d4ed8; box-shadow: 0 1px 4px rgba(59,130,246,0.35); text-shadow: 0 1px 1px rgba(0,0,0,0.15); }
    .role-bgyjn { background: linear-gradient(135deg, #14b8a6, #0d9488); color: #fff; border: 1px solid #0f766e; box-shadow: 0 1px 4px rgba(20,184,166,0.3); text-shadow: 0 1px 1px rgba(0,0,0,0.15); }
    .level-badge { display: inline-block; font-size: 10px; font-weight: 500; padding: 1px 6px; border-radius: 8px; background: var(--surface2); color: var(--text3); border: 1px solid var(--border); margin-left: 6px; }
    /* Dashboard cards */
    .dash-card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 16px; margin-bottom: 12px; }
    .dash-card-row { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; margin-bottom: 12px; }
    .dash-stat {
      text-align: center; padding: 16px 8px 14px;
      background: var(--surface); border: 1px solid var(--border);
      border-radius: var(--radius); position: relative; overflow: hidden;
      transition: transform 0.15s, border-color 0.2s;
    }
    .dash-stat:active { transform: scale(0.97); }
    /* Collapsible dashboard */
    .dash-collapsible {
      max-height: 500px; overflow: hidden;
      transition: max-height 0.35s ease, opacity 0.25s ease; opacity: 1;
    }
    .dash-collapsible.collapsed { max-height: 0; opacity: 0; margin-bottom: 0; }
    .dash-stat::before {
      content: ''; position: absolute; top: 0; left: 0; right: 0; height: 3px;
      background: linear-gradient(90deg, var(--accent), var(--accent2));
    }
    .dash-stat.green::before { background: linear-gradient(90deg, #34d399, #059669); }
    .dash-stat.yellow::before { background: linear-gradient(90deg, #fbbf24, #f59e0b); }
    .dash-stat.pink::before { background: linear-gradient(90deg, #f472b6, #ec4899); }
    .dash-stat .num { font-size: 30px; font-weight: 800; line-height: 1.1; margin-bottom: 4px; }
    .dash-stat.accent .num { background: linear-gradient(135deg, var(--accent), var(--accent2)); -webkit-background-clip: text; background-clip: text; -webkit-text-fill-color: transparent; }
    .dash-stat.green .num  { background: linear-gradient(135deg, #34d399, #10b981); -webkit-background-clip: text; background-clip: text; -webkit-text-fill-color: transparent; }
    .dash-stat.yellow .num { background: linear-gradient(135deg, #fbbf24, #f59e0b); -webkit-background-clip: text; background-clip: text; -webkit-text-fill-color: transparent; }
    .dash-stat.pink .num   { background: linear-gradient(135deg, #f472b6, #ec4899); -webkit-background-clip: text; background-clip: text; -webkit-text-fill-color: transparent; }
    .dash-stat .lbl { font-size: 11px; color: var(--text2); font-weight: 500; }
    /* Dashboard mode toggle */
    .dash-mode-toggle {
      display: flex; gap: 4px; padding: 3px; border-radius: 10px;
      background: var(--surface2); border: 1px solid var(--border); margin-bottom: 14px;
    }
    .dash-mode-btn {
      flex: 1; text-align: center; padding: 7px 10px; border-radius: 8px; font-size: 12px;
      font-weight: 600; cursor: pointer; transition: all 0.2s; color: var(--text2); border: none; background: transparent;
    }
    .dash-mode-btn.active {
      background: var(--accent); color: white; box-shadow: 0 2px 8px rgba(124,106,247,0.3);
    }
    /* Center circle — overlaps at grid center */
    .dash-center-circle {
      width: 76px; height: 76px; border-radius: 50%;
      position: absolute; top: 50%; left: 50%; transform: translate(-50%, -50%);
      background: linear-gradient(135deg, #8b5cf6, #a855f7);
      display: flex; flex-direction: column; align-items: center; justify-content: center;
      box-shadow: 0 4px 20px rgba(139,92,246,0.45); cursor: pointer;
      z-index: 5; border: 3px solid var(--surface);
      transition: transform 0.2s, box-shadow 0.2s;
    }
    .dash-center-circle:active { transform: translate(-50%, -50%) scale(0.92); }
    .dash-center-circle .num { font-size: 22px; font-weight: 800; color: white; line-height: 1; }
    .dash-center-circle .lbl { font-size: 8px; color: rgba(255,255,255,0.9); font-weight: 600; margin-top: 2px; letter-spacing: 0.3px; }
    /* Info tooltip on stat */
    .dash-stat .info-badge {
      position: absolute; top: 6px; right: 6px; width: 16px; height: 16px; border-radius: 50%;
      background: var(--surface2); border: 1px solid var(--border); color: var(--text3);
      font-size: 10px; font-weight: 700; display: flex; align-items: center; justify-content: center;
      cursor: pointer; transition: all 0.2s; z-index: 2; line-height: 1;
    }
    .dash-stat .info-badge:hover { background: var(--accent); color: white; border-color: var(--accent); }
    .dash-stat .info-badge-left { right: auto; left: 6px; }
    /* Dashboard grid 5 cards layout — circle overlaps center */
    .dash-grid-5 {
      display: grid; grid-template-columns: 1fr 1fr; gap: 10px; margin-bottom: 14px;
      position: relative;
    }
    .dash-grid-5 .dash-stat { padding-top: 20px; padding-bottom: 18px; }

    /* Section headers — cleaner accent style */
    .section-header { display: flex; align-items: center; justify-content: space-between; margin-bottom: 12px; padding: 8px 12px; background: var(--surface2); border-radius: var(--radius-sm); border-left: 3px solid var(--accent); }
    .section-title { font-size: 12px; font-weight: 700; color: var(--text); text-transform: uppercase; letter-spacing: 0.8px; }
    .section-count { background: var(--accent); font-size: 10px; font-weight: 700; padding: 2px 8px; border-radius: 10px; color: white; }
    /* Sub-unit group/team row headers */
    .subunit-group-hd {
      cursor: pointer; display: flex; justify-content: space-between; align-items: center;
      padding: 10px 14px; background: var(--surface2);
      border-radius: var(--radius-sm); border: 1px solid var(--border);
      border-left: 4px solid var(--accent); transition: border-color 0.2s;
    }
    .subunit-group-hd:hover { border-left-color: var(--accent2); }
    .subunit-team-hd {
      cursor: pointer; display: flex; justify-content: space-between; align-items: center;
      padding: 8px 12px; border-left: 3px solid var(--green);
      border-radius: 0 var(--radius-sm) var(--radius-sm) 0; background: var(--surface);
      transition: border-color 0.2s;
    }
    .subunit-team-hd:hover { border-left-color: #10b981; }
    .dash-list-item { display: flex; align-items: center; gap: 10px; padding: 10px 0; border-bottom: 1px solid var(--border); cursor: pointer; }
    .dash-list-item:last-child { border-bottom: none; }
    .dash-dot { width: 8px; height: 8px; border-radius: 50%; flex-shrink: 0; }
    .dash-dot.tv { background: var(--yellow); }
    .dash-dot.bb { background: var(--green); }
    .dash-dot.pending { background: var(--accent); animation: pulse 1.5s infinite; }
    .dash-dot.revision { background: #ef4444; animation: pulse 1.5s infinite; }
    .dash-dot.resubmitted { background: #8b5cf6; animation: pulse 1.5s infinite; }
    @keyframes pulse { 0%,100% { opacity: 1; } 50% { opacity: 0.4; } }

    /* Structure tree - collapsible tree */
    .tree-container { position: relative; }
    .tree-branch { position: relative; }
    .tree-node { position: relative; padding: 8px 12px; margin-bottom: 2px; border-radius: var(--radius-sm); background: var(--surface); border: 1px solid var(--border); display: flex; align-items: center; justify-content: space-between; transition: all 0.2s; gap: 8px; }
    .tree-node:hover { border-color: var(--accent); }
    .tree-node.area { border-left: 4px solid var(--accent); }
    .tree-node.group { border-left: 4px solid var(--green); }
    .tree-node.team { border-left: 4px solid var(--yellow); }
    .tree-children { padding-left: 18px; border-left: 2px solid var(--border); margin-left: 10px; margin-bottom: 2px; }
    .tree-children.tree-members { padding-left: 14px; margin-left: 8px; border-left: 2px dashed var(--border); }
    .tree-member-card { display: flex; align-items: center; justify-content: space-between; gap: 8px; padding: 6px 10px; margin-bottom: 2px; border-radius: var(--radius-sm); background: var(--surface); border: 1px solid var(--border); transition: border-color 0.15s; }
    .tree-member-card:hover { border-color: var(--accent); background: var(--surface2); }
    .tree-member-name { font-size: 12px; font-weight: 500; color: var(--text2); white-space: nowrap; flex-shrink: 0; }
    .tree-member-badges { display: flex; flex-wrap: wrap; gap: 3px; justify-content: flex-end; }
    .tree-chevron { display: inline-flex; align-items: center; justify-content: center; width: 16px; height: 16px; font-size: 10px; color: var(--text3); transition: transform 0.2s ease; flex-shrink: 0; user-select: none; }
    .tree-chevron.open { transform: rotate(90deg); }
    .tree-edit-icon { font-size: 12px; opacity: 0.4; transition: opacity 0.2s; cursor: pointer; }
    .tree-edit-icon:hover { opacity: 1; }
    .tree-label { font-size: 13px; font-weight: 600; flex: 1; }
    .tree-meta { font-size: 11px; color: var(--text3); text-align: right; white-space: nowrap; flex-shrink: 0; }
    .tree-manager { font-size: 10px; color: var(--accent2); font-weight: 500; }
    .tree-add { cursor: pointer; opacity: 0.7; transition: opacity 0.2s; color: var(--accent); }
    .tree-add:hover { opacity: 1; }
    .tree-add .tree-label { color: var(--accent); font-weight: 500; }
    /* View As bar */
    .view-as-bar { display: none; background: rgba(248,113,113,0.15); border: 1px solid rgba(248,113,113,0.3); border-radius: 10px; padding: 6px 12px; margin-bottom: 10px; align-items: center; gap: 8px; position: relative; z-index: 10; }
    .view-as-bar.active { display: flex; }
    .view-as-bar label { font-size: 11px; color: var(--red); font-weight: 600; margin: 0; white-space: nowrap; }
    .view-as-bar button { background: none; border: 1px solid rgba(248,113,113,0.3); color: var(--red); font-size: 11px; padding: 3px 8px; border-radius: 6px; cursor: pointer; white-space: nowrap; }
    /* View As Member Search */
    .vam-search-wrap { flex: 1; position: relative; }
    .vam-search-wrap input { width: 100%; padding: 5px 10px; border: 1px solid rgba(248,113,113,0.3); border-radius: 6px; font-size: 12px; font-family: inherit; background: rgba(0,0,0,0.3); color: var(--text); box-sizing: border-box; }
    .vam-search-wrap input::placeholder { color: rgba(255,255,255,0.4); }
    [data-theme="light"] .vam-search-wrap input { background: #fff; border-color: #dde1e7; color: var(--text); }
    [data-theme="light"] .vam-search-wrap input::placeholder { color: #9ca3af; }
    .vam-dropdown { display: none; position: absolute; top: calc(100% + 4px); left: 0; right: 0; max-height: 260px; overflow-y: auto; background: var(--surface); border: 1px solid var(--border); border-radius: 10px; box-shadow: 0 8px 32px rgba(0,0,0,0.18); z-index: 9999; }
    .vam-dropdown.show { display: block; }
    .vam-item { padding: 8px 12px; cursor: pointer; border-bottom: 1px solid var(--border); transition: background 0.15s; }
    .vam-item:last-child { border-bottom: none; }
    .vam-item:hover { background: var(--surface2); }
    .vam-name { font-size: 12px; font-weight: 600; color: var(--text); }
    .vam-meta { font-size: 11px; color: var(--text3); margin-top: 2px; }
    .vam-empty { padding: 12px; text-align: center; font-size: 12px; color: var(--text3); }

    .semester-bar { display: flex; align-items: center; gap: 8px; padding: 6px 12px; background: rgba(124,106,247,0.08); border: 1px solid rgba(124,106,247,0.2); border-radius: 10px; margin-bottom: 8px; }
    [data-theme="light"] .semester-bar { background: rgba(124,106,247,0.06); border-color: rgba(124,106,247,0.15); }

    .semester-badge { font-size: 11px; font-weight: 700; padding: 4px 10px; border-radius: 12px; background: rgba(124,106,247,0.15); border: 1px solid rgba(124,106,247,0.3); color: var(--accent); }

    /* ── Timeline ── */
    .tl-container {
      border-radius: var(--radius-sm);
      overflow: hidden;
      border: 1px solid var(--border);
      position: relative;
      max-width: 800px;
      margin: 0 auto;
      width: 100%;
    }
    .tl-header-row {
      display: flex;
      align-items: stretch;
      background: var(--surface2) !important;
      border-bottom: 1px solid var(--border) !important;
    }
    .tl-header-cell {
      justify-content: center !important;
      align-items: center !important;
      font-weight: 700 !important;
      color: var(--text2) !important;
      font-size: 11px !important;
      text-transform: uppercase !important;
      letter-spacing: 0.5px !important;
      background: none !important;
      padding: 8px 6px !important;
      box-sizing: border-box !important;
      min-height: 32px !important;
    }
    /* Left continuous vertical line (milestones & reports) */
    .tl-container::before {
      content: '';
      position: absolute;
      top: 0;
      bottom: 0;
      left: calc(22% - 1.5px);
      width: 3px;
      background: var(--accent);
      z-index: 2;
      pointer-events: none;
    }
    /* Right continuous vertical line (reports & BTVN cyan border) */
    .tl-container::after {
      content: '';
      position: absolute;
      top: 0;
      bottom: 0;
      left: calc(62% - 1.5px);
      width: 3px;
      background: #0ea5e9;
      z-index: 2;
      pointer-events: none;
    }
    .tl-item {
      display: flex;
      align-items: stretch;
      min-height: 36px;
      border-bottom: 1px solid var(--border);
      transition: background 0.1s;
    }
    .tl-item:last-child { border-bottom: none; }
    .tl-item:hover { background: color-mix(in srgb, var(--accent) 4%, transparent); }
    .tl-left {
      flex: 0 0 22%;
      width: 22%;
      max-width: 22%;
      min-width: 0;
      display: flex;
      align-items: center;
      gap: 5px;
      padding: 7px 6px 7px 8px;
      border-right: none;
      box-sizing: border-box;
    }
    .tl-right {
      flex: 0 0 40%;
      width: 40%;
      max-width: 40%;
      min-width: 0;
      display: flex;
      align-items: center;
      gap: 5px;
      padding: 7px 8px 7px 8px;
      box-sizing: border-box;
    }
    .tl-btvn {
      flex: 1 1 0;
      min-width: 0;
      display: flex;
      align-items: center;
      padding: 7px 8px;
      box-sizing: border-box;
      background: color-mix(in srgb, #0ea5e9 4%, transparent);
    }
    .tl-btvn-standalone {
      background: color-mix(in srgb, #0ea5e9 2%, transparent);
    }
    .tl-btvn-card {
      display: flex;
      align-items: center;
      gap: 6px;
      background: var(--surface2);
      border: 1px solid color-mix(in srgb, #0ea5e9 30%, var(--border));
      border-radius: var(--radius-sm);
      padding: 6px 8px;
      width: 100%;
      box-sizing: border-box;
      transition: border-color 0.2s, background-color 0.2s;
    }
    .tl-btvn-card:hover {
      border-color: #0ea5e9;
      background: var(--surface);
    }
    .tl-btvn-info {
      display: flex;
      flex-direction: column;
      gap: 1px;
      flex: 1;
      min-width: 0;
    }
    .tl-btvn-info .tl-label {
      font-size: 11px;
      font-weight: 600;
      color: var(--text);
      word-break: break-word;
      overflow-wrap: break-word;
    }
    .tl-btvn-card .tl-date {
      font-size: 9px;
    }
    .tl-btn-group-btvn {
      display: flex;
      align-items: center;
      gap: 4px;
    }
    .tl-btn-group-btvn .tl-edit-btn,
    .tl-btn-group-btvn .tl-del-btn {
      opacity: 1 !important;
      visibility: visible !important;
      display: inline-block !important;
    }
    /* Major milestone row */
    .tl-major .tl-left { background: var(--surface2); font-weight: 700; }
    /* KT split row */
    .tl-kt { background: color-mix(in srgb, var(--green) 6%, transparent); }
    .tl-kt .tl-left { background: color-mix(in srgb, var(--green) 12%, transparent); }
    /* Report-only row */
    .tl-report-row .tl-left { background: var(--surface2); }
    /* Icons & labels */
    .tl-icon { font-size: 13px; flex-shrink: 0; line-height: 1; }
    .tl-label {
      font-size: 11.5px;
      font-weight: 600;
      color: var(--text);
      line-height: 1.3;
      word-break: normal;
      overflow-wrap: break-word;
    }
    .tl-label-kt { color: var(--green); font-weight: 700; }
    .tl-left-info {
      display: flex;
      flex-direction: column;
      gap: 1px;
      flex: 1;
      min-width: 0;
    }
    .tl-left-info .tl-label {
      word-break: normal;
      overflow-wrap: break-word;
    }
    .tl-date { font-size: 10px; color: var(--text3); white-space: nowrap; flex-shrink: 0; display: block; }
    .tl-right-info {
      display: flex;
      flex-direction: column;
      gap: 1px;
      flex: 1;
      min-width: 0;
    }
    .tl-right-info .tl-label {
      word-break: normal;
      overflow-wrap: break-word;
    }
    .tl-right-info .tl-date { display: block; }
    /* Clickable reports */
    .tl-clickable { cursor: pointer; }
    .tl-clickable:hover .tl-label { color: var(--accent); text-decoration: underline; }
    .tl-report-row[onclick] { cursor: pointer; }
    .tl-report-row[onclick]:hover .tl-label { color: var(--accent); text-decoration: underline; }
    /* Delete button */
    .tl-del-btn {
      flex-shrink: 0;
      padding: 2px 7px;
      border: 1px solid var(--text3);
      border-radius: 6px;
      background: transparent;
      color: var(--text3);
      font-size: 10px;
      cursor: pointer;
      opacity: 0;
      transition: opacity 0.15s, color 0.15s, border-color 0.15s;
      margin-left: auto;
    }
    .tl-del-btn.visible { opacity: 1; }
    .tl-del-btn:hover { color: var(--red); border-color: var(--red); }
    .tl-item:hover .tl-del-btn { opacity: 1; }
    /* Edit button in timeline */
    .tl-edit-btn {
      flex-shrink: 0;
      padding: 2px 7px;
      border: 1px solid var(--text3);
      border-radius: 6px;
      background: transparent;
      color: var(--text3);
      font-size: 10px;
      cursor: pointer;
      opacity: 0;
      transition: opacity 0.15s, color 0.15s, border-color 0.15s;
    }
    .tl-edit-btn:hover { color: var(--accent); border-color: var(--accent); }
    .tl-item:hover .tl-edit-btn { opacity: 1; }
    /* Button group for edit + delete */
    .tl-btn-group {
      display: flex;
      align-items: center;
      gap: 3px;
      margin-left: auto;
      flex-shrink: 0;
    }
    
    /* Custom Autocomplete */
    .ac-wrap { position: relative; width: 100%; }
    .ac-list { position: absolute; top: calc(100% + 4px); left: 0; right: 0; background: var(--surface2); border: 1px solid var(--border); border-radius: var(--radius-sm); max-height: 200px; overflow-y: auto; z-index: 1000; box-shadow: 0 4px 12px rgba(0,0,0,0.3); display: none; }
    .ac-list.show { display: block; }
    .ac-item { padding: 10px 12px; font-size: 13px; color: var(--text); border-bottom: 1px solid var(--border); cursor: pointer; }
    .ac-item:last-child { border-bottom: none; }
    .ac-item:hover, .ac-item.active { background: color-mix(in srgb, var(--accent) 15%, transparent); color: var(--accent2); font-weight: 600; }
    /* Sticky Notes */
    .sticky-note {
      background: linear-gradient(135deg, #fef9c3, #fde68a);
      border-radius: 6px; padding: 0; margin-bottom: 10px;
      box-shadow: 2px 3px 10px rgba(0,0,0,0.08);
      border: 1px solid #fbbf24; position: relative;
      transition: transform 0.15s;
    }
    .sticky-note:active { transform: scale(0.98); }
    .sticky-note-header {
      display: flex; justify-content: space-between; align-items: center;
      padding: 10px 12px; cursor: pointer; user-select: none;
    }
    .sticky-note-title {
      font-weight: 700; font-size: 13px; color: #92400e;
      flex: 1; white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
    }
    .sticky-note-date { font-size: 10px; color: #b45309; margin-left: 8px; flex-shrink: 0; }
    .sticky-note-body {
      display: none; padding: 0 12px 12px; font-size: 12px;
      color: #78350f; white-space: pre-wrap; line-height: 1.5;
      border-top: 1px dashed #d97706;
    }
    .sticky-note-body.open { display: block; padding-top: 8px; }
    .sticky-note-actions {
      position: absolute; top: -8px; right: -4px; display: flex; gap: 2px;
      opacity: 0; transition: opacity 0.2s; z-index: 3;
    }
    .sticky-note:hover .sticky-note-actions,
    .sticky-note:focus-within .sticky-note-actions { opacity: 1; }
    .sticky-note-edit, .sticky-note-del {
      width: 24px; height: 24px; border-radius: 50%; border: none;
      font-size: 12px; cursor: pointer; display: flex;
      align-items: center; justify-content: center;
      transition: all 0.2s;
    }
    .sticky-note-edit { background: rgba(37,99,235,0.1); color: #2563eb; }
    .sticky-note-edit:hover { background: #2563eb; color: white; }
    .sticky-note-del { background: rgba(220,38,38,0.1); color: #dc2626; }
    .sticky-note-del:hover { background: #dc2626; color: white; }

    /* ═══ Markmap ═══ */
    .markmap { position: relative; }
    .markmap > svg { width: 100%; height: 420px; }
    [data-theme="light"] .markmap > svg { color: #202124; }

    /* ═══ AI Chat ═══ */
    .ai-msg {
      padding: 8px 12px; border-radius: 14px; font-size: 13px;
      line-height: 1.5; max-width: 88%; word-break: break-word;
      white-space: pre-wrap;
    }
    .ai-msg-system {
      background: var(--surface); color: var(--text3); font-size: 11px;
      text-align: center; align-self: center; border-radius: 10px;
      max-width: 100%;
    }
    .ai-msg-user {
      background: var(--accent); color: white; align-self: flex-end;
      border-bottom-right-radius: 4px;
    }
    .ai-msg-ai {
      background: var(--surface2); color: var(--text1); align-self: flex-start;
      border-bottom-left-radius: 4px; border: 1px solid var(--border);
    }
    .ai-msg-cost {
      font-size: 9px; color: var(--text3); text-align: right; margin-top: 2px;
    }
    .ai-typing {
      display: inline-flex; gap: 4px; padding: 10px 16px; align-self: flex-start;
      background: var(--surface2); border-radius: 14px;
    }
    .ai-typing span {
      width: 6px; height: 6px; border-radius: 50%; background: var(--text3);
      animation: aiDot 1.2s infinite;
    }
    .ai-typing span:nth-child(2) { animation-delay: 0.2s; }
    .ai-typing span:nth-child(3) { animation-delay: 0.4s; }
    @keyframes aiDot {
      0%, 60%, 100% { opacity: 0.3; transform: translateY(0); }
      30% { opacity: 1; transform: translateY(-4px); }
    }

/* ═══════════════ AI CHAT ═══════════════ */
.ai-chat-card {
  margin-top: 10px;
  background: var(--surface);
  border-radius: var(--radius);
  border: 1px solid var(--border);
  box-shadow: 0 2px 8px rgba(0,0,0,0.15);
  overflow: hidden;
}
.ai-chat-header {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 14px;
  background: var(--accent);
  cursor: pointer;
  user-select: none;
}
.ai-chat-avatar {
  width: 32px; height: 32px;
  border-radius: 50%;
  background: rgba(255,255,255,0.2);
  color: white;
  font-weight: 700;
  font-size: 14px;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}
.ai-chat-name {
  color: white;
  font-size: 13px;
  font-weight: 700;
}
.ai-chat-status {
  color: rgba(255,255,255,0.6);
  font-size: 10px;
}
.ai-chat-arrow {
  color: rgba(255,255,255,0.5);
  font-size: 14px;
  transition: transform 0.2s;
}
.ai-chat-fs-btn {
  background: rgba(255,255,255,0.15);
  border: none;
  color: white;
  font-size: 14px;
  width: 28px; height: 28px;
  border-radius: 50%;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}

/* Messages area */
.ai-chat-msgs {
  max-height: 350px;
  overflow-y: auto;
  padding: 12px;
  display: flex;
  flex-direction: column;
  gap: 10px;
  background: var(--bg);
}
.ai-msg {
  font-size: 13px;
  line-height: 1.5;
  padding: 10px 14px;
  border-radius: 16px;
  max-width: 88%;
  word-wrap: break-word;
  white-space: pre-wrap;
}
.ai-msg-system {
  background: var(--surface2);
  color: var(--text2);
  font-size: 12px;
  align-self: center;
  text-align: center;
  border-radius: 12px;
  padding: 8px 16px;
  max-width: 95%;
}
.ai-msg-user {
  background: var(--accent);
  color: white;
  align-self: flex-end;
  border-bottom-right-radius: 4px;
}
.ai-msg-ai {
  background: var(--surface);
  color: var(--text);
  border: 1px solid var(--border);
  align-self: flex-start;
  border-bottom-left-radius: 4px;
}

/* Input area */
.ai-chat-input-area {
  display: flex;
  gap: 8px;
  padding: 10px 12px;
  border-top: 1px solid var(--border);
  background: var(--surface);
}
.ai-chat-input {
  flex: 1;
  padding: 10px 16px;
  border-radius: 24px;
  border: 1px solid var(--border);
  background: var(--surface2);
  color: var(--text);
  font-size: 13px;
  outline: none;
  transition: border-color 0.2s;
}
.ai-chat-input:focus {
  border-color: var(--accent);
}
.ai-chat-send {
  width: 40px; height: 40px;
  border-radius: 50%;
  background: var(--accent);
  color: white;
  border: none;
  font-size: 16px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  transition: opacity 0.2s;
}
.ai-chat-send:active { opacity: 0.7; }

/* Typing animation */
.ai-typing {
  display: flex;
  gap: 4px;
  padding: 10px 14px;
  align-self: flex-start;
}
.ai-typing span {
  width: 8px; height: 8px;
  border-radius: 50%;
  background: var(--text3);
  animation: aiDot 1.2s infinite;
}
.ai-typing span:nth-child(2) { animation-delay: 0.2s; }
.ai-typing span:nth-child(3) { animation-delay: 0.4s; }
@keyframes aiDot {
  0%, 80%, 100% { opacity: 0.3; transform: scale(0.8); }
  40% { opacity: 1; transform: scale(1.1); }
}

/* ═══════════════ FULLSCREEN ═══════════════ */
.ai-fullscreen {
  position: fixed !important;
  top: 0 !important; left: 0 !important; right: 0 !important; bottom: 0 !important;
  width: 100vw !important;
  height: 100vh !important;
  max-height: 100vh !important;
  z-index: 99999 !important;
  border-radius: 0 !important;
  border: none !important;
  margin: 0 !important;
  padding: 0 !important;
  background: var(--bg) !important;
  display: flex !important;
  flex-direction: column !important;
}
.ai-fullscreen .ai-chat-header {
  border-radius: 0 !important;
}
.ai-fullscreen .markmap {
  height: 100vh !important;
}
/* Fullscreen close button - Top Left for Telegram Mini App compatibility */
.ai-fs-close {
  position: fixed;
  top: 12px; left: 12px; right: auto;
  z-index: 100000;
  height: 38px;
  padding: 0 16px;
  border-radius: 20px;
  background: rgba(15, 23, 42, 0.88);
  color: #ffffff;
  border: 1px solid rgba(255, 255, 255, 0.25);
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  display: flex;
  align-items: center;
  gap: 6px;
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
  box-shadow: 0 4px 16px rgba(0,0,0,0.35);
  transition: transform 0.15s ease, background 0.15s ease;
}
.ai-fs-close:active {
  transform: scale(0.95);
}
/* Chat in fullscreen */
.ai-fullscreen .ai-chat-msgs {
  max-height: none !important;
  flex: 1 !important;
  height: 0 !important;
  width: 100% !important;
  box-sizing: border-box;
}
.ai-fullscreen .ai-chat-body {
  display: flex !important;
  flex-direction: column !important;
  flex: 1 !important;
  height: 0 !important;
  width: 100% !important;
  box-sizing: border-box;
}
.ai-fullscreen .ai-chat-input-area {
  padding: 12px 16px;
  width: 100% !important;
  box-sizing: border-box;
}

/* Chat Tab Fullscreen Styles */
#chatTab.ai-fullscreen {
  box-sizing: border-box;
}
#chatTab.ai-fullscreen .chat-container {
  flex: 1 !important;
  height: calc(100vh - 48px) !important;
  max-width: 600px;
  margin: 0 auto;
  width: 100%;
}
#chatTab.ai-fullscreen .form-card-header {
  border-radius: 0;
  max-width: 600px;
  margin: 0 auto;
  width: 100%;
  border-bottom: 1px solid var(--border);
}

@media (min-width: 601px) {
  #detailView {
    position: relative;
  }
  #chatTab.ai-fullscreen {
    position: fixed !important;
    top: 0 !important; left: 0 !important; right: 0 !important; bottom: 0 !important;
    width: 100vw !important;
    height: 100vh !important;
    max-height: 100vh !important;
    z-index: 99999 !important;
    border-radius: 0 !important;
    border: none !important;
    margin: 0 !important;
    padding: 0 !important;
    box-sizing: border-box;
    background: var(--bg) !important;
    display: flex !important;
    flex-direction: column !important;
  }
  #chatTab.ai-fullscreen .chat-container {
    flex: 1 !important;
    height: calc(100vh - 48px) !important;
    max-width: 800px !important;
    margin: 0 auto !important;
    width: 100% !important;
  }
  #chatTab.ai-fullscreen .form-card-header {
    border-radius: 0 !important;
    max-width: 800px !important;
    margin: 0 auto !important;
    width: 100% !important;
    border-bottom: 1px solid var(--border) !important;
  }
}

/* ═══════════════ NOTIFICATION BELL ═══════════════ */
.notif-bell {
  width: 32px; height: 32px; border-radius: 50%;
  border: 1px solid rgba(255,255,255,0.3);
  background: rgba(255,255,255,0.15);
  color: white; font-size: 16px; cursor: pointer;
  display: flex; align-items: center; justify-content: center;
  position: relative; transition: all 0.2s; flex-shrink: 0;
}
.notif-bell:active { transform: scale(0.9); }
.notif-badge {
  position: absolute; top: -4px; right: -4px;
  min-width: 16px; height: 16px; padding: 0 4px;
  border-radius: 8px; background: #ef4444;
  color: white; font-size: 9px; font-weight: 700;
  display: flex; align-items: center; justify-content: center;
  border: 2px solid var(--surface);
  animation: notifPulse 2s infinite;
}
@keyframes notifPulse { 0%,80%,100%{transform:scale(1)} 40%{transform:scale(1.15)} }

/* ═══════════════ NOTIFICATION PANEL ═══════════════ */
.notif-panel {
  position: fixed; top: 0; right: -100%; width: 100%; max-width: 380px;
  height: 100vh; background: var(--surface); z-index: 600;
  box-shadow: -4px 0 24px rgba(0,0,0,0.3);
  transition: right 0.3s ease; display: flex; flex-direction: column;
  padding-top: 0; /* Default compact for mobile / small desktop */
}
.notif-panel.open { right: 0; }
.notif-panel-header {
  display: flex; justify-content: space-between; align-items: center;
  padding: 16px 16px 12px; border-bottom: 1px solid var(--border);
  font-size: 15px; font-weight: 700;
}
.notif-panel-body {
  flex: 1; overflow-y: auto; padding: 8px 0;
}
.notif-item {
  display: flex; gap: 10px; padding: 12px 16px;
  border-bottom: 1px solid var(--border);
  cursor: pointer; transition: background 0.15s;
}
.notif-item:hover { background: var(--surface2); }
.notif-item.notif-unread { background: color-mix(in srgb, var(--accent) 6%, transparent); border-left: 3px solid var(--accent); }
.notif-icon { font-size: 20px; flex-shrink: 0; width: 28px; text-align: center; }
.notif-content { flex: 1; min-width: 0; }
.notif-title { font-size: 13px; font-weight: 600; margin-bottom: 2px; }
.notif-body { font-size: 12px; color: var(--text2); margin-bottom: 2px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.notif-time { font-size: 11px; color: var(--text3); }

/* ═══════════════ CALENDAR ═══════════════ */
.cal-grid {
  display: grid; grid-template-columns: repeat(7, 1fr); gap: 2px;
  background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--radius-sm); overflow: hidden;
}
.cal-header {
  padding: 8px 0; text-align: center;
  font-size: 11px; font-weight: 700; color: var(--text3);
  background: var(--surface2);
}
.cal-cell {
  min-height: 52px; display: flex; flex-direction: column;
  align-items: flex-start; justify-content: flex-start;
  padding: 4px 3px 3px;
  cursor: pointer; transition: background 0.15s;
  background: var(--surface); position: relative; overflow: hidden;
}
.cal-cell:hover { background: var(--surface2); }
.cal-empty { background: var(--surface2); opacity: 0.3; cursor: default; }
.cal-today {
  background: color-mix(in srgb, var(--accent) 10%, transparent) !important;
  border: 2px solid var(--accent) !important;
  border-radius: 8px;
  z-index: 1;
  box-shadow: 0 0 8px color-mix(in srgb, var(--accent) 25%, transparent);
}
.cal-today .cal-day-num {
  background: var(--accent); color: white !important;
  border-radius: 50%; width: 24px; height: 24px;
  display: flex; align-items: center; justify-content: center;
  font-weight: 800; font-size: 13px;
  box-shadow: 0 0 0 3px color-mix(in srgb, var(--accent) 30%, transparent);
}
.cal-selected { background: color-mix(in srgb, var(--accent) 12%, transparent) !important; }
.cal-day-num { font-size: 12px; font-weight: 500; color: var(--text); margin-bottom: 2px; flex-shrink: 0; }

/* Calendar event cards */
.cal-event-card {
  display: flex; align-items: stretch; gap: 0;
  background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--radius-sm); margin-bottom: 8px;
  overflow: hidden; cursor: pointer; transition: border-color 0.2s;
  position: relative;
}
.cal-event-card:hover { border-color: var(--accent); }
.cal-event-bar { width: 4px; flex-shrink: 0; }
.cal-event-body { flex: 1; padding: 10px 12px; min-width: 0; }
.cal-event-title { font-size: 13px; font-weight: 600; margin-bottom: 4px; }
.cal-event-meta { display: flex; gap: 10px; font-size: 11px; color: var(--text2); flex-wrap: wrap; }
.cal-event-type { font-weight: 600; }
.cal-event-desc { font-size: 12px; color: var(--text3); margin-top: 4px; }
.cal-event-del {
  position: absolute; top: 6px; right: 6px;
  background: none; border: none; color: var(--text3);
  font-size: 16px; cursor: pointer; opacity: 0; transition: opacity 0.2s;
}
.cal-event-card:hover .cal-event-del { opacity: 1; }
.cal-event-del:hover { color: var(--red); }

/* ═══════════════ PRIORITY ═══════════════ */
.priority-group {
  background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--radius-sm); margin-bottom: 12px; overflow: hidden;
}
.priority-group-header {
  display: flex; justify-content: space-between; align-items: center;
  padding: 10px 14px; background: var(--surface2);
  border-bottom: 1px solid var(--border);
  font-size: 13px; font-weight: 700;
}
.priority-count {
  background: var(--accent); color: white; font-size: 11px;
  font-weight: 700; padding: 2px 8px; border-radius: 10px;
}
.priority-item {
  display: flex; align-items: center; gap: 10px;
  padding: 10px 14px; border-bottom: 1px solid var(--border);
  cursor: pointer; transition: background 0.15s;
}
.priority-item:last-child { border-bottom: none; }
.priority-item:hover { background: var(--surface2); }
.priority-item.priority-seen { opacity: 0.6; }
.priority-item-main { flex: 1; min-width: 0; }
.priority-item-name { font-size: 13px; font-weight: 600; }
.priority-item-meta { font-size: 11px; color: var(--text2); margin-top: 2px; }
.priority-seen-btn {
  background: none; border: 1px solid var(--border);
  border-radius: 6px; padding: 4px 8px; font-size: 12px;
  cursor: pointer; transition: all 0.2s; color: var(--text2);
}
.priority-seen-btn:hover { border-color: var(--accent); color: var(--accent); }
.priority-item-dot {
  width: 8px; height: 8px; border-radius: 50%; flex-shrink: 0;
}
.priority-item.priority-unseen {
  background: color-mix(in srgb, var(--accent) 5%, transparent);
  border-left: 3px solid var(--accent);
}
.priority-item.priority-overdue {
  background: color-mix(in srgb, #ef4444 8%, transparent);
}
.priority-item.priority-overdue .priority-item-meta { color: #ef4444; font-weight: 600; }

/* ═══════════════ NOTIFICATION TOGGLE SWITCH ═══════════════ */
.notif-toggle { position: relative; display: inline-block; width: 40px; height: 22px; cursor: pointer; }
.notif-toggle input { opacity: 0; width: 0; height: 0; }
.notif-toggle-slider {
  position: absolute; inset: 0; border-radius: 22px;
  background: var(--border); transition: background 0.2s;
}
.notif-toggle-slider::before {
  content: ''; position: absolute; width: 16px; height: 16px;
  border-radius: 50%; background: white; left: 3px; top: 3px;
  transition: transform 0.2s; box-shadow: 0 1px 3px rgba(0,0,0,0.3);
}
.notif-toggle input:checked + .notif-toggle-slider { background: var(--accent); }
.notif-toggle input:checked + .notif-toggle-chat { background: var(--green); }
.notif-toggle input:checked + .notif-toggle-slider::before { transform: translateX(18px); }
/* Notification unread dot */
.notif-dot {
  width: 8px; height: 8px; border-radius: 50%; background: var(--accent);
  flex-shrink: 0; align-self: center; margin-left: auto;
}

/* ═══════════════ PIN LOCK SYSTEM ═══════════════ */
#pinLockOverlay {
  position: fixed; inset: 0; z-index: 99999;
  background: linear-gradient(160deg, #0f0f1a 0%, #1a1035 40%, #0d1b2a 100%);
  display: flex; align-items: center; justify-content: center;
  animation: pinFadeIn 0.3s ease-out;
}
[data-theme="light"] #pinLockOverlay {
  background: linear-gradient(160deg, #e8eaf6 0%, #c5cae9 40%, #bbdefb 100%);
}
.pin-lock-container {
  text-align: center; padding: 24px 20px; width: 100%; max-width: 340px;
}
.pin-lock-icon {
  font-size: 48px; margin-bottom: 12px;
  animation: pinBounce 1.5s ease-in-out infinite;
}
.pin-lock-title {
  font-size: 22px; font-weight: 800; color: #fff; margin-bottom: 4px;
  letter-spacing: 0.5px;
}
[data-theme="light"] .pin-lock-title { color: #1a237e; }
.pin-lock-subtitle {
  font-size: 13px; color: rgba(255,255,255,0.5); margin-bottom: 28px;
}
[data-theme="light"] .pin-lock-subtitle { color: rgba(26,35,126,0.5); }

/* PIN Dots */
.pin-dots {
  display: flex; justify-content: center; gap: 14px; margin-bottom: 12px;
}
.pin-dot {
  width: 16px; height: 16px; border-radius: 50%;
  border: 2px solid rgba(255,255,255,0.3);
  background: transparent;
  transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
}
[data-theme="light"] .pin-dot { border-color: rgba(26,35,126,0.3); }
.pin-dot.filled {
  background: var(--accent); border-color: var(--accent);
  transform: scale(1.15);
  box-shadow: 0 0 12px rgba(124,106,247,0.5);
}

/* PIN Error */
.pin-error {
  font-size: 13px; color: #ef4444; min-height: 20px; margin-bottom: 8px;
  font-weight: 600;
}

/* PIN Keypad */
.pin-keypad {
  display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px;
  max-width: 280px; margin: 0 auto;
}
.pin-key {
  width: 68px; height: 68px; border-radius: 50%;
  background: rgba(255,255,255,0.08);
  border: 1px solid rgba(255,255,255,0.12);
  color: #fff; font-size: 26px; font-weight: 600;
  display: flex; align-items: center; justify-content: center;
  cursor: pointer; transition: all 0.15s;
  user-select: none; -webkit-user-select: none;
  margin: 0 auto;
  backdrop-filter: blur(4px);
}
[data-theme="light"] .pin-key {
  background: rgba(26,35,126,0.06);
  border-color: rgba(26,35,126,0.15);
  color: #1a237e;
}
.pin-key:active {
  background: rgba(124,106,247,0.35);
  transform: scale(0.92);
  border-color: var(--accent);
}
.pin-key.del {
  font-size: 22px;
  background: rgba(248,113,113,0.1);
  border-color: rgba(248,113,113,0.2);
}
.pin-key.del:active {
  background: rgba(248,113,113,0.3);
}
.pin-key.empty {
  background: transparent; border: none; cursor: default;
}

/* PIN Animations */
@keyframes pinFadeIn {
  from { opacity: 0; }
  to { opacity: 1; }
}
@keyframes pinUnlock {
  0% { opacity: 1; transform: scale(1); }
  50% { opacity: 0.5; transform: scale(1.05); }
  100% { opacity: 0; transform: scale(1.1); }
}
@keyframes pinShake {
  0%, 100% { transform: translateX(0); }
  15% { transform: translateX(-12px); }
  30% { transform: translateX(10px); }
  45% { transform: translateX(-8px); }
  60% { transform: translateX(6px); }
  75% { transform: translateX(-3px); }
}
@keyframes pinBounce {
  0%, 100% { transform: translateY(0); }
  50% { transform: translateY(-6px); }
}

/* PIN Toggle Switch (iOS-style) */
.pin-switch {
  position: relative; display: inline-block; width: 48px; height: 26px;
  flex-shrink: 0;
}
.pin-switch input { opacity: 0; width: 0; height: 0; }
.pin-slider {
  position: absolute; inset: 0; border-radius: 26px;
  background: var(--border); transition: background 0.3s;
  cursor: pointer;
}
.pin-slider::before {
  content: ''; position: absolute;
  width: 20px; height: 20px; border-radius: 50%;
  background: white; left: 3px; top: 3px;
  transition: transform 0.3s cubic-bezier(0.4, 0, 0.2, 1);
  box-shadow: 0 2px 6px rgba(0,0,0,0.25);
}
.pin-switch input:checked + .pin-slider {
  background: var(--green);
}
.pin-switch input:checked + .pin-slider::before {
  transform: translateX(22px);
}

/* ═══════════════ GUEST MODE (READ-ONLY) ═══════════════ */
.guest-mode .save-btn,
.guest-mode .add-record-btn,
.guest-mode .delete-profile-btn,
.guest-mode #deleteProfileBtn,
.guest-mode .record-delete,
.guest-mode .tl-btn-group,
.guest-mode .fab,
.guest-mode .sticky-note-actions,
.guest-mode .ai-chat-input-area,
.guest-mode #mmResetBtn {
  display: none !important;
}

.guest-mode input,
.guest-mode textarea,
.guest-mode select {
  pointer-events: none !important;
  background: transparent !important;
  border-color: transparent !important;
  color: var(--text) !important;
  appearance: none; -webkit-appearance: none; -moz-appearance: none;
}

/* ═══════════════ PERSONAL NOTES ═══════════════ */
.pnote-card {
  border-radius: 8px; padding: 0; margin-bottom: 10px;
  box-shadow: 2px 3px 10px rgba(0,0,0,0.07);
  border: 1px solid; position: relative;
  transition: transform 0.15s, box-shadow 0.15s;
  cursor: pointer; overflow: hidden;
}
.pnote-card:hover { transform: translateY(-1px); box-shadow: 2px 4px 14px rgba(0,0,0,0.12); }
.pnote-header {
  display: flex; justify-content: space-between; align-items: center;
  padding: 10px 12px; gap: 8px;
}
.pnote-title-row { display: flex; align-items: center; gap: 6px; flex: 1; min-width: 0; }
.pnote-title {
  font-weight: 700; font-size: 13px;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.pnote-time { font-size: 10px; white-space: nowrap; flex-shrink: 0; }
.pnote-body {
  padding: 0 12px 8px; font-size: 12px;
  line-height: 1.5; white-space: pre-wrap; word-break: break-word;
}
.pnote-preview { max-height: 60px; overflow: hidden; }
.pnote-full { max-height: 400px; overflow-y: auto; }
.pnote-footer {
  display: flex; align-items: center; justify-content: space-between;
  padding: 4px 8px 8px; gap: 6px;
}
.pnote-badges { display: flex; gap: 4px; flex-wrap: wrap; flex: 1; min-width: 0; }
.pnote-actions {
  display: flex; gap: 2px; flex-shrink: 0;
  opacity: 0; transition: opacity 0.2s;
}
.pnote-card:hover .pnote-actions { opacity: 1; }
.pnote-actions button {
  width: 28px; height: 28px; border-radius: 50%; border: none;
  background: rgba(0,0,0,0.06); font-size: 13px; cursor: pointer;
  display: flex; align-items: center; justify-content: center;
  transition: all 0.15s;
}
.pnote-actions button:hover { background: rgba(0,0,0,0.12); transform: scale(1.1); }

/* Color picker in modal */
.pnote-color-opt { transition: transform 0.15s, border-color 0.15s; }
.pnote-color-opt:hover { transform: scale(1.15); }
.pnote-color-opt.selected { border-color: var(--accent) !important; transform: scale(1.1); box-shadow: 0 0 0 2px rgba(124,106,247,0.3); }

/* Guest mode: hide note write actions */
.guest-mode .pnote-actions,
.guest-mode #notesFilterChips button { display: none !important; }

/* ═══════════════ NOTES BOARD (Desktop sticky board) ═══════════════ */
.notes-board {
  position: relative;
  min-height: 500px;
  overflow: auto;
}

.board-note {
  position: absolute;
  border: 1.5px solid;
  border-radius: 8px;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  box-shadow: 1px 2px 8px rgba(0,0,0,0.10);
  cursor: default;
}
.board-note:hover {
  box-shadow: 2px 4px 14px rgba(0,0,0,0.16);
}
.board-note-dragging {
  box-shadow: 4px 8px 24px rgba(0,0,0,0.25) !important;
  opacity: 0.92;
}

.board-note-header {
  padding: 6px 8px;
  font-size: 11px;
  font-weight: 700;
  cursor: grab;
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 4px;
  user-select: none;
  border-bottom: 1px solid rgba(0,0,0,0.06);
  flex-shrink: 0;
}
.board-note-dragging .board-note-header { cursor: grabbing; }
.board-note-title {
  flex: 1;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.board-note-time {
  font-size: 9px;
  font-weight: 500;
  white-space: nowrap;
  flex-shrink: 0;
}

.board-note-body {
  flex: 1;
  padding: 6px 8px;
  font-size: 11px;
  line-height: 1.5;
  overflow: hidden;
  cursor: pointer;
  word-break: break-word;
  min-height: 0;
}
.board-note-content {
  white-space: pre-wrap;
}

/* Footer: badges + actions */
.board-note-footer {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 3px 6px 4px;
  flex-shrink: 0;
  gap: 4px;
  flex-wrap: wrap;
}
.board-note-badges {
  display: flex;
  gap: 4px;
  flex-wrap: wrap;
  min-width: 0;
}
.board-badge {
  font-size: 9px;
  padding: 1px 5px;
  border-radius: 6px;
  background: rgba(0,0,0,0.06);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  max-width: 120px;
}
.board-badge-link {
  cursor: pointer;
  text-decoration: underline;
}
.board-badge-link:hover {
  background: rgba(0,0,0,0.12);
}

.board-note-actions {
  display: flex;
  gap: 2px;
  flex-shrink: 0;
}
.board-note-actions button {
  background: none;
  border: none;
  font-size: 12px;
  cursor: pointer;
  padding: 2px 3px;
  border-radius: 4px;
  transition: background 0.15s;
}
.board-note-actions button:hover { background: rgba(0,0,0,0.1); }

/* Resize handle */
.board-note-resize {
  position: absolute;
  right: 0; bottom: 0;
  width: 14px; height: 14px;
  cursor: nwse-resize;
  background: linear-gradient(135deg, transparent 50%, rgba(0,0,0,0.15) 50%);
  border-radius: 0 0 6px 0;
}

/* Expanded note */
.board-note-expanded {
  z-index: 100;
  box-shadow: 4px 8px 30px rgba(0,0,0,0.3);
  transition: width 0.25s ease, height 0.25s ease, min-height 0.25s ease;
}
.board-note-expanded .board-note-body {
  overflow-y: auto;
}

/* Collapse animation */
.board-note-collapsing {
  transition: width 0.25s ease, height 0.25s ease, min-height 0.25s ease;
}

/* ── Vertical divider for stacked tabs in same panel ── */
.panel-vdivider {
  height: 5px;
  cursor: row-resize;
  background: transparent;
  flex-shrink: 0;
  position: relative;
  transition: background 0.2s;
}
.panel-vdivider:hover,
.panel-vdivider.dragging {
  background: var(--accent);
  opacity: 0.5;
}

/* ═══════════════ PHASE 2: DESKTOP & WIDE CONTENT ═══════════════ */
@media (min-width: 640px) {
  /* Wider content limit */
  .content { 
    max-width: 900px !important; 
    padding: 24px; 
    transition: max-width 0.3s;
  }
  
  /* 2-col layout for lists without changing JS — uses auto-fill so narrow containers get 1 col */
  #profileList, 
  #staffList, 
  #notesPanelList, 
  #dashMyList, 
  #dashHapjaList,
  #tvList,
  #bbList,
  #calEventList {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(260px, 1fr));
    gap: 12px;
  }
  /* Timeline is NOT a card grid — keep single column */
  #timelineList {
    display: block;
  }
  
  /* Reset margins for cards inside grids */
  #profileList .profile-card,
  #staffList .staff-card,
  #notesPanelList .pnote-card,
  #dashMyList .profile-card,
  #dashHapjaList .pnote-card {
    margin-bottom: 0;
  }

  /* Priority list handling */
  .priority-group {
    display: grid !important;
    grid-template-columns: repeat(2, 1fr);
    gap: 0;
    column-gap: 12px;
    padding: 0 12px 12px 12px;
  }
  .priority-group-header {
    grid-column: 1 / -1;
    margin: 0 -12px 10px -12px;
  }
  .priority-item {
    border: 1px solid var(--border) !important;
    border-radius: var(--radius-sm);
    margin-bottom: 6px;
  }
  .priority-item:last-child {
    border-bottom: 1px solid var(--border);
  }
}

@media (min-width: 1024px) {
  /* Center modals for large desktop */
  .modal-overlay {
    align-items: center;
    justify-content: center;
    padding: 40px;
  }
  
  .modal {
    border-radius: 20px; /* Full border radius instead of just top */
    max-width: 600px;
    max-height: 85vh;
    margin: auto;
    animation: zoomIn 0.3s ease-out;
  }
  
  .modal-handle {
    display: none; /* Hide drag handle on desktop */
  }
}



@keyframes zoomIn {
  from { opacity: 0; transform: scale(0.95); }
  to { opacity: 1; transform: scale(1); }
}

/* ═══ COMPACT TAB MODE (mobile & narrow screens) ═══ */
.tab-bar.tab-bar--compact {
  flex-wrap: wrap;
  padding: 4px 6px;
  gap: 3px;
  justify-content: center;
  overflow-x: hidden;
}
.tab-bar.tab-bar--compact .tab {
  flex: 0 1 auto;
  padding: 5px 7px;
  font-size: 10px;
  gap: 3px;
  min-width: 0;
  white-space: nowrap;
  border-radius: 16px;
}
.tab-bar.tab-bar--compact .tab-icon {
  font-size: 12px;
}
.tab-bar.tab-bar--compact .tab-label {
  display: inline;
  font-size: 10px;
  overflow: hidden;
  text-overflow: ellipsis;
  max-width: 50px;
}
/* Micro-Animations & Premium UX (Spring Mechanics) */
@keyframes springFadeUp {
  0% { opacity: 0; transform: translateY(20px) scale(0.96); }
  100% { opacity: 1; transform: translateY(0) scale(1); }
}
.stagger-item, .tree-node, .staff-card, .profile-card, .dash-card, .dash-stat { animation: springFadeUp 0.35s cubic-bezier(0.175, 0.885, 0.32, 1.15) both; }
.tree-node, .staff-card { border-left: 2px solid transparent; transition: border-color 0.3s; }

/* Apply staggered delay to list items using a small JS trick or CSS nth-child */
.stagger-item:nth-child(1), .tree-node:nth-child(1), .staff-card:nth-child(1) { animation-delay: 0.04s; }
.stagger-item:nth-child(2), .tree-node:nth-child(2), .staff-card:nth-child(2) { animation-delay: 0.08s; }
.stagger-item:nth-child(3), .tree-node:nth-child(3), .staff-card:nth-child(3) { animation-delay: 0.12s; }
.stagger-item:nth-child(4), .tree-node:nth-child(4), .staff-card:nth-child(4) { animation-delay: 0.16s; }
.stagger-item:nth-child(5), .tree-node:nth-child(5), .staff-card:nth-child(5) { animation-delay: 0.20s; }
.stagger-item:nth-child(1n+6), .tree-node:nth-child(1n+6), .staff-card:nth-child(1n+6) { animation-delay: 0.24s; }

@keyframes tabSlideIn {
  0% { opacity: 0; transform: perspective(500px) translate3d(0, 15px, -20px); filter: blur(2px); }
  100% { opacity: 1; transform: perspective(500px) translate3d(0,0,0); filter: blur(0); }
}
.tab-content-enter { animation: tabSlideIn 0.5s cubic-bezier(0.175, 0.885, 0.32, 1.1) forwards; }

/* Button ripple effect */
.add-record-btn, .button, .form-btn, .tab, .fab { overflow: hidden; }
/* Only apply relative to non-fixed elements */
.add-record-btn, .button, .form-btn, .tab { position: relative; }
.add-record-btn::after, .button::after, .fab::after, .form-btn::after, .tab::after {
  content: ""; display: block; position: absolute; width: 100%; height: 100%;
  top: 0; left: 0; pointer-events: none;
  background-image: radial-gradient(circle, #fff 10%, transparent 10.01%);
  background-repeat: no-repeat; background-position: 50%; transform: scale(10, 10);
  opacity: 0; transition: transform .6s, opacity 1s; z-index: 10;
}
.add-record-btn:active::after, .button:active::after, .fab:active::after, .form-btn:active::after, .tab:active::after { transform: scale(0, 0); opacity: .2; transition: 0s; }

/* ═══════════════ MOTION SYSTEM ═══════════════ */

/* Tabs must sit above ghost indicator */
.tab, .form-tab, .dash-mode-btn {
  position: relative;
  z-index: 1;
}

/* ── Tab Ghost (sliding highlight during tab switch) ── */
.tab-ghost {
  position: absolute;
  pointer-events: none;
  z-index: 0;
  background: var(--accent);
  opacity: 0;
  border-radius: 20px;
  box-shadow: 0 0 20px var(--fab-shadow);
}
.form-tabs .tab-ghost {
  border-radius: 8px;
  box-shadow: none;
}

/* ── Swipe container ── */
#mainContent {
  touch-action: pan-y;
}

/* ═══════════════ ALARM OVERLAY ═══════════════ */
.alarm-overlay {
  position: fixed; inset: 0; z-index: 99998;
  display: flex; align-items: center; justify-content: center; flex-direction: column;
  background: rgba(0,0,0,0.7);
  backdrop-filter: blur(8px); -webkit-backdrop-filter: blur(8px);
  animation: alarmFadeIn 0.3s ease;
}
@keyframes alarmFadeIn { from { opacity: 0; } to { opacity: 1; } }
@keyframes alarmFadeOut { from { opacity: 1; } to { opacity: 0; } }

.alarm-card {
  background: linear-gradient(135deg, #1e1b4b 0%, #312e81 40%, #4338ca 100%);
  border: 2px solid rgba(167,139,250,0.5);
  border-radius: 24px; padding: 32px 28px; text-align: center;
  max-width: 340px; width: 90%;
  box-shadow: 0 16px 64px rgba(99,102,241,0.5), 0 0 80px rgba(139,92,246,0.25);
  animation: alarmBounceIn 0.5s cubic-bezier(0.34, 1.56, 0.64, 1);
}
@keyframes alarmBounceIn {
  0% { opacity: 0; transform: scale(0.5) translateY(40px); }
  60% { transform: scale(1.05) translateY(-5px); }
  100% { opacity: 1; transform: scale(1) translateY(0); }
}

.alarm-bell {
  font-size: 64px; line-height: 1;
  animation: alarmRing 0.5s ease-in-out infinite alternate;
  display: inline-block; margin-bottom: 12px;
  filter: drop-shadow(0 0 16px rgba(251,191,36,0.6));
}
@keyframes alarmRing {
  0% { transform: rotate(-12deg) scale(1); }
  50% { transform: rotate(12deg) scale(1.1); }
  100% { transform: rotate(-12deg) scale(1); }
}

.alarm-pulse-ring {
  position: absolute; width: 120px; height: 120px; border-radius: 50%;
  border: 3px solid rgba(251,191,36,0.4);
  animation: alarmPulseRing 1.5s ease-out infinite;
  top: 50%; left: 50%; transform: translate(-50%, -50%);
  pointer-events: none;
}
@keyframes alarmPulseRing {
  0% { width: 80px; height: 80px; opacity: 1; }
  100% { width: 200px; height: 200px; opacity: 0; }
}

.alarm-title {
  font-size: 20px; font-weight: 800; color: #fff; margin: 8px 0 6px;
  text-shadow: 0 2px 8px rgba(0,0,0,0.3);
}
.alarm-subtitle {
  font-size: 14px; color: rgba(255,255,255,0.8); margin-bottom: 8px;
  font-weight: 500;
}
.alarm-time-badge {
  display: inline-block; padding: 4px 14px; border-radius: 20px;
  background: rgba(251,191,36,0.2); border: 1px solid rgba(251,191,36,0.4);
  color: #fbbf24; font-size: 13px; font-weight: 700; margin-bottom: 16px;
}
.alarm-dismiss {
  padding: 12px 32px; border-radius: 30px; border: none;
  background: linear-gradient(135deg, #fbbf24, #f59e0b); color: #1e1b4b;
  font-size: 14px; font-weight: 700; cursor: pointer;
  box-shadow: 0 4px 16px rgba(251,191,36,0.4);
  transition: transform 0.15s, box-shadow 0.15s;
}
.alarm-dismiss:active { transform: scale(0.95); }
.alarm-countdown {
  font-size: 11px; color: rgba(255,255,255,0.5); margin-top: 12px;
}

/* Alarm icon on event cards */
.cal-event-alarm-btn {
  background: none; border: 1px solid var(--border); border-radius: 6px;
  padding: 2px 5px; font-size: 11px; cursor: pointer; color: var(--text2);
  transition: all 0.2s; flex-shrink: 0; line-height: 1;
}
.cal-event-alarm-btn:hover { border-color: #fbbf24; color: #fbbf24; }
.cal-event-alarm-btn.has-alarm { color: #fbbf24; border-color: #fbbf24; background: rgba(251,191,36,0.1); }

/* Edit event button */
.cal-event-edit-btn {
  background: none; border: 1px solid var(--border); border-radius: 6px;
  padding: 2px 5px; font-size: 11px; cursor: pointer; color: var(--text2);
  transition: all 0.2s; flex-shrink: 0; line-height: 1;
}
.cal-event-edit-btn:hover { border-color: var(--accent); color: var(--accent); }

/* Screen shake for alarm emphasis */
.alarm-shake { animation: alarmScreenShake 0.3s ease-in-out 2; }
@keyframes alarmScreenShake {
  0%, 100% { transform: translate(0); }
  20% { transform: translate(-3px, 2px); }
  40% { transform: translate(3px, -2px); }
  60% { transform: translate(-2px, 1px); }
  80% { transform: translate(2px, -1px); }
}

/* ── Reduced Motion ── */
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
  }
  .tab-ghost { display: none !important; }
}

/* ── Custom Combobox (replaces native datalist) ── */
.combo-wrap { position: relative; }
.combo-dropdown {
  position: absolute; top: 100%; left: 0; right: 0; z-index: 999;
  background: var(--surface, #fff); border: 1px solid var(--border, #ddd);
  border-radius: 0 0 10px 10px; max-height: 180px; overflow-y: auto;
  box-shadow: 0 6px 20px rgba(0,0,0,0.25); display: none;
}
.combo-dropdown.open { display: block; }
.combo-opt {
  padding: 10px 14px; font-size: 13px; cursor: pointer;
  color: var(--text, #333); border-bottom: 1px solid var(--border, #eee);
  transition: background 0.15s;
}
.combo-opt:last-child { border-bottom: none; }
.combo-opt:hover, .combo-opt:active { background: var(--accent, #7c6af7); color: #fff; }
.combo-opt mark { background: rgba(251,191,36,0.3); color: inherit; border-radius: 2px; }

/* ══════════════════════════════════════════════════════════════════════════
   STRATEGY BOARD — Chiến lược tiếp cận
   ══════════════════════════════════════════════════════════════════════ */
.cl-board { position: relative; }
.cl-header { text-align: center; margin-bottom: 12px; }
.cl-header-title { font-size: 15px; font-weight: 700; color: var(--text1); }
.cl-header-name { font-size: 12px; color: var(--text3); margin-top: 2px; }

/* Horizontal roadmap timeline */
.cl-roadmap {
  display: flex; align-items: center; justify-content: center;
  gap: 0; padding: 8px 4px 14px; overflow-x: auto;
  -webkit-overflow-scrolling: touch;
}
.cl-roadmap-node {
  display: flex; flex-direction: column; align-items: center; gap: 3px;
  cursor: pointer; flex-shrink: 0; padding: 4px 2px;
  transition: transform 0.2s;
}
.cl-roadmap-node:active { transform: scale(0.92); }
.cl-roadmap-node.active .cl-roadmap-icon { box-shadow: 0 0 0 3px var(--node-color), 0 0 12px rgba(0,0,0,0.15); transform: scale(1.15); }
.cl-roadmap-icon {
  width: 36px; height: 36px; border-radius: 50%;
  background: var(--surface2); border: 2px solid var(--node-color, var(--border));
  display: flex; align-items: center; justify-content: center;
  font-size: 16px; transition: all 0.25s;
}
.cl-roadmap-label { font-size: 9px; color: var(--text3); font-weight: 600; white-space: nowrap; }
.cl-roadmap-line {
  width: 20px; height: 2px; background: var(--border); flex-shrink: 0;
  margin: 0 -2px; margin-bottom: 16px;
}

/* Section cards */
.cl-section { margin-bottom: 8px; border-radius: var(--radius); overflow: hidden; border: 1px solid var(--border); }
.cl-section-header {
  display: flex; align-items: center; gap: 8px;
  padding: 10px 12px; cursor: pointer;
  background: var(--surface2); transition: background 0.15s;
}
.cl-section-header:active { background: var(--surface3, rgba(128,128,128,0.1)); }
.cl-section-icon {
  width: 28px; height: 28px; border-radius: 8px;
  display: flex; align-items: center; justify-content: center;
  font-size: 14px; color: white; flex-shrink: 0;
}
.cl-section-title { flex: 1; font-size: 13px; font-weight: 700; color: var(--text1); }
.cl-badge {
  font-size: 10px; font-weight: 700; padding: 2px 7px;
  border-radius: 10px; background: var(--accent); color: white;
}
.cl-section-arrow { font-size: 14px; color: var(--text3); transition: transform 0.25s; }

/* Section body */
.cl-section-body { padding: 10px 12px 14px; background: var(--bg); }
.cl-field { margin-bottom: 10px; }
.cl-field:last-child { margin-bottom: 0; }
.cl-field label {
  display: block; font-size: 11px; font-weight: 600;
  color: var(--text2); margin-bottom: 4px;
}
.cl-field input, .cl-field textarea {
  width: 100%; padding: 8px 10px; border: 1px solid var(--border);
  border-radius: var(--radius-sm); background: var(--surface2);
  color: var(--text1); font-size: 13px; font-family: inherit;
  transition: border-color 0.2s, box-shadow 0.2s;
  box-sizing: border-box;
}
.cl-field input:focus, .cl-field textarea:focus {
  outline: none; border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(124,106,247,0.12);
}
.cl-field textarea { min-height: 60px; resize: vertical; }
.cl-field input::placeholder, .cl-field textarea::placeholder {
  color: var(--text3); font-size: 11px; opacity: 0.7;
}

/* Action buttons */
.cl-actions {
  display: flex; gap: 8px; margin-top: 14px; padding-top: 12px;
  border-top: 1px solid var(--border);
}
.cl-btn {
  flex: 1; padding: 10px; border: none; border-radius: var(--radius-sm);
  font-size: 12px; font-weight: 700; cursor: pointer;
  display: flex; align-items: center; justify-content: center; gap: 4px;
  transition: all 0.15s;
}
.cl-btn-copy { background: var(--accent); color: white; }
.cl-btn-copy:active { transform: scale(0.97); }
.cl-btn-fullscreen { background: var(--surface2); color: var(--text2); border: 1px solid var(--border) !important; }
.cl-btn-fullscreen:active { transform: scale(0.97); }

/* Fullscreen mode */
.cl-fullscreen {
  position: fixed !important; top: 0; left: 0; right: 0; bottom: 0;
  z-index: 9998; background: var(--bg); overflow-y: auto;
  padding: 16px; padding-top: 50px;
  animation: clFadeIn 0.2s ease;
}
@keyframes clFadeIn { from { opacity: 0; } to { opacity: 1; } }

/* ══════════════════════════════════════════════════════════════════════════
   STRATEGY PITCH DECK (Story Mode)
   ══════════════════════════════════════════════════════════════════════ */
.pitch-deck-overlay {
  position: fixed; inset: 0; z-index: 10000;
  background: linear-gradient(135deg, #e0f2fe 0%, #bae6fd 100%);
  color: #0f172a;
  display: flex; flex-direction: column; overflow: hidden;
  font-family: 'Inter', sans-serif;
  animation: deckFadeIn 0.3s ease;
}
@keyframes deckFadeIn { from { opacity: 0; transform: scale(1.05); } to { opacity: 1; transform: scale(1); } }
@media (min-width: 1024px) {
  .pitch-deck-overlay { animation: none; contain: strict; }
}
.deck-close {
  position: absolute; top: 16px; left: 16px; z-index: 10002;
  background: rgba(0,0,0,0.08); border: none; color: #334155;
  width: 40px; height: 40px; border-radius: 50%; display: flex;
  align-items: center; justify-content: center; font-size: 20px; cursor: pointer;
  transition: background 0.15s;
}
.deck-close:hover { background: rgba(0,0,0,0.15); }
.ambient-blobs {
  position: absolute; inset: 0; z-index: 10000; pointer-events: none; overflow: hidden; opacity: 0.9;
}
.blob {
  position: absolute; border-radius: 50%; filter: blur(50px);
  animation: blobFloat 10s infinite alternate ease-in-out;
}
.blob-1 { width: 300px; height: 300px; background: #ffffff; top: -100px; left: -100px; animation-delay: 0s; }
.blob-2 { width: 250px; height: 250px; background: #7dd3fc; bottom: -50px; right: -100px; animation-delay: -5s; }
@keyframes blobFloat { 0% { transform: translate(0, 0) scale(1); } 100% { transform: translate(30px, 50px) scale(1.15); } }
@media (min-width: 1024px) {
  .ambient-blobs { opacity: 0.5; }
  .blob { filter: none; }
  .blob-1 { background: radial-gradient(circle, rgba(255,255,255,0.8) 0%, transparent 70%); }
  .blob-2 { background: radial-gradient(circle, rgba(125,211,252,0.6) 0%, transparent 70%); }
}

.deck-container {
  flex: 1; position: relative; z-index: 10001;
  display: flex; flex-direction: column; padding: 20px 16px 40px;
}
.deck-progress {
  display: flex; gap: 4px; margin-bottom: 24px; margin-top: 4px;
}
.deck-progress-bar {
  flex: 1; height: 4px; background: rgba(0,0,0,0.1); border-radius: 2px; overflow: hidden;
}
.deck-progress-fill {
  height: 100%; background: #0ea5e9; width: 0%;
  transition: width 0.3s ease;
}
.deck-slide-area {
  flex: 1; display: flex; align-items: center; justify-content: center; position: relative;
}

.deck-card {
  position: absolute; width: 100%; max-width: 400px;
  background: rgba(255, 255, 255, 0.65);
  backdrop-filter: blur(20px); -webkit-backdrop-filter: blur(20px);
  border: 1px solid rgba(255,255,255,0.9); border-radius: 24px;
  padding: 32px 24px; 
  box-shadow: 0 16px 32px rgba(14,165,233,0.15), inset 0 1px 0 rgba(255,255,255,1);
  transition: all 0.4s cubic-bezier(0.2, 0.8, 0.2, 1);
  opacity: 0; transform: translateX(50px) scale(0.95); pointer-events: none;
}
.deck-card.active {
  opacity: 1; transform: translateX(0) scale(1); pointer-events: auto; z-index: 2;
}
.deck-card.prev {
  transform: translateX(-50px) scale(0.95);
}
@media (min-width: 1024px) {
  .deck-card {
    background: rgba(255,255,255,0.92); backdrop-filter: none; -webkit-backdrop-filter: none;
    border-color: #e2e8f0; box-shadow: 0 8px 24px rgba(14,165,233,0.12);
    transition: opacity 0.3s ease, transform 0.3s ease;
    will-change: transform, opacity;
  }
}

.deck-card-header {
  display: flex; align-items: center; gap: 12px; margin-bottom: 24px;
}
.deck-card-icon {
  width: 44px; height: 44px; border-radius: 12px; display: flex;
  align-items: center; justify-content: center; font-size: 22px;
  background: rgba(255,255,255,0.8);
  border: 1px solid rgba(14,165,233,0.1);
  box-shadow: 0 4px 10px rgba(0,0,0,0.05);
}
.deck-card-title {
  font-size: 22px; font-weight: 800; color: #0f172a; text-transform: uppercase; letter-spacing: 1px;
}

.deck-field { margin-bottom: 16px; border-left: 3px solid rgba(14,165,233,0.4); padding-left: 14px; }
.deck-field label {
  display: block; font-size: 11px; font-weight: 700; color: #64748b; margin-bottom: 6px; text-transform: uppercase; letter-spacing: 0.5px;
}
.deck-field-val {
  font-size: 16px; color: #1e293b; line-height: 1.5; white-space: pre-wrap; font-weight: 500;
}
.deck-tool-badge {
  display: inline-block; padding: 8px 16px; background: linear-gradient(135deg, #0ea5e9 0%, #0284c7 100%);
  color: #fff; font-weight: 800; font-size: 15px; border-radius: 20px;
  box-shadow: 0 4px 15px rgba(14,165,233,0.3); margin-bottom: 6px;
  border: 1px solid rgba(255,255,255,0.3);
}

.deck-nav-hitbox {
  position: absolute; top: 0; bottom: 0; width: 40%; z-index: 10002;
}
.deck-nav-left { left: 0; }
.deck-nav-right { right: 0; }

/* ══════════════════════════════════════════════════════════════════════════
   PROFILE DISCUSSION (GROUP CHAT) SYSTEM
   ══════════════════════════════════════════════════════════════════════ */
.unread-chat-badge {
  font-size: 10px;
  font-weight: 700;
  padding: 2px 6px;
  border-radius: 6px;
  background: var(--red);
  color: white;
  margin-left: 4px;
  display: inline-block;
}

@keyframes pulse {
  0% { transform: scale(1); opacity: 1; }
  50% { transform: scale(1.05); opacity: 0.85; }
  100% { transform: scale(1); opacity: 1; }
}

.chat-container {
  background: var(--surface) !important;
  border-radius: var(--radius);
}

.chat-messages-area {
  background: var(--bg) !important;
  border: 1px solid var(--border) !important;
  border-radius: 12px !important;
  padding: 6px 10px !important;
  box-shadow: inset 0 2px 8px rgba(0,0,0,0.05);
  scrollbar-width: thin;
  display: flex !important;
  flex-direction: column !important;
  gap: 6px !important;
}
/* Push messages to bottom when few, without breaking scroll */
.chat-messages-area::before {
  content: '';
  flex: 1 1 auto;
}
/* Prevent children from stretching vertically */
.chat-messages-area > * {
  flex-shrink: 0 !important;
  flex-grow: 0 !important;
}
[data-theme="dark"] .chat-messages-area {
  background: #0d0d12 !important;
}

.chat-messages-area::-webkit-scrollbar {
  width: 5px;
}
.chat-messages-area::-webkit-scrollbar-thumb {
  background: var(--border);
  border-radius: 4px;
}

.chat-message-row {
  display: flex;
  gap: 6px;
  align-items: flex-start;
  width: 100%;
  max-width: 85%;
  margin-bottom: 1px;
  align-self: flex-start;
  height: fit-content !important;
  min-height: 0 !important;
  flex: 0 0 auto !important;
}

.chat-message-row--me {
  align-self: flex-end;
  flex-direction: row-reverse;
  width: 100%;
  max-width: 85%;
  height: fit-content !important;
  min-height: 0 !important;
  flex: 0 0 auto !important;
  align-items: flex-end;
}

.chat-message-avatar {
  flex-shrink: 0;
  margin-top: 1px;
}

.chat-message-content {
  display: flex;
  flex-direction: column;
  gap: 2px;
  min-width: 0;
  flex: 1 1 auto !important;
  align-items: flex-start;
  height: fit-content !important;
  min-height: 0 !important;
}

.chat-message-row--me .chat-message-content {
  align-items: flex-end;
}

.chat-message-sender {
  font-size: 10.5px;
  font-weight: 700;
  color: var(--text2);
  cursor: pointer;
  display: flex;
  align-items: center;
  gap: 4px;
  margin-left: 4px;
  margin-bottom: 0px;
}
.chat-message-sender:hover {
  color: var(--accent);
}

.chat-message-bubble {
  position: relative;
  background: var(--surface);
  color: var(--text);
  border: 1px solid var(--border);
  border-radius: 4px 14px 14px 14px;
  padding: 6px 12px;
  font-size: 13px;
  line-height: 1.45;
  box-shadow: 0 1px 1.5px rgba(0,0,0,0.08);
  word-break: normal !important;
  overflow-wrap: break-word !important;
  word-wrap: break-word !important;
  white-space: normal;
  transition: all 0.2s;
  box-sizing: border-box;
  align-self: flex-start;
  max-width: 100% !important; /* Constrain inside row max-width (85%) */
  min-width: 80px !important; /* Premium minimum width to align text and time beautifully */
  height: auto !important;
  min-height: 0 !important;
  flex: 0 0 auto !important;
}

.chat-message-bubble--me {
  background: #eeffde; /* Soft Telegram-style green for light theme */
  color: #1f2937; /* Clean dark gray text */
  border: 1px solid #d2f1b8;
  border-radius: 14px 4px 14px 14px;
  box-shadow: 0 1px 1.5px rgba(0,0,0,0.08);
  align-self: flex-end;
}

[data-theme="dark"] .chat-message-bubble--me {
  background: linear-gradient(135deg, #2b5220 0%, #1e3a15 100%); /* Elegant deep forest green for dark theme */
  color: #f3f4f6;
  border: 1px solid #3c6d2d;
  box-shadow: 0 2px 8px rgba(0,0,0,0.2);
}

/* Custom time and seen indicators style overrides for the green bubble */
.chat-message-bubble--me .chat-message-meta-inline {
  color: #55824c !important;
}
[data-theme="dark"] .chat-message-bubble--me .chat-message-meta-inline {
  color: #a7f3d0 !important;
}

/* Premium Reactions Badges */
.chat-message-reactions {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 3px 8px;
  background: var(--surface2);
  border: 1px solid var(--border);
  border-radius: 20px;
  font-size: 11px;
  width: fit-content;
  margin-top: -6px; /* Neg margin to overlap the bubble slightly */
  margin-bottom: 2px;
  z-index: 5;
  box-shadow: 0 1.5px 4px rgba(0,0,0,0.06);
  user-select: none;
  transition: all 0.2s ease;
  height: auto !important;
  min-height: 0 !important;
  flex: 0 0 auto !important;
}
[data-theme="dark"] .chat-message-reactions {
  background: #1a1a24;
}
.chat-message-reactions span {
  display: inline-flex;
  align-items: center;
  gap: 2px;
  cursor: pointer;
  transition: transform 0.15s;
}
.chat-message-reactions span:hover {
  transform: scale(1.18);
}

/* Overlapping Reactee Avatar Circles */
.chat-reaction-avatars-row {
  display: inline-flex;
  align-items: center;
  margin-left: 2px;
}

.chat-reaction-avatar {
  width: 14px;
  height: 14px;
  border-radius: 50%;
  font-size: 8px;
  font-weight: 700;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  color: white;
  border: 1px solid var(--surface);
  box-shadow: 0 1px 2px rgba(0,0,0,0.15);
  user-select: none;
  cursor: pointer;
  transition: all 0.15s ease;
}
[data-theme="dark"] .chat-reaction-avatar {
  border-color: #1a1a24;
}

.chat-reaction-avatar:not(:first-child) {
  margin-left: -5px; /* Slight overlap */
}

.chat-reaction-avatar:hover {
  transform: scale(1.3) translateY(-1px);
  z-index: 10;
}

/* Floating reaction picker animation */
@keyframes scaleFadeIn {
  from { transform: scale(0.85); opacity: 0; }
  to { transform: scale(1); opacity: 1; }
}

.chat-message-bubble--media-only {
  background: transparent !important;
  border: none !important;
  box-shadow: none !important;
  padding: 0 !important;
  margin: 0 !important;
  border-radius: 12px !important;
}

/* Premium media delete button (hidden by default, shown on hover) */
.chat-media-delete-btn {
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.2s ease, transform 0.2s ease !important;
  transform: scale(0.85);
}
.chat-sticker-wrap:hover .chat-media-delete-btn,
.chat-gif-wrap:hover .chat-media-delete-btn,
.chat-image-wrap:hover .chat-media-delete-btn,
.chat-video-wrap:hover .chat-media-delete-btn,
.chat-message-bubble--media-only:hover .chat-media-delete-btn,
.chat-message-bubble:hover .chat-media-delete-btn {
  opacity: 1;
  pointer-events: auto;
  transform: scale(1);
}

.chat-message-text {
  display: inline;
}

.chat-message-meta-inline {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  font-size: 9px;
  color: var(--text3);
  margin-left: 8px;
  margin-top: 4px;
  user-select: none;
  line-height: 1;
  vertical-align: bottom;
  white-space: nowrap;
}
.chat-message-bubble--me .chat-message-meta-inline {
  color: rgba(255, 255, 255, 0.75);
}

.chat-message-media-time-overlay {
  position: absolute;
  bottom: 6px;
  right: 6px;
  background: rgba(0, 0, 0, 0.5);
  color: #fff !important;
  padding: 3px 8px;
  border-radius: 20px;
  font-size: 9px;
  font-weight: 600;
  backdrop-filter: blur(4px);
  -webkit-backdrop-filter: blur(4px);
  display: inline-flex;
  align-items: center;
  gap: 6px;
  z-index: 10;
  border: 1px solid rgba(255, 255, 255, 0.15);
}
.chat-message-media-time-overlay span {
  color: #fff !important;
}

.chat-message-bubble--warning {
  background: linear-gradient(135deg, rgba(239, 68, 68, 0.12), rgba(220, 38, 38, 0.06)) !important;
  border: 1px solid rgba(239, 68, 68, 0.35) !important;
  border-left: 5px solid #dc2626 !important;
  color: var(--text) !important;
  box-shadow: 0 4px 12px rgba(220, 38, 38, 0.12) !important;
}
[data-theme="dark"] .chat-message-bubble--warning {
  background: linear-gradient(135deg, rgba(239, 68, 68, 0.2), rgba(220, 38, 38, 0.1)) !important;
  border: 1px solid rgba(239, 68, 68, 0.4) !important;
  border-left: 5px solid #ef4444 !important;
  color: #fee2e2 !important;
  box-shadow: 0 4px 12px rgba(220, 38, 38, 0.25) !important;
}
[data-theme="light"] .chat-message-bubble--warning {
  background: linear-gradient(135deg, #fff5f5, #ffe3e3) !important;
  border: 1px solid #fca5a5 !important;
  border-left: 5px solid #ef4444 !important;
  color: #991b1b !important;
  box-shadow: 0 4px 12px rgba(239, 68, 68, 0.15) !important;
}

.chat-message-bubble--strategy {
  background: linear-gradient(135deg, rgba(14, 165, 233, 0.12), rgba(2, 132, 199, 0.06)) !important;
  border: 1px solid rgba(14, 165, 233, 0.35) !important;
  border-left: 5px solid #0284c7 !important;
  color: var(--text) !important;
  box-shadow: 0 4px 12px rgba(2, 132, 199, 0.12) !important;
}
[data-theme="dark"] .chat-message-bubble--strategy {
  background: linear-gradient(135deg, rgba(14, 165, 233, 0.2), rgba(2, 132, 199, 0.1)) !important;
  border: 1px solid rgba(14, 165, 233, 0.4) !important;
  border-left: 5px solid #0ea5e9 !important;
  color: #e0f2fe !important;
  box-shadow: 0 4px 12px rgba(2, 132, 199, 0.25) !important;
}
[data-theme="light"] .chat-message-bubble--strategy {
  background: linear-gradient(135deg, #f0f9ff, #e0f2fe) !important;
  border: 1px solid #bae6fd !important;
  border-left: 5px solid #0ea5e9 !important;
  color: #075985 !important;
  box-shadow: 0 4px 12px rgba(14, 165, 233, 0.15) !important;
}

.chat-message-bubble--important {
  background: linear-gradient(135deg, rgba(139, 92, 246, 0.12), rgba(109, 40, 217, 0.06)) !important;
  border: 1px solid rgba(139, 92, 246, 0.35) !important;
  border-left: 5px solid #7c3aed !important;
  color: var(--text) !important;
  box-shadow: 0 4px 12px rgba(109, 40, 217, 0.12) !important;
}
[data-theme="dark"] .chat-message-bubble--important {
  background: linear-gradient(135deg, rgba(139, 92, 246, 0.2), rgba(109, 40, 217, 0.1)) !important;
  border: 1px solid rgba(139, 92, 246, 0.4) !important;
  border-left: 5px solid #8b5cf6 !important;
  color: #f5f3ff !important;
  box-shadow: 0 4px 12px rgba(109, 40, 217, 0.25) !important;
}
[data-theme="light"] .chat-message-bubble--important {
  background: linear-gradient(135deg, #f5f3ff, #ede9fe) !important;
  border: 1px solid #ddd6fe !important;
  border-left: 5px solid #8b5cf6 !important;
  color: #5b21b6 !important;
  box-shadow: 0 4px 12px rgba(139, 92, 246, 0.15) !important;
}

/* Category icons inside bubbles */
.chat-message-body-with-icon {
  display: flex;
  gap: 8px;
  align-items: flex-start;
  margin-top: 4px;
}
.chat-message-cat-icon {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 24px;
  height: 24px;
  border-radius: 50%;
  font-size: 13px;
  flex-shrink: 0;
  box-shadow: 0 1px 3px rgba(0,0,0,0.1);
}
.chat-message-cat-icon--warning {
  background: #fca5a5;
  color: #991b1b;
}
[data-theme="dark"] .chat-message-cat-icon--warning {
  background: rgba(239, 68, 68, 0.3);
  color: #fee2e2;
}
.chat-message-cat-icon--strategy {
  background: #bae6fd;
  color: #075985;
}
[data-theme="dark"] .chat-message-cat-icon--strategy {
  background: rgba(14, 165, 233, 0.3);
  color: #e0f2fe;
}
.chat-message-cat-icon--important {
  background: #ddd6fe;
  color: #5b21b6;
}
[data-theme="dark"] .chat-message-cat-icon--important {
  background: rgba(139, 92, 246, 0.3);
  color: #f5f3ff;
}

/* Custom time overrides for special bubbles to match text color */
.chat-message-bubble--warning .chat-message-time {
  color: rgba(153, 27, 27, 0.6) !important;
}
[data-theme="dark"] .chat-message-bubble--warning .chat-message-time {
  color: rgba(254, 226, 226, 0.6) !important;
}
.chat-message-bubble--strategy .chat-message-time {
  color: rgba(7, 89, 133, 0.6) !important;
}
[data-theme="dark"] .chat-message-bubble--strategy .chat-message-time {
  color: rgba(224, 242, 254, 0.6) !important;
}
.chat-message-bubble--important .chat-message-time {
  color: rgba(91, 33, 182, 0.6) !important;
}
[data-theme="dark"] .chat-message-bubble--important .chat-message-time {
  color: rgba(245, 243, 255, 0.6) !important;
}

.chat-cat-badge {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  font-size: 10px;
  font-weight: 700;
  padding: 1px 7px;
  border-radius: 20px;
  text-transform: uppercase;
  letter-spacing: 0.3px;
  user-select: none;
}
.chat-cat-badge--warning {
  background: #dc2626 !important;
  color: white !important;
}
.chat-cat-badge--strategy {
  background: #0284c7 !important;
  color: white !important;
}
.chat-cat-badge--important {
  background: #7c3aed !important;
  color: white !important;
}

.chat-message-time {
  font-size: 9px;
  color: var(--text3);
  text-align: right;
  margin-top: 3px;
  font-weight: 500;
}
.chat-message-bubble--me .chat-message-time {
  color: rgba(255,255,255,0.75);
}

.chat-mention {
  color: var(--accent);
  font-weight: 700;
  background: rgba(124, 106, 247, 0.1);
  padding: 1px 4px;
  border-radius: 4px;
  border: 1px solid rgba(124,106,247,0.25);
  font-size: 12px;
}
.chat-message-bubble--me .chat-mention {
  color: #3b7a30;
  background: rgba(59, 122, 48, 0.10);
  border-color: rgba(59, 122, 48, 0.25);
}
[data-theme="dark"] .chat-message-bubble--me .chat-mention {
  color: #a7f3d0;
  background: rgba(167, 243, 208, 0.15);
  border-color: rgba(167, 243, 208, 0.3);
}

.chat-emoji-picker-panel {
  grid-template-columns: repeat(7, 1fr);
  box-shadow: 0 10px 25px rgba(0,0,0,0.15);
  scrollbar-width: none;
}
.chat-emoji-picker-panel::-webkit-scrollbar {
  display: none;
}

.chat-category-select {
  outline: none;
  font-weight: 600;
}
.chat-text-input:focus {
  outline: none;
  border-color: var(--accent);
}

/* Seen indicators below chat bubbles */
.chat-message-seen-container {
  display: flex;
  justify-content: flex-end;
  gap: 2px;
  margin-top: 2px;
  padding: 0 4px;
}

.chat-seen-avatar {
  width: 14px;
  height: 14px;
  border-radius: 50%;
  font-size: 8px;
  font-weight: 700;
  display: flex;
  align-items: center;
  justify-content: center;
  color: white;
  border: 1px solid var(--surface);
  box-shadow: 0 1px 2px rgba(0,0,0,0.25);
  user-select: none;
  cursor: pointer;
  transition: all 0.2s cubic-bezier(0.175, 0.885, 0.32, 1.275);
}
[data-theme="dark"] .chat-seen-avatar {
  border-color: #0d0d12;
}

.chat-seen-avatar:hover {
  transform: scale(1.35) translateY(-2px);
  z-index: 10;
  box-shadow: 0 3px 6px rgba(0,0,0,0.4);
}

.chat-seen-avatar:not(:first-child) {
  margin-left: -4px;
}

/* Slide down animation for bubble actions */
@keyframes slideDownFade {
  from { opacity: 0; transform: translateY(-4px); }
  to { opacity: 1; transform: translateY(0); }
}

.chat-bubble-actions-animate {
  animation: slideDownFade 0.18s cubic-bezier(0.16, 1, 0.3, 1) forwards;
}

/* Floating Multi-Chat Animations & Styles */
@keyframes pulse {
  0% {
    transform: scale(0.95);
    box-shadow: 0 0 0 0 rgba(239, 68, 68, 0.7);
  }
  70% {
    transform: scale(1);
    box-shadow: 0 0 0 6px rgba(239, 68, 68, 0);
  }
  100% {
    transform: scale(0.95);
    box-shadow: 0 0 0 0 rgba(239, 68, 68, 0);
  }
}

@keyframes zoomFadeIn {
  from {
    opacity: 0;
    transform: scale(0.9) translateY(10px);
  }
  to {
    opacity: 1;
    transform: scale(1) translateY(0);
  }
}

.floating-avatar-item {
  position: relative;
  display: inline-block;
  cursor: pointer;
  transition: all 0.2s cubic-bezier(0.175, 0.885, 0.32, 1.275);
  flex-shrink: 0;
}

.floating-avatar-item:hover {
  transform: scale(1.05);
}

.floating-avatar-circle {
  width: 40px;
  height: 40px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 700;
  font-size: 11px;
  color: white;
  border: 2px solid transparent;
  transition: all 0.2s;
  box-shadow: 0 2px 5px rgba(0,0,0,0.15);
  text-transform: uppercase;
}

.floating-avatar-item.active .floating-avatar-circle,
.floating-avatar-item.active .floating-avatar-wrapper > div:first-child,
.floating-avatar-item.active .floating-avatar-wrapper > svg:first-child {
  box-shadow: 0 0 0 2.5px var(--accent), 0 0 8px var(--accent);
  transform: scale(1.05);
  border-color: transparent;
}

/* Chat Head Notification Micro-Animation */
.chat-head-bump {
  animation: chatHeadAlert 0.8s ease-in-out;
}

@keyframes chatHeadAlert {
  0%, 100% { transform: scale(1); }
  15% { transform: scale(1.25) translateY(-10px) rotate(-10deg); }
  30% { transform: scale(1.2) translateY(2px) rotate(8deg); }
  45% { transform: scale(1.25) translateY(-6px) rotate(-5deg); }
  60% { transform: scale(1.15) translateY(0) rotate(3deg); }
  80% { transform: scale(1.2) translateY(-2px); }
}

.floating-avatar-close {
  position: absolute;
  top: -4px;
  right: -4px;
  width: 15px;
  height: 15px;
  background: var(--red);
  color: white;
  border-radius: 50%;
  border: 1px solid var(--surface);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 8px;
  font-weight: bold;
  cursor: pointer;
  transition: all 0.15s;
  z-index: 3;
}

.floating-avatar-close:hover {
  background: #dc2626;
  transform: scale(1.2);
}

.floating-avatar-unread {
  position: absolute;
  top: -2px;
  left: -2px;
  width: 9px;
  height: 9px;
  background: var(--red);
  border-radius: 50%;
  border: 1.5px solid var(--surface);
  z-index: 2;
  pointer-events: none;
}

/* Responsive Fullscreen Floating Chat for Mobile */
@media (max-width: 600px) {
  #cjFloatingChatWindow {
    width: 100% !important;
    height: 100% !important;
    top: 0 !important;
    left: 0 !important;
    bottom: 0 !important;
    right: 0 !important;
    border-radius: 0 !important;
    box-shadow: none !important;
  }
}

/* Ensure the header avatar is perfectly circular and clips protruding child borders */
.header-avatar-wrapper {
  overflow: hidden !important;
}
.header-avatar-wrapper,
.header-avatar-wrapper img,
.header-avatar-wrapper div,
.header-avatar-wrapper svg {
  border-radius: 50% !important;
}

/* ═══════════════ INTERACTIVE TOUR ═══════════════ */
.tour-overlay {
  position: fixed;
  top: 0; left: 0; right: 0; bottom: 0;
  background: rgba(0, 0, 0, 0.5);
  z-index: 9999;
  pointer-events: auto;
  transition: opacity 0.3s ease;
}
.tour-highlight {
  z-index: 10000 !important;
  box-shadow: 0 0 0 4px white, 0 0 15px rgba(255, 255, 255, 0.8), 0 8px 25px rgba(0, 0, 0, 0.3) !important;
  transition: all 0.2s ease;
}
.tour-highlight-static {
  position: relative !important;
}
.tour-ancestor-highlight {
  z-index: 10000 !important;
}
/* Stacking context cap for floating elements during active tour */
body.tour-active #cjFloatingChatHead,
body.tour-active #cjFloatingChatHeadBack,
body.tour-active #cjFloatingChatHeadBadge,
body.tour-active #cjFloatingChatWindow {
  z-index: 9998 !important;
}

@keyframes tourBounceDown {
  0%, 100% { transform: translateY(0); }
  50% { transform: translateY(8px); }
}
@keyframes tourBounceUp {
  0%, 100% { transform: translateY(0); }
  50% { transform: translateY(-8px); }
}

.tour-arrow {
  position: fixed;
  z-index: 10002;
  font-size: 36px;
  pointer-events: none;
  transition: all 0.3s ease;
  filter: drop-shadow(0 4px 10px rgba(0,0,0,0.35));
}
.tour-arrow-down { animation: tourBounceDown 1s infinite ease-in-out; }
.tour-arrow-up { animation: tourBounceUp 1s infinite ease-in-out; }
.tour-tooltip {
  position: fixed;
  z-index: 10001;
  background: var(--surface);
  color: var(--text);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 14px 16px;
  width: 280px;
  box-shadow: 0 10px 25px rgba(0, 0, 0, 0.3);
  font-family: inherit;
  font-size: 13px;
  line-height: 1.5;
  display: flex;
  flex-direction: column;
  gap: 10px;
  transition: opacity 0.2s, transform 0.2s;
  pointer-events: auto;
}
.tour-tooltip-title {
  font-weight: 700;
  font-size: 14px;
  color: var(--accent);
  display: flex;
  align-items: center;
  gap: 6px;
}
.tour-tooltip-body {
  color: var(--text2);
}
.tour-tooltip-footer {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-top: 4px;
}
.tour-btn {
  border: none;
  padding: 6px 12px;
  font-size: 11px;
  font-weight: 600;
  border-radius: 6px;
  cursor: pointer;
  transition: all 0.15s;
}
.tour-btn-next {
  background: var(--accent);
  color: white;
}
.tour-btn-next:hover {
  background: color-mix(in srgb, var(--accent) 85%, black);
}
.tour-btn-prev {
  background: var(--surface2);
  border: 1px solid var(--border);
  color: var(--text2);
}
.tour-btn-prev:hover {
  background: var(--border);
}
.tour-step-indicator {
  font-size: 11px;
  color: var(--text3);
  font-weight: 500;
}

/* ═══════════════ GUIDE CENTER (WIKI & STEPPER) ═══════════════ */
.guide-center-container {
  display: flex;
  flex-direction: column;
  gap: 14px;
  max-width: 100%;
}
.guide-search-wrap {
  position: relative;
  width: 100%;
}
.guide-search-wrap input {
  width: 100%;
  padding: 10px 14px 10px 38px;
  background: var(--surface2);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  color: var(--text);
  font-size: 13px;
  outline: none;
  transition: border-color 0.2s;
}
.guide-search-wrap input:focus {
  border-color: var(--accent);
}
.guide-search-wrap .icon {
  position: absolute;
  left: 12px;
  top: 50%;
  transform: translateY(-50%);
  color: var(--text3);
  font-size: 14px;
}
/* Stepper horizontal */
.guide-stepper {
  display: flex;
  align-items: center;
  position: relative;
  padding: 10px 0 15px;
  margin: 5px 0 10px;
  overflow-x: auto;
  scrollbar-width: none;
  gap: 6px;
  -webkit-overflow-scrolling: touch;
}
.guide-stepper::-webkit-scrollbar {
  display: none;
}
.guide-stepper::before {
  content: '';
  position: absolute;
  top: 26px;
  left: 15px;
  right: 15px;
  height: 3px;
  background: var(--border);
  z-index: 1;
}
.guide-step-node {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 6px;
  cursor: pointer;
  z-index: 2;
  flex-shrink: 0;
  min-width: 68px;
}
.guide-step-circle {
  width: 32px;
  height: 32px;
  border-radius: 50%;
  background: var(--surface2);
  border: 2px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 15px;
  color: var(--text2);
  transition: all 0.25s cubic-bezier(0.175, 0.885, 0.32, 1.275);
}
.guide-step-node:hover .guide-step-circle {
  transform: scale(1.1);
  border-color: var(--accent2);
}
.guide-step-node.active .guide-step-circle {
  background: var(--accent);
  border-color: var(--accent);
  color: white;
  box-shadow: 0 0 12px var(--fab-shadow);
  transform: scale(1.15);
}
.guide-step-label {
  font-size: 9px;
  font-weight: 700;
  color: var(--text3);
  text-align: center;
  white-space: normal;
  word-break: keep-all;
  max-width: 65px;
  line-height: 1.25;
  transition: color 0.2s;
}
.guide-step-node.active .guide-step-label {
  color: var(--accent);
}
/* Guide content panel */
.guide-content-panel {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 16px;
  min-height: 200px;
  transition: opacity 0.2s, transform 0.2s;
}
.guide-content-title {
  font-size: 15px;
  font-weight: 700;
  color: var(--accent);
  margin-bottom: 10px;
  display: flex;
  align-items: center;
  gap: 8px;
  border-bottom: 1px solid var(--border);
  padding-bottom: 8px;
}
.guide-content-body {
  font-size: 12px;
  color: var(--text);
  line-height: 1.6;
}
.guide-content-body ul {
  padding-left: 16px;
  margin: 8px 0;
}
.guide-content-body li {
  margin-bottom: 4px;
}
/* CSS flowchart layout */
.guide-flowchart {
  display: flex;
  align-items: center;
  gap: 6px;
  background: var(--surface2);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 10px;
  margin-top: 10px;
  overflow-x: auto;
  scrollbar-width: none;
}
.guide-flowchart::-webkit-scrollbar {
  display: none;
}
.guide-flow-step {
  display: flex;
  flex-direction: column;
  align-items: center;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 6px 8px;
  min-width: 70px;
  max-width: 90px;
  text-align: center;
  flex: 1;
}
.guide-flow-step span {
  font-size: 9.5px;
  font-weight: 700;
  color: var(--accent2);
}
.guide-flow-step small {
  font-size: 8px;
  color: var(--text3);
  margin-top: 2px;
  white-space: nowrap;
}
.guide-flow-arrow {
  font-size: 10px;
  color: var(--text3);
  font-weight: bold;
  flex-shrink: 0;
}

/* Guide profile tab cards */
.guide-profile-tab-card {
  background: var(--surface2);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 12px;
  display: flex;
  flex-direction: column;
  gap: 8px;
  transition: border-color 0.2s, transform 0.2s;
  box-sizing: border-box;
}
.guide-profile-tab-card:hover {
  border-color: var(--accent2);
  transform: translateY(-2px);
}
.guide-profile-tab-header {
  display: flex;
  align-items: center;
  gap: 8px;
}
.guide-profile-tab-header .icon {
  font-size: 14px;
  width: 26px;
  height: 26px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 6px;
  display: flex;
  align-items: center;
  justify-content: center;
}
.guide-profile-tab-header .title {
  font-weight: 700;
  font-size: 12.5px;
  color: var(--text);
}
.guide-profile-tab-card .desc {
  font-size: 11px;
  color: var(--text2);
  line-height: 1.5;
}
/* Guide tabs - Robust Zero-Scroll Grid Layout */
.guide-tabs {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 8px;
  padding-bottom: 8px;
  margin-bottom: 12px;
  border-bottom: 1px solid var(--border);
}
.guide-tab-btn {
  padding: 8px 10px;
  border-radius: 12px;
  border: 1px solid var(--border);
  background: var(--surface2);
  color: var(--text2);
  font-size: 12px;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.25s ease;
  white-space: nowrap;
  display: flex;
  align-items: center;
  justify-content: center;
  text-align: center;
}
.guide-tab-btn.active {
  background: var(--accent);
  color: white;
  border-color: var(--accent);
  box-shadow: 0 4px 10px rgba(59,130,246,0.25);
}
.guide-wiki-item {
  background: var(--surface2);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  margin-bottom: 8px;
  cursor: pointer;
  transition: all 0.25s ease;
  overflow: hidden;
}
.guide-wiki-item:hover {
  border-color: var(--accent);
  box-shadow: 0 2px 8px rgba(0,0,0,0.05);
}
.guide-wiki-header {
  padding: 12px 14px;
  font-weight: 700;
  font-size: 12.5px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  color: var(--text1);
  gap: 8px;
}
.guide-wiki-body {
  padding: 0 14px 14px;
  font-size: 11.5px;
  color: var(--text2);
  line-height: 1.55;
  border-top: 1px dashed var(--border);
  display: none;
}
.guide-wiki-body.open {
  display: block;
  padding-top: 10px;
}

.guide-grid {
  display: grid;
  grid-template-columns: 1fr;
  gap: 12px;
  padding: 4px 0;
}
@media (min-width: 600px) {
  .guide-grid {
    grid-template-columns: repeat(auto-fill, minmax(260px, 1fr));
  }
}

/* Dynamic Mobile Optimizations for Guide Center */
@media (max-width: 768px) {
  .guide-center-container {
    gap: 10px;
  }
  .guide-tabs {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 8px;
    overflow-x: visible;
    padding-bottom: 0;
    margin-bottom: 12px;
  }
  .guide-tab-btn {
    padding: 8px 10px;
    font-size: 11px;
    border-radius: 12px;
    white-space: normal;
    text-align: center;
    line-height: 1.3;
    display: flex;
    align-items: center;
    justify-content: center;
    min-height: 38px;
    box-sizing: border-box;
  }
  .guide-stepper {
    padding: 8px 0 12px;
    margin: 2px 0 6px;
  }
  .guide-stepper::before {
    top: 22px;
  }
  .guide-step-node {
    min-width: 60px;
  }
  .guide-step-circle {
    width: 28px;
    height: 28px;
    font-size: 13px;
  }
  .guide-step-label {
    font-size: 8px;
  }
  .guide-content-panel {
    padding: 12px;
  }
  .guide-content-title {
    font-size: 13.5px;
    margin-bottom: 8px;
    padding-bottom: 6px;
  }
  .guide-content-body {
    font-size: 11px;
    line-height: 1.5;
  }
  
  /* CSS vertical timeline layout for mobile - ultra compact timeline */
  .guide-flowchart {
    flex-direction: column;
    align-items: stretch;
    gap: 14px;
    padding: 16px 16px 16px 20px;
    background: var(--surface2);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    position: relative;
    overflow: hidden;
  }
  .guide-flowchart::before {
    content: '';
    position: absolute;
    left: 24px;
    top: 24px;
    bottom: 24px;
    width: 2px;
    background: var(--border);
    transform: translateX(-50%);
    z-index: 1;
  }
  .guide-flow-step {
    display: flex;
    flex-direction: column;
    align-items: flex-start;
    padding: 0 0 0 22px;
    background: none !important;
    border: none !important;
    box-shadow: none !important;
    min-width: auto;
    max-width: 100%;
    width: auto;
    text-align: left;
    position: relative;
    z-index: 2;
    border-radius: 0;
  }
  .guide-flow-step::before {
    content: '';
    position: absolute;
    left: 4px;
    top: 4px;
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: var(--accent);
    border: 2px solid var(--surface2);
    box-shadow: 0 0 0 2px var(--border);
    transform: translateX(-50%);
    transition: all 0.2s;
  }
  .guide-flow-step:hover::before {
    background: var(--accent2);
    transform: translateX(-50%) scale(1.2);
  }
  .guide-flow-step span {
    font-size: 12px;
    font-weight: 700;
    color: var(--text1);
    display: block;
    margin-bottom: 2px;
  }
  .guide-flow-step small {
    font-size: 11px;
    color: var(--text2);
    margin-top: 0;
    white-space: normal;
    display: block;
    line-height: 1.4;
    text-align: left;
    padding-left: 0;
  }
  .guide-flow-arrow {
    display: none !important;
  }
}

/* ==========================================================================
   CHAT INLINE MEDIA & CUSTOM VOICE PLAYER & RECORDER STYLES
   ========================================================================== */

/* 1. Video Player Container */
.chat-video-wrap {
  margin-top: 6px;
  border-radius: 12px;
  overflow: hidden;
  max-width: 300px;
  border: 1px solid var(--border);
  background: #000;
  position: relative;
  box-shadow: 0 4px 12px rgba(0,0,0,0.15);
}
.chat-video-player {
  width: 100%;
  display: block;
  max-height: 200px;
  object-fit: contain;
}

/* 2. Custom Voice Player (Telegram / Zalo style) */
.voice-player {
  display: flex;
  align-items: center;
  gap: 10px;
  min-width: 240px;
  max-width: 100%;
  padding: 4px 2px;
  box-sizing: border-box;
  user-select: none;
}

/* Play/Pause Button */
.voice-player-play-btn {
  width: 32px;
  height: 32px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--surface2);
  border: 1px solid var(--border);
  cursor: pointer;
  color: var(--accent);
  font-size: 11px;
  flex-shrink: 0;
  transition: all 0.2s cubic-bezier(0.175, 0.885, 0.32, 1.275);
}
.voice-player-play-btn:hover {
  transform: scale(1.08);
  background: var(--border);
}
.voice-player-play-btn:active {
  transform: scale(0.95);
}

/* In outgoing messages (me), play button style adapt */
.chat-message-bubble--me .voice-player-play-btn {
  background: rgba(255, 255, 255, 0.2) !important;
  border-color: rgba(255, 255, 255, 0.1) !important;
  color: #fff !important;
}
.chat-message-bubble--me .voice-player-play-btn:hover {
  background: rgba(255, 255, 255, 0.3) !important;
}

/* Voice Player Body (Telegram style flex column) */
.voice-player-body {
  display: flex;
  flex-direction: column;
  gap: 1px;
  flex-grow: 1;
  min-width: 0;
  box-sizing: border-box;
}

/* Timeline Waveform Container */
.voice-player-waves {
  display: flex;
  gap: 2px;
  align-items: flex-end;
  height: 25px;
  cursor: pointer;
  width: 100%;
  user-select: none;
  padding-top: 4px;
  box-sizing: border-box;
}

/* Individual wave bar */
.voice-player-wave-bar {
  width: 2px;
  background: rgba(0, 0, 0, 0.15);
  border-radius: 1px;
  transition: background 0.1s ease;
  flex-shrink: 0;
}
.chat-message-bubble--me .voice-player-wave-bar {
  background: rgba(255, 255, 255, 0.35);
}

/* Active coloring for wave bar */
.voice-player-wave-bar.active {
  background: var(--accent);
}
.chat-message-bubble--me .voice-player-wave-bar.active {
  background: #ffffff;
}

/* Meta details row under waveform */
.voice-player-meta-row {
  display: flex;
  align-items: center;
  gap: 4px;
  font-size: 10px;
  opacity: 0.8;
  margin-top: 2px;
  font-family: monospace;
}
.chat-message-bubble--me .voice-player-meta-row {
  color: rgba(255, 255, 255, 0.9);
}

.voice-player-time {
  font-weight: 500;
}

.voice-player-divider {
  opacity: 0.5;
  margin: 0 1px;
}

.voice-player-duration {
  opacity: 0.85;
}

/* Speed Capsule Button */
.voice-player-speed-btn {
  font-size: 10px;
  font-weight: 700;
  padding: 2px 6px;
  border-radius: 8px;
  background: var(--surface2);
  border: 1px solid var(--border);
  cursor: pointer;
  color: var(--text2);
  flex-shrink: 0;
  transition: all 0.15s;
  user-select: none;
  font-family: monospace;
  margin-left: auto; /* Pushes the speed button to the far right */
  height: 18px;
  display: flex;
  align-items: center;
  justify-content: center;
}
.voice-player-speed-btn:hover {
  background: var(--border);
  color: var(--text);
}
.chat-message-bubble--me .voice-player-speed-btn {
  background: rgba(255, 255, 255, 0.18) !important;
  border-color: rgba(255, 255, 255, 0.3) !important;
  color: #fff !important;
}
.chat-message-bubble--me .voice-player-speed-btn:hover {
  background: rgba(255, 255, 255, 0.32) !important;
}

/* 3. Voice Note Recording Panel Elements */
.recording-dot {
  animation: blink-recording 1.2s infinite ease-in-out;
  box-shadow: 0 0 6px rgba(239, 68, 68, 0.6);
}
@keyframes blink-recording {
  0%, 100% {
    opacity: 1;
    transform: scale(1);
  }
  50% {
    opacity: 0.3;
    transform: scale(0.85);
  }
}

/* Wave visualizer animation bars */
.voice-wave-bar {
  display: inline-block;
  width: 2.5px;
  background: var(--accent);
  border-radius: 1.5px;
  transition: height 0.15s ease;
}
.voice-wave-bar.bar-1 { height: 6px; animation: wave-pulse 0.7s infinite alternate 0.1s; }
.voice-wave-bar.bar-2 { height: 11px; animation: wave-pulse 0.7s infinite alternate 0.3s; }
.voice-wave-bar.bar-3 { height: 8px; animation: wave-pulse 0.7s infinite alternate 0.2s; }
.voice-wave-bar.bar-4 { height: 14px; animation: wave-pulse 0.7s infinite alternate 0.4s; }
.voice-wave-bar.bar-5 { height: 9px; animation: wave-pulse 0.7s infinite alternate 0.15s; }
.voice-wave-bar.bar-6 { height: 12px; animation: wave-pulse 0.7s infinite alternate 0.35s; }
.voice-wave-bar.bar-7 { height: 7px; animation: wave-pulse 0.7s infinite alternate 0.25s; }

@keyframes wave-pulse {
  0% {
    transform: scaleY(0.45);
    opacity: 0.6;
  }
  100% {
    transform: scaleY(1.3);
    opacity: 1;
  }
}

/* ==========================================================================
   ADAPTIVE RESPONSIVE PROFILES DETAIL CARD FOR MOBILE
   ========================================================================== */
/* Container-aware fluid and responsive layouts for profile details card */
.profile-summary-header {
  display: flex;
  align-items: center;
  gap: 16px;
  position: relative;
  width: 100%;
}
.profile-summary-header-info {
  flex: 1;
  min-width: 0;
  padding-right: 88px !important; /* Enforce spacing on all screens to clear absolute actions */
}
.profile-summary-actions {
  position: absolute !important;
  top: 0 !important;
  right: 0 !important;
  z-index: 10;
  display: flex !important;
  gap: 8px !important;
  margin: 0 !important;
}
.profile-summary-grid {
  display: flex;
  flex-wrap: wrap;
  gap: 16px;
}
.profile-summary-col {
  flex: 1 0 180px !important; /* Force vertical stacking on narrow containers, do not shrink below 180px */
  min-width: 180px !important;
}

/* ==========================================================================
   MESSAGE REPLY SYSTEM STYLES
   ========================================================================== */
.chat-reply-preview-container {
  display: none; /* flex when active */
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  background: var(--surface2);
  border-top: 1px solid var(--border);
  padding: 8px 16px;
  font-size: 12px;
  animation: slideUpReply 0.25s cubic-bezier(0.16, 1, 0.3, 1);
  box-sizing: border-box;
}

@keyframes slideUpReply {
  from { transform: translateY(10px); opacity: 0; }
  to { transform: translateY(0); opacity: 1; }
}

.chat-reply-preview-content {
  border-left: 3px solid var(--accent);
  padding-left: 10px;
  flex: 1;
  min-width: 0;
}

.chat-reply-preview-sender {
  font-weight: 700;
  color: var(--accent);
  margin-bottom: 2px;
  font-size: 11px;
}

.chat-reply-preview-text {
  color: var(--text2);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  font-size: 11px;
}

.chat-reply-preview-close {
  background: none;
  border: none;
  color: var(--text3);
  font-size: 16px;
  cursor: pointer;
  padding: 4px;
  line-height: 1;
}

.chat-reply-preview-close:hover {
  color: var(--red);
}

/* Reply Preview inside message bubbles */
.chat-reply-bubble-preview {
  font-size: 11px;
  background: rgba(0, 0, 0, 0.05);
  border-left: 3px solid var(--accent);
  padding: 6px 10px;
  border-radius: 4px;
  margin-bottom: 6px;
  cursor: pointer;
  display: block;
  max-width: 100%;
  box-sizing: border-box;
  text-align: left;
}

[data-theme="dark"] .chat-reply-bubble-preview {
  background: rgba(255, 255, 255, 0.08);
}

.chat-message-bubble--me .chat-reply-bubble-preview {
  border-left-color: rgba(255, 255, 255, 0.7);
  background: rgba(255, 255, 255, 0.15);
  color: #1f2937;
}

[data-theme="dark"] .chat-message-bubble--me .chat-reply-bubble-preview {
  color: #f3f4f6;
  background: rgba(255, 255, 255, 0.08);
}

.chat-reply-bubble-sender {
  font-weight: 700;
  color: var(--accent);
  margin-bottom: 2px;
  display: block;
}

.chat-message-bubble--me .chat-reply-bubble-sender {
  color: #2b5220; /* Darker green on light theme me-bubble */
}
[data-theme="dark"] .chat-message-bubble--me .chat-reply-bubble-sender {
  color: #a7f3d0;
}

.chat-reply-bubble-text {
  color: var(--text2);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  display: block;
}

.chat-message-bubble--me .chat-reply-bubble-text {
  color: rgba(0, 0, 0, 0.7);
}

[data-theme="dark"] .chat-message-bubble--me .chat-reply-bubble-text {
  color: rgba(255, 255, 255, 0.75);
}

/* Flash highlight animation for original message */
.chat-message-bubble.chat-message-highlight {
  animation: chatMessageFlash 1.5s ease-out !important;
}

@keyframes chatMessageFlash {
  0% { filter: brightness(1.25) saturate(1.5); box-shadow: 0 0 16px var(--accent); }
  50% { filter: brightness(1.25) saturate(1.5); box-shadow: 0 0 16px var(--accent); }
  100% { filter: none; box-shadow: none; }
}

/* Visual Media chat bubble style adjustments (Telegram bubble style) */
.chat-message-bubble--has-visual-media {
  padding: 0 !important;
  overflow: hidden !important;
}

/* Remove gaps and interior borders/radii from visual wrappers in flush bubbles */
.chat-message-bubble--has-visual-media .chat-image-wrap,
.chat-message-bubble--has-visual-media .chat-gif-wrap,
.chat-message-bubble--has-visual-media .chat-video-wrap {
  margin: 0 !important;
  border: none !important;
  border-radius: 0 !important;
  max-width: 100% !important;
  width: 100% !important;
  box-shadow: none !important;
}

.chat-message-bubble--has-visual-media .chat-image-wrap img,
.chat-message-bubble--has-visual-media .chat-gif-wrap video,
.chat-message-bubble--has-visual-media .chat-video-wrap video {
  border-radius: 0 !important;
  width: 100% !important;
  max-height: 280px !important;
}

/* Custom layout for caption text below visual media */
.chat-message-bubble-caption-text {
  padding: 8px 12px 6px 12px;
  display: inline-flex;
  flex-wrap: wrap;
  align-items: flex-end;
  justify-content: space-between;
  gap: 8px;
  word-break: break-word;
  overflow-wrap: break-word;
  width: 100%;
  box-sizing: border-box;
}

.chat-message-bubble-caption-text > span {
  flex: 1;
  min-width: 0;
  white-space: pre-wrap;
}

/* Reply preview margin adjustment inside flush bubbles */
.chat-message-bubble--has-visual-media .chat-reply-bubble-preview {
  margin: 6px 10px 4px 10px !important;
}

/* Category badge alignment inside flush bubbles */
.chat-message-bubble--has-visual-media .chat-cat-badge {
  margin: 6px 12px 4px 12px;
}

/* Lacie AI Action Buttons */
.lacie-action-btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  margin-top: 8px;
  padding: 6px 12px;
  background: linear-gradient(135deg, var(--accent), var(--accent2));
  color: white;
  border: none;
  border-radius: 20px;
  font-size: 11.5px;
  font-weight: 700;
  cursor: pointer;
  box-shadow: 0 2px 8px var(--fab-shadow);
  transition: transform 0.15s ease, opacity 0.15s ease;
}
.lacie-action-btn:active {
  transform: scale(0.96);
  opacity: 0.9;
}

/* Lacie Preset Chips */
.lacie-preset-chip {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 5px 12px;
  background: var(--surface2);
  border: 1px solid var(--border);
  border-radius: 16px;
  color: var(--text1);
  font-size: 11.5px;
  font-weight: 600;
  cursor: pointer;
  white-space: nowrap;
  transition: background 0.2s, border-color 0.2s;
}
.lacie-preset-chip:hover, .lacie-preset-chip:active {
  background: var(--accent);
  color: white;
  border-color: var(--accent);
}

/* Guide Role Filter Chips */
.guide-role-chip {
  padding: 5px 12px;
  border-radius: 20px;
  border: 1px solid var(--border);
  background: var(--surface2);
  color: var(--text2);
  font-size: 11.5px;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.2s ease;
  user-select: none;
}
.guide-role-chip.active {
  background: var(--accent);
  color: white;
  border-color: var(--accent);
  box-shadow: 0 2px 8px var(--fab-shadow);
}

/* ═══════════════ QUICK SUMMARY POPOVER & OFFLINE BADGE ═══════════════ */
.quick-popover-overlay {
  position: fixed; inset: 0; z-index: 9999;
  background: rgba(0, 0, 0, 0.45);
  backdrop-filter: blur(6px);
  -webkit-backdrop-filter: blur(6px);
  display: flex; align-items: center; justify-content: center;
  padding: 16px; box-sizing: border-box;
  opacity: 0; transition: opacity 0.2s cubic-bezier(0.4, 0, 0.2, 1);
  pointer-events: none;
}
.quick-popover-overlay.active {
  opacity: 1; pointer-events: auto;
}

.quick-popover-card {
  width: 100%; max-width: 420px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 16px;
  padding: 18px 20px;
  box-shadow: 0 12px 32px rgba(0, 0, 0, 0.35);
  transform: scale(0.6);
  transform-origin: var(--pop-origin-x, 50%) var(--pop-origin-y, 50%);
  transition: transform 0.28s cubic-bezier(0.34, 1.56, 0.64, 1);
  box-sizing: border-box;
  will-change: transform;
}
.quick-popover-overlay.active .quick-popover-card {
  transform: scale(1);
}

.popover-action-btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 4px;
  padding: 9px 12px; border-radius: 10px; font-size: 12px; font-weight: 600;
  border: none; cursor: pointer; text-decoration: none; transition: all 0.15s;
  box-sizing: border-box; text-align: center;
}
.popover-action-btn:active {
  transform: scale(0.96);
}

@media (max-width: 480px) {
  .quick-popover-card {
    max-width: 94vw;
    padding: 16px 14px;
    border-radius: 14px;
  }
  .popover-action-btn {
    padding: 8px 10px;
    font-size: 11.5px;
  }
}

.offline-sync-badge {
  display: inline-flex; align-items: center; gap: 4px;
  padding: 3px 8px; border-radius: 12px; font-size: 10.5px; font-weight: 700;
  transition: all 0.3s ease; white-space: nowrap;
}









