/* ─────────────────────────────────────────────────────────────────────────
   SysRevAI — application styles. Okabe-Ito accessible palette, Inter/system.
   ───────────────────────────────────────────────────────────────────────── */

:root {
    --c-bg:        #f4f6f8;
    --c-surface:   #ffffff;
    --c-surface-2: #f0f3f6;
    --c-text:      #1b2733;
    --c-muted:     #5b6b7b;
    --c-border:    #dde3e9;
    --c-primary:    #c9f24c;
    --c-primary-d:  #a4cf2d;
    --c-on-primary: #1b2733;
    --c-ok:        #009e73;
    --c-warn:      #e69f00;
    --c-fail:      #d55e00;
    --c-active-fg: #ffffff;       /* text on the dark "is-active" buttons */
    --c-active-bg: #1b2733;
    --c-alert-success-bg:    #e6f6f1;
    --c-alert-success-fg:    #06624a;
    --c-alert-success-bd:    #b7e6d6;
    --c-alert-error-bg:      #fdeee6;
    --c-alert-error-fg:      #9c3b00;
    --c-alert-error-bd:      #f6cdb5;
    --c-alert-warn-bg:       #fdf2dc;
    --c-alert-warn-fg:       #8a6100;
    --c-alert-warn-bd:       #f4dca0;
    --c-tag-active-bg:       #e6f6f1;
    --c-tag-active-fg:       #06624a;
    --c-tag-soft-bg:         #eef1f4;
    --c-tag-soft-fg:         #5b6b7b;
    --c-tag-completed-bg:    #eaf4fb;
    --c-tag-completed-fg:    #1b3a4d;
    --radius:      10px;
    --shadow:      0 1px 3px rgba(16,35,53,.08), 0 6px 24px rgba(16,35,53,.06);
    --font:        "Inter", -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
}

/* Dark mode — set on <html data-theme="dark"> by the toggle (and the
   inline boot script in the layouts, to avoid a light flash on load).
   Only the palette tokens change; the rest of the stylesheet keeps
   referring to the same variables. */
:root[data-theme="dark"] {
    --c-bg:        #0f1923;
    --c-surface:   #1a2632;
    --c-surface-2: #243140;
    --c-text:      #e3e9ef;
    --c-muted:     #94a4b6;
    --c-border:    #2a3744;
    --c-on-primary: #0f1923;   /* keep dark text on the lime accent */
    --c-active-fg: #0f1923;
    --c-active-bg: #e3e9ef;
    --shadow:      0 1px 2px rgba(0,0,0,.30), 0 8px 24px rgba(0,0,0,.35);
    --c-alert-success-bg:    rgba(0,158,115,.12);
    --c-alert-success-fg:    #6fd5b3;
    --c-alert-success-bd:    rgba(0,158,115,.35);
    --c-alert-error-bg:      rgba(213,94,0,.14);
    --c-alert-error-fg:      #f0a378;
    --c-alert-error-bd:      rgba(213,94,0,.40);
    --c-alert-warn-bg:       rgba(230,159,0,.13);
    --c-alert-warn-fg:       #ecc674;
    --c-alert-warn-bd:       rgba(230,159,0,.38);
    --c-tag-active-bg:       rgba(0,158,115,.18);
    --c-tag-active-fg:       #6fd5b3;
    --c-tag-soft-bg:         #243140;
    --c-tag-soft-fg:         #94a4b6;
    --c-tag-completed-bg:    rgba(0,114,178,.18);
    --c-tag-completed-fg:    #6fb7e4;
    color-scheme: dark;
}

* { box-sizing: border-box; }
html, body {
    margin: 0; padding: 0;
    background: var(--c-bg); color: var(--c-text);
    font-family: var(--font); font-size: 16px; line-height: 1.55;
    -webkit-font-smoothing: antialiased;
}
a { color: var(--c-primary); text-decoration: none; }
a:hover { text-decoration: underline; }

/* Brand */
.brand__mark {
    display: inline-block;
    width: 32px; height: 32px; border-radius: 8px;
    object-fit: contain;
}
.brand__name { font-weight: 700; font-size: 17px; color: var(--c-text); }

/* Force the HTML `hidden` attribute to actually hide elements — by default
   the browser only adds `display: none`, which is overridden by any
   explicit `display: flex/grid/block` in this stylesheet. The Copilot
   panel and the collapsible card bodies need this guarantee. */
[hidden] { display: none !important; }

/* Top bar */
.topbar {
    display: flex; align-items: center; gap: 24px;
    background: var(--c-surface); border-bottom: 1px solid var(--c-border);
    padding: 0 24px; height: 60px;
    position: sticky; top: 0; z-index: 20;
}
.topbar__brand { display: flex; align-items: center; gap: 10px; }
.topbar__brand:hover { text-decoration: none; }
.topbar__nav { display: flex; gap: 18px; flex: 1; }
.topbar__nav a { color: var(--c-muted); font-weight: 500; font-size: 15px; }
.topbar__nav a:hover { color: var(--c-text); text-decoration: none; }
.topbar__user { display: flex; align-items: center; gap: 12px; }
.topbar__name {
    font-size: 14px; color: var(--c-muted);
    display: inline-flex; align-items: center; gap: 8px;
}
.topbar__name:hover { color: var(--c-text); text-decoration: none; }
.topbar__name-text { line-height: 1; }
.avatar { display: inline-block; vertical-align: middle; }
.avatar--initials { user-select: none; }
.inline-form { display: inline; }

/* Theme toggle (sun / moon) in the topbar. Only one of the two SVG icons
   is visible at a time, depending on <html data-theme>. */
