/* Default theme. An organization's custom stylesheet loads after this file
   and can override anything here — the custom properties below are the
   intended override points. */

:root {
    --fg: #1a1a1a;
    --muted: #6b6b6b;
    --bg: #ffffff;
    --surface: #f7f7f8;
    --line: #e2e2e4;
    --accent: #2f5fd0;
    --accent-fg: #ffffff;
    --danger: #b3261e;
    --radius: 6px;
    --banner-h: 3.25rem;
    --sidebar-w: 13.5rem;
}

* { box-sizing: border-box; }

/* The hidden attribute must always win. Its UA default (display: none) loses
   to any author display value, so a class like .stack { display: grid } would
   silently un-hide an element carrying hidden — which is exactly how the
   share-permission radios leaked into every modal. */
[hidden] { display: none !important; }

html, body { height: 100%; }

body {
    margin: 0;
    font: 16px/1.6 system-ui, -apple-system, "Segoe UI", sans-serif;
    color: var(--fg);
    background: var(--bg);
}

/* ------------------------------------------------------------------ banner */

.banner {
    position: sticky;
    top: 0;
    z-index: 30;
    display: flex;
    align-items: center;
    gap: 0.75rem;
    height: var(--banner-h);
    padding: 0 1rem;
    background: var(--bg);
    border-bottom: 1px solid var(--line);
}

.brand { font-weight: 650; font-size: 1.05rem; text-decoration: none; color: inherit; }

.banner-right {
    display: flex;
    align-items: center;
    gap: 0.9rem;
    margin-left: auto;
    font-size: 0.88rem;
    color: var(--muted);
    min-width: 0;
}

.org-name { white-space: nowrap; }
.user-name { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

.icon-button {
    display: grid;
    place-items: center;
    width: 2.25rem;
    height: 2.25rem;
    padding: 0;
    background: none;
    border: 0;
    border-radius: var(--radius);
    cursor: pointer;
}

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

/* Hamburger glyph drawn with borders so no icon font is needed. */
.nav-icon,
.nav-icon::before,
.nav-icon::after {
    display: block;
    width: 1.1rem;
    height: 2px;
    background: var(--fg);
    border-radius: 2px;
    content: "";
}

.nav-icon { position: relative; }
.nav-icon::before { position: absolute; top: -5px; }
.nav-icon::after { position: absolute; top: 5px; }

/* ------------------------------------------------------------------- shell */

.shell {
    display: flex;
    min-height: calc(100vh - var(--banner-h));
}

.sidebar {
    flex: 0 0 var(--sidebar-w);
    display: flex;
    flex-direction: column;
    gap: 1px;
    padding: 0.75rem 0.5rem;
    background: var(--surface);
    border-right: 1px solid var(--line);
    transition: margin-left 0.18s ease;
}

.sidebar a {
    padding: 0.45rem 0.75rem;
    color: var(--fg);
    text-decoration: none;
    border-radius: var(--radius);
    font-size: 0.93rem;
}

.sidebar a:hover { background: color-mix(in srgb, var(--accent) 8%, transparent); }

.sidebar a.active {
    background: color-mix(in srgb, var(--accent) 12%, transparent);
    color: var(--accent);
    font-weight: 550;
}

.nav-section {
    margin: 0.9rem 0.75rem 0.15rem;
    font-size: 0.72rem;
    font-weight: 600;
    letter-spacing: 0.06em;
    text-transform: uppercase;
    color: var(--muted);
}

/* Desktop collapse: slide the sidebar out of the flow. */
html.nav-collapsed .sidebar { margin-left: calc(-1 * var(--sidebar-w)); }

.content {
    flex: 1;
    min-width: 0;
    padding: 1.5rem clamp(1rem, 3vw, 2.5rem);
    max-width: 75rem;
}

.backdrop { display: none; }

/* Mobile: off-canvas overlay. */
@media (max-width: 900px) {
    .sidebar {
        position: fixed;
        top: var(--banner-h);
        bottom: 0;
        left: 0;
        z-index: 20;
        margin-left: 0 !important;   /* desktop collapse state does not apply */
        transform: translateX(-100%);
        transition: transform 0.18s ease;
        box-shadow: 2px 0 12px rgb(0 0 0 / 12%);
    }

    html.nav-open .sidebar { transform: none; }

    .backdrop {
        display: block;
        position: fixed;
        inset: var(--banner-h) 0 0 0;
        z-index: 10;
        background: rgb(0 0 0 / 35%);
    }

    .banner-right { gap: 0.5rem; }
    .org-name { display: none; }
}

/* ------------------------------------------------------------ typography */

h1 { font-size: 1.45rem; margin: 0 0 1rem; }
h2 { font-size: 1.1rem; margin: 1.75rem 0 0.6rem; }
h3 { font-size: 0.95rem; margin: 1.25rem 0 0.5rem; }

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

.page-head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 1rem;
    flex-wrap: wrap;
}

