* {
  box-sizing: border-box;
}

body {
  margin: 0;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "Noto Sans KR", sans-serif;
  background: #f3f4f7;
  color: #1f2937;
}

.app-shell {
  min-height: 100vh;
  display: flex;
}

.left-nav {
  width: 92px;
  background: #ffffff;
  border-right: 1px solid #e5e7eb;
  padding: 16px 10px;
  position: sticky;
  top: 0;
  height: 100vh;
  display: flex;
  flex-direction: column;
  gap: 8px;
  overflow-y: auto;
}

.logo-link {
  display: block;
  margin: 0 auto 8px;
  text-align: center;
}

.logo-img {
  max-width: 80px;
  height: auto;
  display: block;
  margin: 0 auto;
}

.nav-item {
  font-size: 12px;
  color: #374151;
  text-decoration: none;
  text-align: center;
  border-radius: 10px;
  padding: 8px 4px;
  display: block;
  cursor: pointer;
}

.nav-item:hover {
  background: #f3f4f6;
}

.nav-item.active {
  background: #e8f0fe;
  color: #1d4ed8;
}

.nav-item.nav-item-ghost {
  color: #9ca3af;
  font-size: 11px;
}

.nav-footer {
  margin-top: auto;
  padding-top: 8px;
}

.nav-separator {
  height: 1px;
  background: #e5e7eb;
  margin-bottom: 8px;
}

button.nav-item {
  background: none;
  border: none;
  width: 100%;
  font: inherit;
}

.content-area {
  flex: 1;
}

.topbar {
  background: #ffffff;
  border-bottom: 1px solid #e5e7eb;
  height: 68px;
  padding: 0 24px;
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.topbar h1 {
  margin: 0;
  font-size: 30px;
}

.top-action {
  border: none;
  background: #f59e0b;
  color: #fff;
  border-radius: 999px;
  padding: 10px 16px;
  cursor: pointer;
  font-weight: 600;
}

.top-action-link {
  text-decoration: none;
  border: none;
  background: #f59e0b;
  color: #fff;
  border-radius: 999px;
  padding: 10px 16px;
  cursor: pointer;
  font-weight: 600;
  font-family: inherit;
  font-size: 14px;
}

.container {
  max-width: 1260px;
  margin: 20px auto 40px;
  padding: 0 22px;
  display: grid;
  gap: 16px;
}

.panel {
  background: #ffffff;
  border-radius: 16px;
  padding: 18px;
  border: 1px solid #e5e7eb;
}

.hero {
  background: linear-gradient(135deg, #161b33 0%, #2f3c7e 100%);
  color: #fff;
}

.hero h2 {
  margin: 0 0 8px;
  font-size: 24px;
}

.hero p {
  margin: 0;
  color: #e5e7eb;
}

.panel h2 {
  margin-top: 0;
}

.section-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
}

.count-chip {
  border-radius: 999px;
  border: 1px solid #d1d5db;
  padding: 3px 10px;
  font-size: 13px;
  color: #4b5563;
}

.form-grid {
  display: grid;
  gap: 12px;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
}

.form-grid label {
  display: grid;
  gap: 6px;
  font-size: 14px;
}

.form-grid .full {
  grid-column: 1 / -1;
}

input,
select,
textarea,
button {
  font: inherit;
}

input,
select,
textarea {
  border: 1px solid #d1d5db;
  border-radius: 8px;
  padding: 10px;
}

button {
  border: none;
  background: #f59e0b;
  color: #fff;
  border-radius: 8px;
  padding: 10px 14px;
  cursor: pointer;
  width: fit-content;
}

.lecture-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(260px, 1fr));
  gap: 12px;
}

.lecture-card {
  display: grid;
  gap: 8px;
  border: 1px solid #e5e7eb;
  border-radius: 12px;
  padding: 10px;
  background: #fff;
  transition: transform 0.15s ease, box-shadow 0.15s ease;
}

.lecture-card:hover {
  transform: translateY(-1px);
  box-shadow: 0 8px 22px rgba(0, 0, 0, 0.08);
}

.lecture-link {
  display: grid;
  gap: 8px;
  text-decoration: none;
  color: inherit;
}

.lecture-card h3 {
  margin: 0;
}

.lecture-card p {
  margin: 0;
  color: #4b5563;
  font-size: 14px;
}

