:root {
  --bg: #f5f5f4;
  --surface: #ffffff;
  --border: #e7e5e4;
  --text: #1c1917;
  --text-muted: #78716c;
  --accent: #0f766e;
  --accent-hover: #0d5c56;
  --danger: #b91c1c;
  --danger-hover: #991b1b;
  --radius: 8px;
  --shadow: 0 1px 3px rgba(0,0,0,.08);
  --font: 'IBM Plex Sans', system-ui, sans-serif;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  font-family: var(--font);
  font-size: 14px;
  color: var(--text);
  background: var(--bg);
  line-height: 1.4;
}

.header {
  display: flex;
  align-items: center;
  gap: 1rem;
  padding: 0.75rem 1.5rem;
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  flex-wrap: wrap;
}

.logo {
  margin: 0;
  font-size: 1.25rem;
  font-weight: 600;
  letter-spacing: -0.02em;
  color: var(--text);
  text-decoration: none;
}

.logo:hover {
  color: var(--accent);
}

.nav-main {
  display: flex;
  gap: 0.25rem;
  align-items: center;
}

.nav-link {
  padding: 0.4rem 0.75rem;
  border: none;
  background: transparent;
  color: var(--text-muted);
  font: inherit;
  font-weight: 500;
  cursor: pointer;
  border-radius: var(--radius);
}

.nav-link:hover {
  color: var(--text);
  background: var(--bg);
}

.nav-link.active {
  color: var(--accent);
  background: var(--surface);
}

.nav-calendar {
  display: flex;
  gap: 0.25rem;
}

.nav-calendar[aria-hidden="true"] {
  visibility: hidden;
  pointer-events: none;
  position: absolute;
}

.nav-views,
.nav-calendar .btn-view {
  display: inline-flex;
  gap: 0.25rem;
}

.btn-view {
  padding: 0.4rem 0.75rem;
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--text);
  font: inherit;
  cursor: pointer;
  border-radius: var(--radius);
}

.btn-view:hover {
  background: var(--bg);
}

.btn-view.active {
  background: var(--text);
  color: var(--surface);
  border-color: var(--text);
}

.header-search {
  position: relative;
}

.header-search input {
  width: 180px;
  padding: 0.4rem 0.6rem 0.4rem 1.75rem;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  font: inherit;
  font-size: 0.9rem;
}

.header-search input:focus {
  outline: none;
  border-color: var(--accent);
}

.header-search .search-shortcut {
  position: absolute;
  left: 0.5rem;
  top: 50%;
  transform: translateY(-50%);
  font-size: 0.75rem;
  color: var(--text-muted);
  pointer-events: none;
}

.header-actions {
  margin-left: auto;
  display: flex;
  gap: 0.5rem;
  align-items: center;
}

.btn {
  padding: 0.5rem 1rem;
  border: none;
  font: inherit;
  font-weight: 500;
  cursor: pointer;
  border-radius: var(--radius);
}

.btn-primary {
  background: var(--accent);
  color: #fff;
}

.btn-primary:hover {
  background: var(--accent-hover);
}

.btn-secondary {
  background: var(--surface);
  color: var(--text);
  border: 1px solid var(--border);
}

.btn-secondary:hover {
  background: var(--bg);
}

.btn-text {
  background: transparent;
  color: var(--text-muted);
}

.btn-text:hover {
  color: var(--text);
}

.btn-icon {
  width: 2rem;
  height: 2rem;
  padding: 0;
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--text);
  font: inherit;
  cursor: pointer;
  border-radius: var(--radius);
}

.btn-icon:hover {
  background: var(--bg);
}

.layout-with-sidebar {
  display: flex;
  max-width: 1600px;
  margin: 0 auto;
  min-height: calc(100vh - 56px);
}

.sidebar {
  width: 280px;
  min-width: 280px;
  background: var(--surface);
  border-right: 1px solid var(--border);
  padding: 1rem;
  overflow-y: auto;
}

.sidebar.collapsed {
  width: 0;
  min-width: 0;
  padding: 0;
  overflow: hidden;
  border-right: none;
}

.sidebar-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 0.75rem;
}

.sidebar-header h3 {
  margin: 0;
  font-size: 0.95rem;
  font-weight: 600;
}

.btn-sidebar-toggle {
  font-size: 1.25rem;
  line-height: 1;
}

