/* ═══════════════════════════════════════
   MESHMARK APP STYLES
   ═══════════════════════════════════════ */

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

:root {
    --ink: #0a0a0a;
    --paper: #fafaf8;
    --node: #2563eb;
    --node-light: #dbeafe;
    --edge: #a5b4fc;
    --accent: #4f46e5;
    --muted: #6b7280;
    --muted-light: #9ca3af;
    --surface: #f1f0ec;
    --surface-hover: #e8e7e3;
    --border: #e5e5e0;
    --green: #10b981;
    --green-light: #d1fae5;
    --amber: #f59e0b;
    --amber-light: #fef3c7;
    --rose: #f43f5e;
    --rose-light: #ffe4e6;
    --purple: #8b5cf6;
    --purple-light: #ede9fe;
    --radius: 12px;
    --radius-sm: 8px;
    --shadow: 0 1px 3px rgba(0,0,0,0.06), 0 1px 2px rgba(0,0,0,0.04);
    --shadow-md: 0 4px 6px rgba(0,0,0,0.06), 0 2px 4px rgba(0,0,0,0.04);
    --transition: 0.15s ease;
}

body {
    font-family: 'DM Sans', -apple-system, sans-serif;
    background: var(--paper);
    color: var(--ink);
    line-height: 1.6;
    overflow-x: hidden;
}

/* ── LOGIN ─────────────────────────── */

#login-screen {
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    background: var(--paper);
}

.login-container {
    text-align: center;
    max-width: 380px;
    padding: 2rem;
}

.login-logo {
    font-family: 'Space Grotesk', sans-serif;
    font-weight: 700;
    font-size: 2rem;
    letter-spacing: -0.5px;
    margin-bottom: 0.5rem;
}
.login-logo span { color: var(--node); }

.login-tagline {
    color: var(--muted);
    font-size: 1.05rem;
    margin-bottom: 2.5rem;
}

.login-form {
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
}

.login-form input {
    padding: 0.85rem 1rem;
    border: 1.5px solid var(--border);
    border-radius: var(--radius-sm);
    font-size: 1rem;
    font-family: inherit;
    background: white;
    transition: border-color var(--transition);
    text-align: center;
}
.login-form input:focus {
    outline: none;
    border-color: var(--node);
}

.login-hint {
    margin-top: 1rem;
    font-size: 0.82rem;
    color: var(--muted-light);
}

/* ── BUTTONS ─────────────────────────── */

.btn {
    padding: 0.7rem 1.25rem;
    border-radius: var(--radius-sm);
    font-size: 0.9rem;
    font-weight: 600;
    font-family: 'Space Grotesk', sans-serif;
    cursor: pointer;
    border: none;
    transition: all var(--transition);
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
}

.btn-primary {
    background: var(--ink);
    color: white;
}
.btn-primary:hover { background: #1f1f1f; transform: translateY(-1px); }

.btn-secondary {
    background: var(--surface);
    color: var(--ink);
}
.btn-secondary:hover { background: var(--surface-hover); }

.btn-small {
    padding: 0.4rem 0.75rem;
    font-size: 0.8rem;
}

.btn-full { width: 100%; }

.btn-icon {
    padding: 0.5rem;
    border-radius: var(--radius-sm);
    background: transparent;
    border: none;
    cursor: pointer;
    color: var(--muted);
    transition: all var(--transition);
}
.btn-icon:hover { background: var(--surface); color: var(--ink); }

.btn-accent {
    background: var(--node);
    color: white;
}
.btn-accent:hover { background: #1d4ed8; }

/* ── LAYOUT ─────────────────────────── */

#main-app {
    display: flex;
    min-height: 100vh;
}

#sidebar {
    width: 220px;
    background: white;
    border-right: 1px solid var(--border);
    display: flex;
    flex-direction: column;
    padding: 1.25rem 0;
    position: fixed;
    top: 0;
    left: 0;
    bottom: 0;
    z-index: 10;
}