.theme-toggle {
    width: 34px; height: 34px; border-radius: 999px;
    border: 1px solid var(--c-border); background: var(--c-surface);
    color: var(--c-muted); cursor: pointer;
    display: inline-flex; align-items: center; justify-content: center;
    transition: color .12s ease, border-color .12s ease, background .12s ease;
}
.theme-toggle:hover { color: var(--c-text); border-color: var(--c-muted); }
.theme-toggle__icon--sun  { display: none; }
.theme-toggle__icon--moon { display: block; }
:root[data-theme="dark"] .theme-toggle__icon--sun  { display: block; }
:root[data-theme="dark"] .theme-toggle__icon--moon { display: none; }

/* Persistent secondary nav rendered by layouts/app.php whenever the user
   is browsing pages of a specific review. Visually consistent with the
   topbar (same surface, same border) and reuses the platform .btn styles
   for the action buttons — no bespoke button look. */
.review-subnav {
    background: var(--c-surface);
    border-bottom: 1px solid var(--c-border);
    box-shadow: 0 1px 2px rgba(16,35,53,.04);
    position: sticky; top: 60px; z-index: 15;
}
/* Match the topbar exactly: full viewport width, same horizontal
   padding. No max-width container around the inner block. */
.review-subnav__inner {
    padding: 8px 24px 10px;
    display: flex; flex-direction: column; gap: 6px;
}
.review-subnav__head {
    display: flex; align-items: center; gap: 10px;
    min-height: 28px;
}
.review-subnav__back {
    display: inline-flex; align-items: center; justify-content: center;
    width: 26px; height: 26px; border-radius: 6px;
    color: var(--c-muted); font-size: 16px; font-weight: 700; line-height: 1;
    border: 1px solid var(--c-border); background: var(--c-surface);
}
.review-subnav__back:hover { color: var(--c-text); border-color: var(--c-muted); text-decoration: none; }
.review-subnav__name {
    color: var(--c-text); font-weight: 700; font-size: 15px;
    max-width: 50ch; overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.review-subnav__name:hover { text-decoration: none; color: var(--c-text); opacity: .82; }
.review-subnav__archive { margin-left: 4px; }

/* All actions in a single horizontal line. If they don't fit, the row
   scrolls horizontally instead of wrapping — keeps the bar to a fixed
   2-row height across viewports. */
.review-subnav__actions {
    display: flex; gap: 6px; align-items: center;
    overflow-x: auto;
    scrollbar-width: thin;
    -webkit-overflow-scrolling: touch;
    padding-bottom: 2px; /* room for the slim scrollbar */
}
.review-subnav__actions::-webkit-scrollbar { height: 4px; }
.review-subnav__actions::-webkit-scrollbar-thumb { background: var(--c-border); border-radius: 4px; }
.review-subnav__actions .btn { white-space: nowrap; flex: 0 0 auto; }

/* Active button: invert the dark text color (no extra primary tint
   needed — primary is already lime everywhere else). Applies to any
   .btn marked with is-active inside the subnav. */
.review-subnav .btn.is-active {
    background: var(--c-active-bg); color: var(--c-active-fg); border-color: var(--c-active-bg);
}
.review-subnav .btn.is-active:hover { opacity: .9; }

@media (max-width: 720px) {
    .review-subnav__inner { padding: 8px 14px; }
    .review-subnav__name { max-width: 18ch; font-size: 14px; }
}

/* AI document upload (currently in the protocol edit page). */
.ai-upload__row {
    display: flex; gap: 10px; flex-wrap: wrap; align-items: center;
    margin-bottom: 8px;
}
.ai-upload__row input[type="file"] { flex: 1; min-width: 220px; padding: 9px 10px; }
.ai-upload__status { margin: 8px 0 0; font-size: 13px; }
.ai-suggested {
    background: color-mix(in srgb, var(--c-primary) 18%, var(--c-surface));
    border-color: color-mix(in srgb, var(--c-primary) 55%, var(--c-border));
    box-shadow: 0 0 0 1px color-mix(in srgb, var(--c-primary) 55%, var(--c-border)) inset;
}
.ai-suggested:focus { outline-color: var(--c-primary-d); }

/* /profile layout: sidebar of sections + main content. */
.profile-layout {
    display: grid; grid-template-columns: 220px 1fr; gap: 24px;
    max-width: 1080px; margin: 0 auto; padding: 28px 24px 64px;
}
.profile-nav {
    background: var(--c-surface); border: 1px solid var(--c-border);
    border-radius: var(--radius); padding: 14px; height: fit-content;
}
.profile-nav__title { margin: 0 0 10px; font-size: 13px; color: var(--c-muted); text-transform: uppercase; letter-spacing: .04em; }
.profile-nav nav { display: flex; flex-direction: column; }
.profile-nav__link {
    padding: 8px 10px; border-radius: 6px; color: var(--c-text); font-size: 14.5px;
}
.profile-nav__link:hover { background: var(--c-surface-2); text-decoration: none; }
.profile-nav__link.is-active { background: var(--c-bg); font-weight: 600; }
.profile-main .page__title { margin: 0 0 18px; }
.profile-main .section-card + .section-card { margin-top: 16px; }

.profile-avatar-row {
    display: flex; align-items: flex-start; gap: 20px; flex-wrap: wrap;
}
.profile-avatar-row .avatar {
    border: 2px solid var(--c-border);
    box-shadow: var(--shadow);
}
.profile-avatar-actions { flex: 1; min-width: 240px; }

.profile-2fa-steps { padding-left: 20px; color: var(--c-muted); margin: 8px 0 16px; }
.profile-2fa-steps li { margin: 4px 0; }
.tfa-key__value {
    display: inline-block; padding: 8px 14px; border-radius: 6px;
    background: var(--c-bg); border: 1px solid var(--c-border);
    font-family: ui-monospace, monospace; font-size: 16px; letter-spacing: .12em;
    user-select: all;
}

@media (max-width: 720px) {
    .profile-layout { grid-template-columns: 1fr; padding: 16px 14px 48px; }
}

/* Scientific Copilot — floating chat widget shown on every page inside
   a review. Single bubble in the bottom-right that expands to a panel. */
.copilot { position: fixed; right: 22px; bottom: 22px; z-index: 30; }
.copilot__toggle {
    width: 52px; height: 52px; border-radius: 50%;
    background: var(--c-primary);
    /* The GitHub-Copilot-style icon must render in solid black on top of
       the lime accent, regardless of the active theme — the user picked
       this combination as the platform's Copilot identity. */
    color: #000;
    border: 1px solid var(--c-primary-d);
    line-height: 1; cursor: pointer;
    box-shadow: 0 4px 12px rgba(16,35,53,.18);
    display: flex; align-items: center; justify-content: center;
}
.copilot__toggle:hover { background: var(--c-primary-d); }
.copilot__toggle-icon { width: 24px; height: 24px; }

.copilot__panel {
    position: absolute; right: 0; bottom: 64px;
    width: 360px; max-width: calc(100vw - 28px);
    height: 520px; max-height: calc(100vh - 120px);
    display: flex; flex-direction: column;
    background: var(--c-surface);
    border: 1px solid var(--c-border); border-radius: 12px;
    box-shadow: var(--shadow);
    overflow: hidden;
    transition: width .2s ease, height .2s ease;
}
.copilot.is-expanded .copilot__panel {
    /* 50% larger in both dimensions, still constrained by the viewport. */
    width: 540px; max-width: calc(100vw - 28px);
    height: 780px; max-height: calc(100vh - 120px);
}
.copilot__head {
    display: flex; align-items: flex-start; justify-content: space-between;
    gap: 8px; padding: 12px 14px;
    background: var(--c-active-bg); color: var(--c-active-fg);
}
.copilot__title { margin: 0; font-size: 14px; font-weight: 700; }
.copilot__subtitle { margin: 2px 0 0; font-size: 11.5px; opacity: .75; }
.copilot__head-actions { display: flex; gap: 2px; }
.copilot__icon-btn {
    background: transparent; border: 0; color: inherit;
    width: 28px; height: 28px; border-radius: 6px;
    line-height: 1; cursor: pointer; opacity: .82;
    display: inline-flex; align-items: center; justify-content: center;
    padding: 0;
}
.copilot__icon-btn:hover, .copilot__icon-btn:focus-visible {
    background: color-mix(in srgb, var(--c-active-fg) 14%, transparent);
    opacity: 1; outline: none;
}
.copilot__icon-expand   { display: block; }
.copilot__icon-collapse { display: none; }
.copilot.is-expanded .copilot__icon-expand   { display: none; }
.copilot.is-expanded .copilot__icon-collapse { display: block; }

.copilot__messages {
    flex: 1; overflow-y: auto; padding: 14px;
    display: flex; flex-direction: column; gap: 10px;
    font-size: 14px; line-height: 1.45;
    background: var(--c-bg);
}
.copilot__greeting { background: var(--c-surface); border: 1px solid var(--c-border); border-radius: 8px; padding: 10px 12px; color: var(--c-muted); font-size: 13px; }
.copilot__msg {
    padding: 9px 12px; border-radius: 10px; max-width: 88%;
    white-space: pre-wrap; overflow-wrap: anywhere;
}
.copilot__msg--user      { align-self: flex-end; background: var(--c-primary); color: var(--c-on-primary); }
.copilot__msg--assistant { align-self: flex-start; background: var(--c-surface); border: 1px solid var(--c-border); color: var(--c-text); }

/* Bouncing-dots "typing" indicator shown while waiting for Claude. */
.copilot__typing { padding: 12px 14px; }
.copilot__dots { display: inline-flex; gap: 4px; align-items: center; height: 16px; }
.copilot__dots span {
    width: 7px; height: 7px; border-radius: 50%;
    background: var(--c-muted); opacity: .55;
    animation: copilot-bounce 1.2s infinite ease-in-out both;
}
.copilot__dots span:nth-child(1) { animation-delay: -0.32s; }
.copilot__dots span:nth-child(2) { animation-delay: -0.16s; }
@keyframes copilot-bounce {
    0%, 80%, 100% { transform: translateY(0);   opacity: .35; }
    40%           { transform: translateY(-4px); opacity: .95; }
}
@media (prefers-reduced-motion: reduce) {
    .copilot__dots span { animation: none; opacity: .55; }
}

/* Global "AI is working" overlay shown over the whole viewport while
   any AI request is in flight. Driven by SysRevAI.showAiOverlay()
   from app.js. */
.ai-overlay {
    position: fixed; inset: 0; z-index: 60;
    display: flex; align-items: center; justify-content: center;
    background: rgba(7, 14, 22, 0.55);
    backdrop-filter: blur(2px);
    animation: ai-overlay-fade .15s ease-out;
}
.ai-overlay__card {
    background: var(--c-surface); color: var(--c-text);
    border-radius: var(--radius);
    box-shadow: 0 24px 48px rgba(0,0,0,.35);
    padding: 36px 48px;
    display: flex; flex-direction: column; align-items: center; gap: 18px;
    text-align: center;
    min-width: 260px; max-width: 420px;
    border: 1px solid var(--c-border);
}
.ai-overlay__icon {
    color: var(--c-text);
    animation: ai-overlay-pulse 1.8s infinite ease-in-out;
}
.ai-overlay__title { margin: 0; font-size: 22px; font-weight: 700; line-height: 1.2; }
.ai-overlay__dots { display: inline-flex; gap: 6px; align-items: center; height: 12px; }
.ai-overlay__dots span {
    width: 10px; height: 10px; border-radius: 50%;
    background: var(--c-primary);
    animation: copilot-bounce 1.2s infinite ease-in-out both;
}
.ai-overlay__dots span:nth-child(1) { animation-delay: -0.32s; }
.ai-overlay__dots span:nth-child(2) { animation-delay: -0.16s; }
@keyframes ai-overlay-fade {
    from { opacity: 0; }
    to   { opacity: 1; }
}
@keyframes ai-overlay-pulse {
    0%, 100% { transform: scale(1);    opacity: .9; }
    50%      { transform: scale(1.07); opacity: 1;  }
}
@media (prefers-reduced-motion: reduce) {
    .ai-overlay { animation: none; }
    .ai-overlay__icon { animation: none; }
    .ai-overlay__dots span { animation: none; opacity: .55; }
}

.copilot__form {
    display: flex; gap: 8px; padding: 10px; border-top: 1px solid var(--c-border);
    background: var(--c-surface);
}
.copilot__input { flex: 1; resize: none; font-size: 13.5px; padding: 8px 10px; }

@media (max-width: 480px) {
    .copilot { right: 12px; bottom: 12px; }
    .copilot__panel { right: 0; bottom: 60px; width: calc(100vw - 24px); height: 70vh; }
    .copilot.is-expanded .copilot__panel { width: calc(100vw - 24px); height: 85vh; }
}

/* Content / page */
.content { max-width: 1080px; margin: 0 auto; padding: 32px 24px 64px; }
.page__head { margin-bottom: 24px; }
.page__title { margin: 0 0 4px; font-size: 26px; }
.page__subtitle { margin: 0; color: var(--c-muted); }

/* Metrics */
.metrics {
    display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
    gap: 16px; margin-bottom: 32px;
}
.metric {
    background: var(--c-surface); border: 1px solid var(--c-border);
    border-radius: var(--radius); box-shadow: var(--shadow);
    padding: 20px; display: flex; flex-direction: column; gap: 6px;
}
.metric__value { font-size: 30px; font-weight: 700; line-height: 1; }
.metric__label { font-size: 13px; color: var(--c-muted); }

.page--narrow { max-width: 760px; }
.page__head--row { display: flex; justify-content: space-between; align-items: flex-start; gap: 16px; }
.breadcrumb { font-size: 13px; margin-bottom: 4px; }
.breadcrumb a { color: var(--c-muted); }

/* Review cards */
.cards { display: grid; grid-template-columns: repeat(auto-fill, minmax(280px, 1fr)); gap: 16px; }
.review-card {
    display: block; background: var(--c-surface); border: 1px solid var(--c-border);
    border-radius: var(--radius); box-shadow: var(--shadow); padding: 18px; color: inherit;
}
.review-card:hover { text-decoration: none; border-color: var(--c-primary); }
.review-card__head { display: flex; justify-content: space-between; align-items: flex-start; gap: 10px; }
.review-card__title { margin: 0; font-size: 17px; }
.review-card__q { color: var(--c-muted); font-size: 14px; margin: 8px 0 12px; }
.review-card__meta { display: flex; gap: 8px; flex-wrap: wrap; }

/* Tags */
.tag { display: inline-block; padding: 2px 9px; border-radius: 999px; font-size: 12px; font-weight: 600; }
.tag--active { background: var(--c-tag-active-bg); color: var(--c-tag-active-fg); }
.tag--archived { background: var(--c-tag-soft-bg); color: var(--c-tag-soft-fg); }
.tag--completed { background: var(--c-tag-completed-bg); color: var(--c-tag-completed-fg); }
.tag--soft { background: var(--c-tag-soft-bg); color: var(--c-tag-soft-fg); }

/* Review detail */
.grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 20px; }
.grid-2 .section-card p { font-size: 14px; }
.member-list, .reason-list { list-style: none; margin: 0; padding: 0; }
.member-list li { display: flex; justify-content: space-between; align-items: center; gap: 10px; padding: 7px 0; border-bottom: 1px solid var(--c-border); font-size: 14px; }
.member-list li:last-child { border-bottom: 0; }
.reason-list li { padding: 5px 0; font-size: 14px; border-bottom: 1px solid var(--c-border); }
.reason-list li:last-child { border-bottom: 0; }

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

