:root {
    --accent: #2563eb;
    --text: #0f172a;
    --muted: #475569;
    --bg: #f8fafc;
    --card: #ffffff;
}

* { box-sizing: border-box; }
body {
    font-family: Arial, sans-serif;
    margin: 0;
    color: var(--text);
    background: var(--bg);
}

.navbar {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 1rem 2rem;
    background: var(--card);
    border-bottom: 1px solid #e2e8f0;
    position: sticky;
    top: 0;
}

.brand a {
    display: inline-flex;
    align-items: center;
    gap: 0.6rem;
    font-weight: bold;
    color: var(--text);
    text-decoration: none;
}

.brand-logo {
    height: 42px;
    width: auto;
}

nav a {
    margin-left: 1rem;
    text-decoration: none;
    color: var(--muted);
}

nav a.button {
    padding: 0.45rem 0.8rem;
    border-radius: 0.4rem;
    border: 1px solid var(--accent);
    color: var(--accent);
}

.nav-actions {
    display: inline-flex;
    align-items: center;
    gap: 0.75rem;
}

.icon-button {
    position: relative;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 38px;
    height: 38px;
    border-radius: 50%;
    background: #f1f5f9;
    text-decoration: none;
    color: var(--text);
    border: 1px solid #e2e8f0;
}

.badge {
    position: absolute;
    top: -6px;
    right: -6px;
    background: #ef4444;
    color: white;
    font-size: 0.7rem;
    padding: 2px 6px;
    border-radius: 999px;
    line-height: 1;
}

nav a.button.primary, button.button.primary, .button.primary {
    background: var(--accent);
    color: white;
    border: 1px solid var(--accent);
}

main { padding: 2rem; }

.hero { text-align: center; margin-bottom: 2rem; }
.hero-actions {
    display: flex;
    justify-content: center;
    gap: 0.75rem;
    flex-wrap: wrap;
    margin-top: 1rem;
}
.columns { display: grid; grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); gap: 1rem; }
.columns div { background: var(--card); padding: 1rem; border-radius: 0.5rem; box-shadow: 0 1px 2px rgba(0,0,0,0.05); }
.split-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(320px, 1fr)); gap: 1.5rem; }
.split-grid .card { height: 100%; display: flex; flex-direction: column; gap: 1rem; }
.split-grid .stack { gap: 0.25rem; }
.dashboard-grid {
    display: grid;
    grid-template-columns: 2fr 1.2fr;
    gap: 1.5rem;
    align-items: start;
}

.dashboard-column {
    display: flex;
    flex-direction: column;
    gap: 1.25rem;
}

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

.form { display: grid; gap: 1rem; max-width: 420px; }
.form.wide { max-width: none; width: 100%; }
.form label { display: grid; gap: 0.35rem; color: var(--muted); }
.form .label-row { display: inline-flex; align-items: center; gap: 0.35rem; color: var(--text); }
.form .info-icon { display: inline-flex; align-items: center; justify-content: center; width: 1.1rem; height: 1.1rem; border-radius: 999px; background: #e2e8f0; color: #475569; font-size: 0.75rem; cursor: help; }
.form input, .form textarea { padding: 0.6rem; border: 1px solid #cbd5e1; border-radius: 0.4rem; width: 100%; }
.form button { padding: 0.6rem 1rem; border: none; cursor: pointer; border-radius: 0.4rem; }

.stack { display: flex; flex-direction: column; gap: 1rem; }
.stack.gap-sm { gap: 0.5rem; }
.stack.gap-lg { gap: 1.5rem; }

.project-form .field-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(260px, 1fr));
    gap: 1rem;
}

.project-form {
    max-width: none;
    width: 100%;
}

.project-form .field-grid label {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
    color: var(--muted);
}