.sidebar-logo {
    font-family: 'Space Grotesk', sans-serif;
    font-weight: 700;
    font-size: 1.25rem;
    letter-spacing: -0.5px;
    padding: 0 1.25rem;
    margin-bottom: 1.5rem;
}
.sidebar-logo span { color: var(--node); }

.nav-links {
    flex: 1;
    display: flex;
    flex-direction: column;
    gap: 2px;
    padding: 0 0.625rem;
}

.nav-link {
    display: flex;
    align-items: center;
    gap: 0.65rem;
    padding: 0.6rem 0.75rem;
    border-radius: var(--radius-sm);
    text-decoration: none;
    color: var(--muted);
    font-size: 0.9rem;
    font-weight: 500;
    transition: all var(--transition);
}
.nav-link:hover { background: var(--surface); color: var(--ink); }
.nav-link.active { background: var(--surface); color: var(--ink); font-weight: 600; }
.nav-link svg { flex-shrink: 0; }

.sidebar-bottom {
    padding: 0 0.625rem;
    border-top: 1px solid var(--border);
    padding-top: 0.75rem;
    margin-top: 0.5rem;
}

#content {
    flex: 1;
    margin-left: 220px;
    padding: 2rem;
    max-width: 1100px;
}

/* ── PAGE HEADER ──────────────────── */

.page-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 1.75rem;
}

.page-header h1 {
    font-family: 'Space Grotesk', sans-serif;
    font-size: 1.5rem;
    font-weight: 700;
    letter-spacing: -0.5px;
}

.page-header-actions {
    display: flex;
    gap: 0.5rem;
}

/* ── STAT CARDS ──────────────────── */

.stats-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
    gap: 1rem;
    margin-bottom: 2rem;
}

.stat-card {
    background: white;
    border-radius: var(--radius);
    padding: 1.25rem;
    border: 1px solid var(--border);
}

.stat-card .stat-label {
    font-size: 0.78rem;
    color: var(--muted);
    text-transform: uppercase;
    letter-spacing: 0.5px;
    margin-bottom: 0.35rem;
}

.stat-card .stat-value {
    font-family: 'Space Grotesk', sans-serif;
    font-size: 1.75rem;
    font-weight: 700;
    letter-spacing: -0.5px;
}

.stat-card .stat-value.blue { color: var(--node); }
.stat-card .stat-value.green { color: var(--green); }
.stat-card .stat-value.purple { color: var(--purple); }
.stat-card .stat-value.amber { color: var(--amber); }

/* ── BOOKMARK CARDS ──────────────── */

.bookmark-list {
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
}

.bookmark-card {
    background: white;
    border-radius: var(--radius);
    padding: 1.25rem;
    border: 1px solid var(--border);
    transition: border-color var(--transition), box-shadow var(--transition);
}
.bookmark-card:hover {
    border-color: var(--edge);
    box-shadow: var(--shadow);
}

.bookmark-author {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    margin-bottom: 0.5rem;
}

.bookmark-author-name {
    font-weight: 600;
    font-size: 0.88rem;
}

.bookmark-author-handle {
    color: var(--node);
    font-size: 0.82rem;
}

.bookmark-content {
    font-size: 0.95rem;
    line-height: 1.65;
    color: var(--ink);
    margin-bottom: 0.75rem;
}

.bookmark-meta {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 0.5rem;
    flex-wrap: wrap;
}

.bookmark-tags {
    display: flex;
    gap: 0.35rem;
    flex-wrap: wrap;
}

.tag {
    font-size: 0.72rem;
    padding: 0.15rem 0.55rem;
    border-radius: 20px;
    background: var(--node-light);
    color: var(--node);
    font-weight: 500;
}

