:root {
  --bg: #0b0e14; --bg2: #0d1017; --panel: #141925; --panel-2: #1a2130; --line: #232b3d;
  --text: #e8ecf4; --muted: #8b93a7; --accent: #6d8dff; --accent-2: #8b5cf6;
  --ok: #34d399; --warn: #fbbf24; --bad: #f87171; --radius: 14px;
}
* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; }
body { font-family: "Segoe UI", system-ui, -apple-system, sans-serif; background: var(--bg); color: var(--text); font-size: 15px; }
.hidden { display: none !important; }
.muted { color: var(--muted); }
.sm { font-size: 12.5px; }

.brand-badge {
  border-radius: 12px; display: inline-flex; align-items: center; justify-content: center;
  font-weight: 700; color: #fff; background: linear-gradient(135deg, var(--accent), var(--accent-2));
}
.brand-badge.lg { width: 56px; height: 56px; font-size: 26px; }
.brand-badge.sm { width: 30px; height: 30px; font-size: 14px; }

.btn { border: 0; border-radius: 10px; padding: 10px 16px; font-size: 14px; cursor: pointer; color: #fff; background: var(--panel-2); transition: filter .15s, transform .05s; }
.btn:hover { filter: brightness(1.15); }
.btn:active { transform: translateY(1px); }
.btn.primary { background: linear-gradient(135deg, var(--accent), var(--accent-2)); }
.btn.ghost { background: transparent; border: 1px solid var(--line); color: var(--muted); }
.btn.danger { background: rgba(248,113,113,.14); color: var(--bad); border: 1px solid rgba(248,113,113,.3); }
.btn.sm { padding: 6px 12px; font-size: 12.5px; }
.btn.wide { width: 100%; }
.btn:disabled { opacity: .55; cursor: not-allowed; }
.linklike { background: none; border: 0; color: var(--accent); cursor: pointer; font-size: 13px; margin-top: 10px; }

.field { margin-bottom: 14px; }
.field label { display: block; font-size: 12.5px; color: var(--muted); margin-bottom: 6px; }
input, select, textarea { width: 100%; background: var(--panel-2); color: var(--text); border: 1px solid var(--line); border-radius: 10px; padding: 10px 12px; font-size: 14px; outline: none; font-family: inherit; transition: border-color .15s; }
input:focus, select:focus, textarea:focus { border-color: var(--accent); }
.form-error { background: rgba(248,113,113,.12); color: var(--bad); border: 1px solid rgba(248,113,113,.35); padding: 9px 12px; border-radius: 10px; font-size: 13px; margin-bottom: 14px; }
.form-ok { background: rgba(52,211,153,.1); color: var(--ok); border: 1px solid rgba(52,211,153,.3); padding: 9px 12px; border-radius: 10px; font-size: 13px; margin-bottom: 14px; }

/* ---------------- auth ---------------- */
.auth-wrap { display: grid; grid-template-columns: 1.1fr 1fr; min-height: 100vh; }
.auth-hero { padding: 9vh 7vw; display: flex; flex-direction: column; justify-content: center; gap: 18px; }
.auth-hero h1 { font-size: clamp(34px, 4.6vw, 56px); line-height: 1.08; margin: 8px 0; letter-spacing: -.02em; }
.grad { background: linear-gradient(135deg, var(--accent), var(--accent-2)); -webkit-background-clip: text; background-clip: text; color: transparent; }
.hero-points { display: flex; flex-direction: column; gap: 10px; color: var(--muted); }
.auth-panel { display: flex; flex-direction: column; justify-content: center; padding: 40px; background: var(--bg2); border-left: 1px solid var(--line); }
.auth-card { max-width: 400px; width: 100%; margin: 0 auto; background: var(--panel); border: 1px solid var(--line); border-radius: 18px; padding: 26px; }
.tabs { display: flex; gap: 6px; margin-bottom: 20px; }
.tab { flex: 1; background: transparent; border: 1px solid var(--line); color: var(--muted); padding: 9px; border-radius: 10px; cursor: pointer; }
.tab.active { background: var(--panel-2); color: #fff; border-color: var(--accent); }
.foot-note { text-align: center; margin-top: 16px; font-size: 12px; }

/* ---------------- app shell ---------------- */
.app-shell { display: flex; height: 100vh; }
.appnav { width: 210px; background: var(--panel); border-right: 1px solid var(--line); display: flex; flex-direction: column; padding: 18px 12px; gap: 8px; }
.side-brand { display: flex; gap: 10px; align-items: center; font-weight: 600; margin-bottom: 18px; padding-left: 6px; }
#app-tabs { display: flex; flex-direction: column; gap: 4px; flex: 1; }
#app-tabs a { padding: 11px 13px; border-radius: 10px; color: var(--muted); cursor: pointer; font-size: 14px; transition: background .15s, color .15s; }
#app-tabs a:hover { color: var(--text); background: var(--panel-2); }
#app-tabs a.active { color: #fff; background: linear-gradient(135deg, rgba(109,141,255,.18), rgba(139,92,246,.14)); }
.appnav-foot { border-top: 1px solid var(--line); padding-top: 12px; display: flex; flex-direction: column; gap: 8px; }
.net-badge { font-size: 12px; padding: 5px 10px; border-radius: 999px; text-align: center; }
.net-badge.online { color: var(--ok); background: rgba(52,211,153,.1); }
.net-badge.offline { color: var(--warn); background: rgba(251,191,36,.12); }

.appmain { flex: 1; overflow-y: auto; padding: 30px 34px; }
.tabpane { display: none; max-width: 980px; }
.tabpane.active { display: block; }
.tabpane h1 { font-size: 24px; margin: 0 0 18px; }
.pane-head { display: flex; justify-content: space-between; align-items: center; margin-bottom: 18px; }
.pane-head h1 { margin: 0; }

.grid2 { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }
.card { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); padding: 18px; margin-bottom: 16px; }
.card h3 { margin: 0 0 12px; font-size: 15.5px; }

.plan-chip { display: inline-block; background: linear-gradient(135deg, rgba(109,141,255,.16), rgba(139,92,246,.12)); border: 1px solid var(--line); padding: 6px 14px; border-radius: 999px; margin-bottom: 18px; font-size: 13px; }

.list { display: flex; flex-direction: column; gap: 10px; }
.list-item { background: var(--panel); border: 1px solid var(--line); border-radius: 12px; padding: 14px 16px; display: flex; justify-content: space-between; align-items: center; gap: 12px; cursor: pointer; transition: border-color .15s; }
.list-item:hover { border-color: var(--accent); }
.list-item .t { font-weight: 600; }
.list-item .m { color: var(--muted); font-size: 12.5px; margin-top: 3px; }
.pill { display: inline-block; padding: 3px 10px; border-radius: 999px; font-size: 11.5px; font-weight: 600; }
.pill.ok { background: rgba(52,211,153,.12); color: var(--ok); }
.pill.warn { background: rgba(251,191,36,.12); color: var(--warn); }
.pill.mut { background: rgba(139,147,167,.12); color: var(--muted); }

.editor { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); padding: 18px; margin-top: 16px; }
.ed-title { font-size: 20px; font-weight: 700; margin-bottom: 10px; }
.editor textarea { resize: vertical; line-height: 1.55; }
.editor-actions { display: flex; gap: 10px; margin-top: 12px; align-items: center; flex-wrap: wrap; }
.editor-actions select { width: auto; }

