*,
*::before,
*::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

:root {
  --bg: #f4f5f8;
  --surface: #ffffff;
  --text: #14161d;
  --text-muted: #6b7280;
  --primary: #4f46e5;
  --primary-hover: #4338ca;
  --primary-soft: #eef2ff;
  --accent: #059669;
  --accent-bg: #ecfdf5;
  --warning: #d97706;
  --warning-bg: #fffbeb;
  --danger: #dc2626;
  --submitted: #7c3aed;
  --submitted-bg: #f3e8ff;
  --border: #e6e8ee;
  --radius: 14px;
  --radius-sm: 9px;
  --shadow: 0 1px 3px rgba(20, 22, 29, 0.06);
  --shadow-lg: 0 10px 30px rgba(20, 22, 29, 0.08);
  --content-max: 1080px;
}

html { font-size: 16px; }

body {
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  background: var(--bg);
  color: var(--text);
  line-height: 1.5;
  min-height: 100dvh;
}

.app-shell {
  min-height: 100dvh;
  display: flex;
  flex-direction: column;
}

/* ---------- Topbar / brand / tabs ---------- */

.topbar {
  position: sticky;
  top: 0;
  z-index: 20;
  background: rgba(255, 255, 255, 0.9);
  backdrop-filter: blur(8px);
  border-bottom: 1px solid var(--border);
  padding: 14px 32px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 24px;
}

.brand {
  display: flex;
  align-items: center;
  gap: 10px;
}

.brand-mark {
  width: 34px;
  height: 34px;
  border-radius: 10px;
  background: linear-gradient(135deg, var(--primary) 0%, #7c3aed 100%);
  color: #fff;
  font-size: 1.25rem;
  font-weight: 700;
  display: grid;
  place-items: center;
  line-height: 1;
}

.brand-name {
  font-size: 1.3rem;
  font-weight: 700;
  letter-spacing: -0.02em;
}

.brand-sub {
  font-size: 0.8125rem;
  color: var(--text-muted);
  padding-left: 10px;
  margin-left: 4px;
  border-left: 1px solid var(--border);
}

.tab-switch {
  display: flex;
  gap: 4px;
  background: var(--bg);
  border-radius: 11px;
  padding: 4px;
}

.tab-btn {
  padding: 9px 22px;
  border: none;
  border-radius: 8px;
  background: transparent;
  font-size: 0.9rem;
  font-weight: 500;
  color: var(--text-muted);
  cursor: pointer;
  transition: background 0.15s, color 0.15s;
}

.tab-btn.active {
  background: var(--surface);
  color: var(--primary);
  box-shadow: var(--shadow);
}

/* ---------- Subhead ---------- */

.subhead {
  display: flex;
  align-items: center;
  gap: 16px;
  padding: 22px 32px 0;
  max-width: calc(var(--content-max) + 64px);
  width: 100%;
  margin: 0 auto;
}

.page-title {
  font-size: 1.6rem;
  font-weight: 700;
  letter-spacing: -0.01em;
}

.page-actions {
  margin-left: auto;
}

.main {
  flex: 1;
  padding: 20px 32px 48px;
  max-width: calc(var(--content-max) + 64px);
  width: 100%;
  margin: 0 auto;
}

.page-content { max-width: var(--content-max); }

.lead {
  color: var(--text-muted);
  margin-bottom: 20px;
  font-size: 0.95rem;
}

.hidden { display: none !important; }

/* ---------- Buttons ---------- */

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  padding: 11px 18px;
  border: none;
  border-radius: var(--radius-sm);
  font-size: 0.9rem;
  font-weight: 600;
  cursor: pointer;
  transition: background 0.15s, opacity 0.15s, transform 0.05s;
}

.btn:active { transform: translateY(1px); }
.btn-primary { background: var(--primary); color: #fff; }
.btn-primary:hover { background: var(--primary-hover); }
.btn-primary:disabled { opacity: 0.7; cursor: default; }

.btn-secondary {
  background: var(--surface);
  color: var(--primary);
  border: 1px solid var(--border);
}
.btn-secondary:hover { background: var(--bg); }
.btn-inline { width: auto; }

.btn-back {
  padding: 8px 14px;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--surface);
  font-size: 0.875rem;
  cursor: pointer;
  color: var(--text);
  white-space: nowrap;
}
.btn-back:hover { background: var(--bg); }

