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

:root {
    --bg: #0a0a0f;
    --surface: rgba(255,255,255,0.04);
    --surface-2: rgba(255,255,255,0.07);
    --border: rgba(255,255,255,0.1);
    --border-hover: rgba(255,255,255,0.2);
    --text: #f0f0f0;
    --text-2: rgba(255,255,255,0.6);
    --text-3: rgba(255,255,255,0.3);
    --accent: #a78bfa;
    --accent-2: #60a5fa;
    --accent-3: #34d399;
    --purple: #a78bfa;
    --green: #34d399;
    --red: #f87171;
    --shadow: 0 2px 20px rgba(0,0,0,0.3);
}

body {
    font-family: 'Inter', -apple-system, sans-serif;
    background: var(--bg);
    color: var(--text);
    min-height: 100vh;
    -webkit-font-smoothing: antialiased;
    position: relative;
}

/* ══ ANIMATED GRADIENT BACKGROUND ══ */
body::before {
    content: '';
    position: fixed;
    inset: 0;
    z-index: -2;
    background: linear-gradient(
        135deg,
        #0a0a1a 0%,
        #1a0a2e 20%,
        #0a1628 40%,
        #0f1a0a 60%,
        #1a0a1a 80%,
        #0a0a1a 100%
    );
    background-size: 400% 400%;
    animation: gradientShift 20s ease infinite;
}

@keyframes gradientShift {
    0% { background-position: 0% 50%; }
    25% { background-position: 100% 0%; }
    50% { background-position: 100% 100%; }
    75% { background-position: 0% 100%; }
    100% { background-position: 0% 50%; }
}

/* ══ GRAIN OVERLAY ══ */
body::after {
    content: '';
    position: fixed;
    inset: 0;
    z-index: -1;
    background-image: url("data:image/svg+xml,%3Csvg viewBox='0 0 256 256' xmlns='http://www.w3.org/2000/svg'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.9' numOctaves='4' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23n)' opacity='0.15'/%3E%3C/svg%3E");
    opacity: 0.4;
    pointer-events: none;
}

.app-container {
    max-width: 1400px;
    margin: 0 auto;
    padding: 0 32px;
    min-height: 100vh;
    display: flex;
    flex-direction: column;
    position: relative;
}

/* NAV */
nav {
    padding: 20px 0;
    border-bottom: 1px solid var(--border);
    display: flex;
    justify-content: space-between;
    align-items: center;
}
.logo {
    font-family: 'Space Grotesk', sans-serif;
    font-size: 22px;
    font-weight: 700;
    letter-spacing: -0.5px;
    text-decoration: none;
    color: var(--text);
}
.logo span {
    background: linear-gradient(135deg, var(--accent), var(--accent-2));
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    font-weight: 600;
}
.nav-right { display: flex; align-items: center; }
.nav-tagline {
    font-size: 12px;
    color: var(--text-3);
    font-weight: 500;
    letter-spacing: 1px;
    text-transform: uppercase;
}

/* SCREENS */
.screen { display: none; flex: 1; }
.screen.active { display: flex; flex-direction: column; }

/* ══ BUTTONS ══ */
.btn-launch {
    width: 100%;
    padding: 18px;
    background: linear-gradient(135deg, var(--accent), var(--accent-2));
    color: #fff;
    border: none;
    border-radius: 12px;
    font-size: 16px;
    font-weight: 700;
    font-family: 'Space Grotesk', sans-serif;
    cursor: pointer;
    transition: all 0.2s;
    margin-top: 16px;
}
.btn-launch:hover { opacity: 0.9; transform: translateY(-1px); box-shadow: 0 8px 30px rgba(167,139,250,0.2); }
.btn-launch:disabled { opacity: 0.3; cursor: not-allowed; transform: none; }

