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

body {
  font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  background: linear-gradient(135deg, #1a1a2e 0%, #16213e 50%, #0f3460 100%);
  min-height: 100vh;
  color: #fff;
}

#app {
  min-height: 100vh;
}

/* App Container */
.app-container {
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

/* Main Navigation */
.main-nav {
  display: flex;
  justify-content: center;
  gap: 0.5rem;
  padding: 1rem;
  background: rgba(0, 0, 0, 0.3);
  border-bottom: 1px solid rgba(255, 255, 255, 0.1);
}

.nav-btn {
  padding: 0.75rem 1.5rem;
  background: transparent;
  border: 2px solid rgba(255, 255, 255, 0.2);
  border-radius: 8px;
  color: #888;
  font-size: 1rem;
  font-weight: 500;
  cursor: pointer;
  transition: all 0.3s ease;
}

.nav-btn:hover {
  border-color: #00d4ff;
  color: #fff;
}

.nav-btn.active {
  background: linear-gradient(90deg, #00d4ff, #7b2cbf);
  border-color: transparent;
  color: #fff;
}

/* App Layout - Sidebar + Main */
.app-layout {
  display: flex;
  flex: 1;
  min-height: 0;
}

/* Sidebar */
.sidebar {
  width: 280px;
  background: rgba(0, 0, 0, 0.3);
  border-right: 1px solid rgba(255, 255, 255, 0.1);
  padding: 1.5rem;
  display: flex;
  flex-direction: column;
  overflow-y: auto;
}

.sidebar h3 {
  color: #00d4ff;
  margin-bottom: 1rem;
  font-size: 1.1rem;
}

.selected-summary {
  flex: 1;
  overflow-y: auto;
}

.empty-state {
  color: #666;
  text-align: center;
  padding: 2rem 0;
  font-size: 0.9rem;
}

.selected-item {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.5rem;
  border-radius: 8px;
  margin-bottom: 0.5rem;
  background: rgba(255, 255, 255, 0.05);
  border-left: 3px solid;
}

.selected-item.difficulty-easy {
  border-left-color: #00ff88;
  background: rgba(0, 255, 136, 0.1);
}

.selected-item.difficulty-medium {
  border-left-color: #ffaa00;
  background: rgba(255, 170, 0, 0.1);
}

.selected-item.difficulty-hard {
  border-left-color: #ff4444;
  background: rgba(255, 68, 68, 0.1);
}

.item-number {
  background: rgba(255, 255, 255, 0.2);
  width: 24px;
  height: 24px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 0.75rem;
  font-weight: 600;
}

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

.item-anime {
  font-size: 0.85rem;
  font-weight: 500;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.item-op {
  font-size: 0.75rem;
  color: #888;
}

.btn-remove-small {
  background: rgba(255, 68, 68, 0.3);
  border: none;
  color: #ff4444;
  width: 20px;
  height: 20px;
  border-radius: 50%;
  cursor: pointer;
  font-size: 0.9rem;
  line-height: 1;
}

.btn-remove-small:hover {
  background: rgba(255, 68, 68, 0.5);
}

.summary-stats {
  padding-top: 1rem;
  border-top: 1px solid rgba(255, 255, 255, 0.1);
  font-size: 0.85rem;
  color: #888;
}

.difficulty-stats {
  display: flex;
  gap: 0.5rem;
  margin-top: 0.5rem;
  flex-wrap: wrap;
}

.stat {
  padding: 0.25rem 0.5rem;
  border-radius: 4px;
  font-size: 0.75rem;
}

.stat.easy {
  background: rgba(0, 255, 136, 0.2);
  color: #00ff88;
}

.stat.medium {
  background: rgba(255, 170, 0, 0.2);
  color: #ffaa00;
}

.stat.hard {
  background: rgba(255, 68, 68, 0.2);
  color: #ff4444;
}

/* Main Content */
.main-content {
  flex: 1;
  padding: 2rem;
  max-width: 900px;
  margin: 0 auto;
}

h1 {
  text-align: center;
  font-size: 2.5rem;
  margin-bottom: 0.5rem;
  background: linear-gradient(90deg, #00d4ff, #7b2cbf);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
}

.subtitle {
  text-align: center;
  color: #888;
  margin-bottom: 2rem;
}

.status-indicator {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0.5rem;
  padding: 0.5rem 1rem;
  border-radius: 8px;
  font-size: 0.875rem;
  margin-bottom: 1rem;
}

.status-indicator.success {
  background: rgba(0, 255, 136, 0.2);
  color: #00ff88;
}

.status-indicator.error {
  background: rgba(255, 59, 48, 0.2);
  color: #ff3b30;
}

/* Cards */
.card {
  background: rgba(255, 255, 255, 0.05);
  border-radius: 16px;
  padding: 1.5rem;
  margin-bottom: 1.5rem;
  border: 1px solid rgba(255, 255, 255, 0.1);
  backdrop-filter: blur(10px);
}

.card h2 {
  font-size: 1.25rem;
  margin-bottom: 1rem;
  color: #00d4ff;
}

/* Settings Grid */
.settings-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
  gap: 1rem;
}

.setting-group {
  margin-bottom: 0.5rem;
}

.setting-group > label {
  display: block;
  margin-bottom: 0.5rem;
  font-weight: 500;
  color: #ccc;
  font-size: 0.9rem;
}

.setting-group input[type="number"],
.setting-group select {
  width: 100%;
  padding: 0.6rem 0.8rem;
  border: 1px solid rgba(255, 255, 255, 0.2);
  border-radius: 8px;
  background: rgba(0, 0, 0, 0.3);
  color: #fff;
  font-size: 0.95rem;
}

.setting-group input:focus,
.setting-group select:focus {
  outline: none;
  border-color: #00d4ff;
}

/* Mode Selector */
.mode-selector {
  display: flex;
  gap: 0.5rem;
}

.mode-btn {
  flex: 1;
  padding: 0.75rem;
  border: 2px solid rgba(255, 255, 255, 0.2);
  border-radius: 8px;
  background: transparent;
  color: #fff;
  cursor: pointer;
  transition: all 0.3s ease;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0.5rem;
}

.mode-btn:hover {
  border-color: #00d4ff;
  background: rgba(0, 212, 255, 0.1);
}

.mode-btn.active {
  border-color: #00d4ff;
  background: rgba(0, 212, 255, 0.2);
}

.mode-btn .icon {
  font-size: 1.2rem;
}

/* Checkbox */
.checkbox-label {
  display: inline-flex;
  align-items: center;
  gap: 0.75rem;
  cursor: pointer;
  padding: 0.6rem 0;
  line-height: 1;
}

.setting-group .checkbox-label {
  margin-top: 1.5rem;
}

.checkbox-label input[type="checkbox"] {
  appearance: none;
  -webkit-appearance: none;
  width: 22px;
  height: 22px;
  border: 2px solid rgba(255, 255, 255, 0.3);
  border-radius: 6px;
  background: rgba(0, 0, 0, 0.3);
  cursor: pointer;
  position: relative;
  transition: all 0.2s ease;
  flex-shrink: 0;
}

.checkbox-label input[type="checkbox"]:hover {
  border-color: #00d4ff;
  background: rgba(0, 212, 255, 0.1);
}

.checkbox-label input[type="checkbox"]:checked {
  background: linear-gradient(135deg, #00d4ff, #7b2cbf);
  border-color: #00d4ff;
}

.checkbox-label input[type="checkbox"]:checked::after {
  content: '✓';
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  color: #fff;
  font-size: 14px;
  font-weight: bold;
}

.checkbox-label span {
  color: #ccc;
  font-weight: 500;
  line-height: 22px;
}

/* Sections */
.sections-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 1rem;
}

.sections-header h2 {
  margin-bottom: 0;
}

.btn-add-section {
  padding: 0.5rem 1rem;
  background: linear-gradient(90deg, #00d4ff, #7b2cbf);
  border: none;
  border-radius: 8px;
  color: #fff;
  cursor: pointer;
  font-weight: 500;
}

.btn-add-section:hover {
  opacity: 0.9;
}

.empty-sections {
  text-align: center;
  color: #666;
  padding: 2rem;
}

.section-item {
  background: rgba(0, 0, 0, 0.2);
  border-radius: 12px;
  padding: 1rem;
  margin-bottom: 1rem;
  border-left: 4px solid;
}

.section-item.section-easy {
  border-left-color: #00ff88;
}

.section-item.section-medium {
  border-left-color: #ffaa00;
}

.section-item.section-hard {
  border-left-color: #ff4444;
}

.section-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  flex-wrap: wrap;
  gap: 0.5rem;
}

.section-title {
  display: flex;
  align-items: center;
  gap: 0.75rem;
}

.section-badge {
  padding: 0.25rem 0.75rem;
  border-radius: 20px;
  font-size: 0.75rem;
  font-weight: 600;
}

.section-badge.easy {
  background: rgba(0, 255, 136, 0.2);
  color: #00ff88;
}

.section-badge.medium {
  background: rgba(255, 170, 0, 0.2);
  color: #ffaa00;
}

.section-badge.hard {
  background: rgba(255, 68, 68, 0.2);
  color: #ff4444;
}

.section-actions {
  display: flex;
  gap: 0.5rem;
}

.section-actions button {
  padding: 0.4rem 0.8rem;
  border-radius: 6px;
  border: 1px solid rgba(255, 255, 255, 0.2);
  background: rgba(255, 255, 255, 0.05);
  color: #fff;
  cursor: pointer;
  font-size: 0.85rem;
}

.section-actions button:hover {
  background: rgba(255, 255, 255, 0.1);
}

.btn-settings {
  border-color: #00d4ff !important;
}

.btn-add {
  border-color: #00ff88 !important;
  color: #00ff88 !important;
}

.btn-remove {
  border-color: #ff4444 !important;
  color: #ff4444 !important;
}

/* Section Settings */
.section-settings {
  margin-top: 1rem;
  padding-top: 1rem;
  border-top: 1px solid rgba(255, 255, 255, 0.1);
}

.settings-row {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
  gap: 1rem;
}

.settings-row .setting-group > label {
  font-size: 0.85rem;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0.5rem;
  cursor: pointer;
  padding: 0.25rem 0;
}

.settings-row .setting-group input[type="checkbox"] {
  appearance: none;
  -webkit-appearance: none;
  width: 18px;
  height: 18px;
  border: 2px solid rgba(255, 255, 255, 0.3);
  border-radius: 4px;
  background: rgba(0, 0, 0, 0.3);
  cursor: pointer;
  position: relative;
  transition: all 0.2s ease;
  flex-shrink: 0;
}

.settings-row .setting-group input[type="checkbox"]:hover {
  border-color: #00d4ff;
}

.settings-row .setting-group input[type="checkbox"]:checked {
  background: linear-gradient(135deg, #00d4ff, #7b2cbf);
  border-color: #00d4ff;
}

.settings-row .setting-group input[type="checkbox"]:checked::after {
  content: '✓';
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  color: #fff;
  font-size: 11px;
  font-weight: bold;
}

.settings-row .setting-group input[type="number"],
.settings-row .setting-group select {
  margin-top: 0.5rem;
}

/* Section Openings */
.section-openings {
  margin-top: 1rem;
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}

.opening-item {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  padding: 0.5rem;
  background: rgba(255, 255, 255, 0.05);
  border-radius: 10px;
  border: 1px solid rgba(255, 255, 255, 0.1);
}

.opening-poster-thumb {
  width: 40px;
  height: 40px;
  border-radius: 6px;
  overflow: hidden;
  flex-shrink: 0;
  background: rgba(0, 0, 0, 0.3);
}

.opening-poster-thumb img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.no-poster-thumb {
  width: 100%;
  height: 100%;
  display: flex;
  align-items: center;
  justify-content: center;
  color: #666;
  font-size: 1.2rem;
}

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

.opening-item-name {
  font-size: 0.9rem;
  font-weight: 500;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.opening-item-op {
  font-size: 0.75rem;
  color: #00d4ff;
}

.poster-select {
  padding: 0.4rem 0.6rem;
  border: 1px solid rgba(255, 255, 255, 0.2);
  border-radius: 6px;
  background: rgba(0, 0, 0, 0.3);
  color: #fff;
  font-size: 0.8rem;
  max-width: 150px;
  cursor: pointer;
}

.poster-select:focus {
  outline: none;
  border-color: #00d4ff;
}

.btn-remove-item {
  width: 28px;
  height: 28px;
  border-radius: 50%;
  border: none;
  background: rgba(255, 68, 68, 0.2);
  color: #ff4444;
  cursor: pointer;
  font-size: 1.1rem;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  transition: all 0.2s ease;
}

.btn-remove-item:hover {
  background: rgba(255, 68, 68, 0.4);
}

/* Generate Button */
.btn-generate {
  width: 100%;
  padding: 1rem 2rem;
  font-size: 1.125rem;
  font-weight: 600;
  border: none;
  border-radius: 12px;
  background: linear-gradient(90deg, #00d4ff, #7b2cbf);
  color: #fff;
  cursor: pointer;
  transition: all 0.3s ease;
}

.btn-generate:hover:not(:disabled) {
  transform: translateY(-2px);
  box-shadow: 0 10px 30px rgba(0, 212, 255, 0.3);
}

.btn-generate:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

/* Progress */
.progress-container {
  margin-top: 1.5rem;
}

.progress-bar {
  height: 8px;
  background: rgba(255, 255, 255, 0.1);
  border-radius: 4px;
  overflow: hidden;
  margin-bottom: 0.5rem;
}

.progress-fill {
  height: 100%;
  background: linear-gradient(90deg, #00d4ff, #7b2cbf);
  transition: width 0.3s ease;
}

.progress-text {
  text-align: center;
  color: #888;
  font-size: 0.875rem;
}

/* Result */
.result-card {
  text-align: center;
}

.result-card h3 {
  color: #00ff88;
  margin-bottom: 1rem;
}

.video-preview {
  width: 100%;
  max-height: 400px;
  border-radius: 12px;
  margin-bottom: 1rem;
}

.btn-download {
  display: inline-block;
  padding: 0.75rem 2rem;
  background: #00ff88;
  color: #000;
  text-decoration: none;
  border-radius: 8px;
  font-weight: 600;
  transition: all 0.3s ease;
}

.btn-download:hover {
  background: #00cc6a;
  transform: translateY(-2px);
}

.error-message {
  background: rgba(255, 59, 48, 0.2);
  border: 1px solid #ff3b30;
  border-radius: 8px;
  padding: 1rem;
  color: #ff3b30;
  margin-top: 1rem;
}

/* Modal */
.modal-overlay {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: rgba(0, 0, 0, 0.8);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 1000;
  padding: 2rem;
}

.modal {
  background: #1a1a2e;
  border-radius: 16px;
  width: 100%;
  max-width: 900px;
  max-height: 90vh;
  display: flex;
  flex-direction: column;
  border: 1px solid rgba(255, 255, 255, 0.1);
}

.modal-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 1.5rem;
  border-bottom: 1px solid rgba(255, 255, 255, 0.1);
}

.modal-header h2 {
  color: #00d4ff;
  font-size: 1.25rem;
}

.modal-close {
  background: none;
  border: none;
  color: #888;
  font-size: 1.5rem;
  cursor: pointer;
}

.modal-close:hover {
  color: #fff;
}

.modal-search {
  padding: 1rem 1.5rem;
  border-bottom: 1px solid rgba(255, 255, 255, 0.1);
}

.modal-search input {
  width: 100%;
  padding: 0.75rem 1rem;
  border: 1px solid rgba(255, 255, 255, 0.2);
  border-radius: 8px;
  background: rgba(0, 0, 0, 0.3);
  color: #fff;
  font-size: 1rem;
}

.modal-search input:focus {
  outline: none;
  border-color: #00d4ff;
}

.modal-body {
  flex: 1;
  overflow-y: auto;
  padding: 1.5rem;
}

.openings-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
  gap: 1rem;
}

.opening-card {
  background: rgba(255, 255, 255, 0.05);
  border-radius: 12px;
  overflow: hidden;
  cursor: pointer;
  transition: all 0.3s ease;
  border: 2px solid transparent;
  position: relative;
}

.opening-card:hover {
  background: rgba(255, 255, 255, 0.1);
  transform: translateY(-2px);
}

.opening-card.selected {
  border-color: #00d4ff;
  background: rgba(0, 212, 255, 0.1);
}

.card-poster {
  height: 120px;
  background: rgba(0, 0, 0, 0.3);
  display: flex;
  align-items: center;
  justify-content: center;
}

.card-poster img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.no-poster {
  color: #666;
  font-size: 0.85rem;
}

.card-info {
  padding: 0.75rem;
}

.card-anime {
  font-weight: 600;
  font-size: 0.9rem;
  margin-bottom: 0.25rem;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.card-op {
  color: #00d4ff;
  font-size: 0.8rem;
  margin-bottom: 0.25rem;
}

.card-song {
  color: #888;
  font-size: 0.75rem;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.card-check {
  position: absolute;
  top: 0.5rem;
  right: 0.5rem;
  background: #00d4ff;
  color: #000;
  width: 24px;
  height: 24px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: bold;
}

.poster-selector {
  padding: 0.5rem 0.75rem;
  border-top: 1px solid rgba(255, 255, 255, 0.1);
}

.poster-selector select {
  width: 100%;
  padding: 0.4rem;
  border: 1px solid rgba(255, 255, 255, 0.2);
  border-radius: 4px;
  background: rgba(0, 0, 0, 0.3);
  color: #fff;
  font-size: 0.75rem;
}

.modal-footer {
  display: flex;
  align-items: center;
  gap: 1rem;
  padding: 1.5rem;
  border-top: 1px solid rgba(255, 255, 255, 0.1);
}

.selection-count {
  flex: 1;
  color: #888;
}

.btn-cancel {
  padding: 0.75rem 1.5rem;
  background: rgba(255, 255, 255, 0.1);
  border: 1px solid rgba(255, 255, 255, 0.2);
  border-radius: 8px;
  color: #fff;
  cursor: pointer;
}

.btn-cancel:hover {
  background: rgba(255, 255, 255, 0.2);
}

.btn-confirm {
  padding: 0.75rem 1.5rem;
  background: linear-gradient(90deg, #00d4ff, #7b2cbf);
  border: none;
  border-radius: 8px;
  color: #fff;
  cursor: pointer;
  font-weight: 500;
}

.btn-confirm:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

/* Responsive */
@media (max-width: 900px) {
  .app-layout {
    flex-direction: column;
  }

  .sidebar {
    width: 100%;
    height: auto;
    position: relative;
    max-height: 200px;
  }

  .selected-summary {
    display: flex;
    flex-wrap: wrap;
    gap: 0.5rem;
  }

  .selected-item {
    margin-bottom: 0;
  }
}

@media (max-width: 600px) {
  .main-content {
    padding: 1rem;
  }

  .settings-grid {
    grid-template-columns: 1fr;
  }

  .section-header {
    flex-direction: column;
    align-items: flex-start;
  }

  .section-actions {
    width: 100%;
    justify-content: flex-end;
  }

  .openings-grid {
    grid-template-columns: repeat(auto-fill, minmax(150px, 1fr));
  }

  h1 {
    font-size: 1.75rem;
  }

  .modal {
    margin: 1rem;
    max-height: calc(100vh - 2rem);
  }
}