.filter-subjects {
  margin-bottom: 0.75rem;
}

.filter-label {
  display: block;
  font-size: 0.75rem;
  font-weight: 500;
  color: var(--text-muted);
  margin-bottom: 0.35rem;
}

.filter-chips {
  display: flex;
  flex-wrap: wrap;
  gap: 0.35rem;
}

.filter-chip {
  padding: 0.25rem 0.5rem;
  border-radius: 4px;
  font-size: 0.75rem;
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--text);
  cursor: pointer;
}

.filter-chip:hover {
  background: var(--bg);
}

.filter-chip.active {
  border-color: var(--accent);
  background: var(--accent);
  color: #fff;
}

.filter-chip.inactive {
  opacity: 0.5;
}

.sidebar-summary {
  font-size: 0.8rem;
  color: var(--text-muted);
  padding: 0.5rem 0;
  margin-bottom: 0.5rem;
  border-bottom: 1px solid var(--border);
}

.upcoming-list {
  list-style: none;
  padding: 0;
  margin: 0;
}

.upcoming-list li {
  padding: 0.5rem 0;
  border-bottom: 1px solid var(--border);
  font-size: 0.85rem;
}

.upcoming-list li:last-child {
  border-bottom: none;
}

.upcoming-list .upcoming-date {
  font-weight: 600;
  font-size: 0.75rem;
  color: var(--text-muted);
  margin-bottom: 0.25rem;
}

.upcoming-list .upcoming-item {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.35rem 0;
  cursor: pointer;
  border-radius: 4px;
  padding-left: 0.5rem;
  margin-left: -0.5rem;
}

.upcoming-list .upcoming-item:hover {
  background: var(--bg);
}

.upcoming-list .upcoming-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  flex-shrink: 0;
}

.upcoming-list .upcoming-item-text {
  flex: 1;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.upcoming-list .upcoming-empty {
  color: var(--text-muted);
  font-size: 0.85rem;
}

.search-no-results {
  color: var(--text-muted);
  font-style: italic;
}

.main {
  flex: 1;
  padding: 1rem 1.5rem;
  min-width: 0;
}

/* Loading */
.app-loading {
  position: fixed;
  inset: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 1rem;
  background: var(--bg);
  z-index: 1000;
  transition: opacity 0.2s ease, visibility 0.2s ease;
}

.app-loading.hidden {
  opacity: 0;
  visibility: hidden;
  pointer-events: none;
}

.spinner {
  width: 40px;
  height: 40px;
  border: 3px solid var(--border);
  border-top-color: var(--accent);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
}

@keyframes spin {
  to { transform: rotate(360deg); }
}

/* Pages */
.page {
  animation: pageIn 0.2s ease;
}

@keyframes pageIn {
  from { opacity: 0.95; }
  to { opacity: 1; }
}

.page.hidden {
  display: none;
}

.page-title {
  margin: 0 0 1rem;
  font-size: 1.25rem;
  font-weight: 600;
}

/* Dashboard */
.dashboard-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
  gap: 1rem;
}

.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1.25rem;
  box-shadow: var(--shadow);
}

.card h3 {
  margin: 0 0 0.75rem;
  font-size: 0.9rem;
  font-weight: 600;
  color: var(--text-muted);
}

.card-welcome {
  grid-column: 1 / -1;
  padding: 1.5rem;
}

.card-welcome .welcome-title {
  margin: 0 0 0.25rem;
  font-size: 1.5rem;
  font-weight: 600;
}

.card-welcome .welcome-sub {
  margin: 0;
  font-size: 0.9rem;
  color: var(--text-muted);
}

.dashboard-summary {
  font-size: 0.9rem;
}

.dashboard-summary .summary-line {
  display: flex;
  justify-content: space-between;
  padding: 0.35rem 0;
  border-bottom: 1px solid var(--border);
}

.dashboard-summary .summary-line:last-child {
  border-bottom: none;
}

.dashboard-exams-list {
  max-height: 280px;
  overflow-y: auto;
}

.dashboard-exam-item {
  display: flex;
  align-items: flex-start;
  gap: 0.75rem;
  padding: 0.75rem 0;
  border-bottom: 1px solid var(--border);
  cursor: pointer;
}

.dashboard-exam-item:hover {
  background: var(--bg);
}

