/* =============================================
   JUNAID KHALID — Portfolio
   Clean, refined, editorial.
   ============================================= */

:root {
    --font-sans: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
    --font-serif: 'Fraunces', Georgia, 'Times New Roman', serif;

    /* Warm light palette */
    --bg: #fafaf7;
    --bg-soft: #f3f2ed;
    --bg-card: #ffffff;
    --bg-tint: #f7f5ef;
    --border: #e8e5dc;
    --border-strong: #d6d3c7;

    --text: #1a1a17;
    --text-2: #38383a;
    --text-3: #6b6b6e;
    --text-4: #a3a39f;

    --accent: #b8410e;
    --accent-hover: #962f06;
    --accent-soft: #fbeee5;

    --radius: 14px;
    --radius-sm: 8px;
    --radius-pill: 999px;

    --max: 1160px;
    --gutter: clamp(20px, 4vw, 44px);

    --shadow-sm: 0 1px 2px rgba(24, 24, 27, 0.04);
    --shadow-md: 0 10px 30px -16px rgba(24, 24, 27, 0.18);
    --shadow-lg: 0 24px 60px -28px rgba(24, 24, 27, 0.22);
}

/* ---------- Reset ---------- */
*, *::before, *::after { margin: 0; padding: 0; box-sizing: border-box; }
html { font-size: 16px; scroll-behavior: smooth; -webkit-text-size-adjust: 100%; }
body {
    font-family: var(--font-sans);
    color: var(--text);
    background: var(--bg);
    line-height: 1.6;
    font-weight: 400;
    -webkit-font-smoothing: antialiased;
    text-rendering: optimizeLegibility;
    background-image:
        radial-gradient(1200px 600px at 80% -10%, rgba(184, 65, 14, 0.05), transparent 60%),
        radial-gradient(900px 500px at -10% 10%, rgba(184, 65, 14, 0.035), transparent 60%);
    background-attachment: fixed;
}
a { color: inherit; text-decoration: none; }
ul { list-style: none; }
img, svg { display: block; max-width: 100%; }
h1, h2, h3, h4 { font-weight: 600; letter-spacing: -0.02em; color: var(--text); }
::selection { background: var(--accent); color: #fff; }

/* ---------- Nav ---------- */
.nav {
    position: sticky;
    top: 0;
    z-index: 50;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 24px;
    padding: 16px var(--gutter);
    background: rgba(250, 250, 247, 0.78);
    backdrop-filter: saturate(180%) blur(14px);
    -webkit-backdrop-filter: saturate(180%) blur(14px);
    border-bottom: 1px solid var(--border);
}
.logo {
    font-family: var(--font-serif);
    font-weight: 500;
    font-size: 1.1rem;
    letter-spacing: -0.01em;
    color: var(--text);
}
.logo::after {
    content: '.';
    color: var(--accent);
}
.nav nav {
    display: flex;
    gap: 30px;
}
.nav nav a {
    font-size: 0.9rem;
    color: var(--text-3);
    transition: color 0.2s ease;
    position: relative;
}
.nav nav a::after {
    content: '';
    position: absolute;
    left: 0;
    bottom: -4px;
    width: 0;
    height: 1.5px;
    background: var(--accent);
    transition: width 0.2s ease;
}
.nav nav a:hover { color: var(--text); }
.nav nav a:hover::after { width: 100%; }
.nav-cta {
    font-size: 0.85rem;
    font-weight: 500;
    color: var(--text);
    padding: 9px 16px;
    border: 1px solid var(--border-strong);
    border-radius: var(--radius-pill);
    background: var(--bg-card);
    transition: all 0.2s ease;
}
.nav-cta:hover {
    border-color: var(--text);
    background: var(--text);
    color: #fff;
}
@media (max-width: 720px) {
    .nav nav { display: none; }
}

/* ---------- Layout ---------- */
main {
    max-width: var(--max);
    margin: 0 auto;
    padding: 0 var(--gutter);
}

.section {
    padding: 110px 0;
    border-top: 1px solid var(--border);
}
.section:first-of-type { border-top: none; }

.section-head { margin-bottom: 48px; }
.section-head .kicker {
    display: inline-block;
    font-size: 0.72rem;
    text-transform: uppercase;
    letter-spacing: 0.18em;
    color: var(--accent);
    margin-bottom: 14px;
    font-weight: 500;
}
.section-head h2 {
    font-family: var(--font-serif);
    font-weight: 400;
    font-size: clamp(1.9rem, 3.6vw, 2.6rem);
    line-height: 1.1;
    letter-spacing: -0.025em;
    margin-bottom: 10px;
}
.section-head h2 em {
    font-style: italic;
    color: var(--accent);
    font-weight: 400;
}
.section-head p {
    color: var(--text-3);
    font-size: 1.02rem;
    max-width: 52ch;
}
.section-head.center {
    text-align: center;
}
.section-head.center p { margin: 0 auto; }

/* ---------- Hero ---------- */
.hero {
    padding: 120px 0 100px;
    max-width: 820px;
}
.eyebrow {
    display: inline-flex;
    align-items: center;
    gap: 9px;
    padding: 7px 14px;
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius-pill);
    font-size: 0.82rem;
    color: var(--text-2);
    margin-bottom: 32px;
    box-shadow: var(--shadow-sm);
}
.dot {
    width: 7px;
    height: 7px;
    border-radius: 50%;
    background: #22c55e;
    box-shadow: 0 0 0 3px rgba(34, 197, 94, 0.18);
}
.hero h1 {
    font-family: var(--font-serif);
    font-weight: 400;
    font-size: clamp(2.3rem, 6vw, 4.2rem);
    line-height: 1.05;
    letter-spacing: -0.035em;
    margin-bottom: 26px;
    color: var(--text);
}
.hero h1 em {
    font-style: italic;
    color: var(--accent);
    font-weight: 400;
}
.hero h1 .underline {
    position: relative;
    display: inline-block;
}
.hero h1 .underline::after {
    content: '';
    position: absolute;
    left: 0;
    right: 0;
    bottom: 0.08em;
    height: 0.18em;
    background: var(--accent-soft);
    z-index: -1;
}
.hero .sub {
    font-size: 1.12rem;
    color: var(--text-2);
    max-width: 620px;
    line-height: 1.65;
    margin-bottom: 36px;
}
.hero-actions {
    display: flex;
    flex-wrap: wrap;
    gap: 12px;
    align-items: center;
}

