/* ============================================
   Tool Hub - Dark-First Stylesheet
   ============================================ */

/* --- CSS Variables (Dark default) --- */
:root {
    --bg-primary: #0f1117;
    --bg-secondary: #161822;
    --bg-tertiary: #1e2030;
    --bg-elevated: #252840;
    --bg-hover: #2a2d45;
    --bg-active: #323660;

    --text-primary: #e2e4f0;
    --text-secondary: #989cb8;
    --text-muted: #6b6f8a;
    --text-inverse: #0f1117;

    --border-color: #2a2d45;
    --border-light: #1e2030;

    --accent: #6c63ff;
    --accent-hover: #5a52e0;
    --accent-light: rgba(108, 99, 255, 0.15);
    --accent-glow: rgba(108, 99, 255, 0.3);

    --success: #22c55e;
    --warning: #f59e0b;
    --danger: #ef4444;
    --info: #3b82f6;
    --anon-color: #22d3ee;

    --success-bg: rgba(34, 197, 94, 0.12);
    --warning-bg: rgba(245, 158, 11, 0.12);
    --danger-bg: rgba(239, 68, 68, 0.12);
    --info-bg: rgba(59, 130, 246, 0.12);

    --radius-sm: 6px;
    --radius-md: 10px;
    --radius-lg: 16px;
    --radius-xl: 20px;

    --shadow-sm: 0 1px 3px rgba(0, 0, 0, 0.3);
    --shadow-md: 0 4px 12px rgba(0, 0, 0, 0.4);
    --shadow-lg: 0 8px 30px rgba(0, 0, 0, 0.5);

    --sidebar-width: 280px;
    --sidebar-collapsed-width: 68px;
    --header-height: 72px;

    --font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;
    --font-mono: 'SF Mono', 'Fira Code', 'JetBrains Mono', 'Cascadia Code', Consolas, monospace;

    --transition: 200ms ease;
    --transition-slow: 350ms ease;
}

/* --- Light theme --- */
[data-theme="light"] {
    --bg-primary: #f5f6fa;
    --bg-secondary: #ffffff;
    --bg-tertiary: #ebeef5;
    --bg-elevated: #ffffff;
    --bg-hover: #f0f2f8;
    --bg-active: #e4e7f0;

    --text-primary: #1a1d2e;
    --text-secondary: #5a5e75;
    --text-muted: #9296ae;
    --text-inverse: #ffffff;

    --border-color: #e0e3ec;
    --border-light: #e8ebf2;

    --shadow-sm: 0 1px 3px rgba(0, 0, 0, 0.06);
    --shadow-md: 0 4px 12px rgba(0, 0, 0, 0.08);
    --shadow-lg: 0 8px 30px rgba(0, 0, 0, 0.12);
    --anon-color: #0891b2;
}

/* --- Reset & Base --- */
*, *::before, *::after {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

html {
    font-size: 15px;
    scroll-behavior: smooth;
}

body {
    font-family: var(--font-family);
    background: var(--bg-primary);
    color: var(--text-primary);
    line-height: 1.6;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
    overflow: hidden;
    height: 100vh;
    position: relative;
}

body::before {
    content: '';
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: radial-gradient(ellipse 800px 600px at 15% 10%, rgba(108, 99, 255, 0.06) 0%, transparent 70%);
    pointer-events: none;
    z-index: 0;
}

a { color: var(--accent); text-decoration: none; }
a:hover { color: var(--accent-hover); }

.font-mono { font-family: var(--font-mono) !important; }

.text-muted { color: var(--text-muted); }

/* --- Scrollbar --- */
::-webkit-scrollbar {
    width: 6px;
    height: 6px;
}
::-webkit-scrollbar-track {
    background: transparent;
}
::-webkit-scrollbar-thumb {
    background: var(--border-color);
    border-radius: 4px;
}
::-webkit-scrollbar-thumb:hover {
    background: var(--text-muted);
}

/* --- App Layout --- */
#app {
    display: flex;
    height: 100vh;
    overflow: hidden;
}

/* ============================================
   Sidebar
   ============================================ */
.sidebar {
    width: var(--sidebar-width);
    background: var(--bg-secondary);
    border-right: 1px solid var(--border-color);
    display: flex;
    flex-direction: column;
    flex-shrink: 0;
    transition: width var(--transition-slow), transform var(--transition-slow);
    z-index: 100;
    position: relative;
}

.sidebar-header {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 20px 16px;
    border-bottom: 1px solid var(--border-color);
    min-height: var(--header-height);
}

.logo {
    display: flex;
    align-items: center;
    gap: 12px;
    font-size: 1.35rem;
    font-weight: 800;
    color: var(--text-primary);
    overflow: hidden;
    flex: 1;
    min-width: 0;
}

.logo i {
    color: var(--accent);
    font-size: 1.6rem;
    flex-shrink: 0;
}

.logo span {
    transition: opacity var(--transition);
    white-space: nowrap;
}

.sidebar-toggle {
    background: none;
    border: none;
    color: var(--text-muted);
    font-size: 1rem;
    cursor: pointer;
    padding: 6px;
    border-radius: var(--radius-sm);
    transition: all var(--transition);
    flex-shrink: 0;
    display: flex;
    align-items: center;
    justify-content: center;
}

.sidebar-toggle:hover {
    background: var(--bg-hover);
    color: var(--text-primary);
}

.sidebar-nav {
    flex: 1;
    overflow-y: auto;
    padding: 16px 14px;
}

.nav-loading {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    padding: 40px 20px;
    color: var(--text-muted);
    font-size: 0.85rem;
}

.nav-item {
    display: flex;
    align-items: center;
    gap: 14px;
    padding: 12px 16px;
    margin-bottom: 3px;
    border-radius: var(--radius-md);
    color: var(--text-secondary);
    cursor: pointer;
    transition: all var(--transition);
    border: none;
    background: none;
    width: 100%;
    text-align: left;
    font-size: 1rem;
    font-weight: 500;
    font-family: var(--font-family);
}

.nav-item i {
    width: 22px;
    text-align: center;
    font-size: 1.15rem;
    flex-shrink: 0;
}

.nav-item:hover {
    background: var(--bg-hover);
    color: var(--text-primary);
}

.nav-item.active {
    background: var(--accent-light);
    color: var(--accent);
}

.nav-item .nav-badge {
    margin-left: auto;
    background: var(--accent);
    color: white;
    font-size: 0.7rem;
    font-weight: 600;
    padding: 1px 8px;
    border-radius: 99px;
    min-width: 20px;
    text-align: center;
}

.nav-section-header {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 12px 16px;
    margin-top: 14px;
    margin-bottom: 4px;
    border-radius: var(--radius-md);
    color: var(--text-muted);
    cursor: pointer;
    transition: all var(--transition);
    border: none;
    background: none;
    width: 100%;
    text-align: left;
    font-size: 0.85rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.8px;
    font-family: var(--font-family);
}

.nav-section-header:hover {
    color: var(--text-secondary);
}

.nav-section-header i:first-child {
    width: 20px;
    text-align: center;
    font-size: 0.85rem;
    flex-shrink: 0;
}

.nav-section-header span {
    flex: 1;
    transition: opacity var(--transition);
}

.nav-chevron {
    font-size: 0.65rem;
    transition: transform var(--transition);
    color: var(--text-muted);
    flex-shrink: 0;
}

.nav-chevron.open {
    transform: rotate(180deg);
}

.nav-sub-wrapper {
    max-height: 0;
    overflow: hidden;
    transition: max-height 0.3s ease;
}

.nav-sub-inner {
    padding: 2px 0 4px 12px;
}

.nav-sub-item {
    font-size: 0.85rem;
    padding: 8px 14px;
    margin-bottom: 1px;
}

.sidebar-footer {
    padding: 14px 20px;
    border-top: 1px solid var(--border-color);
    display: flex;
    align-items: center;
    justify-content: space-between;
}

.version-badge {
    font-size: 0.75rem;
    color: var(--text-muted);
    padding: 2px 10px;
    border-radius: 99px;
    background: var(--bg-tertiary);
}

/* --- Collapsed State --- */
.sidebar.collapsed {
    width: var(--sidebar-collapsed-width, 68px);
}

.sidebar.collapsed .sidebar-header {
    padding: 20px 8px;
    justify-content: center;
}

.sidebar.collapsed .logo {
    gap: 0;
    justify-content: center;
}

.sidebar.collapsed .logo span {
    opacity: 0;
    width: 0;
    overflow: hidden;
}

.sidebar.collapsed .sidebar-nav {
    padding: 12px 6px;
}

.sidebar.collapsed .nav-item {
    justify-content: center;
    padding: 10px;
    gap: 0;
    position: relative;
}

.sidebar.collapsed .nav-item i {
    margin: 0;
    font-size: 1.2rem;
    width: auto;
}

.sidebar.collapsed .nav-item span,
.sidebar.collapsed .nav-item .nav-badge {
    display: none;
}

.sidebar.collapsed .nav-section-header {
    justify-content: center;
    padding: 10px;
    gap: 0;
    margin-top: 6px;
    position: relative;
}

.sidebar.collapsed .nav-section-header i:first-child {
    margin: 0;
    font-size: 1rem;
    width: auto;
}

.sidebar.collapsed .nav-section-header span,
.sidebar.collapsed .nav-section-header .nav-chevron {
    display: none;
}

.sidebar.collapsed .nav-sub-wrapper {
    display: none;
}

.sidebar.collapsed .sidebar-footer {
    justify-content: center;
    padding: 12px;
}

.sidebar.collapsed .sidebar-footer .version-badge {
    display: none;
}

/* --- Collapsed indicator dot on hover --- */
.sidebar.collapsed .nav-item:hover i {
    color: var(--accent);
}

.sidebar.collapsed .nav-item.active i {
    color: var(--accent);
}

/* ============================================
   Main Content
   ============================================ */
