/* ─── FONTS ─────────────────────────────────────────────────────────────── */
@import url('https://fonts.googleapis.com/css2?family=Playfair+Display:ital,wght@0,300;0,400;0,500;0,600;0,700;0,800;0,900;1,300;1,400;1,500;1,600;1,700;1,800;1,900&family=Lora:ital,wght@0,300;0,400;0,500;0,600;0,700;1,300;1,400;1,500;1,600;1,700&family=JetBrains+Mono:wght@400;500&display=swap');

/* ─── RESET & BASE ──────────────────────────────────────────────────────── */
*, *::before, *::after {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

:root {
    /* ── Light (default) ── */
    --bg:          #fafafa;
    --surface:     #ffffff;
    --surface-2:   #f8f9fa;
    --surface-3:   #e9ecef;
    --border:      rgba(0,0,0,0.08);
    --border-hover:rgba(0,0,0,0.15);

    --text:        #212529;
    --text-muted:  #6c757d;
    --text-dim:    #adb5bd;

    --blue:        #2c3e50;
    --blue-dim:    rgba(44,62,80,0.08);
    --blue-glow:   rgba(44,62,80,0.15);

    --gold:        #BF5700;   /* UT Austin burnt orange */
    --gold-dim:    rgba(191,87,0,0.12);

    --emerald:     #27ae60;
    --emerald-dim: rgba(39,174,96,0.12);

    --crimson:     #dc3545;
    --crimson-dim: rgba(220,53,69,0.12);

    --indigo:      #5e35b1;
    --indigo-dim:  rgba(94,53,177,0.12);

    --radius-sm:   6px;
    --radius-md:   12px;
    --radius-lg:   18px;
    --radius-xl:   24px;

    --shadow-sm:   0 2px 4px rgba(0,0,0,0.06);
    --shadow-md:   0 4px 16px rgba(0,0,0,0.08);
    --shadow-lg:   0 8px 32px rgba(0,0,0,0.12);

    --transition:  0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

/* ── Dark mode overrides ─────────────────────────────────────────────────── */
body.dark {
    --bg:          #0f0f14;
    --surface:     #17171e;
    --surface-2:   #1e1e27;
    --surface-3:   #272732;
    --border:      rgba(255,255,255,0.08);
    --border-hover:rgba(255,255,255,0.18);

    --text:        #e8e8f0;
    --text-muted:  #9090a8;
    --text-dim:    #5a5a72;

    --blue:        #7b9cdb;
    --blue-dim:    rgba(123,156,219,0.12);
    --blue-glow:   rgba(123,156,219,0.25);

    --gold:        #E8651A;   /* burnt orange, lighter for dark mode */
    --gold-dim:    rgba(232,101,26,0.14);

    --emerald:     #3ecf74;
    --emerald-dim: rgba(62,207,116,0.12);

    --crimson:     #f06070;
    --crimson-dim: rgba(240,96,112,0.12);

    --indigo:      #9575cd;
    --indigo-dim:  rgba(149,117,205,0.12);
}

body.dark header {
    background: rgba(15,15,20,0.88);
}

html {
    scroll-behavior: smooth;
}

body {
    font-family: 'Lora', serif;
    background-color: var(--bg);
    color: var(--text);
    line-height: 1.7;
    overflow-x: hidden;
}

a { text-decoration: none; color: inherit; }

/* ─── SCROLLBAR ─────────────────────────────────────────────────────────── */
::-webkit-scrollbar { width: 6px; }
::-webkit-scrollbar-track { background: var(--bg); }
::-webkit-scrollbar-thumb { background: var(--surface-3); border-radius: 3px; }
::-webkit-scrollbar-thumb:hover { background: var(--text-dim); }

/* ─── HEADER ────────────────────────────────────────────────────────────── */
header {
    position: fixed;
    top: 0; left: 0;
    width: 100%;
    padding: 0 5%;
    height: 64px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    z-index: 1000;
    background: rgba(250,250,250,0.88);
    backdrop-filter: blur(20px);
    -webkit-backdrop-filter: blur(20px);
    border-bottom: 1px solid var(--border);
    transition: border-color var(--transition);
}

.logo {
    font-family: 'Playfair Display', serif;
    font-size: 1.2rem;
    font-weight: 600;
    color: var(--text);
    letter-spacing: -0.01em;
    white-space: nowrap;
}

.logo span {
    color: var(--gold);
}

nav {
    display: flex;
    gap: 0.25rem;
    align-items: center;
}

nav a {
    font-size: 0.875rem;
    font-weight: 500;
    color: var(--text-muted);
    padding: 0.4rem 0.9rem;
    border-radius: var(--radius-sm);
    transition: color var(--transition), background var(--transition);
    letter-spacing: 0.01em;
}

nav a:hover,
nav a.active {
    color: var(--text);
    background: var(--surface-2);
}

nav a.active {
    color: var(--gold);
}

/* ─── THEME TOGGLE ──────────────────────────────────────────────────────── */
#theme-toggle {
    width: 34px;
    height: 34px;
    border-radius: 50%;
    border: 1px solid var(--border);
    background: var(--surface-2);
    color: var(--text-muted);
    font-size: 0.9rem;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: background var(--transition), border-color var(--transition), color var(--transition), transform var(--transition);
    flex-shrink: 0;
    margin-left: 0.5rem;
}
#theme-toggle:hover {
    border-color: var(--gold);
    color: var(--gold);
    transform: rotate(20deg);
}