.dashboard-exam-item:last-child {
  border-bottom: none;
}

.dashboard-exam-countdown {
  flex-shrink: 0;
  min-width: 3.5rem;
  font-weight: 600;
  font-size: 0.85rem;
  color: var(--accent);
}

.dashboard-exam-countdown.past {
  color: var(--text-muted);
}

.dashboard-exam-info .exam-title {
  font-weight: 500;
  margin: 0 0 0.15rem;
}

.dashboard-exam-info .exam-meta {
  font-size: 0.8rem;
  color: var(--text-muted);
}

.quick-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
}

/* Exams page */
.exams-toolbar {
  margin-bottom: 1rem;
}

.exams-filters {
  display: flex;
  gap: 0.5rem;
}

.exams-filters .btn.active {
  background: var(--accent);
  color: #fff;
  border-color: var(--accent);
}

.exams-list {
  list-style: none;
  padding: 0;
  margin: 0;
}

.exams-list li {
  display: flex;
  align-items: center;
  gap: 1rem;
  padding: 1rem;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  margin-bottom: 0.5rem;
  cursor: pointer;
  transition: border-color 0.15s ease;
}

.exams-list li:hover {
  border-color: var(--accent);
}

.exam-item-dot {
  width: 12px;
  height: 12px;
  border-radius: 50%;
  flex-shrink: 0;
}

.exam-item-main {
  flex: 1;
  min-width: 0;
}

.exam-item-title {
  font-weight: 600;
  margin: 0 0 0.2rem;
}

.exam-item-meta {
  font-size: 0.85rem;
  color: var(--text-muted);
}

.exam-item-countdown {
  flex-shrink: 0;
  font-weight: 600;
  font-size: 0.9rem;
  color: var(--accent);
}

.exam-item-countdown.past {
  color: var(--text-muted);
}

/* Empty state */
.empty-state {
  text-align: center;
  padding: 2rem 1rem;
  color: var(--text-muted);
}

.empty-state p {
  margin: 0 0 1rem;
}

.empty-state.hidden {
  display: none;
}

.btn-sm {
  padding: 0.35rem 0.6rem;
  font-size: 0.85rem;
}

.btn-danger-outline {
  background: transparent;
  border: 1px solid var(--danger);
  color: var(--danger);
  margin-right: auto;
}

.btn-danger-outline:hover {
  background: var(--danger);
  color: #fff;
}

/* Dashboard countdown & goal progress */
.card-countdown {
  text-align: center;
  padding: 1.5rem;
}

.card-countdown .countdown-big {
  font-size: 2rem;
  font-weight: 700;
  color: var(--accent);
  margin: 0 0 0.25rem;
}

.card-countdown .countdown-label {
  font-size: 0.9rem;
  color: var(--text-muted);
}

.card-goal-progress h3 {
  margin-bottom: 0.5rem;
}

.goal-progress-bar {
  height: 8px;
  background: var(--border);
  border-radius: 4px;
  overflow: hidden;
  margin: 0.5rem 0;
}

.goal-progress-fill {
  height: 100%;
  background: var(--accent);
  border-radius: 4px;
  transition: width 0.3s ease;
}

.goal-progress-text {
  font-size: 0.85rem;
  color: var(--text-muted);
}

.dashboard-goals-list {
  max-height: 160px;
  overflow-y: auto;
}

.dashboard-goal-item {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.4rem 0;
  border-bottom: 1px solid var(--border);
  cursor: pointer;
}

.dashboard-goal-item:hover {
  background: var(--bg);
}

.dashboard-goal-item input[type="checkbox"] {
  margin: 0;
}

.dashboard-goal-item.completed span {
  text-decoration: line-through;
  color: var(--text-muted);
}

/* Kanban (Trello-like) */
.kanban-toolbar {
  margin-bottom: 1rem;
  display: flex;
  gap: 0.5rem;
  align-items: center;
}

.kanban-board {
  display: flex;
  gap: 1rem;
  overflow-x: auto;
  padding-bottom: 1rem;
  min-height: 400px;
  align-items: flex-start;
}

.kanban-column {
  flex: 0 0 280px;
  background: var(--border);
  border-radius: var(--radius);
  padding: 0.75rem;
  max-height: calc(100vh - 220px);
  display: flex;
  flex-direction: column;
}