/* --------------------------------------------------------------- BO layout */

/* Detail pages: main column plus the associations rail. */
.with-rail {
    display: grid;
    grid-template-columns: minmax(0, 1fr) 17rem;
    gap: 2rem;
    align-items: start;
}

@media (max-width: 1100px) {
    .with-rail { grid-template-columns: minmax(0, 1fr); }
}

.rail {
    display: grid;
    gap: 1rem;
    position: sticky;
    top: calc(var(--banner-h) + 1rem);
}

@media (max-width: 1100px) {
    .rail { position: static; }
}

.rail-group {
    padding: 0.9rem 1rem;
    background: var(--surface);
    border: 1px solid var(--line);
    border-radius: var(--radius);
}

.rail-group h2 { margin: 0 0 0.5rem; font-size: 0.85rem; color: var(--muted); }

.rail-item {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 0.5rem;
    padding: 0.25rem 0;
    font-size: 0.9rem;
}

.rail-item a { color: var(--fg); text-decoration: none; overflow-wrap: anywhere; }
.rail-item a:hover { color: var(--accent); }

.rail-group-head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 0.5rem;
}

.rail-group-head h2 { margin: 0; }

.rail-add {
    padding: 0.1rem 0.5rem;
    font-size: 0.78rem;
    color: var(--accent);
    background: none;
    border: 1px solid color-mix(in srgb, var(--accent) 40%, var(--line));
    border-radius: 999px;
}

.rail-add:hover { background: color-mix(in srgb, var(--accent) 10%, transparent); }

.rail-label { min-width: 0; overflow-wrap: anywhere; }

.rail-empty { margin: 0.4rem 0 0; font-size: 0.85rem; color: var(--muted); }

/* ------------------------------------------------------------------- modal */

dialog#search-modal {
    width: min(26rem, 92vw);
    padding: 1rem 1.1rem 1.1rem;
    border: 1px solid var(--line);
    border-radius: var(--radius);
    background: var(--bg);
    color: var(--fg);
}

dialog#search-modal::backdrop { background: rgb(0 0 0 / 40%); }

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

.modal-head h2 { margin: 0; font-size: 1.05rem; }

.modal-permission {
    display: flex;
    gap: 1.25rem;
    margin-bottom: 0.6rem;
    font-size: 0.88rem;
}

.modal-permission label { display: flex; align-items: center; gap: 0.35rem; }

#search-modal-input { width: 100%; }

.modal-results {
    display: grid;
    gap: 2px;
    margin-top: 0.6rem;
    max-height: 16rem;
    overflow-y: auto;
}

.modal-result {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 0.75rem;
    padding: 0.5rem 0.6rem;
    font-size: 0.92rem;
    color: var(--fg);
    background: none;
    border: 0;
    border-radius: var(--radius);
    text-align: left;
    cursor: pointer;
}

.modal-result:hover, .modal-result:focus-visible {
    background: color-mix(in srgb, var(--accent) 10%, transparent);
}

.modal-result-meta { font-size: 0.78rem; color: var(--muted); white-space: nowrap; }

.modal-empty { margin: 0.5rem 0 0; font-size: 0.88rem; color: var(--muted); }

.detail-list {
    display: grid;
    grid-template-columns: max-content 1fr;
    gap: 0.35rem 1.25rem;
    margin: 1rem 0;
    font-size: 0.93rem;
}

.detail-list dt { color: var(--muted); }
.detail-list dd { margin: 0; overflow-wrap: anywhere; }

/* ------------------------------------------------------------------- forms */

.stack { display: grid; gap: 1rem; max-width: 38rem; }
.stack label { display: grid; gap: 0.35rem; font-size: 0.9rem; }
.stack label.checkbox { display: flex; align-items: center; gap: 0.5rem; }

input[type="text"], input[type="email"], input[type="password"], input[type="date"],
input[type="search"],
select, textarea {
    padding: 0.5rem 0.6rem;
    font: inherit;
    color: inherit;
    background: var(--bg);
    border: 1px solid var(--line);
    border-radius: var(--radius);
    max-width: 100%;
}

textarea { font-family: inherit; }

input:focus, select:focus, textarea:focus {
    outline: 2px solid var(--accent);
    outline-offset: 1px;
}

button, .button {
    padding: 0.5rem 0.9rem;
    font: inherit;
    font-size: 0.93rem;
    color: var(--accent-fg);
    background: var(--accent);
    border: 0;
    border-radius: var(--radius);
    text-decoration: none;
    cursor: pointer;
    white-space: nowrap;
}