@media (max-width: 768px) {
    header { padding: 0 4%; flex-wrap: wrap; height: auto; padding-top: 0.75rem; padding-bottom: 0.75rem; gap: 0.5rem; }
    nav { gap: 0.15rem; flex-wrap: wrap; justify-content: center; }
    nav a { font-size: 0.8rem; padding: 0.35rem 0.7rem; }
    .logo { font-size: 1rem; }
    #theme-toggle { margin-left: 0; }
}

/* ─── SECTION BASE ──────────────────────────────────────────────────────── */
section {
    padding: 7rem 5%;
    max-width: 1100px;
    margin: 0 auto;
    scroll-margin-top: 64px;
}

/* ─── BANDED SECTION WRAPPERS ───────────────────────────────────────────── */
.section-band {
    width: 100%;
    position: relative;
}

/* odd bands: same as page bg */
.section-band:nth-child(odd) {
    background: var(--bg);
}

/* even bands: slightly lifted surface */
.section-band:nth-child(even) {
    background: var(--surface-2);
    border-top: 1px solid var(--border);
    border-bottom: 1px solid var(--border);
}

/* remove old divider — bands replace it */
.section-divider { display: none; }

/* ─── SECTION HEADING ───────────────────────────────────────────────────── */
.section-heading {
    display: flex;
    align-items: center;
    gap: 1rem;
    margin-bottom: 3.5rem;
}

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

.section-heading h1 {
    font-family: 'Playfair Display', serif;
    font-size: 2.2rem;
    font-weight: 600;
    letter-spacing: -0.02em;
    color: var(--text);
}

.section-heading .line {
    flex: 1;
    height: 1px;
    background: var(--border);
    margin-left: 1rem;
}

/* ─── HOME ──────────────────────────────────────────────────────────────── */
.home {
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 5rem;
    padding-top: 8rem;
    max-width: 1100px;
    position: relative;
}

/* subtle grid background on home */
.home::before {
    content: '';
    position: fixed;
    inset: 0;
    background-image:
        linear-gradient(rgba(212,175,55,0.08) 1px, transparent 1px),
        linear-gradient(90deg, rgba(212,175,55,0.08) 1px, transparent 1px);
    background-size: 60px 60px;
    pointer-events: none;
    z-index: -1;
}

.home-img {
    flex-shrink: 0;
    position: relative;
}

.home-img::before {
    content: '';
    position: absolute;
    inset: -3px;
    border-radius: 50%;
    background: conic-gradient(from 0deg, var(--gold), var(--indigo), var(--emerald), var(--gold));
    z-index: -1;
    animation: spin 6s linear infinite;
    opacity: 0.6;
}

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

.home-img img {
    width: 240px;
    height: 240px;
    border-radius: 50%;
    object-fit: cover;
    display: block;
    border: 3px solid var(--bg);
    position: relative;
    z-index: 1;
}

.home-content {
    max-width: 520px;
}

