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

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
    background: #f1f5f9;
    color: #1e293b;
    min-height: 100vh;
}

/* NAV */
.topnav {
    background: #1e40af;
    color: #fff;
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 1.5rem;
    height: 56px;
    position: sticky;
    top: 0;
    z-index: 100;
    box-shadow: 0 1px 4px rgba(0,0,0,.2);
}
.nav-brand {
    font-weight: 700;
    font-size: 1.1rem;
    color: #fff;
    text-decoration: none;
}
.nav-right { display: flex; align-items: center; gap: .75rem; }
.nav-user { font-size: .875rem; opacity: .8; }

/* CONTAINER */
.container { max-width: 900px; margin: 0 auto; padding: 2rem 1.5rem; }

/* PAGE HEADER */
.page-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 1.5rem;
}
.page-header h2 { font-size: 1.5rem; font-weight: 700; }

/* BREADCRUMB */
.breadcrumb { font-size: .875rem; color: #64748b; margin-bottom: 1rem; }
.breadcrumb a { color: #3b82f6; text-decoration: none; }
.breadcrumb a:hover { text-decoration: underline; }

/* BUTTONS */
.btn {
    display: inline-flex;
    align-items: center;
    gap: .375rem;
    padding: .5rem 1rem;
    border-radius: 6px;
    font-size: .875rem;
    font-weight: 500;
    border: none;
    cursor: pointer;
    text-decoration: none;
    transition: background .15s;
}
.btn-primary  { background: #2563eb; color: #fff; }
.btn-primary:hover { background: #1d4ed8; }
.btn-ghost    { background: transparent; color: #fff; border: 1px solid rgba(255,255,255,.4); }
.btn-ghost:hover { background: rgba(255,255,255,.1); }
.btn-sm       { padding: .3rem .7rem; font-size: .8rem; }
.btn-danger   { background: #fee2e2; color: #dc2626; }
.btn-danger:hover { background: #fecaca; }

/* ALERTS */
.alert {
    padding: .75rem 1rem;
    border-radius: 6px;
    margin-bottom: 1.25rem;
    font-size: .9rem;
}
.alert-error   { background: #fee2e2; color: #dc2626; border: 1px solid #fecaca; }
.alert-success { background: #dcfce7; color: #16a34a; border: 1px solid #bbf7d0; }

/* AUTH PAGE */
.auth-page { display: flex; align-items: center; justify-content: center; background: #f1f5f9; }
.auth-card {
    background: #fff;
    border-radius: 12px;
    padding: 2.5rem;
    width: 100%;
    max-width: 400px;
    box-shadow: 0 4px 20px rgba(0,0,0,.08);
    margin: 2rem 1rem;
}
.auth-card h1 { font-size: 1.6rem; font-weight: 700; color: #1e40af; margin-bottom: .25rem; }
.subtitle { color: #64748b; font-size: .9rem; margin-bottom: 1.5rem; }
.auth-card label { display: block; font-size: .85rem; font-weight: 500; color: #374151; margin-bottom: .35rem; margin-top: 1rem; }
.auth-card input[type=text],
.auth-card input[type=password] {
    width: 100%;
    padding: .6rem .85rem;
    border: 1px solid #cbd5e1;
    border-radius: 6px;
    font-size: .95rem;
    transition: border .15s;
}
.auth-card input:focus { outline: none; border-color: #3b82f6; box-shadow: 0 0 0 3px rgba(59,130,246,.15); }
.auth-card button[type=submit] {
    margin-top: 1.5rem;
    width: 100%;
    padding: .7rem;
    background: #2563eb;
    color: #fff;
    border: none;
    border-radius: 6px;
    font-size: 1rem;
    font-weight: 600;
    cursor: pointer;
    transition: background .15s;
}
.auth-card button[type=submit]:hover { background: #1d4ed8; }

/* PROJECT GRID */
.project-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); gap: 1rem; }
.project-card {
    background: #fff;
    border-radius: 10px;
    border: 1px solid #e2e8f0;
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: .75rem 1rem;
    box-shadow: 0 1px 3px rgba(0,0,0,.05);
    transition: box-shadow .15s;
}
.project-card:hover { box-shadow: 0 4px 12px rgba(0,0,0,.08); }
.project-link { display: flex; align-items: center; gap: .75rem; text-decoration: none; color: inherit; flex: 1; }
.project-icon { font-size: 1.5rem; }
.project-name { font-weight: 600; font-size: .95rem; }
.project-meta { font-size: .8rem; color: #64748b; margin-top: .1rem; }
.btn-delete { background: none; border: none; cursor: pointer; font-size: 1rem; opacity: .5; padding: .25rem; transition: opacity .15s; }
.btn-delete:hover { opacity: 1; }

/* UPLOAD ZONE */
.upload-zone {
    border: 2px dashed #93c5fd;
    border-radius: 10px;
    background: #eff6ff;
    text-align: center;
    padding: 1rem;
    margin-bottom: 1rem;
    cursor: pointer;
    transition: background .15s, border-color .15s;
}
.upload-zone:hover, .upload-zone.drag-over { background: #dbeafe; border-color: #3b82f6; }
.upload-label { display: flex; flex-direction: column; align-items: center; gap: .25rem; cursor: pointer; }
.upload-icon { font-size: 1.4rem; }
.upload-hint { font-size: .75rem; color: #64748b; }

/* FILE TABLE */
.file-table { width: 100%; border-collapse: collapse; background: #fff; border-radius: 10px; overflow: hidden; box-shadow: 0 1px 3px rgba(0,0,0,.05); }
.file-table th { background: #f8fafc; font-size: .8rem; font-weight: 600; text-transform: uppercase; letter-spacing: .05em; color: #64748b; padding: .75rem 1rem; text-align: left; }
.file-table td { padding: .75rem 1rem; border-top: 1px solid #f1f5f9; font-size: .9rem; }
.file-table tr:hover td { background: #f8fafc; }
.file-name { font-weight: 500; vertical-align: middle; }
.file-thumb { width: 48px; height: 48px; object-fit: cover; border-radius: 4px; vertical-align: middle; margin-right: .5rem; border: 1px solid #e2e8f0; }
.fname-label { vertical-align: middle; }
.rename-form { display: inline-flex; align-items: center; gap: .3rem; vertical-align: middle; }
.rename-input { padding: .25rem .5rem; border: 1px solid #93c5fd; border-radius: 4px; font-size: .85rem; width: 140px; }
.file-size, .file-date { color: #64748b; white-space: nowrap; }
.file-actions { text-align: right; white-space: nowrap; display: flex; gap: .5rem; justify-content: flex-end; }

/* EMPTY STATE */
.empty-state { text-align: center; padding: 3rem; color: #94a3b8; }

/* PROJECT TWO-COLUMN LAYOUT */
.project-layout {
    display: flex;
    gap: 1.5rem;
    align-items: flex-start;
    max-width: 1400px;
    margin: 0 auto;
    padding: 2rem 1.5rem;
}
.project-main { flex: 1; min-width: 0; }

/* NOTES PANEL */
.notes-panel {
    flex: 1;
    min-width: 0;
    background: #fff;
    border-radius: 10px;
    border: 1px solid #e2e8f0;
    box-shadow: 0 1px 3px rgba(0,0,0,.05);
    display: flex;
    flex-direction: column;
    position: sticky;
    top: 72px;
    max-height: calc(100vh - 90px);
}
.notes-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: .85rem 1rem;
    border-bottom: 1px solid #f1f5f9;
    background: #f8fafc;
    border-radius: 10px 10px 0 0;
}
.notes-title { font-weight: 600; font-size: .9rem; color: #1e293b; }
.notes-header-right { display: flex; align-items: center; gap: .6rem; }
.notes-status { font-size: .75rem; }
.notes-status.saving { color: #94a3b8; }
.notes-status.saved  { color: #16a34a; }
.notes-status.error  { color: #dc2626; }
.presence-active { font-size: .75rem; color: #2563eb; background: #eff6ff; border-radius: 999px; padding: .1rem .5rem; }
.notes-area {
    flex: 1;
    width: 100%;
    min-height: calc(100vh - 180px);
    padding: 1rem;
    border: none;
    border-radius: 0 0 10px 10px;
    resize: none;
    font-family: inherit;
    font-size: .9rem;
    line-height: 1.6;
    color: #1e293b;
    background: #fff;
    outline: none;
}
.notes-area:focus { background: #fefefe; }

@media (max-width: 800px) {
    .project-layout { flex-direction: column; }
    .project-main { width: 100%; }
    .notes-panel { width: 100%; position: static; max-height: 400px; }
}

/* LIGHTBOX */
.lightbox-overlay {
    position: fixed; inset: 0;
    background: rgba(0,0,0,.85);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 300;
    padding: 1rem;
}
.lightbox-box {
    background: #1e293b;
    border-radius: 12px;
    display: flex;
    flex-direction: column;
    align-items: center;
    max-width: 90vw;
    max-height: 90vh;
    overflow: hidden;
    box-shadow: 0 25px 80px rgba(0,0,0,.6);
}
.lightbox-toolbar {
    width: 100%;
    display: flex;
    align-items: center;
    gap: .75rem;
    padding: .75rem 1rem;
    background: #0f172a;
    border-radius: 12px 12px 0 0;
}
.lightbox-fname { color: #94a3b8; font-size: .875rem; flex: 1; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.lightbox-img {
    max-width: 85vw;
    max-height: calc(90vh - 140px);
    object-fit: contain;
    display: block;
}
.lightbox-rename {
    width: 100%;
    padding: .75rem 1rem;
    background: #0f172a;
    border-top: 1px solid #1e293b;
    border-radius: 0 0 12px 12px;
}
.lightbox-rename form { display: flex; align-items: center; gap: .5rem; flex-wrap: wrap; }
.lightbox-rename-label { color: #94a3b8; font-size: .85rem; white-space: nowrap; }

/* MODAL */
.modal-overlay {
    position: fixed; inset: 0;
    background: rgba(0,0,0,.4);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 200;
}
.modal {
    background: #fff;
    border-radius: 12px;
    padding: 2rem;
    width: 100%;
    max-width: 420px;
    box-shadow: 0 20px 60px rgba(0,0,0,.2);
    margin: 1rem;
}
.modal h3 { font-size: 1.2rem; font-weight: 700; margin-bottom: 1.25rem; }
.modal label { display: block; font-size: .85rem; font-weight: 500; color: #374151; margin-bottom: .4rem; }
.modal input[type=text] {
    width: 100%;
    padding: .6rem .85rem;
    border: 1px solid #cbd5e1;
    border-radius: 6px;
    font-size: .95rem;
}
.modal input:focus { outline: none; border-color: #3b82f6; box-shadow: 0 0 0 3px rgba(59,130,246,.15); }
.modal-actions { display: flex; gap: .75rem; justify-content: flex-end; margin-top: 1.25rem; }
.modal-actions .btn-ghost { color: #374151; border-color: #cbd5e1; }