.button-danger { background: var(--danger); }

.link-button {
    padding: 0;
    color: var(--muted);
    background: none;
    text-decoration: underline;
    white-space: nowrap;
}

.link-button.danger { color: var(--danger); }

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

form.inline { display: inline; }

/* ---------------------------------------------------------------- feedback */

.flash {
    padding: 0.6rem 0.9rem;
    margin-bottom: 1.25rem;
    border-radius: var(--radius);
    border: 1px solid var(--line);
    background: var(--surface);
}

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

/* ------------------------------------------------------------------ tables */

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

table { width: 100%; border-collapse: collapse; font-size: 0.92rem; }
th, td { padding: 0.55rem 0.6rem; text-align: left; border-bottom: 1px solid var(--line); }
th { font-weight: 600; color: var(--muted); white-space: nowrap; }
td a { color: var(--fg); }
td a:hover { color: var(--accent); }

.badge {
    display: inline-block;
    padding: 0.1rem 0.45rem;
    font-size: 0.78rem;
    background: var(--surface);
    border: 1px solid var(--line);
    border-radius: 999px;
    white-space: nowrap;
}

.badge-owner { border-color: color-mix(in srgb, var(--accent) 45%, var(--line)); color: var(--accent); }

/* --------------------------------------------------------------- dashboard */

.stat-row {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(9rem, 1fr));
    gap: 1rem;
    padding: 0;
    margin: 0 0 1rem;
    list-style: none;
}

.stat {
    padding: 0.9rem 1rem;
    background: var(--surface);
    border: 1px solid var(--line);
    border-radius: var(--radius);
}

.stat a { text-decoration: none; color: inherit; display: block; }
.stat-value { display: block; font-size: 1.5rem; font-weight: 600; }
.stat-label { color: var(--muted); font-size: 0.85rem; }

/* ------------------------------------------------------------- auth screen */

body.plain {
    display: grid;
    place-items: center;
    min-height: 100vh;
    background: var(--surface);
}

.narrow {
    width: min(24rem, 92vw);
    padding: 2rem;
    background: var(--bg);
    border: 1px solid var(--line);
    border-radius: var(--radius);
}

/* ------------------------------------------------------------------- misc */

pre { overflow-x: auto; padding: 1rem; background: var(--surface); border-radius: var(--radius); font-size: 0.85em; }
code { font-family: ui-monospace, "SF Mono", Menlo, monospace; font-size: 0.9em; }

/* ---------------------------------------------------------- dataset editor */

.column-editor { display: grid; gap: 0.4rem; max-width: 44rem; }

.column-row {
    display: grid;
    grid-template-columns: minmax(0, 1fr) 8rem 7rem 5rem;
    gap: 0.5rem;
    align-items: center;
}

.column-head { font-size: 0.78rem; color: var(--muted); }

@media (max-width: 700px) {
    .column-row { grid-template-columns: minmax(0, 1fr) 6.5rem 6rem 4rem; font-size: 0.9rem; }
}

/* ----------------------------------------------------------- dataset data */

.data-toolbar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 1rem;
    flex-wrap: wrap;
    margin-bottom: 0.6rem;
    font-size: 0.9rem;
}

.data-actions a { color: var(--accent); }

.import-form {
    display: flex;
    align-items: center;
    gap: 1rem;
    flex-wrap: wrap;
    padding: 0.7rem 0.9rem;
    margin-bottom: 1rem;
    background: var(--surface);
    border: 1px solid var(--line);
    border-radius: var(--radius);
    font-size: 0.9rem;
}

.import-form .checkbox { display: flex; align-items: center; gap: 0.4rem; }

.data-table { font-size: 0.85rem; }
.data-table .type-hint { display: block; font-weight: 400; font-size: 0.72rem; }

.pager {
    display: flex;
    align-items: center;
    gap: 1rem;
    margin-top: 0.75rem;
    font-size: 0.9rem;
}

/* ----------------------------------------------------------- document file */

.file-card {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 1rem;
    flex-wrap: wrap;
    padding: 0.8rem 1rem;
    margin-bottom: 0.75rem;
    background: var(--surface);
    border: 1px solid var(--line);
    border-radius: var(--radius);
}

.file-meta { display: grid; gap: 0.1rem; min-width: 0; }
.file-name { font-weight: 550; color: var(--fg); overflow-wrap: anywhere; }
.file-name:hover { color: var(--accent); }
.file-meta .muted { font-size: 0.85rem; }

/* -------------------------------------------------------------------- tabs */

.tabs {
    display: flex;
    gap: 0.25rem;
    margin-bottom: 1.25rem;
    border-bottom: 1px solid var(--line);
}