.main-content {
    flex: 1;
    display: flex;
    flex-direction: column;
    overflow: hidden;
    min-width: 0;
}

.content-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 20px 32px;
    border-bottom: 1px solid var(--border-color);
    flex-shrink: 0;
    gap: 16px;
}

.header-left h1 {
    font-size: 1.5rem;
    font-weight: 700;
    letter-spacing: -0.02em;
}

.header-left p {
    font-size: 0.85rem;
    margin-top: 2px;
}

.header-actions {
    display: flex;
    align-items: center;
    gap: 8px;
    flex-shrink: 0;
}

.content-body {
    flex: 1;
    overflow-y: auto;
    padding: 24px 32px;
}

/* ============================================
   Buttons
   ============================================ */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    padding: 9px 20px;
    border-radius: var(--radius-md);
    font-size: 0.85rem;
    font-weight: 600;
    font-family: var(--font-family);
    cursor: pointer;
    transition: all var(--transition);
    border: none;
    white-space: nowrap;
    line-height: 1.4;
}

.btn:active {
    transform: scale(0.97);
}

.btn-primary {
    background: var(--accent);
    color: white;
}
.btn-primary:hover {
    background: var(--accent-hover);
    box-shadow: 0 2px 12px var(--accent-glow);
}

.btn-secondary {
    background: var(--bg-tertiary);
    color: var(--text-secondary);
    border: 1px solid var(--border-color);
}
.btn-secondary:hover {
    background: var(--bg-hover);
    color: var(--text-primary);
}

.btn-danger {
    background: var(--danger);
    color: white;
}
.btn-danger:hover {
    background: #dc2626;
}

.btn-ghost {
    background: transparent;
    color: var(--text-secondary);
    padding: 8px 12px;
}
.btn-ghost:hover {
    background: var(--bg-hover);
    color: var(--text-primary);
}

.btn-sm {
    padding: 6px 14px;
    font-size: 0.8rem;
}

.btn-icon {
    width: 40px;
    height: 40px;
    padding: 0;
    border-radius: var(--radius-md);
    background: var(--bg-tertiary);
    color: var(--text-secondary);
    border: 1px solid var(--border-color);
    font-size: 1rem;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all var(--transition);
}

.btn-icon:hover {
    background: var(--bg-hover);
    color: var(--text-primary);
}

.btn-icon-danger:hover {
    background: var(--danger-bg);
    color: var(--danger);
}

/* ============================================
   Dashboard (Redesigned - Minimal)
   ============================================ */
.dashboard {
    max-width: 960px;
    margin: 0 auto;
    padding: 8px 0;
}

/* --- Stats bar --- */
.dash-stats {
    display: flex;
    align-items: center;
    gap: 24px;
    margin-bottom: 40px;
    padding: 20px 24px;
    background: var(--bg-secondary);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-lg);
}

.dash-stat {
    display: flex;
    align-items: center;
    gap: 14px;
}

.dash-stat-icon {
    width: 44px;
    height: 44px;
    border-radius: var(--radius-md);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.1rem;
    flex-shrink: 0;
}

.dash-stat-icon.blue { background: var(--info-bg); color: var(--info); }
.dash-stat-icon.green { background: var(--success-bg); color: var(--success); }
.dash-stat-icon.purple { background: var(--accent-light); color: var(--accent); }

.dash-stat-info {
    display: flex;
    flex-direction: column;
}

.dash-stat-value {
    font-size: 1.5rem;
    font-weight: 800;
    line-height: 1.2;
    color: var(--text-primary);
}

.dash-stat-label {
    font-size: 0.8rem;
    color: var(--text-muted);
    line-height: 1.3;
}

.dash-stat-divider {
    width: 1px;
    height: 36px;
    background: var(--border-color);
    flex-shrink: 0;
}

/* --- Active Tools --- */
.dash-section-label {
    font-size: 0.75rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 1px;
    color: var(--text-muted);
    margin-bottom: 16px;
}

.dash-tools {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 20px;
}

.dash-tool {
    background: var(--bg-secondary);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-lg);
    padding: 28px;
    cursor: pointer;
    transition: all var(--transition);
    position: relative;
    display: flex;
    flex-direction: column;
}

.dash-tool:hover {
    border-color: var(--accent);
    transform: translateY(-3px);
    box-shadow: var(--shadow-lg), 0 0 0 1px var(--accent-light);
}

.dash-tool-icon {
    width: 52px;
    height: 52px;
    border-radius: var(--radius-md);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.4rem;
    margin-bottom: 20px;
    transition: transform var(--transition);
}

.dash-tool:hover .dash-tool-icon {
    transform: scale(1.05);
}

.dash-tool h3 {
    font-size: 1.1rem;
    font-weight: 700;
    margin-bottom: 8px;
    color: var(--text-primary);
}

.dash-tool p {
    font-size: 0.85rem;
    color: var(--text-secondary);
    line-height: 1.5;
    margin-bottom: 20px;
    flex: 1;
}

.dash-tool-action {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    font-size: 0.85rem;
    font-weight: 600;
    color: var(--accent);
    transition: gap var(--transition);
}

.dash-tool:hover .dash-tool-action {
    gap: 12px;
}

/* --- Categories Grid (Standalone) --- */
.categories-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(240px, 1fr));
    gap: 16px;
}

.category-card {
    background: var(--bg-secondary);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-lg);
    overflow: hidden;
    transition: all var(--transition);
}

.category-card:hover {
    border-color: var(--accent);
    box-shadow: var(--shadow-md);
    transform: translateY(-2px);
}

.category-card-head {
    height: 64px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.5rem;
    color: rgba(255,255,255,0.85);
}

.category-card-body {
    padding: 16px 20px 12px;
}

.category-card-body h3 {
    font-size: 1rem;
    font-weight: 600;
    margin-bottom: 2px;
}

.category-card-count {
    font-size: 0.78rem;
    color: var(--text-muted);
}

.category-card-actions {
    display: flex;
    gap: 6px;
    padding: 8px 16px 16px;
}

.category-card-actions .btn {
    flex: 1;
    justify-content: center;
}

/* ============================================
   Command Hub
   ============================================ */
.toolbar {
    margin-bottom: 24px;
}

.toolbar-search-row {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 12px;
    margin-bottom: 10px;
}

.toolbar-search-row .search-input-wrap {
    max-width: 480px;
}

.toolbar-filter-row {
    display: flex;
    justify-content: center;
}

.search-input-wrap {
    position: relative;
    flex: 1;
    max-width: 600px;
}

.search-input-wrap i {
    position: absolute;
    left: 16px;
    top: 50%;
    transform: translateY(-50%);
    color: var(--text-muted);
    font-size: 1rem;
    pointer-events: none;
}

.search-input-wrap input {
    width: 100%;
    padding: 12px 16px 12px 44px;
    background: var(--bg-secondary);
    border: 2px solid var(--border-color);
    border-radius: var(--radius-lg);
    color: var(--text-primary);
    font-size: 1rem;
    font-family: var(--font-family);
    outline: none;
    transition: border-color var(--transition), box-shadow var(--transition);
}

.search-input-wrap input:focus {
    border-color: var(--accent);
    box-shadow: 0 0 0 4px var(--accent-light);
}

.search-input-wrap input::placeholder {
    color: var(--text-muted);
    font-size: 0.95rem;
}

.filter-select {
    padding: 10px 16px;
    background: var(--bg-secondary);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-md);
    color: var(--text-primary);
    font-size: 0.9rem;
    font-family: var(--font-family);
    outline: none;
    cursor: pointer;
    min-width: 220px;
}

.filter-select:focus {
    border-color: var(--accent);
    box-shadow: 0 0 0 3px var(--accent-light);
}

/* --- Command Cards --- */
.commands-grid {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 12px;
}

.commands-grid {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 16px;
}

.command-card {
    background: var(--bg-elevated);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-lg);
    transition: all var(--transition);
    display: flex;
    flex-direction: column;
    box-shadow: var(--shadow-sm);
}

.command-card:hover {
    border-color: var(--accent);
    box-shadow: 0 0 0 1px var(--accent-light), var(--shadow-lg);
    transform: translateY(-2px);
}

.command-card-head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    padding: 16px 18px 0;
}

.command-card-head .command-title {
    font-size: 1.25rem;
    font-weight: 700;
    letter-spacing: -0.02em;
    color: var(--text-primary);
    line-height: 1.3;
    margin: 0;
    flex: 1;
    min-width: 0;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.category-badge {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    font-size: 0.85rem;
    font-weight: 600;
    padding: 4px 14px;
    border-radius: 99px;
    text-transform: capitalize;
    flex-shrink: 0;
    text-shadow: 0 1px 3px rgba(0,0,0,0.3);
}

.command-card-body {
    padding: 12px 18px 16px;
    flex: 1;
}

.command-preview {
    background: var(--bg-primary);
    border-radius: var(--radius-md);
    padding: 14px 18px;
    font-family: var(--font-mono);
    font-size: 0.95rem;
    color: var(--text-primary);
    overflow-x: auto;
    white-space: pre-wrap;
    word-break: break-all;
    border-left: 3px solid var(--accent);
    line-height: 1.6;
}

.command-description {
    font-size: 0.9rem;
    color: var(--text-secondary);
    margin-top: 10px;
    line-height: 1.5;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
}

.command-card-actions {
    display: flex;
    gap: 8px;
    padding: 12px 20px 14px;
    border-top: 1px solid var(--border-color);
}

.command-card-actions .btn {
    flex: 1;
    justify-content: center;
    padding: 10px 12px;
    font-size: 0.88rem;
    font-weight: 600;
    border-radius: var(--radius-sm);
    border: none;
    height: 40px;
}

.btn-copy {
    background: var(--success-bg);
    color: var(--success);
}
.btn-copy:hover {
    background: var(--success);
    color: white;
}
.btn-copy.copied {
    background: var(--success);
    color: white;
}

.btn-edit {
    background: var(--info-bg);
    color: var(--info);
}
.btn-edit:hover {
    background: var(--info);
    color: white;
}

.btn-delete {
    background: var(--danger-bg);
    color: var(--danger);
}
.btn-delete:hover {
    background: var(--danger);
    color: white;
}

@media (max-width: 900px) {
    .commands-grid,
    .snippets-grid {
        grid-template-columns: 1fr;
    }
}

@media (max-width: 900px) {
    .commands-grid {
        grid-template-columns: 1fr;
    }
}

/* --- Snippet Cards --- */
.snippets-grid {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 16px;
}

.snippet-card {
    background: var(--bg-elevated);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-lg);
    transition: all var(--transition);
    display: flex;
    flex-direction: column;
    box-shadow: var(--shadow-sm);
}