/* ---------- Buttons ---------- */
.btn {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    padding: 13px 22px;
    background: var(--text);
    color: #fff;
    border-radius: var(--radius-pill);
    font-size: 0.92rem;
    font-weight: 500;
    transition: all 0.2s ease;
    border: 1px solid var(--text);
}
.btn:hover {
    background: var(--accent);
    border-color: var(--accent);
    transform: translateY(-1px);
    box-shadow: var(--shadow-md);
}
.btn-ghost {
    background: transparent;
    color: var(--text);
    border: 1px solid var(--border-strong);
}
.btn-ghost:hover {
    background: var(--bg-card);
    border-color: var(--text);
    color: var(--text);
}

/* ---------- Work list (typographic, no visuals) ---------- */
.work-list {
    display: flex;
    flex-direction: column;
    border-top: 1px solid var(--border);
}

.work-item {
    display: grid;
    grid-template-columns: 90px 1fr 40px;
    gap: 48px;
    align-items: baseline;
    padding: 56px 8px;
    border-bottom: 1px solid var(--border);
    color: var(--text);
    position: relative;
    overflow: hidden;
    transition: padding 0.35s ease, background 0.35s ease;
}
.work-item::before {
    content: '';
    position: absolute;
    left: 0;
    top: 0;
    bottom: 0;
    width: 3px;
    background: var(--accent-color, var(--accent));
    transform: scaleY(0);
    transform-origin: top;
    transition: transform 0.4s ease;
    z-index: 0;
}
.work-item::after {
    content: '';
    position: absolute;
    inset: 0;
    background: linear-gradient(90deg, var(--accent-color, var(--accent)) 0%, transparent 70%);
    opacity: 0;
    transition: opacity 0.4s ease;
    z-index: 0;
    pointer-events: none;
}
.work-item:hover::before { transform: scaleY(1); }
.work-item:hover::after  { opacity: 0.05; }
.work-item:hover {
    padding-left: 28px;
    padding-right: 28px;
}
.work-item > * { position: relative; z-index: 1; }

.work-num {
    font-family: var(--font-serif);
    font-style: italic;
    font-size: 2.4rem;
    color: var(--text-4);
    font-weight: 400;
    line-height: 1;
    transition: color 0.35s ease, transform 0.35s ease;
}
.work-item:hover .work-num {
    color: var(--accent-color, var(--accent));
    transform: translateY(-2px);
}

.work-info { min-width: 0; }

.work-meta {
    display: flex;
    align-items: center;
    gap: 10px;
    font-size: 0.72rem;
    text-transform: uppercase;
    letter-spacing: 0.16em;
    color: var(--text-3);
    margin-bottom: 14px;
    font-weight: 500;
}
.work-meta .work-year {
    color: var(--accent-color, var(--accent));
    font-weight: 600;
}
.work-meta .work-dot { color: var(--text-4); }

.work-info h3 {
    font-family: var(--font-serif);
    font-weight: 500;
    font-size: 2.4rem;
    letter-spacing: -0.025em;
    margin-bottom: 14px;
    line-height: 1.05;
    transition: color 0.35s ease, transform 0.35s ease;
}
.work-item:hover .work-info h3 {
    color: var(--accent-color, var(--accent));
}
.work-info p {
    font-size: 1.02rem;
    color: var(--text-3);
    margin-bottom: 22px;
    line-height: 1.65;
    max-width: 62ch;
}