.tab {
    padding: 0.45rem 1rem;
    font-size: 0.93rem;
    color: var(--muted);
    background: none;
    border: 0;
    border-bottom: 2px solid transparent;
    border-radius: var(--radius) var(--radius) 0 0;
    cursor: pointer;
}

.tab:hover { color: var(--fg); background: var(--surface); }

.tab.active {
    color: var(--accent);
    font-weight: 550;
    border-bottom-color: var(--accent);
}

/* -------------------------------------------------------------- discussion */

.comments { display: grid; gap: 0.75rem; margin-bottom: 1.25rem; }

.comment {
    padding: 0.7rem 0.9rem;
    background: var(--surface);
    border: 1px solid var(--line);
    border-radius: var(--radius);
}

.comment-head {
    display: flex;
    align-items: baseline;
    gap: 0.75rem;
    font-size: 0.85rem;
}

.comment-head .link-button { margin-left: auto; font-size: 0.8rem; }

.comment-author { font-weight: 600; }

.comment-body {
    margin: 0.3rem 0 0;
    font-size: 0.93rem;
    white-space: pre-wrap;
    overflow-wrap: anywhere;
}

.comment-form { display: grid; gap: 0.6rem; max-width: 40rem; }
.comment-form textarea { resize: vertical; }

/* ------------------------------------------------------------- code fields */

.code-input,
.code-block {
    font-family: ui-monospace, "SF Mono", Menlo, monospace;
    font-size: 0.85rem;
    tab-size: 4;
}

.code-block {
    max-height: 28rem;
    overflow: auto;
    padding: 1rem;
    background: var(--surface);
    border: 1px solid var(--line);
    border-radius: var(--radius);
}

/* ------------------------------------------------------- parameter editor */

.param-card {
    margin: 0 0 1rem;
    padding: 0.9rem 1rem;
    border: 1px solid var(--line);
    border-radius: var(--radius);
    background: var(--surface);
}

.param-grid {
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 0.6rem 1rem;
    margin-bottom: 0.5rem;
}

.param-grid label { display: grid; gap: 0.25rem; font-size: 0.85rem; }
.param-grid .param-wide { grid-column: 1 / -1; }

@media (max-width: 700px) {
    .param-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}

/* ------------------------------------------------------------- run history */