.snippet-card:hover {
    border-color: var(--accent);
    box-shadow: 0 0 0 1px var(--accent-light), var(--shadow-lg);
    transform: translateY(-2px);
}

.snippet-card-head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    padding: 18px 20px 0;
}

.snippet-title {
    font-size: 1.15rem;
    font-weight: 700;
    letter-spacing: -0.02em;
    color: var(--text-primary);
    line-height: 1.3;
    margin: 0;
    flex: 1;
    min-width: 0;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.snippet-date {
    font-size: 0.8rem;
    color: var(--text-muted);
    flex-shrink: 0;
}

.snippet-preview {
    padding: 16px 20px;
    font-family: var(--font-mono);
    font-size: 0.9rem;
    color: var(--text-primary);
    line-height: 1.7;
    white-space: pre-wrap;
    word-break: break-word;
    max-height: 260px;
    overflow-y: auto;
    flex: 1;
}

.snippet-card-actions {
    display: flex;
    gap: 8px;
    padding: 0 20px 18px;
    border-top: 1px solid var(--border-color);
    padding-top: 14px;
    margin-top: 0;
}

.snippet-card-actions .btn {
    flex: 1;
}

/* --- Empty state --- */
.empty-state {
    text-align: center;
    padding: 60px 20px;
    color: var(--text-muted);
}

.empty-state i {
    font-size: 3rem;
    margin-bottom: 16px;
    opacity: 0.4;
}

.empty-state h3 {
    font-size: 1.1rem;
    color: var(--text-secondary);
    margin-bottom: 4px;
}

.empty-state p {
    font-size: 0.85rem;
}

/* ============================================
   Category Management
   ============================================ */
.categories-section {
    margin-bottom: 32px;
}

.section-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 16px;
}

.section-header h2 {
    font-size: 1.1rem;
    font-weight: 600;
}

.categories-list {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
}

.category-chip {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    padding: 6px 14px;
    border-radius: 99px;
    background: var(--bg-tertiary);
    border: 1px solid var(--border-color);
    font-size: 0.82rem;
    color: var(--text-secondary);
    cursor: pointer;
    transition: all var(--transition);
}

.category-chip:hover {
    border-color: var(--text-muted);
}

.category-chip.active {
    background: var(--accent-light);
    border-color: var(--accent);
    color: var(--accent);
}

.category-chip .category-dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    flex-shrink: 0;
}

.category-chip .chip-actions {
    display: inline-flex;
    gap: 2px;
    margin-left: 4px;
}

.category-chip .chip-actions button {
    background: none;
    border: none;
    color: var(--text-muted);
    cursor: pointer;
    font-size: 0.7rem;
    padding: 2px;
    border-radius: 3px;
    transition: all var(--transition);
}

.category-chip .chip-actions button:hover {
    color: var(--text-primary);
    background: var(--bg-hover);
}

/* ============================================
   Modal
   ============================================ */
.modal-overlay {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.6);
    backdrop-filter: blur(4px);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 1000;
    opacity: 0;
    visibility: hidden;
    transition: all var(--transition-slow);
}

.modal-overlay.active {
    opacity: 1;
    visibility: visible;
}

.modal {
    background: var(--bg-secondary);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-lg);
    width: 100%;
    max-width: 540px;
    max-height: 90vh;
    overflow-y: auto;
    box-shadow: var(--shadow-lg);
    transform: scale(0.95) translateY(10px);
    transition: transform var(--transition-slow);
}

.modal-overlay.active .modal {
    transform: scale(1) translateY(0);
}

.modal-sm {
    max-width: 420px;
}

.modal-lg {
    max-width: 720px;
}

.modal-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 20px 24px 0;
}

.modal-header h2 {
    font-size: 1.15rem;
    font-weight: 600;
}

.modal-close {
    background: none;
    border: none;
    color: var(--text-muted);
    font-size: 1.5rem;
    cursor: pointer;
    padding: 4px;
    line-height: 1;
    border-radius: var(--radius-sm);
    transition: all var(--transition);
}

.modal-close:hover {
    color: var(--text-primary);
    background: var(--bg-hover);
}

.modal-body {
    padding: 20px 24px;
}

.modal-footer {
    display: flex;
    align-items: center;
    justify-content: flex-end;
    gap: 8px;
    padding: 0 24px 20px;
}

.cat-manager-toolbar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    margin-bottom: 20px;
}

.cat-manager-toolbar .btn {
    flex-shrink: 0;
}

/* --- Confirm Modal --- */
.confirm-icon {
    text-align: center;
    font-size: 2.5rem;
    color: var(--danger);
    margin-bottom: 12px;
}

.confirm-message {
    text-align: center;
    color: var(--text-secondary);
    font-size: 1rem;
    line-height: 1.5;
}

.btn-danger {
    background: var(--danger);
    color: #fff;
    border: none;
}

/* --- Forms --- */
.form-group {
    margin-bottom: 16px;
}

.form-group label {
    display: block;
    font-size: 0.85rem;
    font-weight: 500;
    margin-bottom: 6px;
    color: var(--text-primary);
}

.form-group input,
.form-group textarea,
.form-group select {
    width: 100%;
    padding: 10px 14px;
    background: var(--bg-tertiary);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-md);
    color: var(--text-primary);
    font-size: 0.88rem;
    font-family: var(--font-family);
    outline: none;
    transition: border-color var(--transition), box-shadow var(--transition);
}

.form-group input:focus,
.form-group textarea:focus,
.form-group select:focus {
    border-color: var(--accent);
    box-shadow: 0 0 0 3px var(--accent-light);
}

.form-group textarea {
    resize: vertical;
    min-height: 80px;
}

.form-group select {
    cursor: pointer;
}

.color-picker-row {
    display: flex;
    align-items: center;
    gap: 10px;
}

.color-picker-row input[type="color"] {
    width: 44px;
    height: 44px;
    padding: 3px;
    border-radius: var(--radius-md);
    cursor: pointer;
    flex-shrink: 0;
}

.color-picker-row input[type="text"] {
    max-width: 100px;
    font-family: var(--font-mono);
    font-size: 0.82rem;
}

/* ============================================
   Toast Notifications
   ============================================ */
.toast-container {
    position: fixed;
    bottom: 24px;
    right: 24px;
    display: flex;
    flex-direction: column;
    gap: 8px;
    z-index: 2000;
    pointer-events: none;
}

.toast {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 12px 20px;
    border-radius: var(--radius-md);
    background: var(--bg-elevated);
    border: 1px solid var(--border-color);
    box-shadow: var(--shadow-lg);
    pointer-events: auto;
    animation: toastIn 300ms ease forwards;
    min-width: 280px;
    max-width: 420px;
}

.toast.removing {
    animation: toastOut 250ms ease forwards;
}

.toast i {
    font-size: 1.1rem;
    flex-shrink: 0;
}

.toast .toast-text {
    font-size: 0.85rem;
    flex: 1;
}

.toast-success i { color: var(--success); }
.toast-error i { color: var(--danger); }
.toast-info i { color: var(--info); }
.toast-warning i { color: var(--warning); }

@keyframes toastIn {
    from {
        opacity: 0;
        transform: translateX(30px);
    }
    to {
        opacity: 1;
        transform: translateX(0);
    }
}

@keyframes toastOut {
    from {
        opacity: 1;
        transform: translateX(0);
    }
    to {
        opacity: 0;
        transform: translateX(30px);
    }
}

/* ============================================
   Loading States
   ============================================ */
.loading-spinner {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 60px 20px;
    color: var(--text-muted);
    gap: 12px;
}

.loading-spinner i {
    font-size: 2rem;
}

.loading-spinner span {
    font-size: 0.85rem;
}

.skeleton {
    background: var(--bg-tertiary);
    border-radius: var(--radius-md);
    animation: pulse 1.5s ease-in-out infinite;
}

.skeleton-card {
    height: 120px;
    margin-bottom: 12px;
}

@keyframes pulse {
    0%, 100% { opacity: 0.5; }
    50% { opacity: 0.8; }
}

/* ============================================
   Email Anonymizer
   ============================================ */
.anon-wrap {
    max-width: 720px;
    margin: 0 auto;
}

.anon-card {
    background: var(--bg-secondary);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-lg);
    padding: 32px;
}

.anon-card-header {
    display: flex;
    align-items: center;
    gap: 12px;
    margin-bottom: 8px;
}

.anon-card-header i {
    font-size: 1.5rem;
    color: var(--accent);
}

.anon-card-header h2 {
    font-size: 1.25rem;
    font-weight: 700;
}

.anon-desc {
    font-size: 0.85rem;
    color: var(--text-secondary);
    margin-bottom: 24px;
    line-height: 1.5;
}

.anon-desc code {
    background: var(--bg-tertiary);
    padding: 1px 6px;
    border-radius: 4px;
    font-family: var(--font-mono);
    font-size: 0.82rem;
    color: var(--accent);
}

.anon-input-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 6px;
}

.anon-input-header label {
    font-size: 0.85rem;
    font-weight: 600;
}