.tags {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
}
.tags span {
    font-size: 0.72rem;
    color: var(--text-2);
    background: transparent;
    border: 1px solid var(--border);
    padding: 5px 12px;
    border-radius: var(--radius-pill);
    font-weight: 500;
    transition: all 0.3s ease;
}
.work-item:hover .tags span {
    background: var(--bg-card);
    border-color: var(--border-strong);
    color: var(--text);
}

.work-arrow {
    font-size: 1.5rem;
    color: var(--text-4);
    transition: all 0.35s ease;
    text-align: right;
    align-self: center;
}
.work-item:hover .work-arrow {
    color: var(--accent-color, var(--accent));
    transform: translateX(8px);
}

@media (max-width: 820px) {
    .work-item {
        grid-template-columns: 60px 1fr;
        gap: 20px;
        padding: 36px 4px;
    }
    .work-num { font-size: 1.8rem; }
    .work-info h3 { font-size: 1.7rem; }
    .work-arrow { display: none; }
    .work-item:hover {
        padding-left: 14px;
        padding-right: 14px;
    }
}

/* ---------- About + Stack ---------- */
.about-grid {
    display: grid;
    grid-template-columns: 1.25fr 1fr;
    gap: 72px;
}
@media (max-width: 820px) {
    .about-grid { grid-template-columns: 1fr; gap: 56px; }
}
.prose p {
    color: var(--text-2);
    font-size: 1.04rem;
    line-height: 1.75;
    margin-bottom: 16px;
}
.prose p:last-child { margin-bottom: 0; }
.prose p:first-child::first-letter {
    font-family: var(--font-serif);
    font-size: 3rem;
    font-weight: 500;
    float: left;
    line-height: 0.9;
    margin: 4px 10px 0 0;
    color: var(--accent);
}

.stack-list {
    display: flex;
    flex-direction: column;
    gap: 24px;
    padding: 28px;
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    box-shadow: var(--shadow-sm);
}
.stack-list h4 {
    font-size: 0.74rem;
    text-transform: uppercase;
    letter-spacing: 0.14em;
    color: var(--accent);
    margin-bottom: 6px;
    font-weight: 600;
}
.stack-list p {
    font-size: 0.96rem;
    color: var(--text);
    line-height: 1.5;
}

/* ---------- Experience ---------- */
.exp {
    display: flex;
    flex-direction: column;
}
.exp li {
    display: grid;
    grid-template-columns: 160px 1fr;
    gap: 36px;
    padding: 26px 0;
    border-top: 1px solid var(--border);
    transition: padding 0.2s ease;
}
.exp li:last-child { border-bottom: 1px solid var(--border); }
.exp li:hover {
    padding-left: 8px;
}
@media (max-width: 540px) {
    .exp li { grid-template-columns: 1fr; gap: 6px; }
    .exp li:hover { padding-left: 0; }
}
.when {
    font-family: var(--font-serif);
    font-style: italic;
    font-size: 0.95rem;
    color: var(--accent);
    padding-top: 3px;
}
.exp h3 {
    font-family: var(--font-serif);
    font-weight: 500;
    font-size: 1.18rem;
    letter-spacing: -0.015em;
    margin-bottom: 6px;
}
.exp p {
    font-size: 0.96rem;
    color: var(--text-3);
    max-width: 58ch;
    line-height: 1.6;
}

/* ---------- Contact ---------- */
.contact {
    text-align: center;
    padding-bottom: 90px;
}
.big-email {
    font-family: var(--font-serif);
    font-style: italic;
    font-weight: 400;
    display: inline-block;
    font-size: clamp(1.6rem, 5vw, 2.8rem);
    color: var(--text);
    border-bottom: 1.5px solid var(--text);
    padding-bottom: 6px;
    margin-top: 12px;
    word-break: break-word;
    transition: all 0.2s ease;
}
.big-email:hover {
    color: var(--accent);
    border-color: var(--accent);
}
.socials {
    margin-top: 40px;
    display: flex;
    justify-content: center;
    gap: 28px;
    flex-wrap: wrap;
}
.socials a {
    font-size: 0.92rem;
    color: var(--text-3);
    transition: color 0.2s ease;
    position: relative;
}
.socials a::after {
    content: '↗';
    margin-left: 4px;
    font-size: 0.85rem;
    opacity: 0.6;
}
.socials a:hover { color: var(--accent); }

/* ---------- Footer ---------- */
.footer {
    max-width: var(--max);
    margin: 0 auto;
    padding: 36px var(--gutter);
    border-top: 1px solid var(--border);
    display: flex;
    justify-content: space-between;
    align-items: center;
    flex-wrap: wrap;
    gap: 12px;
    font-size: 0.85rem;
    color: var(--text-3);
}
.footer span:first-child {
    font-family: var(--font-serif);
    font-style: italic;
}

/* ---------- Project Detail Page ---------- */
.detail {
    max-width: 880px;
    margin: 0 auto;
    padding: 72px var(--gutter) 110px;
}
.detail-back {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    font-size: 0.9rem;
    color: var(--text-3);
    margin-bottom: 40px;
    transition: all 0.2s ease;
}
.detail-back:hover {
    color: var(--accent);
    gap: 12px;
}
.detail-back svg { width: 14px; height: 14px; }

