@import url("https://fonts.googleapis.com/css2?family=IBM+Plex+Mono:wght@400;500;600&family=Noto+Sans+SC:wght@400;500;600;700&family=Plus+Jakarta+Sans:wght@500;600;700&display=swap");

:root {
  --bg: #f6f8fb;
  --surface: #ffffff;
  --surface-2: #f1f5f9;
  --surface-3: #e8eef6;
  --border: #e2e8f0;
  --border-strong: #cbd5e1;
  --ink: #0f172a;
  --ink-2: #334155;
  --muted: #64748b;

  /* Default Student Cobalt Accent */
  --accent: #1d4ed8;
  --accent-hover: #1e40af;
  --accent-soft: #eff6ff;
  --accent-border: #bfdbfe;

  /* Semantic */
  --ok: #15803d;
  --ok-soft: #f0fdf4;
  --ok-border: #bbf7d0;
  --warn: #b45309;
  --warn-soft: #fffbeb;
  --warn-border: #fde68a;
  --danger: #b91c1c;
  --danger-soft: #fef2f2;
  --danger-border: #fecaca;

  --radius-sm: 6px;
  --radius-md: 10px;
  --radius-lg: 14px;
  --shadow-sm: 0 1px 2px rgba(15, 23, 42, 0.05);
  --shadow-md: 0 6px 20px rgba(15, 23, 42, 0.07);
  --shadow-lg: 0 18px 42px rgba(15, 23, 42, 0.16);

  --topbar-h: 52px;
  --bottombar-h: 60px;
  --sidebar-w: 248px;

  --font-sans: "Plus Jakarta Sans", "Noto Sans SC", -apple-system, BlinkMacSystemFont, "PingFang SC", "Microsoft YaHei", sans-serif;
  --font-mono: "IBM Plex Mono", ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
}

body.role-mentor {
  --accent: #0f766e;
  --accent-hover: #115e59;
  --accent-soft: #f0fdfa;
  --accent-border: #99f6e4;
}

*,
*::before,
*::after {
  box-sizing: border-box;
}

html,
body {
  margin: 0;
  padding: 0;
  background: var(--bg);
  color: var(--ink);
  font-family: var(--font-sans);
  font-size: 15px;
  line-height: 1.55;
  -webkit-font-smoothing: antialiased;
  overflow-x: hidden;
}

a {
  color: var(--accent);
  text-decoration: none;
}

a:hover {
  text-decoration: underline;
}

button,
input,
select,
textarea {
  font-family: inherit;
  font-size: 15px;
  color: var(--ink);
}

button {
  cursor: pointer;
}

button:focus-visible,
a:focus-visible,
input:focus-visible,
select:focus-visible,
textarea:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

.mono,
.tabular {
  font-variant-numeric: tabular-nums;
}

.mono {
  font-family: var(--font-mono);
}

.hidden {
  display: none !important;
}

/* ── Brand Mark ─────────────────────────────────────────── */

.brand-link {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  color: var(--ink);
  font-weight: 700;
  font-size: 16px;
  letter-spacing: -0.01em;
  text-decoration: none;
}

.brand-link:hover {
  text-decoration: none;
}

.brand-mark {
  width: 30px;
  height: 30px;
  border-radius: 8px;
  background: var(--accent);
  color: #ffffff;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: 15px;
  font-weight: 700;
  flex-shrink: 0;
}

.brand-mark-img {
  width: 30px;
  height: 30px;
  border-radius: 8px;
  object-fit: cover;
  flex-shrink: 0;
  display: block;
}

.brand-sub {
  font-size: 12px;
  font-weight: 500;
  color: var(--muted);
  display: block;
  line-height: 1.2;
}

/* ── Buttons ────────────────────────────────────────────── */

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  min-height: 44px;
  padding: 0 16px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border-strong);
  background: var(--surface);
  color: var(--ink);
  font-size: 14px;
  font-weight: 600;
  line-height: 1;
  transition: background-color 0.15s ease, border-color 0.15s ease, color 0.15s ease;
  white-space: nowrap;
}

.btn:hover:not(:disabled) {
  background: var(--surface-2);
  text-decoration: none;
}

.btn:disabled {
  opacity: 0.52;
  cursor: not-allowed;
}

.btn-primary {
  background: var(--accent);
  border-color: var(--accent);
  color: #ffffff;
}

.btn-primary:hover:not(:disabled) {
  background: var(--accent-hover);
  border-color: var(--accent-hover);
  color: #ffffff;
}

.btn-soft {
  background: var(--accent-soft);
  border-color: var(--accent-border);
  color: var(--accent);
}

.btn-soft:hover:not(:disabled) {
  background: var(--accent-border);
}

.btn-danger {
  background: var(--danger-soft);
  border-color: var(--danger-border);
  color: var(--danger);
}

.btn-danger:hover:not(:disabled) {
  background: #fee2e2;
}

.btn-ghost {
  background: transparent;
  border-color: transparent;
  color: var(--ink-2);
}