.anon-hint {
    font-size: 0.75rem;
    color: var(--text-muted);
}

.anon-input-area {
    margin-bottom: 20px;
}

.anon-input-area textarea {
    width: 100%;
    padding: 14px 18px;
    background: var(--bg-primary);
    border: 2px solid var(--border-color);
    border-radius: var(--radius-md);
    color: var(--text-primary);
    font-size: 1rem;
    font-family: var(--font-mono);
    outline: none;
    resize: none;
    overflow: hidden;
    transition: border-color var(--transition), box-shadow var(--transition);
}

.anon-input-area textarea:focus {
    border-color: var(--accent);
    box-shadow: 0 0 0 4px var(--accent-light);
}

.anon-result-area {
    margin-bottom: 28px;
}

.anon-output {
    width: 100%;
    min-height: 52px;
    padding: 18px 22px;
    background: var(--bg-tertiary);
    border: 2px solid var(--anon-color);
    border-radius: var(--radius-md);
    color: var(--anon-color);
    font-size: 1.35rem;
    font-weight: 700;
    line-height: 1.6;
    cursor: pointer;
    transition: border-color var(--transition), box-shadow var(--transition);
    word-break: break-all;
    letter-spacing: 0.03em;
}

.anon-output:hover {
    border-color: var(--anon-color);
    box-shadow: 0 0 0 4px color-mix(in srgb, var(--anon-color) 20%, transparent);
}

.anon-output:hover {
    border-color: var(--accent);
}

.anon-placeholder {
    color: var(--text-muted);
    font-size: 0.9rem;
}

/* ============================================
   Email Header Visualizer
   ============================================ */
.hdr-wrap {
    max-width: 960px;
    margin: 0 auto;
}

.hdr-card {
    background: var(--bg-secondary);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-lg);
    padding: 32px;
}

.hdr-card-header {
    display: flex;
    align-items: center;
    gap: 12px;
    margin-bottom: 8px;
}

.hdr-card-header i {
    font-size: 1.5rem;
    color: var(--accent);
}

.hdr-card-header h2 {
    font-size: 1.25rem;
    font-weight: 700;
}

.hdr-desc {
    font-size: 0.85rem;
    color: var(--text-secondary);
    margin-bottom: 24px;
    line-height: 1.5;
}

.hdr-input-area {
    margin-bottom: 24px;
}

.hdr-input-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 8px;
}

.hdr-input-header label {
    font-size: 0.85rem;
    font-weight: 600;
}

.hdr-input-actions {
    display: flex;
    gap: 8px;
}

.hdr-input-area textarea {
    width: 100%;
    padding: 16px 20px;
    background: var(--bg-primary);
    border: 2px solid var(--border-color);
    border-radius: var(--radius-md);
    color: var(--text-primary);
    font-size: 0.85rem;
    font-family: var(--font-mono);
    outline: none;
    resize: vertical;
    min-height: 140px;
    transition: border-color var(--transition), box-shadow var(--transition);
    line-height: 1.5;
}

.hdr-input-area textarea:focus {
    border-color: var(--accent);
    box-shadow: 0 0 0 4px var(--accent-light);
}

/* --- Summary bar --- */
.hdr-summary {
    display: flex;
    align-items: center;
    gap: 16px;
    flex-wrap: wrap;
    padding: 14px 20px;
    background: var(--bg-tertiary);
    border-radius: var(--radius-md);
    margin-bottom: 24px;
    border: 1px solid var(--border-color);
}

.hdr-summary-item {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    font-size: 0.82rem;
    font-weight: 600;
}

.hdr-summary-ok i { color: var(--success); }
.hdr-summary-warn i { color: var(--warning); }
.hdr-summary-err i { color: var(--danger); }
.hdr-summary-total i { color: var(--text-muted); }

.hdr-summary-ok { color: var(--success); }
.hdr-summary-warn { color: var(--warning); }
.hdr-summary-err { color: var(--danger); }
.hdr-summary-total { color: var(--text-muted); }

/* --- Sections --- */
.hdr-section {
    margin-bottom: 24px;
}

.hdr-section:last-child {
    margin-bottom: 0;
}

.hdr-section-title {
    font-size: 0.85rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.8px;
    color: var(--text-muted);
    margin-bottom: 12px;
    display: flex;
    align-items: center;
    gap: 8px;
}

/* --- Table rows --- */
.hdr-table {
    background: var(--bg-primary);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-md);
    overflow: hidden;
}

.hdr-row {
    display: flex;
    gap: 16px;
    padding: 12px 18px;
    border-bottom: 1px solid var(--border-light);
    align-items: flex-start;
    transition: background var(--transition);
}

.hdr-row:last-child {
    border-bottom: none;
}

.hdr-row:hover {
    background: var(--bg-hover);
}

.hdr-key {
    flex-shrink: 0;
    width: 160px;
    font-size: 0.8rem;
    font-weight: 700;
    color: var(--text-secondary);
    text-transform: uppercase;
    letter-spacing: 0.3px;
    padding-top: 1px;
}

.hdr-val {
    font-size: 0.85rem;
    color: var(--text-primary);
    line-height: 1.5;
    word-break: break-word;
    flex: 1;
}

.hdr-val-mono {
    font-family: var(--font-mono);
    font-size: 0.78rem;
}

.hdr-val i {
    margin-right: 6px;
}

/* --- Status colors --- */
.hdr-status-pass {
    background: rgba(34, 197, 94, 0.06);
    border-left: 3px solid var(--success);
}

.hdr-status-fail {
    background: rgba(239, 68, 68, 0.06);
    border-left: 3px solid var(--danger);
}

.hdr-status-warn {
    background: rgba(245, 158, 11, 0.06);
    border-left: 3px solid var(--warning);
}

.hdr-status-pass .hdr-val i { color: var(--success); }
.hdr-status-fail .hdr-val i { color: var(--danger); }
.hdr-status-warn .hdr-val i { color: var(--warning); }

/* --- Timeline (Received headers) --- */
.hdr-timeline {
    position: relative;
    padding-left: 28px;
}

.hdr-timeline::before {
    content: '';
    position: absolute;
    left: 8px;
    top: 8px;
    bottom: 8px;
    width: 2px;
    background: var(--border-color);
    border-radius: 2px;
}

.hdr-timeline-item {
    position: relative;
    padding-bottom: 20px;
    padding-left: 16px;
}

.hdr-timeline-item:last-child {
    padding-bottom: 0;
}

.hdr-timeline-dot {
    position: absolute;
    left: -24px;
    top: 4px;
    width: 12px;
    height: 12px;
    border-radius: 50%;
    background: var(--bg-tertiary);
    border: 2px solid var(--border-color);
}

.hdr-hop-first .hdr-timeline-dot {
    background: var(--accent);
    border-color: var(--accent);
}

.hdr-hop-last .hdr-timeline-dot {
    background: var(--success);
    border-color: var(--success);
}

.hdr-timeline-label {
    font-size: 0.72rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    color: var(--text-muted);
    margin-bottom: 4px;
}

.hdr-timeline-content {
    font-family: var(--font-mono);
    font-size: 0.78rem;
    color: var(--text-secondary);
    line-height: 1.6;
    word-break: break-word;
}

/* --- Empty state --- */
.hdr-empty {
    text-align: center;
    padding: 40px 20px;
    color: var(--text-muted);
    font-size: 0.9rem;
}

.hdr-empty code {
    background: var(--bg-tertiary);
    padding: 1px 6px;
    border-radius: 4px;
    font-family: var(--font-mono);
    font-size: 0.82rem;
}

/* ============================================
   Responsive
   ============================================ */
@media (max-width: 1024px) {
    .content-header {
        padding: 16px 24px;
    }
    .content-body {
        padding: 20px 24px;
    }
}

@media (max-width: 768px) {
    .sidebar {
        position: fixed;
        left: 0;
        top: 0;
        bottom: 0;
        transform: translateX(-100%);
        width: var(--sidebar-width) !important;
    }

    .sidebar.open {
        transform: translateX(0);
    }

    .mobile-overlay {
        position: fixed;
        inset: 0;
        background: rgba(0, 0, 0, 0.5);
        z-index: 99;
        opacity: 0;
        visibility: hidden;
        transition: all var(--transition);
    }

    .mobile-overlay.active {
        opacity: 1;
        visibility: visible;
    }

    .content-header {
        padding: 14px 16px;
        flex-wrap: wrap;
    }

    .content-body {
        padding: 16px;
    }

    .header-left h1 {
        font-size: 1.2rem;
    }

    .toolbar {
        flex-direction: column;
        align-items: stretch;
    }

    .toolbar-left {
        flex-wrap: wrap;
    }

    .search-input-wrap {
        min-width: 100%;
    }

    .dash-tools {
        grid-template-columns: repeat(2, 1fr);
    }

    .dash-stats {
        flex-wrap: wrap;
        gap: 16px;
    }

    .dash-stat-divider {
        display: none;
    }

    .command-card {
        padding: 16px;
    }

    .modal {
        margin: 16px;
        max-height: calc(100vh - 32px);
    }

    .toast-container {
        left: 16px;
        right: 16px;
        bottom: 16px;
    }

    .toast {
        min-width: unset;
        max-width: unset;
    }
}

@media (max-width: 480px) {
    .dash-tools {
        grid-template-columns: 1fr;
    }
}

/* ============================================
   IP Reputation Checker (Modern)
   ============================================ */
.ipr-wrap {
    max-width: 880px;
    margin: 0 auto;
    padding: 8px 0;
}

.ipr-card {
    background: var(--bg-secondary);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-xl);
    padding: 36px;
}

.ipr-card-top {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 16px;
}

.ipr-card-badge {
    display: inline-flex;
    align-items: center;
    gap: 7px;
    padding: 5px 14px;
    background: var(--accent-light);
    border-radius: 20px;
    font-size: 0.7rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.6px;
    color: var(--accent);
}

