* {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
}

html, body {
  height: 100%;
  font-family: 'Bahnschrift', 'Trebuchet MS', 'Tahoma', sans-serif;
  background:
    radial-gradient(circle at 20% 0%, #fff4e8 0%, #f7f7f7 38%, #eef3f8 100%);
  color: #263238;
}

body {
  overflow-x: hidden;
}

#app {
  display: flex;
  flex-direction: column;
  min-height: 100vh;
}

.header {
  background: linear-gradient(135deg, #0f4c81, #1368aa 55%, #1d84ce);
  color: white;
  padding: 1.15rem;
  box-shadow: 0 10px 22px rgba(19, 104, 170, 0.28);
  text-align: center;
}

.header h1 {
  font-size: 1.8rem;
  margin: 0;
}

.ring-selector {
  background: rgba(255, 255, 255, 0.86);
  backdrop-filter: blur(3px);
  padding: 1rem;
  border-bottom: 1px solid #dde5ee;
  display: flex;
  gap: 0.5rem;
  align-items: center;
  flex-wrap: wrap;
}

.ring-selector label {
  font-weight: 600;
  min-width: 100px;
}

.ring-selector select {
  flex: 1;
  min-width: 200px;
  padding: 0.5rem;
  border: 1px solid #ccc;
  border-radius: 4px;
  font-size: 1rem;
}

.status {
  padding: 0.5rem 1rem;
  margin: 0.5rem 0;
  text-align: center;
}

.status.error {
  background: #ffebee;
  color: #c62828;
  border-radius: 4px;
}

.main-container {
  flex: 1;
  display: flex;
  flex-direction: column;
  padding: 1rem;
  gap: 1.25rem;
  overflow-y: auto;
}

.message {
  text-align: center;
  color: #666;
  padding: 2rem;
  font-size: 1.1rem;
}

.loading {
  text-align: center;
  color: #999;
  padding: 2rem;
  font-style: italic;
}

/* ── Progress Layout: 3 Sections ────────────────────────────────────────── */
.progress-layout {
  display: grid;
  grid-template-rows: 1.5fr 4fr 1.2fr;
  gap: 1rem;
  flex: 1;
  min-height: 400px;
}

.progress-layout.animate-shift-up .class-section {
  animation: card-shift-up 480ms cubic-bezier(0.2, 0.8, 0.2, 1) both;
}

.progress-layout.animate-shift-up .class-section.current {
  animation-delay: 40ms;
}

.progress-layout.animate-shift-up .class-section.next {
  animation-delay: 120ms;
}

.progress-layout.animate-shift-up .class-section.after-next {
  animation-delay: 200ms;
}

.progress-layout.animate-shift-up .catalog-chip {
  animation: chip-rise-in 420ms ease both;
}

@keyframes card-shift-up {
  0% {
    opacity: 0;
    transform: translateY(26px) scale(0.985);
  }
  100% {
    opacity: 1;
    transform: translateY(0) scale(1);
  }
}

@keyframes chip-rise-in {
  0% {
    opacity: 0;
    transform: translateY(10px);
  }
  100% {
    opacity: 1;
    transform: translateY(0);
  }
}

.class-section {
  background: rgba(255, 255, 255, 0.88);
  border-radius: 14px;
  padding: 1.1rem 1.2rem;
  box-shadow: 0 8px 20px rgba(27, 39, 53, 0.08);
  border: 1px solid rgba(219, 226, 235, 0.9);
  display: flex;
  flex-direction: column;
  overflow: hidden;
  transition: transform 0.2s ease, box-shadow 0.25s ease;
}

.class-section h2 {
  font-size: 1.02rem;
  color: #586777;
  text-transform: uppercase;
  letter-spacing: 1px;
  margin-bottom: 0.9rem;
  border-bottom: 2px solid #d9e2eb;
  padding-bottom: 0.55rem;
}

.class-section.current h2 {
  border-bottom-color: #d95c3f;
  color: #bf3c1e;
}

.class-section.next h2 {
  border-bottom-color: #ffd369;
  color: #fff0d2;
}

.class-section.after-next h2 {
  border-bottom-color: #8d9eaf;
  color: #5f7283;
}

.class-section.next {
  background: linear-gradient(135deg, #052f57, #0c3f70 52%, #11598f);
  color: #f0f8ff;
  border-color: rgba(9, 58, 100, 0.7);
  box-shadow: 0 18px 34px rgba(7, 55, 95, 0.42);
  transform: scale(1.01);
  position: relative;
}

.class-section.next::after {
  content: '';
  position: absolute;
  inset: 0;
  pointer-events: none;
  background: linear-gradient(120deg, rgba(255, 211, 105, 0.18), transparent 35%);
}

.class-section.current,
.class-section.after-next {
  opacity: 0.96;
}

.class-details {
  flex: 1;
  display: flex;
  flex-direction: column;
  justify-content: center;
  gap: 0.35rem;
  font-size: 1rem;
}

.class-details p {
  margin: 0.25rem 0;
}

.class-breeds {
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  font-weight: 700;
}

.class-meta-line {
  font-weight: 600;
}

.class-manual-title {
  font-weight: 800;
  font-size: 1.2rem;
  color: #143d63;
}

.class-manual-note {
  font-size: 0.95rem;
  color: #5e6f80;
  line-height: 1.4;
}

.class-section.manual-step .catalog-numbers {
  display: none;
}

.class-section.next.manual-step .class-manual-title {
  color: #ffd369;
}

.class-section.next.manual-step .class-manual-note {
  color: #dbeaff;
}

.class-details strong {
  font-weight: 600;
  color: #125994;
}

.class-section.current .class-details strong {
  color: #bf3c1e;
}

.class-section.next .class-details {
  font-size: 1.22rem;
  gap: 0.55rem;
}

.class-section.next .class-details strong {
  color: #ffd369;
}

.class-section.next .catalog-numbers {
  border-top-color: rgba(255, 255, 255, 0.2);
}

.catalog-numbers {
  margin-top: 0.85rem;
  padding-top: 0.85rem;
  border-top: 1px solid #eee;
  font-size: 0.9rem;
}

.catalog-numbers p {
  word-wrap: break-word;
  white-space: pre-wrap;
  margin-bottom: 0.45rem;
}

.catalog-chip-list {
  display: flex;
  flex-wrap: wrap;
  gap: 0.45rem;
}

.catalog-chip {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 42px;
  height: 42px;
  padding: 0 0.65rem;
  border: 3px solid #202124;
  border-radius: 10px;
  background: #fff;
  color: #202124;
  font-size: 2rem;
  font-weight: 800;
  letter-spacing: 0.5px;
  line-height: 1;
  box-shadow: 0 3px 0 rgba(0, 0, 0, 0.2);
}

.catalog-chip.watched {
  border-color: #ff6f3d;
  color: #b63a00;
  box-shadow: 0 0 0 3px rgba(255, 111, 61, 0.25), 0 3px 0 rgba(0, 0, 0, 0.2);
}

.class-section.next .catalog-chip {
  border-color: #ffd369;
  background: rgba(3, 24, 43, 0.9);
  color: #fff;
  box-shadow: 0 0 0 2px rgba(255, 211, 105, 0.15), 0 4px 0 rgba(0, 0, 0, 0.24);
}

.class-section.next .catalog-chip.watched {
  border-color: #ffe2a1;
  background: linear-gradient(180deg, #ffd88b, #ffbe55);
  color: #3b2200;
  box-shadow:
    0 0 0 3px rgba(255, 216, 139, 0.45),
    0 0 18px rgba(255, 190, 85, 0.65),
    0 4px 0 rgba(0, 0, 0, 0.24);
}

.empty {
  color: #999;
  font-style: italic;
  font-size: 1.5rem;
  text-align: center;
}

/* ── Progress Bar ────────────────────────────────────────────────────── */
.progress-bar {
  background: #edf2f7;
  border-radius: 999px;
  height: 30px;
  position: relative;
  overflow: hidden;
  margin: 1rem 0;
}

.progress-fill {
  background: linear-gradient(90deg, #ff8a3d, #ffb266 45%, #ffd369 100%);
  height: 100%;
  transition: width 0.3s ease;
}

.progress-text {
  position: absolute;
  left: 0;
  right: 0;
  top: 50%;
  transform: translateY(-50%);
  text-align: center;
  font-size: 0.9rem;
  font-weight: 600;
  color: #333;
  z-index: 1;
}

.timestamp {
  text-align: right;
  font-size: 0.85rem;
  color: #999;
  margin-top: 0.5rem;
}

/* ── Watch List Panel ────────────────────────────────────────────────── */
.watch-list-panel {
  background: rgba(255, 255, 255, 0.9);
  border-radius: 12px;
  padding: 1.5rem;
  box-shadow: 0 10px 24px rgba(19, 30, 42, 0.1);
  min-width: 280px;
}

.watch-list-panel h3 {
  font-size: 1rem;
  color: #333;
  margin-bottom: 1rem;
  border-bottom: 2px solid #1976d2;
  padding-bottom: 0.5rem;
}

.input-row {
  display: flex;
  gap: 0.5rem;
  margin-bottom: 1rem;
}

.catalog-input {
  flex: 1;
  padding: 0.6rem;
  border: 1px solid #ccc;
  border-radius: 4px;
  font-size: 1rem;
}

.btn-add {
  padding: 0.6rem 1rem;
  background: #1976d2;
  color: white;
  border: none;
  border-radius: 4px;
  cursor: pointer;
  font-weight: 600;
  transition: background 0.2s;
}

.btn-add:hover {
  background: #1565c0;
}

.btn-add:active {
  transform: scale(0.98);
}

.watch-list {
  list-style: none;
  max-height: 300px;
  overflow-y: auto;
}

.watch-list li {
  padding: 0.5rem 0;
  border-bottom: 1px solid #f0f0f0;
  color: #666;
  font-size: 0.95rem;
}

.watch-list li:last-child {
  border-bottom: none;
}

.watch-item {
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.watch-item span {
  flex: 1;
}

.btn-remove {
  background: #ffebee;
  color: #d32f2f;
  border: none;
  width: 28px;
  height: 28px;
  border-radius: 50%;
  cursor: pointer;
  font-weight: bold;
  transition: background 0.2s;
}

.btn-remove:hover {
  background: #ffcdd2;
}

/* ── Responsive Design ───────────────────────────────────────────────────── */

/* Tablet: Side-by-side layout */
@media (min-width: 768px) {
  .main-container {
    flex-direction: row;
    gap: 1.5rem;
  }

  .progress-layout {
    flex: 1;
    grid-template-rows: 1.4fr 4fr 1.2fr;
  }

  .watch-list-panel {
    width: 300px;
    flex-shrink: 0;
    height: fit-content;
    position: sticky;
    top: 1rem;
  }
}

/* Desktop: Full width */
@media (min-width: 1024px) {
  .header h1 {
    font-size: 2.2rem;
  }

  .main-container {
    max-width: 1400px;
    margin: 0 auto;
    width: 100%;
  }

  .class-section {
    padding: 1.45rem 1.6rem;
  }

  .class-details {
    font-size: 1.1rem;
  }

  .watch-list-panel {
    width: 350px;
  }
}

/* Mobile: Vertical stacking */
@media (max-width: 767px) {
  .header h1 {
    font-size: 1.4rem;
  }

  .main-container {
    padding: 0.75rem;
    gap: 0.75rem;
  }

  .progress-layout {
    grid-template-rows: auto;
    min-height: auto;
  }

  .class-section.next {
    transform: none;
  }

  .catalog-chip {
    min-width: 38px;
    height: 38px;
    font-size: 1.7rem;
  }

  .class-section {
    padding: 1rem;
  }

  .class-section h2 {
    font-size: 0.9rem;
  }

  .class-details {
    font-size: 0.9rem;
  }

  .catalog-numbers {
    margin-top: 0.5rem;
    padding-top: 0.5rem;
  }

  .watch-list-panel {
    min-width: auto;
    width: 100%;
  }

  .watch-list {
    max-height: 150px;
  }

  .ring-selector {
    flex-direction: column;
    align-items: stretch;
  }

  .ring-selector label {
    min-width: auto;
  }

  .ring-selector select {
    min-width: auto;
  }
}

/* Print Styles */
@media print {
  body {
    background: white;
  }

  .header, .ring-selector, .watch-list-panel {
    display: none;
  }

  .main-container {
    padding: 0;
  }

  .progress-layout {
    break-inside: avoid;
  }
}

@media (prefers-reduced-motion: reduce) {
  .progress-layout.animate-shift-up .class-section,
  .progress-layout.animate-shift-up .catalog-chip {
    animation: none;
  }
}