.btn-ghost:hover:not(:disabled) {
  background: var(--surface-2);
  color: var(--ink);
}

.btn-sm {
  min-height: 36px;
  padding: 0 12px;
  font-size: 13px;
}

.btn-block {
  width: 100%;
}

/* ── Forms ──────────────────────────────────────────────── */

.field {
  display: flex;
  flex-direction: column;
  gap: 6px;
  margin-bottom: 14px;
}

.field label {
  font-size: 13px;
  font-weight: 600;
  color: var(--ink-2);
}

.field-hint {
  font-size: 12px;
  color: var(--muted);
  margin: 0;
}

.input,
.select,
.textarea {
  width: 100%;
  min-height: 44px;
  padding: 10px 12px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border-strong);
  background: var(--surface);
  color: var(--ink);
  transition: border-color 0.15s ease, box-shadow 0.15s ease;
}

.textarea {
  min-height: 96px;
  resize: vertical;
  line-height: 1.55;
}

.input:focus,
.select:focus,
.textarea:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-soft);
  outline: none;
}

.input-row {
  display: flex;
  gap: 8px;
  align-items: stretch;
}

.input-row > .input {
  flex: 1;
  min-width: 0;
}

/* ── Cards & Panels ─────────────────────────────────────── */

.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  padding: 20px;
  box-shadow: var(--shadow-sm);
  min-width: 0;
}

.card-muted {
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  padding: 16px;
}

.card-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 16px;
}

.card-title {
  margin: 0;
  font-size: 16px;
  font-weight: 700;
  color: var(--ink);
  letter-spacing: -0.01em;
}

.card-desc {
  margin: 4px 0 0;
  font-size: 13px;
  color: var(--muted);
}

.section-header {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 18px;
  flex-wrap: wrap;
}

.section-title {
  margin: 0;
  font-size: 22px;
  font-weight: 700;
  letter-spacing: -0.02em;
  color: var(--ink);
}

.section-sub {
  margin: 4px 0 0;
  font-size: 14px;
  color: var(--muted);
}

/* ── Status Tags (Stateful Only, Crisp Rectangle) ───────── */

.status-tag {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 3px 8px;
  border-radius: 5px;
  font-size: 12px;
  font-weight: 600;
  line-height: 1.3;
  white-space: nowrap;
}

.status-pending {
  background: var(--warn-soft);
  color: var(--warn);
  border: 1px solid var(--warn-border);
}

.status-ok {
  background: var(--ok-soft);
  color: var(--ok);
  border: 1px solid var(--ok-border);
}

.status-accent {
  background: var(--accent-soft);
  color: var(--accent);
  border: 1px solid var(--accent-border);
}

.status-neutral {
  background: var(--surface-2);
  color: var(--ink-2);
  border: 1px solid var(--border);
}

/* ── Inline Banners (No border-l-4 slop) ────────────────── */

.notice {
  padding: 12px 14px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border);
  background: var(--surface-2);
  font-size: 13px;
  color: var(--ink-2);
  line-height: 1.55;
}

.notice-accent {
  background: var(--accent-soft);
  border-color: var(--accent-border);
  color: var(--ink);
}

.notice-ok {
  background: var(--ok-soft);
  border-color: var(--ok-border);
  color: var(--ok);
}

.notice-warn {
  background: var(--warn-soft);
  border-color: var(--warn-border);
  color: var(--warn);
}

.notice-danger {
  background: var(--danger-soft);
  border-color: var(--danger-border);
  color: var(--danger);
}

/* ── Segmented Tabs ─────────────────────────────────────── */

.seg-tabs {
  display: inline-flex;
  padding: 3px;
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: 8px;
  gap: 2px;
  max-width: 100%;
}

.seg-tabs.full {
  display: flex;
  width: 100%;
}

