:root {
  --bg: #0d1117;
  --bg-elev: #161b22;
  --bg-card: #1c2230;
  --bg-hover: #222a3a;
  --border: #2a3142;
  --text: #e6edf3;
  --text-dim: #8b949e;
  --text-faint: #6e7681;
  --accent: #58a6ff;
  --accent-soft: rgba(88, 166, 255, 0.12);
  --success: #3fb950;
  --warning: #d29922;
  --danger: #f85149;
  --pink: #f778ba;
  --purple: #bc8cff;
  --font-sans: -apple-system, BlinkMacSystemFont, "Segoe UI", "Inter", system-ui, sans-serif;
  --font-mono: "JetBrains Mono", "Fira Code", "SF Mono", Consolas, monospace;
}

* { box-sizing: border-box; margin: 0; padding: 0; }

html, body {
  font-family: var(--font-sans);
  background: var(--bg);
  color: var(--text);
  font-size: 15px;
  line-height: 1.55;
  -webkit-font-smoothing: antialiased;
}

a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }

button {
  font-family: inherit;
  font-size: inherit;
  cursor: pointer;
  border: none;
  background: none;
  color: inherit;
}

/* ===== Layout ===== */
.app {
  display: grid;
  grid-template-columns: 280px 1fr;
  min-height: 100vh;
}

/* ===== Sidebar ===== */
.sidebar {
  background: var(--bg-elev);
  border-right: 1px solid var(--border);
  padding: 24px 20px;
  position: sticky;
  top: 0;
  height: 100vh;
  overflow-y: auto;
}

.brand {
  font-family: var(--font-mono);
  font-size: 13px;
  color: var(--text-dim);
  letter-spacing: 0.5px;
  margin-bottom: 4px;
}

.brand-title {
  font-size: 18px;
  font-weight: 700;
  color: var(--text);
  margin-bottom: 24px;
}
.brand-title .accent { color: var(--accent); }

.countdown {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 12px 14px;
  margin-bottom: 20px;
}
.countdown-label {
  font-size: 11px;
  text-transform: uppercase;
  color: var(--text-faint);
  letter-spacing: 0.8px;
  margin-bottom: 4px;
}
.countdown-value {
  font-family: var(--font-mono);
  font-size: 22px;
  font-weight: 600;
  color: var(--pink);
}
.countdown-sub {
  font-size: 12px;
  color: var(--text-dim);
  margin-top: 2px;
}

.progress-block { margin-bottom: 24px; }
.progress-label {
  display: flex;
  justify-content: space-between;
  font-size: 12px;
  color: var(--text-dim);
  margin-bottom: 6px;
}
.progress-bar {
  height: 6px;
  background: var(--bg-card);
  border-radius: 3px;
  overflow: hidden;
}
.progress-fill {
  height: 100%;
  background: linear-gradient(90deg, var(--accent), var(--purple));
  transition: width 0.3s ease;
}

.nav-section {
  font-size: 11px;
  text-transform: uppercase;
  color: var(--text-faint);
  letter-spacing: 1px;
  margin: 16px 0 8px;
  font-weight: 600;
}

.nav-list { list-style: none; }
.nav-list li { margin-bottom: 2px; }
.nav-link {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 10px;
  border-radius: 6px;
  color: var(--text-dim);
  font-size: 14px;
  cursor: pointer;
  transition: all 0.15s;
}
.nav-link:hover { background: var(--bg-hover); color: var(--text); }
.nav-link.active { background: var(--accent-soft); color: var(--accent); }
.nav-link .num {
  font-family: var(--font-mono);
  font-size: 12px;
  color: var(--text-faint);
  min-width: 28px;
}
.nav-link.active .num { color: var(--accent); }

.nav-link .check {
  margin-left: auto;
  width: 14px;
  height: 14px;
  border-radius: 50%;
  background: var(--bg-card);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 9px;
}
.nav-link .check.done { background: var(--success); color: white; }
.nav-link .check.partial { background: var(--warning); color: var(--bg); }

/* ===== Main ===== */
.main {
  padding: 32px 48px;
  max-width: 1100px;
  width: 100%;
}

.page-header {
  margin-bottom: 32px;
}

.page-header .breadcrumb {
  font-family: var(--font-mono);
  font-size: 12px;
  color: var(--text-faint);
  margin-bottom: 8px;
  letter-spacing: 0.5px;
}

.page-title {
  font-size: 28px;
  font-weight: 700;
  margin-bottom: 8px;
  line-height: 1.2;
}