.ipr-card-badge i {
    font-size: 0.75rem;
}

.ipr-card-title {
    font-size: 1.55rem;
    font-weight: 800;
    color: var(--text-primary);
    margin-bottom: 8px;
    line-height: 1.2;
}

.ipr-desc {
    font-size: 0.9rem;
    color: var(--text-secondary);
    margin-bottom: 28px;
    line-height: 1.6;
    max-width: 600px;
}

/* ── Search section ── */
.ipr-search-section {
    margin-bottom: 20px;
}

.ipr-search-box {
    display: flex;
    align-items: center;
    background: var(--bg-primary);
    border: 2px solid var(--border-color);
    border-radius: 60px;
    padding: 5px;
    transition: all var(--transition);
    max-width: 680px;
}

.ipr-search-box:focus-within {
    border-color: var(--accent);
    box-shadow: 0 0 0 5px var(--accent-light), 0 4px 20px rgba(108,99,255,0.15);
}

.ipr-search-icon {
    color: var(--text-muted);
    font-size: 1.1rem;
    padding-left: 18px;
    flex-shrink: 0;
}

.ipr-search-input {
    flex: 1;
    border: none;
    background: transparent;
    padding: 14px 16px;
    font-size: 1rem;
    font-family: var(--font-mono) !important;
    color: var(--text-primary);
    outline: none;
    min-width: 0;
}

.ipr-search-input::placeholder {
    color: var(--text-muted);
    font-family: var(--font-family);
    font-size: 0.95rem;
}

.ipr-search-btn {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    padding: 11px 26px;
    background: var(--accent);
    color: #fff;
    border: none;
    border-radius: 50px;
    font-size: 0.9rem;
    font-weight: 700;
    cursor: pointer;
    white-space: nowrap;
    transition: all var(--transition);
    flex-shrink: 0;
}

.ipr-search-btn:hover {
    background: var(--accent-hover);
    transform: translateY(-1px);
    box-shadow: 0 4px 16px rgba(108,99,255,0.35);
}

.ipr-search-btn:active {
    transform: translateY(0);
}

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

.ipr-search-btn i {
    font-size: 0.9rem;
}

/* ── History ── */
.ipr-history {
    margin-bottom: 20px;
    padding: 16px 20px;
    background: var(--bg-tertiary);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-lg);
}

.ipr-history-header {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 0.72rem;
    font-weight: 700;
    color: var(--text-muted);
    margin-bottom: 12px;
    text-transform: uppercase;
    letter-spacing: 0.8px;
}

.ipr-history-clear {
    margin-left: auto;
    background: none;
    border: none;
    color: var(--text-muted);
    cursor: pointer;
    font-size: 1.3rem;
    line-height: 1;
    padding: 0 4px;
    border-radius: var(--radius-sm);
    transition: color var(--transition);
}

.ipr-history-clear:hover {
    color: var(--danger);
}

.ipr-history-items {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
}

.ipr-history-chip {
    display: inline-flex;
    align-items: center;
    gap: 7px;
    padding: 7px 16px;
    background: var(--bg-secondary);
    border: 1px solid var(--border-color);
    border-radius: 20px;
    font-size: 0.82rem;
    font-family: var(--font-mono) !important;
    color: var(--text-primary);
    cursor: pointer;
    transition: all var(--transition);
}

.ipr-history-chip:hover {
    border-color: var(--accent);
    background: var(--accent-light);
    transform: translateY(-1px);
}

.ipr-history-dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    display: inline-block;
    flex-shrink: 0;
}

/* ── Empty state ── */
.ipr-empty {
    text-align: center;
    padding: 56px 20px;
    color: var(--text-muted);
}

.ipr-empty i {
    font-size: 3rem;
    margin-bottom: 16px;
    opacity: 0.4;
}

.ipr-empty h3 {
    font-size: 1.1rem;
    font-weight: 600;
    color: var(--text-secondary);
    margin-bottom: 6px;
}

.ipr-empty p {
    font-size: 0.9rem;
}

/* ── Result ── */
.ipr-result {
    animation: iprFadeIn 0.4s ease;
}

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

/* ── Banner ── */
.ipr-banner {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 20px;
    border: 1px solid;
    border-radius: var(--radius-lg);
    padding: 20px 24px;
    margin-bottom: 16px;
}

.ipr-banner-left {
    display: flex;
    align-items: center;
    gap: 18px;
    flex: 1;
    min-width: 0;
}

.ipr-banner-icon {
    width: 52px;
    height: 52px;
    border-radius: var(--radius-md);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.3rem;
    flex-shrink: 0;
}

.ipr-banner-info {
    min-width: 0;
}

.ipr-banner-ip {
    display: flex;
    align-items: center;
    gap: 10px;
    margin-bottom: 8px;
}

.ipr-banner-ip span {
    font-size: 1.2rem;
    font-weight: 700;
    color: var(--text-primary);
    word-break: break-all;
}

.ipr-banner-copy {
    background: none;
    border: 1px solid var(--border-color);
    border-radius: var(--radius-sm);
    padding: 4px 8px;
    color: var(--text-muted);
    cursor: pointer;
    font-size: 0.85rem;
    transition: all var(--transition);
    flex-shrink: 0;
}

.ipr-banner-copy:hover {
    color: var(--accent);
    border-color: var(--accent);
    background: var(--accent-light);
}

.ipr-banner-tags {
    display: flex;
    flex-wrap: wrap;
    gap: 7px;
}

.ipr-banner-tag {
    display: inline-flex;
    align-items: center;
    gap: 5px;
    padding: 3px 12px;
    border-radius: 20px;
    font-size: 0.75rem;
    font-weight: 600;
}

.ipr-banner-tag i {
    font-size: 0.7rem;
}

.ipr-banner-score {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 2px;
    flex-shrink: 0;
}

.ipr-banner-score-value {
    font-size: 2.2rem;
    font-weight: 900;
    line-height: 1;
    font-variant-numeric: tabular-nums;
}

.ipr-banner-score-label {
    font-size: 0.7rem;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.5px;
    margin-bottom: 4px;
}

.ipr-banner-score-track {
    width: 80px;
    height: 5px;
    background: var(--bg-tertiary);
    border-radius: 99px;
    overflow: hidden;
}

.ipr-banner-score-fill {
    height: 100%;
    border-radius: 99px;
    transition: width 0.8s ease;
}

/* ── Stats row ── */
.ipr-stats-row {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 12px;
    margin-bottom: 20px;
}

.ipr-stat-card {
    display: flex;
    flex-direction: column;
    align-items: center;
    text-align: center;
    padding: 18px 12px;
    border-radius: var(--radius-lg);
    gap: 4px;
}

.ipr-stat-card-value {
    font-size: 1rem;
    font-weight: 800;
    line-height: 1.2;
    word-break: break-all;
    max-width: 100%;
}

.ipr-stat-card-label {
    font-size: 0.68rem;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

/* ── Toolbar ── */
.ipr-toolbar {
    display: flex;
    gap: 8px;
    margin-bottom: 24px;
}

/* ── Sections (using hdr-* shared classes) ── */
.ipr-sections {
    display: flex;
    flex-direction: column;
    gap: 14px;
    margin-bottom: 24px;
}

/* ── Badges ── */
.ipr-badge {
    display: inline-block;
    padding: 3px 12px;
    border-radius: 20px;
    font-size: 0.72rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.4px;
    line-height: 1.5;
}

.ipr-badge-low {
    background: var(--success-bg);
    color: var(--success);
}

.ipr-badge-med {
    background: rgba(245, 158, 11, 0.15);
    color: var(--warning);
}

.ipr-badge-high {
    background: var(--danger-bg);
    color: var(--danger);
}

/* ── Tags ── */
.ipr-tag {
    display: inline-block;
    padding: 2px 9px;
    background: var(--bg-tertiary);
    border: 1px solid var(--border-color);
    border-radius: 4px;
    font-size: 0.72rem;
    font-family: var(--font-mono) !important;
    color: var(--text-muted);
    margin: 1px;
}

/* ── Quick Actions ── */
.ipr-quick-actions {
    border: 1px solid var(--border-color);
    border-radius: var(--radius-lg);
    overflow: hidden;
    background: var(--bg-primary);
}

.ipr-qa-title {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 16px 20px;
    font-weight: 700;
    font-size: 0.9rem;
    color: var(--text-primary);
    background: var(--bg-secondary);
    border-bottom: 1px solid var(--border-color);
}

.ipr-qa-title i {
    font-size: 1rem;
    color: var(--accent);
}

.ipr-qa-grid {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 10px;
    padding: 18px 20px;
}

.ipr-qa-btn {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 14px 18px;
    background: var(--bg-secondary);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-md);
    color: var(--text-primary);
    text-decoration: none;
    font-size: 0.88rem;
    font-weight: 600;
    transition: all var(--transition);
}

.ipr-qa-btn:hover {
    border-color: var(--accent);
    color: var(--accent);
    transform: translateY(-2px);
    box-shadow: 0 4px 16px rgba(108,99,255,0.15);
}

.ipr-qa-btn i {
    font-size: 1.1rem;
    color: var(--accent);
}

/* ── Responsive ── */
@media (max-width: 800px) {
    .ipr-banner {
        flex-direction: column;
        align-items: stretch;
    }
    .ipr-banner-score {
        flex-direction: row;
        gap: 10px;
        align-items: center;
    }
    .ipr-banner-score-track {
        flex: 1;
        width: auto;
    }
    .ipr-stats-row {
        grid-template-columns: repeat(2, 1fr);
    }
}

