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

:root {
  --primary: #2563eb;
  --primary-dark: #1d4ed8;
  --secondary: #64748b;
  --success: #22c55e;
  --warning: #f59e0b;
  --danger: #ef4444;
  --bg: #f8fafc;
  --card: #ffffff;
  --border: #e2e8f0;
  --text: #1e293b;
  --text-muted: #64748b;
}

body {
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu, sans-serif;
  background: var(--bg);
  color: var(--text);
  line-height: 1.6;
}

.page {
  min-height: 100vh;
}

/* Auth Page */
.auth-container {
  max-width: 400px;
  margin: 0 auto;
  padding: 60px 20px;
  text-align: center;
}

.auth-container h1 {
  font-size: 2.5rem;
  margin-bottom: 0.5rem;
}

.subtitle {
  color: var(--text-muted);
  margin-bottom: 2rem;
}

.auth-form {
  background: var(--card);
  padding: 2rem;
  border-radius: 12px;
  box-shadow: 0 4px 6px -1px rgba(0,0,0,0.1);
}

.auth-form h2 {
  margin-bottom: 1.5rem;
}

.auth-form input {
  width: 100%;
  padding: 12px 16px;
  border: 1px solid var(--border);
  border-radius: 8px;
  font-size: 1rem;
  margin-bottom: 1rem;
}

.auth-form input:focus {
  outline: none;
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.1);
}

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

.auth-form button:hover {
  background: var(--primary-dark);
}

.auth-error {
  color: var(--danger);
  margin-top: 1rem;
  font-size: 0.9rem;
}

/* Disclaimer */
.disclaimer-box {
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 1rem;
  margin: 1rem 0;
  text-align: left;
}

.disclaimer-box h3 {
  margin-bottom: 0.75rem;
  font-size: 1rem;
}

.disclaimer-text {
  max-height: 200px;
  overflow-y: auto;
  font-size: 0.8rem;
  color: var(--text-muted);
  padding-right: 0.5rem;
  margin-bottom: 1rem;
}

.disclaimer-text p {
  margin-bottom: 0.75rem;
}

.disclaimer-checkbox {
  display: flex;
  align-items: flex-start;
  gap: 0.5rem;
  font-size: 0.9rem;
  cursor: pointer;
}

.disclaimer-checkbox input {
  margin-top: 3px;
  width: auto;
}

/* Header */
header {
  background: var(--card);
  padding: 1rem 2rem;
  display: flex;
  align-items: center;
  justify-content: space-between;
  border-bottom: 1px solid var(--border);
  position: sticky;
  top: 0;
  z-index: 100;
}

header h1 {
  font-size: 1.5rem;
}

.header-right {
  display: flex;
  align-items: center;
  gap: 1rem;
}

#user-name {
  color: var(--text-muted);
}

/* Buttons */
.btn-primary {
  padding: 10px 20px;
  background: var(--primary);
  color: white;
  border: none;
  border-radius: 8px;
  font-size: 0.95rem;
  font-weight: 500;
  cursor: pointer;
  transition: background 0.2s;
}

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

.btn-secondary {
  padding: 10px 20px;
  background: transparent;
  color: var(--secondary);
  border: 1px solid var(--border);
  border-radius: 8px;
  font-size: 0.95rem;
  cursor: pointer;
  transition: all 0.2s;
}

.btn-secondary:hover {
  background: var(--bg);
}

.btn-back {
  padding: 8px 16px;
  background: transparent;
  border: none;
  color: var(--primary);
  font-size: 1rem;
  cursor: pointer;
}

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

/* Stats Bar */
.stats-bar {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 1rem;
  margin-bottom: 2rem;
}

.stat {
  background: var(--card);
  padding: 1.5rem;
  border-radius: 12px;
  text-align: center;
  box-shadow: 0 1px 3px rgba(0,0,0,0.1);
}

.stat-value {
  display: block;
  font-size: 2rem;
  font-weight: 700;
  color: var(--primary);
}

.stat-label {
  color: var(--text-muted);
  font-size: 0.9rem;
}