.btn-action {
    padding: 12px 24px;
    border-radius: 10px;
    font-size: 14px;
    font-weight: 700;
    cursor: pointer;
    font-family: 'Inter', sans-serif;
    transition: all 0.15s;
    border: 1px solid var(--border);
}
.btn-action:hover { border-color: var(--border-hover); }
.btn-action-primary {
    background: linear-gradient(135deg, var(--accent), var(--accent-2));
    color: #fff;
    border: none;
}

/* ══ HERO ══ */
.hero-section { margin: 60px 0 32px; padding-bottom: 28px; border-bottom: 1px solid var(--border); }
.hero-section h1 {
    font-family: 'Space Grotesk', sans-serif;
    font-size: 42px;
    font-weight: 700;
    letter-spacing: -2px;
    line-height: 1.15;
    margin-bottom: 10px;
    background: linear-gradient(135deg, #fff 40%, var(--accent));
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
}
.hero-section p { font-size: 16px; color: var(--text-2); line-height: 1.6; margin-bottom: 16px; max-width: 700px; }
.sala-date-badge {
    font-size: 11px; font-weight: 700; text-transform: uppercase; letter-spacing: 1px;
    padding: 4px 14px; border: 1px solid var(--border); border-radius: 100px; color: var(--text-3);
}

/* ══ SALA ══ */
.sala-section { margin-bottom: 20px; }
.opening-card {
    font-size: 16px; line-height: 1.7; padding: 22px 26px;
    background: linear-gradient(135deg, rgba(167,139,250,0.08), rgba(96,165,250,0.08));
    border: 1px solid rgba(167,139,250,0.2);
    border-radius: 16px; margin-bottom: 24px; font-weight: 500;
    backdrop-filter: blur(10px);
}
.sala-chars-strip { display: flex; flex-wrap: wrap; gap: 8px; margin-bottom: 24px; }
.char-tag {
    font-size: 11px; font-weight: 600; padding: 5px 14px;
    border: 1px solid var(--border); border-radius: 100px; color: var(--text-2);
    background: var(--surface); backdrop-filter: blur(10px);
    transition: all 0.15s;
}
.char-tag:hover { border-color: var(--accent); color: var(--text); }
.sala-chat-area { margin: 20px 0; }

/* ══ PROGRESS ══ */
.progress-section { margin-bottom: 24px; }
.progress-bar { height: 4px; background: var(--surface); border-radius: 100px; overflow: hidden; }
.progress-fill {
    height: 100%; border-radius: 100px; transition: width 0.5s; width: 0;
    background: linear-gradient(90deg, var(--accent), var(--accent-2), var(--accent-3));
}
.progress-text { font-size: 13px; color: var(--text-3); margin-top: 10px; }

/* ══ TIMELINE ══ */
.timeline { position: relative; padding: 0 0 20px 0; margin-bottom: 20px; }

.tl-round { margin-bottom: 8px; }
.tl-round-title {
    font-size: 11px; font-weight: 700; letter-spacing: 3px; text-transform: uppercase;
    color: var(--text-3); padding: 28px 0 12px; border-bottom: 1px solid var(--border); margin-bottom: 16px;
}
.tl-round-marker { display: none; }

/* Feed — masonry 3 columns */
.tl-feed {
    column-count: 3;
    column-gap: 14px;
}
.tl-feed > .tl-thread {
    break-inside: avoid;
    margin-bottom: 14px;
    display: inline-block;
    width: 100%;
}
@media (max-width: 1024px) { .tl-feed { column-count: 2; } }
@media (max-width: 640px) { .tl-feed { column-count: 1; } }

/* Thread */
.tl-thread {
    border: 1px solid var(--border);
    border-radius: 16px;
    overflow: hidden;
    background: var(--surface);
    backdrop-filter: blur(10px);
    transition: all 0.2s;
}
.tl-thread:hover { border-color: var(--border-hover); background: var(--surface-2); }

/* Post */
.tl-post { padding: 20px; }
.tl-post-header { display: flex; align-items: center; gap: 12px; margin-bottom: 14px; }
.tl-post-header canvas {
    image-rendering: pixelated; width: 40px; height: 46px; flex-shrink: 0;
    border: 1px solid var(--border); border-radius: 8px; background: rgba(0,0,0,0.3);
}
.tl-post-author {
    font-family: 'Space Grotesk', sans-serif; font-size: 15px; font-weight: 700; letter-spacing: -0.3px;
}
.tl-post-meta { font-size: 11px; color: var(--text-3); }
.tl-post-badge { display: none; }
.tl-post-content { font-size: 15px; line-height: 1.75; color: rgba(255,255,255,0.8); }

/* Thread count (collapsible) */
.tl-thread-count {
    font-size: 12px; font-weight: 700; padding: 10px 20px;
    background: rgba(167,139,250,0.06); border-top: 1px solid var(--border);
    letter-spacing: 0.5px; cursor: pointer; user-select: none; transition: background 0.1s;
    background: linear-gradient(135deg, rgba(167,139,250,0.06), rgba(96,165,250,0.06));
    color: var(--accent);
}
.tl-thread-count:hover { background: rgba(167,139,250,0.12); }
.tl-thread-count::after { content: ' \25BC'; font-size: 9px; }
.tl-thread-count.open::after { content: ' \25B2'; }

.tl-replies { display: none; }
.tl-replies.open { display: block; }

/* Reply */
.tl-reply {
    padding: 14px 20px 14px 36px; border-top: 1px solid var(--border);
    position: relative; background: rgba(0,0,0,0.15);
}
.tl-reply::before {
    content: ''; position: absolute; left: 18px; top: 0; width: 2px; height: 100%;
    background: linear-gradient(180deg, var(--accent), var(--accent-2)); opacity: 0.2; border-radius: 2px;
}
.tl-reply-header { display: flex; align-items: center; gap: 6px; margin-bottom: 4px; }
.tl-reply-name { font-family: 'Space Grotesk', sans-serif; font-size: 13px; font-weight: 700; }
.tl-reply-meta { font-size: 10px; color: var(--text-3); }
.tl-reply-content { font-size: 14px; line-height: 1.65; color: rgba(255,255,255,0.65); }

/* ══ SECTIONS ══ */
.section-divider { height: 1px; background: var(--border); margin: 40px 0 24px; }
.section-title {
    font-family: 'Space Grotesk', sans-serif; font-size: 28px; font-weight: 700;
    letter-spacing: -1px; margin-bottom: 8px;
    background: linear-gradient(135deg, #fff, var(--accent-2));
    -webkit-background-clip: text; -webkit-text-fill-color: transparent;
}
.section-sub { font-size: 15px; color: var(--text-3); margin-bottom: 24px; max-width: 600px; }
.section-label-geo {
    font-size: 11px; text-transform: uppercase; letter-spacing: 3px; font-weight: 700;
    margin-bottom: 16px;
    background: linear-gradient(135deg, var(--accent), var(--accent-2));
    -webkit-background-clip: text; -webkit-text-fill-color: transparent;
}

/* ══ REPORT ══ */
.sala-report-section { margin: 20px 0; }
.report-text {
    font-size: 16px; line-height: 1.8; color: var(--text-2); padding: 24px;
    background: linear-gradient(135deg, rgba(167,139,250,0.06), rgba(52,211,153,0.06));
    border: 1px solid rgba(167,139,250,0.15); border-left: 3px solid var(--accent);
    border-radius: 0 16px 16px 0; margin-bottom: 16px; backdrop-filter: blur(10px);
}
.highlight-card {
    background: var(--surface); border: 1px solid var(--border); border-radius: 16px;
    padding: 20px; margin-bottom: 12px; transition: all 0.15s; backdrop-filter: blur(10px);
}
.highlight-card:hover { border-color: var(--border-hover); }
.highlight-quote { font-size: 15px; line-height: 1.7; font-style: italic; margin-bottom: 8px; border-left: 2px solid var(--accent); padding-left: 16px; color: var(--text-2); }
.highlight-meta { font-size: 13px; color: var(--text-3); }
.highlight-meta strong { color: var(--text-2); }
.empty-text { color: var(--text-3); font-size: 15px; padding: 40px 0; text-align: center; }

/* ══ EMPTY STATE ══ */
.empty-state { text-align: center; padding: 120px 0; }
.empty-state h1 {
    font-family: 'Space Grotesk', sans-serif; font-size: 42px; font-weight: 700;
    letter-spacing: -2px; margin-bottom: 12px;
    background: linear-gradient(135deg, #fff, var(--accent));
    -webkit-background-clip: text; -webkit-text-fill-color: transparent;
}
.empty-state p { font-size: 17px; color: var(--text-3); margin-bottom: 32px; }

/* ══ ARCHIVE ══ */
.archive-section { padding-bottom: 40px; }
.archive-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(280px, 1fr)); gap: 14px; }
.archive-card {
    display: block; text-decoration: none; color: var(--text);
    background: var(--surface); border: 1px solid var(--border); border-radius: 16px; padding: 24px;
    transition: all 0.2s; backdrop-filter: blur(10px);
}
.archive-card:hover { border-color: var(--border-hover); background: var(--surface-2); }
.archive-card-date { font-size: 11px; text-transform: uppercase; letter-spacing: 1px; color: var(--text-3); font-weight: 600; margin-bottom: 8px; }
.archive-card-title { font-family: 'Space Grotesk', sans-serif; font-size: 17px; font-weight: 700; letter-spacing: -0.3px; line-height: 1.3; margin-bottom: 12px; }
.archive-card-status { font-size: 10px; font-weight: 700; text-transform: uppercase; letter-spacing: 1px; padding: 3px 10px; border-radius: 100px; border: 1px solid var(--border); display: inline-block; }
.status-completed, .status-terminada { background: rgba(52,211,153,0.1); color: var(--green); border-color: rgba(52,211,153,0.2); }
.status-running { background: rgba(167,139,250,0.1); color: var(--accent); border-color: rgba(167,139,250,0.2); }
.status-failed { background: rgba(248,113,113,0.1); color: var(--red); border-color: rgba(248,113,113,0.2); }
.status-pending { background: var(--surface); color: var(--text-3); }

/* ══ CHARACTERS ══ */
.characters-section { padding-bottom: 20px; }
.characters-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(300px, 1fr)); gap: 14px; padding-bottom: 60px; }
.char-card {
    background: var(--surface); border: 1px solid var(--border); border-radius: 16px; padding: 24px;
    display: flex; gap: 16px; align-items: flex-start; transition: all 0.2s; backdrop-filter: blur(10px);
}
.char-card:hover { border-color: var(--border-hover); background: var(--surface-2); }
.char-face { image-rendering: pixelated; width: 48px; height: 56px; flex-shrink: 0; border: 1px solid var(--border); border-radius: 8px; background: rgba(0,0,0,0.3); }
.char-info { flex: 1; min-width: 0; }
.char-name { font-family: 'Space Grotesk', sans-serif; font-size: 17px; font-weight: 700; letter-spacing: -0.3px; }
.char-meta { font-size: 12px; color: var(--text-3); margin-bottom: 6px; }
.char-profession { font-size: 13px; color: var(--accent); font-weight: 600; margin-bottom: 6px; }
.char-bio { font-size: 13px; color: rgba(255,255,255,0.45); line-height: 1.7; display: none; margin-top: 10px; padding-top: 10px; border-top: 1px solid var(--border); }
.char-bio.open { display: block; }
.char-toggle { font-size: 12px; color: var(--accent); cursor: pointer; margin-top: 6px; background: none; border: none; font-family: 'Inter', sans-serif; font-weight: 600; padding: 0; }
.char-toggle:hover { text-decoration: underline; }
.char-toggle::after { content: ' \25BC'; font-size: 9px; }
.char-toggle.open::after { content: ' \25B2'; }

