:root {
  --bg: #f5f5f7;
  --surface: #ffffff;
  --text-primary: #1d1d1f;
  --text-secondary: #86868b;
  --text-tertiary: #aeaeb2;
  --accent: #007AFF;
  --accent-hover: #0066d6;
  --border: rgba(0, 0, 0, 0.06);
  --border-strong: rgba(0, 0, 0, 0.1);
  --shadow-sm: 0 1px 3px rgba(0, 0, 0, 0.04), 0 1px 2px rgba(0, 0, 0, 0.02);
  --shadow-md: 0 4px 16px rgba(0, 0, 0, 0.06), 0 1px 4px rgba(0, 0, 0, 0.04);
  --shadow-lg: 0 16px 48px rgba(0, 0, 0, 0.1), 0 4px 16px rgba(0, 0, 0, 0.06);
  --radius-sm: 8px;
  --radius-md: 12px;
  --radius-lg: 16px;
  --radius-xl: 20px;
  --font: -apple-system, BlinkMacSystemFont, "SF Pro Display", "SF Pro Text", "Helvetica Neue", sans-serif;
  --transition: 0.2s cubic-bezier(0.25, 0.1, 0.25, 1);
}

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

body {
  font-family: var(--font);
  background: var(--bg);
  color: var(--text-primary);
  line-height: 1.47059;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  letter-spacing: -0.022em;
}

.hidden { display: none !important; }

/* ═══════════════════════════
   Auth Screen
   ═══════════════════════════ */

#auth-screen {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 100vh;
  min-height: 100dvh;
  background: var(--bg);
  animation: fadeIn 0.6s ease;
}

@keyframes fadeIn {
  from { opacity: 0; transform: translateY(12px); }
  to { opacity: 1; transform: translateY(0); }
}

.auth-container {
  width: 100%;
  max-width: 340px;
  padding: 0 20px;
  text-align: center;
}

.auth-icon {
  margin-bottom: 20px;
}

.auth-title {
  font-size: 28px;
  font-weight: 700;
  letter-spacing: -0.038em;
  color: var(--text-primary);
  margin-bottom: 6px;
}

.auth-subtitle {
  font-size: 15px;
  color: var(--text-secondary);
  margin-bottom: 28px;
  font-weight: 400;
}

.auth-field {
  margin-bottom: 16px;
}

.auth-field input {
  width: 100%;
  padding: 12px 16px;
  font-size: 17px;
  font-family: var(--font);
  background: var(--surface);
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-md);
  outline: none;
  transition: border-color var(--transition), box-shadow var(--transition);
  color: var(--text-primary);
  text-align: center;
  letter-spacing: 0.1em;
}

.auth-field input::placeholder {
  color: var(--text-tertiary);
  letter-spacing: normal;
}

.auth-field input:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(0, 122, 255, 0.15);
}

#auth-btn {
  width: 100%;
  padding: 12px;
  font-size: 17px;
  font-weight: 500;
  font-family: var(--font);
  background: var(--accent);
  color: #fff;
  border: none;
  border-radius: var(--radius-md);
  cursor: pointer;
  transition: background var(--transition), transform 0.1s;
}

#auth-btn:hover { background: var(--accent-hover); }
#auth-btn:active { transform: scale(0.98); }

/* ═══════════════════════════
   Navigation Bar
   ═══════════════════════════ */

.navbar {
  position: sticky;
  top: 0;
  z-index: 100;
  background: rgba(245, 245, 247, 0.72);
  backdrop-filter: saturate(180%) blur(20px);
  -webkit-backdrop-filter: saturate(180%) blur(20px);
  border-bottom: 0.5px solid var(--border);
}

