/* ======================
   TOKENS
   ====================== */

:root {
    --bg: #0b0b0d;
    --surface: #15151a;
    --surface-hover: #1b1b22;
    --border: #26262e;
    --text: #e8e8ec;
    --text-dim: #8b8b96;
    --text-faint: #5a5a64;
    --danger: #e5544d;

    /* Estos dos los pisa JS con el theme de la instancia activa */
    --accent: #5865F2;
    --accent-bg: #0b0b0d;

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

    --font-ui: -apple-system, "Inter", "Segoe UI", system-ui, sans-serif;
    --font-mono: "SF Mono", "JetBrains Mono", ui-monospace, Menlo, monospace;
}

* {
    box-sizing: border-box;
}

html, body {
    margin: 0;
    padding: 0;
    background: var(--bg);
    color: var(--text);
    font-family: var(--font-ui);
    -webkit-font-smoothing: antialiased;
}

button {
    font-family: inherit;
}

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

::selection {
    background: color-mix(in srgb, var(--accent) 35%, transparent);
}

:focus-visible {
    outline: 2px solid var(--accent);
    outline-offset: 2px;
}

/* ======================
   AUTH SCREEN
   ====================== */

.auth-screen {
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 24px;
    background:
        radial-gradient(circle at 20% 20%, color-mix(in srgb, var(--accent) 10%, transparent), transparent 50%),
        var(--bg);
}

.auth-box {
    width: 100%;
    max-width: 380px;
}

.auth-logo {
    display: flex;
    align-items: baseline;
    gap: 6px;
    margin-bottom: 32px;
    justify-content: center;
}

.auth-logo-mark {
    font-family: var(--font-mono);
    font-size: 28px;
    color: var(--accent);
}

.auth-logo-text {
    font-size: 20px;
    font-weight: 600;
    letter-spacing: -0.02em;
}

.auth-tabs {
    display: flex;
    gap: 4px;
    background: var(--surface);
    border-radius: var(--radius-md);
    padding: 4px;
    margin-bottom: 24px;
}

.auth-tab {
    flex: 1;
    border: none;
    background: transparent;
    color: var(--text-dim);
    padding: 8px 0;
    border-radius: var(--radius-sm);
    cursor: pointer;
    font-size: 14px;
    font-weight: 500;
    transition: background 0.15s, color 0.15s;
}

.auth-tab.active {
    background: var(--accent);
    color: #fff;
}

.auth-form {
    display: flex;
    flex-direction: column;
    gap: 14px;
}

.field {
    display: flex;
    flex-direction: column;
    gap: 6px;
}

.field-label {
    font-size: 12px;
    color: var(--text-dim);
    font-weight: 500;
}

input, textarea, select {
    background: var(--surface);
    border: 1px solid var(--border);
    color: var(--text);
    border-radius: var(--radius-sm);
    padding: 10px 12px;
    font-size: 14px;
    font-family: inherit;
    width: 100%;
}

input::placeholder, textarea::placeholder {
    color: var(--text-faint);
}

input:focus, textarea:focus, select:focus {
    border-color: var(--accent);
}

.auth-error {
    color: var(--danger);
    font-size: 13px;
    margin: 0;
}

.btn {
    border: none;
    border-radius: var(--radius-sm);
    padding: 10px 16px;
    font-size: 14px;
    font-weight: 600;
    cursor: pointer;
    transition: opacity 0.15s, transform 0.1s;
}

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

.btn-primary {
    background: var(--accent);
    color: #fff;
}

.btn-primary:hover {
    opacity: 0.9;
}

.btn-full {
    width: 100%;
}

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

.btn-ghost {
    background: transparent;
    color: var(--text-dim);
}

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

/* ======================
   APP SHELL
   ====================== */

.app {
    display: grid;
    grid-template-columns: 68px minmax(0, 600px) 1fr;
    min-height: 100vh;
}

@media (max-width: 1100px) {
    .app {
        grid-template-columns: 68px 1fr;
    }
    .detail-col {
        display: none;
    }
}