/* ══ CHAT ══ */
.chat-panel { display: none; margin-top: 12px; background: var(--surface); border: 1px solid var(--border); border-radius: 16px; overflow: hidden; backdrop-filter: blur(10px); }
.chat-panel.open { display: block; }
.chat-messages { max-height: 400px; overflow-y: auto; padding: 20px; display: flex; flex-direction: column; gap: 12px; }
.chat-msg { padding: 12px 16px; border-radius: 12px; font-size: 14px; line-height: 1.6; max-width: 80%; }
.chat-msg.user { background: linear-gradient(135deg, var(--accent), var(--accent-2)); color: #fff; align-self: flex-end; }
.chat-msg.assistant { background: var(--surface-2); color: var(--text-2); align-self: flex-start; border: 1px solid var(--border); }
.chat-input-area { display: flex; gap: 8px; padding: 14px; border-top: 1px solid var(--border); }
.chat-input {
    flex: 1; padding: 12px 16px; background: rgba(0,0,0,0.2); border: 1px solid var(--border);
    border-radius: 12px; color: var(--text); font-size: 14px; font-family: 'Inter', sans-serif; outline: none;
}
.chat-input:focus { border-color: var(--accent); }
.chat-input::placeholder { color: var(--text-3); }
.chat-send {
    padding: 12px 22px; background: linear-gradient(135deg, var(--accent), var(--accent-2));
    color: #fff; border: none; border-radius: 12px; font-weight: 700; font-size: 14px; cursor: pointer;
}
.chat-send:disabled { opacity: 0.3; cursor: not-allowed; }

/* ══ SCROLLBAR ══ */
::-webkit-scrollbar { width: 4px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--border); border-radius: 4px; }

