/* Manuscribbl Core styles. Colours are variables so they can be matched to the theme in one place. */
:root {
	--msb-accent: #0073aa;
	--msb-accent-dark: #005177;
	--msb-text: #1e293b;
	--msb-muted: #64748b;
	--msb-border: #e2e8f0;
	--msb-surface: #f8fafc;
	--msb-danger: #b91c1c;
	--msb-ok-bg: #dcfce7;
	--msb-ok: #166534;
	--msb-warn-bg: #fef3c7;
	--msb-warn: #92400e;
	--msb-viewer-bg: #525659;
}

/* ---------- Generic ---------- */
.msb-card { background: var(--msb-surface); border: 1px solid var(--msb-border); border-radius: 8px; padding: 20px 24px; margin: 0 0 24px; color: var(--msb-text); line-height: 1.6; }
.msb-card h2, .msb-card h3 { margin-top: 0; }
.msb-center { text-align: center; max-width: 650px; margin-left: auto; margin-right: auto; }
.msb-note { background: var(--msb-warn-bg); color: var(--msb-warn); border-color: #fde68a; }
.msb-error { background: #fff1f0; color: var(--msb-danger); border-color: #ffa39e; }
.msb-help { color: var(--msb-muted); font-size: 0.92em; margin: 4px 0 12px; }
.msb-ok { color: var(--msb-ok); font-weight: 600; }
.msb-warn { color: var(--msb-warn); font-weight: 600; }
.msb-danger, a.msb-danger { color: var(--msb-danger); }
.msb-spacer { flex: 1 1 auto; }

.msb-button { display: inline-block; background: var(--msb-accent); color: #fff !important; border: 0; border-radius: 4px; padding: 10px 18px; font-weight: 600; font-size: 0.95em; line-height: 1.3; text-decoration: none !important; cursor: pointer; }
.msb-button:hover { background: var(--msb-accent-dark); }
.msb-button-plain { background: #f0f0f1; color: #333 !important; }
.msb-button-plain:hover { background: #e2e2e4; }
.msb-button-plain.msb-danger { color: var(--msb-danger) !important; }
.msb-button-dark { background: #1e293b; }
.msb-link-danger { background: none; border: 0; color: var(--msb-danger); cursor: pointer; font-weight: 600; padding: 0; }

.msb-inline-form { display: flex; flex-wrap: wrap; gap: 8px; justify-content: center; margin: 8px 0; }
.msb-inline-form input[type="email"] { flex: 1 1 220px; max-width: 320px; padding: 9px 10px; border: 1px solid #cbd5e1; border-radius: 4px; }
.msb-status { margin: 16px 0; }
.msb-steps { border-left: 4px solid var(--msb-accent); }
.msb-steps ol { padding-left: 20px; margin-bottom: 0; }
.msb-steps ol > li { margin-bottom: 14px; }
.msb-ideas { margin: 8px 0 4px; padding-left: 20px; list-style: disc; }
.msb-important { background: #fff3cd; border-color: #ffeeba; border-left: 4px solid #ffc107; color: #856404; }
.msb-important h4 { margin: 0 0 8px; color: #856404; text-transform: uppercase; letter-spacing: .5px; }
.msb-important ul { margin: 0; padding-left: 20px; }
.msb-tip { background: #e2e8f0; color: #4a5568; font-size: .95em; }
.msb-comment-notice { padding: 12px 16px; background: var(--msb-surface); border: 1px solid var(--msb-border); border-radius: 6px; }

/* ---------- Authors repeater ---------- */
.msb-authors { background: #f1f5f9; border: 1px solid #cbd5e1; border-radius: 8px; padding: 16px; }
.msb-author { background: #fff; border: 1px solid var(--msb-border); border-radius: 6px; padding: 12px 14px; margin-bottom: 12px; }
.msb-author-head { display: flex; justify-content: space-between; align-items: center; margin-bottom: 8px; color: #0284c7; text-transform: uppercase; font-size: 0.82em; }
.msb-author-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); gap: 12px; }
.msb-field { display: block; }
.msb-field span { display: block; font-size: 0.85em; font-weight: 600; color: #475569; margin-bottom: 4px; }
.msb-field input { width: 100%; box-sizing: border-box; padding: 8px; border: 1px solid #ccc; border-radius: 4px; }
.msb-icon-button { background: none; border: 1px solid transparent; border-radius: 4px; padding: 2px 8px; cursor: pointer; color: var(--msb-muted); font-size: 1em; }
.msb-icon-button:hover { border-color: var(--msb-border); color: var(--msb-text); }

.msb-doi-bar { display: flex; flex-wrap: wrap; align-items: center; gap: 10px; margin-top: 8px; }
.msb-doi-bar .msb-help { margin: 0; flex: 1 1 260px; }
.msb-doi-bar .msb-button[disabled] { opacity: .6; cursor: wait; }

/* ROR autocomplete */
.msb-ror-wrap { position: relative; }
.msb-ror-list { position: absolute; top: 100%; left: 0; right: 0; z-index: 99999; margin: 0; padding: 0; list-style: none; background: #fff; border: 1px solid #dcdcdc; border-top: 0; border-radius: 0 0 6px 6px; box-shadow: 0 4px 12px rgba(0,0,0,.1); max-height: 220px; overflow-y: auto; }
.msb-ror-list li { padding: 9px 12px; cursor: pointer; font-size: 14px; color: #333; border-bottom: 1px solid #f0f0f0; }
.msb-ror-list li:hover { background: #f4f6f8; }
.msb-ror-country { font-size: 12px; color: #777; }

/* ---------- Studio & viewer ---------- */
.msb-studio, .msb-viewer { background: #fff; border: 1px solid var(--msb-border); border-radius: 8px; padding: 16px; margin: 20px 0 30px; box-sizing: border-box; color: var(--msb-text); }
.msb-studio { border: 2px solid var(--msb-accent); }
.msb-studio[hidden] { display: none; }
.msb-studio-head { display: flex; justify-content: space-between; align-items: flex-start; gap: 12px; flex-wrap: wrap; }
.msb-studio-head h3 { margin: 0; color: var(--msb-accent); }

.msb-toolbar { display: flex; flex-wrap: wrap; align-items: center; gap: 6px; padding: 10px; margin: 10px 0; background: var(--msb-surface); border: 1px solid var(--msb-border); border-radius: 6px; }
.msb-tool { background: #fff; color: #334155; border: 1px solid #cbd5e1; border-radius: 4px; padding: 7px 12px; font-size: 0.9em; font-weight: 600; cursor: pointer; line-height: 1.2; }
.msb-tool:hover { background: #f1f5f9; }
.msb-tool.msb-on { background: var(--msb-accent); border-color: var(--msb-accent); color: #fff; }
.msb-tool.msb-danger { color: var(--msb-danger); border-color: #fca5a5; }
label.msb-tool[hidden] { display: none; }
.msb-palette { display: inline-flex; gap: 4px; margin: 0 6px; }
.msb-swatch { width: 24px; height: 24px; border-radius: 50%; border: 2px solid #fff; box-shadow: 0 0 0 1px #cbd5e1; cursor: pointer; padding: 0; }
.msb-swatch.msb-on { box-shadow: 0 0 0 2px var(--msb-text); }

.msb-import-bar { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; margin: 0 0 10px; padding: 10px 12px; background: #e0f2fe; border: 1px solid #7dd3fc; border-radius: 6px; font-size: .92em; }
.msb-import-bar[hidden] { display: none; }
.msb-import-bar span { flex: 1 1 280px; }
.msb-status-line { min-height: 1.2em; margin: 4px 0 8px; font-size: 0.92em; color: var(--msb-muted); }
.msb-status-line:empty { display: none; }

.msb-scroll { position: relative; background: var(--msb-viewer-bg); border-radius: 4px; padding: 16px; height: 75vh; min-height: 420px; overflow: auto; box-sizing: border-box; }
.msb-pages { display: flex; flex-direction: column; align-items: center; gap: 24px; padding-bottom: 24px; }

.msb-page { position: relative; flex: 0 0 auto; background: #fff; box-shadow: 0 4px 15px rgba(0,0,0,.3); outline: 3px solid transparent; }
.msb-page.msb-active { outline-color: #0ea5e9; }
.msb-page-bitmap { display: block; }
.msb-page .msb-layer { position: absolute !important; top: 0; left: 0; mix-blend-mode: multiply; } /* highlights tint the text like a marker */
.msb-annotations-hidden .msb-layer { visibility: hidden; }

/* Sticky notes */
.msb-note-pin { position: absolute; z-index: 3; background: transparent; border: 0; padding: 0; cursor: pointer; }
.msb-note-pin:focus-visible { outline: 2px solid var(--msb-accent); }
.msb-note-pop, .msb-note-editor { position: absolute; z-index: 4; width: 260px; max-width: calc(100% - 8px); box-sizing: border-box; background: #fef9c3; color: #1f2937; border: 1px solid #eab308; border-radius: 6px; box-shadow: 0 4px 12px rgba(0,0,0,.25); padding: 10px 12px; font-size: 13px; line-height: 1.45; }
.msb-note-pop { white-space: pre-wrap; max-height: 320px; overflow: auto; }
.msb-note-pop[hidden], .msb-note-editor[hidden] { display: none; }
.msb-note-editor textarea { width: 100%; box-sizing: border-box; border: 1px solid #eab308; border-radius: 4px; padding: 6px; font: inherit; background: #fff; resize: vertical; }
.msb-note-editor div { display: flex; gap: 6px; margin-top: 6px; }
.msb-annotations-hidden .msb-note-pin, .msb-annotations-hidden .msb-note-pop { display: none; }

.msb-extra-item { display: flex; flex-direction: column; align-items: center; gap: 6px; }
.msb-extra-head { display: flex; gap: 8px; align-items: center; color: #fff; font-weight: 600; }
.msb-head-button { background: rgba(255,255,255,.15); color: #fff; border: 1px solid rgba(255,255,255,.35); border-radius: 4px; padding: 2px 9px; cursor: pointer; font-size: .9em; }
.msb-head-button:hover { background: rgba(255,255,255,.3); }
a.msb-tool { text-decoration: none; display: inline-block; }
button.msb-tool[hidden] { display: none; }
.msb-byo-steps { text-align: left; display: inline-block; margin: 0; padding-left: 20px; }
.msb-byo-steps li { margin-bottom: 14px; }
.msb-byo-steps .msb-button { margin: 6px 6px 0 0; }

/* "New window" page */
.msb-standalone { margin: 0; background: #fff; font-family: system-ui, sans-serif; }
.msb-standalone-head { padding: 10px 16px; font-weight: 600; border-bottom: 1px solid var(--msb-border); }
.msb-standalone-head a { color: var(--msb-text); text-decoration: none; }
.msb-standalone .msb-viewer { margin: 0; border: 0; border-radius: 0; }
.msb-standalone .msb-scroll { height: calc(100vh - 140px); }

.msb-byo { background: #fff; border-radius: 8px; max-width: 640px; margin: 20px auto 30px; padding: 24px; text-align: center; }
.msb-byo[hidden] { display: none; }
.msb-byo h3 { margin-top: 0; }
.msb-viewer:fullscreen { display: flex; flex-direction: column; border-radius: 0; margin: 0; }
.msb-viewer:fullscreen .msb-scroll { flex: 1 1 auto; height: auto; }

.msb-fullscreen { position: fixed; inset: 0; z-index: 999999; margin: 0; border-radius: 0; display: flex; flex-direction: column; }
.msb-fullscreen .msb-scroll { flex: 1 1 auto; height: auto; }
html.msb-no-scroll, html.msb-no-scroll body { overflow: hidden; }

.msb-notes summary { cursor: pointer; font-weight: 600; }
.msb-notes ul { margin: 12px 0 0; padding-left: 20px; }
.msb-notes li { margin-bottom: 8px; }
.msb-notes-where { display: inline-block; font-size: 0.8em; color: var(--msb-muted); text-transform: uppercase; margin-right: 6px; }

/* ---------- Single page, library, dashboard ---------- */
.msb-meta ul { margin: 6px 0 12px; padding-left: 20px; }
.msb-meta > div { margin-bottom: 8px; }
.msb-controls { display: flex; gap: 10px; margin: 20px 0; }

.msb-filters { display: flex; flex-wrap: wrap; align-items: flex-end; gap: 10px 12px; padding: 16px; margin-bottom: 8px; background: var(--msb-surface); border: 1px solid var(--msb-border); border-radius: 8px; }
.msb-filters label { display: flex; flex-direction: column; gap: 4px; flex: 1 1 200px; min-width: 0; }
.msb-filters label > span { font-size: .82em; font-weight: 600; color: #475569; }
.msb-filters .msb-filter-search { flex: 2 1 280px; }
.msb-filters input[type="search"], .msb-filters select { width: 100%; box-sizing: border-box; padding: 9px 10px; border: 1px solid #cbd5e1; border-radius: 4px; background: #fff; font-size: .95em; }
.msb-filter-clear { align-self: center; }
.msb-filter-count { flex-basis: 100%; margin: 0; }
.msb-library-item { border-bottom: 1px solid #eee; padding: 22px 0; }
.msb-library-item h3 { margin: 0 0 10px; font-size: 1.4em; }
.msb-library-item h3 a { text-decoration: none; }
.msb-library-meta { color: #4b5563; font-size: 0.95rem; margin-bottom: 6px; }
.msb-library-actions { display: flex; flex-wrap: wrap; align-items: center; gap: 16px; margin-top: 12px; font-size: 0.95em; }
.msb-pagination { margin-top: 24px; text-align: center; }

.msb-dashboard ul { list-style: none; margin: 0; padding: 0; }
.msb-dashboard li { border-bottom: 1px solid #f0f0f0; padding: 14px 0; }
.msb-dashboard h3 { margin: 0 0 4px; font-size: 1.15rem; color: #000; display: flex; flex-wrap: wrap; align-items: center; gap: 10px; }
.msb-badge { font-size: 0.72rem; font-weight: 500; padding: 2px 8px; border-radius: 4px; border: 1px solid; }
.msb-badge-live { background: var(--msb-ok-bg); color: var(--msb-ok); border-color: #bbf7d0; }
.msb-badge-pending { background: #fff3cd; color: #856404; border-color: #ffeeba; }
.msb-badge-draft { background: #e2e8f0; color: #475569; border-color: #cbd5e1; }

@media (max-width: 600px) {
	.msb-card, .msb-studio, .msb-viewer { padding: 14px; }
	.msb-scroll { padding: 8px; height: 70vh; }
	.msb-tool { padding: 7px 9px; }
}