.detail-title {
    font-family: var(--font-serif);
    font-weight: 400;
    font-size: clamp(2.2rem, 5.5vw, 3.4rem);
    line-height: 1.05;
    letter-spacing: -0.03em;
    margin-bottom: 40px;
    max-width: 18ch;
}

.detail-meta {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 32px;
    padding: 26px 0;
    border-top: 1px solid var(--border);
    border-bottom: 1px solid var(--border);
    margin-bottom: 48px;
}
@media (max-width: 640px) {
    .detail-meta { grid-template-columns: 1fr; gap: 18px; }
}
.detail-meta .label {
    font-size: 0.7rem;
    text-transform: uppercase;
    letter-spacing: 0.14em;
    color: var(--accent);
    margin-bottom: 8px;
    font-weight: 600;
}
.detail-meta .val {
    font-size: 0.96rem;
    color: var(--text);
    line-height: 1.55;
}
.detail-meta .val a {
    color: var(--accent);
    margin-right: 14px;
    border-bottom: 1px solid transparent;
    transition: border-color 0.2s ease;
}
.detail-meta .val a:hover { border-color: var(--accent); }

.detail-prose { margin-bottom: 56px; }
.detail-prose h3 {
    font-size: 0.74rem;
    text-transform: uppercase;
    letter-spacing: 0.14em;
    color: var(--accent);
    margin: 32px 0 14px;
    font-weight: 600;
}
.detail-prose h3:first-child { margin-top: 0; }
.detail-prose p,
.detail-prose ul {
    color: var(--text-2);
    font-size: 1.04rem;
    line-height: 1.75;
    margin-bottom: 16px;
}
.detail-prose ul {
    list-style: none;
    padding-left: 0;
}
.detail-prose li {
    position: relative;
    padding-left: 24px;
    margin-bottom: 8px;
}
.detail-prose li::before {
    content: '';
    position: absolute;
    left: 4px; top: 0.7em;
    width: 7px; height: 7px;
    border-radius: 50%;
    background: var(--accent);
}

.detail-images {
    display: grid;
    gap: 20px;
}
.detail-images img {
    width: 100%;
    border-radius: var(--radius);
    border: 1px solid var(--border);
    background: var(--bg-soft);
    box-shadow: var(--shadow-md);
}

@media (prefers-reduced-motion: reduce) {
    *, *::before, *::after { transition-duration: 0ms !important; }
}

/* =====================================================
   AI ASK BAR (hero) + COMMAND PALETTE chat
   ===================================================== */

/* Nav AI button */
.nav-cta-ai {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    cursor: pointer;
    font-family: inherit;
    font-size: 0.85rem;
    font-weight: 500;
    background: var(--text);
    color: #fff;
    border: 1px solid var(--text);
    border-radius: var(--radius-pill);
    padding: 9px 16px 9px 14px;
    position: relative;
    overflow: hidden;
    transition: all 0.2s ease;
}
.nav-cta-ai::before {
    content: '';
    position: absolute;
    inset: 0;
    background: linear-gradient(120deg, transparent 30%, rgba(255,255,255,0.22) 50%, transparent 70%);
    transform: translateX(-100%);
    transition: transform 0.6s ease;
}
.nav-cta-ai:hover {
    background: var(--accent);
    border-color: var(--accent);
    transform: translateY(-1px);
}
.nav-cta-ai:hover::before { transform: translateX(100%); }
.ai-pulse {
    width: 7px;
    height: 7px;
    border-radius: 50%;
    background: #22c55e;
    box-shadow: 0 0 0 3px rgba(34, 197, 94, 0.3);
    animation: aiPulse 1.8s ease-in-out infinite;
}
@keyframes aiPulse {
    0%, 100% { opacity: 1; box-shadow: 0 0 0 3px rgba(34, 197, 94, 0.3); }
    50% { opacity: 0.6; box-shadow: 0 0 0 6px rgba(34, 197, 94, 0.1); }
}

