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

:root {
  --bg: #0f1117;
  --surface: #1a1d27;
  --surface-hover: #222632;
  --border: #2a2e3a;
  --text: #e4e6ed;
  --text-dim: #8b8fa3;
  --accent: #6c8cff;
  --accent-dim: #4a65cc;
  --green: #4ade80;
  --red: #f87171;
  --orange: #fbbf24;
  --radius: 12px;
}

body {
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  background: var(--bg);
  color: var(--text);
  min-height: 100vh;
}

.container {
  max-width: 600px;
  margin: 0 auto;
  padding: 16px;
}

header {
  margin-bottom: 16px;
}

.header-top {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 8px;
}

.header-top h1 {
  font-size: 1.5rem;
  font-weight: 700;
}

.icon-btn {
  background: none;
  border: none;
  color: var(--text-dim);
  font-size: 1.2rem;
  cursor: pointer;
  padding: 8px;
  border-radius: 8px;
  transition: background 0.2s;
}

.icon-btn:hover {
  background: var(--surface);
  color: var(--text);
}

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

.sync-status {
  font-size: 0.8rem;
  padding: 4px 0;
  display: flex;
  align-items: center;
  gap: 6px;
}

.sync-status.syncing { color: var(--accent); }
.sync-status.ok { color: var(--green); }
.sync-status.error { color: var(--red); }

.sync-icon {
  display: inline-block;
}

.sync-icon.spinning {
  animation: spin 1s linear infinite;
}

@keyframes spin {
  from { transform: rotate(0deg); }
  to { transform: rotate(360deg); }
}

.sync-retry {
  background: none;
  border: none;
  color: var(--accent);
  cursor: pointer;
  text-decoration: underline;
  font-size: inherit;
  padding: 0;
}

#groupName {
  font-weight: 600;
  color: var(--accent);
  font-size: 1.1rem;
}

.week-range {
  color: var(--text-dim);
  font-size: 0.85rem;
}

.week-nav {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 16px;
  padding: 12px;
  background: var(--surface);
  border-radius: var(--radius);
  margin-bottom: 12px;
}

.nav-btn {
  background: none;
  border: 1px solid var(--border);
  color: var(--text);
  width: 36px;
  height: 36px;
  border-radius: 8px;
  cursor: pointer;
  font-size: 0.9rem;
  transition: all 0.2s;
}

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

#weekLabel {
  font-size: 0.9rem;
  color: var(--text-dim);
}

.day-tabs {
  display: flex;
  gap: 4px;
  overflow-x: auto;
  padding-bottom: 8px;
  margin-bottom: 16px;
  scrollbar-width: none;
}

.day-tabs::-webkit-scrollbar {
  display: none;
}

.day-tab {
  flex-shrink: 0;
  padding: 8px 14px;
  border-radius: 8px;
  background: var(--surface);
  border: 1px solid var(--border);
  color: var(--text-dim);
  cursor: pointer;
  font-size: 0.85rem;
  transition: all 0.2s;
}

.day-tab:hover {
  background: var(--surface-hover);
  color: var(--text);
}

.day-tab.active {
  background: var(--accent);
  border-color: var(--accent);
  color: #fff;
  font-weight: 600;
}

.day-tab.today {
  border-color: var(--accent-dim);
}

.schedule-content {
  min-height: 200px;
}

.loading {
  text-align: center;
  padding: 40px;
  color: var(--text-dim);
}

.day-schedule {
  animation: fadeIn 0.2s ease;
}

@keyframes fadeIn {
  from { opacity: 0; transform: translateY(8px); }
  to { opacity: 1; transform: translateY(0); }
}

.day-header {
  font-size: 1.1rem;
  font-weight: 600;
  margin-bottom: 12px;
  color: var(--text);
}

.day-date {
  font-weight: 400;
  color: var(--text-dim);
  font-size: 0.85rem;
  margin-left: 8px;
}

.pair-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 14px;
  margin-bottom: 8px;
  transition: border-color 0.2s;
}

.pair-card:hover {
  border-color: var(--accent-dim);
}

.pair-top {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 6px;
}

.pair-num {
  background: var(--accent);
  color: #fff;
  width: 28px;
  height: 28px;
  border-radius: 8px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 700;
  font-size: 0.85rem;
}

.pair-time {
  color: var(--text-dim);
  font-size: 0.85rem;
  font-variant-numeric: tabular-nums;
}

.pair-type {
  font-size: 0.75rem;
  padding: 2px 8px;
  border-radius: 6px;
  font-weight: 500;
}