.tag.topic { background: var(--node-light); color: var(--node); }
.tag.person { background: var(--purple-light); color: var(--purple); }
.tag.company { background: var(--amber-light); color: var(--amber); }
.tag.concept { background: var(--green-light); color: var(--green); }
.tag.technology { background: var(--rose-light); color: var(--rose); }

.bookmark-date {
    font-size: 0.78rem;
    color: var(--muted-light);
    white-space: nowrap;
}

.bookmark-actions {
    display: flex;
    gap: 0.25rem;
    margin-top: 0.5rem;
    padding-top: 0.5rem;
    border-top: 1px solid var(--border);
}

.bookmark-actions .btn-small {
    font-family: 'DM Sans', sans-serif;
    font-weight: 500;
}

/* ── SEARCH ──────────────────────── */

.search-container {
    position: relative;
    margin-bottom: 1.5rem;
}

.search-input {
    width: 100%;
    padding: 0.85rem 1rem 0.85rem 2.75rem;
    border: 1.5px solid var(--border);
    border-radius: var(--radius);
    font-size: 0.95rem;
    font-family: inherit;
    background: white;
    transition: border-color var(--transition), box-shadow var(--transition);
}
.search-input:focus {
    outline: none;
    border-color: var(--node);
    box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.1);
}

.search-icon {
    position: absolute;
    left: 0.9rem;
    top: 50%;
    transform: translateY(-50%);
    color: var(--muted-light);
}

.search-hint {
    font-size: 0.82rem;
    color: var(--muted-light);
    margin-top: 0.5rem;
}

.search-result-type {
    display: inline-block;
    font-size: 0.68rem;
    padding: 0.1rem 0.4rem;
    border-radius: 4px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}
.search-result-type.semantic { background: var(--purple-light); color: var(--purple); }
.search-result-type.keyword { background: var(--amber-light); color: var(--amber); }

/* ── TASK CARDS ──────────────────── */

.task-filters {
    display: flex;
    gap: 0.5rem;
    margin-bottom: 1.25rem;
    flex-wrap: wrap;
}

.filter-chip {
    padding: 0.35rem 0.85rem;
    border-radius: 20px;
    font-size: 0.82rem;
    font-weight: 500;
    background: var(--surface);
    color: var(--muted);
    border: none;
    cursor: pointer;
    transition: all var(--transition);
}
.filter-chip:hover { background: var(--surface-hover); color: var(--ink); }
.filter-chip.active { background: var(--ink); color: white; }

.task-card {
    background: white;
    border-radius: var(--radius);
    padding: 1rem 1.25rem;
    border: 1px solid var(--border);
    display: flex;
    align-items: flex-start;
    gap: 0.75rem;
    transition: all var(--transition);
}
.task-card:hover { border-color: var(--edge); }

.task-checkbox {
    width: 20px;
    height: 20px;
    border-radius: 50%;
    border: 2px solid var(--border);
    cursor: pointer;
    flex-shrink: 0;
    margin-top: 2px;
    transition: all var(--transition);
    display: flex;
    align-items: center;
    justify-content: center;
}
.task-checkbox:hover { border-color: var(--green); }
.task-checkbox.done {
    background: var(--green);
    border-color: var(--green);
}
.task-checkbox.done::after {
    content: '';
    width: 6px;
    height: 6px;
    background: white;
    border-radius: 50%;
}

.task-body { flex: 1; }

.task-action-badge {
    display: inline-block;
    font-size: 0.72rem;
    padding: 0.15rem 0.5rem;
    border-radius: 4px;
    font-weight: 600;
    margin-bottom: 0.35rem;
}
.task-action-badge.read_later { background: var(--node-light); color: var(--node); }
.task-action-badge.share { background: var(--purple-light); color: var(--purple); }
.task-action-badge.act_on { background: var(--rose-light); color: var(--rose); }
.task-action-badge.come_back { background: var(--amber-light); color: var(--amber); }

.task-bookmark-preview {
    font-size: 0.88rem;
    color: var(--muted);
    line-height: 1.5;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
}