.kanban-column-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 0.5rem;
  padding: 0.35rem 0;
  font-weight: 600;
  font-size: 0.9rem;
}

.kanban-column-header .column-name {
  flex: 1;
  min-width: 0;
}

.kanban-column-cards {
  flex: 1;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
  min-height: 60px;
}

.kanban-column-cards.drag-over {
  background: var(--accent);
  opacity: 0.3;
  border-radius: 4px;
}

.kanban-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 0.6rem 0.75rem;
  cursor: grab;
  box-shadow: var(--shadow);
  transition: box-shadow 0.15s ease;
}

.kanban-card:hover {
  box-shadow: 0 2px 8px rgba(0,0,0,.12);
}

.kanban-card.dragging {
  opacity: 0.8;
  cursor: grabbing;
  transform: rotate(2deg);
}

.kanban-card-title {
  font-weight: 500;
  font-size: 0.9rem;
  margin-bottom: 0.25rem;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.kanban-card-meta {
  font-size: 0.75rem;
  color: var(--text-muted);
  display: flex;
  align-items: center;
  gap: 0.5rem;
  flex-wrap: wrap;
}

.kanban-add-card {
  margin-top: 0.5rem;
  padding: 0.5rem;
  text-align: center;
  color: var(--text-muted);
  background: transparent;
  border: 1px dashed var(--border);
  border-radius: var(--radius);
  cursor: pointer;
  font: inherit;
  font-size: 0.9rem;
}

.kanban-add-card:hover {
  background: var(--surface);
  color: var(--accent);
}

.kanban-add-list {
  flex: 0 0 200px;
  min-height: 120px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--border);
  border: 2px dashed var(--text-muted);
  border-radius: var(--radius);
  color: var(--text-muted);
  cursor: pointer;
  font: inherit;
  font-size: 0.95rem;
}

.kanban-add-list:hover {
  border-color: var(--accent);
  color: var(--accent);
}

/* Notes page */
.notes-toolbar {
  margin-bottom: 1rem;
  display: flex;
  gap: 0.5rem;
  align-items: center;
}

.notes-filter {
  padding: 0.5rem 0.75rem;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  font: inherit;
}

.notes-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(260px, 1fr));
  gap: 1rem;
}

.note-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1rem;
  cursor: pointer;
  min-height: 120px;
  display: flex;
  flex-direction: column;
  transition: border-color 0.15s ease, box-shadow 0.15s ease;
}

.note-card:hover {
  border-color: var(--accent);
  box-shadow: var(--shadow);
}

