* {
  box-sizing: border-box;
  -webkit-tap-highlight-color: transparent;
}

body {
  margin: 0;
  padding: 30px 20px;
  background: #0b1120;
  color: #e5e7eb;
  font-family: Inter, system-ui, -apple-system, sans-serif;
  display: flex;
  flex-direction: column;
  align-items: center;
}

body > * {
  width: 100%;
  max-width: 1400px;
}

header {
  display: grid;
  grid-template-columns: 1fr;
  gap: 15px;
  margin-bottom: 20px;
  padding: 20px;
  background: #111827;
  border-bottom: 1px solid #1f2937;
  border-radius: 8px;
}

.logo-title {
  padding-bottom: 15px;
  border-bottom: 1px solid #1f2937;
}

header h1 {
  margin: 0;
  font-size: 1.9rem;
  font-weight: 600;
  color: #e5e7eb;
}

.header-controls {
  display: grid;
  grid-template-columns: 1fr;
  gap: 12px;
}

.search-container {
  width: 100%;
}

#searchInput {
  width: 100%;
}

.header-buttons {
  display: grid;
  grid-template-columns: 1fr 1fr 1fr;
  gap: 12px;
}

input,
select,
button {
  padding: 10px 14px;
  border: 1px solid #1f2937;
  border-radius: 6px;
  background: #111827;
  color: #e5e7eb;
  font-size: 0.95rem;
  outline: none;
  font-family: inherit;
}

input::placeholder { color: #6b7280; }

input:focus,
select:focus {
  border-color: #334155;
  background: #0f172a;
}

button {
  cursor: pointer;
  white-space: nowrap;
  transition: all 0.2s;
}

select {
  min-width: 0;
  width: 100%;
}

.overall-section {
  margin-bottom: 25px;
  padding: 16px 20px;
  background: #111827;
  border: 1px solid #1f2937;
  border-radius: 8px;
}

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

#overallLabel {
  font-size: 0.95rem;
  font-weight: 500;
  color: #e5e7eb;
}

#clearAllBtn {
  padding: 8px 16px;
  border: 1px solid #991b1b;
  border-radius: 6px;
  background: #111827;
  color: #fca5a5;
  font-size: 0.85rem;
  font-weight: 600;
  cursor: pointer;
  white-space: nowrap;
  flex-shrink: 0;
  transition: all 0.2s;
}

#clearAllBtn:hover {
  background: #7f1d1d;
  border-color: #b91c1c;
}

.overall-progress-bar {
  width: 100%;
  height: 8px;
  background: #1f2937;
  border-radius: 4px;
  overflow: hidden;
}

.overall-progress-fill {
  height: 100%;
  width: 0%;
  background: linear-gradient(90deg, #60a5fa, #3b82f6);
  border-radius: 4px;
  transition: width 0.4s ease;
}

#subjectsContainer {
  display: flex;
  flex-direction: column;
  gap: 24px;
  margin-bottom: 20px;
}

.subject-section {
  background: #111827;
  border: 1px solid #1f2937;
  border-radius: 8px;
  overflow: hidden;
}

.subject-header {
  padding: 16px 20px;
  background: #0f172a;
  border-bottom: 1px solid #1f2937;
}

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

.subject-header-left {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
}