/* Hero Ask Bar (primary CTA) */
.ask-bar {
    display: flex;
    align-items: center;
    gap: 14px;
    width: 100%;
    max-width: 580px;
    padding: 14px 14px 14px 18px;
    margin-bottom: 28px;
    background: rgba(255, 255, 255, 0.7);
    border: 1px solid var(--border);
    border-radius: 18px;
    cursor: pointer;
    font-family: inherit;
    text-align: left;
    color: var(--text);
    backdrop-filter: blur(10px);
    -webkit-backdrop-filter: blur(10px);
    position: relative;
    overflow: hidden;
    box-shadow:
        0 1px 0 rgba(255,255,255,0.9) inset,
        0 12px 40px -20px rgba(184, 65, 14, 0.25),
        0 2px 6px -2px rgba(24, 24, 27, 0.06);
    transition: all 0.3s cubic-bezier(0.32, 0.72, 0, 1);
}
.ask-bar::before {
    content: '';
    position: absolute;
    inset: -1px;
    border-radius: 18px;
    padding: 1.5px;
    background: linear-gradient(120deg, transparent 0%, var(--accent) 30%, #f59e0b 50%, var(--accent) 70%, transparent 100%);
    background-size: 200% 100%;
    -webkit-mask: linear-gradient(#000 0 0) content-box, linear-gradient(#000 0 0);
    mask: linear-gradient(#000 0 0) content-box, linear-gradient(#000 0 0);
    -webkit-mask-composite: xor;
    mask-composite: exclude;
    opacity: 0;
    animation: shimmer 3s linear infinite;
    pointer-events: none;
    transition: opacity 0.3s ease;
}
.ask-bar:hover {
    transform: translateY(-2px);
    border-color: transparent;
    background: rgba(255, 255, 255, 0.92);
    box-shadow:
        0 1px 0 rgba(255,255,255,0.9) inset,
        0 24px 60px -24px rgba(184, 65, 14, 0.4),
        0 4px 12px -4px rgba(24, 24, 27, 0.1);
}
.ask-bar:hover::before { opacity: 1; }
@keyframes shimmer {
    0% { background-position: 200% 0; }
    100% { background-position: -200% 0; }
}

.ask-bar-icon {
    width: 40px;
    height: 40px;
    border-radius: 12px;
    background: linear-gradient(135deg, var(--accent) 0%, #f59e0b 100%);
    color: #fff;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    box-shadow: 0 6px 16px -6px rgba(184, 65, 14, 0.5);
    transition: transform 0.3s ease;
}
.ask-bar-icon svg { width: 20px; height: 20px; }
.ask-bar:hover .ask-bar-icon { transform: rotate(-6deg) scale(1.05); }

.ask-bar-text {
    flex: 1;
    min-width: 0;
    display: flex;
    flex-direction: column;
    gap: 2px;
}
.ask-bar-label {
    font-size: 0.95rem;
    font-weight: 600;
    color: var(--text);
    font-family: var(--font-serif);
    letter-spacing: -0.01em;
}
.ask-bar-rotator {
    position: relative;
    height: 1.3em;
    overflow: hidden;
    color: var(--text-3);
    font-size: 0.82rem;
}
.ask-bar-rotator span {
    position: absolute;
    left: 0; top: 0;
    width: 100%;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    animation: rotateUp 18s ease-in-out infinite;
    opacity: 0;
}
.ask-bar-rotator span:nth-child(1) { animation-delay: 0s; }
.ask-bar-rotator span:nth-child(2) { animation-delay: 3.6s; }
.ask-bar-rotator span:nth-child(3) { animation-delay: 7.2s; }
.ask-bar-rotator span:nth-child(4) { animation-delay: 10.8s; }
.ask-bar-rotator span:nth-child(5) { animation-delay: 14.4s; }
@keyframes rotateUp {
    0%   { opacity: 0; transform: translateY(100%); }
    3%   { opacity: 1; transform: translateY(0); }
    18%  { opacity: 1; transform: translateY(0); }
    21%  { opacity: 0; transform: translateY(-100%); }
    100% { opacity: 0; transform: translateY(-100%); }
}

.ask-bar-kbd {
    display: inline-flex;
    align-items: center;
    gap: 3px;
    padding: 6px 10px;
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-bottom-width: 2px;
    border-radius: 8px;
    font-family: 'JetBrains Mono', 'SF Mono', monospace;
    font-size: 0.74rem;
    font-weight: 600;
    color: var(--text-3);
    flex-shrink: 0;
    transition: all 0.2s ease;
}
.ask-bar:hover .ask-bar-kbd {
    background: var(--accent);
    color: #fff;
    border-color: var(--accent);
}

.btn-link {
    font-size: 0.92rem;
    color: var(--text-3);
    border-bottom: 1px solid transparent;
    padding: 4px 0;
    transition: all 0.2s ease;
}
.btn-link:hover {
    color: var(--accent);
    border-bottom-color: var(--accent);
}

@media (max-width: 540px) {
    .ask-bar { padding: 12px 12px 12px 14px; gap: 10px; border-radius: 14px; }
    .ask-bar-icon { width: 36px; height: 36px; }
    .ask-bar-label { font-size: 0.88rem; }
    .ask-bar-rotator { font-size: 0.76rem; }
    .ask-bar-kbd { display: none; }
}

/* Command palette */
.cmdk-overlay {
    position: fixed;
    inset: 0;
    background: rgba(20, 18, 15, 0.55);
    backdrop-filter: blur(8px);
    -webkit-backdrop-filter: blur(8px);
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.35s ease;
    z-index: 90;
}
.cmdk-overlay.open { opacity: 1; pointer-events: auto; }

.cmdk {
    position: fixed;
    inset: 0;
    z-index: 100;
    display: flex;
    align-items: flex-start;
    justify-content: center;
    padding: clamp(40px, 8vh, 80px) 20px 20px;
    pointer-events: none;
    opacity: 0;
    transition: opacity 0.3s ease;
}
.cmdk.open {
    pointer-events: auto;
    opacity: 1;
}

.cmdk-shell {
    width: 100%;
    max-width: 680px;
    max-height: calc(100vh - 100px);
    background: rgba(255, 255, 255, 0.96);
    backdrop-filter: blur(24px);
    -webkit-backdrop-filter: blur(24px);
    border-radius: 22px;
    border: 1px solid var(--border);
    box-shadow:
        0 1px 0 rgba(255, 255, 255, 0.9) inset,
        0 40px 80px -20px rgba(24, 24, 27, 0.4),
        0 0 0 1px rgba(255, 255, 255, 0.5);
    display: flex;
    flex-direction: column;
    overflow: hidden;
    position: relative;
    transform: scale(0.96) translateY(-12px);
    transition: transform 0.4s cubic-bezier(0.32, 0.72, 0, 1);
}
.cmdk.open .cmdk-shell { transform: scale(1) translateY(0); }

.cmdk-glow {
    position: absolute;
    top: -120px;
    right: -80px;
    width: 360px;
    height: 360px;
    background: radial-gradient(circle, rgba(184, 65, 14, 0.18) 0%, transparent 65%);
    pointer-events: none;
    z-index: 0;
    animation: glowDrift 8s ease-in-out infinite alternate;
}
@keyframes glowDrift {
    0%   { transform: translate(0, 0); opacity: 0.7; }
    100% { transform: translate(-40px, 30px); opacity: 1; }
}

.cmdk-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    padding: 18px 22px;
    border-bottom: 1px solid var(--border);
    position: relative;
    z-index: 2;
    background: rgba(255, 255, 255, 0.6);
}
.cmdk-title { display: flex; align-items: center; gap: 13px; min-width: 0; }
.cmdk-avatar {
    width: 42px;
    height: 42px;
    border-radius: 14px;
    background: linear-gradient(135deg, var(--accent) 0%, #f59e0b 100%);
    color: #fff;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    box-shadow:
        0 8px 20px -6px rgba(184, 65, 14, 0.5),
        inset 0 1px 0 rgba(255, 255, 255, 0.3);
    animation: orbit 6s ease-in-out infinite;
}
.cmdk-avatar svg { width: 20px; height: 20px; }
@keyframes orbit {
    0%, 100% { transform: rotate(0deg); }
    50% { transform: rotate(6deg); }
}
.cmdk-title h3 {
    font-family: var(--font-serif);
    font-weight: 500;
    font-size: 1.15rem;
    line-height: 1.2;
    margin-bottom: 3px;
    letter-spacing: -0.015em;
}
.cmdk-title p {
    font-size: 0.74rem;
    color: var(--text-3);
    display: flex;
    align-items: center;
    gap: 7px;
    font-weight: 500;
    letter-spacing: 0.02em;
}
.cmdk-status-dot {
    width: 7px;
    height: 7px;
    border-radius: 50%;
    background: #22c55e;
    box-shadow: 0 0 0 3px rgba(34, 197, 94, 0.2);
    animation: aiPulse 2s ease-in-out infinite;
}
.cmdk-header-actions { display: flex; gap: 8px; }
.cmdk-icon-btn {
    width: 36px;
    height: 36px;
    border-radius: 10px;
    background: var(--bg-soft);
    border: 1px solid var(--border);
    color: var(--text-3);
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s ease;
}
.cmdk-icon-btn svg { width: 16px; height: 16px; }
.cmdk-icon-btn:hover {
    background: var(--text);
    color: #fff;
    border-color: var(--text);
}
#closeChat:hover { transform: rotate(90deg); }

.cmdk-body {
    flex: 1;
    overflow-y: auto;
    padding: 24px 24px 8px;
    display: flex;
    flex-direction: column;
    gap: 16px;
    scroll-behavior: smooth;
    position: relative;
    z-index: 1;
    min-height: 200px;
}
.cmdk-body::-webkit-scrollbar { width: 6px; }
.cmdk-body::-webkit-scrollbar-thumb {
    background: var(--border-strong);
    border-radius: 3px;
}

.cmdk-welcome {
    text-align: center;
    padding: 16px 4px 4px;
    animation: fadeUp 0.5s ease;
}
@keyframes fadeUp {
    from { opacity: 0; transform: translateY(12px); }
    to { opacity: 1; transform: translateY(0); }
}
.cmdk-orb {
    width: 72px;
    height: 72px;
    margin: 0 auto 18px;
    border-radius: 24px;
    background: linear-gradient(135deg, #fff 0%, var(--accent-soft) 100%);
    color: var(--accent);
    display: flex;
    align-items: center;
    justify-content: center;
    border: 1px solid var(--border);
    position: relative;
    box-shadow:
        0 16px 40px -12px rgba(184, 65, 14, 0.4),
        inset 0 1px 0 rgba(255, 255, 255, 1);
    animation: float 4s ease-in-out infinite;
}
.cmdk-orb svg { width: 32px; height: 32px; position: relative; z-index: 1; }
.cmdk-orb-inner {
    position: absolute;
    inset: 6px;
    border-radius: 18px;
    background: conic-gradient(from 0deg, var(--accent), #f59e0b, var(--accent));
    opacity: 0.1;
    animation: rotate360 4s linear infinite;
}
@keyframes rotate360 {
    from { transform: rotate(0deg); }
    to { transform: rotate(360deg); }
}
@keyframes float {
    0%, 100% { transform: translateY(0); }
    50% { transform: translateY(-6px); }
}
.cmdk-welcome h4 {
    font-family: var(--font-serif);
    font-weight: 500;
    font-size: 1.7rem;
    margin-bottom: 10px;
    letter-spacing: -0.025em;
}
.cmdk-welcome > p {
    font-size: 0.96rem;
    color: var(--text-3);
    margin: 0 auto 26px;
    max-width: 42ch;
    line-height: 1.6;
}

.cmdk-suggestions {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 12px;
    text-align: left;
}
@media (max-width: 560px) {
    .cmdk-suggestions { grid-template-columns: 1fr; }
}
.cmdk-sug-group {
    display: flex;
    flex-direction: column;
    gap: 6px;
}
.cmdk-sug-label {
    font-size: 0.7rem;
    text-transform: uppercase;
    letter-spacing: 0.14em;
    color: var(--text-4);
    font-weight: 600;
    padding: 0 4px 4px;
}
.cmdk-sug {
    display: flex;
    align-items: center;
    gap: 10px;
    font-family: inherit;
    font-size: 0.88rem;
    text-align: left;
    padding: 10px 12px;
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: 10px;
    color: var(--text-2);
    cursor: pointer;
    transition: all 0.2s ease;
    line-height: 1.4;
}
.cmdk-sug-emoji {
    font-size: 1rem;
    flex-shrink: 0;
    width: 26px;
    height: 26px;
    background: var(--bg-tint);
    border-radius: 7px;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s ease;
}
.cmdk-sug:hover {
    background: var(--bg-card);
    border-color: var(--accent);
    color: var(--text);
    transform: translateX(2px);
    box-shadow: 0 6px 16px -8px rgba(184, 65, 14, 0.3);
}
.cmdk-sug:hover .cmdk-sug-emoji {
    background: var(--accent-soft);
    transform: scale(1.1) rotate(-5deg);
}

/* Messages */
.chat-msg {
    display: flex;
    gap: 10px;
    max-width: 94%;
    animation: msgIn 0.35s cubic-bezier(0.32, 0.72, 0, 1);
}
@keyframes msgIn {
    from { opacity: 0; transform: translateY(10px); }
    to { opacity: 1; transform: translateY(0); }
}
.chat-msg-user { align-self: flex-end; justify-content: flex-end; }
.chat-msg-ai { align-self: flex-start; }
.chat-msg-avatar {
    width: 30px;
    height: 30px;
    border-radius: 10px;
    background: linear-gradient(135deg, var(--accent) 0%, #f59e0b 100%);
    color: #fff;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    box-shadow: 0 4px 10px -3px rgba(184, 65, 14, 0.4);
    margin-top: 2px;
}
.chat-msg-avatar svg { width: 14px; height: 14px; }

.chat-bubble {
    padding: 12px 16px;
    border-radius: 16px;
    font-size: 0.94rem;
    line-height: 1.6;
    word-wrap: break-word;
    min-width: 40px;
}
.chat-msg-user .chat-bubble {
    background: linear-gradient(135deg, var(--text) 0%, #2a2a2e 100%);
    color: #fff;
    border-bottom-right-radius: 6px;
    box-shadow: 0 6px 16px -8px rgba(24, 24, 27, 0.3);
}
.chat-msg-ai .chat-bubble {
    background: var(--bg-card);
    color: var(--text);
    border: 1px solid var(--border);
    border-bottom-left-radius: 6px;
    box-shadow: 0 2px 8px -4px rgba(24, 24, 27, 0.06);
}
.chat-bubble p { margin-bottom: 10px; }
.chat-bubble p:last-child { margin-bottom: 0; }
.chat-bubble strong { font-weight: 600; }
.chat-msg-user .chat-bubble strong { color: #fff; }
.chat-bubble ul {
    list-style: none;
    padding-left: 0;
    margin: 10px 0;
}
.chat-bubble li {
    position: relative;
    padding-left: 18px;
    margin-bottom: 7px;
    line-height: 1.55;
}
.chat-bubble li::before {
    content: '';
    position: absolute;
    left: 2px; top: 0.6em;
    width: 6px; height: 6px;
    border-radius: 50%;
    background: var(--accent);
}
.chat-msg-user .chat-bubble li::before { background: rgba(255,255,255,0.7); }
.chat-bubble code {
    background: var(--bg-tint);
    color: var(--accent);
    padding: 2px 7px;
    border-radius: 5px;
    font-family: 'JetBrains Mono', monospace;
    font-size: 0.85em;
    font-weight: 500;
}
.chat-msg-user .chat-bubble code {
    background: rgba(255,255,255,0.18);
    color: #fff;
}

.cmdk-cursor {
    display: inline-block;
    width: 7px;
    height: 1em;
    background: var(--accent);
    margin-left: 2px;
    vertical-align: text-bottom;
    animation: blink 1s steps(2) infinite;
    border-radius: 1px;
}
@keyframes blink { 50% { opacity: 0; } }

.dot-typing {
    display: inline-flex;
    gap: 5px;
    align-items: center;
    padding: 6px 4px;
}
.dot-typing span {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: var(--accent);
    animation: dotBounce 1.3s ease-in-out infinite;
    opacity: 0.4;
}
.dot-typing span:nth-child(2) { animation-delay: 0.15s; }
.dot-typing span:nth-child(3) { animation-delay: 0.3s; }
@keyframes dotBounce {
    0%, 60%, 100% { transform: translateY(0) scale(1); opacity: 0.4; }
    30% { transform: translateY(-6px) scale(1.15); opacity: 1; }
}

.cmdk-quick-actions {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
    margin-top: 10px;
}
.cmdk-quick-action {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    font-family: inherit;
    font-size: 0.78rem;
    font-weight: 500;
    padding: 6px 12px;
    background: var(--bg-tint);
    border: 1px solid var(--border);
    border-radius: var(--radius-pill);
    color: var(--text-2);
    cursor: pointer;
    text-decoration: none;
    transition: all 0.2s ease;
}
.cmdk-quick-action:hover {
    background: var(--accent);
    color: #fff;
    border-color: var(--accent);
    transform: translateY(-1px);
}

.cmdk-input-bar {
    padding: 14px 18px 14px;
    border-top: 1px solid var(--border);
    background: rgba(255, 255, 255, 0.7);
    backdrop-filter: blur(14px);
    -webkit-backdrop-filter: blur(14px);
    position: relative;
    z-index: 2;
}
.cmdk-input-wrap {
    display: flex;
    align-items: center;
    gap: 8px;
    background: var(--bg);
    border: 1.5px solid var(--border);
    border-radius: 14px;
    padding: 6px 6px 6px 14px;
    transition: all 0.2s ease;
}
.cmdk-input-wrap:focus-within {
    border-color: var(--accent);
    box-shadow: 0 0 0 4px var(--accent-soft);
}
.cmdk-input-icon {
    color: var(--text-4);
    display: flex;
    align-items: center;
    flex-shrink: 0;
}
.cmdk-input-icon svg { width: 18px; height: 18px; }
.cmdk-input-wrap input {
    flex: 1;
    font-family: inherit;
    font-size: 0.98rem;
    padding: 10px 4px;
    border: none;
    background: transparent;
    color: var(--text);
    outline: none;
    min-width: 0;
}
.cmdk-input-wrap input::placeholder { color: var(--text-4); }
.cmdk-input-wrap input:disabled { opacity: 0.6; cursor: not-allowed; }
.cmdk-input-wrap button {
    width: 40px;
    height: 40px;
    border-radius: 10px;
    background: linear-gradient(135deg, var(--accent) 0%, #f59e0b 100%);
    color: #fff;
    border: none;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: all 0.2s ease;
    flex-shrink: 0;
    box-shadow: 0 4px 12px -4px rgba(184, 65, 14, 0.5);
}
.cmdk-input-wrap button svg { width: 18px; height: 18px; }
.cmdk-input-wrap button:hover {
    transform: scale(1.05) rotate(-6deg);
    box-shadow: 0 8px 20px -4px rgba(184, 65, 14, 0.6);
}
.cmdk-input-wrap button:active { transform: scale(0.95); }
.cmdk-input-wrap button:disabled {
    opacity: 0.5;
    cursor: not-allowed;
    transform: none !important;
}

.cmdk-footer-hints {
    display: flex;
    gap: 16px;
    justify-content: center;
    margin-top: 10px;
    font-size: 0.72rem;
    color: var(--text-4);
}
.cmdk-footer-hints span {
    display: inline-flex;
    align-items: center;
    gap: 5px;
}
.cmdk-footer-hints kbd {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-bottom-width: 1.5px;
    padding: 1px 6px;
    border-radius: 4px;
    font-family: 'JetBrains Mono', monospace;
    font-size: 0.7rem;
    color: var(--text-3);
}

@media (max-width: 560px) {
    .cmdk { padding: 20px 12px 12px; }
    .cmdk-shell { border-radius: 18px; max-height: calc(100vh - 40px); }
    .cmdk-welcome h4 { font-size: 1.4rem; }
    .cmdk-orb { width: 60px; height: 60px; }
    .cmdk-footer-hints { gap: 10px; font-size: 0.68rem; }
}

