/* Rossi Works Spaces — hand-written, no build step */
:root {
    --accent: #4F46E5;
    --bg: #ffffff;
    --bg-side: #f7f7f5;
    --text: #37352f;
    --muted: #787774;
    --border: #e6e4e0;
    --danger: #d44c47;
}
* { box-sizing: border-box; }
body {
    margin: 0;
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
    color: var(--text);
    background: var(--bg);
}
a { color: var(--accent); text-decoration: none; }
h1 { font-size: 1.7rem; }

/* Top bar */
.topbar {
    display: flex; align-items: center; justify-content: space-between;
    padding: 8px 16px; border-bottom: 1px solid var(--border);
    position: sticky; top: 0; background: var(--bg); z-index: 20;
}
.topbar-left, .topbar-right { display: flex; align-items: center; gap: 14px; }
.brand { font-weight: 700; color: var(--text); }
.brand span { color: var(--accent); }
.brand-lg { font-size: 1.4rem; display: block; margin-bottom: 16px; }
.ws-name { color: var(--muted); border-left: 1px solid var(--border); padding-left: 14px; }
.search-form input {
    border: 1px solid var(--border); border-radius: 6px; padding: 6px 10px; width: 220px;
}
.bell { position: relative; font-size: 1.1rem; }
.badge {
    position: absolute; top: -6px; right: -10px; background: var(--danger); color: #fff;
    border-radius: 10px; font-size: 0.65rem; padding: 1px 5px;
}
.nav-link { color: var(--muted); }
.user-menu { position: relative; }
.user-menu summary { cursor: pointer; list-style: none; color: var(--muted); }
.user-menu .menu {
    position: absolute; right: 0; top: 130%; background: #fff; border: 1px solid var(--border);
    border-radius: 8px; box-shadow: 0 4px 16px rgba(0,0,0,.08); padding: 6px; min-width: 190px;
    display: flex; flex-direction: column; z-index: 30;
}
.user-menu .menu a, .user-menu .menu button {
    padding: 7px 10px; border-radius: 6px; color: var(--text); background: none; border: 0;
    text-align: left; font-size: 0.9rem; cursor: pointer; width: 100%;
}
.user-menu .menu a:hover, .user-menu .menu button:hover { background: var(--bg-side); }

/* Shell */
.shell { display: flex; min-height: calc(100vh - 49px); }
.sidebar {
    width: 250px; flex: none; background: var(--bg-side); border-right: 1px solid var(--border);
    padding: 12px 6px; overflow-y: auto;
}
.content { flex: 1; padding: 24px 40px; max-width: 100%; }
.content-full { max-width: 900px; margin: 0 auto; }
.page-narrow { max-width: 640px; margin: 0 auto; }

