/* Dashboard layout — sidebar + main content */
:root {
    --bg-primary: #0a0a0a;
    --bg-secondary: #141414;
    --bg-tertiary: #1a1a1a;
    --bg-card: #1c1c1c;
    --bg-hover: #222;
    --text: #e5e5e5;
    --text-primary: #e5e5e5;
    --text-secondary: #999;
    --text-muted: #666;
    --accent: #FF6B35;
    --accent-hover: #ff8555;
    --border: #2a2a2a;
    --user-bubble: #FF6B35;
    --user-text: #fff;
    --assistant-bubble: #1e1e1e;
    --assistant-text: #e5e5e5;
    --danger: #ef4444;
    --success: #22c55e;
    --radius: 12px;
    --radius-sm: 8px;
    --sidebar-width: 260px;
}

/* Light theme — overrides only the vars that change; the rest inherit from :root.
   --accent, --user-bubble, --user-text stay identical in both themes. */
:root[data-theme="light"] {
    --bg-primary: #ffffff;
    --bg-secondary: #f5f5f7;
    --bg-tertiary: #ececef;
    --bg-card: #ffffff;
    --bg-hover: #ececef;
    --text-primary: #18181b;
    --text-secondary: #52525b;
    --text-muted: #8a8a93;
    --text: #18181b;
    --border: #e3e3e7;
    --accent-hover: #e85a28;
    --assistant-bubble: #f0f0f2;
    --assistant-text: #18181b;
    --danger: #dc2626;
    --success: #16a34a;
}

* { margin: 0; padding: 0; box-sizing: border-box; }

body {
    font-family: 'Inter', system-ui, -apple-system, sans-serif;
    background: var(--bg-primary);
    color: var(--text-primary);
    min-height: 100vh;
}

/* Sidebar */
.sidebar {
    position: fixed;
    left: 0; top: 0; bottom: 0;
    width: var(--sidebar-width);
    background: var(--bg-secondary);
    border-right: 1px solid var(--border);
    display: flex;
    flex-direction: column;
    z-index: 100;
    transition: transform 0.3s ease;
}

.sidebar-brand {
    padding: 20px;
    display: flex;
    align-items: center;
    gap: 10px;
    border-bottom: 1px solid var(--border);
    text-decoration: none;
    color: var(--text-primary);
}

.sidebar-brand .brand-emoji { font-size: 28px; }
.sidebar-brand h2 { font-size: 20px; font-weight: 700; }