@media (max-width: 640px) {
    .app {
        grid-template-columns: 1fr;
    }
    .rail {
        position: fixed;
        bottom: 0;
        left: 0;
        right: 0;
        top: auto;
        width: 100%;
        height: 56px;
        flex-direction: row;
        border-right: none;
        border-top: 1px solid var(--border);
        padding: 0 8px;
        z-index: 50;
    }
    .rail-logo, .rail-spacer {
        display: none;
    }
    .timeline-col {
        padding-bottom: 70px;
    }
}

/* Sidebar */

.rail {
    border-right: 1px solid var(--border);
    display: flex;
    flex-direction: column;
    align-items: center;
    padding: 16px 0;
    gap: 4px;
    position: sticky;
    top: 0;
    height: 100vh;
}

.rail-logo {
    font-family: var(--font-mono);
    font-size: 20px;
    color: var(--accent);
    margin-bottom: 16px;
}

.rail-btn {
    width: 44px;
    height: 44px;
    border-radius: var(--radius-md);
    border: none;
    background: transparent;
    color: var(--text-dim);
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    position: relative;
    transition: background 0.15s, color 0.15s;
}

.rail-btn:hover {
    background: var(--surface-hover);
    color: var(--text);
}

.rail-btn.active {
    color: var(--accent);
}

.rail-spacer {
    flex: 1;
}

.rail-compose {
    background: var(--accent);
    color: #fff;
}

.rail-compose:hover {
    background: var(--accent);
    opacity: 0.9;
}

.rail-badge {
    position: absolute;
    top: 4px;
    right: 4px;
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: var(--danger);
}

/* Timeline column */

.timeline-col {
    border-right: 1px solid var(--border);
    min-height: 100vh;
}

.col-header {
    position: sticky;
    top: 0;
    background: color-mix(in srgb, var(--bg) 85%, transparent);
    backdrop-filter: blur(8px);
    border-bottom: 1px solid var(--border);
    padding: 14px 20px;
    z-index: 10;
}

.col-header h1 {
    font-size: 17px;
    font-weight: 700;
    margin: 0;
}

/* Composer inline */

.composer-inline {
    border-bottom: 1px solid var(--border);
    padding: 16px 20px;
}

.composer-inline textarea, .modal-box textarea {
    background: transparent;
    border: none;
    resize: none;
    font-size: 15px;
    padding: 0;
    margin-bottom: 10px;
}

.composer-inline textarea:focus, .modal-box textarea:focus {
    outline: none;
}

.composer-bar {
    display: flex;
    align-items: center;
    gap: 10px;
}

.composer-icon-btn {
    color: var(--text-dim);
    cursor: pointer;
    display: flex;
    align-items: center;
    padding: 6px;
    border-radius: var(--radius-sm);
}

.composer-icon-btn:hover {
    background: var(--surface-hover);
    color: var(--accent);
}

.composer-visibility {
    width: auto;
    padding: 4px 8px;
    font-size: 12px;
    color: var(--text-dim);
    border: 1px solid var(--border);
}

.composer-spacer {
    flex: 1;
}

.composer-preview {
    margin-top: 10px;
    max-width: 200px;
    border-radius: var(--radius-sm);
    overflow: hidden;
}

.composer-preview img {
    width: 100%;
    display: block;
}

/* Feed / posts */

.feed-loading, .detail-empty {
    padding: 40px 20px;
    color: var(--text-faint);
    text-align: center;
    font-size: 14px;
}

.post {
    display: flex;
    gap: 12px;
    padding: 14px 20px;
    border-bottom: 1px solid var(--border);
    cursor: pointer;
    transition: background 0.1s;
}

.post:hover {
    background: var(--surface);
}

.post-avatar {
    width: 42px;
    height: 42px;
    border-radius: 50%;
    background: var(--surface-hover);
    flex-shrink: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 700;
    color: var(--accent);
    overflow: hidden;
}

.post-avatar img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.post-body {
    flex: 1;
    min-width: 0;
}

.post-head {
    display: flex;
    align-items: baseline;
    gap: 6px;
    flex-wrap: wrap;
}

.post-name {
    font-weight: 600;
    font-size: 14px;
}