.navbar-inner {
  max-width: 780px;
  margin: 0 auto;
  padding: 12px 24px;
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.nav-title {
  font-size: 21px;
  font-weight: 700;
  letter-spacing: -0.03em;
}

.nav-actions {
  display: flex;
  align-items: center;
  gap: 8px;
}

.nav-btn {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 7px 14px;
  font-size: 14px;
  font-weight: 500;
  font-family: var(--font);
  background: transparent;
  color: var(--accent);
  border: none;
  border-radius: var(--radius-xl);
  cursor: pointer;
  transition: background var(--transition);
}

.nav-btn:hover { background: rgba(0, 122, 255, 0.08); }

.nav-btn.primary {
  background: var(--accent);
  color: #fff;
}

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

/* ═══════════════════════════
   Content Area
   ═══════════════════════════ */

.content {
  max-width: 780px;
  margin: 0 auto;
  padding: 20px 24px 120px;
  animation: contentIn 0.5s ease;
}

@keyframes contentIn {
  from { opacity: 0; }
  to { opacity: 1; }
}

/* Resume */

.resume-card {
  width: 100%;
  display: grid;
  grid-template-columns: auto minmax(0, 1fr) auto;
  align-items: center;
  gap: 10px;
  margin-bottom: 20px;
  padding: 14px 16px;
  font-family: var(--font);
  text-align: left;
  background: var(--surface);
  border: 0.5px solid var(--border);
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-sm);
  cursor: pointer;
  transition: border-color var(--transition), box-shadow var(--transition), transform 0.1s;
}

.resume-card:hover {
  border-color: rgba(0, 122, 255, 0.28);
  box-shadow: var(--shadow-md);
}

.resume-card:active {
  transform: scale(0.99);
}

.resume-label {
  padding: 4px 8px;
  border-radius: 999px;
  background: var(--accent);
  color: #fff;
  font-size: 12px;
  font-weight: 600;
  white-space: nowrap;
}

.resume-title {
  min-width: 0;
  overflow: hidden;
  color: var(--text-primary);
  font-size: 15px;
  font-weight: 500;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.resume-meta {
  color: var(--text-secondary);
  font-size: 13px;
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
}

/* ═══════════════════════════
   Course Sections
   ═══════════════════════════ */

.course-section {
  margin-bottom: 24px;
  animation: sectionIn 0.4s ease both;
}

@keyframes sectionIn {
  from { opacity: 0; transform: translateY(8px); }
  to { opacity: 1; transform: translateY(0); }
}

.course-header {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px 0;
  cursor: pointer;
  user-select: none;
  transition: opacity var(--transition);
}

.course-header:hover { opacity: 0.7; }

.course-header .toggle {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 22px;
  height: 22px;
  color: var(--text-tertiary);
  font-size: 10px;
  transition: transform 0.25s cubic-bezier(0.25, 0.1, 0.25, 1);
  flex-shrink: 0;
}

.course-header.collapsed .toggle {
  transform: rotate(-90deg);
}

.course-name {
  font-size: 20px;
  font-weight: 600;
  letter-spacing: -0.03em;
}

.course-count {
  font-size: 14px;
  color: var(--text-tertiary);
  font-weight: 400;
  margin-left: 4px;
}

.course-body {
  background: var(--surface);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-sm);
  overflow: hidden;
  margin-top: 8px;
  border: 0.5px solid var(--border);
}

.course-body.collapsed {
  display: none;
}

/* ═══════════════════════════
   File Items
   ═══════════════════════════ */

.file-item {
  display: flex;
  align-items: center;
  padding: 13px 16px;
  gap: 12px;
  cursor: pointer;
  transition: background var(--transition);
  position: relative;
}

.file-item:not(:last-child)::after {
  content: "";
  position: absolute;
  bottom: 0;
  left: 52px;
  right: 16px;
  height: 0.5px;
  background: var(--border);
}

.file-item:hover { background: rgba(0, 0, 0, 0.02); }

.file-item.active {
  background: rgba(0, 122, 255, 0.06);
}

.file-item .index {
  font-size: 15px;
  font-weight: 500;
  color: var(--text-tertiary);
  min-width: 24px;
  text-align: right;
  font-variant-numeric: tabular-nums;
}

.file-item .type-badge {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 32px;
  height: 32px;
  border-radius: 8px;
  flex-shrink: 0;
  font-size: 13px;
  font-weight: 600;
}