.subject-badge-pill {
  padding: 4px 12px;
  border-radius: 20px;
  font-size: 0.75rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

.subject-completion-badge {
  display: inline-flex;
  align-items: center;
  padding: 3px 10px;
  border-radius: 20px;
  font-size: 0.72rem;
  font-weight: 700;
  background: rgba(74, 222, 128, 0.12);
  color: #4ade80;
  border: 1px solid rgba(74, 222, 128, 0.3);
}

.subject-topic-count {
  font-size: 0.82rem;
  color: #6b7280;
}

.subject-note {
  font-size: 0.8rem;
  color: #9ca3af;
  background: #111827;
  border: 1px solid #1f2937;
  border-radius: 6px;
  padding: 9px 13px;
  margin-bottom: 10px;
  line-height: 1.5;
}

.subject-progress-bar {
  width: 100%;
  height: 5px;
  background: #1f2937;
  border-radius: 3px;
  overflow: hidden;
}

.subject-progress-fill {
  height: 100%;
  width: 0%;
  border-radius: 3px;
  transition: width 0.4s ease;
}

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

.topic-card-item {
  padding: 14px 15px;
  background: #111827;
  border: 1px solid #1f2937;
  border-radius: 8px;
  cursor: pointer;
  transition: all 0.2s;
  display: grid;
  grid-template-columns: 48px 1fr auto;
  gap: 12px;
  align-items: center;
  position: relative;
}

.topic-card-item:hover {
  background: #0f172a;
  border-color: #334155;
}

.topic-card-number {
  width: 48px;
  height: 48px;
  border-radius: 8px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 0.72rem;
  font-weight: 700;
  text-align: center;
  flex-shrink: 0;
  line-height: 1.3;
}

.topic-card-info {
  display: flex;
  flex-direction: column;
  gap: 6px;
  min-width: 0;
}

.topic-card-name {
  font-size: 0.95rem;
  font-weight: 600;
  color: #e5e7eb;
  line-height: 1.3;
}

.topic-card-item.completed .topic-card-name {
  color: #6b7280;
  text-decoration: line-through;
  text-decoration-color: #374151;
}

.topic-card-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 5px;
}

.topic-badge {
  padding: 2px 8px;
  border-radius: 4px;
  font-size: 0.7rem;
  font-weight: 600;
  white-space: nowrap;
}

.conf-badge-low {
  background: rgba(248, 113, 113, 0.12);
  color: #f87171;
  border: 1px solid rgba(248, 113, 113, 0.25);
}

.conf-badge-medium {
  background: rgba(250, 204, 21, 0.12);
  color: #facc15;
  border: 1px solid rgba(250, 204, 21, 0.25);
}

.conf-badge-high {
  background: rgba(74, 222, 128, 0.12);
  color: #4ade80;
  border: 1px solid rgba(74, 222, 128, 0.25);
}

.due-badge {
  background: rgba(251, 146, 60, 0.12);
  color: #fb923c;
  border: 1px solid rgba(251, 146, 60, 0.25);
}

.up-to-date-badge {
  background: rgba(74, 222, 128, 0.12);
  color: #4ade80;
  border: 1px solid rgba(74, 222, 128, 0.25);
}

.last-revised-badge {
  background: #0f172a;
  color: #6b7280;
  border: 1px solid #1f2937;
}

.notes-badge {
  background: rgba(96, 165, 250, 0.12);
  color: #60a5fa;
  border: 1px solid rgba(96, 165, 250, 0.25);
}

.topic-card-tick {
  width: 28px;
  height: 28px;
  min-width: 28px;
  border: 2px solid #374151;
  border-radius: 6px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 0.85rem;
  font-weight: 700;
  color: transparent;
  background: #0b1120;
  transition: all 0.2s;
  flex-shrink: 0;
}

.topic-card-tick.ticked {
  color: #0b1120;
  border-color: transparent;
}

.search-modal {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: rgba(11, 17, 32, 0.9);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 1000;
  padding: 20px;
}

.modal-content {
  position: relative;
  width: 90%;
  max-width: 600px;
  max-height: 88vh;
  background: #111827;
  border: 1px solid #1f2937;
  border-radius: 8px;
  padding: 30px;
  display: flex;
  flex-direction: column;
  gap: 20px;
  overflow-y: auto;
}

.modal-close-topic {
  position: absolute;
  top: 15px;
  right: 20px;
  font-size: 1.8rem;
  color: #6b7280;
  cursor: pointer;
  line-height: 1;
  transition: color 0.2s;
  z-index: 10;
}