.seg-tab {
  flex: 1;
  min-width: 0;
  min-height: 38px;
  padding: 0 12px;
  border: 0;
  border-radius: 6px;
  background: transparent;
  color: var(--muted);
  font-size: 14px;
  font-weight: 600;
  transition: background-color 0.15s ease, color 0.15s ease;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

@media (max-width: 480px) {
  .seg-tab {
    padding: 0 8px;
    font-size: 13px;
  }
}

.seg-tab.active {
  background: var(--surface);
  color: var(--ink);
  box-shadow: var(--shadow-sm);
}

/* ── Grid Utilities ─────────────────────────────────────── */

.grid-2 {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 16px;
}

.grid-3 {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 14px;
}

.stack-12 {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.stack-16 {
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.row-between {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  flex-wrap: wrap;
}

.row-gap {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
}

/* ── Portal Page (/h5/) ─────────────────────────────────── */

.portal-header {
  position: sticky;
  top: 0;
  z-index: 20;
  height: 58px;
  background: rgba(255, 255, 255, 0.94);
  backdrop-filter: blur(10px);
  border-bottom: 1px solid var(--border);
}

.portal-header-inner {
  max-width: 1080px;
  height: 100%;
  margin: 0 auto;
  padding: 0 20px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
}

.portal-nav {
  display: flex;
  align-items: center;
  gap: 18px;
}

.portal-nav a {
  font-size: 14px;
  font-weight: 500;
  color: var(--ink-2);
}

.portal-nav a:hover {
  color: var(--ink);
  text-decoration: none;
}

.portal-main {
  max-width: 1080px;
  margin: 0 auto;
  padding: 40px 20px 56px;
}

.portal-hero {
  max-width: 680px;
  margin-bottom: 28px;
}

.portal-hero h1 {
  margin: 0 0 10px;
  font-size: 32px;
  line-height: 1.22;
  letter-spacing: -0.025em;
  color: var(--ink);
}

.portal-hero p {
  margin: 0;
  font-size: 15px;
  color: var(--ink-2);
  line-height: 1.65;
}

.role-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 20px;
  margin-bottom: 28px;
}

.role-card {
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 26px;
  box-shadow: var(--shadow-sm);
  transition: border-color 0.16s ease, box-shadow 0.16s ease, transform 0.16s ease;
}

.role-card:hover {
  border-color: var(--border-strong);
  box-shadow: var(--shadow-md);
  transform: translateY(-2px);
}

.role-card-head {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-bottom: 14px;
}

.role-icon {
  width: 44px;
  height: 44px;
  border-radius: 10px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}

.role-icon-student {
  background: #eff6ff;
  color: #1d4ed8;
}

.role-icon-mentor {
  background: #f0fdfa;
  color: #0f766e;
}

.role-card h2 {
  margin: 0;
  font-size: 20px;
  font-weight: 700;
  color: var(--ink);
}

.role-card .role-en {
  font-size: 12px;
  color: var(--muted);
  display: block;
}

.role-card-desc {
  margin: 0 0 18px;
  font-size: 14px;
  color: var(--ink-2);
  line-height: 1.6;
}

.role-checklist {
  margin: 0 0 22px;
  padding: 0;
  list-style: none;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.role-checklist li {
  font-size: 13px;
  color: var(--ink-2);
  display: flex;
  align-items: flex-start;
  gap: 8px;
}

.role-checklist li::before {
  content: "";
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: var(--border-strong);
  margin-top: 7px;
  flex-shrink: 0;
}

.role-card-student .role-checklist li::before {
  background: #1d4ed8;
}

.role-card-mentor .role-checklist li::before {
  background: #0f766e;
}

.role-card-mentor .btn-mentor-entry {
  background: #0f766e;
  border-color: #0f766e;
  color: #ffffff;
}

.role-card-mentor .btn-mentor-entry:hover {
  background: #115e59;
  border-color: #115e59;
}

.portal-pillars {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 16px;
  padding-top: 12px;
  border-top: 1px solid var(--border);
}

.pillar-item h3 {
  margin: 0 0 6px;
  font-size: 14px;
  font-weight: 700;
  color: var(--ink);
}

.pillar-item p {
  margin: 0;
  font-size: 13px;
  color: var(--muted);
  line-height: 1.6;
}

/* ── App Shell (Desktop Sidebar + Mobile Compact Bars) ──── */

.app-shell {
  display: flex;
  min-height: 100vh;
}

.sidebar {
  width: var(--sidebar-w);
  flex-shrink: 0;
  background: var(--surface);
  border-right: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  position: sticky;
  top: 0;
  height: 100vh;
  padding: 18px 14px;
}

.sidebar-brand {
  padding: 2px 6px 16px;
  border-bottom: 1px solid var(--border);
  margin-bottom: 14px;
}

.sidebar-user {
  padding: 12px;
  border-radius: var(--radius-sm);
  background: var(--surface-2);
  border: 1px solid var(--border);
  margin-bottom: 14px;
}

.sidebar-user-name {
  font-size: 14px;
  font-weight: 700;
  color: var(--ink);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.sidebar-user-email {
  font-size: 12px;
  color: var(--muted);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  margin-top: 2px;
}

.sidebar-nav {
  display: flex;
  flex-direction: column;
  gap: 4px;
  flex: 1;
  overflow-y: auto;
}

.nav-item {
  width: 100%;
  min-height: 42px;
  padding: 0 12px;
  border: 1px solid transparent;
  border-radius: var(--radius-sm);
  background: transparent;
  color: var(--ink-2);
  font-size: 14px;
  font-weight: 600;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  text-align: left;
  transition: background-color 0.14s ease, color 0.14s ease;
}

.nav-item:hover {
  background: var(--surface-2);
  color: var(--ink);
}

.nav-item.active {
  background: var(--accent-soft);
  border-color: var(--accent-border);
  color: var(--accent);
}

.nav-item-left {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  min-width: 0;
}

.nav-badge {
  min-width: 20px;
  height: 20px;
  padding: 0 6px;
  border-radius: 5px;
  background: var(--accent);
  color: #ffffff;
  font-size: 11px;
  font-weight: 700;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}

.sidebar-footer {
  padding-top: 12px;
  border-top: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.mobile-topbar {
  display: none;
}

.mobile-bottombar {
  display: none;
}

.main-wrap {
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
}

.main-content {
  width: 100%;
  max-width: 1060px;
  margin: 0 auto;
  padding: 28px 28px 48px;
}

.main-content-wide {
  max-width: 1220px;
}

/* ── Auth Panel (Centered Clean Stationery Card) ────────── */

.auth-stage {
  max-width: 480px;
  margin: 24px auto;
}

.demo-strip {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding: 10px 12px;
  border-radius: var(--radius-sm);
  background: var(--surface-2);
  border: 1px dashed var(--border-strong);
  margin-top: 14px;
  font-size: 12px;
  color: var(--ink-2);
  flex-wrap: wrap;
}

/* ── QR Display Box (Clause 8.6 Clean Quiet Zone) ───────── */

.qr-frame {
  display: flex;
  flex-direction: column;
  align-items: center;
  padding: 18px;
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  text-align: center;
}

.qr-hint-top {
  margin: 0 0 12px;
  font-size: 13px;
  font-weight: 600;
  color: var(--ink);
}

.qr-canvas {
  width: 210px;
  height: 210px;
  background: #ffffff;
  border: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: center;
  /* Never round or clip QR quiet zone (Clause 8.6) */
  border-radius: 0;
  overflow: visible;
}

.qr-canvas svg {
  width: 100%;
  height: 100%;
  display: block;
}

.invite-code-display {
  font-family: var(--font-mono);
  font-size: 28px;
  font-weight: 700;
  letter-spacing: 0.16em;
  color: var(--ink);
  margin: 12px 0 4px;
}

/* ── Metric Tiles & Tables ──────────────────────────────── */

.kpi-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 12px;
}

.kpi-tile {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  padding: 14px 16px;
}

.kpi-label {
  font-size: 12px;
  color: var(--muted);
  margin-bottom: 6px;
}

.kpi-val {
  font-size: 22px;
  font-weight: 700;
  color: var(--ink);
  font-variant-numeric: tabular-nums;
  line-height: 1.2;
}

.kpi-sub {
  font-size: 12px;
  color: var(--muted);
  margin-top: 4px;
}

.progress-track {
  width: 100%;
  height: 8px;
  border-radius: 4px;
  background: var(--surface-2);
  overflow: hidden;
}

.progress-fill {
  height: 100%;
  background: var(--accent);
  border-radius: 4px;
  transition: width 0.25s ease;
}

.data-table-wrap {
  width: 100%;
  overflow-x: auto;
}

.data-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 13px;
}

.data-table th,
.data-table td {
  text-align: left;
  padding: 10px 12px;
  border-bottom: 1px solid var(--border);
  vertical-align: middle;
}

.data-table th {
  font-size: 12px;
  font-weight: 600;
  color: var(--muted);
  background: var(--surface-2);
}

/* ── Mentor Master-Detail Split & 6-Tier Approval (Clause 8.3 & 8.7) ─ */

.mentor-split {
  display: grid;
  grid-template-columns: 330px minmax(0, 1fr);
  gap: 18px;
  align-items: start;
}

.req-list {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.req-item {
  width: 100%;
  text-align: left;
  padding: 14px;
  border-radius: var(--radius-md);
  border: 1px solid var(--border);
  background: var(--surface);
  transition: border-color 0.14s ease, background-color 0.14s ease;
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.req-item:hover {
  border-color: var(--border-strong);
  background: var(--surface-2);
}

.req-item.active {
  border-color: var(--accent);
  background: var(--accent-soft);
}

.req-item-top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
}

.req-item-student {
  font-size: 14px;
  font-weight: 700;
  color: var(--ink);
}

.req-item-subject {
  font-size: 12px;
  color: var(--muted);
}

.req-item-stem {
  font-size: 13px;
  color: var(--ink-2);
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
  line-height: 1.45;
}

/* Six locked validity radio cards (Clause 8.3) */
.tier-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 10px;
  margin: 14px 0 16px;
}

.tier-option {
  position: relative;
  display: flex;
  align-items: center;
  gap: 10px;
  min-height: 48px;
  padding: 10px 14px;
  border-radius: var(--radius-sm);
  border: 1.5px solid var(--border-strong);
  background: var(--surface);
  cursor: pointer;
  transition: border-color 0.14s ease, background-color 0.14s ease;
}

.tier-option:hover {
  border-color: var(--accent);
}

.tier-option.selected {
  border-color: var(--accent);
  background: var(--accent-soft);
}

.tier-option input[type="radio"] {
  width: 18px;
  height: 18px;
  margin: 0;
  accent-color: var(--accent);
  flex-shrink: 0;
}

.tier-label {
  font-size: 14px;
  font-weight: 600;
  color: var(--ink);
  line-height: 1.35;
}

/* HD Question Image Card (Clause 8.7) */
.hd-image-box {
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  overflow: hidden;
  background: #0f172a;
}

.hd-image-trigger {
  display: block;
  width: 100%;
  padding: 0;
  border: 0;
  background: transparent;
  cursor: zoom-in;
}

.hd-image-trigger img {
  display: block;
  width: 100%;
  max-height: 360px;
  object-fit: contain;
  background: #0f172a;
}

.hd-image-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding: 10px 14px;
  background: var(--surface-2);
  border-top: 1px solid var(--border);
  flex-wrap: wrap;
}

.hd-image-hint {
  font-size: 12px;
  color: var(--muted);
}

/* Dialog Transcript */
.transcript-list {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.turn {
  padding: 12px 14px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border);
  background: var(--surface-2);
}

.turn-student {
  background: var(--accent-soft);
  border-color: var(--accent-border);
}

.turn-meta {
  display: flex;
  align-items: center;
  justify-content: space-between;
  font-size: 12px;
  font-weight: 600;
  color: var(--muted);
  margin-bottom: 4px;
}

.turn-text {
  margin: 0;
  font-size: 14px;
  color: var(--ink);
  line-height: 1.6;
  white-space: pre-wrap;
  word-break: break-word;
}

/* ── Model Provider Cards ───────────────────────────────── */

.provider-card {
  padding: 14px 16px;
  border-radius: var(--radius-md);
  border: 1px solid var(--border);
  background: var(--surface);
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.provider-card.selected {
  border-color: var(--accent);
  background: var(--accent-soft);
}

.provider-url {
  font-family: var(--font-mono);
  font-size: 12px;
  color: var(--muted);
  word-break: break-all;
}

.step-badge {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 20px;
  height: 20px;
  border-radius: 50%;
  background: var(--accent-soft);
  color: var(--accent);
  font-size: 11px;
  font-weight: 700;
  margin-right: 6px;
}

/* ── Native Accessible Modals (<dialog>) ────────────────── */

dialog.modal {
  padding: 0;
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  background: var(--surface);
  color: var(--ink);
  width: min(480px, calc(100vw - 24px));
  max-height: calc(100vh - 32px);
  box-shadow: var(--shadow-lg);
  overflow: hidden;
}

dialog.modal::backdrop {
  background: rgba(15, 23, 42, 0.56);
  backdrop-filter: blur(2px);
}

.modal-head {
  padding: 16px 20px;
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.modal-head h3 {
  margin: 0;
  font-size: 16px;
  font-weight: 700;
}

.modal-body {
  padding: 18px 20px;
  overflow-y: auto;
  max-height: calc(100vh - 160px);
}

.modal-foot {
  padding: 14px 20px;
  border-top: 1px solid var(--border);
  display: flex;
  justify-content: flex-end;
  gap: 10px;
}

/* Fullscreen HD Image Viewer Modal (Clause 8.7) */
dialog.lightbox-modal {
  padding: 0;
  border: 0;
  border-radius: 0;
  background: #020617;
  color: #f8fafc;
  width: 100vw;
  max-width: 100vw;
  height: 100vh;
  max-height: 100vh;
  margin: 0;
}

dialog.lightbox-modal::backdrop {
  background: rgba(2, 6, 23, 0.92);
}

.lightbox-shell {
  display: flex;
  flex-direction: column;
  height: 100%;
}

.lightbox-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding: 10px 16px;
  background: rgba(15, 23, 42, 0.92);
  border-bottom: 1px solid rgba(148, 163, 184, 0.2);
  flex-wrap: wrap;
}

.lightbox-stage {
  flex: 1;
  overflow: auto;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 16px;
}

.lightbox-stage.mode-native {
  align-items: flex-start;
  justify-content: flex-start;
}

.lightbox-stage img {
  max-width: 100%;
  max-height: 100%;
  object-fit: contain;
  transition: transform 0.16s ease;
}

.lightbox-stage.mode-native img {
  max-width: none;
  max-height: none;
  width: auto;
  height: auto;
}

.lightbox-btn {
  min-height: 38px;
  padding: 0 12px;
  border-radius: 6px;
  border: 1px solid rgba(148, 163, 184, 0.35);
  background: rgba(30, 41, 59, 0.9);
  color: #f8fafc;
  font-size: 13px;
  font-weight: 600;
  text-decoration: none;
  display: inline-flex;
  align-items: center;
  gap: 6px;
}

.lightbox-btn:hover {
  background: rgba(51, 65, 85, 0.95);
  text-decoration: none;
  color: #ffffff;
}

.lightbox-btn.active {
  background: var(--accent);
  border-color: var(--accent);
}

/* ── Toast Notification ─────────────────────────────────── */

.toast-region {
  position: fixed;
  bottom: 20px;
  right: 20px;
  z-index: 90;
  display: flex;
  flex-direction: column;
  gap: 8px;
  max-width: min(360px, calc(100vw - 32px));
  pointer-events: none;
}

.req-card-list {
  display: none;
  flex-direction: column;
  gap: 10px;
  margin-top: 14px;
}

.req-card-item {
  padding: 12px 14px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border);
  background: var(--surface-2);
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.toast {
  padding: 11px 15px;
  border-radius: var(--radius-sm);
  background: #0f172a;
  color: #ffffff;
  font-size: 13px;
  font-weight: 500;
  box-shadow: var(--shadow-md);
  pointer-events: auto;
}

.toast-ok {
  background: #14532d;
}

.toast-err {
  background: #991b1b;
}

/* ── Embed Mode (?embed=1 inside Native Client WebView) ─── */

body.is-embed .sidebar,
body.is-embed .mobile-topbar,
body.is-embed .portal-header {
  display: none !important;
}

body.is-embed .main-content {
  padding: 14px 14px 80px;
}

/* ── Responsive Breakpoints (Tablet & Mobile) ───────────── */

@media (max-width: 959px) {
  .app-shell {
    display: block;
  }

  .sidebar {
    display: none;
  }

  .mobile-topbar {
    position: sticky;
    top: 0;
    z-index: 30;
    height: var(--topbar-h);
    background: rgba(255, 255, 255, 0.96);
    backdrop-filter: blur(10px);
    border-bottom: 1px solid var(--border);
    padding: 0 14px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 10px;
  }

  .mobile-topbar-title {
    font-size: 15px;
    font-weight: 700;
    color: var(--ink);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
  }

  .mobile-bottombar {
    position: fixed;
    left: 0;
    right: 0;
    bottom: 0;
    z-index: 30;
    height: calc(var(--bottombar-h) + env(safe-area-inset-bottom, 0px));
    padding-bottom: env(safe-area-inset-bottom, 0px);
    background: rgba(255, 255, 255, 0.97);
    backdrop-filter: blur(10px);
    border-top: 1px solid var(--border);
    display: flex;
    align-items: stretch;
  }

  .mobile-tab {
    flex: 1;
    border: 0;
    background: transparent;
    color: var(--muted);
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 3px;
    font-size: 11px;
    font-weight: 600;
    padding: 4px 2px;
    position: relative;
  }

  .mobile-tab.active {
    color: var(--accent);
  }

  .mobile-tab-dot {
    position: absolute;
    top: 6px;
    right: calc(50% - 16px);
    min-width: 16px;
    height: 16px;
    padding: 0 4px;
    border-radius: 8px;
    background: var(--accent);
    color: #ffffff;
    font-size: 10px;
    line-height: 16px;
    text-align: center;
  }

  .main-content {
    padding: 16px 14px calc(var(--bottombar-h) + 28px);
  }

  .section-title {
    font-size: 19px;
  }

  .role-grid,
  .portal-pillars,
  .grid-2,
  .grid-3,
  .mentor-split {
    grid-template-columns: 1fr;
  }

  .kpi-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .tier-grid {
    grid-template-columns: 1fr;
  }

  .portal-main {
    padding: 24px 14px 40px;
  }

  .portal-hero h1 {
    font-size: 24px;
  }

  .portal-nav a.hide-xs {
    display: none;
  }

  .toast-region {
    bottom: calc(var(--bottombar-h) + 12px);
    top: auto;
    left: 14px;
    right: 14px;
    max-width: none;
  }

  .req-table-desktop {
    display: none;
  }

  .req-card-list {
    display: flex;
  }

  /* Mobile Master-Detail Drill-Down on Mentor Page */
  .mentor-split.mobile-show-detail .mentor-queue-col {
    display: none;
  }

  .mentor-split.mobile-show-list .mentor-detail-col {
    display: none;
  }
}

@media (min-width: 960px) {
  .mobile-only {
    display: none !important;
  }
}

/* ── Unified Study Process Waterfall & Information Stream ─ */

.study-standalone-main {
  width: 100%;
  max-width: 1180px;
  margin: 0 auto;
  padding: 20px 20px 56px;
}

.study-opener-bar {
  margin-bottom: 16px;
}

.sf-root {
  display: flex;
  flex-direction: column;
  gap: 14px;
}

.sf-summary-bar {
  padding: 16px 18px;
}

.sf-summary-top {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
  flex-wrap: wrap;
  margin-bottom: 14px;
}

.sf-summary-heading {
  font-size: 16px;
  font-weight: 700;
  color: var(--ink);
  line-height: 1.3;
}

.sf-summary-sub {
  font-size: 12px;
  color: var(--muted);
  margin-top: 4px;
}

.sf-metrics-strip {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  border-top: 1px solid var(--border);
  padding-top: 12px;
  gap: 8px;
}

.sf-metric {
  display: flex;
  flex-direction: column;
  gap: 2px;
  padding-right: 8px;
  border-right: 1px solid var(--border);
}

.sf-metric:last-child {
  border-right: 0;
}

.sf-metric-val {
  font-size: 18px;
  font-weight: 700;
  color: var(--ink);
  font-variant-numeric: tabular-nums;
  line-height: 1.25;
}

.sf-metric-label {
  font-size: 12px;
  color: var(--muted);
}

.sf-controls {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.sf-day-strip {
  display: flex;
  align-items: center;
  gap: 8px;
  overflow-x: auto;
  padding-bottom: 2px;
  -webkit-overflow-scrolling: touch;
  scrollbar-width: none;
}

.sf-day-strip::-webkit-scrollbar {
  display: none;
}

.sf-day-btn {
  flex: 0 0 auto;
  min-height: 38px;
  padding: 0 14px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--ink-2);
  font-size: 13px;
  font-weight: 600;
  white-space: nowrap;
  transition: background-color 0.14s ease, border-color 0.14s ease, color 0.14s ease;
}

.sf-day-btn:hover {
  border-color: var(--border-strong);
  color: var(--ink);
}

.sf-day-btn.active {
  background: var(--accent);
  border-color: var(--accent);
  color: #ffffff;
}

.sf-controls-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  flex-wrap: wrap;
}

.sf-filter-seg {
  flex: 1 1 auto;
  min-width: 240px;
}

.sf-layout-seg {
  flex: 0 0 auto;
}

/* Masonry Waterfall Grid */
.sf-masonry {
  display: grid;
  gap: 14px;
  align-items: start;
}

.sf-masonry-2 {
  grid-template-columns: repeat(2, minmax(0, 1fr));
}

.sf-masonry-3 {
  grid-template-columns: repeat(3, minmax(0, 1fr));
}

.sf-masonry-col {
  display: flex;
  flex-direction: column;
  gap: 14px;
  min-width: 0;
}

/* Single-Column Information Stream */
.sf-stream {
  display: flex;
  flex-direction: column;
  gap: 14px;
  max-width: 780px;
  margin: 0 auto;
}

/* Feed Cards */
.sf-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  overflow: hidden;
  box-shadow: var(--shadow-sm);
  transition: border-color 0.15s ease, box-shadow 0.15s ease;
}

.sf-card:hover {
  border-color: var(--border-strong);
}

.sf-card-summary {
  background: var(--accent-soft);
  border-color: var(--accent-border);
}

.sf-card-media {
  position: relative;
  width: 100%;
  background: #f1f5f9;
  overflow: hidden;
}

.sf-card-media.is-loading {
  aspect-ratio: 4 / 3;
}

.sf-card-media.is-loaded {
  aspect-ratio: auto;
}

.sf-spotlight {
  background: var(--accent-soft);
  border: 1px solid var(--accent-border);
  border-radius: var(--radius-md);
  padding: 12px 14px;
  margin-bottom: 12px;
}

.sf-compact-banner,
.sf-switcher-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding: 9px 12px;
  border-radius: var(--radius-sm);
  background: var(--surface);
  border: 1px solid var(--border);
  margin-bottom: 10px;
  font-size: 12.5px;
  color: var(--ink-2);
}