.note-card-title {
  font-weight: 600;
  margin-bottom: 0.35rem;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.note-card-preview {
  font-size: 0.85rem;
  color: var(--text-muted);
  flex: 1;
  overflow: hidden;
  display: -webkit-box;
  -webkit-line-clamp: 3;
  -webkit-box-orient: vertical;
}

.note-card-date {
  font-size: 0.75rem;
  color: var(--text-muted);
  margin-top: 0.5rem;
}

/* Goals page */
.goals-toolbar {
  margin-bottom: 1rem;
}

.goals-list {
  list-style: none;
  padding: 0;
  margin: 0;
}

.goals-list .goal-item {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  padding: 1rem;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  margin-bottom: 0.5rem;
  cursor: pointer;
  transition: border-color 0.15s ease;
}

.goals-list .goal-item:hover {
  border-color: var(--accent);
}

.goals-list .goal-item.completed {
  opacity: 0.7;
}

.goals-list .goal-item.completed .goal-item-title {
  text-decoration: line-through;
  color: var(--text-muted);
}

.goal-item-check {
  flex-shrink: 0;
}

.goal-item-content {
  flex: 1;
  min-width: 0;
}

.goal-item-title {
  font-weight: 600;
  margin-bottom: 0.2rem;
}

.goal-item-meta {
  font-size: 0.85rem;
  color: var(--text-muted);
}

/* Shortcuts modal */
.shortcuts-list {
  list-style: none;
  padding: 0;
  margin: 0;
}

.shortcuts-list li {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  padding: 0.5rem 0;
  border-bottom: 1px solid var(--border);
}

.shortcuts-list kbd {
  display: inline-block;
  padding: 0.2rem 0.5rem;
  background: var(--border);
  border-radius: 4px;
  font-size: 0.85rem;
  min-width: 2rem;
  text-align: center;
}

/* Racha + Concentración */
.card-streak {
  text-align: center;
  padding: 1rem;
}

.card-streak .streak-number {
  font-size: 2rem;
  font-weight: 700;
  color: var(--accent);
  margin: 0;
}

.card-streak .streak-label {
  font-size: 0.85rem;
  color: var(--text-muted);
}

.card-focus-actions h3 {
  margin-bottom: 0.5rem;
}

.card-focus-actions .btn {
  margin-right: 0.5rem;
  margin-bottom: 0.5rem;
}

/* Focus overlay + Pomodoro */
.focus-overlay {
  position: fixed;
  inset: 0;
  background: var(--bg);
  z-index: 2000;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 2rem;
}

.focus-overlay.hidden {
  display: none;
}

.focus-content {
  max-width: 420px;
  width: 100%;
  position: relative;
}

.focus-close {
  position: absolute;
  top: -0.5rem;
  right: -0.5rem;
  width: 2.5rem;
  height: 2.5rem;
  border: none;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 50%;
  font-size: 1.25rem;
  cursor: pointer;
  color: var(--text-muted);
}

.focus-close:hover {
  color: var(--text);
  background: var(--bg);
}

.focus-task {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1rem;
  margin-bottom: 1.5rem;
  font-weight: 500;
  min-height: 3rem;
}

.pomodoro-box {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1.5rem;
  text-align: center;
}

.pomodoro-mode {
  font-size: 0.9rem;
  color: var(--text-muted);
  margin-bottom: 0.5rem;
}

.pomodoro-time {
  font-size: 3rem;
  font-weight: 700;
  color: var(--accent);
  margin: 0.5rem 0;
  font-variant-numeric: tabular-nums;
}

.pomodoro-controls {
  display: flex;
  gap: 0.5rem;
  justify-content: center;
  flex-wrap: wrap;
  margin: 1rem 0;
}

.pomodoro-hint {
  font-size: 0.8rem;
  color: var(--text-muted);
  margin: 0.5rem 0 0;
}

/* Checklist en modal tarea */
.checklist-list {
  margin-bottom: 0.5rem;
  max-height: 120px;
  overflow-y: auto;
}

.checklist-item {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.35rem 0;
  font-size: 0.9rem;
}

.checklist-item input[type="checkbox"] {
  margin: 0;
}

.checklist-item.done span {
  text-decoration: line-through;
  color: var(--text-muted);
}

.checklist-item .checklist-remove {
  margin-left: auto;
  padding: 0.2rem 0.4rem;
  font-size: 0.75rem;
  background: transparent;
  border: none;
  color: var(--text-muted);
  cursor: pointer;
}

.checklist-item .checklist-remove:hover {
  color: var(--danger);
}

.checklist-add {
  display: flex;
  gap: 0.35rem;
  margin-top: 0.35rem;
}

.checklist-add input {
  flex: 1;
  padding: 0.4rem 0.5rem;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  font: inherit;
}

/* Tareas vencidas */
.kanban-card.overdue,
.exams-list li.overdue {
  border-left: 3px solid var(--danger);
}

/* Etiquetas en settings */
#tags-list .subject-color {
  width: 1rem;
  height: 1rem;
  border-radius: 4px;
}

/* Stats page */
.stats-period {
  margin-bottom: 1rem;
  display: flex;
  gap: 0.5rem;
}

.stats-period-btn.active {
  background: var(--accent);
  color: #fff;
  border-color: var(--accent);
}

.stats-cards {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(320px, 1fr));
  gap: 1rem;
}

.stats-chart {
  min-height: 200px;
}

.stats-bar-row {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  margin-bottom: 0.75rem;
}

.stats-bar-label {
  min-width: 120px;
  font-size: 0.9rem;
}

.stats-bar-track {
  flex: 1;
  height: 24px;
  background: var(--border);
  border-radius: 4px;
  overflow: hidden;
}

.stats-bar-fill {
  height: 100%;
  border-radius: 4px;
  min-width: 4px;
  transition: width 0.3s ease;
}

.stats-bar-value {
  min-width: 3rem;
  text-align: right;
  font-weight: 500;
  font-size: 0.9rem;
}