.link-btn {
  background: none;
  border: none;
  color: var(--primary);
  font-size: 0.85rem;
  font-weight: 500;
  cursor: pointer;
  padding: 0;
}
.link-btn:hover { text-decoration: underline; }
.link-btn--danger { color: var(--danger); }

/* ---------- Cards / grid ---------- */

.card {
  background: var(--surface);
  border-radius: var(--radius);
  padding: 20px;
  box-shadow: var(--shadow);
  border: 1px solid var(--border);
  cursor: pointer;
  transition: box-shadow 0.15s, border-color 0.15s, transform 0.1s;
}
.card:hover {
  border-color: #d3d7e2;
  box-shadow: var(--shadow-lg);
  transform: translateY(-1px);
}

.card-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
  gap: 16px;
}

.card-title { font-size: 1.05rem; font-weight: 600; margin-bottom: 4px; }
.card-meta { font-size: 0.875rem; color: var(--text-muted); }

.card-badge {
  display: inline-block;
  font-size: 0.75rem;
  font-weight: 600;
  padding: 3px 10px;
  border-radius: 999px;
  margin-right: 6px;
}
.badge-new { background: var(--primary-soft); color: var(--primary); }
.badge-viewed { background: var(--accent-bg); color: var(--accent); }
.badge-deadline { background: var(--warning-bg); color: var(--warning); }
.badge-overdue { background: #fee2e2; color: var(--danger); }
.badge-submitted { background: var(--submitted-bg); color: var(--submitted); }

.section-title {
  font-size: 0.8rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--text-muted);
  margin: 28px 0 14px;
}

/* ---------- Materials ---------- */

.material-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(260px, 1fr));
  gap: 16px;
}
.material-grid--compact { grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)); }

.material-cell { display: flex; flex-direction: column; gap: 8px; }

.material-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 18px;
  box-shadow: var(--shadow);
  height: 100%;
}

.material-kind {
  display: inline-block;
  font-size: 0.72rem;
  font-weight: 600;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.04em;
  margin-bottom: 8px;
}
.material-title { font-weight: 600; font-size: 0.98rem; }
.material-body { font-size: 0.85rem; color: var(--text-muted); margin-top: 6px; }
.material-link {
  display: inline-block;
  margin-top: 10px;
  color: var(--primary);
  font-size: 0.85rem;
  font-weight: 600;
  word-break: break-all;
}
.material-cell-actions { display: flex; gap: 14px; padding-left: 4px; }

.material-mini-list { display: flex; flex-wrap: wrap; gap: 8px; }
.material-chip {
  background: var(--primary-soft);
  color: var(--primary);
  font-size: 0.8rem;
  font-weight: 500;
  padding: 5px 12px;
  border-radius: 999px;
}

.material-picker {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
  gap: 10px;
  margin-top: 8px;
}
.material-pick {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 6px 10px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 12px 14px;
  cursor: pointer;
  background: var(--surface);
  transition: border-color 0.15s, background 0.15s;
}
.material-pick.is-checked,
.material-pick:has(input:checked) {
  border-color: var(--primary);
  background: var(--primary-soft);
}
.material-pick input { width: auto; margin: 0; }
.material-pick .material-kind { margin: 0; width: 100%; }
.material-pick .material-title { font-size: 0.9rem; }

/* ---------- Student cards ---------- */