.lab-form { width: 100%; }
.lab-form .field-grid { display: grid; grid-template-columns: 1fr; gap: 1rem; }
.lab-form label { display: flex; flex-direction: column; gap: 0.5rem; color: var(--muted); }
.lab-form textarea { width: 100%; padding: 0.85rem; font-size: 1rem; border: 1px solid #cbd5e1; border-radius: 0.5rem; }
.lab-form textarea:focus { outline: 2px solid #bfdbfe; }
.wiki-form { max-width: none; width: 100%; }
.markdown-editor { display: flex; flex-direction: column; gap: 0.35rem; }
.editor-header { display: flex; align-items: center; justify-content: space-between; gap: 0.75rem; }
.editor-toolbar { display: inline-flex; align-items: center; gap: 0.35rem; flex-wrap: wrap; }
.editor-toolbar button { border: 1px solid #cbd5e1; background: #fff; padding: 0.3rem 0.45rem; border-radius: 0.35rem; cursor: pointer; color: var(--text); font-size: 0.95rem; }
.editor-toolbar button:hover, .editor-toolbar button:focus { background: #eff6ff; border-color: #bfdbfe; outline: none; }

.editor-body {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 1rem;
    align-items: stretch;
}

.editor-pane {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
}

.markdown-editor textarea {
    height: 100%;
    min-height: 220px;
}

.markdown-preview {
    background: #f8fafc;
    border: 1px solid #e2e8f0;
    border-radius: 0.6rem;
    padding: 0.75rem;
    display: flex;
    flex-direction: column;
    gap: 0.4rem;
}

.markdown-preview .preview-header {
    font-size: 0.9rem;
    color: var(--muted);
    font-weight: 600;
}

.markdown-preview .preview-content {
    flex: 1;
    min-height: 160px;
}

@media (max-width: 900px) {
    .editor-body {
        grid-template-columns: 1fr;
    }
}

.wide-input textarea,
.wide-input input {
    width: 100%;
}

.field-label {
    display: block;
    margin-bottom: 0.35rem;
    color: var(--muted);
    font-weight: 600;
}

.profile-message-form textarea {
    width: 100%;
}

.full-width {
    width: 100%;
}

.flash-messages { list-style: none; padding: 0 2rem; }
.flash-messages li { margin: 0.4rem 0; padding: 0.75rem 1rem; border-radius: 0.4rem; }
.flash-messages .success { background: #ecfdf3; color: #166534; }
.flash-messages .info { background: #eff6ff; color: #1d4ed8; }
.like-bar {
    display: flex;
    gap: 0.75rem;
    align-items: center;
    flex-wrap: wrap;
}
.like-details summary {
    cursor: pointer;
    font-weight: 600;
    color: var(--muted);
}
.like-details summary::-webkit-details-marker {
    display: none;
}
.like-details summary::before {
    content: "❤ ";
    color: #ef4444;
}
.like-details {
    background: #f8fafc;
    border: 1px solid #e2e8f0;
    padding: 0.35rem 0.6rem;
    border-radius: 0.5rem;
}
.thumb-button {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 2.4rem;
    height: 2.4rem;
    border-radius: 999px;
    border: 2px solid #cbd5e1;
    background: transparent;
    color: #1d4ed8;
    font-size: 1.1rem;
    transition: background 0.15s ease, color 0.15s ease, border-color 0.15s ease;
    cursor: pointer;
}
.thumb-button:hover {
    border-color: #1d4ed8;
}
.thumb-button.filled {
    background: #1d4ed8;
    color: #fff;
    border-color: #1d4ed8;
}
.thumb-button:focus {
    outline: 3px solid #bfdbfe;
    outline-offset: 2px;
}
.thumb-icon {
    line-height: 1;
}
.flash-messages .warning { background: #fff7ed; color: #9a3412; }
.flash-messages .danger { background: #fef2f2; color: #b91c1c; }

footer { text-align: center; padding: 1.5rem; color: var(--muted); }

.user-menu {
    position: relative;
    display: inline-block;
}

.avatar {
    width: 36px;
    height: 36px;
    border-radius: 50%;
    background: var(--accent);
    color: white;
    display: grid;
    place-items: center;
    cursor: default;
    font-weight: bold;
    overflow: hidden;
}

.avatar img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    border-radius: 50%;
    display: block;
}

.avatar.has-image {
    background: transparent;
    border: 1px solid #e2e8f0;
}

.avatar-small {
    width: 32px;
    height: 32px;
    font-size: 0.9rem;
}

.avatar-large {
    width: 64px;
    height: 64px;
    font-size: 1.5rem;
}

.user-menu .avatar {
    cursor: pointer;
}

.user-menu .menu {
    position: absolute;
    right: 0;
    top: 100%;
    background: var(--card);
    border: 1px solid #e2e8f0;
    border-radius: 0.4rem;
    display: none;
    min-width: 150px;
    box-shadow: 0 4px 10px rgba(0,0,0,0.05);
}

.user-menu:hover .menu { display: block; }
.user-menu .menu a { display: block; padding: 0.75rem 1rem; color: var(--text); text-decoration: none; }
.user-menu .menu a:hover { background: #f1f5f9; }

.user-menu .menu.friend-menu {
    width: 320px;
    padding: 0.75rem;
    display: none;
}

.user-menu:hover .menu.friend-menu {
    display: block;
}

.menu-item {
    padding: 0.5rem 0.25rem;
    border-bottom: 1px solid #e2e8f0;
}

.menu-item:last-child {
    border-bottom: none;
}

.menu-actions {
    display: flex;
    gap: 0.5rem;
    flex-wrap: wrap;
    margin-top: 0.35rem;
}

.activity-item .activity-meta {
    display: flex;
    gap: 0.75rem;
    align-items: center;
}

.activity-item .avatar {
    flex-shrink: 0;
}

.profile-header {
    display: grid;
    grid-template-columns: auto 1fr auto;
    gap: 1rem;
    align-items: center;
}

.profile-grid {
    display: grid;
    gap: 1rem;
    grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
}

.avatar-preview {
    display: flex;
    align-items: flex-start;
    gap: 0.75rem;
}

.avatar-preview-copy {
    display: flex;
    flex-direction: column;
    gap: 0.35rem;
}

.settings-form {
    gap: 1rem;
}

.settings-form .card {
    width: 100%;
}

.settings-form .field-label {
    display: flex;
    flex-direction: column;
    gap: 0.35rem;
    width: 100%;
}

.settings-form input[type="text"],
.settings-form input[type="file"],
.settings-form textarea {
    width: 100%;
    max-width: 100%;
}

.settings-form textarea {
    min-height: 160px;
}

.button.small {
    padding: 0.35rem 0.6rem;
    font-size: 0.9rem;
}

.page-header {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 1rem;
    margin-bottom: 1.5rem;
}

.eyebrow {
    text-transform: uppercase;
    letter-spacing: 0.05em;
    font-size: 0.8rem;
    color: var(--muted);
    margin: 0;
}

.muted { color: var(--muted); }
.meta { color: var(--muted); font-size: 0.95rem; }

.card {
    background: var(--card);
    border: 1px solid #e2e8f0;
    padding: 1.25rem;
    border-radius: 0.75rem;
    box-shadow: 0 2px 6px rgba(0,0,0,0.04);
    margin-bottom: 1.25rem;
}

.message-card .message-header {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 1rem;
}

.message-card .markdown {
    margin: 0.5rem 0 1rem;
}

.reply-form textarea {
    width: 100%;
}

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

.muted-card {
    background: #f8fafc;
}

.pill {
    display: inline-block;
    padding: 0.2rem 0.75rem;
    border-radius: 999px;
    background: #eef2ff;
    color: #3730a3;
    font-size: 0.9rem;
}

.muted-pill {
    background: #e2e8f0;
    color: #475569;
}

.projects-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(260px, 1fr));
    gap: 1rem;
}

.project-card .card-header {
    display: flex;
    justify-content: space-between;
    gap: 0.75rem;
}

.project-card h3 { margin: 0; }
.project-card p { margin: 0.35rem 0; }

.search-form {
    display: flex;
    gap: 0.5rem;
}

.pagination {
    display: flex;
    gap: 0.5rem;
    margin-top: 1rem;
}

.form.two-column {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(260px, 1fr));
    gap: 1rem;
    max-width: none;
    width: 100%;
}

.form.two-column .full { grid-column: 1 / -1; }

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

.actions.stack { flex-direction: column; align-items: flex-end; }

.tab-links {
    display: inline-flex;
    gap: 0.5rem;
    margin-bottom: 0.75rem;
}

.tab-link {
    padding: 0.45rem 0.85rem;
    border: 1px solid #e2e8f0;
    background: #fff;
    border-radius: 999px;
    color: var(--muted);
    cursor: pointer;
}

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

.tab-panel { display: none; }
.tab-panel.active { display: block; }

.pill {
    display: inline-flex;
    align-items: center;
    padding: 0.15rem 0.55rem;
    border-radius: 999px;
    background: #e0f2fe;
    color: #0ea5e9;
    font-size: 0.85rem;
    font-weight: 700;
}

.pagination {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-top: 0.75rem;
    gap: 1rem;
    flex-wrap: wrap;
}

.pagination .page-info {
    color: var(--muted);
}

.pagination .page-controls {
    display: inline-flex;
    gap: 0.5rem;
}

.table-wrapper { overflow-x: auto; }

table.table {
    width: 100%;
    border-collapse: collapse;
}

table.table th, table.table td {
    padding: 0.75rem;
    border-bottom: 1px solid #e2e8f0;
    text-align: left;
}

table.table th { color: var(--muted); }

table.table tr.unread td {
    font-weight: 700;
}

.message-detail .message-meta {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(160px, 1fr));
    gap: 1rem;
    margin-bottom: 1rem;
}

.message-detail .message-meta p {
    margin: 0;
}

.button.danger { background: #dc2626; color: #fff; border-color: #dc2626; }

.markdown {
    line-height: 1.6;
}

.markdown img {
    max-width: 100%;
    height: auto;
    display: block;
    border-radius: 0.5rem;
    border: 1px solid #e2e8f0;
}

.markdown video {
    width: 100%;
    border-radius: 0.5rem;
    border: 1px solid #e2e8f0;
    background: #000;
}

.markdown .embedded-video {
    max-width: 100%;
    display: block;
}

.markdown h1, .markdown h2, .markdown h3 {
    margin-top: 1rem;
}

.markdown ul { padding-left: 1.25rem; }

.actions.align-right {
    justify-content: flex-end;
}

.form.inline-form {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
    align-items: end;
    gap: 0.75rem;
}

.pill-list {
    list-style: none;
    padding: 0;
    display: flex;
    gap: 0.5rem;
    flex-wrap: wrap;
}

.media-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
    gap: 1rem;
}

.media-grid img,
.media-grid video {
    width: 100%;
    border-radius: 0.5rem;
    border: 1px solid #e2e8f0;
    background: #000;
}

.media-grid figure { margin: 0; }
.media-grid figcaption { margin-top: 0.4rem; color: var(--muted); font-size: 0.9rem; }

.wiki-layout {
    display: grid;
    grid-template-columns: 280px 1fr;
    gap: 1.5rem;
}

.wiki-sidebar {
    border-right: 1px solid #e2e8f0;
    padding-right: 1rem;
}

.wiki-sidebar .tree {
    margin: 0;
}

.wiki-content .section-header {
    margin-bottom: 1rem;
}

.tree {
    list-style: none;
    padding-left: 0;
}

.tree ul {
    list-style: none;
    padding-left: 1rem;
}

.tree li {
    margin: 0.25rem 0;
}

.tree a[aria-current="page"] {
    font-weight: 700;
    text-decoration: underline;
}