.stats-summary .summary-row {
  display: flex;
  justify-content: space-between;
  padding: 0.5rem 0;
  border-bottom: 1px solid var(--border);
}

.stats-summary .summary-row:last-child {
  border-bottom: none;
}

/* Settings page */
.card-settings label {
  display: block;
  margin-bottom: 1rem;
}

.card-settings label input,
.card-settings label select {
  display: block;
  width: 100%;
  max-width: 320px;
  margin-top: 0.25rem;
  padding: 0.5rem 0.6rem;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  font: inherit;
}

/* Print */
@media print {
  .header, .sidebar, .app-loading, .toast, .btn, .nav-main, .nav-calendar, .header-actions, .header-search,
  .calendar-toolbar .btn, #btn-sidebar-open, #btn-today {
    display: none !important;
  }
  .layout-with-sidebar { display: block; }
  .main { padding: 0; }
  .calendar-wrap { box-shadow: none; border: 1px solid #ccc; }
  .page-dashboard, .page-exams, .page-stats, .page-settings, .page-tasks, .page-notes, .page-goals, .focus-overlay { display: none !important; }
  .page-calendar { display: block !important; }
  body { background: #fff; }
}

.calendar-toolbar {
  display: flex;
  align-items: center;
  gap: 1rem;
  margin-bottom: 1rem;
}

.calendar-title {
  margin: 0;
  font-size: 1.125rem;
  font-weight: 600;
  min-width: 12rem;
  text-align: center;
}

.calendar-wrap {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  overflow: hidden;
}

.calendar-extra {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(340px, 1fr));
  gap: 1rem;
  margin-top: 1.5rem;
}

.timetable-hint {
  font-size: 0.85rem;
  color: var(--text-muted);
  margin: 0 0 0.75rem;
}

.weekly-timetable {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}

.weekly-day {
  display: flex;
  align-items: flex-start;
  gap: 0.75rem;
  padding: 0.5rem;
  background: var(--bg);
  border-radius: var(--radius);
}

.weekly-day-name {
  font-weight: 600;
  min-width: 4.5rem;
  font-size: 0.9rem;
}

.weekly-day-classes {
  flex: 1;
  display: flex;
  flex-wrap: wrap;
  gap: 0.35rem;
}

.weekly-class-chip {
  padding: 0.25rem 0.5rem;
  border-radius: 4px;
  font-size: 0.8rem;
  border-left: 3px solid currentColor;
}

.recurring-classes-list {
  margin-bottom: 0.75rem;
  max-height: 280px;
  overflow-y: auto;
}

.rc-item {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.5rem 0;
  border-bottom: 1px solid var(--border);
  font-size: 0.9rem;
}

.rc-item:last-child {
  border-bottom: none;
}

.rc-item-type {
  padding: 0.15rem 0.4rem;
  border-radius: 4px;
  font-size: 0.75rem;
  font-weight: 500;
}