.badge.run-completed { border-color: color-mix(in srgb, #2e7d32 50%, var(--line)); color: #2e7d32; }
.badge.run-failed { border-color: color-mix(in srgb, var(--danger) 50%, var(--line)); color: var(--danger); }
.badge.run-running { border-color: color-mix(in srgb, var(--accent) 50%, var(--line)); color: var(--accent); }

.run-error { font-size: 0.8rem; max-width: 18rem; }

.run-params code {
    display: inline-block;
    margin: 0 0.25rem 0.15rem 0;
    padding: 0.05rem 0.35rem;
    background: var(--surface);
    border: 1px solid var(--line);
    border-radius: 3px;
    font-size: 0.78rem;
}

/* ---------------------------------------------------------------- calendar */

.cal-head {
    display: flex;
    align-items: center;
    gap: 1rem;
    flex-wrap: wrap;
    margin-bottom: 0.75rem;
}

.cal-title { margin: 0; }
.cal-head [data-cal-add] { margin-left: auto; }

.cal-nav { display: flex; gap: 0.75rem; font-size: 0.9rem; }
.cal-nav a { color: var(--accent); text-decoration: none; }

.cal-grid { table-layout: fixed; }

.cal-grid th {
    text-align: center;
    font-size: 0.78rem;
    padding: 0.3rem 0;
}

.cal-cell {
    vertical-align: top;
    height: 5.5rem;
    padding: 0.25rem 0.3rem;
    border: 1px solid var(--line);
    cursor: pointer;
}

.cal-cell:hover { background: color-mix(in srgb, var(--accent) 4%, transparent); }

.cal-out { background: var(--surface); opacity: 0.55; }

.cal-today .cal-day {
    background: var(--accent);
    color: var(--accent-fg);
    border-radius: 999px;
}

.cal-day {
    display: inline-block;
    min-width: 1.4rem;
    text-align: center;
    font-size: 0.78rem;
    color: var(--muted);
    margin-bottom: 0.2rem;
}

.cal-entry {
    display: block;
    width: 100%;
    margin-bottom: 2px;
    padding: 0.1rem 0.35rem;
    font-size: 0.75rem;
    line-height: 1.35;
    text-align: left;
    color: var(--fg);
    background: color-mix(in srgb, var(--accent) 12%, transparent);
    border: 1px solid color-mix(in srgb, var(--accent) 30%, var(--line));
    border-radius: 3px;
    cursor: pointer;
    overflow: hidden;
    white-space: nowrap;
    text-overflow: ellipsis;
}

.cal-entry:hover { background: color-mix(in srgb, var(--accent) 22%, transparent); }

.cal-assignee { color: var(--muted); font-size: 0.7rem; margin-left: 0.25rem; }

.cal-form-dates { display: flex; gap: 1rem; flex-wrap: wrap; }

.upcoming-desc { font-size: 0.82rem; }

/* ------------------------------------------------- login page (HSI theme) */
/* Themed after hisescientific.com: brand red #c92e2e on white, light-grey
   backdrop, dark #272727 headings, pill-shaped uppercase buttons. Scoped to
   .hsi-theme so the signed-in app keeps its own (org-themeable) look. */

/* body.hsi-theme (not bare .hsi-theme): body.plain earlier in this file sets
   its own background at element+class specificity, which silently beats a
   lone class no matter the source order. */
body.hsi-theme {
    --hsi-red: #c92e2e;
    --hsi-red-dark: #af2323;
    --hsi-ink: #272727;
    --hsi-body: #6e6d6d;
    --hsi-paper: #f7f6f6;
    --hsi-field: #f1f1f1;
    font-family: 'Roboto', Arial, Helvetica, sans-serif;
    color: var(--hsi-body);
    /* The hisescientific.com forest hero under a soft dark wash so the white
       card reads crisply at any viewport; grey shows while the image loads. */
    background-color: var(--hsi-paper);
    background-image:
        linear-gradient(rgb(10 20 12 / 45%), rgb(10 20 12 / 55%)),
        url('../img/login-bg.jpg');
    background-position: center;
    background-size: cover;
    background-repeat: no-repeat;
}

.hsi-theme .login-card {
    width: min(26rem, 92vw);
    padding: 2.5rem 2.5rem 1.5rem;
    background: #fff;
    border: 1px solid #ebebeb;
    border-top: 4px solid var(--hsi-red);
    border-radius: 6px;
    /* Deeper shadow than on a flat page: the card floats over the forest. */
    box-shadow: 0 18px 50px rgb(0 0 0 / 35%);
}

/* The footer line sits on the photo's dark field when outside the card, but
   it lives inside the card here — keep it, just soften the divider. */

.hsi-theme .login-logo {
    display: block;
    width: 100%;
    max-width: 20rem;
    margin: 0 auto 1.75rem;
}

.hsi-theme .login-title {
    margin: 0 0 1.25rem;
    font-family: 'Roboto Condensed', 'Roboto', Arial, sans-serif;
    font-size: 1.6rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.02em;
    color: var(--hsi-ink);
    text-align: center;
}

.hsi-theme .login-form label {
    font-family: 'Roboto Condensed', 'Roboto', Arial, sans-serif;
    font-size: 0.95rem;
    text-transform: uppercase;
    letter-spacing: 0.04em;
    color: var(--hsi-ink);
}

.hsi-theme .login-form input {
    padding: 0.7rem 0.9rem;
    font-family: 'Roboto', Arial, sans-serif;
    font-size: 1rem;
    color: var(--hsi-ink);
    background: var(--hsi-field);
    border: 1px solid #ddd;
    border-radius: 4px;
}

.hsi-theme .login-form input:focus {
    outline: 2px solid var(--hsi-red);
    outline-offset: 1px;
    background: #fff;
}

.hsi-theme .login-submit {
    margin-top: 0.5rem;
    padding: 0.75rem 2.8rem;
    justify-self: center;
    font-family: 'Roboto', Arial, sans-serif;
    font-size: 0.9rem;
    font-weight: 500;
    letter-spacing: 0.08em;
    text-transform: uppercase;
    color: #fff;
    background: var(--hsi-red);
    border: 0;
    border-radius: 30px;
    cursor: pointer;
    transition: background 0.15s ease;
}

.hsi-theme .login-submit:hover {
    background: var(--hsi-red-dark);
}

.hsi-theme .flash-error {
    background: #fdf1f1;
    border: 1px solid var(--hsi-red);
    color: var(--hsi-red-dark);
}

.hsi-theme .login-foot {
    margin: 1.75rem 0 0;
    padding-top: 1rem;
    border-top: 1px solid #ebebeb;
    font-family: 'Roboto Condensed', Arial, sans-serif;
    font-size: 0.85rem;
    text-transform: uppercase;
    letter-spacing: 0.14em;
    text-align: center;
    color: var(--hsi-body);
}

/* ------------------------------------------------------------ private notes */

.note-privacy { margin-top: 0; }

.note-editor {
    min-height: 14rem;
    padding: 0.75rem 1rem;
    background: var(--bg);
    /* A shade darker than --line so the boundary actually reads on white. */
    border: 1px solid color-mix(in srgb, var(--muted) 35%, var(--line));
    border-radius: var(--radius);
    margin-bottom: 0.75rem;
}

.note-editor:focus-within {
    border-color: var(--accent);
}

/* editor.js uses generous side padding for its block controls; keep the
   content aligned with the app's forms on narrow screens. */
.note-editor .ce-block__content,
.note-editor .ce-toolbar__content { max-width: 100%; }

/* Multi-note layout: list beside the editor, stacking on narrow screens. */
.notes-layout {
    display: grid;
    grid-template-columns: 14rem minmax(0, 1fr);
    gap: 1.5rem;
    align-items: start;
}

@media (max-width: 800px) {
    .notes-layout { grid-template-columns: minmax(0, 1fr); }
}

.notes-list {
    display: grid;
    gap: 0.6rem;
    padding: 1rem;
    margin: 0.25rem 0 1rem;
    background: var(--surface);
    border: 1px solid var(--line);
    border-radius: var(--radius);
}

/* Items sit on the grey card, so they need their own white ground. */
.notes-list .note-item { background: var(--bg); }

.note-item {
    display: grid;
    gap: 0.1rem;
    width: 100%;
    min-width: 0;
    padding: 0.5rem 0.7rem;
    text-align: left;
    color: var(--fg);
    background: var(--surface);
    border: 1px solid var(--line);
    border-radius: var(--radius);
    cursor: pointer;
    /* The global button rule sets nowrap, which would let long titles
       overflow the card — notes titles wrap instead. */
    white-space: normal;
}

.note-item:hover { border-color: var(--accent); }
.note-item.active { border-color: var(--accent); background: color-mix(in srgb, var(--accent) 8%, transparent); }
.note-item-title {
    font-weight: 550;
    overflow-wrap: anywhere;
    word-break: break-word;
}
.note-item-date { font-size: 0.75rem; }

.notes-empty { margin: 0.25rem 0 0; font-size: 0.85rem; }

.note-title {
    width: 100%;
    margin-bottom: 0.6rem;
    font-size: 1.05rem;
    font-weight: 550;
}

/* The placeholder paragraph sits in the second grid column until a note opens. */
.notes-layout > [data-note-placeholder] { grid-column: 2; margin-top: 0.5rem; }

@media (max-width: 800px) {
    .notes-layout > [data-note-placeholder] { grid-column: 1; }
}

.notes-editor { grid-column: 2; }

@media (max-width: 800px) {
    .notes-editor { grid-column: 1; }
}

/* ------------------------------------------------------------ index search */

.index-search {
    display: flex;
    gap: 0.6rem;
    align-items: center;
    flex-wrap: wrap;
    margin: 1rem 0 0.75rem;
}

.index-search input[type="search"] { flex: 1 1 14rem; max-width: 24rem; }
.index-search input[name="col"] { flex: 0 1 12rem; }

.index-search-summary { margin: 0 0 0.75rem; font-size: 0.88rem; }

/* ---------------------------------------------------------------- profiles */

.profile-layout {
    display: grid;
    grid-template-columns: 12rem minmax(0, 1fr);
    gap: 2rem;
    align-items: start;
}

@media (max-width: 700px) {
    .profile-layout { grid-template-columns: minmax(0, 1fr); }
}

.profile-photo {
    width: 10rem;
    height: 10rem;
    object-fit: cover;
    border-radius: 50%;
    border: 1px solid var(--line);
    margin-bottom: 1rem;
}

.profile-photo-empty {
    display: grid;
    place-items: center;
    font-size: 3.5rem;
    font-weight: 600;
    color: var(--muted);
    background: var(--surface);
}

.members-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(16rem, 1fr));
    gap: 1rem;
    margin-top: 1rem;
}