.student-card { display: flex; flex-direction: column; gap: 12px; }
.student-avatar {
  width: 46px;
  height: 46px;
  border-radius: 12px;
  background: linear-gradient(135deg, var(--primary) 0%, #7c3aed 100%);
  color: #fff;
  font-weight: 700;
  display: grid;
  place-items: center;
}
.student-main { flex: 1; display: flex; flex-direction: column; gap: 2px; }
.student-main .card-badge { margin-top: 6px; }
.student-card-foot { border-top: 1px solid var(--border); padding-top: 12px; }

/* ---------- Share box ---------- */

.share-box {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  background: var(--primary-soft);
  border: 1px solid #dfe3fb;
  border-radius: var(--radius);
  padding: 16px 20px;
  margin-bottom: 24px;
  flex-wrap: wrap;
}
.share-label { font-size: 0.78rem; font-weight: 600; color: var(--primary); text-transform: uppercase; letter-spacing: 0.04em; margin-bottom: 4px; }
.share-link { font-size: 0.85rem; color: var(--text); word-break: break-all; }

/* ---------- Profile ---------- */

.profile-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 24px;
  margin-bottom: 24px;
  padding-bottom: 20px;
  border-bottom: 1px solid var(--border);
}
.profile-name { font-size: 1.6rem; font-weight: 700; margin-bottom: 6px; }
.profile-note { font-size: 0.92rem; color: var(--text-muted); max-width: 620px; }

/* ---------- Detail blocks ---------- */

.detail-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }
.detail-grid .detail-block--full { grid-column: 1 / -1; }

.detail-block {
  background: var(--surface);
  border-radius: var(--radius);
  padding: 20px;
  border: 1px solid var(--border);
  box-shadow: var(--shadow);
}
.detail-block h2 {
  font-size: 0.78rem;
  font-weight: 700;
  color: var(--text-muted);
  margin-bottom: 10px;
  text-transform: uppercase;
  letter-spacing: 0.04em;
}
.detail-block p { font-size: 0.95rem; white-space: pre-wrap; }

.submission-block { border-color: #dfe3fb; background: #fbfbff; }
.comment-block { border-left: 3px solid var(--primary); }

.lesson-head { display: flex; justify-content: space-between; align-items: flex-start; gap: 16px; }

/* ---------- Forms ---------- */

.form-panel { max-width: 680px; }
.form-panel--wide { max-width: 860px; }
.form-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }
.form-grid .form-group--full { grid-column: 1 / -1; }
.form-group { margin-bottom: 4px; }
.form-group label { display: block; font-size: 0.875rem; font-weight: 600; margin-bottom: 6px; }
.form-group .hint { font-size: 0.75rem; color: var(--text-muted); margin-top: 6px; }

.form-group input,
.form-group textarea,
.form-group select {
  width: 100%;
  padding: 10px 12px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  font-size: 0.95rem;
  font-family: inherit;
  background: var(--surface);
}
.form-group input:focus,
.form-group textarea:focus,
.form-group select:focus {
  outline: none;
  border-color: var(--primary);
  box-shadow: 0 0 0 3px var(--primary-soft);
}
.form-group textarea { min-height: 100px; resize: vertical; }
.form-actions { display: flex; gap: 12px; margin-top: 16px; }

/* ---------- Empty state ---------- */

.empty-state {
  text-align: center;
  padding: 60px 20px;
  color: var(--text-muted);
  background: var(--surface);
  border: 1px dashed var(--border);
  border-radius: var(--radius);
}
.empty-title { font-size: 1.1rem; font-weight: 600; color: var(--text); margin-bottom: 8px; }
.empty-state p { margin-bottom: 12px; }

/* ---------- Student view ---------- */