.rc-item-type.theory { background: #eff6ff; color: #1d4ed8; }
.rc-item-type.seminar { background: #fef3c7; color: #b45309; }
.rc-item-type.practice { background: #ecfdf5; color: #059669; }

.rc-weeks {
  display: flex;
  flex-wrap: wrap;
  gap: 0.35rem;
  margin: 0.5rem 0 1rem;
}

.rc-week {
  display: inline-flex;
  align-items: center;
  gap: 0.25rem;
}

.rc-week input {
  margin: 0;
}

.view {
  min-height: 420px;
}

.view.hidden,
.hidden {
  display: none !important;
}

/* Day view */
.view-day {
  display: grid;
  grid-template-columns: 4rem 1fr;
  grid-template-rows: auto 1fr;
}

.view-day .day-header {
  grid-column: 2;
  padding: 0.75rem 1rem;
  border-bottom: 1px solid var(--border);
  font-weight: 600;
}

.view-day .day-hours {
  grid-column: 1;
  padding: 0.5rem;
  border-right: 1px solid var(--border);
  font-size: 0.75rem;
  color: var(--text-muted);
}

.view-day .day-hours span {
  display: block;
  height: 3rem;
  line-height: 3rem;
}

.view-day .day-slots {
  position: relative;
  min-height: 24 * 3rem;
}

.view-day .day-slot {
  height: 3rem;
  border-bottom: 1px solid var(--border);
}

.view-day .day-events {
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  pointer-events: none;
}

.view-day .day-events .event-card {
  position: absolute;
  left: 4px;
  right: 4px;
  padding: 0.35rem 0.5rem;
  border-radius: 4px;
  font-size: 0.8rem;
  pointer-events: auto;
  cursor: pointer;
  border-left: 3px solid currentColor;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

/* Week view */
.view-week {
  display: grid;
  grid-template-columns: 4rem repeat(7, 1fr);
  grid-template-rows: auto 1fr;
}

.view-week .week-day-header {
  padding: 0.5rem;
  text-align: center;
  border-bottom: 1px solid var(--border);
  font-size: 0.75rem;
  font-weight: 500;
}

.view-week .week-day-header .day-num {
  display: block;
  font-size: 1rem;
  font-weight: 600;
}

.view-week .week-day-header.today {
  background: var(--bg);
}

.view-week .week-hours {
  padding: 0.25rem;
  border-right: 1px solid var(--border);
  font-size: 0.7rem;
  color: var(--text-muted);
  grid-column: 1;
  grid-row: 2;
}

.view-week .week-day-column {
  border-right: 1px solid var(--border);
  position: relative;
  min-height: 24 * 2rem;
}

.view-week .week-day-column:last-child {
  border-right: none;
}

.view-week .week-slot {
  height: 2rem;
  border-bottom: 1px solid var(--border);
}

.view-week .week-events {
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  pointer-events: none;
}

.view-week .week-events .event-card {
  position: absolute;
  margin: 1px 2px;
  padding: 0.25rem 0.4rem;
  border-radius: 4px;
  font-size: 0.7rem;
  pointer-events: auto;
  cursor: pointer;
  border-left: 3px solid currentColor;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

/* Month view */
.view-month {
  padding: 0.5rem;
}

.month-days-header {
  display: grid;
  grid-template-columns: repeat(7, 1fr);
  gap: 1px;
  margin-bottom: 2px;
}

.month-days-header span {
  padding: 0.5rem;
  text-align: center;
  font-size: 0.7rem;
  font-weight: 600;
  text-transform: uppercase;
  color: var(--text-muted);
}

.month-grid {
  display: grid;
  grid-template-columns: repeat(7, 1fr);
  gap: 1px;
}

.month-cell {
  min-height: 100px;
  padding: 0.35rem;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 4px;
}

.month-cell.other-month {
  background: var(--bg);
  color: var(--text-muted);
}

.month-cell.today {
  border-color: var(--accent);
  background: #f0fdfa;
}

.month-cell .cell-date {
  font-size: 0.8rem;
  font-weight: 600;
  margin-bottom: 0.35rem;
}

.month-cell .cell-events {
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.month-cell .event-chip {
  padding: 0.2rem 0.35rem;
  border-radius: 4px;
  font-size: 0.7rem;
  cursor: pointer;
  border-left: 3px solid currentColor;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

/* Modals */
.modal {
  border: none;
  padding: 0;
  border-radius: var(--radius);
  box-shadow: 0 4px 20px rgba(0,0,0,.15);
  max-width: 90vw;
  width: 420px;
}

.modal::backdrop {
  background: rgba(0,0,0,.4);
}

.modal-content {
  padding: 1.5rem;
}

.modal-content h3 {
  margin: 0 0 1rem;
  font-size: 1.125rem;
  font-weight: 600;
}

.modal label {
  display: block;
  margin-bottom: 0.75rem;
  font-size: 0.85rem;
  font-weight: 500;
  color: var(--text);
}

.modal label input,
.modal label select,
.modal label textarea {
  display: block;
  width: 100%;
  margin-top: 0.25rem;
  padding: 0.5rem 0.6rem;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  font: inherit;
}

.modal label input:focus,
.modal label select:focus,
.modal label textarea:focus {
  outline: none;
  border-color: var(--accent);
}

.form-actions {
  display: flex;
  gap: 0.5rem;
  margin-top: 1.25rem;
  justify-content: flex-end;
}

.form-inline {
  display: flex;
  gap: 0.5rem;
  flex-wrap: wrap;
  align-items: center;
  margin-top: 1rem;
}

.form-inline input[type="text"] {
  padding: 0.5rem 0.6rem;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  font: inherit;
  min-width: 120px;
}

.form-inline input[type="color"] {
  width: 2.5rem;
  height: 2rem;
  padding: 2px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  cursor: pointer;
}

.subjects-list {
  list-style: none;
  padding: 0;
  margin: 0;
}

.subjects-list li {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.5rem 0;
  border-bottom: 1px solid var(--border);
}

.subjects-list li:last-child {
  border-bottom: none;
}

.subjects-list .subject-color {
  width: 1rem;
  height: 1rem;
  border-radius: 4px;
  flex-shrink: 0;
}

.subjects-list .subject-name {
  flex: 1;
}

.subjects-list .btn-delete {
  padding: 0.25rem 0.5rem;
  font-size: 0.75rem;
  background: transparent;
  border: 1px solid var(--border);
  color: var(--text-muted);
  cursor: pointer;
  border-radius: 4px;
}

.subjects-list .btn-delete:hover {
  color: var(--danger);
  border-color: var(--danger);
}

.event-detail-actions {
  display: flex;
  gap: 0.5rem;
  margin-top: 1rem;
}

.event-detail-actions .btn-danger {
  background: var(--danger);
  color: #fff;
  border: none;
  padding: 0.5rem 1rem;
  border-radius: var(--radius);
  font: inherit;
  cursor: pointer;
}

.event-detail-actions .btn-danger:hover {
  background: var(--danger-hover);
}

.event-type-badge {
  display: inline-block;
  padding: 0.2rem 0.5rem;
  border-radius: 4px;
  font-size: 0.75rem;
  font-weight: 500;
  margin-bottom: 0.5rem;
}

.event-type-badge.exam { background: #fef2f2; color: #b91c1c; }
.event-type-badge.deadline { background: #fef9c3; color: #a16207; }
.event-type-badge.study { background: #ecfdf5; color: #059669; }
.event-type-badge.class { background: #eff6ff; color: #1d4ed8; }
.event-type-badge.other { background: var(--border); color: var(--text-muted); }

.priority-badge {
  display: inline-block;
  padding: 0.15rem 0.4rem;
  border-radius: 4px;
  font-size: 0.7rem;
  font-weight: 500;
  margin-left: 0.5rem;
}
.priority-badge.high { background: #fef2f2; color: #b91c1c; }
.priority-badge.medium { background: var(--border); color: var(--text-muted); }
.priority-badge.low { background: #f5f5f4; color: #78716c; }

/* Toast */
.toast {
  position: fixed;
  bottom: 1.5rem;
  left: 50%;
  transform: translateX(-50%) translateY(100px);
  padding: 0.6rem 1.25rem;
  background: var(--text);
  color: var(--surface);
  border-radius: var(--radius);
  font-size: 0.9rem;
  font-weight: 500;
  z-index: 1000;
  opacity: 0;
  transition: transform 0.25s ease, opacity 0.25s ease;
  pointer-events: none;
}

.toast.show {
  transform: translateX(-50%) translateY(0);
  opacity: 1;
}

/* Search results modal */
.modal-wide {
  width: 480px;
  max-width: 95vw;
}

.search-results-list {
  list-style: none;
  padding: 0;
  margin: 0;
  max-height: 60vh;
  overflow-y: auto;
}

.search-results-list li {
  padding: 0.6rem 0;
  border-bottom: 1px solid var(--border);
  cursor: pointer;
}

.search-results-list li:hover {
  background: var(--bg);
}

.search-results-list .search-item-type {
  font-size: 0.7rem;
  color: var(--text-muted);
  text-transform: uppercase;
}

.search-results-list .search-item-title {
  font-weight: 500;
}

.search-results-list .search-item-meta {
  font-size: 0.8rem;
  color: var(--text-muted);
}

/* Dark theme */
body.dark {
  --bg: #1c1917;
  --surface: #292524;
  --border: #44403c;
  --text: #fafaf9;
  --text-muted: #a8a29e;
  --accent: #2dd4bf;
  --accent-hover: #5eead4;
}

body.dark .month-cell.today {
  border-color: var(--accent);
  background: rgba(45, 212, 191, 0.15);
}

body.dark .view-week .week-day-header.today {
  background: var(--border);
}

body.dark .filter-chip.active {
  background: var(--accent);
  color: var(--bg);
  border-color: var(--accent);
}

body.dark .toast {
  background: var(--accent);
  color: var(--bg);
}
