:root {
  color-scheme: light dark;
  --bg: #0b1020;
  --panel: #11182d;
  --panel-soft: rgba(255, 255, 255, 0.03);
  --strip: rgba(255, 255, 255, 0.02);
  --text: #e7ecf5;
  --muted: #b8c3d6;
  --accent: #6ea8fe;
  --accent-soft: #9ecbff;
  --accent-soft-hover: #c7e0ff;
  --border: #2a3553;
  --border-soft: rgba(255, 255, 255, 0.12);
  --menu-bg: #16203a;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  font-family: system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  background: var(--bg);
  color: var(--text);
}

a {
  color: var(--accent);
}

a:hover,
a:focus {
  color: var(--accent-soft-hover);
}

.wrap {
  width: min(1100px, calc(100% - 2rem));
  margin: 0 auto;
}

.site-header {
  border-bottom: 1px solid var(--border);
  background: var(--panel);
}

.site-header .wrap {
  display: flex;
  align-items: center;
  justify-content: space-between;
  min-height: 64px;
  gap: 1rem;
}

.brand {
  display: inline-flex;
  align-items: center;
  gap: 0.75rem;
  min-width: 0;
  color: var(--text);
  text-decoration: none;
  font-weight: 700;
}

.brand:hover,
.brand:focus {
  color: var(--text);
  text-decoration: none;
}

.brand-logo {
  display: block;
  height: 40px;
  width: auto;
  max-width: 160px;
  object-fit: contain;
}

.brand-text {
  white-space: nowrap;
}

.top-nav {
  display: flex;
  gap: 1rem;
  flex-wrap: wrap;
}

.top-nav a {
  color: var(--accent);
  text-decoration: none;
}

.top-nav a:hover,
.top-nav a:focus {
  text-decoration: underline;
}

.panel {
  padding: 1rem 1.1rem;
  border: 1px solid var(--border-soft);
  border-radius: 0.75rem;
  background: var(--panel-soft);
}

.main-panel {
  margin: 2rem 0;
}

.panel.narrow {
  max-width: 520px;
}

.login-form {
  display: grid;
  gap: 1rem;
}

.login-form label {
  display: grid;
  gap: 0.35rem;
  color: var(--muted);
}

.login-form input,
.login-form button,
.panel-toggle,
.breadcrumb-trigger {
  padding: 0.7rem 0.8rem;
  border-radius: 8px;
  border: 1px solid var(--border);
}

.login-form input,
.panel-toggle,
.breadcrumb-trigger {
  background: rgba(255, 255, 255, 0.04);
  color: var(--text);
}

.login-form button {
  background: var(--accent);
  color: #08111f;
  font-weight: 600;
  cursor: pointer;
}

.login-form button:hover,
.login-form button:focus {
  filter: brightness(1.05);
}

.error-message {
  color: #ffb4b4;
}

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

.panel-header h2 {
  margin: 0;
}

.panel-toggle {
  background: rgba(255, 255, 255, 0.04);
  color: inherit;
  cursor: pointer;
}

.panel-toggle:hover,
.panel-toggle:focus {
  background: rgba(255, 255, 255, 0.08);
}

.collapsible-panel.is-collapsed .panel-body {
  display: none;
}

.collapsible-panel.is-collapsed .panel-header {
  margin-bottom: 0;
}

.detail-page-shell {
  display: grid;
  gap: 1rem;
  margin: 2rem 0;
}

.breadcrumbs {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.35rem;
  padding: 0.2rem 0.5rem;
  border-radius: 0.5rem;
  margin-top: -1rem;
  background: var(--strip);
}

.breadcrumbs-loading {
  color: var(--muted);
}

.breadcrumb-separator {
  color: var(--muted);
  opacity: 0.8;
  margin: 0 0.15rem;
}

.breadcrumb-link,
.breadcrumb-current {
  font-size: 0.95rem;
  line-height: 1.2;
  padding: 0.3rem 0.15rem;
}

.breadcrumb-link {
  color: var(--accent-soft);
  text-decoration: none;
}

.breadcrumb-link:hover,
.breadcrumb-link:focus {
  color: var(--accent-soft-hover);
  text-decoration: underline;
}

.breadcrumb-current {
  color: var(--text);
  font-weight: 600;
}

.breadcrumb-dropdown {
  position: relative;
  display: inline-flex;
  align-items: center;
}

.breadcrumb-trigger {
  font: inherit;
  padding: 0.35rem 0.6rem;
  background: rgba(255, 255, 255, 0.035);
  color: var(--text);
  cursor: pointer;
}

.breadcrumb-trigger:hover,
.breadcrumb-trigger:focus {
  background: rgba(255, 255, 255, 0.08);
}