/* Empty state */
.empty-state {
    background: var(--c-surface); border: 1px dashed var(--c-border);
    border-radius: var(--radius); padding: 48px 24px; text-align: center;
}
.empty-state p { color: var(--c-muted); margin: 0 0 16px; }

/* Auth + error pages */
.auth-body { display: flex; min-height: 100vh; align-items: center; justify-content: center; }
.auth-wrap { width: 100%; max-width: 380px; padding: 24px; }
.auth-brand { display: flex; align-items: center; justify-content: center; gap: 10px; margin-bottom: 20px; }
.auth-card {
    background: var(--c-surface); border: 1px solid var(--c-border);
    border-radius: var(--radius); box-shadow: var(--shadow); padding: 28px;
}
.auth-card--center { text-align: center; }
.auth-card__title { margin: 0 0 18px; font-size: 22px; }
.error-code { font-size: 56px; font-weight: 800; color: var(--c-primary); line-height: 1; margin-bottom: 8px; }
.lead { color: var(--c-muted); }

/* Forms */
.form-grid { display: flex; flex-direction: column; gap: 16px; }
.field { display: flex; flex-direction: column; }
.field-label { font-weight: 600; font-size: 14px; margin-bottom: 6px; }
.input {
    width: 100%; padding: 10px 12px; font-size: 15px; font-family: inherit;
    border: 1px solid var(--c-border); border-radius: 8px;
    background: var(--c-surface); color: var(--c-text);
}
.input:focus { outline: 2px solid var(--c-primary); outline-offset: 1px; }