.file-item .type-badge.audio {
  background: linear-gradient(135deg, #FF2D55, #FF6482);
  color: #fff;
}

.file-item .type-badge.video {
  background: linear-gradient(135deg, #5856D6, #AF52DE);
  color: #fff;
}

.file-item .title {
  flex: 1;
  min-width: 0;
  font-size: 15px;
  font-weight: 400;
  color: var(--text-primary);
  letter-spacing: -0.01em;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.file-item .progress-time {
  padding: 2px 6px;
  border-radius: 999px;
  background: rgba(0, 122, 255, 0.08);
  color: var(--accent);
  font-size: 12px;
  font-weight: 500;
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
}

.file-item .play-indicator {
  color: var(--accent);
  opacity: 0;
  transition: opacity var(--transition);
  display: flex;
  align-items: center;
}

.file-item:hover .play-indicator,
.file-item.active .play-indicator {
  opacity: 1;
}

/* ═══════════════════════════
   Attachments
   ═══════════════════════════ */

.attachments {
  padding: 12px 16px;
  border-top: 0.5px solid var(--border);
}

.attachments-label {
  font-size: 12px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--text-tertiary);
  margin-bottom: 8px;
}

.attachment-item {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 6px 0;
}

.attachment-item a {
  font-size: 14px;
  color: var(--accent);
  text-decoration: none;
  font-weight: 400;
  transition: opacity var(--transition);
}

.attachment-item a:hover { opacity: 0.7; }

.attachment-icon {
  color: var(--text-tertiary);
  display: flex;
}

/* ═══════════════════════════
   Player Bar
   ═══════════════════════════ */

#player-bar {
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  z-index: 200;
  background: rgba(255, 255, 255, 0.88);
  backdrop-filter: saturate(180%) blur(20px);
  -webkit-backdrop-filter: saturate(180%) blur(20px);
  border-top: 0.5px solid var(--border);
  animation: slideUp 0.35s cubic-bezier(0.25, 0.1, 0.25, 1);
}

@keyframes slideUp {
  from { transform: translateY(100%); }
  to { transform: translateY(0); }
}

.player-inner {
  max-width: 780px;
  margin: 0 auto;
  padding: 12px 24px 16px;
}

.player-info {
  display: flex;
  align-items: baseline;
  gap: 8px;
  margin-bottom: 8px;
}

.player-now {
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--accent);
}

.player-track {
  font-size: 15px;
  font-weight: 500;
  color: var(--text-primary);
  letter-spacing: -0.01em;
}

#player-bar audio {
  width: 100%;
  height: 36px;
  border-radius: 8px;
}

#player-bar video {
  width: 100%;
  max-height: 280px;
  border-radius: var(--radius-md);
  background: #000;
}

/* ═══════════════════════════
   Modal
   ═══════════════════════════ */

.modal-overlay {
  position: fixed;
  inset: 0;
  z-index: 300;
  background: rgba(0, 0, 0, 0.32);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  display: flex;
  align-items: flex-end;
  justify-content: center;
  animation: overlayIn 0.2s ease;
}

@keyframes overlayIn {
  from { opacity: 0; }
  to { opacity: 1; }
}

.modal-sheet {
  width: 100%;
  max-width: 480px;
  background: var(--surface);
  border-radius: var(--radius-xl) var(--radius-xl) 0 0;
  box-shadow: var(--shadow-lg);
  animation: sheetUp 0.35s cubic-bezier(0.25, 0.1, 0.25, 1);
  max-height: 90vh;
  overflow-y: auto;
}

@media (min-width: 600px) {
  .modal-overlay { align-items: center; }
  .modal-sheet {
    border-radius: var(--radius-xl);
    max-height: 80vh;
  }
}

@keyframes sheetUp {
  from { transform: translateY(40px); opacity: 0; }
  to { transform: translateY(0); opacity: 1; }
}

.modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 20px 24px 0;
}