.breadcrumb-trigger::after {
  content: "▾";
  margin-left: 0.45rem;
  font-size: 0.8em;
  opacity: 0.85;
}

.breadcrumb-menu {
  position: absolute;
  top: calc(100% + 0.35rem);
  left: 0;
  min-width: 14rem;
  max-width: 22rem;
  max-height: 18rem;
  overflow-y: auto;
  padding: 0.35rem;
  border: 1px solid var(--border-soft);
  border-radius: 0.5rem;
  background: var(--menu-bg);
  box-shadow: 0 10px 24px rgba(0, 0, 0, 0.3);
  z-index: 20;
}

.breadcrumb-menu[hidden] {
  display: none;
}

.breadcrumb-menu a {
  display: block;
  padding: 0.5rem 0.65rem;
  border-radius: 0.35rem;
  color: var(--text);
  text-decoration: none;
}

.breadcrumb-menu a:hover,
.breadcrumb-menu a:focus {
  background: rgba(255, 255, 255, 0.08);
  color: var(--accent-soft-hover);
}

.course-page,
.week-page,
.subtopic-page,
.microlecture-page {
  display: grid;
  grid-template-columns: 18rem minmax(0, 1fr);
  gap: 1.25rem;
  align-items: start;
}

.course-content-column,
.week-content-column,
.subtopic-content-column,
.microlecture-content-column,
.courses-content-column {
  display: grid;
  gap: 1.25rem;
}

.course-sidebar,
.week-sidebar,
.subtopic-sidebar,
.microlecture-sidebar {
  position: sticky;
  top: 1rem;
  display: grid;
  gap: 1.25rem;
}

.proposal-page {
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  gap: 1.25rem;
  align-items: start;
}

.proposal-page .course-sidebar {
  position: static;
  top: auto;
}
.course-main,
.course-status,
.week-main,
.week-status,
.subtopic-main,
.subtopic-status,
.microlecture-main,
.microlecture-status,
.courses-main {
  min-width: 0;
}

.course-header,
.week-header,
.subtopic-header,
.microlecture-header {
  margin-bottom: 1rem;
}

.course-header h1,
.week-header h1,
.subtopic-header h1,
.microlecture-header h1 {
  margin: 0;
}

.course-subtitle,
.week-subtitle,
.week-context,
.subtopic-subtitle,
.subtopic-context,
.microlecture-subtitle,
.microlecture-context {
  margin-top: 0.35rem;
  opacity: 0.8;
  color: var(--muted);
}

.field-label {
  display: block;
  margin-bottom: 0.5rem;
  font-weight: 600;
}

.yaml-editor {
  width: 100%;
  min-height: 65vh;
  resize: vertical;
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  font-size: 0.95rem;
  line-height: 1.45;
  padding: 0.9rem;
  border-radius: 0.5rem;
  border: 1px solid rgba(255, 255, 255, 0.14);
  background: rgba(0, 0, 0, 0.35);
  color: #f5f7fb;
}

.tree-list,
.status-list,
.course-list,
.resource-list,
.microlecture-list {
  margin: 0;
  padding-left: 1.1rem;
}

.tree-list li,
.status-list li,
.course-list li,
.resource-list li,
.microlecture-list li {
  margin: 0.35rem 0;
}

.tree-list a,
.course-list a,
.resource-list a,
.microlecture-list a {
  color: var(--accent-soft);
  text-decoration: none;
}

.tree-list a:hover,
.tree-list a:focus,
.course-list a:hover,
.course-list a:focus,
.resource-list a:hover,
.resource-list a:focus,
.microlecture-list a:hover,
.microlecture-list a:focus {
  color: var(--accent-soft-hover);
  text-decoration: underline;
}

.resource-label,
.microlecture-label {
  font-weight: 600;
}

.resource-description {
  margin-top: 0.2rem;
  color: var(--muted);
  font-size: 0.92rem;
}

.courses-page {
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  gap: 1.25rem;
  align-items: start;
  margin: 2rem 0;
}

@media (max-width: 1000px) {
  .course-page,
  .week-page,
  .subtopic-page,
  .microlecture-page {
    grid-template-columns: 1fr;
  }

  .course-sidebar,
  .week-sidebar,
  .subtopic-sidebar,
  .microlecture-sidebar {
    position: static;
  }

  .yaml-editor {
    min-height: 28rem;
  }

  .breadcrumb-menu {
    min-width: 12rem;
    max-width: min(22rem, 90vw);
  }
}

.editor-actions {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  margin-bottom: 1rem;
}