.task-done .task-bookmark-preview { text-decoration: line-through; opacity: 0.5; }
.task-done .task-action-badge { opacity: 0.5; }

.task-note {
    font-size: 0.82rem;
    color: var(--muted-light);
    margin-top: 0.25rem;
    font-style: italic;
}

.task-delete {
    opacity: 0;
    transition: opacity var(--transition);
}
.task-card:hover .task-delete { opacity: 1; }

/* ── GRAPH ───────────────────────── */

.graph-wrapper {
    background: white;
    border-radius: var(--radius);
    border: 1px solid var(--border);
    overflow: hidden;
    position: relative;
}

.graph-svg {
    width: 100%;
    height: 600px;
    display: block;
}

.graph-controls {
    position: absolute;
    top: 1rem;
    right: 1rem;
    display: flex;
    gap: 0.35rem;
}

.graph-node-label {
    font-family: 'Space Grotesk', sans-serif;
    font-size: 11px;
    fill: var(--ink);
    font-weight: 500;
    pointer-events: none;
}

.graph-tooltip {
    position: absolute;
    background: var(--ink);
    color: white;
    padding: 0.5rem 0.75rem;
    border-radius: var(--radius-sm);
    font-size: 0.82rem;
    pointer-events: none;
    opacity: 0;
    transition: opacity var(--transition);
    z-index: 100;
    max-width: 250px;
}
.graph-tooltip.visible { opacity: 1; }

.graph-legend {
    display: flex;
    gap: 1rem;
    padding: 0.75rem 1rem;
    border-top: 1px solid var(--border);
    flex-wrap: wrap;
}

.legend-item {
    display: flex;
    align-items: center;
    gap: 0.35rem;
    font-size: 0.78rem;
    color: var(--muted);
}

.legend-dot {
    width: 10px;
    height: 10px;
    border-radius: 50%;
}

/* ── MODALS ──────────────────────── */

.modal {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    z-index: 1000;
    display: flex;
    align-items: center;
    justify-content: center;
}

.modal-overlay {
    position: absolute;
    inset: 0;
    background: rgba(0,0,0,0.4);
    backdrop-filter: blur(2px);
}

.modal-content {
    position: relative;
    background: white;
    border-radius: var(--radius);
    padding: 1.5rem;
    max-width: 480px;
    width: 90%;
    max-height: 90vh;
    overflow-y: auto;
    box-shadow: var(--shadow-md);
}

.modal-large { max-width: 600px; }

.modal-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 1.25rem;
}

.modal-header h3 {
    font-family: 'Space Grotesk', sans-serif;
    font-size: 1.15rem;
    font-weight: 700;
}

.modal-close {
    background: none;
    border: none;
    font-size: 1.5rem;
    cursor: pointer;
    color: var(--muted);
    line-height: 1;
    padding: 0.25rem;
}
.modal-close:hover { color: var(--ink); }

.modal-actions {
    display: flex;
    justify-content: flex-end;
    gap: 0.5rem;
    margin-top: 1.25rem;
}

/* ── FORMS ───────────────────────── */

.form-group {
    margin-bottom: 1rem;
}

.form-group label {
    display: block;
    font-size: 0.85rem;
    font-weight: 600;
    margin-bottom: 0.35rem;
    color: var(--ink);
}

.form-group input,
.form-group textarea,
.form-group select {
    width: 100%;
    padding: 0.65rem 0.85rem;
    border: 1.5px solid var(--border);
    border-radius: var(--radius-sm);
    font-size: 0.9rem;
    font-family: inherit;
    background: white;
    transition: border-color var(--transition);
    resize: vertical;
}
.form-group input:focus,
.form-group textarea:focus {
    outline: none;
    border-color: var(--node);
}

.form-row {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 0.75rem;
}

.form-hint {
    font-size: 0.8rem;
    color: var(--muted-light);
    margin-bottom: 0.5rem;
}

