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

:root {
  --primary: #2563eb;
  --primary-hover: #1d4ed8;
  --bg: #f8fafc;
  --surface: #ffffff;
  --text: #1e293b;
  --text-muted: #64748b;
  --border: #e2e8f0;
  --error: #dc2626;
  --success: #16a34a;
}

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

.container {
  max-width: 900px;
  margin: 0 auto;
  padding: 2rem;
}

header {
  text-align: center;
  margin-bottom: 2rem;
}

header h1 {
  font-size: 2rem;
  font-weight: 700;
  color: var(--text);
}

.subtitle {
  color: var(--text-muted);
  margin-top: 0.5rem;
}

.input-section {
  margin-bottom: 2rem;
}

.input-tabs {
  display: flex;
  gap: 0.5rem;
  margin-bottom: 1rem;
}

.input-tab {
  padding: 0.5rem 1rem;
  font-size: 0.875rem;
  font-weight: 500;
  color: var(--text-muted);
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 6px;
  cursor: pointer;
  transition: all 0.2s;
}

.input-tab:hover {
  color: var(--text);
  border-color: var(--text-muted);
}

.input-tab.active {
  color: var(--primary);
  border-color: var(--primary);
  background: #eff6ff;
}

.input-panel {
  margin-bottom: 1rem;
}

.url-input-wrapper {
  display: flex;
  gap: 0.75rem;
}

#urlInput {
  width: 100%;
  padding: 0.875rem 1rem;
  font-size: 1rem;
  border: 2px solid var(--border);
  border-radius: 8px;
  outline: none;
  transition: border-color 0.2s;
}

#urlInput:focus {
  border-color: var(--primary);
}

.file-upload-wrapper {
  width: 100%;
}

.file-upload-label {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 2rem;
  border: 2px dashed var(--border);
  border-radius: 8px;
  cursor: pointer;
  transition: all 0.2s;
  background: var(--surface);
}

.file-upload-label:hover {
  border-color: var(--primary);
  background: #f8faff;
}

.file-upload-label.drag-over {
  border-color: var(--primary);
  background: #eff6ff;
}

.file-upload-label.has-file {
  border-color: var(--success);
  background: #f0fdf4;
}

.file-upload-icon {
  font-size: 2rem;
  margin-bottom: 0.5rem;
}

#fileUploadText {
  color: var(--text-muted);
  font-size: 0.9rem;
}

#textInput {
  width: 100%;
  padding: 0.875rem 1rem;
  font-size: 1rem;
  font-family: inherit;
  border: 2px solid var(--border);
  border-radius: 8px;
  outline: none;
  resize: vertical;
  min-height: 120px;
  transition: border-color 0.2s;
}

#textInput:focus {
  border-color: var(--primary);
}

.title-input {
  width: 100%;
  margin-top: 0.5rem;
  padding: 0.75rem 1rem;
  font-size: 0.9rem;
  border: 2px solid var(--border);
  border-radius: 8px;
  outline: none;
  transition: border-color 0.2s;
}

.title-input:focus {
  border-color: var(--primary);
}

.primary-btn {
  width: 100%;
  padding: 0.875rem 1.5rem;
  font-size: 1rem;
  font-weight: 600;
  color: white;
  background: var(--primary);
  border: none;
  border-radius: 8px;
  cursor: pointer;
  transition: background 0.2s;
}

.primary-btn:hover:not(:disabled) {
  background: var(--primary-hover);
}

.primary-btn:disabled {
  opacity: 0.7;
  cursor: not-allowed;
}

.btn-loading {
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.spinner {
  width: 16px;
  height: 16px;
  border: 2px solid rgba(255, 255, 255, 0.3);
  border-top-color: white;
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
}

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

.hidden {
  display: none !important;
}

.error-message {
  margin-top: 0.75rem;
  padding: 0.75rem 1rem;
  background: #fef2f2;
  color: var(--error);
  border-radius: 6px;
  font-size: 0.9rem;
}

.results-section {
  background: var(--surface);
  border-radius: 12px;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.1);
  overflow: hidden;
}

.article-info {
  padding: 1.5rem;
  border-bottom: 1px solid var(--border);
}

.article-info h2 {
  font-size: 1.25rem;
  margin-bottom: 0.25rem;
}

.meta {
  color: var(--text-muted);
  font-size: 0.875rem;
}

.tabs {
  display: flex;
  border-bottom: 1px solid var(--border);
  background: var(--bg);
}

.tab {
  flex: 1;
  padding: 1rem;
  font-size: 0.9rem;
  font-weight: 500;
  color: var(--text-muted);
  background: none;
  border: none;
  cursor: pointer;
  transition: color 0.2s, background 0.2s;
  position: relative;
}

.tab:hover {
  color: var(--text);
  background: rgba(0, 0, 0, 0.02);
}

.tab.active {
  color: var(--primary);
  background: var(--surface);
}

.tab.active::after {
  content: '';
  position: absolute;
  bottom: -1px;
  left: 0;
  right: 0;
  height: 2px;
  background: var(--primary);
}

.tab-panel {
  padding: 1.5rem;
}

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

.panel-header h3 {
  font-size: 1rem;
  font-weight: 600;
}

.btn-group {
  display: flex;
  gap: 0.5rem;
}

.copy-btn,
.export-btn {
  padding: 0.5rem 1rem;
  font-size: 0.875rem;
  font-weight: 500;
  border-radius: 6px;
  cursor: pointer;
  transition: background 0.2s;
}

.copy-btn {
  color: var(--text);
  background: var(--bg);
  border: 1px solid var(--border);
}

.copy-btn:hover {
  background: var(--border);
}

.export-btn {
  color: white;
  background: var(--primary);
  border: none;
}

.export-btn:hover {
  background: var(--primary-hover);
}

.content-area {
  font-size: 0.95rem;
  line-height: 1.7;
}

.content-area ul {
  padding-left: 1.5rem;
}

.content-area li {
  margin-bottom: 0.5rem;
}

.content-area ul ul {
  margin-top: 0.5rem;
}

.flashcards-grid {
  display: grid;
  gap: 1rem;
}

.flashcard {
  background: var(--bg);
  border-radius: 8px;
  overflow: hidden;
}

.flashcard-front,
.flashcard-back {
  padding: 1rem;
}

.flashcard-front {
  font-weight: 500;
  border-bottom: 1px solid var(--border);
}

.flashcard-back {
  color: var(--text-muted);
}

.question-item {
  padding: 1rem;
  background: var(--bg);
  border-radius: 8px;
  margin-bottom: 0.75rem;
}

.question-item:last-child {
  margin-bottom: 0;
}

.question-text {
  font-weight: 500;
  margin-bottom: 0.5rem;
}

.question-hint {
  font-size: 0.875rem;
  color: var(--text-muted);
  font-style: italic;
}

.question-hint::before {
  content: 'Hint: ';
  font-weight: 500;
}

footer {
  text-align: center;
  margin-top: 2rem;
  color: var(--text-muted);
  font-size: 0.875rem;
}

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

  .url-input-wrapper {
    flex-direction: column;
  }

  .primary-btn {
    width: 100%;
  }

  .tabs {
    overflow-x: auto;
  }
}