.sf-compact-banner {
  background: var(--surface-2);
}

.sf-switcher-label {
  font-weight: 600;
  color: var(--ink);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.sf-media-trigger {
  display: block;
  width: 100%;
  padding: 0;
  border: 0;
  background: transparent;
  cursor: zoom-in;
  position: relative;
  text-align: left;
}

.sf-media-trigger img {
  display: block;
  width: 100%;
  height: auto;
  max-height: 460px;
  object-fit: cover;
  background: #f1f5f9;
}

.sf-card-media-crop .sf-media-trigger img {
  max-height: 240px;
  object-fit: contain;
  background: #f8fafc;
}

.sf-media-time {
  position: absolute;
  right: 8px;
  bottom: 8px;
  padding: 2px 7px;
  border-radius: 4px;
  background: rgba(15, 23, 42, 0.72);
  color: #ffffff;
  font-size: 11px;
  font-weight: 600;
  font-family: var(--font-mono);
  letter-spacing: 0.02em;
}

.sf-media-fallback {
  height: 120px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 12px;
  color: var(--muted);
  background: var(--surface-2);
}

.sf-card-body {
  padding: 12px 14px 14px;
}

.sf-card-kicker {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  margin-bottom: 6px;
}

.sf-kicker-label {
  font-size: 11px;
  font-weight: 700;
  color: var(--accent);
  letter-spacing: 0.02em;
}

.sf-kicker-time {
  font-size: 11px;
  color: var(--muted);
}

.sf-card-title {
  font-size: 14px;
  font-weight: 700;
  color: var(--ink);
  line-height: 1.4;
  word-break: break-word;
}

.sf-card-text {
  margin: 6px 0 0;
  font-size: 13px;
  color: var(--ink-2);
  line-height: 1.55;
  word-break: break-word;
}

.sf-summary-text {
  margin: 0;
  font-size: 13.5px;
  color: var(--ink);
  line-height: 1.65;
  white-space: pre-wrap;
  word-break: break-word;
}

.sf-summary-en {
  margin: 8px 0 0;
  padding-top: 8px;
  border-top: 1px dashed var(--accent-border);
  font-size: 12px;
  color: var(--muted);
  line-height: 1.55;
}

.sf-qa-turns {
  margin-top: 10px;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.sf-qa-turn {
  padding: 8px 10px;
  border-radius: var(--radius-sm);
  background: var(--surface-2);
  border: 1px solid var(--border);
}

.sf-qa-turn.is-student {
  background: var(--accent-soft);
  border-color: var(--accent-border);
}

.sf-qa-who {
  font-size: 11px;
  font-weight: 700;
  color: var(--muted);
  margin-bottom: 3px;
}

.sf-qa-turn.is-student .sf-qa-who {
  color: var(--accent);
}

.sf-qa-msg {
  font-size: 13px;
  color: var(--ink);
  line-height: 1.55;
  white-space: pre-wrap;
  word-break: break-word;
}

.sf-card-meta {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  margin-top: 8px;
  font-size: 11.5px;
  color: var(--muted);
}

.sf-inline-action {
  border: 0;
  background: transparent;
  padding: 4px 2px;
  min-height: 30px;
  font-size: 12px;
  font-weight: 600;
  color: var(--accent);
  cursor: pointer;
}

.sf-inline-action:hover {
  text-decoration: underline;
}

.sf-load-more {
  display: flex;
  justify-content: center;
  padding: 8px 0 4px;
}

.sf-empty,
.sf-loading {
  text-align: center;
  padding: 32px 18px;
}

.sf-empty-title {
  font-size: 15px;
  font-weight: 700;
  color: var(--ink);
  margin-bottom: 6px;
}

.sf-empty-desc {
  margin: 0 0 14px;
  font-size: 13px;
  color: var(--muted);
  line-height: 1.6;
}

.sf-opener-form {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
}

.sf-opener-form .input {
  flex: 1 1 260px;
}

.sf-recent-row {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
}

@media (max-width: 959px) {
  .study-standalone-main {
    padding: 12px 10px 44px;
  }

  .sf-summary-bar {
    padding: 14px;
  }

  .sf-metrics-strip {
    grid-template-columns: repeat(2, minmax(0, 1fr));
    row-gap: 10px;
  }

  .sf-metric:nth-child(2n) {
    border-right: 0;
  }

  .sf-masonry {
    gap: 10px;
  }

  .sf-masonry-col {
    gap: 10px;
  }

  .sf-card-body {
    padding: 10px 10px 12px;
  }

  .sf-card-title {
    font-size: 13px;
  }

  .sf-card-text,
  .sf-qa-msg {
    font-size: 12.5px;
  }

  .sf-summary-text {
    font-size: 13px;
  }

  .sf-filter-seg {
    min-width: 0;
    width: 100%;
  }

  .sf-layout-seg {
    width: 100%;
  }
}

/* ── Clause 8.16: Multi-Account OTP Mail Inbox Preview & Inline Student Editor ── */

.mail-inbox-card {
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-md);
  background: var(--surface);
  overflow: hidden;
  margin-top: 12px;
}

.mail-inbox-head {
  padding: 10px 14px;
  background: var(--surface-2);
  border-bottom: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.mail-inbox-title {
  font-size: 13px;
  font-weight: 700;
  color: var(--ink);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
}

.mail-inbox-meta {
  font-size: 12px;
  color: var(--muted);
  word-break: break-all;
}

.mail-otp-list {
  display: flex;
  flex-direction: column;
}

.mail-otp-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding: 10px 14px;
  border-bottom: 1px solid var(--border);
  flex-wrap: wrap;
}

.mail-otp-row:last-child {
  border-bottom: 0;
}

.mail-otp-row.is-mentor {
  background: rgba(15, 118, 110, 0.04);
}

.mail-otp-info {
  min-width: 0;
  flex: 1 1 160px;
}

.mail-otp-label {
  font-size: 13px;
  font-weight: 700;
  color: var(--ink);
}

.mail-otp-sub {
  font-size: 11.5px;
  color: var(--muted);
  margin-top: 2px;
}

.mail-otp-actions {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-shrink: 0;
}

.mail-otp-code {
  font-family: var(--font-mono);
  font-size: 18px;
  font-weight: 700;
  letter-spacing: 0.14em;
  color: var(--ink);
  padding: 4px 10px;
  border-radius: 6px;
  background: var(--surface-2);
  border: 1px solid var(--border);
  user-select: all;
}

.inline-edit-panel {
  padding: 12px;
  border-radius: var(--radius-sm);
  background: var(--surface);
  border: 1px solid var(--border-strong);
  display: flex;
  flex-direction: column;
  gap: 10px;
}

@media (max-width: 560px) {
  .mail-otp-row {
    align-items: flex-start;
  }

  .mail-otp-actions {
    width: 100%;
    justify-content: space-between;
  }
}