.action-button {
  padding: 0.7rem 0.9rem;
  border-radius: 8px;
  border: 1px solid var(--border);
  background: var(--accent);
  color: #08111f;
  font-weight: 600;
  cursor: pointer;
}

.action-button:hover,
.action-button:focus {
  filter: brightness(1.05);
}

.action-button:disabled {
  opacity: 0.65;
  cursor: progress;
}

.save-message {
  color: var(--muted);
}


.sidebar-current {
  color: var(--text);
  font-weight: 600;
}

.resource-label,
.sidebar-current,
.tree-list a,
.resource-list li {
  overflow-wrap: anywhere;
  word-break: break-word;
}

.resource-page {
  display: grid;
  grid-template-columns: 18rem minmax(0, 1fr);
  gap: 1.25rem;
  align-items: start;
}

.resource-sidebar {
  position: sticky;
  top: 1rem;
}

.resource-content-column {
  display: grid;
  gap: 1.25rem;
}

.resource-header h1 {
  margin: 0;
}

.resource-context {
  margin-top: 0.35rem;
  opacity: 0.8;
  color: var(--muted);
}

.text-input {
  width: 100%;
  padding: 0.7rem 0.8rem;
  border-radius: 8px;
  border: 1px solid var(--border);
  background: rgba(255, 255, 255, 0.04);
  color: var(--text);
  margin-bottom: 1rem;
}

.sidebar-action {
  margin: 0 0 0.75rem 0;
}


.microlecture-create-form {
  margin-bottom: 1rem;
  padding-bottom: 1rem;
  border-bottom: 1px solid var(--border);
}

.compact-input {
  margin-bottom: 0.6rem;
}

.compact-action-button {
  width: 100%;
  justify-content: center;
}

.microlecture-row {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 0.75rem;
}

.microlecture-item {
  list-style: none;
}

.microlecture-meta {
  margin-top: 0.15rem;
  color: var(--muted);
  font-size: 0.8rem;
  opacity: 0.75;
  word-break: break-all;
}

.resource-row {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 0.75rem;
}

.resource-item {
  list-style: none;
}

.resource-meta {
  margin-top: 0.15rem;
  color: var(--muted);
  font-size: 0.85rem;
  word-break: break-all;
}

.inline-danger-button,
.danger-button {
  padding: 0.45rem 0.7rem;
  border-radius: 8px;
  border: 1px solid rgba(255, 120, 120, 0.35);
  background: rgba(255, 120, 120, 0.12);
  color: var(--text);
  cursor: pointer;
}

.inline-danger-button {
  font-size: 0.85rem;
  padding: 0.25rem 0.5rem;
}

.inline-danger-button:hover,
.inline-danger-button:focus,
.danger-button:hover,
.danger-button:focus {
  background: rgba(255, 120, 120, 0.2);
}

@media (max-width: 1000px) {
  .resource-page {
    grid-template-columns: 1fr;
  }

  .resource-sidebar {
    position: static;
  }
}

.table-scroll {
  overflow-x: auto;
}

.job-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.95rem;
}

.job-table th,
.job-table td {
  border-bottom: 1px solid var(--border);
  padding: 0.55rem 0.6rem;
  text-align: left;
  vertical-align: top;
}

.job-table th {
  color: var(--muted);
  font-weight: 600;
}

.job-table code {
  font-size: 0.85rem;
  word-break: break-all;
}

.job-status-badge {
  display: inline-block;
  border: 1px solid var(--border);
  border-radius: 999px;
  padding: 0.15rem 0.45rem;
  white-space: nowrap;
}

.job-summary-cell {
  min-width: 16rem;
}

.ai-workflow-panel {
  margin: 1.25rem 0;
  padding: 1rem;
  border: 1px solid var(--border-soft);
  border-radius: 0.75rem;
  background: rgba(255, 255, 255, 0.035);
}

.ai-workflow-panel h2 {
  margin-top: 0;
}

.helper-text {
  color: var(--muted);
  margin-top: 0.25rem;
}

.prompt-guidance-editor {
  width: 100%;
  resize: vertical;
  font: inherit;
  line-height: 1.45;
  padding: 0.75rem;
  border-radius: 0.5rem;
  border: 1px solid rgba(255, 255, 255, 0.14);
  background: rgba(0, 0, 0, 0.25);
  color: var(--text);
  margin-bottom: 0.75rem;
}

.proposal-list {
  margin: 0.75rem 0 0;
  padding-left: 1.25rem;
}

.proposal-list-item {
  margin-bottom: 0.75rem;
}

.proposal-meta,
.proposal-reason,
.proposal-diff-summary {
  color: var(--muted);
  font-size: 0.9rem;
  margin: 0.25rem 0;
}