/* Alerts */
.alert { border-radius: 8px; padding: 12px 16px; margin-bottom: 16px; font-size: 14px; }
.alert--error { background: var(--c-alert-error-bg); border: 1px solid var(--c-alert-error-bd); color: var(--c-alert-error-fg); }
.alert--success { background: var(--c-alert-success-bg); border: 1px solid var(--c-alert-success-bd); color: var(--c-alert-success-fg); }

.badge { display: inline-block; padding: 2px 8px; border-radius: 999px; font-size: 12px; font-weight: 700; letter-spacing: .3px; }
.badge--ok   { background: var(--c-tag-active-bg); color: var(--c-tag-active-fg); }
.badge--fail { background: var(--c-alert-error-bg); color: var(--c-alert-error-fg); }

/* Buttons */
.btn {
    display: inline-flex; align-items: center; justify-content: center; gap: 6px;
    padding: 11px 20px; border-radius: 8px; border: 1px solid transparent;
    font-family: inherit; font-size: 15px; font-weight: 600; cursor: pointer; text-decoration: none;
    transition: background .15s ease, border-color .15s ease, opacity .15s ease;
}
.btn:hover { text-decoration: none; }
.btn.is-busy, .btn[disabled] { cursor: progress; opacity: .75; }
.btn--sm { padding: 7px 12px; font-size: 13px; }
.btn--xs { padding: 4px 10px; font-size: 12.5px; border-radius: 6px; }
.btn--block { width: 100%; }
.btn--primary { background: var(--c-primary); color: var(--c-on-primary); }
.btn--primary:hover { background: var(--c-primary-d); }
.btn--ghost { background: var(--c-surface); border-color: var(--c-border); color: var(--c-text); }
.btn--ghost:hover { border-color: var(--c-muted); }