@media (max-width: 600px) {
    .ipr-card {
        padding: 24px 18px;
    }
    .ipr-search-box {
        flex-wrap: wrap;
        border-radius: var(--radius-lg);
        padding: 4px;
    }
    .ipr-search-input {
        padding: 12px 14px;
        font-size: 0.95rem;
    }
    .ipr-search-btn {
        width: 100%;
        justify-content: center;
        border-radius: var(--radius-md);
        padding: 12px;
    }
    .ipr-stats-row {
        grid-template-columns: 1fr;
    }
    .ipr-qa-grid {
        grid-template-columns: 1fr;
    }
    .ipr-banner-left {
        flex-direction: column;
        align-items: flex-start;
    }
}

/* ============================================
   Login Screen
   ============================================ */
.login-overlay {
    position: fixed;
    inset: 0;
    z-index: 9999;
    display: flex;
    align-items: center;
    justify-content: center;
    opacity: 0;
    visibility: hidden;
    transition: opacity 0.5s ease, visibility 0.5s ease;
}

.login-overlay.active {
    opacity: 1;
    visibility: visible;
}

.login-bg {
    position: absolute;
    inset: 0;
    background: var(--bg-primary);
    z-index: -1;
}

.login-bg::before {
    content: '';
    position: absolute;
    top: -50%;
    left: -50%;
    width: 200%;
    height: 200%;
    background: radial-gradient(ellipse 600px 400px at 20% 30%, rgba(108, 99, 255, 0.08) 0%, transparent 60%),
                radial-gradient(ellipse 500px 500px at 80% 70%, rgba(34, 197, 94, 0.05) 0%, transparent 60%);
    pointer-events: none;
    animation: loginBgShift 20s ease-in-out infinite alternate;
}

@keyframes loginBgShift {
    0% { transform: translate(0, 0) rotate(0deg); }
    100% { transform: translate(-2%, -2%) rotate(3deg); }
}

.login-card {
    position: relative;
    width: 100%;
    max-width: 400px;
    padding: 20px;
}

.login-card-inner {
    background: var(--bg-secondary);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-xl);
    padding: 40px 36px 36px;
    box-shadow: var(--shadow-lg), 0 0 0 1px rgba(108, 99, 255, 0.05);
    transition: box-shadow var(--transition);
}

.login-overlay.active .login-card-inner {
    animation: loginCardIn 0.5s ease forwards;
}

@keyframes loginCardIn {
    from {
        opacity: 0;
        transform: translateY(20px) scale(0.97);
    }
    to {
        opacity: 1;
        transform: translateY(0) scale(1);
    }
}

.login-icon {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 64px;
    height: 64px;
    margin: 0 auto 20px;
    background: var(--accent-light);
    border-radius: var(--radius-lg);
    font-size: 1.8rem;
    color: var(--accent);
}

.login-title {
    text-align: center;
    font-size: 1.5rem;
    font-weight: 800;
    color: var(--text-primary);
    margin-bottom: 4px;
    letter-spacing: -0.02em;
}

.login-subtitle {
    text-align: center;
    font-size: 0.9rem;
    color: var(--text-muted);
    margin-bottom: 32px;
}

.login-field {
    margin-bottom: 18px;
}

.login-field label {
    display: block;
    font-size: 0.8rem;
    font-weight: 600;
    color: var(--text-secondary);
    margin-bottom: 6px;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.login-field input {
    width: 100%;
    padding: 12px 16px;
    background: var(--bg-tertiary);
    border: 2px solid var(--border-color);
    border-radius: var(--radius-md);
    color: var(--text-primary);
    font-size: 0.95rem;
    font-family: var(--font-family);
    outline: none;
    transition: border-color var(--transition), box-shadow var(--transition);
}

.login-field input:focus {
    border-color: var(--accent);
    box-shadow: 0 0 0 4px var(--accent-light);
}

.login-field input::placeholder {
    color: var(--text-muted);
    font-size: 0.9rem;
}

.login-error {
    font-size: 0.82rem;
    color: var(--danger);
    margin-bottom: 16px;
    min-height: 0;
    line-height: 1.4;
}

.login-btn {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 10px;
    width: 100%;
    padding: 13px 24px;
    border: none;
    border-radius: var(--radius-md);
    font-size: 0.95rem;
    font-weight: 700;
    font-family: var(--font-family);
    cursor: pointer;
    transition: all var(--transition);
    position: relative;
}

.login-btn-primary {
    background: var(--accent);
    color: white;
}

.login-btn-primary:hover {
    background: var(--accent-hover);
    box-shadow: 0 4px 20px var(--accent-glow);
    transform: translateY(-1px);
}

.login-btn-primary:active {
    transform: translateY(0);
}

.login-btn-primary:disabled {
    opacity: 0.7;
    cursor: not-allowed;
    transform: none;
    box-shadow: none;
}

.login-btn-secondary {
    background: transparent;
    color: var(--text-secondary);
    border: 1px solid var(--border-color);
    margin-top: 8px;
    font-size: 0.85rem;
    padding: 10px 20px;
}

.login-btn-secondary:hover {
    background: var(--bg-hover);
    color: var(--text-primary);
}

.login-btn .login-btn-text {
    transition: opacity var(--transition);
}

.login-btn .login-btn-loading {
    display: none;
    position: absolute;
}

.login-btn.loading .login-btn-text {
    visibility: hidden;
}

.login-btn.loading .login-btn-loading {
    display: flex;
}

.login-alt-link {
    text-align: center;
    margin-top: 20px;
    font-size: 0.82rem;
}

.login-alt-link a {
    color: var(--text-muted);
    text-decoration: none;
    transition: color var(--transition);
}

.login-alt-link a:hover {
    color: var(--accent);
}

/* ============================================
   User Management
   ============================================ */
.checkbox-label {
    display: flex;
    align-items: center;
    gap: 10px;
    cursor: pointer;
    font-size: 0.9rem;
    color: var(--text-primary);
    padding: 8px 0;
}

.checkbox-label input[type="checkbox"] {
    width: 18px;
    height: 18px;
    accent-color: var(--accent);
    cursor: pointer;
}

.users-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(340px, 1fr));
    gap: 16px;
}

.user-card {
    display: flex;
    flex-direction: column;
    background: var(--bg-secondary);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-lg);
    padding: 20px;
    transition: all var(--transition);
}

.user-card:hover {
    border-color: var(--accent);
    box-shadow: var(--shadow-md);
}

.user-card-avatar {
    width: 48px;
    height: 48px;
    border-radius: 50%;
    background: var(--accent-light);
    color: var(--accent);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.3rem;
    margin-bottom: 12px;
}

.user-card-body {
    margin-bottom: 12px;
}

.user-card-name {
    font-size: 1.05rem;
    font-weight: 700;
    color: var(--text-primary);
    margin-bottom: 2px;
}

.user-card-username {
    font-size: 0.82rem;
    color: var(--text-muted);
    display: block;
    margin-bottom: 2px;
}

.user-card-email {
    font-size: 0.82rem;
    color: var(--text-secondary);
    display: block;
}

.user-card-badges {
    display: flex;
    gap: 8px;
    margin-bottom: 10px;
    flex-wrap: wrap;
}

.user-badge {
    display: inline-flex;
    align-items: center;
    gap: 5px;
    font-size: 0.72rem;
    font-weight: 700;
    padding: 3px 10px;
    border-radius: 20px;
    text-transform: uppercase;
    letter-spacing: 0.4px;
}

.admin-badge {
    background: var(--accent-light);
    color: var(--accent);
}

.user-badge-user {
    background: var(--bg-tertiary);
    color: var(--text-muted);
}

.active-badge {
    background: var(--success-bg);
    color: var(--success);
}

.inactive-badge {
    background: var(--danger-bg);
    color: var(--danger);
}

.user-card-meta {
    font-size: 0.78rem;
    color: var(--text-muted);
    margin-bottom: 14px;
    padding-top: 10px;
    border-top: 1px solid var(--border-color);
}

.user-card-actions {
    display: flex;
    gap: 8px;
}

.user-card-actions .btn {
    flex: 1;
    justify-content: center;
}

/* ============================================
   Rich Text Editor
   ============================================ */
.rte-wrap {
    max-width: 1100px;
    margin: 0 auto;
    display: flex;
    flex-direction: column;
    height: calc(100vh - 140px);
    position: relative;
}

.rte-toolbar {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 4px;
    padding: 10px 14px;
    background: var(--bg-secondary);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-lg) var(--radius-lg) 0 0;
    border-bottom: none;
    position: sticky;
    top: 0;
    z-index: 10;
}

.rte-toolbar-group {
    display: flex;
    align-items: center;
    gap: 2px;
    padding: 0 6px;
    border-right: 1px solid var(--border-color);
}

.rte-toolbar-group:last-child {
    border-right: none;
}

.rte-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 40px;
    height: 38px;
    border: none;
    background: transparent;
    color: var(--text-secondary);
    border-radius: var(--radius-md);
    cursor: pointer;
    transition: all 0.15s ease;
    font-size: 1rem;
    position: relative;
}

.rte-btn:hover {
    background: var(--bg-hover);
    color: var(--text-primary);
    transform: translateY(-1px);
}

.rte-btn.active {
    background: var(--accent-light);
    color: var(--accent);
    box-shadow: inset 0 0 0 1px var(--accent);
}

.rte-btn:active {
    transform: scale(0.95);
}

.rte-btn-wide {
    width: auto;
    padding: 0 14px;
    gap: 6px;
    font-size: 0.85rem;
    font-weight: 600;
}

.rte-btn-wide i {
    font-size: 0.85rem;
}

.rte-btn-label {
    font-size: 0.78rem;
    font-weight: 600;
    padding: 0 4px;
}

.rte-select {
    padding: 6px 10px;
    background: transparent;
    border: 1px solid transparent;
    color: var(--text-secondary);
    font-size: 0.85rem;
    font-family: var(--font-family);
    cursor: pointer;
    border-radius: var(--radius-md);
    outline: none;
    height: 36px;
    transition: all 0.15s ease;
}

.rte-select:hover {
    background: var(--bg-hover);
    border-color: var(--border-color);
}