.proposal-file-change-card,
.proposal-finding-card {
  border: 1px solid var(--border-soft);
  border-radius: 0.75rem;
  padding: 1rem;
  margin-bottom: 1rem;
  background: rgba(255, 255, 255, 0.025);
}

.proposal-file-change-card h3,
.proposal-finding-card h3 {
  margin-top: 0;
  overflow-wrap: anywhere;
}

.proposal-diff {
  max-height: 30rem;
  overflow: auto;
  white-space: pre-wrap;
  border: 1px solid var(--border-soft);
  border-radius: 0.5rem;
  padding: 0.75rem;
  background: rgba(0, 0, 0, 0.25);
  font-size: 0.85rem;
  line-height: 1.35;
}

.proposal-actions {
  display: flex;
  gap: 0.75rem;
  align-items: center;
  flex-wrap: wrap;
  margin-top: 0.75rem;
}

.proposal-nav-groups h3 {
  margin-bottom: 0.25rem;
}

.subtopic-create-form,
.microlecture-create-form {
  display: grid;
  gap: 0.45rem;
  margin-bottom: 0.9rem;
}

.subtopic-management-list,
.microlecture-list {
  display: grid;
  gap: 0.5rem;
}

.subtopic-management-item,
.microlecture-item {
  list-style: none;
}

.subtopic-management-row,
.microlecture-row,
.resource-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.5rem;
}

.subtopic-label,
.microlecture-label,
.resource-label {
  min-width: 0;
  overflow-wrap: anywhere;
}

.inline-control-group {
  display: inline-flex;
  flex-wrap: wrap;
  gap: 0.25rem;
  justify-content: flex-end;
}

.split-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 1rem;
}

.primary-link-button,
.secondary-action,
.form-actions button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 2.5rem;
  padding: 0.65rem 0.9rem;
  border-radius: 8px;
  border: 1px solid var(--border);
  text-decoration: none;
  font-weight: 600;
}

.primary-link-button,
.form-actions button {
  background: var(--accent);
  color: #08111f;
}

.primary-link-button:hover,
.primary-link-button:focus,
.form-actions button:hover,
.form-actions button:focus {
  color: #08111f;
  filter: brightness(1.05);
  text-decoration: none;
}

.secondary-action {
  background: rgba(255, 255, 255, 0.04);
  color: var(--text);
}

.secondary-action:hover,
.secondary-action:focus {
  color: var(--text);
  background: rgba(255, 255, 255, 0.08);
  text-decoration: none;
}

.stacked-form {
  display: grid;
  gap: 1rem;
  margin-top: 1rem;
}

.stacked-form label {
  display: grid;
  gap: 0.35rem;
  color: var(--muted);
}

.stacked-form input,
.stacked-form textarea,
.stacked-form select {
  width: 100%;
  padding: 0.7rem 0.8rem;
  border-radius: 8px;
  border: 1px solid var(--border);
  background: rgba(255, 255, 255, 0.04);
  color: var(--text);
  font: inherit;
}

.stacked-form textarea {
  min-height: 8rem;
  resize: vertical;
}

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

.field-grid.two-column {
  grid-template-columns: repeat(2, minmax(0, 1fr));
}

.field-grid.three-column {
  grid-template-columns: repeat(3, minmax(0, 1fr));
}

.form-help {
  margin: -0.5rem 0 0;
  color: var(--muted);
  font-size: 0.95rem;
}

.form-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 0.75rem;
  align-items: center;
}

.form-message {
  margin: 0;
}

@media (max-width: 760px) {
  .split-header,
  .field-grid.two-column,
  .field-grid.three-column {
    grid-template-columns: 1fr;
  }

  .split-header {
    display: grid;
  }
}

.course-wizard fieldset {
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 1rem;
}

.course-wizard legend {
  padding: 0 0.4rem;
  color: var(--text);
  font-weight: 700;
}

.wizard-progress {
  display: grid;
  gap: 0.5rem;
}

.wizard-progress-label {
  margin: 0;
  color: var(--muted);
  font-weight: 600;
}

.wizard-progress-track {
  height: 0.55rem;
  overflow: hidden;
  border: 1px solid var(--border);
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.04);
}

.wizard-progress-track span {
  display: block;
  height: 100%;
  background: var(--accent);
  transition: width 160ms ease-out;
}

.wizard-step[hidden] {
  display: none;
}

.wizard-review {
  display: grid;
  gap: 0.75rem;
  margin-top: 1rem;
}

.wizard-review p {
  margin: 0;
}

.wizard-review ul {
  margin: 0;
  padding-left: 1.25rem;
}