.student-mode .topbar { background: #ffffff; }

.course-hero {
  background: linear-gradient(135deg, #4f46e5 0%, #7c3aed 100%);
  color: #fff;
  border-radius: 20px;
  padding: 32px;
  margin-bottom: 12px;
  box-shadow: var(--shadow-lg);
}
.course-hero-badge {
  display: inline-block;
  font-size: 0.72rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  background: rgba(255, 255, 255, 0.2);
  padding: 5px 12px;
  border-radius: 999px;
  margin-bottom: 14px;
}
.course-hero-title { font-size: 1.9rem; font-weight: 800; letter-spacing: -0.02em; }
.course-hero-desc { margin-top: 10px; opacity: 0.92; max-width: 640px; }

.progress { margin-top: 22px; }
.progress-bar {
  height: 8px;
  background: rgba(255, 255, 255, 0.25);
  border-radius: 999px;
  overflow: hidden;
}
.progress-bar span { display: block; height: 100%; background: #fff; border-radius: 999px; transition: width 0.3s; }
.progress-label { margin-top: 8px; font-size: 0.85rem; opacity: 0.92; }

.lesson-list { display: flex; flex-direction: column; gap: 12px; }
.lesson-row { display: flex; align-items: center; gap: 16px; }
.lesson-index {
  width: 38px;
  height: 38px;
  flex-shrink: 0;
  border-radius: 10px;
  background: var(--primary-soft);
  color: var(--primary);
  font-weight: 700;
  display: grid;
  place-items: center;
}
.lesson-row-main { flex: 1; min-width: 0; }
.lesson-badges { margin-top: 8px; display: flex; flex-wrap: wrap; gap: 6px; }
.lesson-arrow { color: var(--text-muted); font-size: 1.2rem; }

.submission-form { margin-top: 16px; display: grid; gap: 12px; }
.submission-form .btn { justify-self: start; }

/* ---------- AI feedback ---------- */

.feedback-area {
  margin-top: 20px;
  padding-top: 20px;
  border-top: 1px dashed var(--border);
}
.ai-row {
  display: flex;
  align-items: center;
  gap: 12px;
  flex-wrap: wrap;
  margin-bottom: 10px;
}
.ai-hint { font-size: 0.82rem; color: var(--text-muted); }
.ai-status {
  font-size: 0.82rem;
  color: var(--primary);
  min-height: 1.1em;
  margin-bottom: 8px;
}
.ai-status--error { color: var(--danger); }
.ai-file-warning {
  background: #fff8e6;
  border: 1px solid #f0d78c;
  color: #6b5a1e;
  border-radius: var(--radius-sm);
  padding: 10px 12px;
  font-size: 0.88rem;
  margin-bottom: 12px;
  line-height: 1.4;
}

#feedback-form { display: grid; gap: 12px; }
#feedback-form .btn { justify-self: start; }

.wysiwyg {
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--surface);
  overflow: hidden;
}
.wysiwyg:focus-within {
  border-color: var(--primary);
  box-shadow: 0 0 0 3px var(--primary-soft);
}
.wysiwyg-toolbar {
  display: flex;
  gap: 4px;
  padding: 6px 8px;
  border-bottom: 1px solid var(--border);
  background: #f7f8fa;
}
.wysiwyg-btn {
  border: 1px solid var(--border);
  background: #fff;
  border-radius: 6px;
  padding: 4px 10px;
  font-size: 0.85rem;
  cursor: pointer;
  color: var(--text);
}
.wysiwyg-btn:hover { background: var(--primary-soft); border-color: var(--primary); }
.wysiwyg-editor {
  min-height: 130px;
  padding: 12px;
  font-family: inherit;
  font-size: 0.95rem;
  line-height: 1.5;
  outline: none;
}
.wysiwyg-editor:empty:before {
  content: attr(data-placeholder);
  color: var(--text-muted);
  pointer-events: none;
}
.wysiwyg-editor ul { margin: 0.4em 0 0.4em 1.2em; padding: 0; }

.feedback-send-status {
  font-size: 0.88rem;
  color: var(--primary);
  margin: 0;
}
.feedback-send-status--error { color: var(--danger); }
.feedback-sent-hint {
  margin: 0;
  padding: 10px 12px;
  border-radius: var(--radius-sm);
  background: #e8f7ee;
  color: #1b6b3a;
  font-size: 0.9rem;
  font-weight: 600;
}

.feedback-view {
  border-left: 3px solid var(--accent);
  background: var(--accent-bg);
}
.feedback-html { font-size: 0.95rem; line-height: 1.5; }
.feedback-html ul { margin: 0.4em 0 0.4em 1.2em; }

/* ---------- Buttons (small) ---------- */

.btn-sm { padding: 7px 14px; font-size: 0.83rem; border-radius: 8px; }
.header-btns { display: flex; gap: 12px; align-items: center; }

/* ---------- Material cards (library) ---------- */

.material-card-lg { display: flex; flex-direction: column; cursor: default; }
.material-card-lg:hover { transform: none; }
.material-card-info { margin-top: 8px; }
.card-actions {
  display: flex;
  align-items: center;
  gap: 14px;
  margin-top: 16px;
  padding-top: 14px;
  border-top: 1px solid var(--border);
}

/* ---------- Blocks: read-only view ---------- */

.blocks-view { display: flex; flex-direction: column; gap: 12px; }
.block {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 16px 18px;
  box-shadow: var(--shadow);
  font-size: 0.95rem;
}
.block--note { white-space: normal; line-height: 1.55; }
.block--link { display: flex; align-items: center; gap: 8px; }
.block--link a { color: var(--primary); word-break: break-all; font-weight: 500; }
.block-ico { flex-shrink: 0; }
.block-file-name { display: flex; align-items: center; gap: 8px; font-weight: 500; margin-bottom: 10px; }
.block--file a { color: var(--primary); word-break: break-all; }
.block-img {
  max-width: 100%;
  max-height: 320px;
  border-radius: 10px;
  border: 1px solid var(--border);
  display: block;
}

/* ---------- Blocks: editor ---------- */

.editor-page { max-width: 780px; }
.editor-section { margin-top: 24px; }
.editor-section-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-bottom: 12px; }

.blocks-editor { display: flex; flex-direction: column; gap: 12px; }
.blocks-empty { padding: 8px 0; }

.block-row {
  display: flex;
  align-items: flex-start;
  gap: 12px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 14px 16px;
  box-shadow: var(--shadow);
}
.block-row-body { flex: 1; min-width: 0; }
.block-row-body .block { border: none; box-shadow: none; padding: 0; background: transparent; }
.block-row-actions { display: flex; flex-direction: column; gap: 6px; flex-shrink: 0; }

.block-editor {
  border: 1px solid var(--primary);
  border-radius: var(--radius);
  padding: 16px;
  background: var(--primary-soft);
  display: flex;
  flex-direction: column;
  gap: 10px;
}
.block-editor-head { font-size: 0.78rem; font-weight: 700; text-transform: uppercase; letter-spacing: 0.04em; color: var(--primary); }
.block-editor input {
  width: 100%;
  padding: 10px 12px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  font-family: inherit;
  font-size: 0.95rem;
  background: var(--surface);
}
.block-editor .wysiwyg { background: var(--surface); }
.block-editor-actions { display: flex; align-items: center; gap: 14px; }

.file-input-row { display: flex; flex-wrap: wrap; align-items: center; gap: 10px; }
.file-input-hidden {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}
.file-pick-btn { cursor: pointer; margin: 0; }
.file-current { font-size: 0.82rem; color: var(--text-muted); }

.add-block-row { display: flex; gap: 10px; align-items: center; }
.add-block-type {
  padding: 9px 12px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  font-family: inherit;
  font-size: 0.9rem;
  background: var(--surface);
}

.hw-editor-block {
  border: 1px dashed var(--border);
  border-radius: var(--radius);
  padding: 16px;
  background: #fbfbfe;
}
.hw-meta-row { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; margin-bottom: 16px; }

.label-hint { font-weight: 400; color: var(--text-muted); font-size: 0.8rem; }

/* ---------- Homework meta ---------- */

.hw-meta { display: flex; flex-wrap: wrap; gap: 14px; align-items: center; margin-top: 12px; font-size: 0.9rem; color: var(--text-muted); }

/* ---------- Visibility tags ---------- */

.vis-tag {
  font-size: 0.68rem;
  font-weight: 600;
  padding: 2px 8px;
  border-radius: 999px;
  text-transform: uppercase;
  letter-spacing: 0.03em;
  margin-left: 6px;
  vertical-align: middle;
}
.vis-yes { background: var(--accent-bg); color: var(--accent); }
.vis-no { background: #f1f3f6; color: var(--text-muted); }
.profile-note--private { color: var(--text-muted); font-style: italic; margin-top: 6px; }

/* ---------- Add material to student ---------- */

.add-material-box { display: flex; gap: 12px; align-items: center; flex-wrap: wrap; }
.add-material-box select {
  flex: 1;
  min-width: 220px;
  padding: 10px 12px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  font-family: inherit;
  font-size: 0.95rem;
  background: var(--surface);
}

/* ---------- Feedback footer ---------- */

.feedback-foot { display: flex; gap: 12px; align-items: center; flex-wrap: wrap; }
.feedback-foot select {
  padding: 10px 12px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  font-family: inherit;
  font-size: 0.92rem;
  background: var(--surface);
}

/* ---------- Access gate ---------- */

.gate {
  position: fixed;
  inset: 0;
  z-index: 1000;
  display: grid;
  place-items: center;
  background:
    radial-gradient(ellipse at 20% 20%, rgba(79, 70, 229, 0.12), transparent 50%),
    radial-gradient(ellipse at 80% 80%, rgba(5, 150, 105, 0.1), transparent 45%),
    var(--bg);
  padding: 24px;
}

.gate[hidden] { display: none !important; }

.gate-card {
  width: min(400px, 100%);
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow-lg);
  padding: 28px 24px;
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.gate-brand {
  margin: 0;
  font-size: 0.95rem;
  color: var(--text-muted);
  letter-spacing: 0.02em;
}

.gate-title {
  margin: 0;
  font-size: 1.45rem;
  font-weight: 700;
  color: var(--text);
}

.gate-hint {
  margin: 0;
  color: var(--text-muted);
  font-size: 0.92rem;
  line-height: 1.45;
}

.auth-tabs {
  display: flex;
  gap: 4px;
  padding: 4px;
  background: var(--bg);
  border-radius: var(--radius-sm);
}

.auth-tab {
  flex: 1;
  border: none;
  background: transparent;
  padding: 8px 10px;
  border-radius: 7px;
  font: inherit;
  font-size: 0.9rem;
  color: var(--text-muted);
  cursor: pointer;
}

.auth-tab.active {
  background: var(--surface);
  color: var(--text);
  font-weight: 600;
  box-shadow: var(--shadow);
}

.auth-panel {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.auth-panel[hidden] { display: none !important; }

.gate-label {
  font-size: 0.82rem;
  color: var(--text-muted);
  margin-bottom: -4px;
}

.gate-input {
  padding: 12px 14px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  font-family: inherit;
  font-size: 1rem;
  background: var(--bg);
}

.gate-input:focus {
  outline: 2px solid var(--primary-soft);
  border-color: var(--primary);
}

.gate-error {
  margin: 0;
  color: var(--danger);
  font-size: 0.88rem;
}

.gate-submit { align-self: flex-start; margin-top: 4px; }

.gate-password-hint {
  margin: -2px 0 0;
  font-size: 0.82rem;
  color: var(--text-muted);
  line-height: 1.4;
}

.topbar-user {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-left: auto;
}

.topbar-email {
  font-size: 0.85rem;
  color: var(--text-muted);
  max-width: 180px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.btn-ghost {
  background: transparent;
  border: 1px solid var(--border);
  color: var(--text-muted);
  padding: 6px 12px;
  border-radius: var(--radius-sm);
  font: inherit;
  font-size: 0.85rem;
  cursor: pointer;
}

.btn-ghost:hover {
  color: var(--text);
  border-color: var(--text-muted);
}

.gate-help-link {
  margin: 4px 0 0;
  text-align: center;
  font-size: 0.9rem;
}

.gate-help-link a {
  color: var(--primary);
  text-decoration: none;
}

.gate-help-link a:hover {
  text-decoration: underline;
}

.topbar-help {
  font-size: 0.85rem;
  color: var(--text-muted);
  text-decoration: none;
  padding: 6px 8px;
}

.topbar-help:hover {
  color: var(--primary);
}

/* ---------- Responsive ---------- */

@media (max-width: 860px) {
  .topbar { flex-wrap: wrap; padding: 12px 16px; gap: 12px; }
  .brand-sub { display: none; }
  .tab-switch { width: 100%; }
  .tab-btn { flex: 1; }
  .subhead { padding: 16px 16px 0; flex-wrap: wrap; }
  .main { padding: 16px; }
  .detail-grid, .form-grid, .material-picker, .hw-meta-row { grid-template-columns: 1fr; }
  .block-row { flex-direction: column; }
  .block-row-actions { flex-direction: row; }
  .profile-header { flex-direction: column; }
  .course-hero { padding: 24px; }
  .course-hero-title { font-size: 1.5rem; }
}