.lecture-card small {
  color: #6b7280;
}

.badge {
  display: inline-flex;
  width: fit-content;
  border-radius: 999px;
  padding: 3px 8px;
  font-size: 12px;
  font-weight: 600;
}

.badge.youtube {
  background: #fee2e2;
  color: #b91c1c;
}

.badge.ppt {
  background: #dbeafe;
  color: #1d4ed8;
}

.thumb {
  border-radius: 10px;
  padding: 12px;
  min-height: 88px;
  display: grid;
  gap: 3px;
  overflow: hidden;
  position: relative;
}

.thumb.youtube {
  background: linear-gradient(135deg, #7f1d1d, #ef4444);
  color: #fff;
}

.thumb.ppt {
  background: linear-gradient(135deg, #1d4ed8, #60a5fa);
  color: #fff;
}

.thumb-image {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: cover;
  opacity: 0.35;
}

.thumb-fallback {
  position: absolute;
  right: 8px;
  top: 8px;
  font-size: 11px;
  padding: 2px 6px;
  border-radius: 999px;
  background: rgba(17, 24, 39, 0.4);
  color: #fff;
  z-index: 1;
}

.thumb-kicker {
  font-size: 11px;
  opacity: 0.9;
  position: relative;
  z-index: 1;
}

.thumb strong {
  line-height: 1.3;
  position: relative;
  z-index: 1;
}

.thumb small {
  opacity: 0.9;
  position: relative;
  z-index: 1;
}

.tag-row {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

.tag-chip {
  border-radius: 999px;
  padding: 2px 8px;
  background: #f3f4f6;
  color: #4b5563;
  font-size: 12px;
}

.filter-panel,
.admin-panel {
  display: grid;
  gap: 10px;
}

.filter-grid {
  display: grid;
  gap: 10px;
  grid-template-columns: repeat(auto-fit, minmax(210px, 1fr));
}

.filter-grid label {
  display: grid;
  gap: 6px;
}

.filter-row-bottom {
  grid-column: 1 / -1;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 12px 0 0;
}

.category-radios {
  display: flex;
  flex-wrap: nowrap;
  gap: 16px;
  align-items: center;
}

.category-radios label {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  cursor: pointer;
  font-size: 14px;
  color: #374151;
}

.category-radios input[type="radio"] {
  margin: 0;
}

.category-radios-inline {
  display: flex;
  flex-wrap: wrap;
  gap: 12px 20px;
  align-items: center;
}

.category-radios-inline label {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  cursor: pointer;
  font-size: 14px;
  color: #374151;
}

.category-radios-inline input[type="radio"] {
  margin: 0;
}

.filter-actions {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-shrink: 0;
}

.link-muted {
  color: #6b7280;
  text-decoration: none;
}

.admin-mode-header {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 12px;
}

.admin-mode-header h2 {
  margin: 0;
}

.admin-mode-toggle {
  display: flex;
  align-items: center;
  gap: 12px;
  flex-wrap: wrap;
}

.admin-status {
  font-size: 13px;
  font-weight: 600;
  padding: 4px 10px;
  border-radius: 999px;
}

.admin-status.active {
  background: #dcfce7;
  color: #166534;
}

.admin-status.inactive {
  background: #fef3c7;
  color: #92400e;
}

.btn-admin-off {
  display: inline-block;
  padding: 6px 14px;
  font-size: 13px;
  color: #6b7280;
  background: #f3f4f6;
  border: 1px solid #e5e7eb;
  border-radius: 8px;
  text-decoration: none;
}

.btn-admin-off:hover {
  background: #e5e7eb;
  color: #374151;
}

.admin-activate-inline {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
}

.admin-activate-inline input[type="password"] {
  padding: 6px 10px;
  border: 1px solid #d1d5db;
  border-radius: 8px;
  font-size: 14px;
  min-width: 140px;
}

.admin-activate-inline button {
  padding: 6px 14px;
  font-size: 13px;
  background: #f59e0b;
  color: #fff;
  border: none;
  border-radius: 8px;
  cursor: pointer;
}

.admin-activate-inline button:hover {
  background: #d97706;
}

.admin-inline {
  display: flex;
  gap: 8px;
  align-items: center;
  flex-wrap: wrap;
}

.queue-status {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
  color: #374151;
  font-size: 13px;
}

.api-hint {
  margin: 4px 0 0;
  color: #6b7280;
  font-size: 13px;
}

.dashboard-grid {
  display: grid;
  gap: 10px;
  grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
}

.chart-grid {
  display: grid;
  gap: 10px;
  grid-template-columns: repeat(auto-fit, minmax(320px, 1fr));
}

.kpi-grid {
  display: grid;
  gap: 10px;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
}

.kpi-card {
  border: 1px solid #e5e7eb;
  border-radius: 10px;
  padding: 10px;
  background: #fff;
  display: grid;
  gap: 4px;
}

.kpi-card small {
  color: #6b7280;
}

.kpi-card b {
  font-size: 24px;
}

.mini-panel {
  border: 1px solid #e5e7eb;
  border-radius: 10px;
  padding: 10px;
  background: #fff;
}

.mini-panel h3 {
  margin: 0 0 8px;
  font-size: 15px;
}

.plain-list {
  list-style: none;
  margin: 0;
  padding: 0;
  display: grid;
  gap: 6px;
}

.plain-list li {
  display: grid;
  gap: 2px;
  font-size: 13px;
}

.bar-chart {
  min-height: 180px;
  border: 1px solid #f3f4f6;
  border-radius: 8px;
  padding: 8px;
  display: grid;
  grid-template-columns: repeat(24, minmax(0, 1fr));
  gap: 4px;
  align-items: end;
}

.bar-item {
  display: grid;
  gap: 4px;
  justify-items: center;
}

.bar-item small {
  font-size: 10px;
  color: #6b7280;
}

.bar {
  width: 100%;
  min-height: 2px;
  border-radius: 4px;
}

.bar.processed {
  background: #2563eb;
}

.bar.failed {
  background: #dc2626;
}

.inline {
  display: inline-flex;
  gap: 6px;
  align-items: center;
  font-size: 13px;
}

.event-table-wrap {
  overflow: auto;
  border: 1px solid #e5e7eb;
  border-radius: 10px;
}

.event-table {
  width: 100%;
  border-collapse: collapse;
  min-width: 900px;
  background: #fff;
}

.event-table th,
.event-table td {
  border-bottom: 1px solid #f3f4f6;
  padding: 10px;
  text-align: left;
  vertical-align: top;
  font-size: 13px;
}

.event-table th {
  background: #f9fafb;
  font-weight: 600;
}

.evt-type {
  width: fit-content;
  border-radius: 999px;
  padding: 2px 8px;
  color: #fff;
  font-size: 11px;
}

.evt-type.enqueue {
  background: #6b7280;
}

.evt-type.start {
  background: #2563eb;
}

.evt-type.success {
  background: #059669;
}

.evt-type.failed,
.evt-type.worker-error {
  background: #dc2626;
}

.admin-ok {
  color: #166534;
  margin: 0;
}

.admin-warn {
  color: #92400e;
  margin: 0;
}

.admin-error {
  color: #b91c1c;
  margin: 0 0 8px 0;
}

.delete-form {
  display: flex;
  justify-content: end;
}

.lecture-card-actions {
  display: flex;
  gap: 8px;
  align-items: center;
  flex-wrap: wrap;
  padding: 8px 0;
  margin-bottom: 4px;
  border-bottom: 1px solid #e5e7eb;
}

.lecture-card-actions .btn-edit {
  display: inline-block;
  padding: 6px 12px;
  font-size: 13px;
  color: #1d4ed8;
  background: #eff6ff;
  border: 1px solid #bfdbfe;
  border-radius: 8px;
  text-decoration: none;
  cursor: pointer;
}

.lecture-card-actions .btn-edit:hover {
  background: #dbeafe;
}

.delete-form-inline {
  display: inline;
}

.delete-form-inline button {
  padding: 6px 12px;
  font-size: 13px;
}

.form-actions {
  display: flex;
  gap: 12px;
  align-items: center;
}

.muted {
  color: #9ca3af;
  font-size: 12px;
}

.thumb-state-row {
  display: grid;
  gap: 4px;
}

.state-chip {
  width: fit-content;
  border-radius: 999px;
  padding: 2px 8px;
  font-size: 12px;
  font-weight: 600;
}

.state-chip.ready {
  background: #dcfce7;
  color: #166534;
}

.state-chip.processing {
  background: #dbeafe;
  color: #1d4ed8;
}

.state-chip.pending {
  background: #f3f4f6;
  color: #374151;
}

.state-chip.failed {
  background: #fee2e2;
  color: #b91c1c;
}

.error-text {
  color: #b91c1c;
}

.danger {
  background: #dc2626;
}

.ghost {
  background: #4b5563;
}

.viewer-wrap {
  max-width: 1260px;
  margin: 20px auto;
  padding: 0 24px 32px;
}

.back-link {
  text-decoration: none;
  display: inline-block;
  margin-bottom: 10px;
}

.description {
  color: #4b5563;
}

.youtube-frame {
  width: 100%;
  aspect-ratio: 16 / 9;
  border-radius: 12px;
  overflow: hidden;
  border: 1px solid #d1d5db;
  background: #000;
}

.youtube-frame iframe {
  width: 100%;
  height: 100%;
}

.ppt-tools {
  margin: 14px 0;
  color: #374151;
}

.slide-list {
  display: grid;
  gap: 12px;
}

.slide-card {
  border: 1px solid #e5e7eb;
  border-radius: 12px;
  background: #fff;
  padding: 16px;
}

.slide-card h2 {
  margin: 0;
  font-size: 18px;
}

.slide-card header p {
  margin: 4px 0 0;
  color: #4b5563;
}

.slide-image-wrap {
  margin: 12px 0;
  border-radius: 8px;
  overflow: hidden;
  background: #f3f4f6;
}
.slide-image {
  display: block;
  max-width: 100%;
  height: auto;
}

.slide-card ul {
  margin: 10px 0 0;
  padding-left: 20px;
  display: grid;
  gap: 6px;
}

.empty {
  color: #6b7280;
}

.subtitle {
  margin: 0 0 16px;
  color: #6b7280;
  font-size: 14px;
}

.search-bar-wrap {
  margin-bottom: 12px;
}

.search-input {
  width: 100%;
  max-width: 400px;
  padding: 10px 12px 10px 36px;
  border: 1px solid #d1d5db;
  border-radius: 8px;
}

.filter-tags {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 12px;
}

.filter-tag {
  padding: 6px 12px;
  border: 1px solid #d1d5db;
  border-radius: 999px;
  background: #fff;
  font-size: 13px;
  cursor: pointer;
}

.filter-tag:hover {
  background: #f3f4f6;
}

.ai-card-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
  gap: 16px;
}

.ai-card {
  border: 1px solid #e5e7eb;
  border-radius: 12px;
  padding: 16px;
}

.ai-card-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 8px;
}

.ai-card-icon {
  font-size: 24px;
}

.status-chip {
  font-size: 12px;
  padding: 2px 8px;
  border-radius: 6px;
}

.status-chip.public {
  background: #dcfce7;
  color: #166534;
}

.status-chip.private {
  background: #fef3c7;
  color: #92400e;
}

.ai-card h3 {
  margin: 0 0 8px;
  font-size: 16px;
}

.ai-card p {
  margin: 0 0 8px;
  font-size: 14px;
  color: #4b5563;
}

.chat-area {
  display: flex;
  flex-direction: column;
  height: 100vh;
}

.chat-main {
  flex: 1;
  display: flex;
  flex-direction: column;
  min-height: 0;
  max-width: 800px;
  margin: 0 auto;
  width: 100%;
  padding: 0 24px 24px;
}

.chat-messages {
  flex: 1;
  overflow-y: auto;
  padding: 20px 0;
}

.chat-welcome {
  padding: 40px 0;
  text-align: center;
}

.chat-welcome h2 {
  margin: 0 0 12px;
  font-size: 24px;
  color: #1f2937;
}

.chat-welcome p {
  margin: 0;
  color: #6b7280;
  font-size: 15px;
}

.chat-msg {
  margin-bottom: 16px;
  max-width: 85%;
}

.chat-msg-user {
  margin-left: auto;
}

.chat-msg-user .chat-msg-content {
  background: #f59e0b;
  color: #fff;
  padding: 12px 16px;
  border-radius: 16px 16px 4px 16px;
}

.chat-msg-assistant .chat-msg-content {
  background: #f3f4f6;
  color: #1f2937;
  padding: 12px 16px;
  border-radius: 16px 16px 16px 4px;
}

.chat-input-wrap {
  padding: 16px 0;
  border-top: 1px solid #e5e7eb;
}

.chat-form {
  display: flex;
  gap: 12px;
  align-items: flex-end;
}

.chat-model-select {
  flex-shrink: 0;
  width: 160px;
  height: 44px;
  padding: 0 12px;
  border: 1px solid #d1d5db;
  border-radius: 12px;
  font: inherit;
  font-size: 14px;
  background: #fff;
  cursor: pointer;
}

.chat-model-select:focus {
  outline: none;
  border-color: #f59e0b;
}

.chat-form textarea {
  flex: 1;
  min-height: 44px;
  max-height: 120px;
  padding: 12px 16px;
  border: 1px solid #d1d5db;
  border-radius: 12px;
  resize: none;
  font: inherit;
}

.chat-form textarea:focus {
  outline: none;
  border-color: #f59e0b;
  box-shadow: 0 0 0 2px rgba(245, 158, 11, 0.2);
}

.chat-send-btn {
  width: 44px;
  height: 44px;
  border-radius: 12px;
  background: #f59e0b;
  color: #fff;
  border: none;
  font-size: 18px;
  cursor: pointer;
  flex-shrink: 0;
}

.chat-send-btn:hover:not(:disabled) {
  background: #d97706;
}

.chat-send-btn:disabled {
  opacity: 0.6;
  cursor: not-allowed;
}

.chat-disclaimer {
  margin: 12px 0 0;
  font-size: 12px;
  color: #9ca3af;
}

.chat-placeholder {
  padding: 24px;
  text-align: center;
}

.chat-placeholder .muted {
  color: #9ca3af;
  font-size: 13px;
  margin-top: 8px;
}

.form-actions {
  display: flex;
  gap: 12px;
  margin-top: 16px;
}

.btn-ghost {
  background: #fff !important;
  color: #374151 !important;
  border: 1px solid #d1d5db !important;
}

.upload-zone {
  border: 2px dashed #d1d5db;
  border-radius: 12px;
  padding: 32px;
  text-align: center;
  color: #6b7280;
  font-size: 14px;
  cursor: pointer;
}

.upload-zone:hover {
  border-color: #f59e0b;
  background: #fffbeb;
}

.breadcrumb {
  margin: 0 0 16px;
  font-size: 14px;
  color: #6b7280;
}

.breadcrumb a {
  color: #1d4ed8;
  text-decoration: none;
}

.panel h3 {
  margin: 0 0 12px;
  font-size: 16px;
}

@media (max-width: 900px) {
  .left-nav {
    display: none;
  }
  .topbar {
    height: auto;
    padding: 14px 16px;
  }
  .topbar h1 {
    font-size: 24px;
  }
  .top-action {
    padding: 8px 12px;
  }
  .top-action-link {
    padding: 8px 12px;
  }
  .container,
  .viewer-wrap {
    padding: 0 12px;
  }
}

/* Admin token modal */
.modal-overlay {
  position: fixed;
  inset: 0;
  z-index: 1000;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 16px;
}
.modal-overlay[hidden] {
  display: none;
}
.modal-backdrop {
  position: absolute;
  inset: 0;
  background: rgba(0, 0, 0, 0.4);
}
.modal-content {
  position: relative;
  background: #fff;
  border-radius: 16px;
  padding: 24px;
  max-width: 400px;
  width: 100%;
  box-shadow: 0 20px 50px rgba(0, 0, 0, 0.2);
}
.modal-content h3 {
  margin: 0 0 8px;
  font-size: 20px;
}
.modal-desc {
  margin: 0 0 16px;
  color: #6b7280;
  font-size: 14px;
}
.admin-token-form input[type="password"] {
  width: 100%;
  padding: 10px 12px;
  border: 1px solid #e5e7eb;
  border-radius: 8px;
  font-size: 14px;
  margin-bottom: 12px;
}
.admin-token-form input:focus {
  outline: none;
  border-color: #f97316;
}
.modal-actions {
  display: flex;
  gap: 8px;
  justify-content: flex-end;
}
.modal-actions button {
  padding: 8px 16px;
  border-radius: 8px;
  font-size: 14px;
  cursor: pointer;
}
.modal-actions button[type="submit"] {
  background: #f97316;
  color: #fff;
  border: none;
}
.modal-actions button[type="submit"]:hover {
  background: #ea580c;
}