.home-content .eyebrow {
    display: inline-flex;
    align-items: center;
    gap: 0.5rem;
    font-size: 0.8rem;
    font-weight: 500;
    color: var(--blue);
    letter-spacing: 0.1em;
    text-transform: uppercase;
    background: var(--blue-dim);
    border: 1px solid rgba(79,142,247,0.2);
    padding: 0.3rem 0.8rem;
    border-radius: 999px;
    margin-bottom: 1.2rem;
}

.home-content h1 {
    font-family: 'Playfair Display', serif;
    font-size: 3.5rem;
    font-weight: 700;
    letter-spacing: -0.03em;
    line-height: 1.1;
    margin-bottom: 0.75rem;
    color: var(--text);
}

.home-content h1 span {
    color: var(--gold);
    font-weight: 700;
}

.home-content h3 {
    font-family: 'Playfair Display', serif;
    font-size: 1.25rem;
    font-weight: 400;
    font-style: italic;
    color: var(--text-muted);
    margin-bottom: 1.2rem;
}

.home-content h3 span {
    color: #BF5700;   /* UT Austin burnt orange */
    font-weight: 600;
}

.home-content p {
    font-size: 1rem;
    color: var(--text-muted);
    line-height: 1.75;
    max-width: 440px;
    margin-bottom: 2rem;
}

.home-actions {
    display: flex;
    gap: 0.75rem;
    flex-wrap: wrap;
    align-items: center;
}

.btn-primary {
    display: inline-flex;
    align-items: center;
    gap: 0.5rem;
    font-family: 'Playfair Display', serif;
    font-size: 0.95rem;
    font-weight: 600;
    padding: 0.7rem 1.6rem;
    border-radius: var(--radius-md);
    background: var(--blue);
    color: #fff;
    transition: background var(--transition), transform var(--transition), box-shadow var(--transition);
}

.btn-primary:hover {
    background: var(--text);
    transform: translateY(-1px);
    box-shadow: var(--shadow-md);
}

.btn-ghost {
    display: inline-flex;
    align-items: center;
    gap: 0.5rem;
    font-size: 0.9rem;
    font-weight: 500;
    padding: 0.7rem 1.4rem;
    border-radius: var(--radius-md);
    border: 1px solid var(--border);
    color: var(--text-muted);
    transition: border-color var(--transition), color var(--transition);
}

.btn-ghost:hover {
    border-color: var(--border-hover);
    color: var(--text);
}

.social-row {
    display: flex;
    gap: 0.75rem;
    margin-top: 2rem;
}

.social-row a {
    width: 38px; height: 38px;
    border-radius: var(--radius-sm);
    border: 1px solid var(--border);
    display: flex; align-items: center; justify-content: center;
    color: var(--text-muted);
    font-size: 1rem;
    transition: border-color var(--transition), color var(--transition), background var(--transition);
}

.social-row a:hover {
    border-color: var(--blue);
    color: var(--blue);
    background: var(--blue-dim);
}

@media (max-width: 820px) {
    .home { flex-direction: column; gap: 2.5rem; text-align: center; padding-top: 7rem; }
    .home-content p { margin-left: auto; margin-right: auto; }
    .home-actions { justify-content: center; }
    .social-row { justify-content: center; }
    .home-content h1 { font-size: 2.6rem; }
    .home-img img { width: 180px; height: 180px; }
}

/* ─── PROJECT CARDS (shared) ────────────────────────────────────────────── */
.project-card.detailed {
    display: grid;
    grid-template-columns: 1.4fr 1fr;
    gap: 2.5rem;
    padding: 2.5rem;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    margin-bottom: 1.5rem;
    transition: border-color var(--transition), transform var(--transition), box-shadow var(--transition);
    position: relative;
    overflow: hidden;
}

.project-card.detailed::before {
    content: '';
    position: absolute;
    top: 0; left: 0; right: 0;
    height: 2px;
    background: linear-gradient(90deg, var(--card-accent, var(--blue)), transparent);
    opacity: 0;
    transition: opacity var(--transition);
}

.project-card.detailed:hover {
    border-color: var(--border-hover);
    transform: translateY(-3px);
    box-shadow: var(--shadow-lg);
}

.project-card.detailed:hover::before {
    opacity: 1;
}

/* ─── PROJECT INFO ──────────────────────────────────────────────────────── */
.project-info {
    display: flex;
    flex-direction: column;
    gap: 1.4rem;
}

