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

:root {
  --bg: #1a1a2e;
  --bg-card: #16213e;
  --bg-card-hover: #1a2744;
  --accent: #003580;
  --accent-light: #0052cc;
  --text: #e0e0e0;
  --text-dim: #8899aa;
  --text-bright: #ffffff;
  --green: #28a745;
  --green-dim: #1e7e34;
  --border: #2a3a5e;
  --radius: 8px;
}

html {
  font-size: 16px;
  scroll-behavior: smooth;
}

body {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  background: var(--bg);
  color: var(--text);
  min-height: 100vh;
  -webkit-font-smoothing: antialiased;
}

#app {
  max-width: 720px;
  margin: 0 auto;
}

/* Header */
header {
  position: sticky;
  top: 0;
  z-index: 100;
  background: var(--accent);
  padding: 14px 16px;
  display: flex;
  align-items: center;
  gap: 12px;
  box-shadow: 0 2px 8px rgba(0,0,0,0.3);
}

header h1 {
  font-size: 1.1rem;
  font-weight: 600;
  color: var(--text-bright);
  flex: 1;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

#back-btn {
  background: none;
  border: none;
  color: var(--text-bright);
  font-size: 1.4rem;
  cursor: pointer;
  padding: 4px 8px;
  border-radius: 4px;
  line-height: 1;
}

#back-btn:hover {
  background: rgba(255,255,255,0.15);
}

#progress-badge {
  background: rgba(255,255,255,0.15);
  padding: 4px 10px;
  border-radius: 12px;
  font-size: 0.8rem;
  color: var(--text-bright);
  white-space: nowrap;
}

/* Curriculum view */
#curriculum-view {
  padding: 12px;
}

.phase {
  margin-bottom: 16px;
}

.phase-header {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 14px 16px;
  cursor: pointer;
  display: flex;
  align-items: center;
  gap: 12px;
  user-select: none;
  transition: background 0.15s;
}

.phase-header:hover {
  background: var(--bg-card-hover);
}

.phase-arrow {
  font-size: 0.8rem;
  color: var(--text-dim);
  transition: transform 0.2s;
  flex-shrink: 0;
}

.phase.open .phase-arrow {
  transform: rotate(90deg);
}

.phase-title {
  flex: 1;
  font-weight: 600;
  font-size: 0.95rem;
}

.phase-level {
  font-size: 0.75rem;
  color: var(--text-dim);
  margin-top: 2px;
}

.phase-progress {
  font-size: 0.8rem;
  color: var(--text-dim);
  white-space: nowrap;
}

.phase-progress.complete {
  color: var(--green);
}

.phase-lessons {
  display: none;
  padding: 4px 0 0 0;
}

.phase.open .phase-lessons {
  display: block;
}

/* Lesson row */
.lesson-row {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 16px;
  margin: 2px 0;
  border-radius: var(--radius);
  cursor: pointer;
  transition: background 0.15s;
}

.lesson-row:hover {
  background: var(--bg-card-hover);
}

.lesson-checkbox {
  width: 22px;
  height: 22px;
  flex-shrink: 0;
  cursor: pointer;
  accent-color: var(--green);
}

.lesson-number {
  color: var(--text-dim);
  font-size: 0.8rem;
  width: 32px;
  flex-shrink: 0;
  text-align: right;
}

.lesson-title {
  flex: 1;
  font-size: 0.9rem;
  line-height: 1.3;
}

.lesson-row.completed .lesson-title {
  color: var(--text-dim);
  text-decoration: line-through;
  text-decoration-color: var(--text-dim);
}

.lesson-type {
  font-size: 0.7rem;
  padding: 2px 8px;
  border-radius: 10px;
  background: var(--border);
  color: var(--text-dim);
  flex-shrink: 0;
}

.lesson-type.grammar { background: #1e3a5f; color: #6db3f2; }
.lesson-type.vocabulary { background: #1e4d3a; color: #6dd4a0; }
.lesson-type.situation { background: #4d3a1e; color: #d4a06d; }
.lesson-type.review { background: #3a1e4d; color: #a06dd4; }

/* Lesson view */
#lesson-view {
  padding: 16px;
  padding-bottom: 80px;
}

#lesson-content {
  line-height: 1.7;
  font-size: 0.95rem;
}

#lesson-content h1 {
  font-size: 1.4rem;
  color: var(--text-bright);
  margin-bottom: 20px;
  padding-bottom: 12px;
  border-bottom: 2px solid var(--accent);
}

#lesson-content h2 {
  font-size: 1.15rem;
  color: var(--accent-light);
  margin-top: 28px;
  margin-bottom: 12px;
}

