.top-nav-menu { position: fixed; top: 68px; left: 50%; transform: translateX(-50%); z-index: 1300; width: 250px; padding: 9px; border-color: rgba(90,190,196,.22); border-radius: 14px; background: #123754; }
.top-nav-menu .nav-btn { justify-content: flex-start; width: 100%; min-width: 0; height: 40px; flex: 1 1 auto; padding: 0 10px; border-color: transparent; border-radius: 10px; text-align: left; }
.auth-screen { grid-template-columns: minmax(0, 440px); justify-content: center; justify-items: center; }
.auth-card { justify-self: center; }
.auth-brand { width: 100%; align-items: center; justify-content: center; text-align: center; }
.auth-brand img { margin-inline: auto; }
.theme-logo-dark { display: none !important; }
[data-theme="dark"] .theme-logo-light { display: none !important; }
[data-theme="dark"] .theme-logo-dark { display: block !important; }
@media (max-width: 760px) {
  .top-nav { justify-content: flex-start; gap: 4px; padding-inline: 8px; }
  .top-nav > .nav-btn, .top-nav .top-nav-trigger { padding-inline: 10px; }
  .top-nav .nav-btn { font-size: .82rem; }
}

/* Keep the sidebar control visually quiet and anchored to the sidebar edge. */
.sidebar-float-toggle {
  top: 50%;
  left: calc((100vw - min(1920px, calc(100vw - 36px))) / 2 + 282px);
  width: 40px;
  height: 40px;
  border: 1px solid rgba(205, 217, 229, .9);
  border-radius: 50%;
  color: #20364a;
  background: #f8fafc;
  box-shadow: 0 3px 12px rgba(20,32,44,.18);
  font-size: 23px;
  font-weight: 650;
  line-height: 1;
}
.sidebar-float-toggle:hover { color: #10263b; background: #fff; box-shadow: 0 5px 16px rgba(20,32,44,.22); }
.sidebar-float-toggle:focus-visible { outline: 3px solid #edb944; outline-offset: 3px; }
.sidebar-collapsed .sidebar-float-toggle { left: 14px; border-radius: 50%; }
@media (max-width: 1120px) {
  .sidebar-float-toggle { left: 14px; }
  .sidebar-collapsed .sidebar-float-toggle { left: 14px; }
}

/* Small screens use the fixed top navigation; keep the desktop sidebar out of
   the single-column workspace so it does not push the actual content down. */
@media (max-width: 1120px) {
  .app-screen.active { grid-template-columns: minmax(0, 1fr); }
  .app-screen .sidebar,
  .sidebar-float-toggle { display: none; }
  .app-screen.active { padding-top: 80px; }
  .workspace { min-width: 0; }
}

@media (max-width: 760px) {
  .app-screen { width: calc(100% - 16px); padding-bottom: 16px; }
  .app-screen.active { padding-top: 72px; gap: 12px; }
  .top-nav { height: 58px; padding: 7px 8px; gap: 4px; }
  .top-nav > .nav-btn,
  .top-nav .top-nav-trigger { height: 42px; padding-inline: 10px; font-size: .8rem; }
  .top-nav .nav-btn[data-view]::before { width: 20px; height: 20px; flex-basis: 20px; font-size: 12px; }
  .top-nav-menu { top: 62px; left: 8px; width: min(260px, calc(100vw - 16px)); }
  .topbar { min-height: 0; padding: 16px; gap: 12px; align-items: flex-start; flex-wrap: wrap; }
  .topbar #topbarTitle { font-size: clamp(1.25rem, 6vw, 1.7rem); overflow-wrap: anywhere; }
  .topbar-meta { width: 100%; flex-wrap: wrap; }
  .workspace, .workspace > *, .card, .pad { min-width: 0; }
  .pad, .stat { padding: 16px; }
  .cols-2, .cols-3 { grid-template-columns: minmax(0, 1fr); }
  .table-wrap, .table-responsive { max-width: 100%; overflow-x: auto; -webkit-overflow-scrolling: touch; }
  input, select, textarea { max-width: 100%; }
}

/* Builder form controls: keep checkboxes inline and make field labels distinct. */
#formBuilder .check-row {
  display: flex;
  align-items: center;
  justify-content: flex-start;
  gap: 11px;
  width: 100%;
  font-size: .96rem;
  font-weight: 650;
  line-height: 1.35;
}
#formBuilder .check-row input[type="checkbox"] {
  display: block;
  flex: 0 0 18px;
  width: 18px;
  height: 18px;
  margin: 0;
  padding: 0;
  accent-color: #315d83;
}
#formBuilder > label:not(.check-row) > span:first-child,
#formBuilder .logo-uploader > span:first-child {
  display: block;
  margin-bottom: 4px;
  color: var(--text);
  font-size: 1.04rem;
  font-weight: 800;
  letter-spacing: .005em;
  line-height: 1.3;
}
#formBuilder > label:not(.check-row) { gap: 5px; }
#formBuilder > label:not(.check-row) > .muted { margin-top: 2px; font-size: .82rem; }
#formBuilder > label:not(.check-row) > input,
#formBuilder > label:not(.check-row) > select,
#formBuilder > label:not(.check-row) > textarea { margin-top: 2px; }
#formBuilder .split-head > div > span {
  display: block;
  color: var(--text);
  font-size: 1.12rem;
  font-weight: 800;
  line-height: 1.3;
}
#formBuilder .split-head > div > .muted { margin-top: 4px; font-size: .88rem; }
#formBuilder .section-editor { display: grid; gap: 0; margin-top: 8px; padding: 4px 14px; border: 1px solid var(--line); border-radius: 12px; background: var(--surface-subtle); }
#formBuilder .section-editor-row { padding: 0; border: 0; border-bottom: 1px solid var(--line); border-radius: 0; background: transparent; }
#formBuilder .section-editor-row:last-child { border-bottom: 0; }
#formBuilder .section-editor-row:not([open]) { padding-bottom: 0; }
#formBuilder .section-editor-head { min-height: 48px; gap: 14px; }
#formBuilder .section-editor-head > span { gap: 7px; min-width: 0; }
#formBuilder .section-editor-head strong { font-size: .98rem; }
#formBuilder .section-range, #formBuilder .section-format { font-size: .9rem; }
#formBuilder .section-editor-head .tiny-btn { flex: 0 0 auto; min-height: 34px; padding: 5px 11px; border-radius: 9px; font-size: .82rem; }
#formBuilder .section-editor-content { padding: 4px 0 14px; }
#formBuilder .section-editor:empty { display: none; }
#formBuilder .section-add-row { margin-top: 10px; }
#formBuilder > .check-row { padding: 11px 13px; border: 1px solid var(--line); border-radius: 12px; background: var(--surface-subtle); }
#formBuilder .identity-fields {
  display: grid;
  gap: 8px;
  min-width: 0;
  margin: 0;
  padding: 12px 14px 14px;
  border: 1px solid var(--line);
  border-radius: 14px;
  background: var(--surface-subtle);
}
#formBuilder .identity-fields legend {
  padding: 0 6px;
  color: var(--text);
  font-size: 1.04rem;
  font-weight: 800;
}
#formBuilder .logo-uploader > span:first-child {
  display: inline-flex;
  width: fit-content;
  padding: 7px 10px;
  border: 1px solid var(--line);
  border-radius: 9px;
  background: var(--surface-subtle);
}
#formBuilder .logo-uploader { display: grid; gap: 10px; padding: 14px; border: 1px solid var(--line); border-radius: 14px; background: var(--surface-subtle); }
#formBuilder .logo-uploader > span:first-child { margin: 0; }
#formBuilder .logo-file-picker { position: relative; display: inline-flex; align-items: center; justify-content: center; width: fit-content; min-height: 44px; overflow: hidden; padding: 0 16px; border: 1px solid #315d83; border-radius: 10px; color: #fff; background: #315d83; font-size: .9rem; font-weight: 750; cursor: pointer; }
#formBuilder .logo-file-picker:hover { background: #244866; }
#formBuilder .logo-file-input { position: absolute; inset: 0; width: 100%; height: 100%; opacity: 0; cursor: pointer; }
#formBuilder .logo-file-picker:focus-within { outline: 3px solid color-mix(in srgb, #315d83 30%, transparent); outline-offset: 2px; }
#formBuilder .logo-library-label { gap: 8px; }
#formBuilder .logo-library-label > span {
  color: var(--text);
  font-size: .96rem;
  font-weight: 800;
}