/* ══ RESPONSIVE ══ */
@media (max-width: 1024px) { .tl-feed { column-count: 2; } }
@media (max-width: 640px) {
    .tl-feed { column-count: 1; }
    .hero-section h1 { font-size: 26px; }
    .section-title { font-size: 22px; }
    .empty-state h1 { font-size: 28px; }
    .app-container { padding: 0 16px; }

    /* Mobile readability */
    .tl-post-content { font-size: 16px; line-height: 1.8; color: #eee; }
    .tl-post-author { font-size: 16px; }
    .tl-post-meta { font-size: 12px; color: rgba(255,255,255,0.45); }
    .tl-reply-content { font-size: 15px; line-height: 1.75; color: rgba(255,255,255,0.7); }
    .tl-reply-name { font-size: 14px; }

    .char-name { font-size: 18px; color: #fff; }
    .char-meta { font-size: 13px; color: rgba(255,255,255,0.45); }
    .char-profession { font-size: 14px; }
    .char-bio { font-size: 14px; line-height: 1.7; color: rgba(255,255,255,0.5); }
    .char-card { padding: 20px; }

    .opening-card { font-size: 16px; color: #eee; }
    .char-tag { font-size: 12px; padding: 6px 14px; }
    .hero-section p { font-size: 15px; color: rgba(255,255,255,0.6); }

    .report-text { font-size: 15px; color: rgba(255,255,255,0.7); }
    .highlight-quote { font-size: 15px; color: rgba(255,255,255,0.7); }
    .highlight-meta { font-size: 13px; }

    .archive-card-title { font-size: 16px; }
    .archive-card-date { font-size: 12px; }

    .section-sub { font-size: 14px; color: rgba(255,255,255,0.45); }
    .tl-round-title { font-size: 12px; }
    .tl-thread-count { font-size: 13px; }

    .characters-grid { grid-template-columns: 1fr; }

    /* Reduce spacing */
    .section-divider { margin: 28px 0 20px; }
    .hero-section { margin: 28px 0 20px; padding-bottom: 18px; }
    .sala-chars-strip { margin-bottom: 16px; }
    .characters-section { padding-bottom: 10px; }
    .archive-section { padding-bottom: 20px; }
    .tl-round-title { padding: 18px 0 8px; }

    /* Fix char card alignment */
    .char-card { align-items: center; }
    .char-face { width: 44px; height: 52px; }
    .char-info { display: flex; flex-direction: column; }
}