.pair-type.лекция { background: #1e3a5f; color: #60a5fa; }
.pair-type.практика { background: #1a3a2a; color: #4ade80; }
.pair-type.лабораторная { background: #3a2a1a; color: #fbbf24; }
.pair-type.семинар { background: #2a1a3a; color: #c084fc; }
.pair-type.практическое { background: #1a3a2a; color: #4ade80; }

.pair-subject {
  font-weight: 600;
  font-size: 0.95rem;
  margin-bottom: 4px;
}

.pair-teacher {
  color: var(--text-dim);
  font-size: 0.85rem;
}

.pair-room {
  color: var(--text-dim);
  font-size: 0.85rem;
}

.pair-room::before {
  content: '🚪 ';
}

.no-pairs {
  text-align: center;
  padding: 40px;
  color: var(--text-dim);
  font-size: 0.95rem;
}

.error-msg {
  text-align: center;
  padding: 24px;
  color: var(--red);
  background: var(--surface);
  border-radius: var(--radius);
  border: 1px solid var(--red);
}

.error-msg button {
  margin-top: 12px;
  padding: 8px 20px;
  background: var(--red);
  color: #fff;
  border: none;
  border-radius: 8px;
  cursor: pointer;
  font-size: 0.9rem;
}

/* Homework Section */
.homework-section {
  margin-top: 24px;
  border-top: 1px solid var(--border);
  padding-top: 20px;
}

.homework-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 12px;
}

.homework-header h2 {
  font-size: 1.1rem;
}

.add-btn {
  padding: 6px 14px;
  background: var(--accent);
  color: #fff;
  border: none;
  border-radius: 8px;
  cursor: pointer;
  font-size: 0.85rem;
  font-weight: 500;
  transition: opacity 0.2s;
}

.add-btn:hover {
  opacity: 0.85;
}

.homework-list {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.hw-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 12px 14px;
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 12px;
}

.hw-card.overdue {
  border-color: var(--red);
}

.hw-card.due-soon {
  border-color: var(--orange);
}

.hw-info {
  flex: 1;
  min-width: 0;
}

.hw-subject {
  font-weight: 600;
  font-size: 0.9rem;
  margin-bottom: 2px;
}

.hw-task {
  color: var(--text-dim);
  font-size: 0.85rem;
  word-break: break-word;
}

.hw-due {
  font-size: 0.8rem;
  color: var(--orange);
  margin-top: 4px;
}

.hw-due.overdue {
  color: var(--red);
}

.hw-delete {
  background: none;
  border: none;
  color: var(--text-dim);
  cursor: pointer;
  font-size: 1.1rem;
  padding: 4px;
  border-radius: 6px;
  transition: all 0.2s;
  flex-shrink: 0;
}

.hw-delete:hover {
  color: var(--red);
  background: rgba(248, 113, 113, 0.1);
}

.no-homework {
  text-align: center;
  padding: 20px;
  color: var(--text-dim);
  font-size: 0.9rem;
}

/* Modal */
.modal {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.6);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 100;
  padding: 16px;
}

.modal.hidden {
  display: none;
}

.modal-content {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  width: 100%;
  max-width: 400px;
}

.modal-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 16px;
  border-bottom: 1px solid var(--border);
}

.modal-header h2 {
  font-size: 1rem;
}

.modal-body {
  padding: 16px;
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.modal-body label {
  display: flex;
  flex-direction: column;
  gap: 4px;
  font-size: 0.85rem;
  color: var(--text-dim);
}

.modal-body input,
.modal-body textarea {
  padding: 10px 12px;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 8px;
  color: var(--text);
  font-size: 0.9rem;
  font-family: inherit;
  resize: vertical;
}

.modal-body input:focus,
.modal-body textarea:focus {
  outline: none;
  border-color: var(--accent);
}

.settings-note {
  font-size: 0.8rem;
  color: var(--text-dim);
  background: var(--bg);
  padding: 10px;
  border-radius: 8px;
  line-height: 1.4;
}

.settings-note code {
  color: var(--accent);
}

.save-btn {
  padding: 10px;
  background: var(--accent);
  color: #fff;
  border: none;
  border-radius: 8px;
  cursor: pointer;
  font-size: 0.9rem;
  font-weight: 600;
  transition: opacity 0.2s;
}

.save-btn:hover {
  opacity: 0.85;
}

/* Mobile tweaks */
@media (max-width: 400px) {
  .container { padding: 10px; }
  .day-tab { padding: 6px 10px; font-size: 0.8rem; }
}
