:root {
  --bg: #f5f7fb;
  --surface: #ffffff;
  --text: #12151c;
  --muted: #606776;
  --accent: #3b82f6;
  --accent-2: #7c3aed;
  --border: #e6e8ef;
  --success: #16a34a;
  --warning: #d97706;
  --danger: #dc2626;
  --card-radius: 14px;
  --shadow: 0 10px 30px rgba(12, 18, 34, 0.08);
  --mono: "SFMono-Regular", "Cascadia Code", Consolas, monospace;
  --transition: 180ms ease;
}

body.theme-dark {
  --bg: #0c0f17;
  --surface: #111625;
  --text: #e9edf7;
  --muted: #9ca3b4;
  --accent: #60a5fa;
  --accent-2: #c084fc;
  --border: #1c2337;
  --shadow: 0 12px 32px rgba(0, 0, 0, 0.35);
}

*,
*::before,
*::after {
  box-sizing: border-box;
}

body {
  margin: 0;
  font-family: "Inter", "Segoe UI", system-ui, -apple-system, sans-serif;
  background: var(--bg);
  color: var(--text);
  transition: background var(--transition), color var(--transition);
}

h1,
h2,
h3 {
  margin: 0;
  font-weight: 700;
}

p {
  margin: 0;
}

.app-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 18px 24px;
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  position: sticky;
  top: 0;
  z-index: 10;
  box-shadow: var(--shadow);
}

.title-group {
  display: flex;
  align-items: center;
  gap: 12px;
}

.logo-dot {
  width: 40px;
  height: 40px;
  border-radius: 12px;
  background: linear-gradient(135deg, var(--accent), var(--accent-2));
  box-shadow: inset 0 2px 8px rgba(255, 255, 255, 0.12);
}

.subtitle {
  color: var(--muted);
  font-size: 0.95rem;
}

.header-actions {
  display: flex;
  gap: 10px;
}

.ghost-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  background: transparent;
  border: 1px solid var(--border);
  color: var(--text);
  padding: 10px 14px;
  border-radius: 10px;
  cursor: pointer;
  transition: all var(--transition);
  font-weight: 600;
  text-decoration: none;
}

.ghost-btn:hover {
  border-color: var(--accent);
  color: var(--accent);
}

#app {
  padding: 18px 24px 80px;
  max-width: 1200px;
  margin: 0 auto;
}

.view.hidden {
  display: none;
}

.toolbar {
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
  align-items: center;
  margin-bottom: 16px;
}

.search-input {
  flex: 1;
  min-width: 260px;
  padding: 12px 14px;
  border-radius: 12px;
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--text);
  outline: none;
  box-shadow: var(--shadow);
}

.filters {
  display: flex;
  gap: 10px;
}

select {
  padding: 10px 12px;
  border-radius: 10px;
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--text);
  outline: none;
}

.dashboard {
  display: grid;
  grid-template-columns: 2fr 1fr;
  gap: 16px;
}

.panel {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--card-radius);
  padding: 16px;
  box-shadow: var(--shadow);
}

.panel-header {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  margin-bottom: 10px;
}

.hint {
  color: var(--muted);
  font-size: 0.9rem;
}

.topics-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(210px, 1fr));
  gap: 12px;
}

.topic-card {
  background: linear-gradient(145deg, var(--surface), rgba(255, 255, 255, 0.82));
  border: 1px solid var(--border);
  border-radius: var(--card-radius);
  padding: 14px;
  cursor: pointer;
  transition: transform var(--transition), border-color var(--transition), box-shadow var(--transition);
}

.topic-card:hover {
  transform: translateY(-3px);
  border-color: var(--accent);
  box-shadow: 0 16px 40px rgba(30, 64, 175, 0.16);
}

.topic-meta {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin: 8px 0;
  color: var(--muted);
}

.badge {
  padding: 4px 8px;
  border-radius: 999px;
  font-size: 0.8rem;
  font-weight: 600;
  color: #fff;
}

.badge.level-beginner { background: #22c55e; }
.badge.level-intermediate { background: #f59e0b; }
.badge.level-advanced { background: #8b5cf6; }
.badge.status-not_started { background: #334155; }
.badge.status-in_progress { background: #0ea5e9; }
.badge.status-done { background: #16a34a; }
.badge.status-need_review { background: #d97706; }

.progress-bar {
  height: 8px;
  background: var(--border);
  border-radius: 999px;
  overflow: hidden;
}

.progress-fill {
  height: 100%;
  width: 0%;
  background: linear-gradient(90deg, var(--accent), var(--accent-2));
  transition: width 240ms ease;
}

.recent-list,
.notes-list {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.recent-item,
.note-item {
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 10px 12px;
  background: var(--surface);
  cursor: pointer;
  transition: border-color var(--transition), transform var(--transition);
}

.recent-item:hover,
.note-item:hover {
  border-color: var(--accent);
  transform: translateY(-2px);
}

.note-title-row {
  display: flex;
  justify-content: space-between;
  gap: 10px;
}

.note-summary {
  color: var(--muted);
  margin-top: 4px;
  line-height: 1.4;
}

.tags {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-top: 6px;
}

.tag {
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 3px 8px;
  font-size: 0.8rem;
  color: var(--muted);
}

.content-split {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 16px;
  margin-top: 16px;
}

.note-detail {
  min-height: 280px;
}

.note-detail.empty-state {
  display: grid;
  place-items: center;
  color: var(--muted);
  height: 100%;
}

.note-actions {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  margin: 12px 0;
}

.primary-btn {
  background: var(--accent);
  color: #fff;
  border: none;
  padding: 10px 12px;
  border-radius: 10px;
  cursor: pointer;
  font-weight: 700;
  box-shadow: var(--shadow);
  transition: filter var(--transition);
}

.primary-btn:hover {
  filter: brightness(1.05);
}

.checklist {
  margin-top: 12px;
  padding-left: 16px;
}

.checklist li {
  margin: 6px 0;
}

.app-footer {
  margin-top: 24px;
  padding: 16px 24px;
  border-top: 1px solid var(--border);
  display: flex;
  justify-content: space-between;
  align-items: center;
  color: var(--muted);
}

.footer-meta {
  font-size: 0.9rem;
}

.hidden {
  display: none;
}

.form-grid {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.form-grid label {
  display: flex;
  flex-direction: column;
  gap: 6px;
  font-weight: 600;
  color: var(--text);
}

.form-grid input,
.form-grid textarea,
.form-grid select {
  padding: 10px 12px;
  border-radius: 10px;
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--text);
  outline: none;
}

.form-grid textarea {
  resize: vertical;
  min-height: 80px;
}

.input-row {
  display: flex;
  gap: 8px;
  align-items: center;
}

.input-row select {
  flex: 1;
}

@media (max-width: 960px) {
  .dashboard {
    grid-template-columns: 1fr;
  }

  .content-split {
    grid-template-columns: 1fr;
  }
}

@media (max-width: 640px) {
  .app-header {
    flex-direction: column;
    align-items: flex-start;
    gap: 12px;
  }

  .header-actions {
    width: 100%;
  }

  .ghost-btn {
    flex: 1;
  }

  #app {
    padding: 14px 16px 64px;
  }
}