.project-info h3 {
    display: flex;
    align-items: center;
    gap: 0.7rem;
    font-family: 'Playfair Display', serif;
    font-size: 1.4rem;
    font-weight: 600;
    color: var(--text);
    letter-spacing: -0.02em;
}

.project-info h3 i {
    font-size: 1.1rem;
    color: var(--card-accent, var(--blue));
    width: 32px; height: 32px;
    background: var(--blue-dim);
    border-radius: var(--radius-sm);
    display: flex; align-items: center; justify-content: center;
    flex-shrink: 0;
}

.project-section h4 {
    font-family: 'Lora', serif;
    font-size: 0.85rem;
    font-weight: 600;
    font-style: italic;
    letter-spacing: 0.05em;
    color: var(--text-dim);
    margin-bottom: 0.55rem;
    display: flex;
    align-items: center;
    gap: 0.4rem;
}

.project-section h4 i {
    font-size: 0.7rem;
    color: var(--card-accent, var(--blue));
}

.project-section p,
.project-section ul {
    font-size: 0.925rem;
    color: var(--text-muted);
    line-height: 1.7;
}

.project-section ul {
    padding-left: 1.2rem;
    display: flex;
    flex-direction: column;
    gap: 0.3rem;
}

/* ─── SKILL PILLS ───────────────────────────────────────────────────────── */
.skills {
    display: flex;
    flex-wrap: wrap;
    gap: 0.5rem;
    list-style: none;
    padding: 0;
}

.skills li {
    font-size: 0.78rem;
    font-weight: 500;
    font-family: 'JetBrains Mono', monospace;
    padding: 0.3rem 0.75rem;
    border-radius: 999px;
    background: var(--surface-2);
    border: 1px solid var(--border);
    color: var(--text-muted);
    transition: border-color var(--transition), color var(--transition);
}

.project-card.detailed:hover .skills li {
    border-color: rgba(79,142,247,0.2);
    color: var(--text);
}

/* ─── PROJECT MEDIA ─────────────────────────────────────────────────────── */
.project-media {
    display: flex;
    align-items: center;
    justify-content: center;
}

.project-media img {
    width: 100%;
    height: 280px;
    object-fit: contain;
    background: var(--surface-2);
    border-radius: var(--radius-md);
    border: 1px solid var(--border);
    transition: transform var(--transition);
    padding: 0.5rem;
}

.project-card.detailed:hover .project-media img {
    transform: scale(1.02);
}

/* ─── CODING ICON PANEL ─────────────────────────────────────────────────── */
.project-icon-panel {
    width: 100%;
    height: 280px;
    border-radius: var(--radius-md);
    border: 1px solid var(--border);
    background: var(--surface-2);
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 1rem;
    transition: border-color var(--transition), background var(--transition);
    position: relative;
    overflow: hidden;
}

/* subtle radial glow from accent colour */
.project-icon-panel::before {
    content: '';
    position: absolute;
    width: 200px; height: 200px;
    border-radius: 50%;
    background: radial-gradient(circle, var(--panel-glow, rgba(167,139,250,0.15)), transparent 70%);
    pointer-events: none;
}

.project-card.detailed:hover .project-icon-panel {
    border-color: rgba(167,139,250,0.3);
    background: var(--surface-3);
}

.project-icon-panel .panel-icon {
    font-size: 3.2rem;
    color: var(--purple);
    opacity: 0.85;
    z-index: 1;
    transition: transform var(--transition), opacity var(--transition);
}

.project-card.detailed:hover .project-icon-panel .panel-icon {
    transform: scale(1.1);
    opacity: 1;
}

.project-icon-panel .panel-label {
    font-size: 0.72rem;
    font-weight: 600;
    letter-spacing: 0.12em;
    text-transform: uppercase;
    color: var(--text-dim);
    z-index: 1;
}

/* ─── GITHUB LINK ───────────────────────────────────────────────────────── */
.github-link {
    display: inline-flex;
    align-items: center;
    gap: 0.45rem;
    font-size: 0.8rem;
    font-weight: 500;
    padding: 0.35rem 0.9rem;
    border-radius: var(--radius-sm);
    border: 1px solid var(--border);
    color: var(--text-muted);
    transition: all var(--transition);
    font-family: 'JetBrains Mono', monospace;
}