.post-handle, .post-time {
    color: var(--text-faint);
    font-size: 13px;
    font-family: var(--font-mono);
}

.post-requote {
    font-size: 12px;
    color: var(--text-dim);
    display: flex;
    align-items: center;
    gap: 6px;
    margin-bottom: 4px;
}

.post-content {
    font-size: 15px;
    line-height: 1.45;
    white-space: pre-wrap;
    word-break: break-word;
    margin: 2px 0 6px;
}

.post-content .mention {
    color: var(--accent);
}

.post-images {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(120px, 1fr));
    gap: 6px;
    margin-bottom: 8px;
    border-radius: var(--radius-md);
    overflow: hidden;
}

.post-images img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    max-height: 280px;
    background: var(--surface-hover);
}

.post-quote {
    border: 1px solid var(--border);
    border-radius: var(--radius-md);
    padding: 10px 12px;
    margin-bottom: 8px;
}

.post-edited {
    font-size: 12px;
    color: var(--text-faint);
}

.post-actions {
    display: flex;
    gap: 24px;
    margin-top: 4px;
}

.post-action {
    display: flex;
    align-items: center;
    gap: 6px;
    color: var(--text-dim);
    background: none;
    border: none;
    cursor: pointer;
    font-size: 13px;
    padding: 4px;
    border-radius: var(--radius-sm);
    transition: color 0.15s;
}

.post-action:hover {
    color: var(--text);
}

.post-action.liked {
    color: var(--danger);
}

.post-action.reposted {
    color: var(--accent);
}

.post-private-tag {
    font-size: 11px;
    color: var(--text-faint);
    border: 1px solid var(--border);
    padding: 1px 6px;
    border-radius: 4px;
}

/* Detail column */

.detail-col {
    padding: 0;
    min-height: 100vh;
}

.detail-header {
    position: sticky;
    top: 0;
    background: color-mix(in srgb, var(--bg) 85%, transparent);
    backdrop-filter: blur(8px);
    border-bottom: 1px solid var(--border);
    padding: 14px 20px;
}

.profile-card {
    padding: 20px;
    border-bottom: 1px solid var(--border);
}

.profile-avatar-lg {
    width: 64px;
    height: 64px;
    border-radius: 50%;
    background: var(--surface-hover);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 24px;
    font-weight: 700;
    color: var(--accent);
    margin-bottom: 12px;
    overflow: hidden;
}

.profile-avatar-lg img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.profile-name {
    font-size: 17px;
    font-weight: 700;
}

.profile-handle {
    font-family: var(--font-mono);
    color: var(--text-faint);
    font-size: 13px;
    margin-bottom: 10px;
}

.profile-bio {
    font-size: 14px;
    color: var(--text-dim);
    margin-bottom: 12px;
    white-space: pre-wrap;
}

.profile-stats {
    display: flex;
    gap: 16px;
    font-size: 13px;
    color: var(--text-dim);
}

.profile-stats b {
    color: var(--text);
}

/* Empty / error states */

.empty-state {
    padding: 60px 20px;
    text-align: center;
    color: var(--text-faint);
}

/* Modal */

.modal {
    position: fixed;
    inset: 0;
    z-index: 100;
    display: flex;
    align-items: center;
    justify-content: center;
}

.modal-backdrop {
    position: absolute;
    inset: 0;
    background: rgba(0,0,0,0.6);
}

.modal-box {
    position: relative;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    width: 100%;
    max-width: 480px;
    margin: 16px;
    padding: 16px;
}

.modal-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 12px;
    font-weight: 600;
}

.modal-close {
    background: none;
    border: none;
    color: var(--text-dim);
    cursor: pointer;
    font-size: 16px;
}

/* Toast */

.toast {
    position: fixed;
    bottom: 24px;
    left: 50%;
    transform: translateX(-50%);
    background: var(--surface);
    border: 1px solid var(--border);
    color: var(--text);
    padding: 10px 16px;
    border-radius: var(--radius-md);
    font-size: 13px;
    z-index: 200;
    box-shadow: 0 8px 24px rgba(0,0,0,0.4);
}

.toast.error {
    border-color: var(--danger);
    color: var(--danger);
}