#lesson-content h3 {
  font-size: 1rem;
  color: var(--text-bright);
  margin-top: 20px;
  margin-bottom: 8px;
}

#lesson-content p {
  margin-bottom: 10px;
}

#lesson-content strong {
  color: var(--text-bright);
}

#lesson-content em {
  color: #a8c8e8;
  font-style: italic;
}

#lesson-content ul, #lesson-content ol {
  margin: 8px 0 12px 24px;
}

#lesson-content li {
  margin-bottom: 4px;
}

#lesson-content table {
  width: 100%;
  border-collapse: collapse;
  margin: 12px 0;
  font-size: 0.88rem;
  overflow-x: auto;
  display: block;
}

#lesson-content thead {
  display: table-header-group;
}

#lesson-content tbody {
  display: table-row-group;
}

#lesson-content tr {
  display: table-row;
  border-bottom: 1px solid var(--border);
}

#lesson-content table {
  display: table;
}

#lesson-content th {
  background: var(--accent);
  color: var(--text-bright);
  padding: 8px 10px;
  text-align: left;
  font-weight: 600;
  font-size: 0.82rem;
}

#lesson-content td {
  padding: 7px 10px;
  border-bottom: 1px solid var(--border);
}

#lesson-content tr:nth-child(even) td {
  background: rgba(255,255,255,0.02);
}

#lesson-content code {
  background: var(--bg-card);
  padding: 2px 6px;
  border-radius: 4px;
  font-size: 0.88em;
  color: #a8c8e8;
}

#lesson-content pre {
  background: var(--bg-card);
  padding: 14px;
  border-radius: var(--radius);
  overflow-x: auto;
  margin: 12px 0;
  border: 1px solid var(--border);
}

#lesson-content pre code {
  background: none;
  padding: 0;
}

#lesson-content blockquote {
  border-left: 3px solid var(--accent);
  padding: 8px 16px;
  margin: 12px 0;
  background: rgba(0,53,128,0.1);
  border-radius: 0 var(--radius) var(--radius) 0;
}

#lesson-content hr {
  border: none;
  border-top: 1px solid var(--border);
  margin: 24px 0;
}

/* Completion button at bottom of lesson */
.lesson-complete-btn {
  display: block;
  width: 100%;
  padding: 14px;
  margin-top: 32px;
  border: 2px solid var(--green);
  border-radius: var(--radius);
  background: transparent;
  color: var(--green);
  font-size: 1rem;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.2s;
}

.lesson-complete-btn:hover {
  background: var(--green);
  color: var(--text-bright);
}

.lesson-complete-btn.completed {
  background: var(--green-dim);
  border-color: var(--green-dim);
  color: var(--text-bright);
}

/* Navigation buttons */
.lesson-nav {
  display: flex;
  gap: 12px;
  margin-top: 16px;
}

.lesson-nav button {
  flex: 1;
  padding: 10px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--bg-card);
  color: var(--text);
  font-size: 0.9rem;
  cursor: pointer;
  transition: background 0.15s;
}

.lesson-nav button:hover {
  background: var(--bg-card-hover);
}

.lesson-nav button:disabled {
  opacity: 0.3;
  cursor: not-allowed;
}

/* Utility */
.hidden {
  display: none !important;
}

/* Scrollbar */
::-webkit-scrollbar {
  width: 6px;
}
::-webkit-scrollbar-track {
  background: var(--bg);
}
::-webkit-scrollbar-thumb {
  background: var(--border);
  border-radius: 3px;
}

/* Responsive table wrapper */
.table-wrapper {
  overflow-x: auto;
  margin: 12px 0;
  -webkit-overflow-scrolling: touch;
}

@media (max-width: 480px) {
  header h1 {
    font-size: 0.95rem;
  }
  #lesson-content h1 {
    font-size: 1.2rem;
  }
  #lesson-content {
    font-size: 0.9rem;
  }
  #lesson-content th, #lesson-content td {
    padding: 5px 6px;
    font-size: 0.8rem;
  }
}
