/* Citavo app + auth UI — the "Sourced" identity (matches landing.css).
   Replaces the old dark site.css/app.css on the logged-in and auth pages.
   Self-contained; strict-CSP safe. */

@font-face { font-family: 'PlexMono'; src: url('/fonts/plex-mono-400.woff2') format('woff2'); font-weight: 400; font-display: swap; }
@font-face { font-family: 'PlexMono'; src: url('/fonts/plex-mono-500.woff2') format('woff2'); font-weight: 500; font-display: swap; }
@font-face { font-family: 'PlexSans'; src: url('/fonts/plex-sans-400.woff2') format('woff2'); font-weight: 400; font-display: swap; }
@font-face { font-family: 'PlexSans'; src: url('/fonts/plex-sans-600.woff2') format('woff2'); font-weight: 600; font-display: swap; }

:root {
  --paper: #F2F2EC; --card: #FBFBF7; --ink: #16191E; --slate: #565E68;
  --rule: #DEDFD6; --mark: #D6F24E; --mark-deep: #AEC931;
  --mono: 'PlexMono', ui-monospace, 'SFMono-Regular', Menlo, monospace;
  --sans: 'PlexSans', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
}
* { box-sizing: border-box; }
body { margin: 0; background: var(--paper); color: var(--ink); font-family: var(--sans); line-height: 1.6; -webkit-font-smoothing: antialiased; }
a { color: inherit; }
h1, h2, h3 { font-family: var(--mono); font-weight: 500; letter-spacing: -0.02em; line-height: 1.12; }
h1 { font-size: 1.7rem; }
h2 { font-size: 1.2rem; margin: 26px 0 10px; }
code { font-family: var(--mono); font-size: 0.88em; background: #E9EAE1; padding: 1px 5px; border-radius: 3px; }

/* Centered card layout (auth + app pages) */
.auth { min-height: 100vh; display: flex; flex-direction: column; align-items: center; padding: 40px 20px 60px; }
.auth-brand { font-family: var(--mono); font-weight: 500; font-size: 1.15rem; letter-spacing: -0.02em; display: inline-flex; align-items: center; gap: 8px; margin-bottom: 22px; }
.beat { width: 9px; height: 9px; border-radius: 2px; background: var(--mark); border: 1px solid var(--ink); }
.auth-card { width: 100%; max-width: 440px; background: var(--card); border: 1px solid var(--ink); border-radius: 3px; padding: 30px; box-shadow: 8px 8px 0 var(--mark); }
.auth-card-wide { max-width: 760px; }

/* Shared app top nav (injected by nav.js) */
.appnav { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 11px 20px; border-bottom: 1px solid var(--rule); background: var(--card); position: sticky; top: 0; z-index: 50; }
.appnav-brand { display: inline-flex; align-items: center; gap: 8px; font-family: var(--mono); font-weight: 500; font-size: 1.05rem; color: var(--ink); text-decoration: none; letter-spacing: -0.02em; }
.appnav-links { display: flex; align-items: center; gap: 4px; }
.appnav-links a { font-family: var(--mono); font-size: 0.82rem; color: var(--slate); text-decoration: none; padding: 6px 10px; border-radius: 2px; }
.appnav-links a:hover { color: var(--ink); }
.appnav-new { font-family: var(--mono); font-size: 0.82rem; color: var(--ink) !important; border: 1px solid var(--rule); border-radius: 2px; padding: 6px 10px; }
.appnav-new:hover { border-color: var(--ink); }
.appnav-dd { position: relative; display: inline-block; }
.appnav-dd-btn { font-family: var(--mono); font-size: 0.82rem; color: var(--slate); background: transparent; border: none; padding: 6px 10px; border-radius: 2px; cursor: pointer; }
.appnav-dd-btn:hover { color: var(--ink); }
.appnav-menu { position: absolute; top: calc(100% + 6px); left: 0; min-width: 220px; background: var(--card); border: 1px solid var(--ink); border-radius: 3px; box-shadow: 5px 5px 0 var(--mark); padding: 5px; z-index: 60; max-height: 340px; overflow-y: auto; }
.appnav-menu[hidden] { display: none; }
.appnav-menu a { display: block; padding: 7px 10px; font-family: var(--mono); font-size: 0.82rem; color: var(--ink); text-decoration: none; border-radius: 2px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.appnav-menu a:hover { background: #F0F1E4; }
.appnav-menu-new { border-top: 1px solid var(--rule); margin-top: 4px; color: var(--mark-deep) !important; }
.appnav-user { font-family: var(--mono); font-size: 0.76rem; color: var(--slate); margin: 0 6px 0 10px; max-width: 200px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.appnav-logout { font-family: var(--mono); font-size: 0.82rem; color: var(--ink); background: transparent; border: 1px solid var(--ink); border-radius: 2px; padding: 6px 12px; margin-left: 4px; cursor: pointer; }
.appnav-logout:hover { background: var(--ink); color: var(--paper); }
.appnav-logout:disabled { opacity: .5; cursor: default; }

.eyebrow { font-family: var(--mono); font-size: 0.72rem; letter-spacing: 0.02em; color: var(--slate); text-transform: lowercase; }
.eyebrow::before { content: '[ '; color: var(--mark-deep); }
.eyebrow::after { content: ' ]'; color: var(--mark-deep); }
.sub { color: var(--slate); font-size: 0.95rem; }
.help { color: var(--slate); font-size: 0.8rem; margin-top: 5px; }
/* Visually hidden but available to screen readers (accessible field labels). */
.sr-only { position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; border: 0; }
/* An inline, link-styled button (for "resend"/"start over" affordances inside copy). */
.linkbtn { background: none; border: 0; padding: 0; margin: 0; font: inherit; color: var(--ink); text-decoration: underline; cursor: pointer; }
.linkbtn:hover { opacity: 0.8; }
.linkbtn:disabled { cursor: default; opacity: 0.6; text-decoration: none; }
.faint { color: var(--slate); font-size: 0.82rem; word-break: break-word; }

/* Forms */
.field { margin: 14px 0; }
.field label { display: block; font-family: var(--mono); font-size: 0.78rem; color: var(--slate); margin-bottom: 6px; }
input, textarea, select {
  width: 100%; font: inherit; font-size: 0.95rem; padding: 10px 12px;
  border: 1px solid var(--rule); border-radius: 2px; background: #fff; color: var(--ink);
}
input:focus, textarea:focus, select:focus { outline: none; border-color: var(--ink); box-shadow: 0 0 0 3px rgba(174,201,49,.35); }
textarea { resize: vertical; }

/* Keyboard focus: a visible, on-brand ink outline for every interactive element
   that isn't a text field (buttons, links, chips, tabs). Mouse clicks stay clean
   via :focus-visible; only keyboard navigation shows the ring. */
.btn:focus-visible, a:focus-visible, .linkbtn:focus-visible, .chip:focus-visible,
button:focus-visible, [tabindex]:focus-visible, [role="button"]:focus-visible {
  outline: 2px solid var(--ink); outline-offset: 2px; border-radius: 2px;
}

/* Respect reduced-motion: kill transitions/animations and the smooth scroll. */
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: 0.01ms !important; animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important; scroll-behavior: auto !important;
  }
}

/* Show/hide password eye toggle (injected by password-toggle.js) */
.pw-wrap { position: relative; display: block; }
.pw-wrap input { padding-right: 42px; }
.pw-toggle {
  position: absolute; top: 0; right: 0; height: 100%; width: 40px;
  display: flex; align-items: center; justify-content: center;
  padding: 0; margin: 0; background: transparent; border: 0; border-radius: 0;
  color: var(--slate); cursor: pointer;
}
.pw-toggle:hover { color: var(--ink); }
.pw-toggle svg { width: 18px; height: 18px; display: block; }
/* Hide the browser's own native password-reveal control (Edge/IE) so it doesn't duplicate ours */
input[type="password"]::-ms-reveal, input[type="password"]::-ms-clear { display: none; }

/* Buttons */
.btn { display: inline-block; font-family: var(--mono); font-size: 0.9rem; padding: 11px 20px; border-radius: 2px; border: 1px solid var(--ink); cursor: pointer; background: transparent; color: var(--ink); transition: transform .08s ease, background .15s ease, color .15s ease; text-decoration: none; }
.btn:hover { transform: translateY(-1px); }
.btn-primary { background: var(--ink); color: var(--paper); }
.btn-primary:hover { background: #000; }
.btn-block { display: block; width: 100%; text-align: center; margin-top: 8px; }
.btn-sm { padding: 6px 13px; font-size: 0.8rem; }
.btn-danger { border-color: #B4472B; color: #B4472B; }
.btn-danger:hover { background: #B4472B; color: #fff; }
.danger-link { color: #B4472B; }

/* Links under forms */
.auth-alt { text-align: center; margin-top: 18px; font-size: 0.9rem; color: var(--slate); }
.auth-alt a { color: var(--ink); text-decoration: underline; }
.auth-legal { max-width: 440px; text-align: center; font-size: 0.75rem; color: var(--slate); margin-top: 18px; }

/* Banners */
.banner { padding: 10px 12px; border-radius: 2px; margin: 12px 0; font-size: 0.9rem; border: 1px solid; }
.banner-danger { background: #FBEDE7; border-color: #E0A78F; color: #8A3417; }
.banner-success { background: #F2F8DE; border-color: var(--mark-deep); color: #4C5A16; }
.banner-info, .banner-warning { background: #F0F1E8; border-color: var(--rule); color: var(--slate); }

/* Lists / badges / rows */
.list-item { border: 1px solid var(--rule); border-radius: 3px; padding: 12px 14px; margin: 10px 0; background: #fff; }
.list-item a { text-decoration: none; }
.row { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; margin-top: 8px; }
.row.between { justify-content: space-between; }
.badge { display: inline-block; font-family: var(--mono); font-size: 0.7rem; padding: 2px 9px; border-radius: 2px; border: 1px solid var(--rule); white-space: nowrap; }
.badge-success { color: #4C5A16; background: var(--mark); border-color: var(--mark-deep); }
.badge-danger { color: #8A3417; border-color: #E0A78F; }
.badge-neutral { color: var(--slate); }

/* Chat (hosted page + widget test) */
.chat-page { max-width: 720px; margin: 0 auto; height: 100vh; display: flex; flex-direction: column; padding: 0 16px; }
.chat-head { display: flex; align-items: center; gap: 10px; padding: 16px 4px; border-bottom: 1px solid var(--rule); font-family: var(--mono); font-size: 1.02rem; }
.ai-tag { margin-left: auto; font-family: var(--mono); font-size: 0.7rem; color: var(--slate); border: 1px solid var(--rule); border-radius: 2px; padding: 2px 9px; white-space: nowrap; }
.chat-messages { flex: 1; overflow-y: auto; padding: 18px 2px; display: flex; flex-direction: column; gap: 12px; }
.msg { max-width: 85%; padding: 11px 14px; border-radius: 3px; line-height: 1.5; white-space: pre-wrap; word-wrap: break-word; }
.msg-user { align-self: flex-end; background: var(--ink); color: var(--paper); }
.msg-assistant { align-self: flex-start; background: #fff; border: 1px solid var(--rule); border-left: 3px solid var(--mark); }
.msg-cites { margin-top: 8px; padding-top: 8px; border-top: 1px dashed var(--rule); font-family: var(--mono); font-size: 0.74rem; color: var(--slate); }
.msg-cites a { color: var(--mark-deep); }
.msg-thinking { color: var(--slate); font-style: italic; }
.msg-error { color: #B4472B; }
.chat-input { display: flex; gap: 8px; padding: 12px 0 8px; border-top: 1px solid var(--rule); }
.chat-input input { flex: 1; }
.chat-footer { text-align: center; font-family: var(--mono); font-size: 0.72rem; color: var(--slate); padding: 6px 0 12px; }
/* Owner preview toolbar on the public chat page (only shown with ?proj=) */
.owner-bar { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; padding: 10px 4px; border-bottom: 1px dashed var(--rule); }
.owner-bar-note { font-family: var(--mono); font-size: 0.66rem; color: var(--slate); margin-left: auto; text-transform: uppercase; letter-spacing: 0.06em; }

/* In-dashboard test chat */
.test-chat { margin-top: 18px; border: 1px solid var(--rule); border-radius: 3px; padding: 12px; }
.test-messages { max-height: 320px; overflow-y: auto; display: flex; flex-direction: column; gap: 10px; margin-bottom: 10px; }
.test-messages:empty { display: none; }

/* AI & data dashboard tiles + quick actions */
.dash { margin: 6px 0 20px; }
.dash-tiles { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; margin-bottom: 14px; }
.tile { border: 1px solid var(--rule); border-left: 3px solid var(--mark); border-radius: 3px; padding: 12px 14px; background: #fff; }
.tile-label { font-family: var(--mono); font-size: 0.7rem; text-transform: uppercase; letter-spacing: 0.05em; color: var(--slate); margin-bottom: 6px; }
.tile-value { font-size: 1.02rem; font-weight: 600; color: var(--ink); display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.tile-sub { font-size: 0.8rem; color: var(--slate); margin-top: 5px; line-height: 1.45; }
.tile-sub a { color: var(--mark-deep); }
.dash-actions { display: flex; flex-wrap: wrap; gap: 8px; }
.dash-ai { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; margin-bottom: 14px; padding: 10px 12px; border: 1px solid var(--rule); border-radius: 3px; background: #fff; }
.dash-ai label { font-family: var(--mono); font-size: 0.78rem; color: var(--slate); }
.dash-ai select { max-width: 260px; }
.dash-ai-hint { font-size: 0.78rem; color: var(--slate); }
.dash-ai-hint a { color: var(--mark-deep); }

/* Project header chip bar: [Local/Cloud] [AI: App/Personal] [Sources] */
.projbar { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; margin-bottom: 14px; }
.projbar-chip { display: inline-flex; align-items: center; gap: 6px; font-family: var(--mono); font-size: 0.8rem; color: var(--ink); background: #fff; border: 1px solid var(--rule); border-radius: 999px; padding: 6px 12px; text-decoration: none; white-space: nowrap; }
a.projbar-chip:hover { border-color: var(--ink); }
.chip-green { border-color: #8AB800; background: #F3F8E4; }
.chip-amber { border-color: #E3A008; background: #FBF3DE; }
.projbar-ai { padding: 2px 8px 2px 12px; }
.projbar-ai label { color: var(--slate); margin-right: 2px; }
.projbar-ai select { width: auto; border: none; background: transparent; font-family: var(--mono); font-size: 0.8rem; padding: 3px 4px; max-width: 200px; cursor: pointer; }
.projbar-ai select:focus { outline: none; box-shadow: none; }
.projbar-link { font-family: var(--mono); font-size: 0.78rem; color: var(--mark-deep); text-decoration: none; }
@media (max-width: 560px) { .dash-tiles { grid-template-columns: 1fr; } }

/* File drop zone */
.dropzone { position: relative; display: block; border: 1.5px dashed var(--rule); border-radius: 4px; background: #fff; padding: 22px 16px; text-align: center; cursor: pointer; transition: border-color .12s ease, background .12s ease; }
.dropzone:hover { border-color: var(--ink); }
.dropzone.is-drag { border-color: var(--ink); background: #FBFCF3; }
.dropzone.has-file { border-style: solid; text-align: left; }
.dropzone-input { position: absolute; width: 1px; height: 1px; opacity: 0; pointer-events: none; }
.dropzone-ico { width: 26px; height: 26px; color: var(--slate); margin-bottom: 8px; }
.dropzone.is-drag .dropzone-ico { color: var(--ink); }
.dropzone-lead { font-size: 0.92rem; color: var(--ink); }
.dropzone-link { color: var(--mark-deep); text-decoration: underline; }
.dropzone-hint { font-family: var(--mono); font-size: 0.72rem; color: var(--slate); margin-top: 6px; }
.dropzone-file { display: flex; align-items: center; gap: 10px; }
.df-name { font-weight: 600; font-size: 0.9rem; color: var(--ink); word-break: break-all; }
.df-size { font-family: var(--mono); font-size: 0.72rem; color: var(--slate); white-space: nowrap; }
.df-remove { margin-left: auto; border: 1px solid var(--rule); background: #fff; border-radius: 2px; width: 26px; height: 26px; cursor: pointer; color: var(--slate); font-size: 16px; line-height: 1; flex-shrink: 0; }
.df-remove:hover { color: var(--ink); border-color: var(--ink); }
.dropzone-progress { margin-top: 12px; }
.dropzone-status { font-family: var(--mono); font-size: 0.74rem; color: var(--slate); margin-bottom: 6px; }
.dropzone-track { height: 6px; background: #E9EAE1; border-radius: 3px; overflow: hidden; }
.dropzone-bar { height: 100%; width: 0%; background: var(--mark); transition: width .2s ease; }
.dropzone-bar.indet { width: 38%; animation: dz-indet 1.1s ease-in-out infinite; }
@keyframes dz-indet { 0% { margin-left: -38%; } 100% { margin-left: 100%; } }

/* Generic busy progress (deck drafting, etc.) */
.gen-progress { margin: 12px 0; }
.gen-status { font-family: var(--mono); font-size: 0.78rem; color: var(--slate); margin-bottom: 6px; }
.pbar-track { height: 6px; background: #E9EAE1; border-radius: 3px; overflow: hidden; }
.pbar { height: 100%; width: 100%; background: var(--mark); }
.pbar.indet { width: 38%; animation: dz-indet 1.1s ease-in-out infinite; }

/* Per-slide image thumbnail in the deck editor */
.slide-thumb { max-width: 240px; max-height: 150px; border: 1px solid var(--rule); border-radius: 3px; display: block; margin: 6px 0; object-fit: contain; }
.slide-audio { width: 100%; max-width: 340px; display: block; margin: 6px 0; }
.s-voice { max-width: 150px; }

/* Empty-state callout */
.empty-cue { border: 1.5px dashed var(--rule); border-radius: 4px; padding: 16px; text-align: center; color: var(--slate); font-size: 0.9rem; background: #fff; }
.empty-cue strong { color: var(--ink); display: block; margin-bottom: 3px; }

/* Error / info modal */
.modal-overlay { position: fixed; inset: 0; background: rgba(22,25,30,.5); display: flex; align-items: center; justify-content: center; padding: 20px; z-index: 100; }
.modal-overlay[hidden] { display: none; }
.modal { width: 100%; max-width: 440px; background: var(--card); border: 1px solid var(--ink); border-radius: 4px; box-shadow: 10px 10px 0 var(--mark); padding: 22px; }
.modal-head { font-family: var(--mono); font-size: 1.02rem; font-weight: 600; color: var(--ink); margin-bottom: 10px; }
.modal-body { font-size: 0.92rem; color: var(--ink); line-height: 1.5; word-break: break-word; }
.modal-hint { font-size: 0.85rem; color: var(--slate); margin-top: 12px; padding: 10px 12px; background: #F4F5EC; border-left: 3px solid var(--mark); border-radius: 2px; line-height: 1.5; }
.modal-hint:empty { display: none; }
.modal-actions { margin-top: 16px; display: flex; justify-content: flex-end; gap: 8px; }

/* API token reveal (shown once) */
.token-reveal { border: 1px solid var(--ink); border-left: 3px solid var(--mark); border-radius: 3px; padding: 12px 14px; margin: 10px 0; background: #FBFCF3; }
.token-reveal-head { font-size: 0.85rem; color: var(--ink); margin-bottom: 8px; }
.token-reveal input { font-family: var(--mono); font-size: 0.82rem; }

/* Legal pages */
.legal { line-height: 1.6; }
.legal h2 { font-size: 1.02rem; margin: 22px 0 6px; }
.legal p, .legal li { color: var(--ink); }
.legal ul { padding-left: 20px; margin: 8px 0; }
.legal li { margin: 5px 0; }
.legal-note { background: #FBF3D6; border: 1px solid #E3C766; border-radius: 3px; padding: 10px 12px; font-size: 0.85rem; margin: 12px 0; }

/* Onboarding wizard */
.wizard { max-width: 560px; }
.wiz-progress { display: flex; gap: 6px; margin-bottom: 16px; }
.wiz-dot { flex: 1; height: 4px; border-radius: 2px; background: var(--rule); }
.wiz-dot.done { background: var(--mark); }
.wiz-back { display: inline-block; font-family: var(--mono); font-size: 0.78rem; color: var(--slate); background: transparent; border: none; padding: 0 0 6px; cursor: pointer; }
.wiz-back:hover { color: var(--ink); }
.wiz-radio { display: flex; gap: 10px; align-items: flex-start; padding: 12px 14px; border: 1px solid var(--rule); border-radius: 3px; margin: 8px 0; cursor: pointer; }
.wiz-radio input { width: auto; margin-top: 3px; }
.wiz-radio span { font-size: 0.9rem; }
.wiz-source-list { margin-bottom: 12px; }
.wiz-source-list:empty { display: none; }

/* Deck editor + embed snippet */
.deck-slide { border: 1px solid var(--rule); border-radius: 3px; padding: 12px 14px; margin: 12px 0; background: #fff; }
.bullet-row { margin: 6px 0; }
.bullet-row .bullet { flex: 1; }
.embed-snippet { background: #E9EAE1; border: 1px solid var(--rule); border-radius: 2px; padding: 8px 10px; font-family: var(--mono); font-size: 12px; overflow-x: auto; white-space: pre-wrap; word-break: break-all; margin: 8px 0; }

/* Getting-started checklist */
.checklist { list-style: none; display: flex; flex-wrap: wrap; gap: 8px 18px; padding: 12px 14px; margin: 4px 0 16px; border: 1px solid var(--rule); border-radius: 6px; background: var(--panel, #F4F4EC); }
.checklist li { display: flex; align-items: center; gap: 8px; font-size: 14px; }
.checklist .check { width: 18px; height: 18px; border: 2px solid var(--rule); border-radius: 50%; flex: 0 0 auto; position: relative; }
.checklist li.done .check { background: var(--accent, #6c8f2f); border-color: var(--accent, #6c8f2f); }
.checklist li.done .check::after { content: "✓"; position: absolute; inset: 0; display: flex; align-items: center; justify-content: center; color: #fff; font-size: 12px; line-height: 1; }
.checklist li.done a { color: var(--muted, #777); text-decoration: line-through; }
.checklist a { text-decoration: none; color: inherit; }
.checklist a:hover { text-decoration: underline; }