.sidebar-nav {
    flex: 1;
    min-height: 0; /* allow this flex child to shrink below content so overflow can scroll */
    overflow-y: auto; /* scroll the nav when Crew sub-agents push it past the viewport */
    padding: 12px;
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.sidebar-nav a {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 12px 16px;
    border-radius: var(--radius-sm);
    text-decoration: none;
    color: var(--text-secondary);
    font-size: 14px;
    font-weight: 500;
    transition: background-color 0.15s, color 0.15s;
}

.sidebar-nav a:hover { background: var(--bg-hover); color: var(--text-primary); }
.sidebar-nav a.active { background: var(--accent); color: #fff; }
.sidebar-nav a .nav-icon { font-size: 18px; width: 24px; text-align: center; }

.sidebar-user {
    padding: 16px 20px;
    border-top: 1px solid var(--border);
    display: flex;
    align-items: center;
    gap: 12px;
}

.sidebar-user img {
    width: 36px; height: 36px;
    border-radius: 50%;
    object-fit: cover;
}

.sidebar-user .user-info { flex: 1; min-width: 0; }
.sidebar-user .user-name { font-size: 13px; font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.sidebar-user .user-email { font-size: 11px; color: var(--text-muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

/* Main content area */
.main-content {
    margin-left: var(--sidebar-width);
    min-height: 100vh;
    display: flex;
    flex-direction: column;
}

/* Mobile nav */
.mobile-nav {
    display: none;
    position: fixed;
    bottom: 0; left: 0; right: 0;
    background: var(--bg-secondary);
    border-top: 1px solid var(--border);
    z-index: 100;
    padding: 8px 0 calc(8px + env(safe-area-inset-bottom));
}

.mobile-nav-inner {
    display: flex;
    justify-content: space-around;
}

.mobile-nav a {
    display: flex;
    flex: 1 1 0;
    min-width: 0;
    flex-direction: column;
    align-items: center;
    gap: 4px;
    padding: 6px 2px;
    text-decoration: none;
    color: var(--text-muted);
    font-size: 10px;
    font-weight: 500;
    white-space: nowrap;
}

.mobile-nav a.active { color: var(--accent); }
.mobile-nav a .nav-icon { font-size: 20px; }

/* Mobile hamburger */
.mobile-header {
    display: none;
    position: fixed;
    top: 0; left: 0; right: 0;
    background: var(--bg-secondary);
    border-bottom: 1px solid var(--border);
    padding: 12px 16px;
    z-index: 99;
    align-items: center;
    gap: 12px;
}

.mobile-header .brand-emoji { font-size: 24px; }
.mobile-header h2 { font-size: 18px; font-weight: 700; flex: 1; }

/* Buttons */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    padding: 10px 20px;
    border-radius: var(--radius-sm);
    font-size: 14px;
    font-weight: 600;
    border: none;
    cursor: pointer;
    transition: background-color 0.15s, color 0.15s, border-color 0.15s, opacity 0.15s, box-shadow 0.15s, transform 0.15s;
    font-family: inherit;
}

.btn-primary { background: var(--accent); color: #fff; }
.btn-primary:hover { background: var(--accent-hover); }
.btn-secondary { background: var(--bg-tertiary); color: var(--text-primary); border: 1px solid var(--border); }
.btn-secondary:hover { background: var(--bg-hover); }
.btn-danger { background: var(--danger); color: #fff; }
.btn-danger:hover { opacity: 0.9; }
.btn-sm { padding: 6px 14px; font-size: 13px; }
.btn.loading { opacity: 0.6; pointer-events: none; }

/* Page header */
.page-header {
    padding: 24px 32px;
    border-bottom: 1px solid var(--border);
}

.page-header h1 { font-size: 24px; font-weight: 700; }
.page-header p { color: var(--text-secondary); font-size: 14px; margin-top: 4px; }

/* Cards */
.card {
    background: var(--bg-tertiary);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 20px;
}

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

.empty-state .empty-icon { font-size: 48px; margin-bottom: 16px; }
.empty-state h3 { font-size: 18px; color: var(--text-secondary); margin-bottom: 8px; }
.empty-state p { font-size: 14px; }

/* Loading spinner */
.spinner {
    width: 24px; height: 24px;
    border: 3px solid var(--border);
    border-top-color: var(--accent);
    border-radius: 50%;
    animation: spin 0.8s linear infinite;
}

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

/* Responsive */
@media (max-width: 768px) {
    .sidebar { transform: translateX(-100%); }
    .sidebar.open { transform: translateX(0); }
    .main-content { margin-left: 0; padding-bottom: 70px; }
    .mobile-nav { display: block; }
    .mobile-header { display: flex; }
    .page-header { padding: 16px; padding-top: 68px; }
}

/* ============================================================
   Home dashboard (home.html / home.js)
   ============================================================ */
.home-wrap { width: 100%; max-width: 1080px; margin: 0 auto; padding: 28px 28px 60px; }

/* Hero */
.home-hero {
    display: flex; align-items: center; justify-content: space-between; gap: 20px;
    background: linear-gradient(135deg, rgba(255,107,53,0.14), rgba(255,107,53,0.02));
    border: 1px solid var(--border); border-radius: var(--radius);
    padding: 22px 24px; margin-bottom: 26px;
}
.home-hero-text h1 { font-size: 24px; font-weight: 800; letter-spacing: -0.4px; }
.home-hero-sub { color: var(--text-secondary); font-size: 14px; margin-top: 6px; max-width: 640px; line-height: 1.5; }
.home-hero-cta {
    flex-shrink: 0; display: inline-flex; align-items: center; gap: 8px;
    background: var(--accent); color: #fff; text-decoration: none;
    padding: 11px 18px; border-radius: var(--radius-sm); font-weight: 600; font-size: 14px;
    transition: background 0.15s, transform 0.05s;
}
.home-hero-cta:hover { background: var(--accent-hover); }
.home-hero-cta:active { transform: translateY(1px); }

/* Section titles */
.home-section-title {
    font-size: 13px; font-weight: 700; text-transform: uppercase; letter-spacing: 0.8px;
    color: var(--text-secondary); margin: 26px 2px 14px; display: flex; align-items: center; gap: 8px;
}
.home-section-title i { color: var(--accent); font-size: 13px; }

/* Stat grid */
.home-stats { display: grid; grid-template-columns: repeat(auto-fit, minmax(168px, 1fr)); gap: 12px; }
.home-stat {
    background: var(--bg-secondary); border: 1px solid var(--border); border-radius: var(--radius);
    padding: 16px 16px 14px; text-decoration: none; color: var(--text-primary);
    display: flex; flex-direction: column; gap: 2px; transition: border-color 0.15s, transform 0.1s, background 0.15s;
}
.home-stat:hover { border-color: var(--accent); background: var(--bg-tertiary); }
@media (hover: hover) and (pointer: fine) {
    .home-stat:hover { transform: translateY(-2px); }
}
.home-stat.accent { border-left: 3px solid var(--accent); }
.home-stat.muted { opacity: 0.82; }
.home-stat-ic { font-size: 16px; color: var(--accent); margin-bottom: 6px; }
.home-stat.muted .home-stat-ic { color: var(--text-secondary); }
.home-stat-v { font-size: 28px; font-weight: 800; line-height: 1.1; letter-spacing: -0.5px; }
.home-stat-l { font-size: 13px; font-weight: 600; }
.home-stat-s { font-size: 11.5px; color: var(--text-muted); margin-top: 2px; }
.home-stat-skeleton {
    height: 108px; border-radius: var(--radius); border: 1px solid var(--border);
    background: linear-gradient(90deg, var(--bg-secondary), var(--bg-tertiary), var(--bg-secondary));
    background-size: 200% 100%; animation: home-shimmer 1.3s infinite;
}
@keyframes home-shimmer { 0% { background-position: 200% 0; } 100% { background-position: -200% 0; } }

/* Two-column row */
.home-cols { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; margin-top: 16px; }
.home-card { background: var(--bg-secondary); border: 1px solid var(--border); border-radius: var(--radius); padding: 18px 20px; }
.home-card-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 14px; }
.home-card-head h3 { font-size: 15px; font-weight: 700; display: flex; align-items: center; gap: 9px; }
.home-card-head h3 i { color: var(--accent); font-size: 14px; }

/* Setup checklist */
.home-setup-progress { font-size: 12px; color: var(--text-muted); font-weight: 600; }
.home-progress { height: 6px; background: var(--bg-tertiary); border-radius: 3px; overflow: hidden; margin-bottom: 14px; }
/* motion-audit: allow layout-prop — fill width set from JS (home.js) */ /* motion-audit: allow slow-ui — explanatory progress fill */
.home-progress-fill { height: 100%; background: var(--accent); border-radius: 3px; transition: width 0.5s ease; }
.home-steps { display: flex; flex-direction: column; gap: 2px; }
.home-step { display: flex; align-items: center; gap: 11px; padding: 9px 4px; border-bottom: 1px solid var(--border); }
.home-step:last-child { border-bottom: none; }
.home-step-ring { width: 20px; height: 20px; flex-shrink: 0; border-radius: 50%; border: 2px solid var(--border); display: flex; align-items: center; justify-content: center; font-size: 10px; color: #fff; }
.home-step.done .home-step-ring { background: var(--success); border-color: var(--success); }
.home-step-label { flex: 1; font-size: 13.5px; color: var(--text-primary); }
.home-step.done .home-step-label { color: var(--text-muted); text-decoration: line-through; }
.home-step-cta { flex-shrink: 0; background: transparent; border: 1px solid var(--accent); color: var(--accent); border-radius: 999px; padding: 4px 13px; font-size: 12px; font-weight: 600; cursor: pointer; transition: background-color 0.15s, color 0.15s; }
.home-step-cta:hover { background: var(--accent); color: #fff; }

/* Recent wins */
.home-results { display: flex; flex-direction: column; gap: 2px; }
.home-result { display: flex; align-items: flex-start; gap: 11px; padding: 9px 4px; border-bottom: 1px solid var(--border); }
.home-result:last-child { border-bottom: none; }
.home-result-ic { font-size: 16px; flex-shrink: 0; line-height: 1.4; }
.home-result-t { font-size: 13.5px; font-weight: 500; }
.home-result-m { font-size: 11.5px; color: var(--text-muted); margin-top: 1px; }
.home-results-empty { text-align: center; color: var(--text-muted); font-size: 13px; line-height: 1.6; padding: 26px 10px; }
.home-results-empty-ic { font-size: 32px; margin-bottom: 8px; }

/* Learn / tour card */
.home-learn { display: flex; align-items: center; gap: 18px; margin-top: 16px; background: linear-gradient(120deg, rgba(255,107,53,0.10), var(--bg-secondary)); }
.home-learn-icon { width: 48px; height: 48px; flex-shrink: 0; border-radius: 12px; background: var(--accent); color: #fff; display: flex; align-items: center; justify-content: center; font-size: 22px; }
.home-learn-text { flex: 1; min-width: 0; }
.home-learn-text h3 { font-size: 15px; font-weight: 700; }
.home-learn-text p { font-size: 13px; color: var(--text-secondary); margin-top: 4px; line-height: 1.45; }
.home-learn-actions { display: flex; gap: 9px; flex-shrink: 0; }
.home-btn { text-decoration: none; padding: 9px 15px; border-radius: var(--radius-sm); font-size: 13px; font-weight: 600; white-space: nowrap; }
.home-btn-primary { background: var(--accent); color: #fff; }
.home-btn-primary:hover { background: var(--accent-hover); }
.home-btn-ghost { border: 1px solid var(--border); color: var(--text-secondary); }
.home-btn-ghost:hover { border-color: var(--accent); color: var(--text-primary); }

/* Use-case gallery */
.home-usecases { display: grid; grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)); gap: 12px; }
.home-uc {
    text-align: left; cursor: pointer; background: var(--bg-secondary); border: 1px solid var(--border);
    border-radius: var(--radius); padding: 16px; display: flex; flex-direction: column; gap: 3px;
    color: var(--text-primary); font-family: inherit; transition: border-color 0.15s, transform 0.1s, background 0.15s;
}
.home-uc:hover { border-color: var(--accent); background: var(--bg-tertiary); }
@media (hover: hover) and (pointer: fine) {
    .home-uc:hover { transform: translateY(-2px); }
}
.home-uc-ic { font-size: 22px; margin-bottom: 5px; }
.home-uc-l1 { font-size: 13.5px; font-weight: 600; line-height: 1.3; }
.home-uc-l2 { font-size: 11px; font-weight: 700; text-transform: uppercase; letter-spacing: 0.5px; color: var(--accent); margin-top: 3px; }

@media (max-width: 860px) {
    .home-wrap { padding: 18px 16px 60px; }
    .home-hero { flex-direction: column; align-items: flex-start; gap: 14px; }
    .home-hero-cta { width: 100%; justify-content: center; }
    .home-cols { grid-template-columns: 1fr; }
    .home-learn { flex-direction: column; align-items: flex-start; }
    .home-learn-actions { width: 100%; }
    .home-btn { flex: 1; text-align: center; }
}

/* Mobile only: the fixed .mobile-header (~57px) shows at <=768px. Pages that
   lead with a toolbar/hero instead of .page-header (which already carries this
   offset) need their own header clearance, or their first row clips under the
   fixed header. Home → .home-wrap; Memory/Loop/Jobs → their first toolbar. */
@media (max-width: 768px) {
    .home-wrap { padding-top: 74px; }
    .memory-toolbar, .loop-toolbar, .jobs-toolbar { margin-top: 57px; }
}

/* ── Skills page (curated skills: suggested + installed + detail modal) ── */
.skills-section-title {
    display: flex; align-items: center; gap: 8px;
    font-size: 12px; font-weight: 700; text-transform: uppercase; letter-spacing: 0.5px;
    color: var(--text-muted); padding: 0 32px; margin: 22px 0 12px;
}
.skills-section-title i { color: var(--accent); }
.skills-suggested-list { display: flex; flex-direction: column; gap: 12px; padding: 0 32px; }
.skills-list { padding: 0 32px 24px; display: grid; grid-template-columns: repeat(auto-fill, minmax(300px, 1fr)); gap: 12px; }

/* Suggestion card — pending workflow the user approves / dismisses */
.skill-suggestion {
    background: var(--bg-secondary); border: 1px solid var(--accent);
    border-radius: var(--radius); padding: 16px;
}
.skill-suggestion-head { display: flex; align-items: center; gap: 10px; margin-bottom: 8px; }
.skill-suggestion-name { font-size: 15px; font-weight: 600; color: var(--text-primary); flex: 1; min-width: 0; }
.skill-evidence-chip {
    font-size: 11px; font-weight: 600; padding: 2px 8px; border-radius: 999px;
    background: rgba(255,107,53,0.15); color: var(--accent); white-space: nowrap;
}
.skill-suggestion-trigger { font-size: 13px; color: var(--text-secondary); margin-bottom: 4px; }
.skill-suggestion-why { font-size: 13px; color: var(--text-muted); line-height: 1.5; margin-bottom: 12px; }
.skill-suggestion-actions { display: flex; gap: 8px; flex-wrap: wrap; }

/* Installed skill card */
.skill-card {
    background: var(--bg-secondary); border: 1px solid var(--border);
    border-radius: var(--radius); padding: 16px; cursor: pointer; transition: border-color 0.15s, transform 0.15s;
}
.skill-card:hover { border-color: var(--accent); }
@media (hover: hover) and (pointer: fine) {
    .skill-card:hover { transform: translateY(-1px); }
}
.skill-card-head { display: flex; align-items: center; gap: 10px; margin-bottom: 8px; }
.skill-card-head i { color: var(--accent); }
.skill-card-name { font-size: 14px; font-weight: 600; color: var(--text-primary); flex: 1; min-width: 0; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.skill-card-size { font-size: 11px; color: var(--text-muted); white-space: nowrap; }
.skill-card-desc { font-size: 13px; color: var(--text-secondary); line-height: 1.5; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }

/* Shared skill action buttons (suggestion + modal) */
.skill-btn {
    padding: 7px 14px; border-radius: var(--radius-sm); border: 1px solid var(--border);
    background: var(--bg-tertiary); color: var(--text-primary); font-size: 13px; font-weight: 500;
    cursor: pointer; transition: background-color 0.15s, color 0.15s, border-color 0.15s;
}
.skill-btn:hover { border-color: var(--accent); }
.skill-btn:disabled { opacity: 0.6; cursor: default; }
.skill-btn-approve, .skill-btn-edit { background: var(--accent); color: #fff; border-color: var(--accent); }
.skill-btn-approve:hover, .skill-btn-edit:hover { background: var(--accent-hover); border-color: var(--accent-hover); }
.skill-btn-dismiss, .skill-btn-delete { color: var(--danger); border-color: rgba(239,68,68,0.4); }
.skill-btn-dismiss:hover, .skill-btn-delete:hover { background: rgba(239,68,68,0.12); border-color: var(--danger); }

/* Detail / edit modal */
.skill-detail-overlay { display: none; position: fixed; inset: 0; background: rgba(0,0,0,0.6); z-index: 100; }
.skill-detail-overlay.active { display: flex; align-items: center; justify-content: center; }
.skill-detail-panel {
    background: var(--bg-secondary); border: 1px solid var(--border); border-radius: var(--radius);
    max-width: 680px; width: 90%; max-height: 84vh; overflow-y: auto; padding: 24px; position: relative;
}
.skill-detail-close { position: absolute; top: 12px; right: 12px; background: none; border: none; color: var(--text-muted); font-size: 24px; cursor: pointer; padding: 4px 10px; }
.skill-detail-close:hover { color: var(--text-primary); }
.skill-detail-title { font-size: 18px; font-weight: 600; margin-bottom: 16px; padding-right: 32px; color: var(--text-primary); }
.skill-detail-hint { font-size: 13px; color: var(--text-muted); margin-bottom: 12px; }
.skill-detail-content { font-size: 14px; color: var(--text-secondary); line-height: 1.6; word-break: break-word; }
.skill-detail-content pre { background: var(--bg-primary); padding: 10px; border-radius: var(--radius-sm); overflow-x: auto; font-size: 12.5px; white-space: pre-wrap; word-break: break-word; }
.skill-detail-content code { background: var(--bg-primary); padding: 2px 5px; border-radius: 4px; font-size: 12.5px; }
.skill-detail-content h1, .skill-detail-content h2, .skill-detail-content h3 { color: var(--text-primary); margin: 14px 0 8px; }
.skill-edit-textarea {
    width: 100%; box-sizing: border-box; margin: 6px 0; padding: 12px;
    border: 1px solid var(--border); border-radius: var(--radius-sm);
    background: var(--bg-primary); color: var(--text-primary); font-size: 13px;
    font-family: ui-monospace, SFMono-Regular, Menlo, monospace; line-height: 1.55; outline: none; resize: vertical;
}
.skill-edit-textarea:focus { border-color: var(--accent); }
.skill-detail-actions { display: flex; gap: 10px; margin-top: 18px; flex-wrap: wrap; }

@media (max-width: 768px) {
    .skills-section-title { padding: 0 16px; }
    .skills-suggested-list { padding: 0 16px; }
    .skills-list { padding: 0 16px 80px; grid-template-columns: 1fr; }
    .skill-detail-panel { padding: 20px 16px; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: 1ms !important; animation-iteration-count: 1 !important; transition-duration: 1ms !important; scroll-behavior: auto !important; }
}
