﻿:root {
  --bg0: #0b1220;
  --bg1: #121c2f;
  --bg2: #1a2740;
  --line: rgba(255, 255, 255, 0.08);
  --text: #e8eef8;
  --muted: #93a0b8;
  --accent: #2dd4bf;
  --accent2: #f59e0b;
  --danger: #fb7185;
  --ok: #34d399;
  --shadow: 0 20px 50px rgba(0, 0, 0, 0.35);
  --radius: 18px;
  --font-display: "Syne", sans-serif;
  --font-body: "Vazirmatn", "IBM Plex Sans", sans-serif;
}

* { box-sizing: border-box; }
html, body { height: 100%; }
body {
  margin: 0;
  color: var(--text);
  font-family: var(--font-body);
  background:
    radial-gradient(1200px 600px at 10% -10%, rgba(45, 212, 191, 0.18), transparent 55%),
    radial-gradient(900px 500px at 100% 0%, rgba(245, 158, 11, 0.12), transparent 50%),
    linear-gradient(160deg, var(--bg0), var(--bg1) 45%, #0a1628);
  min-height: 100vh;
}

a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }

.app-shell {
  width: min(1180px, calc(100% - 2rem));
  margin: 0 auto;
  padding: 1.25rem 0 2.5rem;
}

/* Chat page: lock layout so only the message box scrolls (no page jump) */
body.page-chat {
  overflow: hidden;
  height: 100%;
}
body.page-chat .topnav {
  margin-bottom: 0.65rem;
  padding: 0.45rem 0.65rem;
}
body.page-chat .nav-links a {
  padding: 0.3rem 0.5rem;
  font-size: 0.82rem;
}
body.page-chat .app-shell {
  height: 100%;
  max-height: 100vh;
  max-height: 100dvh;
  display: flex;
  flex-direction: column;
  padding-top: 0.65rem;
  padding-bottom: 0.5rem;
  box-sizing: border-box;
  width: min(1280px, calc(100% - 1.25rem));
}
body.page-chat main {
  flex: 1 1 auto;
  min-height: 0;
  display: flex;
  flex-direction: column;
}
body.page-chat .chat-workspace {
  flex: 1 1 auto;
  height: auto !important;
  max-height: none !important;
  min-height: 0;
}

.topnav {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  margin-bottom: 1.5rem;
  padding: 0.75rem 1rem;
  border: 1px solid var(--line);
  border-radius: 16px;
  background: rgba(10, 18, 32, 0.72);
  backdrop-filter: blur(10px);
  position: sticky;
  top: 0.75rem;
  z-index: 40;
}

.brand {
  font-family: var(--font-display);
  font-weight: 700;
  font-size: 1.2rem;
  letter-spacing: 0.02em;
  white-space: nowrap;
}
.brand span { color: var(--accent); }
.brand a {
  color: inherit;
  text-decoration: none;
}
.brand a:hover { text-decoration: none; }

.nav-links {
  display: flex;
  gap: 0.35rem;
  flex-wrap: wrap;
  justify-content: flex-end;
}
.nav-links a {
  color: var(--muted);
  padding: 0.4rem 0.72rem;
  border-radius: 10px;
  border: 1px solid transparent;
  text-decoration: none;
  transition: 0.2s ease;
  font-size: 0.88rem;
  font-weight: 600;
}
.nav-links a:hover,
.nav-links a.active {
  color: var(--text);
  border-color: rgba(45, 212, 191, 0.28);
  background: rgba(45, 212, 191, 0.1);
  text-decoration: none;
}

.page-pad {
  padding: 1.15rem 1.25rem 1.35rem;
}
.page-hero {
  display: flex;
  justify-content: space-between;
  align-items: flex-end;
  gap: 1rem;
  flex-wrap: wrap;
  margin-bottom: 1.15rem;
  padding: 1.35rem 1.4rem;
  border-radius: 20px;
  border: 1px solid rgba(255,255,255,0.08);
  background:
    linear-gradient(135deg, rgba(45, 212, 191, 0.12), transparent 45%),
    linear-gradient(225deg, rgba(245, 158, 11, 0.1), transparent 42%),
    linear-gradient(180deg, rgba(18, 28, 47, 0.95), rgba(10, 18, 32, 0.98));
  animation: rise 0.4s ease;
}
.page-kicker {
  margin: 0 0 0.35rem;
  color: var(--accent);
  font-size: 0.78rem;
  font-weight: 700;
  letter-spacing: 0.06em;
}
.page-hero h1 {
  margin: 0;
  font-family: var(--font-display);
  font-size: clamp(1.35rem, 2.6vw, 1.85rem);
  line-height: 1.3;
}
.page-hero > div > p {
  margin: 0.45rem 0 0;
  color: var(--muted);
  max-width: 40rem;
  line-height: 1.65;
  font-size: 0.92rem;
}
.page-hero-actions {
  display: flex;
  gap: 0.55rem;
  flex-wrap: wrap;
  align-items: center;
}

.metric-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(170px, 1fr));
  gap: 0.85rem;
  margin-bottom: 1.15rem;
}
.metric-card {
  display: block;
  border: 1px solid var(--line);
  border-radius: 16px;
  padding: 1rem 1.05rem;
  background: rgba(255,255,255,0.03);
  text-decoration: none;
  color: inherit;
  transition: border-color 0.2s ease, transform 0.2s ease, background 0.2s ease;
  animation: rise 0.4s ease both;
}
a.metric-card:hover {
  border-color: rgba(45, 212, 191, 0.35);
  background: rgba(45, 212, 191, 0.06);
  transform: translateY(-2px);
  text-decoration: none;
}
.metric-card span {
  display: block;
  color: var(--muted);
  font-size: 0.82rem;
  margin-bottom: 0.4rem;
}
.metric-card strong {
  display: block;
  font-family: var(--font-display);
  font-size: 1.4rem;
  line-height: 1.2;
  word-break: break-word;
}
.metric-card em {
  display: block;
  margin-top: 0.35rem;
  font-style: normal;
  color: var(--muted);
  font-size: 0.75rem;
}
.metric-card.warn strong { color: var(--accent2); }
.metric-card.ok strong { color: var(--ok); }

.section-block {
  margin-top: 0.35rem;
}
.section-block + .section-block {
  margin-top: 1.25rem;
  padding-top: 1.15rem;
  border-top: 1px solid var(--line);
}
.section-title {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 0.75rem;
  flex-wrap: wrap;
  margin-bottom: 0.85rem;
}
.section-title h2 {
  margin: 0;
  font-family: var(--font-display);
  font-size: 1.12rem;
}
.section-title p {
  margin: 0;
  color: var(--muted);
  font-size: 0.85rem;
}

.badge-status {
  display: inline-flex;
  align-items: center;
  gap: 0.3rem;
  padding: 0.22rem 0.6rem;
  border-radius: 999px;
  font-size: 0.72rem;
  font-weight: 700;
  letter-spacing: 0.02em;
  border: 1px solid var(--line);
  color: var(--muted);
}
.badge-status.active {
  color: #042f2e;
  background: var(--accent);
  border-color: transparent;
}
.badge-status.staging {
  color: var(--accent2);
  border-color: rgba(245, 158, 11, 0.4);
  background: rgba(245, 158, 11, 0.1);
}
.badge-status.idle {
  color: var(--muted);
}

.empty-state {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 0.35rem;
  padding: 1.4rem 1.1rem;
  border: 1px dashed rgba(255,255,255,0.14);
  border-radius: 14px;
  background: rgba(0,0,0,0.15);
}
.empty-state strong {
  font-family: var(--font-display);
  color: var(--text);
}
.empty-state span {
  color: var(--muted);
  font-size: 0.9rem;
  line-height: 1.6;
}

.form-grid {
  display: grid;
  grid-template-columns: 1fr 1.4fr auto;
  gap: 0.75rem;
  align-items: end;
}
.form-grid .field { min-width: 0; }
.form-grid label {
  margin-top: 0;
}
@media (max-width: 720px) {
  .form-grid {
    grid-template-columns: 1fr;
  }
  .form-grid button { width: 100%; }
  .topnav {
    flex-direction: column;
    align-items: stretch;
    position: static;
  }
  .nav-links { justify-content: flex-start; }
}

.kv-list {
  list-style: none;
  margin: 0;
  padding: 0;
  display: grid;
  gap: 0.55rem;
}
.kv-item {
  display: grid;
  grid-template-columns: minmax(120px, 180px) 1fr;
  gap: 0.75rem;
  align-items: start;
  padding: 0.8rem 0.95rem;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: rgba(255,255,255,0.02);
}
.kv-item strong {
  color: var(--accent);
  font-size: 0.88rem;
  word-break: break-word;
}
.kv-item span {
  color: var(--text);
  line-height: 1.55;
  word-break: break-word;
}
@media (max-width: 560px) {
  .kv-item { grid-template-columns: 1fr; gap: 0.25rem; }
}

.flow-steps {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
  gap: 0.55rem;
  padding: 0;
  margin: 0;
  list-style: none;
  counter-reset: step;
}
.flow-steps li {
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 0.85rem 0.9rem;
  background: rgba(255,255,255,0.02);
  counter-increment: step;
  font-size: 0.9rem;
  line-height: 1.45;
}
.flow-steps li::before {
  content: counter(step, decimal-leading-zero);
  display: block;
  color: var(--accent);
  font-family: var(--font-display);
  font-size: 0.78rem;
  font-weight: 700;
  margin-bottom: 0.35rem;
}

.quick-links {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(180px, 1fr));
  gap: 0.65rem;
}
.quick-link {
  display: flex;
  flex-direction: column;
  gap: 0.25rem;
  padding: 0.9rem 1rem;
  border-radius: 14px;
  border: 1px solid var(--line);
  background: rgba(255,255,255,0.02);
  text-decoration: none;
  color: inherit;
  transition: 0.2s ease;
}
.quick-link:hover {
  border-color: rgba(45, 212, 191, 0.35);
  background: rgba(45, 212, 191, 0.07);
  text-decoration: none;
  transform: translateY(-1px);
}
.quick-link strong {
  font-family: var(--font-display);
  font-size: 0.98rem;
}
.quick-link span {
  color: var(--muted);
  font-size: 0.8rem;
  line-height: 1.45;
}

.table-wrap {
  overflow-x: auto;
  border: 1px solid var(--line);
  border-radius: 14px;
  background: rgba(0,0,0,0.12);
}
.table-wrap .data-table {
  margin: 0;
}
.data-table th {
  color: var(--muted);
  font-size: 0.78rem;
  font-weight: 600;
  background: rgba(255,255,255,0.03);
  white-space: nowrap;
}
.data-table td {
  vertical-align: middle;
}
.data-table tr:hover td {
  background: rgba(45, 212, 191, 0.04);
}
.btn-link {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 0.75rem 1rem;
  border-radius: 12px;
  border: 1px solid var(--line);
  color: var(--text);
  background: transparent;
  font-weight: 600;
  text-decoration: none;
}
.btn-link:hover {
  border-color: rgba(45, 212, 191, 0.35);
  background: rgba(45, 212, 191, 0.08);
  text-decoration: none;
}
.btn-sm {
  padding: 0.45rem 0.75rem !important;
  font-size: 0.82rem !important;
  border-radius: 10px !important;
}

.panel {
  background: linear-gradient(180deg, rgba(255,255,255,0.04), rgba(255,255,255,0.02));
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  overflow: hidden;
}

.panel-head {
  padding: 1.1rem 1.25rem;
  border-bottom: 1px solid var(--line);
  display: flex;
  justify-content: space-between;
  gap: 1rem;
  align-items: flex-start;
  flex-wrap: wrap;
}
.panel-head h1 {
  margin: 0;
  font-family: var(--font-display);
  font-size: 1.35rem;
}
.panel-head p {
  margin: 0.35rem 0 0;
  color: var(--muted);
  font-size: 0.92rem;
}