.modal-header h2 {
  font-size: 20px;
  font-weight: 700;
  letter-spacing: -0.03em;
}

.modal-close {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 30px;
  height: 30px;
  border-radius: 50%;
  background: rgba(0, 0, 0, 0.06);
  border: none;
  cursor: pointer;
  color: var(--text-secondary);
  transition: background var(--transition);
}

.modal-close:hover { background: rgba(0, 0, 0, 0.1); }

.modal-body {
  padding: 20px 24px;
}

.field {
  margin-bottom: 18px;
}

.field-label {
  display: block;
  font-size: 13px;
  font-weight: 600;
  color: var(--text-secondary);
  margin-bottom: 6px;
  letter-spacing: -0.01em;
}

.field-input {
  width: 100%;
  padding: 10px 14px;
  font-size: 15px;
  font-family: var(--font);
  background: var(--bg);
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-sm);
  outline: none;
  color: var(--text-primary);
  transition: border-color var(--transition), box-shadow var(--transition);
  -webkit-appearance: none;
}

.field-input:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(0, 122, 255, 0.12);
}

select.field-input {
  cursor: pointer;
}

/* File drop zone */
.file-drop {
  position: relative;
  border: 2px dashed var(--border-strong);
  border-radius: var(--radius-md);
  padding: 28px;
  text-align: center;
  transition: border-color var(--transition), background var(--transition);
  cursor: pointer;
}

.file-drop:hover,
.file-drop.drag-over {
  border-color: var(--accent);
  background: rgba(0, 122, 255, 0.03);
}

.file-drop input[type="file"] {
  position: absolute;
  inset: 0;
  opacity: 0;
  cursor: pointer;
}

.file-drop-content {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
  pointer-events: none;
}

.file-drop-content span {
  font-size: 14px;
  color: var(--text-tertiary);
}

.upload-progress {
  font-size: 14px;
  color: var(--text-secondary);
  padding: 10px 14px;
  background: var(--bg);
  border-radius: var(--radius-sm);
  margin-top: -8px;
}

.modal-footer {
  padding: 0 24px 24px;
}

.btn-primary {
  width: 100%;
  padding: 13px;
  font-size: 17px;
  font-weight: 600;
  font-family: var(--font);
  background: var(--accent);
  color: #fff;
  border: none;
  border-radius: var(--radius-md);
  cursor: pointer;
  transition: background var(--transition), transform 0.1s;
  letter-spacing: -0.01em;
}

.btn-primary:hover { background: var(--accent-hover); }
.btn-primary:active { transform: scale(0.98); }
.btn-primary:disabled {
  opacity: 0.5;
  cursor: not-allowed;
  transform: none;
}

/* ═══════════════════════════
   Loading / Empty State
   ═══════════════════════════ */

.empty-state {
  text-align: center;
  padding: 80px 20px;
}

.empty-state p {
  font-size: 17px;
  color: var(--text-tertiary);
}

.loading-text {
  text-align: center;
  padding: 60px 20px;
  font-size: 15px;
  color: var(--text-tertiary);
}

.error-text {
  text-align: center;
  padding: 40px 20px;
  font-size: 15px;
  color: #FF3B30;
}

/* ═══════════════════════════
   Responsive
   ═══════════════════════════ */

@media (max-width: 600px) {
  .navbar-inner { padding: 10px 16px; }
  .nav-title { font-size: 18px; }
  .content { padding: 16px 16px 120px; }
  .resume-card {
    grid-template-columns: minmax(0, 1fr) auto;
    gap: 6px 10px;
  }
  .resume-label {
    grid-column: 1 / -1;
    width: max-content;
  }
  .course-name { font-size: 18px; }
  .file-item { padding: 12px 14px; gap: 10px; }
  .file-item:not(:last-child)::after { left: 46px; right: 14px; }
  .player-inner { padding: 10px 16px 14px; }
  .modal-body { padding: 16px 20px; }
  .modal-header { padding: 16px 20px 0; }
  .modal-footer { padding: 0 20px 20px; }
}