/* Section Header */
.section-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 1.5rem;
}

.section-header h2 {
  font-size: 1.25rem;
}

/* Assignments List */
.assignments-list {
  display: flex;
  flex-direction: column;
  gap: 1rem;
}

.assignment-card {
  background: var(--card);
  padding: 1.5rem;
  border-radius: 12px;
  box-shadow: 0 1px 3px rgba(0,0,0,0.1);
  cursor: pointer;
  transition: transform 0.2s, box-shadow 0.2s;
}

.assignment-card:hover {
  transform: translateY(-2px);
  box-shadow: 0 4px 12px rgba(0,0,0,0.15);
}

.assignment-card h3 {
  margin-bottom: 0.5rem;
}

.assignment-card .meta {
  display: flex;
  gap: 1.5rem;
  color: var(--text-muted);
  font-size: 0.9rem;
}

.assignment-card .status {
  display: inline-block;
  padding: 4px 10px;
  border-radius: 20px;
  font-size: 0.8rem;
  font-weight: 500;
}

.status-draft { background: #fef3c7; color: #92400e; }
.status-submitted { background: #dbeafe; color: #1e40af; }
.status-graded { background: #dcfce7; color: #166534; }

.empty-state {
  text-align: center;
  padding: 3rem;
  color: var(--text-muted);
}

/* Forms */
.form-card {
  background: var(--card);
  padding: 2rem;
  border-radius: 12px;
  box-shadow: 0 1px 3px rgba(0,0,0,0.1);
}

.form-group {
  margin-bottom: 1.5rem;
}

.form-group label {
  display: block;
  font-weight: 500;
  margin-bottom: 0.5rem;
}

.form-group input,
.form-group textarea {
  width: 100%;
  padding: 12px 16px;
  border: 1px solid var(--border);
  border-radius: 8px;
  font-size: 1rem;
  font-family: inherit;
}

.form-group textarea {
  resize: vertical;
}

.form-group input:focus,
.form-group textarea:focus {
  outline: none;
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.1);
}

.help-text {
  font-size: 0.85rem;
  color: var(--text-muted);
  margin-top: 0.5rem;
}

.textarea-footer {
  display: flex;
  justify-content: flex-end;
  margin-top: 0.5rem;
}

#word-count {
  font-size: 0.85rem;
  color: var(--text-muted);
}

.form-actions {
  display: flex;
  gap: 1rem;
  justify-content: flex-end;
  margin-top: 2rem;
}

/* Tabs */
.tabs {
  display: flex;
  gap: 0;
  border-bottom: 2px solid var(--border);
  margin-bottom: 1.5rem;
}

.tab {
  padding: 12px 24px;
  border: none;
  background: none;
  font-size: 1rem;
  color: var(--text-muted);
  cursor: pointer;
  border-bottom: 2px solid transparent;
  margin-bottom: -2px;
  transition: all 0.2s;
}

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

.tab.active {
  color: var(--primary);
  border-bottom-color: var(--primary);
}

.tab-content {
  display: none;
}

.tab-content.active {
  display: block;
}

/* Rubric Input */
.rubric-input {
  background: var(--bg);
  padding: 1.5rem;
  border-radius: 8px;
  margin-bottom: 1.5rem;
}

.rubric-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 0.75rem 0;
  border-bottom: 1px solid var(--border);
}

.rubric-row:last-child {
  border-bottom: none;
}

.rubric-row.total {
  font-weight: 700;
  font-size: 1.1rem;
  padding-top: 1rem;
  margin-top: 0.5rem;
  border-top: 2px solid var(--border);
  border-bottom: none;
}

.rubric-row label {
  flex: 1;
}

.rubric-row input {
  width: 80px;
  padding: 8px 12px;
  text-align: center;
  border: 1px solid var(--border);
  border-radius: 6px;
}

/* Drafts List */
.drafts-list {
  display: flex;
  flex-direction: column;
  gap: 1rem;
}

.draft-card {
  background: var(--card);
  padding: 1.25rem;
  border-radius: 10px;
  border: 1px solid var(--border);
  cursor: pointer;
  display: flex;
  justify-content: space-between;
  align-items: center;
  transition: border-color 0.2s;
}