/* Page tree */
.tree-item { display: flex; align-items: center; border-radius: 6px; }
.tree-item:hover { background: #efefec; }
.tree-item:hover .tree-add button { opacity: 1; }
.tree-link {
    color: var(--text); flex: 1; padding: 5px 4px; font-size: 0.9rem;
    white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.tree-link.active { font-weight: 600; color: var(--accent); }
.tree-icon { margin-right: 6px; }
.tree-add button {
    opacity: 0; border: 0; background: none; color: var(--muted); cursor: pointer;
    font-size: 1rem; padding: 2px 8px;
}
.new-page-form { margin-top: 10px; padding: 0 8px; }

/* Editor */
.page-editor-wrap { max-width: 860px; margin: 0 auto; }
.breadcrumbs { display: flex; align-items: center; gap: 8px; font-size: 0.85rem; color: var(--muted); }
.breadcrumbs a { color: var(--muted); }
.crumb-current { color: var(--text); }
.spacer { flex: 1; }
.title-row { display: flex; gap: 8px; margin: 22px 0 4px; }
#page-icon { width: 58px; font-size: 2rem; border: 0; background: none; text-align: center; }
#page-title { flex: 1; font-size: 2.2rem; font-weight: 700; border: 0; outline: none; background: none; color: var(--text); }
.icon-picker[hidden] { display: none !important; }
.icon-picker {
    display: grid; grid-template-columns: repeat(9, 40px); gap: 4px;
    background: #fff; border: 1px solid var(--border); border-radius: 10px;
    box-shadow: 0 4px 16px rgba(0,0,0,.1); padding: 8px; margin: 4px 0 0 8px;
    position: absolute; z-index: 50;
}
.icon-picker button {
    font-size: 1.3rem; border: 0; background: none; border-radius: 8px;
    padding: 5px; cursor: pointer;
}
.icon-picker button:hover { background: var(--bg-side); }
#page-icon { cursor: pointer; }
.editor-surface { min-height: 320px; padding: 8px 0 40px; }
.editor-surface .ProseMirror { outline: none; min-height: 300px; line-height: 1.6; }
.editor-surface .ProseMirror p.is-editor-empty:first-child::before {
    content: attr(data-placeholder); color: var(--muted); float: left; height: 0; pointer-events: none;
}
.editor-surface img { max-width: 100%; border-radius: 6px; }
.editor-surface pre {
    background: #f1f1ef; border-radius: 6px; padding: 12px; overflow-x: auto; font-size: 0.88rem;
}
.editor-surface blockquote { border-left: 3px solid var(--accent); margin-left: 0; padding-left: 14px; color: var(--muted); }
.editor-surface ul[data-type="taskList"] { list-style: none; padding-left: 4px; }
.editor-surface ul[data-type="taskList"] li { display: flex; gap: 8px; }

/* Comments */
.comments { border-top: 1px solid var(--border); margin-top: 30px; padding-top: 18px; }
.comments h2 { font-size: 1.05rem; }
.comment { border: 1px solid var(--border); border-radius: 8px; padding: 10px 14px; margin: 10px 0; }
.comment.resolved { opacity: 0.55; }
.comment.reply { margin-left: 26px; border-style: dashed; }
.comment-head { display: flex; align-items: center; gap: 10px; font-size: 0.85rem; }
.comment-body { margin-top: 6px; white-space: pre-wrap; }
.mention { color: var(--accent); font-weight: 600; }
.comment-form { position: relative; display: flex; flex-direction: column; gap: 8px; align-items: flex-start; }
.comment-form textarea, .reply-form input {
    width: 100%; border: 1px solid var(--border); border-radius: 8px; padding: 10px; font: inherit;
}
.reply-form { margin-top: 8px; }
.mention-menu {
    position: absolute; bottom: 52px; left: 10px; background: #fff; border: 1px solid var(--border);
    border-radius: 8px; box-shadow: 0 4px 16px rgba(0,0,0,.1); display: flex; flex-direction: column; z-index: 40;
}
.mention-menu button { border: 0; background: none; padding: 8px 14px; text-align: left; cursor: pointer; }
.mention-menu button:hover { background: var(--bg-side); }

/* Notifications dropdown */
.notif-menu summary { font-size: 1.1rem; }
.notif-list { width: 320px; max-height: 420px; overflow-y: auto; }
.notif-item { padding: 9px 10px; border-radius: 6px; font-size: 0.9rem; }
.notif-item.unread { background: color-mix(in srgb, var(--accent) 8%, #fff); }
.notif-item a { color: var(--text); display: block; }
.notif-item a:hover { color: var(--accent); }
.notif-meta { font-size: 0.78rem; margin-top: 2px; }
.notif-all {
    display: block; text-align: center; padding: 9px; border-top: 1px solid var(--border);
    margin-top: 4px; font-size: 0.85rem;
}

/* Avatars */
.avatar { border-radius: 50%; object-fit: cover; vertical-align: middle; flex: none; }
.avatar-fallback {
    display: inline-flex; align-items: center; justify-content: center;
    color: #fff; font-weight: 600; vertical-align: middle;
}
.user-menu summary { display: inline-flex; align-items: center; gap: 7px; }

/* Forms & misc */
.stack { display: flex; flex-direction: column; gap: 14px; max-width: 420px; }
.stack label { display: flex; flex-direction: column; gap: 5px; font-size: 0.9rem; }
.stack input:not([type=checkbox]), .stack select {
    border: 1px solid var(--border); border-radius: 8px; padding: 9px 11px; font: inherit;
}
.checkbox { flex-direction: row !important; align-items: center; gap: 8px !important; }
.btn {
    background: var(--accent); color: #fff; border: 0; border-radius: 8px; padding: 9px 16px;
    font: inherit; cursor: pointer; display: inline-block;
}
.btn:hover { filter: brightness(1.08); }
.btn-ghost { background: none; border: 0; color: var(--muted); cursor: pointer; font: inherit; padding: 4px 8px; border-radius: 6px; }
.btn-ghost:hover { background: var(--bg-side); color: var(--text); }
.btn-ghost.danger:hover, .danger { color: var(--danger); }
.muted { color: var(--muted); }
.flash { background: #eef4ee; border: 1px solid #cfe3cf; border-radius: 8px; padding: 10px 14px; margin-bottom: 16px; }
.flash-error { background: #fdf0ef; border-color: #f2cfcd; }
.flash-warn { background: #fdf6e3; border-color: #efe3b5; display: flex; align-items: center; gap: 10px; }
.field-error { color: var(--danger); font-size: 0.85rem; }

/* Cards & tables */
.ws-card {
    display: flex; align-items: center; gap: 12px; border: 1px solid var(--border);
    border-radius: 10px; padding: 14px 16px; margin: 10px 0; color: var(--text);
}
.ws-card:hover { border-color: var(--accent); }
.ws-dot { width: 12px; height: 12px; border-radius: 50%; }
table.list { width: 100%; border-collapse: collapse; }
table.list th, table.list td { text-align: left; padding: 9px 10px; border-bottom: 1px solid var(--border); font-size: 0.92rem; }
table.list th { color: var(--muted); font-weight: 500; }
.inline-form { display: inline-flex; gap: 6px; align-items: center; }
.inline-form select { border: 1px solid var(--border); border-radius: 6px; padding: 5px 7px; }

/* Mobile */
.menu-toggle { display: none; border: 0; background: none; font-size: 1.3rem; cursor: pointer; color: var(--text); padding: 2px 6px; }
.backdrop { display: none; }

@media (max-width: 820px) {
    .menu-toggle { display: block; }
    .ws-name { display: none; }
    .search-form input { width: 130px; }
    .topbar { padding: 8px 10px; }
    .topbar-left, .topbar-right { gap: 8px; }
    .user-menu summary .user-name { display: none; } /* avatar only on small screens */

    /* Off-canvas sidebar */
    .sidebar {
        position: fixed; top: 0; bottom: 0; left: 0; z-index: 100;
        width: min(280px, 84vw);
        transform: translateX(-100%);
        transition: transform 0.2s ease;
        box-shadow: none;
    }
    body.sidebar-open .sidebar { transform: translateX(0); box-shadow: 0 0 30px rgba(0,0,0,.25); }
    body.sidebar-open .backdrop {
        display: block; position: fixed; inset: 0; z-index: 90; background: rgba(0,0,0,.3);
    }
    body.sidebar-open { overflow: hidden; }

    .content { padding: 16px 14px; }
    .page-editor-wrap { max-width: 100%; }
    #page-title { font-size: 1.6rem; }
    #page-icon { width: 44px; font-size: 1.5rem; }
    .breadcrumbs { flex-wrap: wrap; }
    .comment-head { flex-wrap: wrap; }
    .icon-picker { grid-template-columns: repeat(6, 40px); }
    .notif-list { width: min(320px, calc(100vw - 20px)); }
    .inline-form { flex-wrap: wrap; }
    .stack { max-width: 100%; }

    /* Tables scroll horizontally instead of blowing out the page */
    table.list { display: block; overflow-x: auto; white-space: nowrap; }
}

/* Auth */
.guest-body { background: var(--bg-side); display: flex; align-items: center; justify-content: center; min-height: 100vh; padding: 14px; }
.auth-card { background: #fff; border: 1px solid var(--border); border-radius: 12px; padding: 34px; width: 420px; max-width: 100%; }