.page-subtitle {
  color: var(--text-dim);
  font-size: 15px;
  max-width: 700px;
}

/* ===== Cards ===== */
.card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 20px 24px;
  margin-bottom: 16px;
}

.card-title {
  font-size: 16px;
  font-weight: 600;
  margin-bottom: 12px;
  display: flex;
  align-items: center;
  gap: 10px;
}
.card-title .badge {
  font-family: var(--font-mono);
  font-size: 11px;
  background: var(--accent-soft);
  color: var(--accent);
  padding: 2px 8px;
  border-radius: 4px;
  font-weight: 500;
}

.section-title {
  font-size: 12px;
  text-transform: uppercase;
  color: var(--text-faint);
  letter-spacing: 1.2px;
  margin: 32px 0 12px;
  font-weight: 600;
}

/* ===== Dashboard ===== */
.week-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 14px;
}
.week-card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 18px;
  cursor: pointer;
  transition: all 0.15s;
  position: relative;
  overflow: hidden;
}
.week-card:hover {
  border-color: var(--accent);
  transform: translateY(-1px);
}
.week-card.current {
  border-color: var(--pink);
  box-shadow: 0 0 0 1px rgba(247, 120, 186, 0.3);
}
.week-card.current::before {
  content: "ATUAL";
  position: absolute;
  top: 8px;
  right: 8px;
  font-family: var(--font-mono);
  font-size: 10px;
  background: var(--pink);
  color: white;
  padding: 2px 6px;
  border-radius: 3px;
  font-weight: 600;
}
.week-card-num {
  font-family: var(--font-mono);
  font-size: 11px;
  color: var(--text-faint);
  letter-spacing: 1px;
}
.week-card-title {
  font-size: 16px;
  font-weight: 600;
  margin: 4px 0 8px;
}
.week-card-meta {
  font-size: 12px;
  color: var(--text-dim);
  display: flex;
  gap: 12px;
  margin-top: 12px;
  padding-top: 12px;
  border-top: 1px solid var(--border);
}
.week-card-meta span { display: flex; align-items: center; gap: 4px; }
.dot {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: var(--text-faint);
}
.dot.done { background: var(--success); }
.dot.partial { background: var(--warning); }

/* ===== Lesson Detail ===== */
.lesson-meta {
  display: flex;
  gap: 16px;
  flex-wrap: wrap;
  margin-bottom: 24px;
  padding: 16px 20px;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: 8px;
}
.lesson-meta-item {
  display: flex;
  flex-direction: column;
  gap: 2px;
}
.lesson-meta-label {
  font-size: 10px;
  text-transform: uppercase;
  color: var(--text-faint);
  letter-spacing: 1px;
}
.lesson-meta-value {
  font-family: var(--font-mono);
  font-size: 14px;
  color: var(--text);
}

.plan-step {
  display: grid;
  grid-template-columns: 90px 140px 1fr;
  gap: 16px;
  padding: 14px 0;
  border-bottom: 1px solid var(--border);
  align-items: flex-start;
}
.plan-step:last-child { border-bottom: none; }
.plan-step-time {
  font-family: var(--font-mono);
  font-size: 13px;
  color: var(--accent);
  font-weight: 600;
}
.plan-step-phase {
  font-size: 13px;
  font-weight: 600;
  color: var(--purple);
}
.plan-step-desc {
  font-size: 14px;
  color: var(--text-dim);
}

ul.phrase-list, ul.prompt-list, ul.mistake-list {
  list-style: none;
}
ul.phrase-list li, ul.prompt-list li, ul.mistake-list li {
  padding: 8px 12px;
  margin-bottom: 6px;
  border-radius: 6px;
  font-size: 14px;
  line-height: 1.5;
}
ul.phrase-list li {
  background: var(--bg);
  border-left: 3px solid var(--accent);
  font-family: var(--font-mono);
  font-size: 13px;
}
ul.prompt-list li {
  background: var(--bg);
  border-left: 3px solid var(--purple);
  font-style: italic;
}
ul.mistake-list li {
  background: var(--bg);
  border-left: 3px solid var(--warning);
  font-size: 13px;
}