.github-link:hover {
    border-color: var(--purple);
    color: var(--purple);
    background: var(--purple-dim);
}

@media (max-width: 900px) {
    .project-card.detailed {
        grid-template-columns: 1fr;
        gap: 1.8rem;
    }
    .project-media { order: -1; }
    .project-media img { height: 220px; }
    .project-icon-panel { height: 180px; order: -1; }
    .project-icon-panel .panel-icon { font-size: 2.5rem; }
}

/* ─── CAD SECTION ───────────────────────────────────────────────────────── */
.CAD .project-card.detailed { --card-accent: var(--indigo); }
.CAD .project-info h3 i { background: var(--indigo-dim); color: var(--indigo); }

/* ─── CODING SECTION ────────────────────────────────────────────────────── */
.Coding .project-card.detailed { --card-accent: var(--emerald); }
.Coding .project-info h3 i { background: var(--emerald-dim); color: var(--emerald); }
.Coding .project-section h4 i { color: var(--emerald); }

/* Code-flavored skill pills in coding section */
.Coding .skills li {
    background: var(--purple-dim);
    border-color: rgba(167,139,250,0.2);
    color: var(--purple);
}

.Coding .project-card.detailed::before {
    background: linear-gradient(90deg, var(--purple), transparent);
}

/* Project links */
.project-links {
    display: flex;
    gap: 0.6rem;
    flex-wrap: wrap;
    margin-top: 0.4rem;
}

.project-link {
    display: inline-flex;
    align-items: center;
    gap: 0.4rem;
    font-size: 0.8rem;
    font-weight: 500;
    padding: 0.35rem 0.85rem;
    border-radius: var(--radius-sm);
    border: 1px solid var(--border);
    color: var(--text-muted);
    transition: all var(--transition);
}

.project-link:hover {
    border-color: var(--purple);
    color: var(--purple);
    background: var(--purple-dim);
}

.project-link.primary {
    background: var(--purple-dim);
    border-color: rgba(167,139,250,0.3);
    color: var(--purple);
}

/* ─── REPORT SECTION ────────────────────────────────────────────────────── */
.report-section {
    margin-top: 3rem;
    padding: 2rem;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
}

.report-section h4 {
    font-size: 1rem;
    font-weight: 600;
    color: var(--text);
    margin-bottom: 0.5rem;
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.report-section h4 i { color: var(--red); }

.report-section p {
    font-size: 0.9rem;
    color: var(--text-muted);
    margin-bottom: 1.2rem;
}

.report-section embed {
    width: 100%;
    height: 420px;
    border-radius: var(--radius-md);
    border: 1px solid var(--border);
    margin-bottom: 1rem;
}

.report-section .btn {
    display: inline-flex;
    align-items: center;
    gap: 0.5rem;
    font-size: 0.875rem;
    font-weight: 600;
    padding: 0.6rem 1.4rem;
    border-radius: var(--radius-md);
    background: var(--surface-2);
    border: 1px solid var(--border);
    color: var(--text);
    transition: all var(--transition);
}

.report-section .btn:hover {
    border-color: var(--blue);
    color: var(--blue);
}

/* ─── CLASSES ───────────────────────────────────────────────────────────── */
.classes-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 1.5rem;
}

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

.classes-card {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    padding: 1.8rem 2rem;
}