.draft-card:hover {
  border-color: var(--primary);
}

.draft-card .version {
  font-weight: 600;
}

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

.draft-card .score {
  background: var(--primary);
  color: white;
  padding: 6px 12px;
  border-radius: 20px;
  font-weight: 600;
}

/* Loading */
.loading {
  text-align: center;
  padding: 3rem;
}

.spinner {
  width: 40px;
  height: 40px;
  border: 4px solid var(--border);
  border-top-color: var(--primary);
  border-radius: 50%;
  margin: 0 auto 1rem;
  animation: spin 1s linear infinite;
}

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

/* Prediction Results */
.prediction-results {
  background: var(--card);
  padding: 2rem;
  border-radius: 12px;
  box-shadow: 0 1px 3px rgba(0,0,0,0.1);
}

.prediction-results h3 {
  margin: 1.5rem 0 1rem;
}

.prediction-results h3:first-child {
  margin-top: 0;
}

.rubric-scores {
  display: grid;
  gap: 0.75rem;
}

.score-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 0.75rem 1rem;
  background: var(--bg);
  border-radius: 8px;
}

.score-row .criteria {
  font-weight: 500;
}

.score-row .level {
  font-size: 0.85rem;
  color: var(--text-muted);
  margin-left: 0.5rem;
}

.score-row .score {
  font-weight: 700;
  color: var(--primary);
}

.score-row.total {
  background: var(--primary);
  color: white;
}

.score-row.total .score {
  color: white;
}

.feedback-content,
.suggestions-content {
  background: var(--bg);
  padding: 1.25rem;
  border-radius: 8px;
  white-space: pre-wrap;
}

/* Assignment Meta */
.assignment-meta {
  background: var(--card);
  padding: 1.5rem;
  border-radius: 12px;
  margin-bottom: 1.5rem;
  box-shadow: 0 1px 3px rgba(0,0,0,0.1);
}

.assignment-meta h3 {
  margin-bottom: 1rem;
}

.assignment-meta .prompt {
  color: var(--text-muted);
  white-space: pre-wrap;
}

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

.modal-content {
  background: var(--card);
  padding: 2rem;
  border-radius: 12px;
  width: 100%;
  max-width: 400px;
  box-shadow: 0 20px 25px -5px rgba(0,0,0,0.1);
}

.modal-content h2 {
  margin-bottom: 1.5rem;
}

/* Upload Toggle */
.upload-toggle {
  display: flex;
  gap: 0;
  margin-bottom: 1.5rem;
  border: 1px solid var(--border);
  border-radius: 8px;
  overflow: hidden;
}

.toggle-btn {
  flex: 1;
  padding: 12px;
  border: none;
  background: var(--bg);
  font-size: 1rem;
  cursor: pointer;
  transition: all 0.2s;
}

.toggle-btn:first-child {
  border-right: 1px solid var(--border);
}

.toggle-btn.active {
  background: var(--primary);
  color: white;
}

.toggle-btn:hover:not(.active) {
  background: var(--border);
}

/* File Drop Zone */
.file-drop-zone {
  border: 2px dashed var(--border);
  border-radius: 12px;
  padding: 3rem 2rem;
  text-align: center;
  cursor: pointer;
  transition: all 0.2s;
}

.file-drop-zone:hover,
.file-drop-zone.dragover {
  border-color: var(--primary);
  background: rgba(37, 99, 235, 0.05);
}

.drop-icon {
  font-size: 3rem;
  display: block;
  margin-bottom: 1rem;
}

.drop-content p {
  margin: 0.5rem 0;
}

.selected-file {
  margin-top: 1rem !important;
  color: var(--primary);
  font-weight: 600;
}

/* Responsive */
@media (max-width: 600px) {
  main {
    padding: 1rem;
  }

  .stats-bar {
    grid-template-columns: 1fr;
  }

  .form-actions {
    flex-direction: column;
  }

  .form-actions button {
    width: 100%;
  }
}