.modal-close-topic:hover { color: #e5e7eb; }

.topic-modal-top {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
  padding-right: 30px;
}

.topic-modal-badge {
  padding: 4px 12px;
  border-radius: 20px;
  font-size: 0.75rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

.topic-modal-num {
  padding: 4px 10px;
  background: #0f172a;
  border: 1px solid #1f2937;
  border-radius: 6px;
  font-size: 0.82rem;
  color: #9ca3af;
  font-weight: 600;
}

.topic-modal-title {
  margin: 0;
  font-size: 1.55rem;
  font-weight: 700;
  color: #e5e7eb;
  line-height: 1.2;
}

.topic-modal-info-grid {
  display: grid;
  grid-template-columns: 1fr 1fr 1fr;
  gap: 12px;
}

.topic-info-box {
  padding: 14px;
  background: #0f172a;
  border: 1px solid #1f2937;
  border-radius: 8px;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.topic-info-box-label {
  font-size: 0.7rem;
  font-weight: 600;
  color: #6b7280;
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

.topic-info-box-value {
  font-size: 0.85rem;
  color: #e5e7eb;
  font-weight: 500;
}

.topic-toggle-btn {
  padding: 8px 10px;
  border: 1px solid #1f2937;
  border-radius: 6px;
  background: #111827;
  color: #e5e7eb;
  font-size: 0.78rem;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.2s;
  text-align: center;
  white-space: normal;
  line-height: 1.3;
}

.topic-toggle-btn:hover {
  background: #0f172a;
  border-color: #334155;
}

.topic-toggle-btn.completed {
  border-color: rgba(74, 222, 128, 0.35);
  color: #4ade80;
  background: rgba(74, 222, 128, 0.08);
}

.topic-modal-section {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.topic-modal-section-title {
  font-size: 0.78rem;
  font-weight: 600;
  color: #9ca3af;
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

.confidence-buttons {
  display: grid;
  grid-template-columns: 1fr 1fr 1fr;
  gap: 10px;
}

.conf-btn {
  padding: 12px;
  border: 1px solid #1f2937;
  border-radius: 6px;
  background: #0f172a;
  font-size: 0.88rem;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.2s;
  text-align: center;
}

.conf-btn.conf-low { color: #f87171; }
.conf-btn.conf-medium { color: #facc15; }
.conf-btn.conf-high { color: #4ade80; }

.conf-btn.conf-low.active {
  background: rgba(248, 113, 113, 0.12);
  border-color: rgba(248, 113, 113, 0.4);
}

.conf-btn.conf-medium.active {
  background: rgba(250, 204, 21, 0.12);
  border-color: rgba(250, 204, 21, 0.4);
}

.conf-btn.conf-high.active {
  background: rgba(74, 222, 128, 0.12);
  border-color: rgba(74, 222, 128, 0.4);
}

#modalNotes {
  width: 100%;
  min-height: 120px;
  padding: 12px;
  background: #0f172a;
  border: 1px solid #1f2937;
  border-radius: 6px;
  color: #e5e7eb;
  font-size: 0.9rem;
  font-family: inherit;
  resize: vertical;
}

#modalNotes:focus {
  outline: none;
  border-color: #334155;
}

.save-notes-btn {
  padding: 10px 20px;
  background: #111827;
  border: 1px solid #1f2937;
  border-radius: 6px;
  color: #e5e7eb;
  font-size: 0.9rem;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.2s;
  align-self: flex-start;
}

.save-notes-btn:hover {
  background: #0f172a;
  border-color: #334155;
}

footer {
  margin-top: 40px;
  padding-top: 20px;
  border-top: 1px solid #1f2937;
  color: #6b7280;
  font-size: 0.85rem;
  text-align: center;
  width: 100%;
}

footer a {
  color: #60a5fa;
  text-decoration: none;
}

footer a:hover {
  text-decoration: underline;
}

@media (max-width: 768px) {
  body { padding: 15px; }
  header { padding: 15px; }
  header h1 { font-size: 1.3rem; }
  .header-buttons { grid-template-columns: 1fr 1fr; }
  .header-buttons select:last-child { grid-column: 1 / -1; }
  .topics-list { grid-template-columns: 1fr; }
  .topic-modal-info-grid { grid-template-columns: 1fr 1fr; }
  .topic-modal-info-grid .topic-info-box:last-child { grid-column: 1 / -1; }
  .modal-content { padding: 20px; }
  .topic-modal-title { font-size: 1.25rem; }
}

@media (max-width: 480px) {
  body { padding: 10px; }
  header h1 { font-size: 1.1rem; }
  .header-buttons { grid-template-columns: 1fr; }
  .topic-card-item { grid-template-columns: 42px 1fr auto; }
  .topic-card-number { width: 42px; height: 42px; font-size: 0.65rem; }
  .confidence-buttons { grid-template-columns: 1fr 1fr 1fr; }
  .topic-modal-info-grid { grid-template-columns: 1fr; }
  .overall-header { flex-direction: column; align-items: flex-start; }
}