/* ===== Off-class section ===== */
.offclass-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 16px;
  margin-top: 16px;
}
.vocab-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
  gap: 8px;
}
.vocab-item {
  background: var(--bg);
  padding: 10px 12px;
  border-radius: 6px;
  font-size: 13px;
  border: 1px solid var(--border);
  cursor: pointer;
  transition: all 0.15s;
}
.vocab-item:hover { border-color: var(--accent); }
.vocab-en {
  font-family: var(--font-mono);
  color: var(--accent);
  font-weight: 500;
}
.vocab-pt {
  color: var(--text-dim);
  font-size: 12px;
  margin-top: 2px;
}
.vocab-item.flipped .vocab-pt { font-size: 14px; color: var(--text); }
.vocab-item.flipped .vocab-en { font-size: 11px; color: var(--text-faint); }

.grammar-box {
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 16px;
}
.grammar-box .topic {
  font-weight: 600;
  color: var(--purple);
  margin-bottom: 6px;
}
.grammar-box .why {
  font-size: 13px;
  color: var(--text-dim);
  margin-bottom: 10px;
}
.grammar-box .examples {
  list-style: none;
}
.grammar-box .examples li {
  padding: 6px 10px;
  background: var(--bg-card);
  border-left: 2px solid var(--purple);
  margin-bottom: 4px;
  font-family: var(--font-mono);
  font-size: 12px;
  border-radius: 0 4px 4px 0;
}

/* ===== Checkbox tasks ===== */
.task-list { list-style: none; }
.task-item {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  padding: 10px 0;
  border-bottom: 1px solid var(--border);
  cursor: pointer;
}
.task-item:last-child { border-bottom: none; }
.task-checkbox {
  width: 18px;
  height: 18px;
  border-radius: 4px;
  border: 1.5px solid var(--text-faint);
  flex-shrink: 0;
  margin-top: 1px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 12px;
  transition: all 0.15s;
}
.task-item.done .task-checkbox {
  background: var(--success);
  border-color: var(--success);
  color: white;
}
.task-item.done .task-text {
  color: var(--text-faint);
  text-decoration: line-through;
}
.task-text {
  font-size: 14px;
  line-height: 1.5;
}