.member-card {
    display: flex;
    gap: 0.9rem;
    align-items: center;
    padding: 0.9rem 1rem;
    background: var(--surface);
    border: 1px solid var(--line);
    border-radius: var(--radius);
    text-decoration: none;
    color: var(--fg);
}

.member-card:hover { border-color: var(--accent); }

.member-avatar {
    flex: 0 0 3.25rem;
    width: 3.25rem;
    height: 3.25rem;
    object-fit: cover;
    border-radius: 50%;
    border: 1px solid var(--line);
}

.member-avatar-empty {
    display: grid;
    place-items: center;
    font-size: 1.4rem;
    font-weight: 600;
    color: var(--muted);
    background: var(--bg);
}

.member-meta { display: grid; gap: 0.05rem; min-width: 0; font-size: 0.9rem; }
.member-name { font-weight: 600; }
.member-email { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

.member-profile-name { margin-bottom: 0.25rem; }
.member-profile-title { margin: 0 0 0.5rem; font-weight: 550; }

/* Profile: text on the left, photo with contact info beneath it on the right. */
.member-profile-grid {
    display: grid;
    grid-template-columns: minmax(0, 1fr) 12rem;
    gap: 2rem;
    align-items: start;
    text-align: left;
}

.member-profile-side .profile-photo { margin-bottom: 0.75rem; }
.member-profile-side h2 { margin-top: 0.5rem; font-size: 1rem; }
.member-profile-side p { font-size: 0.92rem; margin: 0; }

@media (max-width: 640px) {
    .member-profile-grid { grid-template-columns: minmax(0, 1fr); }
    .member-profile-side { order: -1; }
}

/* Public pages: the wide content card, same branding as the login card. */
.hsi-theme .public-card {
    width: min(48rem, 94vw);
    margin: 3rem auto;
    padding: 2.5rem 3rem 1.5rem;
    background: #fff;
    border: 1px solid #ebebeb;
    border-top: 4px solid var(--hsi-red);
    border-radius: 6px;
    box-shadow: 0 18px 50px rgb(0 0 0 / 35%);
}

.hsi-theme .public-card .login-logo { margin-bottom: 2rem; }

/* The public body centers the login card via place-items; the public card
   flows instead so tall profiles scroll naturally. */
body.public-page { display: block; overflow-y: auto; }

/* Comment composer: a compact editor, and readable formatted bodies. */
.comment-editor { min-height: 6rem; margin-bottom: 0.6rem; }

.comment-body { margin: 0.3rem 0 0; font-size: 0.93rem; overflow-wrap: anywhere; }
.comment-body p { margin: 0 0 0.4rem; line-height: 1.5; }
.comment-body p:last-child { margin-bottom: 0; }
.comment-body h2, .comment-body h3, .comment-body h4 { margin: 0.5rem 0 0.25rem; font-size: 1rem; }
.comment-body ul, .comment-body ol { margin: 0.25rem 0 0.4rem 1.25rem; }
.comment-body ul li { list-style: disc; }
.comment-body ol li { list-style: decimal; }
.comment-body code { background: var(--bg); padding: 0.05rem 0.3rem; border-radius: 3px; }

/* Calendar entry modal — same family as the search modal. */
dialog.cal-modal {
    width: min(30rem, 92vw);
    padding: 1rem 1.25rem 1.25rem;
    border: 1px solid var(--line);
    border-radius: var(--radius);
    background: var(--bg);
    color: var(--fg);
}

dialog.cal-modal::backdrop { background: rgb(0 0 0 / 40%); }

dialog.cal-modal .modal-head h3 { margin: 0; font-size: 1.05rem; }

/* Compact type tag on rail items (document types) — kept small so titles
   stay the dominant element. */
.rail-tag {
    flex: 0 0 auto;
    /* Push the tag to the right edge, sitting just left of the × control. */
    margin-left: auto;
    padding: 0 0.35rem;
    font-size: 0.68rem;
    line-height: 1.5;
    color: var(--muted);
    background: var(--bg);
    border: 1px solid var(--line);
    border-radius: 3px;
    white-space: nowrap;
}

/* Inline document title above the text editor; auto-saves with the body. */
.doc-title-field {
    display: grid;
    gap: 0.35rem;
    margin-bottom: 0.75rem;
    max-width: 34rem;
    font-size: 0.9rem;
}

/* Heading row with an action beside it (e.g. the Text section's export). */
.section-head {
    display: flex;
    align-items: baseline;
    justify-content: space-between;
    gap: 1rem;
}

.section-head h2 { margin-bottom: 0.6rem; }

/* -------------------------------------------------------- project citations */

.citation-list {
    margin: 0;
    padding: 0;
    list-style: none;
    display: grid;
    gap: 0.5rem;
}

.citation-item {
    display: flex;
    align-items: baseline;
    justify-content: space-between;
    gap: 0.75rem;
    padding: 0.55rem 0.75rem;
    background: var(--surface);
    border: 1px solid var(--line);
    border-radius: var(--radius);
    font-size: 0.92rem;
}

.citation-text { overflow-wrap: anywhere; }

.citation-actions {
    flex: 0 0 auto;
    display: flex;
    align-items: baseline;
    gap: 0.5rem;
    font-size: 0.85rem;
}

.citation-paste textarea { font-size: 0.9rem; }

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

.citation-source { display: block; font-size: 0.8rem; }

.citation-paste-helper {
    margin-bottom: 1.25rem;
    padding: 0.9rem 1rem;
    background: var(--surface);
    border: 1px solid var(--line);
    border-radius: var(--radius);
}

.citation-paste-helper textarea { width: 100%; font-size: 0.9rem; }

/* ----------------------------------------------------------------- quill */

/* Editing area gets a sensible default height; the toolbar sits above it
   with its own chrome from quill.snow.css. */
.ql-container { min-height: 10rem; font-size: 0.95rem; font-family: inherit; }
.ql-toolbar { background: var(--surface); border-radius: var(--radius) var(--radius) 0 0; }
.ql-container.ql-snow { border-radius: 0 0 var(--radius) var(--radius); }

/* Read-only rendering of stored editor HTML (document text for viewers). */
.rendered-text {
    padding: 0.25rem 0;
    overflow-wrap: anywhere;
}

.rendered-text blockquote {
    margin: 0.5rem 0;
    padding-left: 0.9rem;
    border-left: 3px solid var(--line);
    color: var(--muted);
}

/* Completed calendar entries and dashboard rows. */
.cal-entry.cal-done { text-decoration: line-through; opacity: 0.6; }
.cal-completed { display: flex; align-items: center; gap: 0.45rem; font-size: 0.9rem; }
.upcoming-check { color: var(--accent); font-weight: 650; text-align: center; }
.upcoming-done td { color: var(--muted); }
.upcoming-done td:nth-child(3) { text-decoration: line-through; }

/* Dashboard completed toggle: a quiet check control in the Done column. */
.check-toggle {
    padding: 0 0.4rem;
    font-size: 1rem;
    line-height: 1.4;
    color: var(--accent);
    background: none;
    border: 0;
    cursor: pointer;
}

.check-toggle:hover { background: color-mix(in srgb, var(--accent) 10%, transparent); border-radius: var(--radius); }
.upcoming-done .check-toggle { color: var(--accent); }

.login-links { margin: 0.25rem 0 0; font-size: 0.88rem; text-align: center; }
.login-links a { color: inherit; }

/* ------------------------------------------------------- document history */

.revision-list { margin: 0; padding: 0; list-style: none; display: grid; gap: 0.9rem; }

.revision-item {
    padding: 0.75rem 0.9rem;
    background: var(--surface);
    border: 1px solid var(--line);
    border-radius: var(--radius);
}

.revision-head { display: flex; align-items: baseline; gap: 0.6rem; flex-wrap: wrap; }

.revision-diff {
    margin-top: 0.5rem;
    font-size: 0.9rem;
    overflow-wrap: anywhere;
}

.revision-diff del { background: #fbe4e4; color: #8a1f1f; text-decoration: line-through; }
.revision-diff ins { background: #e2f4e4; color: #1d5e26; text-decoration: none; }

/* ------------------------------------------------------- inline comments */

.ql-comment {
    background: #fff3c2;
    border-bottom: 2px solid #e5c341;
}

.ql-comment-flash { background: #ffe066; transition: background 0.4s; }

.doc-comments {
    margin: 0 0 1rem;
    padding: 0.75rem 0.9rem;
    display: grid;
    gap: 0.75rem;
    background: var(--surface);
    border: 1px solid var(--line);
    border-radius: var(--radius);
}

.doc-comment { cursor: pointer; }
.doc-comment .comment-head { display: flex; gap: 0.6rem; align-items: baseline; flex-wrap: wrap; }
.doc-comment .comment-author { font-weight: 600; }
.doc-comment .comment-body { font-size: 0.92rem; }

/* Inline citation markers in document text. */
.ql-citation {
    color: var(--accent);
    white-space: nowrap;
    font-size: 0.92em;
}

.rendered-text .ql-citation { cursor: pointer; }
.rendered-text .ql-citation:hover { text-decoration: underline; }

dialog[data-cite-insert-dialog] textarea { width: 100%; font-size: 0.9rem; }

/* Action row at the top of a titleless tab panel (document tabs). */
.tab-actions {
    display: flex;
    justify-content: flex-end;
    margin: 0.75rem 0;
}

/* Remote service enrollment cards on the profile Settings tab. */
.remote-service {
    margin-bottom: 1rem;
    padding: 0.9rem 1rem;
    background: var(--surface);
    border: 1px solid var(--line);
    border-radius: var(--radius);
}

.remote-service-desc { margin-top: -0.4rem; }

/* Enabled remote services: indented sub-entries in the main menu. */
.sidebar a.sub-link {
    padding-left: 1.9rem;
    font-size: 0.88rem;
    color: var(--muted);
}

.sidebar a.sub-link.active,
.sidebar a.sub-link:hover { color: var(--accent); }

/* ESN device import row: name + auto-sync + button on one line. */
.esn-import-form { display: flex; align-items: center; gap: 0.6rem; flex-wrap: wrap; }
.esn-import-form input[type="text"] { max-width: 16rem; }
