:root {
  --bg: #edf3f8;
  --panel: rgba(255, 255, 255, 0.92);
  --panel-strong: #ffffff;
  --line: #dbe4ee;
  --text: #1f2f3d;
  --muted: #617487;
  --brand: #2d5f8b;
  --brand-dark: #214564;
  --brand-soft: #e8f0fb;
  --accent: #ff8a5b;
  --shadow: 0 18px 40px rgba(31, 47, 61, 0.08);
  --app-gap: clamp(10px, 1vw, 14px);
  --panel-padding: clamp(10px, 1vw, 14px);
  --section-padding-y: clamp(10px, 1.1vh, 14px);
  --section-padding-x: clamp(12px, 1vw, 16px);
  --student-row-height: clamp(40px, 5vh, 48px);
  --toolbar-button-width: clamp(152px, 14vw, 176px);
  --prompt-preview-height: clamp(84px, 12vh, 120px);
  --overlay: rgba(18, 28, 39, 0.48);
}

* {
  box-sizing: border-box;
}

html,
body {
  margin: 0;
  min-height: 100%;
  width: 100%;
  max-width: 100%;
  overflow-x: clip;
  overflow-y: auto;
  color: var(--text);
  background:
    radial-gradient(circle at top left, rgba(45, 95, 139, 0.1), transparent 24rem),
    radial-gradient(circle at bottom right, rgba(255, 138, 91, 0.12), transparent 20rem),
    linear-gradient(180deg, #f6f9fc 0%, var(--bg) 100%);
  font-family: "Aptos", "Segoe UI", sans-serif;
}

body {
  min-height: 100dvh;
}

[hidden] {
  display: none !important;
}

.workspace-screen {
  min-height: 100dvh;
  overflow-x: clip;
}

.standalone-screen {
  display: grid;
  grid-template-rows: auto 1fr;
  min-height: 100dvh;
  padding: clamp(18px, 2vw, 28px);
}

.standalone-screen-muted {
  background:
    radial-gradient(circle at top center, rgba(45, 95, 139, 0.08), transparent 22rem),
    linear-gradient(180deg, #f8fbfe 0%, #edf3f8 100%);
}

.standalone-brand {
  width: min(1180px, 100%);
  margin: 0 auto 18px;
  font-family: Georgia, "Times New Roman", serif;
  font-size: clamp(1.5rem, 2vw, 1.9rem);
  font-weight: 700;
  color: var(--brand-dark);
}

.auth-shell {
  width: min(1180px, 100%);
  margin: 0 auto;
  display: grid;
  grid-template-columns: minmax(320px, 460px) minmax(0, 1fr);
  gap: 18px;
  align-items: start;
}

.auth-card,
.signed-out-card,
.walkthrough-card,
.modal-shell {
  border: 1px solid var(--line);
  border-radius: 28px;
  box-shadow: var(--shadow);
  background: rgba(255, 255, 255, 0.94);
}

.auth-card,
.signed-out-card {
  display: grid;
  gap: 14px;
  padding: clamp(22px, 2vw, 28px);
}

.signed-out-card {
  width: min(520px, 100%);
  margin: 8vh auto 0;
}

.auth-card h1,
.signed-out-card h1 {
  margin: 0;
  font-family: Georgia, "Times New Roman", serif;
  line-height: 1.08;
  color: var(--brand-dark);
}

.auth-copy,
.auth-note {
  margin: 0;
  color: var(--muted);
  line-height: 1.55;
}

.auth-note-muted {
  font-size: 0.9rem;
}

.auth-delivery-hint {
  display: grid;
  gap: 6px;
  padding: 13px 15px;
  border: 1px solid #efd8ad;
  border-radius: 16px;
  background: linear-gradient(180deg, #fffdf7 0%, #fff8e8 100%);
  color: #6f542a;
  line-height: 1.5;
}

.auth-delivery-hint strong,
.auth-delivery-hint p {
  margin: 0;
}

.auth-delivery-hint p {
  font-size: 0.9rem;
}

.auth-label {
  font-size: 0.88rem;
  font-weight: 700;
}

.auth-mode-switch {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 8px;
  padding: 6px;
  border: 1px solid var(--line);
  border-radius: 18px;
  background: #f7fbff;
}

.auth-mode-button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 42px;
  padding: 0 14px;
  border: 1px solid transparent;
  border-radius: 14px;
  background: transparent;
  color: var(--muted);
  font: inherit;
  font-weight: 700;
  cursor: pointer;
  transition: background 0.16s ease, border-color 0.16s ease, color 0.16s ease, transform 0.16s ease;
}

.auth-mode-button:hover {
  transform: translateY(-1px);
}

.auth-mode-button-active {
  border-color: #d4e2f3;
  background: linear-gradient(180deg, #ffffff 0%, #edf4fb 100%);
  color: var(--brand-dark);
  box-shadow: 0 8px 18px rgba(45, 95, 139, 0.08);
}

.auth-status-card {
  display: grid;
  gap: 8px;
  padding: 14px 16px;
  border-radius: 18px;
  border: 1px solid #d7e5f6;
  background: linear-gradient(180deg, #f6faff 0%, #eef5ff 100%);
}

.auth-status-card strong {
  color: var(--brand-dark);
}

.auth-status-card-error {
  border-color: #f1c7c7;
  background: linear-gradient(180deg, #fff8f7 0%, #fff1ef 100%);
}

.auth-status-card-success {
  border-color: #cfe7da;
  background: linear-gradient(180deg, #f5fcf8 0%, #eef9f3 100%);
}

.auth-status-card-loading {
  border-color: #d7e5f6;
  background: linear-gradient(180deg, #f6faff 0%, #eef5ff 100%);
}

.auth-actions,
.signed-out-actions {
  display: grid;
  gap: 10px;
}

.auth-action-screen {
  align-content: start;
}

.auth-action-card {
  width: min(560px, 100%);
  margin: clamp(32px, 8vh, 88px) auto 0;
}

.auth-action-form {
  display: grid;
  gap: 12px;
}

.auth-action-return {
  text-decoration: none;
}

.walkthrough-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 16px;
}

.walkthrough-card {
  display: grid;
  gap: 10px;
  padding: clamp(18px, 1.7vw, 22px);
}

.walkthrough-card h2 {
  margin: 0;
  font-size: 1.06rem;
  color: var(--brand-dark);
}

.walkthrough-card p {
  margin: 0;
  color: var(--muted);
  line-height: 1.5;
}

.walkthrough-step,
.mode-pill,
.sync-pill,
.survey-link-status {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: fit-content;
  min-height: 32px;
  padding: 0 12px;
  border-radius: 999px;
  font-size: 0.82rem;
  font-weight: 800;
}

.walkthrough-step {
  background: #eef4fb;
  color: var(--brand-dark);
}

.mode-pill {
  margin-top: 4px;
  min-height: 26px;
  padding: 0 9px;
  font-size: 0.75rem;
  background: rgba(255, 255, 255, 0.12);
  border: 1px solid rgba(255, 255, 255, 0.12);
  color: #f5f9fd;
}

.sync-pill {
  min-height: 26px;
  padding: 0 9px;
  font-size: 0.75rem;
  background: rgba(103, 211, 155, 0.13);
  border: 1px solid rgba(130, 229, 179, 0.22);
  color: #c9f5dc;
}

.sync-pill-error {
  background: rgba(245, 166, 88, 0.14);
  border-color: rgba(255, 184, 112, 0.28);
  color: #ffe0bd;
}

.sidebar-tour-button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 30px;
  padding: 0 12px;
  border: 1px solid rgba(255, 255, 255, 0.14);
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.06);
  color: #f5f9fd;
  font: inherit;
  font-size: 0.78rem;
  font-weight: 700;
  cursor: pointer;
  transition: background 0.16s ease, border-color 0.16s ease, transform 0.16s ease;
}

.sidebar-tour-button:hover {
  background: rgba(93, 140, 187, 0.14);
  border-color: rgba(141, 183, 223, 0.22);
  transform: translateY(-1px);
}

.survey-link-status {
  background: #eff8f4;
  color: #2f725c;
}

.survey-link-status-muted {
  background: #f4f7fb;
  color: var(--muted);
}

.modal-backdrop {
  position: fixed;
  inset: 0;
  z-index: 40;
  display: grid;
  place-items: center;
  padding: 24px;
  background: var(--overlay);
  backdrop-filter: blur(16px);
}

.modal-shell {
  width: min(1040px, 100%);
  height: min(82vh, 860px);
  max-height: min(82vh, 860px);
  display: grid;
  grid-template-columns: 240px minmax(0, 1fr);
  overflow: hidden;
}

.modal-shell > * {
  min-height: 0;
}

.modal-sidebar {
  display: grid;
  align-content: start;
  gap: 20px;
  padding: 24px 18px;
  background: linear-gradient(180deg, #22384d 0%, #1a2b3b 100%);
  color: #f3f7fb;
}

.modal-sidebar h2 {
  margin: 4px 0 0;
  font-family: Georgia, "Times New Roman", serif;
}

.modal-nav {
  display: grid;
  gap: 8px;
}

.modal-nav-button {
  display: flex;
  align-items: center;
  width: 100%;
  padding: 12px 14px;
  border: 1px solid transparent;
  border-radius: 14px;
  background: rgba(255, 255, 255, 0.04);
  color: #f3f7fb;
  cursor: pointer;
  text-align: left;
}

.modal-nav-button:hover,
.modal-nav-button-active {
  background: rgba(93, 140, 187, 0.14);
  border-color: rgba(93, 140, 187, 0.2);
}

.modal-content {
  position: relative;
  min-height: 0;
  overflow-y: auto;
  overscroll-behavior: contain;
  scrollbar-gutter: stable;
  padding: 24px;
  background: rgba(255, 255, 255, 0.97);
}

.modal-close {
  position: absolute;
  top: 16px;
  right: 18px;
  width: 38px;
  height: 38px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: #f8fbfe;
  color: var(--brand-dark);
  cursor: pointer;
  font-size: 1.2rem;
}

.modal-panel {
  display: grid;
  gap: 18px;
}

.modal-panel-head {
  display: grid;
  gap: 8px;
  padding-right: 56px;
}

.modal-panel-head h3 {
  margin: 0;
  font-family: Georgia, "Times New Roman", serif;
  color: var(--brand-dark);
}

.modal-panel-head p {
  margin: 0;
  color: var(--muted);
  line-height: 1.5;
}

.modal-form-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 16px;
}

.modal-field,
.profile-meta-card,
.modal-note-card {
  display: grid;
  gap: 8px;
  padding: 14px 16px;
  border-radius: 18px;
  border: 1px solid var(--line);
  background: #fbfdff;
}

.modal-field span,
.profile-meta-label {
  font-size: 0.84rem;
  font-weight: 700;
  color: var(--muted);
}

.modal-field small {
  color: var(--muted);
  line-height: 1.45;
}

.modal-field-compact {
  justify-self: start;
  width: min(100%, 280px);
}

.modal-note-card-info {
  margin-bottom: 18px;
  background: linear-gradient(180deg, #f6faff 0%, #f0f6ff 100%);
  border-color: #d7e5f6;
}

.modal-field-wide {
  grid-column: 1 / -1;
}

.toggle-field {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  padding: 14px 16px;
  border-radius: 18px;
  border: 1px solid var(--line);
  background: #fbfdff;
}

.toggle-field strong,
.modal-note-card strong,
.profile-meta-card strong {
  color: var(--brand-dark);
}

.toggle-field p,
.modal-note-card p {
  margin: 0;
  color: var(--muted);
  line-height: 1.5;
}

.toggle-field input {
  width: 22px;
  height: 22px;
  margin: 0;
}

.modal-footer-actions {
  display: flex;
  justify-content: flex-start;
}

.modal-shell-tour {
  width: min(960px, 100%);
  max-height: min(84vh, 900px);
  grid-template-columns: 1fr;
}

.modal-content-tour {
  padding-top: 28px;
}

.walkthrough-grid-tour {
  grid-template-columns: repeat(2, minmax(0, 1fr));
}

.survey-create-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 12px;
}

.survey-links-list {
  display: grid;
  gap: 12px;
}

.survey-links-empty {
  display: grid;
  gap: 8px;
  justify-items: center;
  padding: 24px;
  border: 1px dashed var(--line);
  border-radius: 18px;
  background: linear-gradient(180deg, rgba(247, 251, 255, 0.9) 0%, rgba(240, 246, 252, 0.92) 100%);
  color: var(--muted);
  text-align: center;
}

.survey-links-empty strong {
  color: var(--brand-dark);
  font-size: 1rem;
}

.survey-links-empty p {
  margin: 0;
  max-width: 34ch;
  line-height: 1.45;
}

.survey-link-card {
  display: grid;
  gap: 12px;
  padding: 16px;
  border-radius: 18px;
  border: 1px solid var(--line);
  background: #fbfdff;
}

.survey-link-card-archived {
  opacity: 0.8;
}

.survey-link-head,
.survey-link-meta,
.survey-link-actions {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  flex-wrap: wrap;
}

.survey-link-title {
  margin: 0;
  font-size: 1rem;
  color: var(--brand-dark);
}

.survey-link-url,
.survey-link-meta span {
  color: var(--muted);
  font-size: 0.9rem;
}

.survey-link-actions {
  justify-content: flex-start;
}

.survey-link-button {
  padding: 10px 12px;
}

.compact-app {
  display: grid;
  grid-template-columns: clamp(202px, 16vw, 232px) minmax(0, 1fr);
  min-height: 100dvh;
  gap: var(--app-gap);
  padding: var(--app-gap);
  align-items: stretch;
  width: 100%;
  max-width: 100%;
  overflow-x: clip;
}

.sidebar,
.main-panel,
.prompt-drawer {
  border: 1px solid var(--line);
  border-radius: 28px;
  box-shadow: var(--shadow);
}

.sidebar {
  display: grid;
  grid-template-rows: 1fr;
  gap: 8px;
  padding: 8px;
  background: linear-gradient(180deg, #31485d 0%, #27394b 100%);
  color: #f3f7fb;
  max-height: calc(100dvh - (var(--app-gap) * 2));
  overflow-y: auto;
  overflow-x: hidden;
  scrollbar-width: thin;
  overscroll-behavior: contain;
}

.sidebar-stack {
  display: grid;
  gap: 8px;
  min-width: 0;
  max-width: 100%;
}

.sidebar-brand,
.sidebar-card {
  border-radius: 20px;
  border: 1px solid rgba(255, 255, 255, 0.06);
  background: rgba(255, 255, 255, 0.038);
  padding: 8px 10px;
}

.sidebar-brand {
  display: grid;
  gap: 6px;
  padding: 8px 10px;
  border-color: rgba(141, 183, 223, 0.18);
  background:
    linear-gradient(180deg, rgba(67, 96, 123, 0.78) 0%, rgba(40, 59, 78, 0.9) 100%);
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.04);
  min-width: 0;
  max-width: 100%;
}

.sidebar-brand-actions {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
  margin-top: 4px;
}

.sidebar-teacher-name {
  margin: 3px 0 0;
  color: rgba(243, 247, 251, 0.9);
  font-family: Georgia, "Times New Roman", serif;
  font-size: 1.05rem;
  font-weight: 700;
}

.sidebar-card-setup {
  border-color: rgba(141, 183, 223, 0.16);
  background:
    linear-gradient(180deg, rgba(255, 255, 255, 0.06) 0%, rgba(102, 142, 182, 0.08) 100%);
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.04);
}

.sidebar-card-workspace {
  border-color: rgba(255, 255, 255, 0.08);
  background:
    linear-gradient(180deg, rgba(255, 255, 255, 0.022) 0%, rgba(255, 255, 255, 0.048) 100%);
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.04);
}

.brand-mark {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 40px;
  height: 40px;
  border-radius: 13px;
  background: linear-gradient(135deg, #5d8cbb, #ff8a5b);
  color: #fff;
  font-weight: 800;
  letter-spacing: 0.08em;
}

.sidebar-kicker,
.panel-kicker,
.status-label {
  margin: 0;
  text-transform: uppercase;
  letter-spacing: 0.12em;
  font-size: 0.72rem;
  font-weight: 800;
  color: var(--accent);
}

.sidebar-brand h1,
.sidebar-card h2,
.main-header h2,
.selected-student-card h3,
.student-picker h3,
.drawer-head h3 {
  margin: 4px 0 0;
  font-family: Georgia, "Times New Roman", serif;
  line-height: 1.08;
}

.sidebar-brand h1 {
  font-size: clamp(1.02rem, 1.2vw, 1.34rem);
  line-height: 0.94;
  overflow-wrap: normal;
  word-break: normal;
  hyphens: none;
}

.sidebar-card h2 {
  font-size: 1.02rem;
}

.sidebar-copy {
  margin: 0;
  color: rgba(243, 247, 251, 0.72);
  font-size: 0.75rem;
  line-height: 1.18;
  overflow-wrap: normal;
}

.sidebar-card {
  display: grid;
  gap: 6px;
  min-width: 0;
  max-width: 100%;
}

.sidebar-card-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
  min-width: 0;
  max-width: 100%;
}

label {
  font-size: 0.9rem;
  font-weight: 700;
}

input,
select {
  width: 100%;
  padding: clamp(10px, 1vh, 12px) 14px;
  border-radius: 16px;
  border: 1px solid rgba(219, 228, 238, 0.7);
  background: rgba(255, 255, 255, 0.96);
  color: var(--text);
  font: inherit;
}

input:focus,
select:focus {
  outline: none;
  border-color: rgba(93, 140, 187, 0.9);
  box-shadow: 0 0 0 4px rgba(93, 140, 187, 0.12);
}

input:disabled,
select:disabled {
  cursor: not-allowed;
  color: var(--muted);
  background: #f4f7fb;
}

.sidebar-nav {
  gap: 6px;
  min-width: 0;
}

.sidebar-link,
.primary-button,
.secondary-button,
.tab-button,
.page-button,
.student-tile,
.toolbar-action,
.toolbar-preview-button,
.ai-shortcut,
.auth-provider,
.modal-nav-button,
.modal-close {
  font: inherit;
}

.sidebar-link {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 7px 10px;
  border: 1px solid transparent;
  border-radius: 14px;
  background: rgba(255, 255, 255, 0.03);
  color: #f3f7fb;
  cursor: pointer;
  text-align: left;
  transition: background 0.16s ease, transform 0.16s ease, border-color 0.16s ease;
  min-width: 0;
  max-width: 100%;
}

.sidebar-link:hover,
.sidebar-link-active {
  background: rgba(93, 140, 187, 0.12);
  border-color: rgba(93, 140, 187, 0.16);
  transform: translateY(-1px);
}

.auth-provider {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 100%;
  padding: 13px 16px;
  border: 1px solid var(--line);
  border-radius: 16px;
  background: var(--panel-strong);
  color: var(--brand-dark);
  cursor: pointer;
  transition: transform 0.16s ease, background 0.16s ease, border-color 0.16s ease, color 0.16s ease;
}

.auth-provider:hover {
  transform: translateY(-1px);
}

.auth-provider:disabled {
  opacity: 0.68;
  cursor: not-allowed;
  transform: none;
}

.auth-provider-primary {
  background: linear-gradient(135deg, #5d8cbb, var(--brand));
  border-color: transparent;
  color: #fff;
}

.auth-provider-outline {
  background: #f8fbfe;
}

.auth-provider-demo {
  background: linear-gradient(135deg, #fff8f2, #fef1e8);
  border-color: #f4d8c8;
  color: #a85e34;
}

.primary-button,
.secondary-button,
.tab-button,
.page-button {
  border-radius: 14px;
  border: 1px solid transparent;
  cursor: pointer;
  transition: transform 0.16s ease, background 0.16s ease, border-color 0.16s ease;
}

.primary-button:hover,
.secondary-button:hover,
.tab-button:hover,
.page-button:hover,
.toolbar-action:hover,
.toolbar-preview-button:hover,
.ai-shortcut:hover {
  transform: translateY(-1px);
}

.primary-button:disabled,
.secondary-button:disabled,
.tab-button:disabled,
.page-button:disabled,
.toolbar-action:disabled {
  opacity: 0.55;
  cursor: not-allowed;
  transform: none;
}

.primary-button {
  padding: 13px 15px;
  background: linear-gradient(135deg, #5d8cbb, var(--brand));
  color: #fff;
}

.secondary-button {
  padding: 11px 14px;
  background: var(--brand-soft);
  color: var(--brand-dark);
  border-color: #d4e2f3;
}

.main-panel {
  display: grid;
  grid-template-rows: auto minmax(0, 1fr) auto;
  align-content: stretch;
  gap: 12px;
  padding: var(--panel-padding);
  overflow: visible;
  background: var(--panel);
  min-height: calc(100dvh - (var(--app-gap) * 2));
  min-width: 0;
  max-width: 100%;
  overflow-x: clip;
}

.main-panel-workspace {
  background:
    linear-gradient(180deg, rgba(255, 255, 255, 0.96) 0%, rgba(247, 251, 255, 0.92) 100%);
  box-shadow:
    0 18px 40px rgba(31, 47, 61, 0.08),
    inset 0 0 0 1px rgba(255, 255, 255, 0.55);
}

.main-header,
.selected-student-card,
.student-picker,
.prompt-actions-panel,
.prompt-preview {
  border: 1px solid var(--line);
  border-radius: 22px;
  background: rgba(255, 255, 255, 0.88);
}

.main-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 16px;
  padding: var(--section-padding-y) var(--section-padding-x);
  min-width: 0;
  overflow-x: clip;
  flex-wrap: wrap;
  background:
    linear-gradient(180deg, rgba(255, 255, 255, 0.94) 0%, rgba(246, 250, 255, 0.88) 100%);
}

.header-summary {
  margin: 6px 0 0;
  color: var(--muted);
}

.header-status {
  display: flex;
  gap: 10px;
  min-width: 0;
  flex-wrap: wrap;
  justify-content: flex-end;
}

.status-chip {
  display: grid;
  gap: 3px;
  min-width: 124px;
  padding: clamp(8px, 0.9vh, 10px) 12px;
  border-radius: 16px;
  border: 1px solid var(--line);
  background: #f8fbfe;
}

.status-chip strong {
  color: var(--brand-dark);
}

.app-toast {
  position: fixed;
  left: 50%;
  bottom: 18px;
  transform: translateX(-50%) translateY(8px);
  min-width: 180px;
  max-width: min(420px, calc(100vw - 32px));
  padding: 12px 16px;
  border: 1px solid rgba(45, 95, 139, 0.12);
  border-radius: 16px;
  background: rgba(31, 47, 61, 0.94);
  box-shadow: 0 18px 34px rgba(18, 28, 39, 0.2);
  color: #f7fbff;
  text-align: center;
  font-size: 0.9rem;
  font-weight: 700;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.18s ease, transform 0.18s ease;
  z-index: 60;
}

.app-toast-visible {
  opacity: 1;
  transform: translateX(-50%) translateY(0);
}

.selected-student-card {
  display: grid;
  gap: 8px;
  padding: var(--section-padding-y) var(--section-padding-x);
  min-width: 0;
  overflow-x: clip;
  background:
    linear-gradient(180deg, rgba(245, 249, 255, 0.98) 0%, rgba(238, 245, 255, 0.92) 100%);
  border-color: #d4e1f1;
}

.selected-top {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
  min-width: 0;
  flex-wrap: wrap;
}

.selected-identity {
  display: flex;
  align-items: center;
  gap: 12px;
  min-width: 0;
  flex-wrap: wrap;
}

.selected-avatar {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: clamp(36px, 4vh, 42px);
  height: clamp(36px, 4vh, 42px);
  border-radius: 999px;
  background: linear-gradient(135deg, #5d8cbb, var(--brand));
  color: #fff;
  font-size: clamp(0.9rem, 1.8vh, 1rem);
  font-weight: 800;
}

.selected-meta,
.selected-angle-text {
  margin: 4px 0 0;
  color: var(--muted);
}

.selected-quick-chips {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 6px;
  flex-wrap: wrap;
  min-width: 0;
}

.quick-chip {
  display: inline-flex;
  align-items: center;
  min-height: 28px;
  padding: 0 11px;
  border-radius: 999px;
  border: 1px solid rgba(45, 95, 139, 0.14);
  background: rgba(255, 255, 255, 0.78);
  color: var(--brand-dark);
  font-size: 0.8rem;
  font-weight: 700;
}

.selected-angle {
  display: grid;
  align-content: center;
  gap: 8px;
  padding: 14px 16px;
  border-radius: 18px;
  background: linear-gradient(135deg, rgba(232, 240, 251, 0.95), rgba(255, 255, 255, 0.9));
  border: 1px solid #dce7f5;
}

.selected-details {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 8px;
  min-width: 0;
}

.selected-response-actions {
  display: flex;
  justify-content: flex-end;
}

.danger-button {
  padding: 8px 11px;
  border: 1px solid #efc4bd;
  border-radius: 12px;
  background: #fff6f4;
  color: #a73e30;
  font: inherit;
  font-size: 0.82rem;
  font-weight: 700;
  cursor: pointer;
}

.danger-button:hover {
  border-color: #dc8f83;
  background: #feece8;
}

.detail-card {
  display: grid;
  gap: 5px;
  padding: clamp(7px, 0.8vh, 9px) 12px;
  border-radius: 16px;
  border: 1px solid rgba(219, 228, 238, 0.86);
  background: rgba(255, 255, 255, 0.82);
}

.detail-card span {
  color: var(--muted);
  font-size: 0.8rem;
  font-weight: 700;
}

.detail-card strong {
  font-size: 0.9rem;
  line-height: 1.28;
}

.student-picker {
  display: grid;
  grid-template-rows: auto minmax(0, 1fr);
  container-type: inline-size;
  align-content: stretch;
  gap: 8px;
  padding: var(--section-padding-y) var(--section-padding-x);
  min-height: 0;
  overflow: hidden;
  min-width: 0;
  background:
    linear-gradient(180deg, rgba(255, 255, 255, 0.94) 0%, rgba(249, 252, 255, 0.92) 100%);
}

.student-picker-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 16px;
  min-width: 0;
  flex-wrap: wrap;
}

.picker-controls {
  display: flex;
  align-items: center;
  gap: 8px;
  min-width: 0;
  flex-wrap: wrap;
  justify-content: flex-end;
}

.count-chip,
.page-indicator {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 38px;
  padding: 0 12px;
  border-radius: 999px;
  border: 1px solid var(--line);
  background: #f8fbfe;
  font-size: 0.9rem;
  font-weight: 700;
  color: var(--brand-dark);
}

.page-button {
  width: 38px;
  height: 38px;
  background: var(--panel-strong);
  border-color: var(--line);
  color: var(--brand-dark);
}

.page-button:disabled {
  opacity: 0.45;
  cursor: not-allowed;
  transform: none;
}

.student-grid {
  --student-grid-columns: 5;
  display: grid;
  grid-template-columns: repeat(var(--student-grid-columns), minmax(0, 1fr));
  grid-template-rows: repeat(var(--student-grid-rows, 3), minmax(var(--student-row-height), 1fr));
  grid-auto-rows: minmax(var(--student-row-height), 1fr);
  gap: 7px;
  height: 100%;
  min-height: 0;
  overflow: hidden;
  align-content: stretch;
  min-width: 0;
}

.student-tile {
  display: grid;
  justify-items: center;
  align-content: center;
  gap: 2px;
  appearance: none;
  -webkit-appearance: none;
  position: relative;
  border: 1px solid var(--line);
  border-radius: 14px;
  background: var(--panel-strong);
  color: var(--text);
  padding: 2px 6px;
  text-align: center;
  transition: transform 0.16s ease, border-color 0.16s ease, background 0.16s ease, box-shadow 0.16s ease;
}

.student-tile strong {
  font-size: 0.82rem;
  line-height: 1.1;
}

.student-tile:hover {
  border-color: rgba(45, 95, 139, 0.24);
  background: rgba(255, 255, 255, 0.96);
}

.student-tile:focus-visible {
  outline: 2px solid rgba(45, 95, 139, 0.22);
  outline-offset: 1px;
}

.student-tile-active {
  z-index: 1;
  border-color: rgba(45, 95, 139, 0.42);
  background: var(--brand-soft);
  box-shadow:
    inset 0 0 0 1px rgba(45, 95, 139, 0.12),
    0 10px 22px rgba(45, 95, 139, 0.08);
}

.prompt-actions-panel {
  display: grid;
  gap: 10px;
  padding: var(--section-padding-y) var(--section-padding-x);
  min-width: 0;
  background:
    linear-gradient(180deg, rgba(250, 252, 255, 0.94) 0%, rgba(244, 249, 255, 0.9) 100%);
}

.bottom-toolbar {
  display: grid;
  grid-template-columns: 1fr auto 1fr;
  align-items: center;
  gap: 12px;
  padding: 0;
  border-top: none;
  background: transparent;
  min-width: 0;
  overflow-x: clip;
}

.toolbar-preview-button {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  justify-self: start;
  padding: 10px 12px;
  border: 1px solid #d8e3ef;
  border-radius: 14px;
  background: rgba(255, 255, 255, 0.88);
  color: var(--brand-dark);
  font-weight: 700;
  cursor: pointer;
}

.toolbar-preview-line {
  display: inline-block;
  width: 34px;
  height: 5px;
  border-radius: 999px;
  background: #9db6cf;
}

.toolbar-copy-group {
  display: inline-flex;
  align-items: center;
  justify-self: center;
  gap: 12px;
  min-width: 0;
  flex-wrap: wrap;
}

.toolbar-action {
  min-width: var(--toolbar-button-width);
  padding: clamp(9px, 1vh, 11px) 16px;
  border: 1px solid transparent;
  border-radius: 14px;
  cursor: pointer;
  font-weight: 700;
  transition: transform 0.16s ease, background 0.16s ease, border-color 0.16s ease, color 0.16s ease;
}

.toolbar-action-primary {
  background: linear-gradient(135deg, #5d8cbb, var(--brand));
  color: #fff;
}

.toolbar-action-secondary {
  background: linear-gradient(135deg, #f6f9fd, #ebf2fb);
  color: var(--brand-dark);
  border-color: #d4e2f3;
}

.toolbar-ai-links {
  display: inline-flex;
  align-items: center;
  justify-self: end;
  gap: 10px;
  position: relative;
  min-width: 0;
  flex-wrap: wrap;
  padding: 6px 10px;
  border: 1px solid #dfe8f2;
  border-radius: 16px;
  background: rgba(255, 255, 255, 0.86);
}

.toolbar-ai-label {
  color: var(--muted);
  font-size: 0.78rem;
  font-weight: 800;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.help-bubble {
  position: relative;
}

.help-button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: clamp(30px, 3.4vh, 34px);
  height: clamp(30px, 3.4vh, 34px);
  border-radius: 999px;
  border: 1px solid var(--line);
  background: #f8fbfe;
  color: var(--brand-dark);
  font: inherit;
  font-weight: 800;
  cursor: pointer;
}

.help-tooltip {
  position: absolute;
  right: 0;
  bottom: calc(100% + 10px);
  width: 220px;
  padding: 12px 14px;
  border: 1px solid var(--line);
  border-radius: 16px;
  background: rgba(255, 255, 255, 0.98);
  box-shadow: 0 16px 34px rgba(31, 47, 61, 0.12);
  color: var(--text);
  opacity: 0;
  pointer-events: none;
  transform: translateY(6px);
  transition: opacity 0.16s ease, transform 0.16s ease;
  z-index: 5;
}

.help-tooltip strong {
  display: block;
  margin-bottom: 8px;
}

.help-tooltip p {
  margin: 4px 0;
  color: var(--muted);
  line-height: 1.35;
}

.help-bubble:hover .help-tooltip,
.help-bubble:focus-within .help-tooltip {
  opacity: 1;
  pointer-events: auto;
  transform: translateY(0);
}

.ai-shortcut {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: clamp(32px, 3.6vh, 36px);
  height: clamp(32px, 3.6vh, 36px);
  border-radius: 12px;
  border: 1px solid var(--line);
  background: #f8fbfe;
}

.ai-shortcut img {
  width: clamp(17px, 2.1vh, 19px);
  height: clamp(17px, 2.1vh, 19px);
  object-fit: contain;
}

.tile-avatar {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: clamp(18px, 2.35vh, 22px);
  height: clamp(18px, 2.35vh, 22px);
  border-radius: 999px;
  background: linear-gradient(135deg, #5d8cbb, var(--brand));
  color: #fff;
  font-size: clamp(0.62rem, 1.35vh, 0.7rem);
  font-weight: 800;
}

.empty-students {
  grid-column: 1 / -1;
  display: grid;
  gap: 8px;
  align-content: center;
  justify-items: center;
  min-height: 152px;
  padding: 20px;
  border: 1px dashed var(--line);
  border-radius: 18px;
  background: linear-gradient(180deg, rgba(247, 251, 255, 0.9) 0%, rgba(240, 246, 252, 0.92) 100%);
  color: var(--muted);
  text-align: center;
}

.empty-students strong {
  color: var(--brand-dark);
  font-size: 1rem;
}

.empty-students p {
  margin: 0;
  max-width: 32ch;
  line-height: 1.45;
}

.prompt-drawer {
  min-height: 0;
  background: rgba(255, 255, 255, 0.97);
  border: 1px solid var(--line);
  border-radius: 16px;
  overflow: hidden;
  min-width: 0;
}

.prompt-drawer-open {
  display: block;
}

.drawer-content {
  display: grid;
  gap: 8px;
  padding: 10px 12px;
}

.drawer-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 16px;
}

.drawer-actions {
  display: flex;
  align-items: center;
  gap: 10px;
}

.tab-button {
  padding: 10px 13px;
  background: #f4f7fb;
  color: var(--muted);
  border-color: var(--line);
}

.tab-button-active {
  background: var(--brand-soft);
  color: var(--brand-dark);
  border-color: #d4e2f3;
}

.prompt-preview {
  margin: 0;
  height: var(--prompt-preview-height);
  padding: 10px 12px;
  overflow-y: auto;
  overflow-x: hidden;
  white-space: pre-wrap;
  font-family: Consolas, "Courier New", monospace;
  line-height: 1.35;
  font-size: 0.8rem;
}

html[data-density="cozy"] {
  --student-row-height: 42px;
  --prompt-preview-height: 92px;
}

html[data-density="compact"] {
  --app-gap: 10px;
  --panel-padding: 10px;
  --section-padding-y: 8px;
  --section-padding-x: 12px;
  --student-row-height: 40px;
  --toolbar-button-width: 138px;
  --prompt-preview-height: 78px;
}

@container (min-width: 1700px) {
  .student-grid {
    --student-grid-columns: 6;
  }
}

@container (max-width: 1320px) {
  .student-grid {
    --student-grid-columns: 4;
  }
}

@container (max-width: 980px) {
  .student-grid {
    --student-grid-columns: 3;
  }
}

@container (max-width: 720px) {
  .student-grid {
    --student-grid-columns: 2;
  }
}

@media (max-width: 1120px) {
  .compact-app {
    grid-template-columns: clamp(188px, 20vw, 220px) minmax(0, 1fr);
  }

  .auth-shell {
    grid-template-columns: 1fr;
  }

  .bottom-toolbar {
    grid-template-columns: 1fr auto 1fr;
  }

  .selected-top {
    align-items: flex-start;
  }

  .selected-quick-chips {
    justify-content: flex-start;
  }

  .selected-response-actions {
    justify-content: flex-start;
  }

  .selected-details {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .toolbar-copy-group {
    flex-wrap: wrap;
    justify-content: center;
  }

  .toolbar-action {
    min-width: 156px;
  }
}

@media (max-height: 820px) {
  .selected-details {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .sidebar-brand h1,
  .main-header h2,
  .student-picker h3 {
    font-size: 0.92em;
  }

  .sidebar-brand {
    gap: 6px;
    padding: 9px 11px;
  }

  .sidebar-copy {
    font-size: 0.75rem;
    line-height: 1.18;
  }
}

/* Keep the complete teacher sidebar visible on short desktop-width mobile browsers. */
@media (max-height: 900px) and (min-width: 761px) {
  .sidebar {
    gap: 6px;
    padding: 6px;
    overflow-y: hidden;
  }

  .sidebar-stack {
    gap: 6px;
  }

  .sidebar-brand,
  .sidebar-card {
    gap: 4px;
    padding: 7px 8px;
    border-radius: 18px;
  }

  .sidebar-brand {
    gap: 3px;
  }

  .brand-mark {
    width: 34px;
    height: 34px;
    border-radius: 11px;
  }

  .sidebar-teacher-name {
    margin-top: 1px;
    font-size: 0.98rem;
  }

  .sidebar-brand-actions {
    gap: 5px;
    margin-top: 1px;
  }

  .sync-pill {
    min-height: 24px;
    padding: 0 7px;
    font-size: 0.7rem;
  }

  .sidebar-tour-button {
    min-height: 26px;
    padding: 0 8px;
    font-size: 0.7rem;
  }

  .sidebar-kicker {
    font-size: 0.66rem;
  }

  .sidebar-card h2 {
    margin-top: 1px;
    font-size: 0.94rem;
  }

  .sidebar label {
    font-size: 0.82rem;
  }

  .sidebar input,
  .sidebar select {
    padding: 8px 11px;
    border-radius: 14px;
  }

  .sidebar-nav {
    gap: 4px;
  }

  .sidebar-link {
    min-height: 30px;
    padding: 5px 9px;
  }
}

@media (max-width: 980px) {
  .walkthrough-grid,
  .walkthrough-grid-tour,
  .selected-details,
  .modal-form-grid {
    grid-template-columns: 1fr;
  }

  .modal-shell {
    grid-template-columns: 1fr;
    max-height: min(88vh, 920px);
  }

  .modal-sidebar {
    gap: 14px;
  }

  .modal-nav {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
}

@media (max-width: 760px) {
  .standalone-screen,
  .modal-backdrop {
    padding: 14px;
  }

  .compact-app {
    grid-template-columns: 1fr;
  }

  .sidebar {
    max-height: none;
    overflow: visible;
    overscroll-behavior: auto;
  }

  .drawer-head {
    flex-direction: column;
    gap: 12px;
  }

  .drawer-actions {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    width: 100%;
  }

  .drawer-actions button {
    width: 100%;
  }

  .prompt-preview {
    height: clamp(180px, 30vh, 260px);
    font-size: 0.82rem;
  }

  .header-status,
  .student-picker-head,
  .bottom-toolbar,
  .survey-create-row {
    grid-template-columns: 1fr;
    display: grid;
  }

  .toolbar-copy-group,
  .toolbar-ai-links {
    justify-self: start;
  }

  .header-status,
  .picker-controls {
    justify-content: flex-start;
  }

  .modal-nav {
    grid-template-columns: 1fr;
  }
}