/* ===== Action buttons ===== */
.btn-row { display: flex; gap: 10px; margin-top: 16px; }
.btn {
  padding: 8px 14px;
  border-radius: 6px;
  font-size: 13px;
  font-weight: 500;
  background: var(--bg-card);
  border: 1px solid var(--border);
  color: var(--text);
  transition: all 0.15s;
}
.btn:hover { background: var(--bg-hover); border-color: var(--accent); }
.btn.primary {
  background: var(--accent);
  border-color: var(--accent);
  color: white;
}
.btn.primary:hover { background: #4d8edd; }
.btn-back {
  font-size: 13px;
  color: var(--text-dim);
  margin-bottom: 16px;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  cursor: pointer;
}
.btn-back:hover { color: var(--accent); }

/* ===== Resources ===== */
.resource-list { list-style: none; }
.resource-item {
  padding: 12px 0;
  border-bottom: 1px solid var(--border);
}
.resource-item:last-child { border-bottom: none; }
.resource-name { font-weight: 600; }
.resource-note { font-size: 13px; color: var(--text-dim); margin-top: 2px; }

/* ===== Print ===== */
@media print {
  .sidebar { display: none; }
  .app { grid-template-columns: 1fr; }
  .main { padding: 20px; }
  body { background: white; color: black; }
  .card, .grammar-box, .vocab-item { background: white !important; border-color: #ccc !important; }
}

/* ===== Responsive ===== */
@media (max-width: 900px) {
  .app { grid-template-columns: 1fr; }
  .sidebar { position: relative; height: auto; }
  .main { padding: 24px 20px; }
  .week-grid { grid-template-columns: 1fr; }
  .offclass-grid { grid-template-columns: 1fr; }
  .plan-step { grid-template-columns: 1fr; gap: 4px; }
}

/* ===== Loading ===== */
.loading {
  display: flex;
  align-items: center;
  justify-content: center;
  height: 100vh;
  color: var(--text-faint);
  font-family: var(--font-mono);
  font-size: 14px;
}

/* ===== Login screen ===== */
.login-screen {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 100vh;
  padding: 24px;
  background: radial-gradient(ellipse at top, rgba(88, 166, 255, 0.08) 0%, var(--bg) 50%);
}
.login-card {
  background: var(--bg-elev);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 36px 32px;
  width: 100%;
  max-width: 380px;
  box-shadow: 0 8px 32px rgba(0,0,0,0.4);
}
.login-brand {
  margin-bottom: 28px;
}
.login-card h1 {
  font-size: 22px;
  margin-bottom: 4px;
}
.login-sub {
  color: var(--text-dim);
  font-size: 13px;
  margin-bottom: 24px;
}
.login-card form label {
  display: block;
  margin-bottom: 14px;
}
.login-card form label span {
  display: block;
  font-size: 12px;
  color: var(--text-dim);
  margin-bottom: 6px;
  text-transform: uppercase;
  letter-spacing: 0.5px;
}
.login-card input {
  width: 100%;
  padding: 10px 12px;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 6px;
  color: var(--text);
  font-size: 14px;
  font-family: inherit;
  transition: border-color 0.15s;
}
.login-card input:focus {
  outline: none;
  border-color: var(--accent);
}
.login-error {
  background: rgba(248, 81, 73, 0.1);
  border: 1px solid rgba(248, 81, 73, 0.3);
  color: var(--danger);
  padding: 10px 12px;
  border-radius: 6px;
  font-size: 13px;
  margin-bottom: 12px;
}

/* ===== User pill ===== */
.user-pill {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 12px;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: 8px;
  margin-bottom: 16px;
}
.user-avatar {
  width: 36px;
  height: 36px;
  border-radius: 50%;
  background: var(--accent);
  color: white;
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 600;
  font-size: 14px;
  flex-shrink: 0;
}
.user-avatar.tutor { background: var(--purple); }
.user-avatar.student { background: var(--accent); }
.user-info { flex: 1; min-width: 0; }
.user-name {
  font-size: 13px;
  font-weight: 600;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.user-role {
  font-size: 11px;
  color: var(--text-faint);
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

.logout-btn {
  margin-top: 20px;
  width: 100%;
  font-size: 12px;
  color: var(--text-dim);
}
.logout-btn:hover { color: var(--danger); border-color: var(--danger); }

/* ===== Comments ===== */
.comment {
  padding: 14px;
  border-radius: 8px;
  background: var(--bg);
  border: 1px solid var(--border);
  margin-bottom: 10px;
}
.comment.tutor {
  border-left: 3px solid var(--purple);
}
.comment.student {
  border-left: 3px solid var(--accent);
}
.comment-head {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  margin-bottom: 8px;
}
.comment-avatar {
  width: 28px;
  height: 28px;
  border-radius: 50%;
  background: var(--accent);
  color: white;
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 600;
  font-size: 12px;
  flex-shrink: 0;
}
.comment-avatar.tutor { background: var(--purple); }
.comment-author {
  font-size: 13px;
  font-weight: 600;
}
.comment-role {
  font-size: 10px;
  font-weight: 500;
  background: var(--bg-card);
  color: var(--text-faint);
  padding: 1px 6px;
  border-radius: 3px;
  margin-left: 6px;
  text-transform: uppercase;
  letter-spacing: 0.5px;
}
.comment.tutor .comment-role { background: rgba(188, 140, 255, 0.15); color: var(--purple); }
.comment.student .comment-role { background: rgba(88, 166, 255, 0.15); color: var(--accent); }
.comment-time {
  font-size: 11px;
  color: var(--text-faint);
  margin-top: 2px;
}
.comment-actions {
  margin-left: auto;
  display: flex;
  gap: 8px;
}
.link-btn {
  font-size: 11px;
  color: var(--text-faint);
  text-decoration: underline;
  cursor: pointer;
  padding: 2px 4px;
}
.link-btn:hover { color: var(--text); }
.link-btn.danger:hover { color: var(--danger); }
.comment-body {
  font-size: 14px;
  line-height: 1.55;
  white-space: pre-wrap;
  word-break: break-word;
}

.comment-composer {
  margin-top: 16px;
  padding-top: 16px;
  border-top: 1px solid var(--border);
}
.comment-composer textarea {
  width: 100%;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 6px;
  color: var(--text);
  padding: 10px 12px;
  font-family: inherit;
  font-size: 14px;
  line-height: 1.5;
  resize: vertical;
  min-height: 80px;
}
.comment-composer textarea:focus {
  outline: none;
  border-color: var(--accent);
}

/* ===== Readonly states ===== */
.task-checkbox.readonly {
  cursor: not-allowed;
  opacity: 0.6;
}
.task-item.readonly { cursor: default; }
.lesson-row { cursor: pointer; }

/* ===== Scrollbar ===== */
::-webkit-scrollbar { width: 8px; height: 8px; }
::-webkit-scrollbar-track { background: var(--bg); }
::-webkit-scrollbar-thumb { background: var(--border); border-radius: 4px; }
::-webkit-scrollbar-thumb:hover { background: var(--text-faint); }