#formBuilder .logo-library-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(190px, 1fr)); gap: 8px; margin-top: 10px; }
#formBuilder .logo-library-item { display: flex; align-items: center; gap: 10px; min-width: 0; padding: 9px 11px; border: 1px solid var(--line); border-radius: 12px; color: var(--text); background: var(--surface-strong); text-align: left; cursor: pointer; }
#formBuilder .logo-library-item:hover, #formBuilder .logo-library-item.selected { border-color: #315d83; background: var(--surface-subtle); }
#formBuilder .logo-library-item img { display: block; width: 42px; height: 42px; flex: 0 0 42px; object-fit: contain; padding: 3px; border: 1px solid var(--line); border-radius: 8px; background: #fff; }
#formBuilder .logo-library-item-copy { display: grid; gap: 3px; min-width: 0; }
#formBuilder .logo-library-item-copy strong { overflow: hidden; font-size: .8rem; text-overflow: ellipsis; white-space: nowrap; }
#formBuilder .logo-library-item-copy small, #formBuilder .logo-library-empty { color: var(--muted); font-size: .74rem; }
#formBuilder .logo-library-empty { padding: 10px 12px; border: 1px dashed var(--line); border-radius: 10px; }

.sheet-card-updated { margin: 3px 0 0 47px; color: var(--muted); font-size: .78rem; line-height: 1.45; }
#formBuilder #formLogoFileName { max-width: 100%; overflow-wrap: anywhere; }
#formBuilder #formLogoStatus { line-height: 1.5; }
.scan-mode-options { display: grid; gap: 10px; margin: 0; padding: 13px 15px; border: 1px solid var(--line); border-radius: 14px; }
#scanForm:has(input[name="scanMode"][value="quick"]:checked) #scanStudentField { display: none !important; }
.scan-mode-options legend { padding: 0 6px; color: var(--muted); font-size: .82rem; font-weight: 700; }
.scan-mode-options .radio-option { display: flex; align-items: center; gap: 9px; margin: 0; font-weight: 650; }
.scan-mode-options input { width: auto; margin: 0; accent-color: #315d83; }
.scan-answer-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(86px, 1fr)); gap: 7px; margin-top: 10px; }
.scan-answer { display: grid; gap: 2px; padding: 8px; border: 1px solid var(--line); border-radius: 10px; background: var(--surface-subtle); }
.scan-answer strong { font-size: .72rem; color: var(--muted); }
.scan-answer span { font-weight: 800; }
.scan-answer small { font-size: .7rem; }
.scan-answer.is-correct { border-color: rgba(45, 145, 91, .35); background: rgba(45, 145, 91, .09); }
.scan-answer.is-correct small { color: #24824e; }
.scan-answer.is-wrong { border-color: rgba(196, 74, 74, .3); background: rgba(196, 74, 74, .07); }
.scan-answer.is-wrong small { color: #b43d3d; }
.profile-picture-editor { display: flex; align-items: center; gap: 1rem; flex-wrap: wrap; }
.profile-avatar { width: 88px; height: 88px; flex: 0 0 88px; }
.profile-picture-preview, .profile-picture-placeholder { width: 88px; height: 88px; box-sizing: border-box; object-fit: cover; border-radius: 50%; border: 2px solid var(--line, #dbe3ee); background: #f3f6fa; }
.profile-picture-placeholder { display: grid; place-items: center; color: var(--muted, #667085); font-size: 1.8rem; font-weight: 700; }
.profile-picture-upload { display: grid; gap: .35rem; }
.profile-picture-upload small { color: var(--muted, #667085); }

.password-input-wrap { position: relative; display: block; width: 100%; }
.password-input-wrap input { box-sizing: border-box; width: 100%; padding-right: 52px; }
.password-visibility-toggle { position: absolute; top: 50%; right: 7px; display: grid; place-items: center; width: 38px; height: 38px; padding: 8px; transform: translateY(-50%); border: 0; border-radius: 10px; color: var(--muted, #667085); background: transparent; cursor: pointer; }
.password-visibility-toggle:hover { color: var(--accent, #00a99d); background: var(--surface-subtle, rgba(0, 169, 157, .09)); }
.password-visibility-toggle:focus-visible { outline: 2px solid var(--accent, #00a99d); outline-offset: 1px; }
.password-visibility-toggle svg { display: block; width: 20px; height: 20px; }
.password-visibility-toggle .eye-closed, .password-visibility-toggle[aria-pressed="true"] .eye-open { display: none; }
.password-visibility-toggle[aria-pressed="true"] .eye-closed { display: block; }
.auth-card .btn-primary:disabled { opacity: .72; cursor: wait; }

/* Let the fixed dropdown escape the horizontally scrolling navigation bar. */
.top-nav { overflow: visible; }
.top-nav-menu { z-index: 1300; }
.top-nav-item { position: relative; }
.top-nav-trigger { list-style: none; }
.top-nav-trigger::-webkit-details-marker { display: none; }
.top-nav-item[open] .top-nav-menu { display: grid; gap: 5px; }
.top-nav-item:hover .top-nav-menu,
.top-nav-item:focus-within .top-nav-menu { display: grid; gap: 5px; }
@media (max-width: 760px) {
  .top-nav {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    align-content: center;
    height: auto;
    min-height: 104px;
    overflow: visible;
    padding: 7px 8px;
  }
  .top-nav-item { width: 100%; min-width: 0; }
  .top-nav > .nav-btn,
  .top-nav .top-nav-trigger { width: 100%; justify-content: center; }
  .top-nav-menu { top: 110px; left: 8px; transform: none; width: min(280px, calc(100vw - 16px)); }
  .app-screen.active { padding-top: 116px; }
}


/* Make logout easy to find in the always-visible top bar. */
.topbar .topbar-logout-btn {
  display: inline-flex;
  min-height: 42px;
  align-items: center;
  justify-content: center;
  padding: 0 16px;
  border: 1px solid #a72720;
  border-radius: 10px;
  background: #bd3028;
  color: #fff;
  font-weight: 800;
  white-space: nowrap;
}
.topbar .topbar-logout-btn:hover { background: #9f241e; }
.topbar .topbar-logout-btn:focus-visible { outline: 3px solid #f2c14e; outline-offset: 3px; }
