/* RoboQuest platform console: sign-in, Content Studio and the shared top bar. */
:root {
  --bg: #f6f5fb; --surface: #ffffff; --surface-2: #f9f8fd; --border: #e4e0f0; --border-strong: #cfc8e3;
  --text: #221b36; --muted: #6c6483; --faint: #948cab;
  --primary: #5b3fd0; --primary-hover: #4a30b8; --primary-soft: #eeeafd; --on-primary: #ffffff;
  --success: #17803d; --success-soft: #e3f6ea; --warning: #8a5a00; --warning-soft: #fff3d6;
  --danger: #b42318; --danger-soft: #fdecea; --info-soft: #e8f1fe; --info: #1d5fbf;
  --radius: 12px; --radius-sm: 8px; --shadow: 0 1px 2px rgba(34, 27, 54, .06), 0 4px 16px rgba(34, 27, 54, .05);
  --font: "Inter", system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
}
* { box-sizing: border-box; }
html, body { margin: 0; }
body { background: var(--bg); color: var(--text); font: 15px/1.5 var(--font); -webkit-font-smoothing: antialiased; }
a { color: var(--primary); }
h1, h2, h3, h4 { margin: 0; line-height: 1.25; }
h1 { font-size: 24px; font-weight: 700; }
h2 { font-size: 18px; font-weight: 650; }
h3 { font-size: 15px; font-weight: 650; }
p { margin: 0; }
.muted { color: var(--muted); }
.small { font-size: 13px; }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
[hidden] { display: none !important; }

/* Form controls */
label.field { display: grid; gap: 6px; font-size: 13px; font-weight: 600; color: var(--text); }
label.field .hint { font-weight: 400; color: var(--muted); }
input, select, textarea, button { font: inherit; color: inherit; }
input:not([type=checkbox]):not([type=radio]):not([type=file]), select, textarea {
  width: 100%; padding: 9px 11px; border: 1px solid var(--border-strong); border-radius: var(--radius-sm); background: var(--surface);
}
textarea { min-height: 110px; resize: vertical; line-height: 1.55; }
input:focus-visible, select:focus-visible, textarea:focus-visible, button:focus-visible, a:focus-visible, summary:focus-visible {
  outline: 3px solid color-mix(in srgb, var(--primary) 35%, transparent); outline-offset: 1px; border-color: var(--primary);
}
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px; padding: 8px 14px; border-radius: var(--radius-sm);
  border: 1px solid var(--border-strong); background: var(--surface); color: var(--text); font-weight: 600; font-size: 14px;
  cursor: pointer; text-decoration: none; white-space: nowrap; min-height: 38px;
}
.btn:hover { background: var(--surface-2); }
.btn.primary { background: var(--primary); border-color: var(--primary); color: var(--on-primary); }
.btn.primary:hover { background: var(--primary-hover); }
.btn.danger { color: var(--danger); border-color: color-mix(in srgb, var(--danger) 35%, var(--border)); }
.btn.danger:hover { background: var(--danger-soft); }
.btn.ghost { border-color: transparent; background: transparent; }
.btn.ghost:hover { background: var(--primary-soft); }
.btn.small { padding: 4px 10px; min-height: 30px; font-size: 13px; }
.btn:disabled { opacity: .5; cursor: not-allowed; }
.btn-row { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; }

/* Badges */
.badge { display: inline-flex; align-items: center; gap: 4px; padding: 2px 9px; border-radius: 999px; font-size: 12px; font-weight: 650; white-space: nowrap; }
.badge.published { background: var(--success-soft); color: var(--success); }
.badge.draft { background: var(--warning-soft); color: var(--warning); }
.badge.missing { background: var(--danger-soft); color: var(--danger); }
.badge.neutral { background: var(--surface-2); color: var(--muted); border: 1px solid var(--border); }
.badge.info { background: var(--info-soft); color: var(--info); }