/* Footer + donate */
.appfooter {
    display: flex; align-items: center; justify-content: center; gap: 14px;
    padding: 20px; color: var(--c-muted); font-size: 13px;
    border-top: 1px solid var(--c-border);
}
.donate { color: #c2487f; font-weight: 600; }
.donate:hover { color: #a23667; }

.topbar__nav a.is-active { color: var(--c-text); font-weight: 600; }

/* Exports */
.prisma-preview { background: var(--c-surface); border: 1px solid var(--c-border); border-radius: 8px; padding: 14px; overflow: auto; margin: 8px 0 14px; }
.prisma-preview svg { display: block; max-width: 100%; height: auto; }

/* Summaries + translation */
.translate-block { }
.translate-block__head { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-bottom: 10px; flex-wrap: wrap; }
.translate-controls { display: flex; gap: 8px; align-items: center; }
.translate-result { margin-top: 12px; padding: 12px 14px; background: var(--c-tag-completed-bg); border: 1px solid var(--c-alert-success-bd); border-radius: 8px; white-space: pre-wrap; font-size: 14px; }
.summary-dl dt { font-weight: 600; margin-top: 10px; font-size: 14px; }
.summary-dl dd { margin: 4px 0 0; }
.small { font-size: 12px; }

/* Risk of bias */
.rob-summary { max-width: 720px; margin: 8px 0 16px; }
.rob-legend { display: flex; gap: 14px; flex-wrap: wrap; font-size: 13px; color: var(--c-muted); }
.rob-legend__item { display: inline-flex; align-items: center; gap: 6px; }
.rob-cell { display: inline-block; width: 16px; height: 16px; border-radius: 50%; vertical-align: middle; border: 1px solid rgba(0,0,0,.08); }
.rob-cell-td { text-align: center; }
.rob-table th { white-space: nowrap; }
.rob-domain { padding: 14px 0; border-bottom: 1px solid var(--c-border); }
.rob-domain:last-child { border-bottom: 0; }
.rob-domain__title { margin: 0 0 8px; font-size: 15px; }
.rob-domain__actions { display: flex; align-items: center; gap: 10px; margin-top: 8px; }

/* Full-text retrieval — references list + queue */
.ft-dot { display: inline-block; width: 12px; height: 12px; border-radius: 50%; vertical-align: middle; margin-right: 6px; border: 1px solid rgba(0,0,0,.1); cursor: help; }
.ft-dot--ok { background: var(--c-ok); }
.ft-dot--none { background: var(--c-warn); }
.ft-dot--queued { background: var(--c-primary); }
.ft-dot--never { background: #dde3e9; }
.tag--pending { background: var(--c-tag-soft-bg); color: var(--c-tag-soft-fg); }
.tag--processing { background: var(--c-tag-completed-bg); color: var(--c-tag-completed-fg); }
.tag--completed { background: var(--c-tag-active-bg); color: var(--c-tag-active-fg); }
.tag--failed { background: #fbe9e1; color: var(--c-fail); }

/* Full-text retrieval admin */
.ft-source { padding: 14px 0; border-bottom: 1px solid var(--c-border); }
.ft-source:last-of-type { border-bottom: 0; }
.ft-source__actions { display: flex; align-items: center; gap: 12px; margin-top: 10px; }
.ft-source__status { font-size: 13px; }
.ft-test-result { margin-top: 14px; padding: 12px 14px; background: #0f1b26; color: #d6e2ec; border-radius: 8px; font-family: ui-monospace, "SFMono-Regular", Menlo, Consolas, monospace; font-size: 12px; white-space: pre-wrap; max-height: 320px; overflow: auto; }

/* Extraction template editor */
.tpl-row { border: 1px solid var(--c-border); border-radius: 8px; padding: 14px; margin-bottom: 12px; background: var(--c-surface); }
.tpl-row__actions { margin-top: 8px; }
.tpl-options { margin-top: 10px; }
.compare-row { padding: 8px 0; border-bottom: 1px solid var(--c-border); }
.compare-row summary { cursor: pointer; display: flex; gap: 8px; align-items: center; font-size: 14px; }
.compare-row .kv { margin-top: 8px; font-size: 13px; }
.tag--draft { background: var(--c-tag-soft-bg); color: var(--c-tag-soft-fg); }
.tag--submitted { background: var(--c-tag-completed-bg); color: var(--c-tag-completed-fg); }
.tag--approved { background: var(--c-tag-active-bg); color: var(--c-tag-active-fg); }

/* Full-text screening */
.ft-layout { display: grid; grid-template-columns: minmax(0, 1fr) 360px; gap: 20px; align-items: start; }
.ft-main { min-width: 0; }
.ft-aside { display: flex; flex-direction: column; gap: 14px; }
.pdf-viewer { margin: 16px 0; border: 1px solid var(--c-border); border-radius: 8px; overflow: hidden; }
.pdf-viewer iframe { display: block; border: 0; background: var(--c-surface-2); }
.chat-panel { background: var(--c-surface); border: 1px solid var(--c-border); border-radius: var(--radius); padding: 18px; }
.chat-history { max-height: 320px; overflow-y: auto; display: flex; flex-direction: column; gap: 8px; padding: 8px 0; margin-bottom: 10px; }
.chat-msg { padding: 8px 12px; border-radius: 10px; font-size: 14px; max-width: 92%; white-space: pre-wrap; }
.chat-msg--user { background: var(--c-primary); color: var(--c-on-primary); align-self: flex-end; }
.chat-msg--assistant { background: var(--c-bg); color: var(--c-text); align-self: flex-start; border: 1px solid var(--c-border); }
.chat-form { display: flex; flex-direction: column; gap: 8px; }
.chat-form .btn { align-self: flex-end; }
@media (max-width: 880px) { .ft-layout { grid-template-columns: 1fr; } }

/* AI suggestion panel */
.ai-suggest { margin-top: 16px; }
.ai-suggest__panel { margin-top: 10px; padding: 12px 14px; border-radius: 8px; font-size: 14px; background: var(--c-bg); border: 1px solid var(--c-border); }
.ai-suggest__panel.is-include { background: var(--c-tag-active-bg); border-color: var(--c-alert-success-bd); }
.ai-suggest__panel.is-exclude { background: #fbe9e1; border-color: #f3c4a9; }
.ai-suggest__panel.is-maybe { background: var(--c-alert-warn-bg); border-color: var(--c-alert-warn-bd); }

/* Screening */
.screen-progress { display: flex; align-items: center; gap: 14px; margin-bottom: 20px; }
.screen-progress .progress { flex: 1; }
.screen-grid { display: grid; grid-template-columns: 1fr 300px; gap: 20px; align-items: start; }
.screen-card { background: var(--c-surface); border: 1px solid var(--c-border); border-radius: var(--radius); box-shadow: var(--shadow); padding: 28px; }
.screen-card__title { margin: 0 0 8px; font-size: 21px; line-height: 1.3; }
.screen-card__meta { margin: 0 0 18px; }
.screen-card__abstract { font-size: 15px; line-height: 1.65; max-height: 50vh; overflow-y: auto; }
.screen-actions { margin-top: 22px; border-top: 1px solid var(--c-border); padding-top: 18px; display: flex; flex-direction: column; gap: 12px; }
.screen-reason { display: flex; flex-direction: column; }
.decision-buttons { display: flex; gap: 10px; }
.decision-buttons .btn { flex: 1; justify-content: center; }
.btn--include { background: var(--c-ok); color: #fff; }
.btn--include:hover { background: #007a59; }
.btn--maybe { background: var(--c-warn); color: #fff; }
.btn--maybe:hover { background: #c98a00; }
.btn--exclude { background: var(--c-fail); color: #fff; }
.btn--exclude:hover { background: #b34e00; }
kbd { background: rgba(255,255,255,.25); border-radius: 4px; padding: 1px 5px; font-size: 11px; margin-left: 4px; }
.screen-protocol { background: var(--c-surface); border: 1px solid var(--c-border); border-radius: var(--radius); padding: 18px; font-size: 14px; }
.screen-protocol p { margin: 0 0 10px; }
.screen-legend { margin-top: 14px; font-size: 12px; }
.decision-rows { list-style: none; margin: 12px 0; padding: 0; }
.decision-rows li { display: flex; align-items: center; gap: 8px; padding: 6px 0; font-size: 14px; flex-wrap: wrap; }
.tag--include { background: var(--c-tag-active-bg); color: var(--c-tag-active-fg); }
.tag--exclude { background: #fbe9e1; color: var(--c-fail); }
.tag--maybe { background: var(--c-alert-warn-bg); color: var(--c-alert-warn-fg); }
.alert--warn { background: var(--c-alert-warn-bg); border: 1px solid var(--c-alert-warn-bd); color: var(--c-alert-warn-fg); }
.coord-banner { display: flex; align-items: center; gap: 12px; justify-content: space-between; }
@media (max-width: 760px) { .screen-grid { grid-template-columns: 1fr; } }

/* Import / references */
.toolbar { display: flex; gap: 10px; align-items: center; margin-bottom: 16px; flex-wrap: wrap; }
.toolbar .input { max-width: 280px; }
.pager { display: flex; gap: 14px; align-items: center; justify-content: center; margin-top: 18px; }

/* Duplicate resolution */
.dup-pair { display: grid; grid-template-columns: 1fr 1fr auto; gap: 18px; align-items: center; }
.dup-side { display: flex; flex-direction: column; gap: 2px; font-size: 14px; }
.dup-side strong { font-size: 15px; }
.dup-meta { display: flex; flex-direction: column; gap: 8px; align-items: flex-end; }
@media (max-width: 700px) { .dup-pair { grid-template-columns: 1fr; } .dup-meta { align-items: flex-start; } }

/* Notification bell */
.bell { position: relative; }
.bell__btn { position: relative; display: inline-flex; align-items: center; color: var(--c-muted); padding: 6px; }
.bell__btn:hover { color: var(--c-text); }
.bell__badge {
    position: absolute; top: -2px; right: -4px; min-width: 16px; height: 16px;
    padding: 0 4px; border-radius: 999px; background: var(--c-fail); color: #fff;
    font-size: 10px; font-weight: 700; display: inline-flex; align-items: center; justify-content: center;
}
.bell__dropdown {
    position: absolute; right: 0; top: 40px; width: 320px; max-width: 90vw;
    background: var(--c-surface); border: 1px solid var(--c-border); border-radius: var(--radius);
    box-shadow: var(--shadow); z-index: 50; overflow: hidden;
}
.bell__head { padding: 10px 14px; font-weight: 600; font-size: 13px; border-bottom: 1px solid var(--c-border); }
.bell__list { max-height: 320px; overflow-y: auto; }
.bell__item { display: block; padding: 10px 14px; border-bottom: 1px solid var(--c-border); color: inherit; font-size: 13px; }
.bell__item:hover { background: var(--c-bg); text-decoration: none; }
.bell__item.is-unread { background: var(--c-tag-completed-bg); }
.bell__item strong { display: block; }
.bell__item span { color: var(--c-muted); }
.bell__empty { padding: 18px; text-align: center; color: var(--c-muted); }
.bell__all { display: block; padding: 10px 14px; text-align: center; font-size: 13px; font-weight: 600; }

/* Notifications page */
.tabs { display: flex; gap: 6px; margin-bottom: 16px; border-bottom: 1px solid var(--c-border); }
.tab { padding: 8px 14px; color: var(--c-muted); font-weight: 500; border-bottom: 2px solid transparent; }
.tab:hover { text-decoration: none; color: var(--c-text); }
.tab.is-active { color: var(--c-primary); border-bottom-color: var(--c-primary); }
.notif-list { list-style: none; margin: 0; padding: 0; }
.notif-item { border-bottom: 1px solid var(--c-border); }
.notif-item.is-unread { background: var(--c-tag-completed-bg); }
.notif-item__form { margin: 0; }
.notif-item__btn { display: block; width: 100%; text-align: left; background: none; border: 0; padding: 14px 18px; cursor: pointer; font: inherit; }
.notif-item__msg { display: block; color: var(--c-muted); font-size: 14px; margin: 2px 0; }
.notif-item__time { font-size: 12px; }

/* Comments */
.comment-list { list-style: none; margin: 0 0 18px; padding: 0; }
.comment { padding: 12px 0; border-bottom: 1px solid var(--c-border); }
.comment__head { display: flex; align-items: center; gap: 8px; font-size: 13px; margin-bottom: 4px; }
.comment__del { margin-left: auto; }
.link-del { background: none; border: 0; color: var(--c-muted); cursor: pointer; font-size: 18px; line-height: 1; }
.link-del:hover { color: var(--c-fail); }
.comment__body { font-size: 14px; }
.invite-link { display: inline-block; word-break: break-all; background: var(--c-bg); padding: 4px 8px; border-radius: 6px; font-size: 13px; }

/* Admin layout */
.admin { display: flex; max-width: 1080px; margin: 0 auto; gap: 28px; padding: 28px 24px 64px; }
.admin__sidebar { flex: 0 0 220px; }
.admin__title { font-size: 14px; text-transform: uppercase; letter-spacing: .04em; color: var(--c-muted); margin: 4px 0 12px; }
.admin__nav { display: flex; flex-direction: column; gap: 2px; }
.admin__link {
    padding: 9px 12px; border-radius: 8px; color: var(--c-muted);
    font-weight: 500; font-size: 15px;
}
.admin__link:hover { background: var(--c-surface); color: var(--c-text); text-decoration: none; }
.admin__link.is-active { background: var(--c-surface); color: var(--c-primary); box-shadow: var(--shadow); }
.admin__content { flex: 1; min-width: 0; }

.section__title { margin: 0 0 16px; font-size: 22px; }
.section__subtitle { margin: 0 0 8px; font-size: 17px; }
.section__intro { color: var(--c-muted); margin: 0 0 18px; }

/* System dependency rows in Admin → Files. */
.dep-list { display: flex; flex-direction: column; gap: 10px; }
.dep-row {
    display: flex; align-items: center; flex-wrap: wrap; gap: 12px;
    padding: 12px 14px; border: 1px solid var(--c-border); border-radius: 8px;
    background: var(--c-surface-2);
}
.dep-row__label { display: flex; align-items: center; gap: 10px; flex: 1; min-width: 220px; }
.dep-row code { font-size: 12.5px; font-family: ui-monospace, monospace; opacity: .85; }
.checkbox.is-disabled { color: var(--c-muted); opacity: .7; cursor: not-allowed; }
.checkbox.is-disabled input { cursor: not-allowed; }
.section-card {
    background: var(--c-surface); border: 1px solid var(--c-border);
    border-radius: var(--radius); box-shadow: var(--shadow);
    padding: 24px; margin-bottom: 20px;
}
.section-card--inline { display: flex; align-items: center; gap: 16px; }

/* Collapsible card (Protocol / Team on the review overview). */
.collapse-card { padding: 0; overflow: hidden; }
.collapse-card__head {
    width: 100%;
    display: flex; align-items: center; justify-content: space-between;
    gap: 12px; padding: 16px 20px;
    background: transparent; border: 0; cursor: pointer; text-align: left;
    color: var(--c-text); font-family: inherit;
    font-size: 16px; font-weight: 600;
}
.collapse-card__head:hover { background: var(--c-surface-2); }
.collapse-card__head:focus-visible { outline: 2px solid var(--c-primary); outline-offset: -2px; }
.collapse-card__head .icon--chevron {
    color: var(--c-muted);
    transition: transform .2s ease;
}
.collapse-card.is-collapsed .collapse-card__head .icon--chevron { transform: rotate(-90deg); }
.collapse-card__title { display: inline-flex; align-items: center; gap: 8px; }
.collapse-card__body { padding: 6px 20px 20px; border-top: 1px solid var(--c-border); font-size: 13.5px; }

/* Protocol body: grid of icon-card items per PICO + wide rows for the
   research question, inclusion / exclusion criteria. */
.protocol-body { display: flex; flex-direction: column; gap: 12px; }
.protocol-grid {
    display: grid; grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
    gap: 10px;
}
.protocol-item {
    display: flex; gap: 10px; align-items: flex-start;
    padding: 10px 12px; border: 1px solid var(--c-border); border-radius: 8px;
    background: var(--c-surface-2);
}
.protocol-item--wide { grid-column: 1 / -1; }
.protocol-item__icon {
    flex: 0 0 28px; width: 28px; height: 28px; border-radius: 6px;
    display: inline-flex; align-items: center; justify-content: center;
    background: var(--c-surface); color: var(--c-text);
    border: 1px solid var(--c-border);
}
.protocol-item__label {
    font-size: 11px; text-transform: uppercase; letter-spacing: .04em;
    color: var(--c-muted); font-weight: 600; margin-bottom: 2px;
}
.protocol-item__value { color: var(--c-text); font-size: 13.5px; line-height: 1.5; word-break: break-word; }
.protocol-item--include .protocol-item__icon { background: var(--c-tag-active-bg); color: var(--c-tag-active-fg); border-color: transparent; }
.protocol-item--exclude .protocol-item__icon { background: var(--c-alert-error-bg); color: var(--c-alert-error-fg); border-color: transparent; }

.team-block + .team-block { margin-top: 16px; }
.team-block__head { display: flex; align-items: center; gap: 8px; margin-bottom: 8px; }
.team-block__title { margin: 0; font-size: 13.5px; font-weight: 700; color: var(--c-text); }

/* Discussion card title with the chat icon inline. */
.discussion-card__title { display: flex; align-items: center; gap: 8px; }

.form-row { display: flex; }
.form-row--split { gap: 16px; }
.form-row--split > .field { flex: 1; }
.select {
    width: 100%; padding: 10px 12px; font-size: 15px; font-family: inherit;
    border: 1px solid var(--c-border); border-radius: 8px; background: var(--c-surface); color: var(--c-text);
}
.select:focus { outline: 2px solid var(--c-primary); outline-offset: 1px; }
.input--color { padding: 4px; height: 42px; }
.field-help { font-size: 12px; color: var(--c-muted); margin-top: 4px; }
.checkbox { display: flex; align-items: center; gap: 8px; font-size: 14px; cursor: pointer; }
.checkbox input { width: 16px; height: 16px; }

.toggles { border: 1px solid var(--c-border); border-radius: 8px; padding: 14px 16px; display: flex; flex-direction: column; gap: 10px; }
.toggles legend { font-weight: 600; font-size: 14px; padding: 0 6px; }

.actions { display: flex; justify-content: space-between; align-items: center; gap: 12px; }
.actions--start { justify-content: flex-start; }

.kv { display: grid; grid-template-columns: max-content 1fr; gap: 8px 24px; margin: 0; }
.kv dt { color: var(--c-muted); font-weight: 600; }
.kv dd { margin: 0; }
.link-ext { font-size: 14px; }

.field--narrow { max-width: 130px; }
textarea.input { resize: vertical; font-family: inherit; line-height: 1.5; }
.input--color { padding: 4px; height: 42px; width: 80px; }
.checkbox-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(110px, 1fr)); gap: 8px; }
.api-block { padding: 14px 0; border-bottom: 1px solid var(--c-border); }
.api-block:last-of-type { border-bottom: 0; }
.api-block .section__subtitle { margin: 0 0 10px; }
.api-help {
    margin: -4px 0 12px; padding: 10px 12px;
    background: var(--c-surface-2); border: 1px solid var(--c-border); border-radius: 6px;
    font-size: 13px; color: var(--c-muted); line-height: 1.45;
}
.api-help a { font-weight: 600; white-space: nowrap; }
.btn-row { display: flex; gap: 10px; flex-wrap: wrap; }
.muted { color: var(--c-muted); font-size: 13px; }

/* Buttons: danger */
.btn--danger { background: #fbe9e1; border-color: #f3c4a9; color: var(--c-fail); }
.btn--danger:hover { background: #f7d8c8; }

/* Tables */
.table-wrap { overflow-x: auto; }
.table { width: 100%; border-collapse: collapse; font-size: 14px; }
.table th, .table td { text-align: left; padding: 10px 12px; border-bottom: 1px solid var(--c-border); vertical-align: top; }
.table th { color: var(--c-muted); font-weight: 600; font-size: 12px; text-transform: uppercase; letter-spacing: .03em; }
.row-form { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.row-actions { display: flex; gap: 8px; align-items: center; }
.select--sm { width: auto; padding: 6px 10px; font-size: 13px; }

@media (max-width: 640px) {
    .topbar { gap: 12px; padding: 0 14px; }
    .topbar__nav { gap: 12px; }
    .topbar__name { display: none; }
    .admin { flex-direction: column; gap: 16px; }
    .admin__sidebar { flex: none; }
    .admin__nav { flex-direction: row; flex-wrap: wrap; }
    .form-row--split { flex-direction: column; gap: 16px; }
}