.chat-box {
  flex: 1 1 auto !important;
  min-height: 0;
  height: auto;
  overflow-y: auto;
  padding: 1rem 0.85rem 1.15rem;
  display: flex;
  flex-direction: column;
  gap: 0.9rem;
  border-radius: 16px;
  background:
    linear-gradient(180deg, rgba(255,255,255,0.025), rgba(255,255,255,0.01)),
    rgba(0,0,0,0.18);
  border: 1px solid rgba(255,255,255,0.05);
  scroll-behavior: smooth;
}
.chat-welcome {
  margin: auto;
  max-width: 420px;
  text-align: center;
  padding: 2rem 1rem;
  animation: rise 0.45s ease;
}
.chat-welcome-mark {
  width: 3.4rem;
  height: 3.4rem;
  margin: 0 auto 0.9rem;
  border-radius: 16px;
  display: grid;
  place-items: center;
  font-family: var(--font-display);
  font-weight: 700;
  color: #042f2e;
  background: linear-gradient(135deg, #2dd4bf, #f59e0b);
  box-shadow: 0 12px 28px rgba(45, 212, 191, 0.25);
}
.chat-welcome h2 {
  margin: 0 0 0.45rem;
  font-family: var(--font-display);
  font-size: 1.45rem;
}
.chat-welcome p {
  margin: 0;
  color: var(--muted);
  line-height: 1.75;
  font-size: 0.95rem;
}

.msg {
  max-width: min(88%, 680px);
  padding: 0.75rem 0.9rem 0.85rem;
  border-radius: 16px;
  line-height: 1.75;
  animation: rise 0.35s ease;
  white-space: normal;
}
.msg-label {
  font-size: 0.72rem;
  font-weight: 700;
  letter-spacing: 0.04em;
  margin-bottom: 0.35rem;
  opacity: 0.75;
}
.msg-body { white-space: pre-wrap; }
.msg.user {
  align-self: flex-start;
  background: linear-gradient(145deg, rgba(45, 212, 191, 0.18), rgba(45, 212, 191, 0.08));
  border: 1px solid rgba(45, 212, 191, 0.28);
  border-bottom-right-radius: 6px;
}
.msg.user .msg-label { color: var(--accent); }
.msg.bot {
  align-self: flex-end;
  background: rgba(255, 255, 255, 0.05);
  border: 1px solid rgba(255,255,255,0.08);
  border-bottom-left-radius: 6px;
}
.msg.bot .msg-label { color: var(--accent2); }
.msg .meta {
  display: block;
  margin-top: 0.45rem;
  font-size: 0.75rem;
  color: var(--muted);
}

.msg.thinking {
  align-self: flex-end;
  max-width: min(90%, 420px);
  background: rgba(255, 255, 255, 0.03);
  border: 1px dashed rgba(45, 212, 191, 0.35);
  color: var(--muted);
}
.think-dots {
  display: inline-flex;
  gap: 0.28rem;
  margin-left: 0.35rem;
  vertical-align: middle;
}
.think-dots i {
  width: 0.4rem;
  height: 0.4rem;
  border-radius: 50%;
  background: var(--accent);
  display: inline-block;
  animation: thinkPulse 1s ease infinite;
}
.think-dots i:nth-child(2) { animation-delay: 0.15s; }
.think-dots i:nth-child(3) { animation-delay: 0.3s; }
@keyframes thinkPulse {
  0%, 80%, 100% { opacity: 0.25; transform: translateY(0); }
  40% { opacity: 1; transform: translateY(-2px); }
}
.msg.thinking.fade-out {
  opacity: 0;
  transform: translateY(6px);
  transition: opacity 0.35s ease, transform 0.35s ease;
  pointer-events: none;
}
.thinking-head {
  display: flex;
  align-items: center;
  gap: 0.55rem;
  font-size: 0.88rem;
  color: var(--text);
  margin-bottom: 0.45rem;
}
.thinking-spinner {
  width: 0.7rem;
  height: 0.7rem;
  border-radius: 50%;
  border: 2px solid rgba(45, 212, 191, 0.25);
  border-top-color: var(--accent);
  animation: spin 0.8s linear infinite;
  flex-shrink: 0;
}
@keyframes spin {
  to { transform: rotate(360deg); }
}
.thinking-list {
  margin: 0;
  padding: 0 0 0 1.1rem;
  list-style: disc;
  font-size: 0.8rem;
  line-height: 1.55;
  max-height: 9.5rem;
  overflow-y: auto;
}
.thinking-list li {
  margin: 0.15rem 0;
  color: var(--muted);
}
.thinking-list li strong {
  color: var(--accent);
  font-weight: 600;
}
.thinking-list li.is-current {
  color: var(--text);
}
.chat-options {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.75rem 1.1rem;
  padding: 0 1.25rem;
  margin-top: -0.35rem;
  margin-bottom: 0.35rem;
}
.chat-options label {
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  font-size: 0.82rem;
  color: var(--muted);
  cursor: pointer;
  margin: 0;
}
.chat-options input {
  accent-color: var(--accent);
}
.folder-select-wrap select {
  background: rgba(255,255,255,0.04);
  border: 1px solid var(--line);
  color: var(--text);
  border-radius: 10px;
  padding: 0.35rem 0.55rem;
  font-family: inherit;
  min-width: 170px;
  cursor: pointer;
}
.folder-manage-link {
  color: var(--accent);
  font-size: 0.82rem;
  text-decoration: none;
}
.folder-manage-link:hover {
  text-decoration: underline;
}

.composer {
  display: block;
  padding: 0.35rem 0 0.15rem;
  border-top: none;
  background: transparent;
}
.composer-shell {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 0.55rem;
  align-items: end;
  padding: 0.55rem;
  border-radius: 18px;
  border: 1px solid rgba(255,255,255,0.1);
  background: rgba(12, 20, 36, 0.9);
  box-shadow: 0 12px 30px rgba(0,0,0,0.22);
}
.composer textarea,
input[type="text"],
input[type="password"],
select,
textarea {
  width: 100%;
  border: 1px solid var(--line);
  background: var(--bg2);
  color: var(--text);
  border-radius: 12px;
  padding: 0.85rem 1rem;
  font: inherit;
  resize: vertical;
}
.composer textarea {
  min-height: 48px;
  max-height: 140px;
  border: none;
  background: transparent;
  padding: 0.65rem 0.7rem;
  resize: none;
  outline: none;
}
.composer-send {
  border: none;
  border-radius: 12px;
  padding: 0.7rem 1.15rem;
  font-family: inherit;
  font-weight: 700;
  cursor: pointer;
  color: #042f2e;
  background: linear-gradient(135deg, #2dd4bf, #14b8a6);
  box-shadow: 0 8px 18px rgba(20, 184, 166, 0.25);
}
.composer-send:disabled { opacity: 0.55; cursor: wait; }

button, .btn {
  border: 0;
  border-radius: 12px;
  padding: 0.85rem 1.15rem;
  font: inherit;
  font-weight: 600;
  cursor: pointer;
  background: linear-gradient(135deg, var(--accent), #14b8a6);
  color: #042f2e;
  transition: transform 0.15s ease, filter 0.15s ease;
}
button:hover, .btn:hover { filter: brightness(1.05); transform: translateY(-1px); }
button:disabled { opacity: 0.6; cursor: not-allowed; transform: none; }
button.secondary, .btn.secondary {
  background: transparent;
  color: var(--text);
  border: 1px solid var(--line);
}
button.danger { background: linear-gradient(135deg, #fb7185, #e11d48); color: #fff; }

.grid-2 {
  display: grid;
  grid-template-columns: 1.1fr 0.9fr;
  gap: 1rem;
}
@media (max-width: 860px) {
  .grid-2 { grid-template-columns: 1fr; }
}

.form-card, .list-card {
  padding: 1.25rem;
}
label {
  display: block;
  margin: 0.75rem 0 0.35rem;
  color: var(--muted);
  font-size: 0.9rem;
}
.actions {
  display: flex;
  gap: 0.6rem;
  flex-wrap: wrap;
  margin-top: 1rem;
}

.knowledge-item {
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 0.85rem 1rem;
  margin-bottom: 0.65rem;
  background: rgba(255,255,255,0.02);
}
.knowledge-item strong { display: block; margin-bottom: 0.25rem; }
.knowledge-item .ans { color: var(--muted); font-size: 0.92rem; }
.knowledge-item .row {
  display: flex;
  justify-content: space-between;
  gap: 0.5rem;
  align-items: center;
  margin-top: 0.55rem;
}
.badge {
  font-size: 0.72rem;
  padding: 0.2rem 0.5rem;
  border-radius: 999px;
  border: 1px solid var(--line);
  color: var(--muted);
}
.badge.chatgpt { border-color: rgba(245, 158, 11, 0.4); color: var(--accent2); }
.badge.cursor { border-color: rgba(45, 212, 191, 0.45); color: var(--accent); }
.badge.manual { border-color: rgba(45, 212, 191, 0.35); color: var(--accent); }

.toast {
  position: fixed;
  bottom: 1.2rem;
  left: 50%;
  transform: translateX(-50%) translateY(120%);
  background: #102033;
  border: 1px solid var(--line);
  color: var(--text);
  padding: 0.75rem 1rem;
  border-radius: 12px;
  transition: 0.25s ease;
  z-index: 50;
  max-width: min(92vw, 480px);
}
.toast.show { transform: translateX(-50%) translateY(0); }
.toast.error { border-color: rgba(251, 113, 133, 0.5); }
.toast.ok { border-color: rgba(52, 211, 153, 0.5); }

.empty {
  color: var(--muted);
  text-align: center;
  padding: 2rem 1rem;
}

@keyframes rise {
  from { opacity: 0; transform: translateY(8px); }
  to { opacity: 1; transform: translateY(0); }
}

.stat-line {
  color: var(--muted);
  font-size: 0.85rem;
}
.stat-line b { color: var(--text); font-weight: 600; }

.stack {
  display: flex;
  flex-direction: column;
  gap: 1rem;
}

.inline-row {
  display: flex;
  gap: 0.6rem;
  flex-wrap: wrap;
}
.inline-row input[type="text"] {
  flex: 1;
  min-width: 160px;
}

select {
  width: 100%;
  border: 1px solid var(--line);
  background: var(--bg2);
  color: var(--text);
  border-radius: 12px;
  padding: 0.85rem 1rem;
  font: inherit;
}

.cat-chip {
  display: flex;
  width: 100%;
  justify-content: space-between;
  align-items: center;
  gap: 0.75rem;
  margin-bottom: 0.5rem;
  padding: 0.75rem 0.9rem;
  border-radius: 12px;
  border: 1px solid var(--line);
  background: rgba(255,255,255,0.02);
  color: var(--text);
  text-align: right;
  font-weight: 600;
}
.cat-chip span {
  color: var(--muted);
  font-size: 0.78rem;
  font-weight: 500;
}
.cat-chip.active {
  border-color: rgba(45, 212, 191, 0.45);
  background: rgba(45, 212, 191, 0.08);
}
.cat-chip:hover {
  transform: none;
  filter: none;
  border-color: rgba(45, 212, 191, 0.35);
}

.doc-list {
  margin-top: 1rem;
  padding-top: 0.75rem;
  border-top: 1px solid var(--line);
}

input[type="file"] {
  width: 100%;
  color: var(--muted);
  font: inherit;
}

.train-correct {
  max-width: 720px;
}
.train-correct .form-card label {
  display: block;
  margin-top: 0.85rem;
  margin-bottom: 0.35rem;
}
.train-correct .form-card label:first-child {
  margin-top: 0;
}
.train-correct textarea,
.train-correct input[type="text"] {
  width: 100%;
}
.train-divider {
  border: 0;
  border-top: 1px solid rgba(255, 255, 255, 0.08);
  margin: 1.25rem 0;
}


.train-hero {
  position: relative;
  display: grid;
  grid-template-columns: 1.4fr 0.8fr;
  gap: 1.25rem;
  align-items: end;
  margin-bottom: 1.35rem;
  padding: 1.6rem 1.5rem;
  border-radius: 24px;
  overflow: hidden;
  border: 1px solid rgba(255,255,255,0.08);
  background:
    linear-gradient(135deg, rgba(45, 212, 191, 0.14), transparent 42%),
    linear-gradient(225deg, rgba(245, 158, 11, 0.12), transparent 40%),
    linear-gradient(180deg, rgba(18, 28, 47, 0.92), rgba(10, 18, 32, 0.96));
  animation: rise 0.45s ease;
}
.train-hero::before {
  content: "";
  position: absolute;
  inset: auto -10% -40% 40%;
  height: 180px;
  background: radial-gradient(circle, rgba(45, 212, 191, 0.22), transparent 70%);
  pointer-events: none;
  animation: pulseGlow 4.5s ease-in-out infinite;
}
.train-hero-copy,
.train-hero-stats {
  position: relative;
  z-index: 1;
}
.train-kicker {
  margin: 0 0 0.45rem;
  color: var(--accent);
  font-size: 0.82rem;
  letter-spacing: 0.08em;
  font-weight: 700;
}
.train-hero h1 {
  margin: 0;
  font-family: var(--font-display);
  font-size: clamp(1.6rem, 3vw, 2.2rem);
  line-height: 1.25;
}
.train-hero-copy > p:last-child {
  margin: 0.55rem 0 0;
  color: var(--muted);
  max-width: 36rem;
  line-height: 1.7;
}
.train-hero-stats {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0.7rem;
}
.train-stat {
  padding: 0.9rem 1rem;
  border-radius: 16px;
  border: 1px solid rgba(255,255,255,0.08);
  background: rgba(0, 0, 0, 0.22);
  backdrop-filter: blur(8px);
}
.train-stat-label {
  display: block;
  color: var(--muted);
  font-size: 0.78rem;
  margin-bottom: 0.35rem;
}
.train-stat strong {
  font-family: var(--font-display);
  font-size: 1.05rem;
  font-weight: 700;
  color: var(--text);
  word-break: break-word;
}

.train-layout {
  display: grid;
  grid-template-columns: 1.15fr 0.85fr;
  gap: 1.1rem;
}

.train-panel {
  animation: rise 0.5s ease both;
}
.train-panel--knowledge { animation-delay: 0.05s; }
.train-panel--faq { animation-delay: 0.12s; }
.train-panel--browser { animation-delay: 0.08s; }
.train-panel--saved { animation-delay: 0.16s; }

.train-panel .panel-head h2 {
  margin: 0.15rem 0 0;
  font-family: var(--font-display);
  font-size: 1.28rem;
}
.section-tag {
  margin: 0;
  display: inline-block;
  color: var(--accent2);
  font-size: 0.75rem;
  font-weight: 700;
  letter-spacing: 0.04em;
}

.train-form {
  display: flex;
  flex-direction: column;
  gap: 0.15rem;
}

.create-strip {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 0.75rem;
  align-items: end;
  padding: 1rem;
  border-radius: 16px;
  border: 1px solid rgba(45, 212, 191, 0.18);
  background:
    linear-gradient(90deg, rgba(45, 212, 191, 0.08), transparent 70%);
}
.create-strip label { margin-top: 0; }
.create-strip button { white-space: nowrap; }

.field-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0.85rem;
}

.upload-block {
  margin-top: 1rem;
}

.dropzone {
  position: relative;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 0.35rem;
  margin: 1rem 0 0.35rem;
  padding: 1.6rem 1rem;
  border-radius: 18px;
  border: 1.5px dashed rgba(45, 212, 191, 0.35);
  background:
    radial-gradient(circle at 30% 20%, rgba(45, 212, 191, 0.12), transparent 45%),
    rgba(26, 39, 64, 0.55);
  text-align: center;
  cursor: pointer;
  transition: border-color 0.2s ease, transform 0.2s ease, background 0.2s ease;
}
.dropzone:hover,
.dropzone.dragover {
  border-color: rgba(45, 212, 191, 0.7);
  transform: translateY(-2px);
  background:
    radial-gradient(circle at 30% 20%, rgba(45, 212, 191, 0.18), transparent 45%),
    rgba(26, 39, 64, 0.75);
}
.dropzone.has-files {
  border-style: solid;
  border-color: rgba(245, 158, 11, 0.45);
}
.dropzone input[type="file"] {
  position: absolute;
  inset: 0;
  opacity: 0;
  cursor: pointer;
}
.dropzone-icon {
  width: 42px;
  height: 42px;
  margin-bottom: 0.25rem;
  border-radius: 14px;
  background:
    linear-gradient(135deg, rgba(45, 212, 191, 0.9), rgba(20, 184, 166, 0.65));
  box-shadow: 0 10px 24px rgba(45, 212, 191, 0.25);
  position: relative;
}
.dropzone-icon::before,
.dropzone-icon::after {
  content: "";
  position: absolute;
  background: #042f2e;
  border-radius: 2px;
}
.dropzone-icon::before {
  width: 16px;
  height: 2px;
  top: 20px;
  left: 13px;
}
.dropzone-icon::after {
  width: 2px;
  height: 16px;
  top: 13px;
  left: 20px;
}
.dropzone strong {
  color: var(--text);
  font-size: 0.98rem;
}
.dropzone em {
  color: var(--muted);
  font-style: normal;
  font-size: 0.82rem;
}
.dropzone-files {
  margin-top: 0.45rem;
  color: var(--accent2);
  font-size: 0.8rem;
  max-width: 100%;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.faq-pair {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0.85rem;
}

.train-foot {
  margin-top: 1rem !important;
  padding-top: 0.85rem;
  border-top: 1px solid var(--line);
}

.browser-card,
.faq-list {
  max-height: 560px;
  overflow: auto;
}

.cat-rail {
  display: flex;
  flex-direction: column;
  gap: 0.45rem;
}

.cat-chip {
  display: flex;
  width: 100%;
  justify-content: space-between;
  align-items: center;
  gap: 0.75rem;
  margin-bottom: 0;
  padding: 0.85rem 0.95rem;
  border-radius: 14px;
  border: 1px solid var(--line);
  background: rgba(255,255,255,0.025);
  color: var(--text);
  text-align: right;
  font-weight: 600;
  transition: border-color 0.2s ease, background 0.2s ease, transform 0.2s ease;
}
.cat-chip-main {
  display: inline-flex;
  align-items: center;
  gap: 0.55rem;
  min-width: 0;
}
.cat-dot {
  width: 9px;
  height: 9px;
  border-radius: 50%;
  background: var(--muted);
  flex: 0 0 auto;
}
.cat-name {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.cat-meta,
.cat-chip span {
  color: var(--muted);
  font-size: 0.78rem;
  font-weight: 500;
  flex: 0 0 auto;
}
.cat-chip.active {
  border-color: rgba(45, 212, 191, 0.5);
  background: linear-gradient(90deg, rgba(45, 212, 191, 0.14), rgba(45, 212, 191, 0.04));
  transform: translateX(-3px);
}
.cat-chip.active .cat-dot {
  background: var(--accent);
  box-shadow: 0 0 0 4px rgba(45, 212, 191, 0.15);
}
.cat-chip:hover {
  transform: translateX(-2px);
  filter: none;
  border-color: rgba(45, 212, 191, 0.35);
}

.doc-list {
  margin-top: 1rem;
  padding-top: 0.9rem;
  border-top: 1px solid var(--line);
  display: flex;
  flex-direction: column;
  gap: 0.65rem;
}

.knowledge-item {
  margin-bottom: 0;
  transition: border-color 0.2s ease, transform 0.2s ease, background 0.2s ease;
  animation: rise 0.35s ease both;
}
.knowledge-item:hover {
  border-color: rgba(255,255,255,0.16);
  background: rgba(255,255,255,0.04);
  transform: translateY(-1px);
}
.doc-item-top {
  display: flex;
  justify-content: space-between;
  gap: 0.6rem;
  align-items: flex-start;
  margin-bottom: 0.35rem;
}
.doc-item-top strong {
  margin-bottom: 0;
}
.soft-hint {
  color: var(--muted);
  font-size: 0.75rem;
}
.ghost-danger {
  padding: 0.35rem 0.75rem !important;
  font-size: 0.82rem !important;
  border-radius: 10px !important;
}

.empty-rich {
  display: flex;
  flex-direction: column;
  gap: 0.35rem;
  padding: 2.4rem 1rem;
}
.empty-rich strong {
  color: var(--text);
  font-family: var(--font-display);
}
.empty-rich span {
  color: var(--muted);
  font-size: 0.9rem;
}

@keyframes pulseGlow {
  0%, 100% { opacity: 0.55; transform: translateY(0); }
  50% { opacity: 1; transform: translateY(-8px); }
}

@media (max-width: 960px) {
  .train-hero,
  .train-layout,
  .field-grid,
  .faq-pair,
  .create-strip {
    grid-template-columns: 1fr;
  }
  .train-hero-stats {
    grid-template-columns: 1fr 1fr;
  }
  .create-strip button {
    width: 100%;
  }
}

@media (max-width: 560px) {
  .train-hero {
    padding: 1.2rem 1rem;
  }
  .train-hero-stats {
    grid-template-columns: 1fr;
  }
  .cat-chip {
    flex-direction: column;
    align-items: flex-start;
  }
}

/* Chat workspace */
.chat-workspace {
  display: grid;
  grid-template-columns: 280px 1fr;
  gap: 0;
  padding: 0;
  overflow: hidden;
  min-height: 0;
  border: 1px solid rgba(255,255,255,0.08);
  border-radius: 22px;
  background: linear-gradient(165deg, rgba(18, 28, 48, 0.92), rgba(10, 18, 32, 0.88));
  box-shadow: 0 24px 60px rgba(0, 0, 0, 0.28);
  position: relative;
}
.chat-workspace::before {
  content: "";
  position: absolute;
  inset: 0;
  pointer-events: none;
  background:
    radial-gradient(600px 280px at 100% 0%, rgba(45, 212, 191, 0.10), transparent 55%),
    radial-gradient(480px 240px at 0% 100%, rgba(245, 158, 11, 0.08), transparent 50%);
  border-radius: inherit;
  z-index: 0;
}
.chat-sidebar, .chat-main { position: relative; z-index: 1; }
.chat-sidebar {
  border-left: 1px solid rgba(255,255,255,0.07);
  padding: 1rem 0.9rem;
  background: rgba(0,0,0,0.22);
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
  min-height: 0;
  overflow: hidden;
}
.chat-side-top { display: flex; flex-direction: column; gap: 0.65rem; }
.chat-new-btn {
  display: flex; align-items: center; justify-content: center; gap: 0.45rem;
  width: 100%; border: none; border-radius: 14px; padding: 0.72rem 0.9rem;
  font-family: inherit; font-weight: 700; font-size: 0.95rem; color: #042f2e; cursor: pointer;
  background: linear-gradient(135deg, #2dd4bf, #14b8a6 60%, #0d9488);
  box-shadow: 0 10px 24px rgba(20, 184, 166, 0.28);
  transition: transform 0.15s ease, filter 0.15s ease;
}
.chat-new-btn:hover { filter: brightness(1.05); transform: translateY(-1px); }
.chat-new-ico {
  width: 1.35rem; height: 1.35rem; border-radius: 999px; display: inline-grid; place-items: center;
  background: rgba(4, 47, 46, 0.15); font-size: 1.05rem; line-height: 1;
}
.chat-search-wrap { display: block; }
.chat-main {
  padding: 0.85rem 1.05rem 0.75rem;
  display: grid;
  grid-template-rows: auto auto minmax(0, 1fr) auto;
  gap: 0.55rem;
  min-width: 0; min-height: 0; overflow: hidden;
}
.chat-head {
  display: flex; align-items: flex-start; justify-content: space-between; gap: 1rem; flex-wrap: wrap;
  padding: 0.15rem 0.2rem 0.55rem; border-bottom: 1px solid rgba(255,255,255,0.06);
}
.chat-kicker { margin: 0; font-size: 0.7rem; letter-spacing: 0.14em; color: var(--accent); font-weight: 700; }
.chat-head-copy h1 { margin: 0.2rem 0 0.25rem; font-family: var(--font-display); font-size: 1.35rem; }
.chat-meta { margin: 0; color: var(--muted); font-size: 0.86rem; }
.chat-head-tools { display: flex; align-items: flex-end; gap: 0.55rem; }
.chat-folder { display: flex; flex-direction: column; gap: 0.25rem; font-size: 0.78rem; color: var(--muted); }
.chat-folder select {
  min-width: 150px; background: rgba(255,255,255,0.04); border: 1px solid var(--line); color: var(--text);
  border-radius: 10px; padding: 0.45rem 0.6rem; font-family: inherit;
}
.chat-link {
  align-self: flex-end; padding: 0.45rem 0.7rem; border-radius: 10px; border: 1px solid var(--line);
  color: var(--text); font-size: 0.82rem; text-decoration: none; background: rgba(255,255,255,0.03);
}
.chat-link:hover { border-color: rgba(45,212,191,0.4); text-decoration: none; }
.chat-toolbar { display: flex; align-items: center; justify-content: space-between; gap: 0.75rem; flex-wrap: wrap; }
.chat-teacher-toggle {
  display: flex; align-items: center; gap: 0.55rem; margin: 0; cursor: pointer;
  padding: 0.35rem 0.55rem; border-radius: 12px; border: 1px solid transparent;
}
.chat-teacher-toggle:hover { border-color: var(--line); background: rgba(255,255,255,0.03); }
.chat-teacher-toggle input { position: absolute; opacity: 0; width: 1px; height: 1px; }
.chat-teacher-ui {
  width: 38px; height: 22px; border-radius: 999px; background: #334155; position: relative; flex: 0 0 auto; transition: 0.2s ease;
}
.chat-teacher-ui::after {
  content: ""; position: absolute; top: 3px; left: 3px; width: 16px; height: 16px; border-radius: 50%; background: #e2e8f0; transition: 0.2s ease;
}
.chat-teacher-toggle input:checked + .chat-teacher-ui { background: #f59e0b; }
.chat-teacher-toggle input:checked + .chat-teacher-ui::after { left: 19px; background: #422006; }
.chat-teacher-copy { display: flex; flex-direction: column; line-height: 1.25; }
.chat-teacher-copy strong { font-size: 0.84rem; }
.chat-teacher-copy small { color: var(--muted); font-size: 0.72rem; }
.conv-search {
  width: 100%; box-sizing: border-box; background: rgba(255,255,255,0.04); border: 1px solid var(--line);
  color: var(--text); border-radius: 12px; padding: 0.6rem 0.75rem; font-family: inherit; font-size: 0.88rem;
}
.conv-search:focus { outline: none; border-color: rgba(45, 212, 191, 0.45); box-shadow: 0 0 0 3px rgba(45, 212, 191, 0.12); }
.chat-history-list { overflow: auto; display: flex; flex-direction: column; gap: 0.4rem; flex: 1; }
.chat-empty-side { padding: 1.2rem 0.8rem; text-align: center; color: var(--muted); font-size: 0.9rem; line-height: 1.6; }
.chat-empty-side div { margin-top: 0.25rem; font-size: 0.8rem; opacity: 0.8; }
.conv-item {
  display: flex; align-items: stretch; gap: 0.2rem; text-align: right;
  background: rgba(255,255,255,0.02); border: 1px solid transparent; color: var(--text);
  padding: 0.15rem; border-radius: 14px; font-family: inherit;
  transition: background 0.15s ease, border-color 0.15s ease;
}
.conv-open {
  flex: 1; min-width: 0; text-align: right; background: transparent; border: none; color: inherit;
  padding: 0.55rem; cursor: pointer; font-family: inherit;
}
.conv-title { display: block; font-size: 0.9rem; font-weight: 700; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.conv-item small { display: block; margin-top: 0.2rem; color: var(--muted); font-size: 0.72rem; }
.conv-actions {
  display: flex;
  align-items: center;
  justify-content: center;
  flex: 0 0 auto;
  opacity: 0;
  transition: opacity 0.15s ease;
  padding: 0 0.2rem 0 0.1rem;
}
.conv-item:hover .conv-actions,
.conv-item.active .conv-actions { opacity: 1; }
.conv-act {
  width: 1.85rem;
  height: 1.85rem;
  border-radius: 10px;
  border: 1px solid rgba(255,255,255,0.08);
  background: rgba(255,255,255,0.04);
  color: #94a3b8;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 0;
  line-height: 0;
  font-family: inherit;
  transition: background 0.15s ease, color 0.15s ease, border-color 0.15s ease;
}
.conv-act svg { display: block; pointer-events: none; }
.conv-act:hover {
  background: rgba(255,255,255,0.08);
  color: var(--text);
}
.conv-act.danger:hover {
  background: rgba(251, 113, 133, 0.16);
  color: #fb7185;
  border-color: rgba(251, 113, 133, 0.35);
}
.conv-item:hover, .conv-item.active { background: rgba(45, 212, 191, 0.08); border-color: rgba(45, 212, 191, 0.22); }
.visually-hidden {
  position: absolute !important; width: 1px; height: 1px; padding: 0; margin: -1px;
  overflow: hidden; clip: rect(0,0,0,0); white-space: nowrap; border: 0;
}
.btn-primary {
  background: var(--accent);
  color: #042f2e;
  border: none;
  border-radius: 12px;
  padding: 0.65rem 0.8rem;
  font-weight: 700;
  cursor: pointer;
  font-family: inherit;
}
.dash-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(160px, 1fr));
  gap: 0.85rem;
  margin-bottom: 1.5rem;
}
.dash-card {
  border: 1px solid var(--line);
  border-radius: 14px;
  padding: 1rem;
  background: rgba(255,255,255,0.03);
}
.dash-card span {
  display: block;
  color: var(--muted);
  font-size: 0.85rem;
  margin-bottom: 0.35rem;
}
.dash-card strong {
  font-size: 1.45rem;
  font-family: var(--font-display);
}
.arch-flow ol {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
  gap: 0.5rem;
  padding: 0;
  list-style: none;
  counter-reset: step;
}
.arch-flow li {
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 0.75rem;
  counter-increment: step;
}
.arch-flow li::before {
  content: counter(step) ". ";
  color: var(--accent);
  font-weight: 700;
}
.data-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.9rem;
}
.data-table th,
.data-table td {
  border-bottom: 1px solid var(--line);
  padding: 0.7rem 0.85rem;
  text-align: right;
}
.actions-row {
  display: flex;
  gap: 0.75rem;
  align-items: center;
  margin-bottom: 1rem;
  flex-wrap: wrap;
}
.mem-list {
  list-style: none;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: 0.4rem;
}
.mem-list li {
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 0.55rem 0.75rem;
}
.model-active-card {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 1rem;
  flex-wrap: wrap;
  padding: 1.1rem 1.2rem;
  margin-bottom: 1.15rem;
  border-radius: 16px;
  border: 1px solid rgba(45, 212, 191, 0.28);
  background:
    linear-gradient(135deg, rgba(45, 212, 191, 0.12), transparent 55%),
    rgba(255,255,255,0.03);
}
.model-active-card .label {
  color: var(--muted);
  font-size: 0.8rem;
  margin-bottom: 0.3rem;
}
.model-active-card .name {
  font-family: var(--font-display);
  font-size: 1.2rem;
  margin: 0;
}
@media (max-width: 860px) {
  .chat-workspace {
    grid-template-columns: 1fr;
    grid-template-rows: minmax(140px, 28%) minmax(0, 1fr);
    height: auto;
    max-height: none;
    min-height: 0;
    border-radius: 16px;
  }
  .chat-sidebar {
    border-left: none;
    border-bottom: 1px solid var(--line);
    max-height: none;
    min-height: 0;
  }
  .chat-head-copy h1 { font-size: 1.15rem; }
  .conv-item .conv-actions { opacity: 1; }
  body.page-chat .chat-box {
    height: auto !important;
    flex: unset !important;
    min-height: 0 !important;
  }
}

/* User info folders */
.folders-workspace {
  display: grid;
  grid-template-columns: 260px 1fr;
  gap: 0;
  padding: 0;
  overflow: hidden;
  min-height: 72vh;
}
.folders-sidebar {
  border-left: 1px solid var(--line);
  padding: 1rem;
  background: rgba(0,0,0,0.18);
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
}
.folders-main {
  padding: 1.25rem;
  min-width: 0;
}
.panel-head.compact h1 {
  font-size: 1.25rem;
  margin: 0 0 0.25rem;
}
.panel-head.compact p {
  margin: 0;
  color: var(--muted);
  font-size: 0.85rem;
}
.folder-create {
  display: flex;
  flex-direction: column;
  gap: 0.45rem;
}
.folder-create input {
  background: rgba(255,255,255,0.04);
  border: 1px solid var(--line);
  color: var(--text);
  border-radius: 10px;
  padding: 0.55rem 0.7rem;
  font-family: inherit;
}
.folder-list {
  overflow: auto;
  display: flex;
  flex-direction: column;
  gap: 0.35rem;
  flex: 1;
}
.folder-item {
  text-align: right;
  background: transparent;
  border: 1px solid transparent;
  color: var(--text);
  padding: 0.55rem 0.65rem;
  border-radius: 12px;
  cursor: pointer;
  font-family: inherit;
}
.folder-item small {
  display: block;
  color: var(--muted);
  font-size: 0.72rem;
  margin-top: 0.2rem;
}
.folder-item:hover,
.folder-item.active {
  border-color: var(--line);
  background: rgba(45, 212, 191, 0.08);
}
.empty-folder-state {
  padding: 3rem 1.5rem;
  text-align: center;
  color: var(--muted);
}
.empty-folder-state h2 {
  color: var(--text);
  margin-bottom: 0.5rem;
}
.folder-grid {
  display: grid;
  grid-template-columns: minmax(180px, 240px) 1fr;
  gap: 1.25rem;
  margin-top: 0.5rem;
}
.folder-docs h3,
.folder-editor h3,
.upload-block h3 {
  margin: 0 0 0.65rem;
  font-size: 0.95rem;
}
.doc-list {
  display: flex;
  flex-direction: column;
  gap: 0.35rem;
  max-height: 60vh;
  overflow: auto;
}
.doc-item {
  display: flex;
  align-items: stretch;
  border: 1px solid var(--line);
  border-radius: 10px;
  overflow: hidden;
}
.doc-open {
  flex: 1;
  text-align: right;
  background: transparent;
  border: none;
  color: var(--text);
  padding: 0.55rem 0.65rem;
  cursor: pointer;
  font-family: inherit;
}
.doc-open strong {
  display: block;
  font-weight: 600;
}
.doc-open small {
  color: var(--muted);
  font-size: 0.72rem;
}
.doc-del {
  border: none;
  background: transparent;
  color: var(--muted);
  padding: 0 0.7rem;
  cursor: pointer;
  font-size: 1.1rem;
}
.doc-del:hover {
  color: #fda4af;
  background: rgba(244, 63, 94, 0.1);
}
.folder-editor label {
  display: block;
  margin: 0.55rem 0 0.3rem;
  color: var(--muted);
  font-size: 0.85rem;
}
.folder-editor input[type="text"],
.folder-editor textarea {
  width: 100%;
  box-sizing: border-box;
  background: rgba(255,255,255,0.04);
  border: 1px solid var(--line);
  color: var(--text);
  border-radius: 10px;
  padding: 0.6rem 0.75rem;
  font-family: inherit;
  resize: vertical;
}
.upload-block {
  margin-top: 1.5rem;
  padding-top: 1.25rem;
  border-top: 1px solid var(--line);
}
.danger-btn {
  border-color: rgba(244, 63, 94, 0.35) !important;
  color: #fda4af !important;
}
@media (max-width: 960px) {
  .folders-workspace {
    grid-template-columns: 1fr;
  }
  .folders-sidebar {
    border-left: none;
    border-bottom: 1px solid var(--line);
    max-height: 280px;
  }
  .folder-grid {
    grid-template-columns: 1fr;
  }
}

/* API keys page */
.api-keys-layout {
  display: grid;
  grid-template-columns: minmax(280px, 1fr) minmax(320px, 1.15fr);
  gap: 1rem;
  align-items: start;
}
.api-key-create label {
  display: block;
  margin-bottom: 0.35rem;
  color: var(--muted);
  font-size: 0.85rem;
}
.api-key-create-row {
  display: flex;
  gap: 0.55rem;
  flex-wrap: wrap;
}
.api-key-create-row input {
  flex: 1;
  min-width: 180px;
  background: rgba(255,255,255,0.04);
  border: 1px solid var(--line);
  color: var(--text);
  border-radius: 10px;
  padding: 0.65rem 0.8rem;
  font-family: inherit;
}
.api-key-reveal {
  margin-top: 1rem;
  padding: 1rem 1.1rem;
  border-radius: 14px;
  border: 1px solid rgba(45, 212, 191, 0.35);
  background: rgba(45, 212, 191, 0.08);
  display: grid;
  gap: 0.55rem;
}
.api-key-reveal code {
  display: block;
  word-break: break-all;
  padding: 0.7rem 0.8rem;
  border-radius: 10px;
  background: rgba(0,0,0,0.35);
  color: var(--accent);
  font-size: 0.88rem;
}
.api-keys-list {
  display: flex;
  flex-direction: column;
  gap: 0.55rem;
}
.api-key-row {
  display: flex;
  justify-content: space-between;
  gap: 0.75rem;
  align-items: flex-start;
  padding: 0.85rem 0.95rem;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: rgba(255,255,255,0.03);
}
.api-key-actions {
  display: flex;
  gap: 0.35rem;
  flex-wrap: wrap;
  flex-shrink: 0;
}
.api-key-badge {
  display: inline-block;
  font-size: 0.72rem;
  font-weight: 700;
  padding: 0.15rem 0.45rem;
  border-radius: 6px;
  margin-right: 0.35rem;
}
.api-key-badge.ok {
  background: rgba(45, 212, 191, 0.15);
  color: var(--accent);
}
.api-key-badge.off {
  background: rgba(244, 63, 94, 0.12);
  color: #fda4af;
}
.api-docs h3 {
  margin: 1.15rem 0 0.45rem;
  font-size: 0.98rem;
}
.api-docs h3:first-child {
  margin-top: 0;
}
.api-docs p {
  color: var(--muted);
  line-height: 1.65;
  margin: 0.25rem 0 0.5rem;
}
.api-fields {
  margin: 0.4rem 0 0.8rem;
  padding-right: 1.2rem;
  color: var(--muted);
  line-height: 1.8;
}
.api-fields code,
.api-docs code {
  font-size: 0.84rem;
  color: var(--accent);
}
.api-code {
  margin: 0.4rem 0 0.85rem;
  padding: 0.85rem 1rem;
  border-radius: 12px;
  border: 1px solid var(--line);
  background: rgba(0,0,0,0.35);
  color: #e2e8f0;
  font-size: 0.78rem;
  line-height: 1.55;
  overflow-x: auto;
  white-space: pre-wrap;
  word-break: break-word;
  direction: ltr;
  text-align: left;
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
}
@media (max-width: 900px) {
  .api-keys-layout {
    grid-template-columns: 1fr;
  }
}

body.page-settings .app-shell {
  width: min(1220px, calc(100% - 2rem));
}

.set-hero {
  position: relative;
  overflow: hidden;
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 1.2rem;
  flex-wrap: wrap;
  margin-bottom: 1.15rem;
  padding: 1.6rem 1.55rem 1.5rem;
  border-radius: 24px;
  border: 1px solid rgba(255,255,255,0.08);
  background:
    linear-gradient(135deg, rgba(45, 212, 191, 0.16), transparent 42%),
    linear-gradient(210deg, rgba(99, 102, 241, 0.16), transparent 46%),
    linear-gradient(180deg, rgba(16, 24, 40, 0.96), rgba(8, 14, 26, 0.98));
}
.set-hero-glow {
  position: absolute;
  inset: auto -80px -90px auto;
  width: 260px;
  height: 260px;
  border-radius: 50%;
  background: radial-gradient(circle, rgba(45, 212, 191, 0.28), transparent 68%);
  pointer-events: none;
}
.set-hero-copy { position: relative; max-width: 40rem; }
.set-hero-copy h1 {
  margin: 0;
  font-family: var(--font-display);
  font-size: clamp(1.5rem, 3vw, 2.05rem);
  line-height: 1.25;
}
.set-hero-copy p {
  margin: 0.5rem 0 0;
  color: var(--muted);
  line-height: 1.7;
}

.set-status {
  position: relative;
  display: flex;
  align-items: center;
  gap: 0.7rem;
  min-width: 210px;
  padding: 0.75rem 0.95rem;
  border-radius: 16px;
  border: 1px solid rgba(255,255,255,0.1);
  background: rgba(0,0,0,0.28);
}
.set-status strong, .set-status small { display: block; }
.set-status small { color: var(--muted); margin-top: 0.15rem; font-size: 0.78rem; }
.set-status-dot {
  width: 12px;
  height: 12px;
  border-radius: 50%;
  background: #64748b;
  box-shadow: 0 0 0 5px rgba(100, 116, 139, 0.18);
  flex: 0 0 auto;
}
.set-status.on { border-color: rgba(45, 212, 191, 0.35); }
.set-status.on .set-status-dot {
  background: var(--ok);
  box-shadow: 0 0 0 5px rgba(52, 211, 153, 0.2);
  animation: pulse-dot 1.6s ease infinite;
}
.set-status.off { border-color: rgba(251, 113, 133, 0.28); }
.set-status.off .set-status-dot {
  background: var(--danger);
  box-shadow: 0 0 0 5px rgba(251, 113, 133, 0.16);
}
@keyframes pulse-dot {
  0%, 100% { transform: scale(1); }
  50% { transform: scale(1.15); }
}

.set-card {
  margin-bottom: 1.1rem;
  padding: 1.25rem 1.3rem 1.4rem;
  border-radius: 22px;
  border: 1px solid rgba(255,255,255,0.08);
  background:
    linear-gradient(180deg, rgba(255,255,255,0.045), rgba(255,255,255,0.02));
  box-shadow: var(--shadow);
}
.set-card-help {
  background:
    linear-gradient(180deg, rgba(245, 158, 11, 0.07), rgba(255,255,255,0.02) 38%);
}
.set-card-head { margin-bottom: 1.05rem; }
.set-card-head h2 {
  margin: 0.15rem 0 0;
  font-family: var(--font-display);
  font-size: 1.25rem;
}
.set-card-head p { margin: 0.3rem 0 0; color: var(--muted); font-size: 0.9rem; }
.set-step {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 2.1rem;
  padding: 0.12rem 0.45rem;
  border-radius: 999px;
  background: rgba(45, 212, 191, 0.16);
  color: var(--accent);
  font-size: 0.72rem;
  font-weight: 800;
  letter-spacing: 0.04em;
}
.set-step.gold {
  background: rgba(245, 158, 11, 0.16);
  color: #fbbf24;
}

.set-offline {
  margin-bottom: 1rem;
  padding: 1rem 1.05rem;
  border-radius: 16px;
  border: 1px solid rgba(251, 113, 133, 0.35);
  background: rgba(251, 113, 133, 0.08);
}
.set-offline p { margin: 0.4rem 0 0.8rem; color: var(--muted); line-height: 1.65; }
.set-offline-actions { display: flex; flex-wrap: wrap; gap: 0.55rem; }
.set-offline-actions .set-btn { text-decoration: none; display: inline-flex; align-items: center; }

.set-connect {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 0.75rem;
  align-items: end;
  padding: 0.9rem;
  border-radius: 16px;
  border: 1px solid var(--line);
  background: rgba(0,0,0,0.18);
}
.set-connect-main label {
  margin-top: 0;
}
.set-hint {
  margin: 0.7rem 0 0;
  color: var(--muted);
  font-size: 0.84rem;
  line-height: 1.6;
}
.set-btn {
  border: 0;
  border-radius: 12px;
  padding: 0.78rem 1.05rem;
  font: inherit;
  font-weight: 700;
  cursor: pointer;
  color: #042f2e;
  background: linear-gradient(135deg, #5eead4, #14b8a6);
  box-shadow: 0 8px 20px rgba(20, 184, 166, 0.22);
}
.set-btn:hover { filter: brightness(1.06); transform: translateY(-1px); }
.set-btn.ghost {
  background: transparent;
  color: var(--text);
  border: 1px solid var(--line);
  box-shadow: none;
}
.set-btn.danger {
  background: transparent;
  color: #fda4af;
  border: 1px solid rgba(251, 113, 133, 0.35);
  box-shadow: none;
}

.set-models {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(270px, 1fr));
  gap: 0.95rem;
  margin-top: 1.15rem;
}
.set-kind-filters {
  display: flex;
  flex-wrap: wrap;
  gap: 0.45rem;
  margin-top: 1rem;
}
.set-kind-btn {
  border: 1px solid rgba(255,255,255,0.12);
  background: rgba(255,255,255,0.03);
  color: var(--muted);
  border-radius: 999px;
  padding: 0.35rem 0.85rem;
  font-size: 0.82rem;
  font-weight: 700;
  cursor: pointer;
  transition: border-color 0.15s ease, color 0.15s ease, background 0.15s ease;
}
.set-kind-btn:hover {
  border-color: rgba(45, 212, 191, 0.35);
  color: #e2e8f0;
}
.set-kind-btn.on {
  border-color: rgba(45, 212, 191, 0.55);
  background: rgba(45, 212, 191, 0.12);
  color: #99f6e4;
}
.set-model {
  position: relative;
  display: flex;
  flex-direction: column;
  gap: 0.65rem;
  min-height: 100%;
  padding: 1.05rem 1.05rem 1rem;
  border-radius: 18px;
  border: 1px solid rgba(255,255,255,0.08);
  background:
    linear-gradient(180deg, rgba(255,255,255,0.045), rgba(8, 14, 26, 0.2));
  transition: transform 0.18s ease, border-color 0.18s ease, box-shadow 0.18s ease;
}
.set-model:hover {
  transform: translateY(-3px);
  border-color: rgba(45, 212, 191, 0.28);
  box-shadow: 0 16px 36px rgba(0,0,0,0.28);
}
.set-model.on { border-color: rgba(45, 212, 191, 0.5); box-shadow: 0 0 0 1px rgba(45, 212, 191, 0.15); }
.set-model.have { border-color: rgba(245, 158, 11, 0.38); }
.set-model.busy { border-color: rgba(148, 163, 184, 0.4); }
.set-model.fail { border-color: rgba(251, 113, 133, 0.4); }
.set-model-top { display: flex; align-items: center; gap: 0.75rem; }
.set-model-title h3 {
  margin: 0;
  font-size: 1.02rem;
  font-family: var(--font-display);
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.4rem;
}
.set-model p { margin: 0; color: var(--muted); font-size: 0.88rem; line-height: 1.65; flex: 1; }
.set-ico {
  width: 46px;
  height: 46px;
  border-radius: 14px;
  display: grid;
  place-items: center;
  font-weight: 800;
  font-size: 0.82rem;
  letter-spacing: 0.02em;
  color: #042f2e;
  background: linear-gradient(145deg, #99f6e4, #2dd4bf);
  flex: 0 0 auto;
}
.tone-code .set-ico { background: linear-gradient(145deg, #fde68a, #f59e0b); color: #451a03; }
.tone-data .set-ico { background: linear-gradient(145deg, #a5f3fc, #0891b2); color: #083344; }
.tone-erp .set-ico { background: linear-gradient(145deg, #ddd6fe, #7c3aed); color: #fff; }
.tone-web .set-ico { background: linear-gradient(145deg, #bae6fd, #0284c7); color: #082f49; }
.tone-speech .set-ico { background: linear-gradient(145deg, #fecdd3, #e11d48); color: #fff; }
.tone-qwen .set-ico { background: linear-gradient(145deg, #c4b5fd, #7c3aed); color: #fff; }
.tone-llama .set-ico { background: linear-gradient(145deg, #93c5fd, #2563eb); color: #fff; }
.tone-meta .set-ico { background: linear-gradient(145deg, #67e8f9, #0284c7); color: #082f49; }
.tone-gemma .set-ico { background: linear-gradient(145deg, #fdba74, #ea580c); color: #fff; }
.tone-mistral .set-ico { background: linear-gradient(145deg, #fda4af, #e11d48); color: #fff; }
.tone-phi .set-ico { background: linear-gradient(145deg, #a5b4fc, #4f46e5); color: #fff; }
.tone-fa .set-ico { background: linear-gradient(145deg, #5eead4, #0f766e); color: #ecfdf5; }
.tone-embed .set-ico { background: linear-gradient(145deg, #86efac, #16a34a); color: #052e16; }
.set-kind, .set-rec, .set-specs span {
  display: inline-flex;
  align-items: center;
  border-radius: 999px;
  font-size: 0.7rem;
  font-weight: 700;
}
.set-kind {
  margin-top: 0.28rem;
  padding: 0.12rem 0.5rem;
  color: var(--accent);
  background: rgba(45, 212, 191, 0.1);
}
.set-rec {
  font-style: normal;
  padding: 0.1rem 0.45rem;
  color: #451a03;
  background: #fbbf24;
}
.set-specs { display: flex; flex-wrap: wrap; gap: 0.35rem; }
.set-specs span {
  padding: 0.22rem 0.5rem;
  color: #cbd5e1;
  background: rgba(255,255,255,0.05);
  border: 1px solid rgba(255,255,255,0.06);
}
.set-model-status {
  font-size: 0.8rem;
  font-weight: 700;
  color: #94a3b8;
}
.set-model.on .set-model-status { color: var(--ok); }
.set-model-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 0.45rem;
  margin-top: auto;
}
.set-model-actions .set-btn { flex: 1; min-width: 7rem; }
.set-progress {
  width: 100%;
  display: flex;
  align-items: center;
  gap: 0.55rem;
  color: var(--muted);
  font-size: 0.84rem;
}
.set-progress i {
  width: 18px;
  height: 18px;
  border-radius: 50%;
  border: 2px solid rgba(45, 212, 191, 0.25);
  border-top-color: var(--accent);
  animation: spin 0.8s linear infinite;
}
.set-dl { width: 100%; display: grid; gap: 0.45rem; }
.set-dl-top {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  gap: 0.6rem;
}
.set-dl-top strong {
  font-size: 1.15rem;
  font-family: var(--font-display);
  color: var(--accent);
  min-width: 3.2rem;
}
.set-dl-top span {
  color: var(--muted);
  font-size: 0.78rem;
  text-align: left;
  direction: ltr;
}
.set-dl-bar {
  height: 8px;
  border-radius: 999px;
  background: rgba(255,255,255,0.08);
  overflow: hidden;
}
.set-dl-bar i {
  display: block;
  height: 100%;
  width: 0;
  border-radius: inherit;
  background: linear-gradient(90deg, #2dd4bf, #67e8f9);
  transition: width 0.25s ease;
}
@keyframes spin { to { transform: rotate(360deg); } }
.set-empty {
  grid-column: 1 / -1;
  padding: 1.4rem;
  border: 1px dashed rgba(255,255,255,0.14);
  border-radius: 14px;
  color: var(--muted);
}

.set-toggles {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0.75rem;
  margin-bottom: 1rem;
}
.set-toggle {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  margin: 0;
  padding: 0.9rem 0.95rem;
  border-radius: 16px;
  border: 1px solid var(--line);
  background: rgba(0,0,0,0.18);
  cursor: pointer;
  color: var(--text);
}
.set-toggle strong, .set-toggle small { display: block; }
.set-toggle small { color: var(--muted); font-weight: 400; margin-top: 0.18rem; line-height: 1.5; }
.set-toggle input {
  position: absolute;
  opacity: 0;
  width: 1px;
  height: 1px;
  overflow: hidden;
}
.set-switch {
  width: 42px;
  height: 24px;
  border-radius: 999px;
  background: #334155;
  position: relative;
  flex: 0 0 auto;
  transition: 0.2s ease;
  box-shadow: inset 0 0 0 1px rgba(255,255,255,0.08);
}
.set-switch::after {
  content: "";
  position: absolute;
  top: 3px;
  left: 3px;
  width: 18px;
  height: 18px;
  border-radius: 50%;
  background: #e2e8f0;
  transition: 0.2s ease;
}
.set-toggle input:checked + .set-switch { background: #14b8a6; }
.set-toggle input:checked + .set-switch::after { left: 21px; background: #042f2e; }
.set-help-status {
  margin: 0 0 0.85rem;
  padding: 0.7rem 0.9rem;
  border-radius: 12px;
  border: 1px solid var(--line);
  background: rgba(0,0,0,0.16);
  color: var(--muted);
  font-size: 0.92rem;
}
.set-help-status.on { color: #99f6e4; border-color: rgba(20,184,166,0.35); }
.set-help-status.warn { color: #fde68a; border-color: rgba(245,158,11,0.35); }
.set-help-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0.85rem 1rem;
}
.set-help-key { grid-column: 1 / -1; }
.set-help-actions { margin-top: 1rem; }
@media (max-width: 760px) {
  .set-connect, .set-toggles, .set-help-grid { grid-template-columns: 1fr; }
}

.model-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(260px, 1fr));
  gap: 0.85rem;
  margin-top: 1.1rem;
}
.model-card {
  border: 1px solid var(--line);
  border-radius: 16px;
  padding: 1rem 1.05rem;
  background: rgba(255,255,255,0.03);
  display: flex;
  flex-direction: column;
  gap: 0.45rem;
}
.model-card.on { border-color: rgba(45, 212, 191, 0.4); background: rgba(45, 212, 191, 0.06); }
.model-card.have { border-color: rgba(245, 158, 11, 0.3); }
.model-card.busy { border-color: rgba(147, 160, 184, 0.4); }
.model-card header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 0.5rem;
}
.model-card h3 { margin: 0; font-size: 1.02rem; font-family: var(--font-display); }
.model-card p { margin: 0; color: var(--muted); font-size: 0.88rem; line-height: 1.6; }
.model-pills {
  display: flex;
  flex-wrap: wrap;
  gap: 0.4rem;
  margin: 0;
  flex: 1;
}
.model-pill {
  border: 1px solid rgba(255,255,255,0.1);
  background: rgba(255,255,255,0.03);
  color: var(--muted);
  border-radius: 999px;
  padding: 0.35rem 0.8rem;
  font-size: 0.8rem;
  font-weight: 700;
  cursor: pointer;
  font-family: inherit;
  transition: 0.15s ease;
}
.model-pill:hover { border-color: rgba(45,212,191,0.35); color: var(--text); }
.model-pill.on {
  color: #042f2e;
  background: linear-gradient(135deg, #2dd4bf, #14b8a6);
  border-color: transparent;
  box-shadow: 0 6px 14px rgba(20,184,166,0.22);
}
.answer-card {
  border: 1px solid rgba(255,255,255,0.08);
  border-radius: 14px;
  padding: 0.75rem 0.85rem;
  margin-bottom: 0.55rem;
  background: rgba(0,0,0,0.22);
}
.answer-card:last-child { margin-bottom: 0; }
.answer-card.teacher {
  border-color: rgba(245, 158, 11, 0.4);
  background: rgba(245, 158, 11, 0.08);
}
.answer-card.err {
  border-color: rgba(251, 113, 133, 0.4);
  background: rgba(251, 113, 133, 0.08);
}
.answer-card.brain {
  border-color: rgba(45, 212, 191, 0.45);
  background:
    linear-gradient(135deg, rgba(45, 212, 191, 0.12), rgba(14, 165, 233, 0.08));
}
.brain-note {
  margin-top: 0.35rem;
  font-size: 0.75rem;
  color: #94a3b8;
  line-height: 1.5;
}
.answer-model {
  color: var(--accent);
  font-size: 0.75rem;
  font-weight: 700;
  margin-bottom: 0;
  flex: 1;
  min-width: 0;
}
.answer-card-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 0.6rem;
  margin-bottom: 0.4rem;
}
.answer-report-btn {
  flex-shrink: 0;
  border: 1px solid rgba(251, 113, 133, 0.35);
  background: rgba(251, 113, 133, 0.08);
  color: #fda4af;
  border-radius: 999px;
  padding: 0.2rem 0.55rem;
  font-size: 0.68rem;
  font-weight: 700;
  font-family: inherit;
  cursor: pointer;
  line-height: 1.4;
  transition: background 0.15s ease, border-color 0.15s ease, color 0.15s ease;
}
.answer-report-btn:hover {
  background: rgba(251, 113, 133, 0.18);
  border-color: rgba(251, 113, 133, 0.55);
  color: #fecdd3;
}
.answer-text {
  line-height: 1.7;
  word-break: break-word;
}

.feedback-modal[hidden] { display: none !important; }
.feedback-modal {
  position: fixed;
  inset: 0;
  z-index: 80;
  display: grid;
  place-items: center;
  padding: 1rem;
}
.feedback-modal-backdrop {
  position: absolute;
  inset: 0;
  background: rgba(2, 6, 23, 0.72);
  backdrop-filter: blur(4px);
}
.feedback-modal-panel {
  position: relative;
  z-index: 1;
  width: min(520px, 100%);
  max-height: min(90vh, 640px);
  overflow: auto;
  border-radius: 18px;
  border: 1px solid rgba(255,255,255,0.1);
  background: linear-gradient(165deg, #0f172a, #0b1220 60%);
  box-shadow: 0 24px 60px rgba(0,0,0,0.45);
  padding: 1.1rem 1.15rem 1.15rem;
}
.feedback-modal-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem;
  margin-bottom: 0.55rem;
}
.feedback-modal-head h2 {
  margin: 0;
  font-size: 1.05rem;
}
.feedback-modal-x {
  border: none;
  background: transparent;
  color: var(--muted);
  font-size: 1.4rem;
  line-height: 1;
  cursor: pointer;
  padding: 0.15rem 0.35rem;
}
.feedback-modal-source {
  margin: 0 0 0.85rem;
  color: var(--accent);
  font-size: 0.8rem;
  font-weight: 700;
}
.feedback-modal-label {
  display: block;
  font-size: 0.82rem;
  color: var(--muted);
  margin-bottom: 0.35rem;
}
.feedback-modal-panel textarea {
  width: 100%;
  resize: vertical;
  min-height: 96px;
  border-radius: 12px;
  border: 1px solid var(--line);
  background: rgba(0,0,0,0.28);
  color: var(--text);
  padding: 0.7rem 0.8rem;
  font-family: inherit;
  font-size: 0.92rem;
  margin-bottom: 0.85rem;
}
.feedback-modal-preview {
  border: 1px solid rgba(255,255,255,0.08);
  border-radius: 12px;
  padding: 0.7rem 0.8rem;
  background: rgba(0,0,0,0.22);
  margin-bottom: 1rem;
}
.feedback-modal-preview span {
  display: block;
  font-size: 0.72rem;
  color: var(--muted);
  margin-bottom: 0.35rem;
}
.feedback-modal-preview p {
  margin: 0;
  font-size: 0.85rem;
  line-height: 1.6;
  color: #cbd5e1;
  max-height: 140px;
  overflow: auto;
  white-space: pre-wrap;
}
.feedback-modal-actions {
  display: flex;
  justify-content: flex-start;
  gap: 0.55rem;
}

/* —— Teach / feedback page —— */
body.page-feedback .app-shell {
  width: min(1180px, calc(100% - 2rem));
}

.teach-hero {
  position: relative;
  overflow: hidden;
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 1.25rem;
  flex-wrap: wrap;
  margin-bottom: 1.15rem;
  padding: 1.55rem 1.5rem 1.45rem;
  border-radius: 24px;
  border: 1px solid rgba(255,255,255,0.08);
  background:
    linear-gradient(125deg, rgba(251, 113, 133, 0.14), transparent 40%),
    linear-gradient(215deg, rgba(45, 212, 191, 0.16), transparent 48%),
    linear-gradient(180deg, rgba(16, 24, 40, 0.96), rgba(8, 14, 26, 0.98));
  animation: rise 0.45s ease;
}
.teach-hero-glow {
  position: absolute;
  inset: auto auto -100px -60px;
  width: 280px;
  height: 280px;
  border-radius: 50%;
  background: radial-gradient(circle, rgba(251, 113, 133, 0.22), transparent 68%);
  pointer-events: none;
}
.teach-hero-copy {
  position: relative;
  max-width: 38rem;
}
.teach-hero-copy h1 {
  margin: 0;
  font-family: var(--font-display);
  font-size: clamp(1.5rem, 3vw, 2.05rem);
  line-height: 1.25;
}
.teach-hero-copy p {
  margin: 0.5rem 0 0;
  color: var(--muted);
  line-height: 1.7;
  font-size: 0.95rem;
}
.teach-hero-stats {
  position: relative;
  display: flex;
  gap: 0.65rem;
  flex-wrap: wrap;
}
.teach-stat {
  min-width: 7.5rem;
  padding: 0.85rem 1rem;
  border-radius: 16px;
  border: 1px solid rgba(255,255,255,0.1);
  background: rgba(0,0,0,0.32);
  backdrop-filter: blur(8px);
}
.teach-stat span {
  display: block;
  color: var(--muted);
  font-size: 0.75rem;
  font-weight: 600;
  margin-bottom: 0.25rem;
}
.teach-stat strong {
  font-family: var(--font-display);
  font-size: 1.55rem;
  line-height: 1;
}
.teach-stat-ok {
  border-color: rgba(45, 212, 191, 0.32);
  background: rgba(45, 212, 191, 0.08);
}
.teach-stat-ok strong { color: var(--accent); }

.teach-shell { margin-bottom: 1.1rem; }
.teach-main {
  display: grid;
  grid-template-columns: minmax(0, 1.55fr) minmax(260px, 0.85fr);
  gap: 1rem;
  align-items: start;
}
.teach-main:has(.teach-side[hidden]) {
  grid-template-columns: 1fr;
}
.teach-card {
  margin-bottom: 0;
  padding: 1.3rem 1.35rem 1.45rem;
  border-radius: 22px;
  border: 1px solid rgba(255,255,255,0.08);
  background:
    linear-gradient(180deg, rgba(255,255,255,0.05), rgba(255,255,255,0.015));
  box-shadow: var(--shadow);
  animation: rise 0.45s ease both;
}
.teach-history {
  margin-top: 1.1rem;
  margin-bottom: 0.5rem;
  background:
    linear-gradient(180deg, rgba(245, 158, 11, 0.07), rgba(255,255,255,0.02) 42%);
}
.teach-side {
  padding: 1.15rem 1.15rem 1.25rem;
  border-radius: 22px;
  border: 1px solid rgba(245, 158, 11, 0.22);
  background:
    linear-gradient(180deg, rgba(245, 158, 11, 0.1), rgba(255,255,255,0.02) 50%);
  box-shadow: var(--shadow);
  animation: rise 0.5s ease both;
}
.teach-card-head {
  display: flex;
  align-items: flex-start;
  gap: 0.85rem;
  margin-bottom: 1.15rem;
}
.teach-card-head.compact { margin-bottom: 0.9rem; }
.teach-card-head h2 {
  margin: 0.1rem 0 0;
  font-family: var(--font-display);
  font-size: 1.2rem;
}
.teach-card-head p {
  margin: 0.28rem 0 0;
  color: var(--muted);
  font-size: 0.88rem;
  line-height: 1.55;
}
.teach-step {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 2.4rem;
  height: 2.4rem;
  padding: 0 0.45rem;
  border-radius: 12px;
  font-family: var(--font-display);
  font-size: 0.85rem;
  font-weight: 700;
  color: #042f2e;
  background: linear-gradient(135deg, #2dd4bf, #14b8a6);
  flex: 0 0 auto;
}
.teach-step.gold {
  color: #422006;
  background: linear-gradient(135deg, #fbbf24, #f59e0b);
}

.teach-form {
  display: grid;
  gap: 1.05rem;
  max-width: none;
}
.teach-field label {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 0.4rem;
  font-weight: 700;
  margin-bottom: 0.45rem;
  font-size: 0.9rem;
}
.teach-field label em {
  font-style: normal;
  font-weight: 500;
  color: var(--muted);
  font-size: 0.78rem;
}
.teach-field textarea,
.teach-field input[type="number"] {
  width: 100%;
  border-radius: 14px;
  border: 1px solid rgba(255,255,255,0.1);
  background: rgba(0,0,0,0.32);
  color: var(--text);
  padding: 0.8rem 0.9rem;
  font-family: inherit;
  font-size: 0.95rem;
  line-height: 1.6;
  transition: border-color 0.2s ease, box-shadow 0.2s ease;
}
.teach-field textarea {
  resize: vertical;
  min-height: 88px;
}
.teach-field textarea:focus,
.teach-field input:focus {
  outline: none;
  border-color: rgba(45, 212, 191, 0.45);
  box-shadow: 0 0 0 3px rgba(45, 212, 191, 0.12);
}
.teach-field-wrong textarea {
  border-color: rgba(251, 113, 133, 0.28);
  background: rgba(251, 113, 133, 0.05);
}
.teach-field-wrong textarea:focus {
  border-color: rgba(251, 113, 133, 0.5);
  box-shadow: 0 0 0 3px rgba(251, 113, 133, 0.12);
}
.teach-field-right textarea {
  border-color: rgba(45, 212, 191, 0.32);
  background: rgba(45, 212, 191, 0.05);
}
.teach-field-right textarea:focus {
  border-color: rgba(45, 212, 191, 0.55);
  box-shadow: 0 0 0 3px rgba(45, 212, 191, 0.14);
}
.teach-tag {
  display: inline-flex;
  align-items: center;
  padding: 0.12rem 0.45rem;
  border-radius: 999px;
  font-size: 0.68rem;
  font-weight: 800;
  letter-spacing: 0.02em;
}
.teach-tag.wrong {
  color: #fecdd3;
  background: rgba(251, 113, 133, 0.18);
  border: 1px solid rgba(251, 113, 133, 0.35);
}
.teach-tag.right {
  color: #99f6e4;
  background: rgba(45, 212, 191, 0.16);
  border: 1px solid rgba(45, 212, 191, 0.35);
}
.teach-compare {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0.85rem;
}
.teach-conv-row {
  display: flex;
  gap: 0.55rem;
  flex-wrap: wrap;
}
.teach-conv-row input {
  flex: 1;
  min-width: 140px;
}
.teach-hint {
  margin: 0.45rem 0 0;
  color: var(--muted);
  font-size: 0.8rem;
  line-height: 1.55;
}
.teach-actions {
  display: flex;
  align-items: center;
  gap: 0.85rem;
  flex-wrap: wrap;
  padding-top: 0.25rem;
}
.teach-btn {
  appearance: none;
  border: none;
  border-radius: 14px;
  padding: 0.78rem 1.25rem;
  font-family: inherit;
  font-weight: 700;
  font-size: 0.95rem;
  cursor: pointer;
  color: #042f2e;
  background: linear-gradient(135deg, #2dd4bf, #14b8a6);
  box-shadow: 0 10px 24px rgba(20, 184, 166, 0.22);
  transition: filter 0.15s ease, transform 0.15s ease;
}
.teach-btn:hover {
  filter: brightness(1.06);
  transform: translateY(-1px);
}
.teach-btn:disabled {
  opacity: 0.55;
  cursor: wait;
  transform: none;
}
.teach-btn.ghost {
  color: var(--text);
  background: rgba(255,255,255,0.06);
  border: 1px solid rgba(255,255,255,0.12);
  box-shadow: none;
}
.teach-btn.ghost:hover {
  border-color: rgba(45, 212, 191, 0.35);
  background: rgba(45, 212, 191, 0.08);
}

.teach-pairs {
  display: grid;
  gap: 0.55rem;
  max-height: 28rem;
  overflow: auto;
  padding-left: 0.15rem;
}
.teach-pair {
  display: grid;
  gap: 0.35rem;
  width: 100%;
  text-align: right;
  border: 1px solid rgba(255,255,255,0.08);
  background: rgba(0,0,0,0.28);
  color: var(--text);
  border-radius: 14px;
  padding: 0.75rem 0.85rem;
  font-family: inherit;
  cursor: pointer;
  transition: border-color 0.15s ease, background 0.15s ease, transform 0.15s ease;
}
.teach-pair:hover {
  border-color: rgba(245, 158, 11, 0.4);
  background: rgba(245, 158, 11, 0.08);
  transform: translateY(-1px);
}
.teach-pair.on {
  border-color: rgba(45, 212, 191, 0.45);
  background: rgba(45, 212, 191, 0.1);
}
.teach-pair-q {
  font-size: 0.86rem;
  font-weight: 700;
  line-height: 1.5;
}
.teach-pair-a {
  font-size: 0.78rem;
  color: var(--muted);
  line-height: 1.55;
}

.teach-lessons {
  display: grid;
  gap: 0.85rem;
}
.teach-empty {
  padding: 1.5rem 1rem;
  text-align: center;
  color: var(--muted);
  border: 1px dashed rgba(255,255,255,0.12);
  border-radius: 16px;
  background: rgba(0,0,0,0.18);
  line-height: 1.7;
}
.teach-lesson {
  border: 1px solid rgba(255,255,255,0.08);
  border-radius: 18px;
  padding: 1rem 1.05rem 1.05rem;
  background: rgba(0,0,0,0.24);
  animation: rise 0.4s ease both;
}
.teach-lesson-head {
  display: flex;
  align-items: center;
  gap: 0.65rem;
  flex-wrap: wrap;
  margin-bottom: 0.85rem;
}
.teach-lesson-id {
  font-family: var(--font-display);
  font-weight: 700;
  color: var(--accent);
  font-size: 0.95rem;
}
.teach-lesson-meta {
  color: var(--muted);
  font-size: 0.75rem;
  flex: 1;
}
.teach-pill {
  margin-inline-start: auto;
  border-radius: 999px;
  padding: 0.2rem 0.65rem;
  font-size: 0.72rem;
  font-weight: 700;
  color: #99f6e4;
  background: rgba(45, 212, 191, 0.14);
  border: 1px solid rgba(45, 212, 191, 0.32);
}
.teach-lesson-q span,
.teach-lesson-wrong span,
.teach-lesson-right span {
  display: block;
  font-size: 0.7rem;
  font-weight: 700;
  color: var(--muted);
  margin-bottom: 0.28rem;
  letter-spacing: 0.02em;
}
.teach-lesson-q p,
.teach-lesson-wrong p,
.teach-lesson-right p {
  margin: 0;
  font-size: 0.9rem;
  line-height: 1.65;
  white-space: pre-wrap;
  word-break: break-word;
}
.teach-lesson-q {
  margin-bottom: 0.75rem;
  padding-bottom: 0.75rem;
  border-bottom: 1px solid rgba(255,255,255,0.06);
}
.teach-lesson-cols {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0.7rem;
}
.teach-lesson-wrong,
.teach-lesson-right {
  border-radius: 12px;
  padding: 0.7rem 0.8rem;
}
.teach-lesson-wrong {
  background: rgba(251, 113, 133, 0.07);
  border: 1px solid rgba(251, 113, 133, 0.22);
}
.teach-lesson-wrong span { color: #fda4af; }
.teach-lesson-right {
  background: rgba(45, 212, 191, 0.07);
  border: 1px solid rgba(45, 212, 191, 0.22);
}
.teach-lesson-right span { color: #5eead4; }
.teach-lesson-note {
  margin: 0.75rem 0 0;
  padding-top: 0.65rem;
  border-top: 1px solid rgba(255,255,255,0.06);
  color: var(--muted);
  font-size: 0.85rem;
  line-height: 1.6;
}

@media (max-width: 900px) {
  .teach-main,
  .teach-main:has(.teach-side[hidden]) {
    grid-template-columns: 1fr;
  }
  .teach-compare,
  .teach-lesson-cols {
    grid-template-columns: 1fr;
  }
  .teach-pill { margin-inline-start: 0; }
}

.teacher-form, .ollama-form { display: grid; gap: 0.85rem; }
.teacher-form input[type="text"],
.teacher-form input[type="password"],
.teacher-form select,
.ollama-form input[type="text"] {
  width: 100%;
}
.check-row {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  color: var(--text);
}
.table-wrap { overflow-x: auto; }
.stat-line { color: var(--muted); font-size: 0.85rem; }

.login-wrap {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 1.5rem;
}
.login-card {
  width: min(420px, 100%);
  background: rgba(18, 28, 47, 0.92);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 1.75rem;
  box-shadow: var(--shadow);
  display: grid;
  gap: 0.75rem;
}
.login-card h1 {
  margin: 0;
  font-family: var(--font-display);
  font-size: 1.6rem;
}
.login-card > p { margin: 0; color: var(--muted); }
.login-card label { font-size: 0.9rem; color: var(--muted); }
.login-card input[type="password"] {
  width: 100%;
  border-radius: 12px;
  border: 1px solid var(--line);
  background: rgba(0, 0, 0, 0.25);
  color: var(--text);
  padding: 0.75rem 0.9rem;
  font: inherit;
}
.login-error {
  color: var(--danger);
  background: rgba(251, 113, 133, 0.12);
  border-radius: 10px;
  padding: 0.6rem 0.75rem;
}

/* —— Report (compact) —— */
.rep-hero {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 1rem;
  margin: 0.4rem 0 1rem;
}
.rep-hero h1 {
  margin: 0.15rem 0;
  font-family: var(--font-display);
  font-size: clamp(1.35rem, 2.4vw, 1.85rem);
}
.rep-hero p { margin: 0; color: var(--muted); font-size: 0.9rem; }
.rep-chips {
  display: flex;
  flex-wrap: wrap;
  gap: 0.45rem;
  margin-bottom: 1rem;
}
.rep-chip {
  display: inline-flex;
  align-items: baseline;
  gap: 0.35rem;
  padding: 0.35rem 0.65rem;
  border-radius: 999px;
  border: 1px solid var(--line);
  background: rgba(255,255,255,0.03);
  font-size: 0.78rem;
  color: var(--muted);
}
.rep-chip strong {
  color: var(--text);
  font-size: 0.92rem;
  font-weight: 700;
}
.rep-chip em {
  font-style: normal;
  opacity: 0.75;
  font-size: 0.72rem;
}
.rep-panel {
  border: 1px solid var(--line);
  border-radius: 16px;
  background: rgba(18, 28, 47, 0.55);
  padding: 0.9rem 1rem 1rem;
  margin-bottom: 0.85rem;
}
.rep-panel-head {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 0.75rem;
  margin-bottom: 0.7rem;
}
.rep-panel-head h2 {
  margin: 0;
  font-size: 0.98rem;
  font-weight: 700;
}
.rep-panel-head p {
  margin: 0;
  color: var(--muted);
  font-size: 0.78rem;
}
.rep-flow {
  display: flex;
  align-items: center;
  gap: 0.35rem;
  overflow-x: auto;
  padding: 0.2rem 0 0.85rem;
}
.rep-node {
  flex: 0 0 auto;
  min-width: 4.4rem;
  text-align: center;
  padding: 0.55rem 0.65rem;
  border-radius: 14px;
  border: 1px solid var(--line);
  background: rgba(0,0,0,0.18);
}
.rep-node b {
  display: block;
  font-size: 1.05rem;
  line-height: 1.1;
}
.rep-node span {
  display: block;
  margin-top: 0.2rem;
  font-size: 0.7rem;
  color: var(--muted);
}
.rep-node.chat b { color: var(--accent); }
.rep-node.review b { color: #93c5fd; }
.rep-node.yes b { color: var(--ok); }
.rep-node.no b { color: var(--danger); }
.rep-node.lesson b { color: var(--accent2); }
.rep-node-line {
  flex: 1 1 1.2rem;
  height: 2px;
  min-width: 0.8rem;
  background: linear-gradient(90deg, rgba(45,212,191,0.15), rgba(245,158,11,0.35), rgba(45,212,191,0.15));
  border-radius: 99px;
}
.rep-legend {
  display: flex;
  flex-wrap: wrap;
  gap: 0.35rem;
  margin: 0.15rem 0 0.55rem;
}
.rep-leg {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  border: 1px solid var(--line);
  background: rgba(255,255,255,0.03);
  color: var(--muted);
  border-radius: 999px;
  padding: 0.28rem 0.6rem;
  font: inherit;
  font-size: 0.72rem;
  cursor: pointer;
  opacity: 0.45;
}
.rep-leg.on { opacity: 1; color: var(--text); }
.rep-leg i {
  width: 0.55rem;
  height: 0.55rem;
  border-radius: 50%;
  display: inline-block;
}
.rep-chart-wrap {
  width: 100%;
  overflow: hidden;
  border-radius: 12px;
  border: 1px solid var(--line);
  background:
    linear-gradient(180deg, rgba(45,212,191,0.05), transparent 40%),
    rgba(0,0,0,0.18);
  margin-bottom: 0.85rem;
}
.rep-chart {
  width: 100%;
  height: auto;
  display: block;
  min-height: 180px;
}
.rep-grid {
  stroke: rgba(255,255,255,0.06);
  stroke-width: 1;
}
.rep-axis {
  fill: var(--muted);
  font-size: 9px;
  font-family: var(--font-body);
}
.rep-rail {
  display: grid;
  gap: 0.45rem;
  position: relative;
  padding-right: 0.85rem;
}
.rep-rail::before {
  content: "";
  position: absolute;
  top: 0.4rem;
  bottom: 0.4rem;
  right: 0.28rem;
  width: 2px;
  background: rgba(45,212,191,0.22);
}
.rep-rail-item {
  display: grid;
  grid-template-columns: 0.7rem 1fr;
  gap: 0.55rem;
  align-items: start;
}
.rep-dot {
  width: 0.55rem;
  height: 0.55rem;
  margin-top: 0.35rem;
  border-radius: 50%;
  background: var(--accent);
  box-shadow: 0 0 0 3px rgba(45,212,191,0.15);
  position: relative;
  z-index: 1;
}
.rep-rail-item.kind-review .rep-dot { background: #93c5fd; box-shadow: 0 0 0 3px rgba(147,197,253,0.18); }
.rep-rail-item.kind-lesson .rep-dot { background: var(--accent2); box-shadow: 0 0 0 3px rgba(245,158,11,0.18); }
.rep-rail-item.kind-chat .rep-dot { background: var(--accent); }
.rep-rail-item strong { font-size: 0.82rem; }
.rep-rail-item p {
  margin: 0.15rem 0 0;
  font-size: 0.78rem;
  color: var(--text);
  opacity: 0.9;
}
.rep-rail-item small {
  color: var(--muted);
  font-size: 0.7rem;
}
.rep-grid-2 {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0.85rem;
}
.rep-list { display: grid; gap: 0.4rem; }
.rep-list.compact { margin-top: 0.55rem; }
.rep-panel-fixed {
  display: flex;
  flex-direction: column;
  min-height: 0;
}
.rep-panel-fixed .rep-list.rep-scroll {
  flex: 1 1 auto;
  height: 240px;
  max-height: 240px;
  overflow-y: auto;
  overflow-x: hidden;
  overscroll-behavior: contain;
  padding-left: 0.25rem;
  scrollbar-width: thin;
  scrollbar-color: rgba(45,212,191,0.4) rgba(255,255,255,0.04);
}
.rep-list.rep-scroll {
  height: 240px;
  max-height: 240px;
  overflow-y: auto;
  overflow-x: hidden;
  overscroll-behavior: contain;
  padding-left: 0.25rem;
  scrollbar-width: thin;
  scrollbar-color: rgba(45,212,191,0.4) rgba(255,255,255,0.04);
}
.rep-list.rep-scroll::-webkit-scrollbar { width: 6px; }
.rep-list.rep-scroll::-webkit-scrollbar-thumb {
  background: rgba(45,212,191,0.4);
  border-radius: 99px;
}
.rep-row {
  display: flex;
  justify-content: space-between;
  gap: 0.6rem;
  align-items: flex-start;
  padding: 0.5rem 0.6rem;
  border-radius: 12px;
  border: 1px solid var(--line);
  background: rgba(0,0,0,0.14);
}
.rep-row strong {
  display: block;
  font-size: 0.8rem;
  font-weight: 600;
}
.rep-row small {
  display: block;
  margin-top: 0.15rem;
  color: var(--muted);
  font-size: 0.7rem;
}
.rep-row em {
  font-style: normal;
  font-size: 0.72rem;
  color: var(--muted);
  white-space: nowrap;
}
.rep-row.ok em { color: var(--ok); }
.rep-row.bad em { color: var(--danger); }
.rep-row.v-yes em { color: var(--ok); }
.rep-row.v-no em { color: var(--danger); }
.rep-mini {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0.4rem;
}
.rep-side {
  padding: 0.45rem 0.55rem;
  border-radius: 10px;
  border: 1px solid var(--line);
  background: rgba(255,255,255,0.02);
}
.rep-side span {
  display: block;
  font-size: 0.7rem;
  color: var(--muted);
}
.rep-side strong {
  font-size: 0.88rem;
}
.rep-table th, .rep-table td {
  font-size: 0.78rem;
  padding: 0.45rem 0.5rem;
}
@media (max-width: 860px) {
  .rep-grid-2 { grid-template-columns: 1fr; }
  .rep-hero { flex-direction: column; align-items: stretch; }
}