.classes-card h2 {
    font-size: 0.75rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.1em;
    color: var(--text-dim);
    margin-bottom: 1.2rem;
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.classes-card h2 .dot {
    width: 7px; height: 7px;
    border-radius: 50%;
    flex-shrink: 0;
}

.classes-card.completed h2 .dot { background: var(--text-dim); }
.classes-card.current h2 .dot { background: var(--green); box-shadow: 0 0 6px var(--green); }

.classes-card ul {
    list-style: none;
    display: flex;
    flex-direction: column;
    gap: 0.6rem;
}

.classes-card ul li {
    font-size: 0.9rem;
    color: var(--text-muted);
    display: flex;
    align-items: baseline;
    gap: 0.6rem;
    line-height: 1.4;
}

.classes-card ul li::before {
    content: '';
    width: 4px; height: 4px;
    border-radius: 50%;
    background: var(--border-hover);
    flex-shrink: 0;
    margin-top: 0.45rem;
}

.classes-card.current ul li::before { background: var(--green); }

.course-code {
    font-family: 'JetBrains Mono', monospace;
    font-size: 0.72rem;
    color: var(--text-dim);
    white-space: nowrap;
}

/* ─── RESUME ────────────────────────────────────────────────────────────── */
.resume-wrapper {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    padding: 2rem;
}

.resume-wrapper p {
    font-size: 0.9rem;
    color: var(--text-muted);
    margin-bottom: 1.2rem;
}

.resume-wrapper embed {
    width: 100%;
    height: 640px;
    border-radius: var(--radius-md);
    border: 1px solid var(--border);
    margin-bottom: 1.2rem;
    display: block;
}

.resume-wrapper .btn {
    display: inline-flex;
    align-items: center;
    gap: 0.5rem;
    font-size: 0.875rem;
    font-weight: 600;
    padding: 0.65rem 1.5rem;
    border-radius: var(--radius-md);
    background: var(--blue);
    color: #fff;
    transition: all var(--transition);
}

.resume-wrapper .btn:hover {
    background: #6aa3fa;
    transform: translateY(-1px);
    box-shadow: 0 8px 24px var(--blue-glow);
}

/* ─── CONTACT ───────────────────────────────────────────────────────────── */
.contact-inner {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius-xl);
    padding: 4rem 3rem;
    text-align: center;
    max-width: 560px;
    margin: 0 auto;
    position: relative;
    overflow: hidden;
}

.contact-inner::before {
    content: '';
    position: absolute;
    top: -80px; left: 50%;
    transform: translateX(-50%);
    width: 300px; height: 300px;
    background: radial-gradient(circle, rgba(79,142,247,0.08), transparent 70%);
    pointer-events: none;
}

.contact-inner h2 {
    font-size: 1.6rem;
    font-weight: 700;
    letter-spacing: -0.03em;
    margin-bottom: 0.75rem;
    color: var(--text);
}

.contact-inner p {
    font-size: 0.95rem;
    color: var(--text-muted);
    margin-bottom: 2rem;
    line-height: 1.7;
}

.contact-inner .btn-primary {
    margin-bottom: 2rem;
}

.contact-inner .social-row {
    justify-content: center;
}

/* ─── FOOTER ────────────────────────────────────────────────────────────── */
footer {
    text-align: center;
    padding: 2rem 5%;
    border-top: 1px solid var(--border);
    font-family: 'Lora', serif;
    font-size: 0.9rem;
    font-style: italic;
    color: var(--text-dim);
    margin-top: 2rem;
}

/* ─── DIVIDER (kept for compat, hidden via band rule above) ─────────────── */
.section-divider {
    display: none;
}

/* ─── FLOATING AI TWIN CHAT BUBBLE ─────────────────────────────────────── */

/* Container anchors everything to bottom-right */
#twin-bubble {
    position: fixed;
    bottom: 24px;
    right: 24px;
    z-index: 9999;
    display: flex;
    flex-direction: column;
    align-items: flex-end;
    gap: 12px;
}

/* ── Toggle button ─────────────────────────────────────────────────────── */
#twin-toggle {
    width: 52px;
    height: 52px;
    border-radius: 50%;
    background: var(--blue);
    border: none;
    color: #fff;
    font-size: 1.25rem;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    box-shadow: 0 4px 20px var(--blue-glow);
    transition: background var(--transition), transform var(--transition);
    flex-shrink: 0;
}
#twin-toggle:hover { background: var(--text); transform: scale(1.07); }

/* ── Chat panel ────────────────────────────────────────────────────────── */
#twin-panel {
    width: 340px;
    height: 460px;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    display: flex;
    flex-direction: column;
    overflow: hidden;
    box-shadow: var(--shadow-lg);

    /* Hidden by default — slide up when .open */
    opacity: 0;
    pointer-events: none;
    transform: translateY(16px) scale(0.97);
    transform-origin: bottom right;
    transition: opacity 0.22s ease, transform 0.22s ease;
}
#twin-panel.open {
    opacity: 1;
    pointer-events: all;
    transform: translateY(0) scale(1);
}