.required { color: var(--rose); }

.action-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 0.5rem;
}

.action-option {
    cursor: pointer;
}
.action-option input { display: none; }
.action-chip {
    display: block;
    padding: 0.6rem;
    text-align: center;
    border: 1.5px solid var(--border);
    border-radius: var(--radius-sm);
    font-size: 0.85rem;
    font-weight: 500;
    transition: all var(--transition);
}
.action-option input:checked + .action-chip {
    border-color: var(--node);
    background: var(--node-light);
    color: var(--node);
}

/* ── EMPTY STATE ─────────────────── */

.empty-state {
    text-align: center;
    padding: 4rem 2rem;
    color: var(--muted);
}

.empty-state svg {
    width: 48px;
    height: 48px;
    margin-bottom: 1rem;
    color: var(--muted-light);
}

.empty-state h3 {
    font-family: 'Space Grotesk', sans-serif;
    font-size: 1.1rem;
    color: var(--ink);
    margin-bottom: 0.35rem;
}

.empty-state p {
    font-size: 0.9rem;
    max-width: 360px;
    margin: 0 auto 1.25rem;
}

/* ── SECTION TITLES ──────────────── */

.section-title {
    font-family: 'Space Grotesk', sans-serif;
    font-size: 1rem;
    font-weight: 600;
    color: var(--ink);
    margin-bottom: 0.75rem;
    letter-spacing: -0.3px;
}

/* ── LOADING ─────────────────────── */

.spinner {
    display: inline-block;
    width: 20px;
    height: 20px;
    border: 2px solid var(--border);
    border-top-color: var(--node);
    border-radius: 50%;
    animation: spin 0.6s linear infinite;
}

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

.loading-overlay {
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 3rem;
    color: var(--muted);
    gap: 0.75rem;
}

/* ── TOAST ───────────────────────── */

.toast {
    position: fixed;
    bottom: 1.5rem;
    right: 1.5rem;
    background: var(--ink);
    color: white;
    padding: 0.75rem 1.25rem;
    border-radius: var(--radius-sm);
    font-size: 0.88rem;
    z-index: 2000;
    animation: slideUp 0.3s ease, fadeOut 0.3s ease 2.5s forwards;
    box-shadow: var(--shadow-md);
}

.toast.error { background: var(--rose); }
.toast.success { background: var(--green); }

@keyframes slideUp {
    from { transform: translateY(20px); opacity: 0; }
    to { transform: translateY(0); opacity: 1; }
}
@keyframes fadeOut {
    to { opacity: 0; transform: translateY(-10px); }
}

/* ── ENTITY LIST ─────────────────── */

.entity-list {
    display: flex;
    flex-wrap: wrap;
    gap: 0.35rem;
    margin-bottom: 1rem;
}

/* ── RESPONSIVE ──────────────────── */

@media (max-width: 768px) {
    #sidebar {
        position: fixed;
        bottom: 0;
        left: 0;
        right: 0;
        top: auto;
        width: 100%;
        height: auto;
        flex-direction: row;
        border-right: none;
        border-top: 1px solid var(--border);
        padding: 0;
        z-index: 100;
        background: white;
    }

    .sidebar-logo, .sidebar-bottom { display: none; }

    .nav-links {
        flex-direction: row;
        justify-content: space-around;
        padding: 0.5rem;
        width: 100%;
    }

    .nav-link {
        flex-direction: column;
        gap: 0.15rem;
        padding: 0.4rem;
        font-size: 0.68rem;
    }

    #content {
        margin-left: 0;
        padding: 1.25rem;
        padding-bottom: 5rem;
    }

    .stats-grid {
        grid-template-columns: repeat(2, 1fr);
    }

    .form-row {
        grid-template-columns: 1fr;
    }

    .graph-svg {
        height: 400px;
    }

    .page-header {
        flex-direction: column;
        align-items: flex-start;
        gap: 0.75rem;
    }
}