.rte-select:focus {
    border-color: var(--accent);
    background: var(--bg-primary);
}

.rte-select option {
    background: var(--bg-secondary);
    color: var(--text-primary);
    padding: 8px;
}

.rte-separator {
    width: 1px;
    height: 28px;
    background: var(--border-color);
    margin: 0 6px;
    flex-shrink: 0;
}

.rte-editor-wrapper {
    flex: 1;
    display: flex;
    flex-direction: column;
    background: var(--bg-secondary);
    border: 1px solid var(--border-color);
    border-radius: 0 0 var(--radius-lg) var(--radius-lg);
    overflow: hidden;
    position: relative;
}

.rte-editor {
    flex: 1;
    padding: 28px 32px;
    overflow-y: auto;
    outline: none;
    font-size: 1.05rem;
    line-height: 1.8;
    color: var(--text-primary);
    background: var(--bg-secondary);
    min-height: 350px;
    word-wrap: break-word;
}

.rte-editor:empty::before {
    content: attr(data-placeholder);
    color: var(--text-muted);
    pointer-events: none;
}

.rte-editor h1 { font-size: 2em; font-weight: 700; margin: 0.67em 0; line-height: 1.3; }
.rte-editor h2 { font-size: 1.5em; font-weight: 700; margin: 0.75em 0; line-height: 1.35; }
.rte-editor h3 { font-size: 1.25em; font-weight: 600; margin: 0.83em 0; line-height: 1.4; }
.rte-editor h4 { font-size: 1.1em; font-weight: 600; margin: 1em 0; }
.rte-editor h5 { font-size: 1em; font-weight: 600; margin: 1em 0; }
.rte-editor h6 { font-size: 0.9em; font-weight: 600; margin: 1em 0; text-transform: uppercase; letter-spacing: 0.5px; }

.rte-editor p { margin: 0 0 0.5em 0; min-height: 1.7em; }

.rte-editor blockquote {
    border-left: 3px solid var(--accent);
    padding: 8px 16px;
    margin: 12px 0;
    color: var(--text-secondary);
    background: var(--bg-tertiary);
    border-radius: 0 var(--radius-sm) var(--radius-sm) 0;
}

.rte-editor pre {
    background: var(--bg-primary);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-md);
    padding: 16px 20px;
    margin: 12px 0;
    overflow-x: auto;
    font-family: var(--font-mono);
    font-size: 0.85rem;
    line-height: 1.6;
    tab-size: 4;
}

.rte-editor code {
    font-family: var(--font-mono);
    font-size: 0.85em;
    padding: 2px 6px;
    background: var(--bg-tertiary);
    border-radius: 4px;
}

.rte-editor pre code {
    background: none;
    padding: 0;
    border-radius: 0;
    font-size: inherit;
}

.rte-editor ul, .rte-editor ol {
    padding-left: 24px;
    margin: 8px 0;
}

.rte-editor li {
    margin: 4px 0;
}

.rte-editor ul[data-type="checklist"] {
    list-style: none;
    padding-left: 0;
}

.rte-editor ul[data-type="checklist"] li {
    display: flex;
    align-items: center;
    gap: 8px;
}

.rte-editor ul[data-type="checklist"] li::before {
    display: none;
}

.rte-editor .rte-checkbox {
    width: 18px;
    height: 18px;
    accent-color: var(--accent);
    cursor: pointer;
    flex-shrink: 0;
}

.rte-editor a {
    color: var(--accent);
    text-decoration: underline;
}

.rte-editor a:hover {
    color: var(--accent-hover);
}

.rte-editor img {
    max-width: 100%;
    height: auto;
    border-radius: var(--radius-md);
    margin: 12px 0;
    display: block;
}

.rte-editor img.rte-align-left { margin-right: auto; }
.rte-editor img.rte-align-center { margin-left: auto; margin-right: auto; }
.rte-editor img.rte-align-right { margin-left: auto; }

.rte-editor table {
    border-collapse: collapse;
    width: 100%;
    margin: 12px 0;
    font-size: 0.9rem;
}

.rte-editor th {
    background: var(--bg-tertiary);
    font-weight: 700;
    text-align: left;
}

.rte-editor td, .rte-editor th {
    border: 1px solid var(--border-color);
    padding: 10px 14px;
    min-width: 60px;
}

.rte-editor hr {
    border: none;
    border-top: 2px solid var(--border-color);
    margin: 20px 0;
}

.rte-status-bar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 10px 20px;
    background: var(--bg-tertiary);
    border-top: 1px solid var(--border-color);
    font-size: 0.85rem;
    color: var(--text-muted);
    flex-shrink: 0;
}

.rte-status-left {
    display: flex;
    align-items: center;
    gap: 20px;
}

.rte-status-right {
    display: flex;
    align-items: center;
    gap: 16px;
}

.rte-status-item {
    display: flex;
    align-items: center;
    gap: 6px;
}

.rte-status-item i {
    font-size: 0.85rem;
}

.rte-saved-indicator {
    display: flex;
    align-items: center;
    gap: 6px;
    font-weight: 600;
}

.rte-emojis-popup {
    position: absolute;
    top: 100%;
    left: 0;
    z-index: 100;
    background: var(--bg-elevated);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-lg);
    padding: 14px;
    width: 330px;
    max-height: 280px;
    overflow-y: auto;
    display: grid;
    grid-template-columns: repeat(7, 1fr);
    gap: 4px;
}

.rte-emoji-btn {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 40px;
    height: 40px;
    border: none;
    background: transparent;
    border-radius: var(--radius-sm);
    cursor: pointer;
    font-size: 1.4rem;
    transition: all 0.15s ease;
}

.rte-emoji-btn:hover {
    background: var(--bg-hover);
    transform: scale(1.15);
}

.rte-table-picker {
    position: absolute;
    top: 100%;
    left: 0;
    z-index: 100;
    background: var(--bg-elevated);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-lg);
    padding: 14px;
}

.rte-table-grid {
    display: grid;
    grid-template-columns: repeat(8, 28px);
    gap: 3px;
}

.rte-table-cell {
    width: 28px;
    height: 28px;
    border: 1px solid var(--border-color);
    border-radius: 3px;
    cursor: pointer;
    transition: all 0.1s ease;
}

.rte-table-cell:hover, .rte-table-cell.active {
    background: var(--accent);
    border-color: var(--accent);
}

.rte-table-label {
    text-align: center;
    font-size: 0.85rem;
    color: var(--text-muted);
    margin-top: 8px;
    font-weight: 600;
}

.rte-search-bar {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 10px 18px;
    background: var(--bg-tertiary);
    border-bottom: 1px solid var(--border-color);
    flex-shrink: 0;
    flex-wrap: wrap;
}

.rte-search-input {
    flex: 1;
    padding: 10px 14px;
    background: var(--bg-primary);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-md);
    color: var(--text-primary);
    font-size: 0.9rem;
    font-family: var(--font-family);
    outline: none;
    max-width: 280px;
    min-width: 140px;
}

.rte-search-input:focus {
    border-color: var(--accent);
    box-shadow: 0 0 0 3px var(--accent-light);
}

.rte-search-input::placeholder {
    color: var(--text-muted);
}

.rte-search-count {
    font-size: 0.82rem;
    color: var(--text-muted);
    white-space: nowrap;
    font-weight: 600;
}

.rte-search-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 36px;
    height: 36px;
    border: 1px solid var(--border-color);
    background: var(--bg-primary);
    color: var(--text-secondary);
    border-radius: var(--radius-md);
    cursor: pointer;
    font-size: 0.85rem;
    transition: all 0.15s ease;
}

.rte-search-btn:hover {
    background: var(--bg-hover);
    color: var(--text-primary);
    border-color: var(--accent);
}

.rte-search-close {
    background: none;
    border: none;
    color: var(--text-muted);
    cursor: pointer;
    font-size: 1.3rem;
    padding: 4px 8px;
    border-radius: var(--radius-sm);
    transition: all 0.15s ease;
}

.rte-search-close:hover {
    color: var(--text-primary);
    background: var(--bg-hover);
}

.rte-editor .rte-highlight {
    background: rgba(245, 158, 11, 0.3);
    padding: 1px 0;
}

.rte-editor mark {
    background: #fef08a;
    color: #1a1a2e;
    padding: 1px 4px;
    border-radius: 2px;
}

[data-theme="dark"] .rte-editor mark {
    background: #a68b00;
    color: #f5f5f5;
}

.rte-editor .rte-selected-text {
    background: var(--accent-light);
}

.rte-fullscreen .rte-wrap {
    position: fixed;
    inset: 0;
    z-index: 999;
    max-width: none;
    height: 100vh;
    background: var(--bg-primary);
}

.rte-fullscreen .content-header,
.rte-fullscreen .sidebar {
    display: none;
}

.rte-fullscreen .main-content {
    height: 100vh;
}

.rte-fullscreen .rte-toolbar {
    border-radius: 0;
    border-left: none;
    border-right: none;
    border-top: none;
}

.rte-fullscreen .rte-editor-wrapper {
    border-radius: 0;
    border-left: none;
    border-right: none;
    border-bottom: none;
}

.rte-variables-bar {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 8px 18px;
    background: var(--bg-tertiary);
    border-bottom: 1px solid var(--border-color);
    flex-shrink: 0;
    flex-wrap: wrap;
}

.rte-variables-label {
    font-size: 0.78rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    color: var(--text-muted);
    margin-right: 4px;
}

.rte-var-btn {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 5px 14px;
    background: var(--bg-elevated);
    border: 1px solid var(--border-color);
    border-radius: 20px;
    color: var(--accent);
    font-size: 0.82rem;
    font-family: var(--font-mono);
    cursor: pointer;
    transition: all 0.15s ease;
}

.rte-var-btn:hover {
    background: var(--accent-light);
    border-color: var(--accent);
}