.ai-out { margin-top: 14px; background: var(--bg); border: 1px solid var(--line); border-radius: 12px; padding: 16px; white-space: pre-wrap; line-height: 1.6; min-height: 60px; max-height: 420px; overflow-y: auto; }

.lesson { border-top: 1px solid var(--line); padding: 14px 2px; }
.lesson h4 { margin: 0 0 8px; }
.quiz-q { margin-bottom: 14px; }
.quiz-q .q { font-weight: 600; margin-bottom: 8px; }
.quiz-q label { display: block; padding: 8px 12px; border: 1px solid var(--line); border-radius: 10px; margin-bottom: 6px; cursor: pointer; }
.quiz-q label:hover { border-color: var(--accent); }

.row2 { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; }

.toast { position: fixed; bottom: 24px; left: 50%; transform: translateX(-50%); background: var(--panel-2); color: var(--text); border: 1px solid var(--line); padding: 11px 18px; border-radius: 12px; font-size: 13.5px; box-shadow: 0 12px 40px rgba(0,0,0,.5); z-index: 50; }

@media (max-width: 880px) {
  .auth-wrap { grid-template-columns: 1fr; }
  .auth-hero { padding: 40px 24px 8px; }
  .auth-panel { border-left: 0; padding: 16px; }
  .app-shell { flex-direction: column; }
  .appnav { width: 100%; flex-direction: row; align-items: center; padding: 8px 12px; }
  #app-tabs { flex-direction: row; overflow-x: auto; }
  #app-tabs a span { display: none; }
  .appnav-foot { border: 0; flex-direction: row; align-items: center; }
  .brand-text, #user-email { display: none; }
  .grid2, .row2 { grid-template-columns: 1fr; }
  .appmain { padding: 18px; }
}