/* Top bar */
.rq-topbar { position: sticky; top: 0; z-index: 30; background: #1f1636; color: #fff; }
.rq-topbar .inner { max-width: 1320px; margin: auto; padding: 0 20px; height: 58px; display: flex; align-items: center; gap: 24px; }
.rq-brand { display: flex; align-items: center; gap: 10px; font-weight: 700; color: #fff; text-decoration: none; white-space: nowrap; }
.rq-brand .mark { width: 30px; height: 30px; border-radius: 8px; background: linear-gradient(135deg, #8b6cff, #5b3fd0); display: grid; place-items: center; font-size: 14px; }
.rq-brand small { display: block; font-weight: 500; font-size: 11px; color: #c9bff0; letter-spacing: .02em; }
.rq-nav { display: flex; gap: 4px; flex: 1; }
.rq-nav a { color: #d8d0f5; text-decoration: none; padding: 8px 12px; border-radius: 8px; font-weight: 600; font-size: 14px; }
.rq-nav a:hover { background: rgba(255, 255, 255, .08); color: #fff; }
.rq-nav a[aria-current=page] { background: rgba(255, 255, 255, .14); color: #fff; }
.rq-user { position: relative; }
.rq-user > button { display: flex; align-items: center; gap: 8px; background: transparent; border: 1px solid rgba(255, 255, 255, .2); color: #fff; padding: 6px 10px; border-radius: 999px; cursor: pointer; }
.rq-user .avatar { width: 26px; height: 26px; border-radius: 50%; background: #8b6cff; display: grid; place-items: center; font-weight: 700; font-size: 12px; }
.rq-menu { position: absolute; right: 0; top: calc(100% + 8px); min-width: 230px; background: var(--surface); color: var(--text); border: 1px solid var(--border); border-radius: var(--radius); box-shadow: var(--shadow); padding: 6px; }
.rq-menu .who { padding: 8px 10px 10px; border-bottom: 1px solid var(--border); margin-bottom: 4px; }
.rq-menu button { display: block; width: 100%; text-align: left; background: none; border: 0; padding: 9px 10px; border-radius: 8px; cursor: pointer; font-weight: 500; }
.rq-menu button:hover { background: var(--surface-2); }

/* Page layout */
.page { max-width: 1320px; margin: auto; padding: 24px 20px 80px; }
.page-head { display: flex; flex-wrap: wrap; align-items: flex-end; justify-content: space-between; gap: 16px; margin-bottom: 20px; }
.page-head p { margin-top: 4px; }
.card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); box-shadow: var(--shadow); }
.card-pad { padding: 20px; }
.section { margin-top: 18px; }
.card-pad > h2 + p.muted, .card-pad > h2 + p.small { margin: 4px 0 16px; }
.card-pad > h2:only-child, .card-pad > h2 + .table-wrap, .card-pad > h2 + ul { margin-bottom: 12px; }
.grid-2 { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 14px; }
.grid-3 { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 14px; }
.stack { display: grid; gap: 14px; }
.tabs { display: flex; gap: 4px; border-bottom: 1px solid var(--border); margin-bottom: 18px; overflow-x: auto; }
.tabs a { padding: 10px 14px; text-decoration: none; color: var(--muted); font-weight: 600; border-bottom: 2px solid transparent; white-space: nowrap; }
.tabs a[aria-current=page] { color: var(--primary); border-bottom-color: var(--primary); }
.tabs .count { font-weight: 500; color: var(--faint); margin-left: 4px; }

/* Overview */
.stats { display: grid; grid-template-columns: repeat(auto-fit, minmax(190px, 1fr)); gap: 14px; }
.stat { padding: 18px; }
.stat .value { font-size: 28px; font-weight: 700; margin-top: 4px; }
.stat .label { color: var(--muted); font-size: 13px; font-weight: 600; }
.list { list-style: none; margin: 0; padding: 0; }
.list li { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 12px 0; border-top: 1px solid var(--border); }
.list li:first-child { border-top: 0; }

/* Filters and tables */
.toolbar { display: flex; flex-wrap: wrap; gap: 10px; align-items: center; padding: 14px 16px; border-bottom: 1px solid var(--border); }
.toolbar .search { flex: 1 1 240px; }
.toolbar select { width: auto; min-width: 150px; }
.chips { display: flex; flex-wrap: wrap; gap: 6px; }
.chip { border: 1px solid var(--border-strong); background: var(--surface); border-radius: 999px; padding: 5px 12px; font-size: 13px; font-weight: 600; cursor: pointer; color: var(--muted); }
.chip[aria-pressed=true] { background: var(--primary-soft); border-color: var(--primary); color: var(--primary); }
.table-wrap { overflow-x: auto; }
table.data { width: 100%; border-collapse: collapse; font-size: 14px; }
table.data th { text-align: left; font-size: 12px; text-transform: uppercase; letter-spacing: .04em; color: var(--muted); font-weight: 650; padding: 10px 16px; background: var(--surface-2); border-bottom: 1px solid var(--border); }
table.data td { padding: 14px 16px; border-bottom: 1px solid var(--border); vertical-align: top; }
table.data tr:last-child td { border-bottom: 0; }
table.data tr:hover td { background: #fcfbff; }
.course-title { font-weight: 650; }
a.course-title { color: var(--text); text-decoration: none; }
a.course-title:hover { color: var(--primary); text-decoration: underline; }
.meta { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 6px; align-items: center; }
.empty { padding: 40px 20px; text-align: center; color: var(--muted); }
.empty h3 { color: var(--text); margin-bottom: 6px; }

/* Topic grid (Skill Labs) */
.topic-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(250px, 1fr)); gap: 14px; }
.topic { padding: 16px; display: grid; gap: 10px; text-decoration: none; color: inherit; }
.topic:hover { border-color: var(--primary); }
.levels { display: flex; gap: 6px; flex-wrap: wrap; }

/* Editor */
.editor { display: grid; grid-template-columns: minmax(0, 1fr) 320px; gap: 20px; align-items: start; }
.editor-side { position: sticky; top: 78px; display: grid; gap: 14px; }
.actionbar { position: sticky; top: 58px; z-index: 20; background: color-mix(in srgb, var(--bg) 92%, transparent); backdrop-filter: blur(6px); padding: 12px 0; margin: -12px 0 8px; display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 12px; border-bottom: 1px solid var(--border); }
.crumbs { font-size: 13px; color: var(--muted); }
.crumbs a { color: var(--muted); }
.unsaved { color: var(--warning); font-weight: 600; font-size: 13px; }
.block { border: 1px solid var(--border); border-radius: var(--radius); background: var(--surface); }
.block + .block { margin-top: 12px; }
.block-head { display: flex; align-items: center; gap: 10px; padding: 12px 14px; border-bottom: 1px solid var(--border); background: var(--surface-2); border-radius: var(--radius) var(--radius) 0 0; }
.block-head input { font-weight: 650; background: var(--surface); }
.block-head > .small { white-space: nowrap; }
.block-body { padding: 14px; display: grid; gap: 12px; }
.lesson { border: 1px solid var(--border); border-radius: var(--radius-sm); background: var(--surface); }
.lesson > summary { list-style: none; display: flex; align-items: center; gap: 10px; padding: 10px 12px; cursor: pointer; }
.lesson > summary::-webkit-details-marker { display: none; }
.lesson > summary .title { flex: 1; font-weight: 600; }
.lesson > summary .chev { transition: transform .15s; color: var(--muted); }
.lesson[open] > summary .chev { transform: rotate(90deg); }
.lesson .lesson-body { padding: 4px 12px 14px; display: grid; gap: 12px; border-top: 1px solid var(--border); }
.order { display: inline-flex; gap: 2px; }
.icon-btn { width: 30px; height: 30px; border-radius: 7px; border: 1px solid var(--border); background: var(--surface); cursor: pointer; display: inline-grid; place-items: center; color: var(--muted); font-size: 14px; }
.icon-btn:hover { background: var(--surface-2); color: var(--text); }
.icon-btn:disabled { opacity: .35; cursor: default; }
.icon-btn.danger:hover { color: var(--danger); background: var(--danger-soft); }
.attachments { display: flex; flex-wrap: wrap; gap: 6px; }
.file-chip { display: inline-flex; align-items: center; gap: 6px; padding: 4px 6px 4px 10px; background: var(--primary-soft); border-radius: 999px; font-size: 13px; }
.file-chip button { border: 0; background: transparent; cursor: pointer; color: var(--muted); font-size: 15px; line-height: 1; }
.dropzone { border: 1.5px dashed var(--border-strong); border-radius: var(--radius-sm); padding: 14px; text-align: center; color: var(--muted); font-size: 13px; background: var(--surface-2); }
.dropzone.over { border-color: var(--primary); background: var(--primary-soft); color: var(--primary); }
.dropzone.big { padding: 32px; font-size: 14px; }
.kv { display: grid; grid-template-columns: auto 1fr; gap: 6px 12px; font-size: 13px; }
.kv dt { color: var(--muted); }
.kv dd { margin: 0; font-weight: 600; }
.choices { display: grid; gap: 8px; }
.choice { display: grid; grid-template-columns: auto 1fr auto; gap: 8px; align-items: center; }
details.advanced > summary { cursor: pointer; font-weight: 600; color: var(--muted); font-size: 13px; }

/* Preview */
.preview h2 { font-size: 22px; margin-bottom: 6px; }
.preview h3 { margin: 18px 0 6px; }
.preview h4 { margin: 12px 0 4px; font-size: 14px; }
.preview .text { white-space: pre-wrap; line-height: 1.65; }

/* Modal, toast */
dialog.modal { border: 0; border-radius: 14px; padding: 0; width: min(640px, calc(100vw - 32px)); max-height: calc(100vh - 64px); box-shadow: 0 20px 60px rgba(20, 12, 40, .3); color: var(--text); }
dialog.modal::backdrop { background: rgba(23, 16, 41, .45); }
dialog.modal.wide { width: min(900px, calc(100vw - 32px)); }
.modal-head { display: flex; justify-content: space-between; align-items: center; padding: 16px 20px; border-bottom: 1px solid var(--border); }
.modal-body { padding: 20px; overflow: auto; max-height: calc(100vh - 220px); display: grid; gap: 14px; }
.modal-foot { display: flex; justify-content: flex-end; gap: 8px; padding: 14px 20px; border-top: 1px solid var(--border); background: var(--surface-2); }
.toasts { position: fixed; right: 20px; bottom: 20px; z-index: 100; display: grid; gap: 8px; max-width: min(420px, calc(100vw - 40px)); }
.toast { background: #221b36; color: #fff; padding: 12px 14px; border-radius: 10px; box-shadow: var(--shadow); font-size: 14px; display: flex; gap: 10px; align-items: flex-start; }
.toast.error { background: var(--danger); }
.toast.success { background: #145f33; }
.notice { padding: 12px 14px; border-radius: var(--radius-sm); font-size: 14px; }
.notice.warning { background: var(--warning-soft); color: var(--warning); }
.notice.info { background: var(--info-soft); color: var(--info); }
.notice.error { background: var(--danger-soft); color: var(--danger); }
.spinner { width: 18px; height: 18px; border: 2px solid var(--border-strong); border-top-color: var(--primary); border-radius: 50%; animation: spin .8s linear infinite; display: inline-block; vertical-align: middle; }
@keyframes spin { to { transform: rotate(360deg); } }
.loading { padding: 60px; text-align: center; color: var(--muted); }

/* Sign-in */
.auth-page { min-height: 100vh; display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); }
.auth-side { background: radial-gradient(circle at 20% 20%, #3a2a74 0, #1f1636 60%); color: #fff; padding: 56px; display: flex; flex-direction: column; justify-content: space-between; }
.auth-side h1 { font-size: 34px; margin: 18px 0 12px; }
.auth-side p { color: #d8d0f5; max-width: 440px; font-size: 16px; }
.auth-side ul { margin: 28px 0 0; padding: 0; list-style: none; display: grid; gap: 12px; color: #e6e0fb; }
.auth-side li::before { content: "✓"; color: #a993ff; margin-right: 10px; font-weight: 700; }
.auth-main { display: grid; place-items: center; padding: 32px; }
.auth-card { width: min(420px, 100%); display: grid; gap: 18px; }
.auth-card form { display: grid; gap: 14px; }
.auth-card .btn.primary { min-height: 44px; font-size: 15px; }

@media (max-width: 960px) {
  .editor { grid-template-columns: 1fr; }
  .editor-side { position: static; }
  .grid-3 { grid-template-columns: 1fr 1fr; }
  .auth-page { grid-template-columns: 1fr; }
  .auth-side { padding: 18px 20px; }
  .auth-side > div, .auth-side > p { display: none; }
  .auth-main { place-items: start center; padding-top: 28px; }
}
@media (max-width: 640px) {
  .rq-topbar .inner { gap: 10px; padding: 0 12px; }
  .rq-brand > span:not(.mark), .rq-user .name { display: none; }
  .rq-nav a { padding: 8px; font-size: 13px; }
  .page { padding: 16px 12px 60px; }
  .grid-2, .grid-3 { grid-template-columns: 1fr; }
  .hide-sm { display: none; }
  .rq-nav a { white-space: nowrap; }
}