.rte-templates-bar {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 8px 18px;
    background: var(--bg-tertiary);
    border-bottom: 1px solid var(--border-color);
    flex-shrink: 0;
    flex-wrap: wrap;
}

.rte-template-btn {
    display: inline-flex;
    align-items: center;
    gap: 5px;
    padding: 6px 14px;
    background: var(--bg-elevated);
    border: 1px solid var(--border-color);
    border-radius: 20px;
    color: var(--text-secondary);
    font-size: 0.82rem;
    cursor: pointer;
    transition: all 0.15s ease;
    font-weight: 500;
}

.rte-template-btn:hover {
    background: var(--accent-light);
    border-color: var(--accent);
    color: var(--accent);
    transform: translateY(-1px);
}

.rte-template-btn i {
    font-size: 0.78rem;
}

.rte-action-bar {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 12px 18px;
    background: var(--bg-secondary);
    border-bottom: 1px solid var(--border-color);
    flex-shrink: 0;
    flex-wrap: wrap;
}

.rte-action-label {
    font-size: 0.8rem;
    font-weight: 700;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.5px;
    margin-right: 8px;
}

.rte-btn-copy-all {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 10px;
    padding: 12px 28px;
    background: linear-gradient(135deg, var(--accent), #5a52e0);
    color: #fff;
    border: none;
    border-radius: var(--radius-lg);
    font-size: 1.05rem;
    font-weight: 700;
    font-family: var(--font-family);
    cursor: pointer;
    transition: all 0.2s ease;
    box-shadow: 0 4px 16px rgba(108,99,255,0.3);
    min-width: 180px;
}

.rte-btn-copy-all:hover {
    transform: translateY(-2px);
    box-shadow: 0 6px 24px rgba(108,99,255,0.45);
}

.rte-btn-copy-all:active {
    transform: translateY(0);
    box-shadow: 0 2px 8px rgba(108,99,255,0.25);
}

.rte-btn-copy-all i {
    font-size: 1.2rem;
}

.rte-btn-copy-all.copied {
    background: linear-gradient(135deg, var(--success), #1ea34d);
    box-shadow: 0 4px 16px rgba(34,197,94,0.3);
}

.rte-btn-copy-plain {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    padding: 10px 20px;
    background: var(--bg-tertiary);
    color: var(--text-secondary);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-lg);
    font-size: 0.9rem;
    font-weight: 600;
    font-family: var(--font-family);
    cursor: pointer;
    transition: all 0.15s ease;
}

.rte-btn-copy-plain:hover {
    background: var(--bg-hover);
    color: var(--text-primary);
    border-color: var(--accent);
    transform: translateY(-1px);
}

.rte-btn-copy-plain i {
    font-size: 1rem;
}

.rte-export-group {
    display: flex;
    align-items: center;
    gap: 4px;
    margin-left: auto;
}

.rte-export-btn {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 8px 14px;
    background: transparent;
    color: var(--text-muted);
    border: 1px solid transparent;
    border-radius: var(--radius-md);
    font-size: 0.78rem;
    font-weight: 600;
    font-family: var(--font-family);
    cursor: pointer;
    transition: all 0.15s ease;
}

.rte-export-btn:hover {
    background: var(--bg-hover);
    color: var(--text-secondary);
    border-color: var(--border-color);
}

.rte-export-btn i {
    font-size: 0.85rem;
}

.rte-color-popup {
    position: absolute;
    top: 100%;
    left: 0;
    z-index: 100;
    background: var(--bg-elevated);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-lg);
    padding: 14px;
    display: flex;
    flex-direction: column;
    gap: 10px;
    min-width: 200px;
}

.rte-color-row {
    display: flex;
    align-items: center;
    gap: 8px;
    flex-wrap: wrap;
}

.rte-color-swatch {
    width: 32px;
    height: 32px;
    border-radius: 50%;
    border: 2px solid transparent;
    cursor: pointer;
    transition: all 0.15s ease;
}

.rte-color-swatch:hover {
    transform: scale(1.2);
    border-color: var(--text-primary);
    box-shadow: 0 0 0 3px var(--accent-light);
}

.rte-color-input {
    width: 100px;
    height: 34px;
    padding: 0 4px;
    border: 1px solid var(--border-color);
    border-radius: var(--radius-md);
    background: var(--bg-primary);
    cursor: pointer;
}

.rte-color-clear {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 6px 14px;
    background: transparent;
    border: 1px solid var(--border-color);
    border-radius: var(--radius-md);
    color: var(--text-muted);
    font-size: 0.82rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.15s ease;
}

.rte-color-clear:hover {
    background: var(--bg-hover);
    color: var(--text-primary);
}

.rte-link-popup {
    position: absolute;
    top: 100%;
    left: 0;
    z-index: 100;
    background: var(--bg-elevated);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-lg);
    padding: 14px;
    display: flex;
    flex-direction: column;
    gap: 10px;
    min-width: 320px;
}

.rte-link-input-group {
    display: flex;
    align-items: center;
    gap: 8px;
}

.rte-link-input {
    flex: 1;
    padding: 10px 14px;
    background: var(--bg-primary);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-md);
    color: var(--text-primary);
    font-size: 0.9rem;
    font-family: var(--font-family);
    outline: none;
}

.rte-link-input:focus {
    border-color: var(--accent);
    box-shadow: 0 0 0 3px var(--accent-light);
}

.rte-link-input::placeholder {
    color: var(--text-muted);
}

.rte-link-btn {
    padding: 10px 18px;
    background: var(--accent);
    color: #fff;
    border: none;
    border-radius: var(--radius-md);
    font-size: 0.85rem;
    font-weight: 700;
    cursor: pointer;
    transition: all 0.15s ease;
}

.rte-link-btn:hover {
    background: var(--accent-hover);
    transform: translateY(-1px);
}

/* ── Image resize ── */
.rte-img-box {
    display: inline-block;
    max-width: 100%;
    position: relative;
    vertical-align: bottom;
    overflow: hidden;
    line-height: 0;
    border: 2px solid transparent;
    border-radius: 4px;
    transition: border-color 0.15s ease, box-shadow 0.15s ease;
    margin: 4px 2px;
}

.rte-img-box::after {
    content: '';
    position: absolute;
    right: 0;
    bottom: 0;
    width: 14px;
    height: 14px;
    background: var(--accent);
    border: 2px solid #fff;
    border-radius: 3px;
    cursor: nwse-resize;
    opacity: 0;
    transition: opacity 0.15s ease;
    box-shadow: 0 1px 4px rgba(0,0,0,0.2);
    z-index: 2;
    pointer-events: none;
}

.rte-img-box:hover::after {
    opacity: 0.6;
}

.rte-img-box.selected {
    border-color: var(--accent);
    box-shadow: 0 0 0 1px var(--accent), 0 4px 16px rgba(108,99,255,0.15);
}

.rte-img-box.selected::after {
    opacity: 1;
}

.rte-img-box img {
    display: block;
    width: 100% !important;
    height: auto !important;
    max-width: 100%;
    border-radius: 2px;
    user-select: none;
    -webkit-user-drag: none;
    pointer-events: none;
}

/* Custom resize handle overlay (fixed to viewport) */
.rte-img-resize-handle {
    position: fixed;
    width: 20px;
    height: 20px;
    background: var(--accent);
    border: 3px solid #fff;
    border-radius: 50%;
    cursor: nwse-resize;
    z-index: 999999;
    box-shadow: 0 2px 10px rgba(0,0,0,0.4);
    pointer-events: all;
    transition: transform 0.1s ease, box-shadow 0.1s ease;
}

.rte-img-resize-handle:hover {
    transform: scale(1.3);
    box-shadow: 0 4px 16px rgba(108,99,255,0.6);
}

.rte-img-resize-handle:active {
    transform: scale(1.15);
    box-shadow: 0 2px 8px rgba(108,99,255,0.4);
    background: var(--accent-hover);
}

.rte-img-size-badge {
    position: fixed;
    z-index: 999999;
    transform: translateX(-50%);
    background: #1e1e2e;
    color: #fff;
    padding: 4px 12px;
    border-radius: 6px;
    font-size: 0.75rem;
    font-weight: 600;
    font-family: monospace;
    white-space: nowrap;
    box-shadow: 0 2px 12px rgba(0,0,0,0.4);
    pointer-events: none;
}

@media (max-width: 1024px) {
    .rte-export-group {
        margin-left: 0;
        width: 100%;
        justify-content: flex-start;
        padding-top: 6px;
        border-top: 1px solid var(--border-color);
    }

    .rte-action-bar {
        gap: 8px;
    }

    .rte-btn-copy-all {
        padding: 10px 20px;
        font-size: 0.95rem;
        min-width: 140px;
        flex: 1;
    }

    .rte-btn-copy-plain {
        flex: 1;
    }
}

@media (max-width: 768px) {
    .rte-toolbar {
        padding: 8px 10px;
        gap: 3px;
        overflow-x: auto;
        flex-wrap: nowrap;
        -webkit-overflow-scrolling: touch;
    }

    .rte-toolbar-group {
        flex-shrink: 0;
    }

    .rte-editor {
        padding: 18px;
        font-size: 1rem;
    }

    .rte-wrap {
        height: calc(100vh - 120px);
    }

    .rte-variables-bar,
    .rte-templates-bar,
    .rte-action-bar {
        padding: 6px 12px;
    }

    .rte-btn-copy-all {
        padding: 10px 16px;
        font-size: 0.9rem;
        min-width: auto;
    }

    .rte-btn-copy-plain {
        padding: 8px 14px;
        font-size: 0.82rem;
    }

    .rte-status-bar {
        padding: 8px 14px;
        font-size: 0.78rem;
        flex-wrap: wrap;
        gap: 6px;
    }

    .rte-search-bar {
        padding: 8px 12px;
    }

    .rte-search-input {
        min-width: 100px;
        font-size: 0.82rem;
        padding: 8px 12px;
    }
}