/* ── Header ────────────────────────────────────────────────────────────── */
#twin-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 12px 14px;
    background: var(--surface-2);
    border-bottom: 1px solid var(--border);
    flex-shrink: 0;
}
#twin-header-left {
    display: flex;
    align-items: center;
    gap: 10px;
}
#twin-avatar {
    width: 34px;
    height: 34px;
    border-radius: 50%;
    background: var(--blue-dim);
    color: var(--blue);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 0.95rem;
    flex-shrink: 0;
}
#twin-name {
    font-size: 0.88rem;
    font-weight: 600;
    color: var(--text);
}
#twin-status {
    font-size: 0.72rem;
    color: var(--text-dim);
    display: flex;
    align-items: center;
    gap: 5px;
    margin-top: 1px;
}
#twin-dot {
    width: 6px;
    height: 6px;
    border-radius: 50%;
    background: var(--green);
    box-shadow: 0 0 5px var(--green);
    display: inline-block;
}
#twin-close-btn {
    background: none;
    border: none;
    color: var(--text-dim);
    cursor: pointer;
    font-size: 1rem;
    padding: 4px;
    line-height: 1;
    transition: color var(--transition);
}
#twin-close-btn:hover { color: var(--text); }

/* ── Messages ──────────────────────────────────────────────────────────── */
#twin-messages {
    flex: 1;
    overflow-y: auto;
    padding: 14px 12px;
    display: flex;
    flex-direction: column;
    gap: 10px;
    scroll-behavior: smooth;
}
#twin-messages::-webkit-scrollbar { width: 4px; }
#twin-messages::-webkit-scrollbar-thumb { background: var(--surface-3); border-radius: 2px; }

.twin-msg {
    display: flex;
    max-width: 85%;
}
.twin-msg.user  { align-self: flex-end; }
.twin-msg.bot   { align-self: flex-start; }

.twin-msg-text {
    display: inline-block;
    padding: 8px 12px;
    border-radius: 14px;
    font-size: 0.85rem;
    line-height: 1.5;
    word-break: break-word;
}
.twin-msg.user .twin-msg-text {
    background: var(--blue);
    color: #fff;
    border-bottom-right-radius: 4px;
}
.twin-msg.bot .twin-msg-text {
    background: var(--surface-2);
    color: var(--text);
    border: 1px solid var(--border);
    border-bottom-left-radius: 4px;
}

/* Typing indicator dots */
.twin-dots {
    display: inline-flex;
    gap: 4px;
    align-items: center;
    padding: 2px 0;
}
.twin-dots span {
    width: 6px;
    height: 6px;
    border-radius: 50%;
    background: var(--text-dim);
    animation: twin-bounce 1.2s infinite ease-in-out;
}
.twin-dots span:nth-child(1) { animation-delay: 0s; }
.twin-dots span:nth-child(2) { animation-delay: 0.2s; }
.twin-dots span:nth-child(3) { animation-delay: 0.4s; }
@keyframes twin-bounce {
    0%, 80%, 100% { transform: scale(0.7); opacity: 0.4; }
    40%           { transform: scale(1);   opacity: 1; }
}

/* ── Input row ─────────────────────────────────────────────────────────── */
#twin-input-row {
    display: flex;
    gap: 8px;
    padding: 10px 12px;
    border-top: 1px solid var(--border);
    background: var(--surface);
    flex-shrink: 0;
}
#twin-input {
    flex: 1;
    background: var(--surface-2);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    color: var(--text);
    font-family: 'Inter', sans-serif;
    font-size: 0.85rem;
    padding: 8px 12px;
    outline: none;
    transition: border-color var(--transition);
}
#twin-input:focus { border-color: var(--blue); }
#twin-input::placeholder { color: var(--text-dim); }

#twin-send {
    width: 36px;
    height: 36px;
    border-radius: var(--radius-sm);
    background: var(--blue);
    border: none;
    color: #fff;
    font-size: 0.85rem;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    transition: background var(--transition);
}
#twin-send:hover { background: var(--text); }
#twin-send:disabled { opacity: 0.5; cursor: default; }

/* ── Mobile: full-width panel ──────────────────────────────────────────── */
@media (max-width: 480px) {
    #twin-bubble { bottom: 16px; right: 16px; }
    #twin-panel  { width: calc(100vw - 32px); height: 420px; }
}
