:root {
  color-scheme: light;
  --bg: #f6f7fb;
  --surface: #ffffff;
  --surface-2: #f1f4f8;
  --text: #1d1d1f;
  --muted: #70717a;
  --line: rgba(29, 29, 31, 0.1);
  --accent: #0071e3;
  --accent-2: #34a853;
  --warn: #b45309;
  --danger: #b42318;
  --shadow: 0 18px 48px rgba(29, 29, 31, 0.09);
  --soft-shadow: 0 8px 24px rgba(29, 29, 31, 0.07);
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  font-family:
    -apple-system, BlinkMacSystemFont, "SF Pro Display", "Segoe UI", Inter,
    sans-serif;
  color: var(--text);
  background: linear-gradient(180deg, #fbfbfd 0%, var(--bg) 100%);
}

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

button {
  border: 0;
  cursor: pointer;
  transition:
    transform 160ms ease,
    background 160ms ease,
    box-shadow 160ms ease,
    opacity 160ms ease;
}

button:hover {
  transform: translateY(-1px);
}

button:active {
  transform: translateY(0);
}

.hidden {
  display: none !important;
}

.eyebrow {
  margin: 0 0 10px;
  color: var(--accent);
  font-size: 0.76rem;
  font-weight: 800;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.muted,
.form-error {
  color: var(--muted);
  line-height: 1.7;
}

.form-error {
  min-height: 24px;
  margin: 14px 0 0;
  color: var(--danger);
}

.login-view {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 24px;
}

.login-panel {
  width: min(520px, 100%);
  padding: 44px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.82);
  backdrop-filter: blur(24px);
  box-shadow: var(--shadow);
}

.login-panel h1,
.progress-copy h1 {
  margin: 0;
  font-size: clamp(2.1rem, 7vw, 4rem);
  line-height: 1.05;
  letter-spacing: 0;
}

.login-copy {
  margin: 18px 0 0;
  color: var(--muted);
  line-height: 1.8;
}

.login-form {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 12px;
  margin-top: 28px;
}

.login-form input,
.toolbar input,
.import-panel input,
.import-panel select,
.import-panel textarea,
.topbar select,
.number-input {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 8px;
  color: var(--text);
  background: #fff;
  outline: none;
}

.login-form input,
.toolbar input,
.import-panel input,
.import-panel select,
.topbar select,
.number-input {
  min-height: 44px;
  padding: 0 14px;
}

.import-panel textarea {
  min-height: 220px;
  padding: 14px;
  resize: vertical;
}

.login-form input:focus,
.toolbar input:focus,
.import-panel input:focus,
.import-panel select:focus,
.import-panel textarea:focus,
.topbar select:focus,
.number-input:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(15, 118, 110, 0.13);
}

.login-form button,
.quick-login button,
.top-actions button,
.card-head button,
.import-panel button,
.material-form button,
.small-button,
.identity-card button,
.bulk-actions button,
.preview-tools button {
  min-height: 44px;
  padding: 0 16px;
  border-radius: 8px;
  color: #fff;
  background: var(--accent);
  font-weight: 700;
  box-shadow: 0 6px 16px rgba(0, 113, 227, 0.18);
}

.quick-login {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  margin-top: 16px;
}

.quick-login button {
  color: var(--accent);
  background: rgba(0, 113, 227, 0.1);
  box-shadow: none;
}

.app-shell {
  min-height: 100vh;
  display: grid;
  grid-template-columns: 280px minmax(0, 1fr);
}

.sidebar {
  position: sticky;
  top: 0;
  height: 100vh;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  padding: 28px;
  border-right: 1px solid var(--line);
  background: rgba(255, 255, 255, 0.78);
  backdrop-filter: blur(24px);
}

.sidebar h2 {
  margin: 0;
  font-size: 1.8rem;
}

.side-nav {
  display: grid;
  gap: 10px;
  margin-top: 34px;
}

.nav-button {
  min-height: 42px;
  padding: 0 14px;
  border-radius: 8px;
  color: var(--muted);
  background: transparent;
  font-weight: 800;
  text-align: left;
}

.nav-button.active,
.nav-button:hover {
  color: var(--text);
  background: var(--surface-2);
}

.identity-card {
  display: grid;
  gap: 8px;
  padding: 18px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
}

.identity-card span {
  color: var(--muted);
  font-size: 0.88rem;
}

.identity-card strong {
  font-size: 1.2rem;
}

.main-panel {
  min-width: 0;
  padding: 28px;
}

.topbar {
  display: flex;
  align-items: end;
  justify-content: space-between;
  gap: 18px;
  margin-bottom: 22px;
}

.topbar > div:first-child {
  width: min(520px, 100%);
}

.topbar label,
.field-label,
.import-panel label,
.material-form label {
  display: grid;
  gap: 8px;
  color: var(--muted);
  font-size: 0.9rem;
  font-weight: 800;
}

.top-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  justify-content: flex-end;
}

#clearProgressButton,
.danger-button {
  color: var(--danger);
  background: rgba(180, 35, 24, 0.09);
}

.section {
  display: none;
}

.active-section {
  display: block;
}

.hero-metrics {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 320px;
  gap: 18px;
}

.progress-card,
.plan-card,
.stat-card,
.task-panel,
.import-panel,
.empty-panel {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.82);
  backdrop-filter: blur(20px);
  box-shadow: var(--soft-shadow);
}

.progress-card {
  display: grid;
  grid-template-columns: 190px minmax(0, 1fr);
  gap: 28px;
  align-items: center;
  padding: 30px;
}

.progress-ring {
  position: relative;
  display: grid;
  place-items: center;
  width: 160px;
  height: 160px;
}

.progress-ring svg,
.progress-ring div {
  grid-area: 1 / 1;
}

.progress-ring svg {
  width: 100%;
  height: 100%;
  transform: rotate(-90deg);
}

.progress-ring circle {
  fill: none;
  stroke-width: 12;
}

.ring-bg {
  stroke: #e3e9ef;
}

.ring-value {
  stroke: var(--accent);
  stroke-linecap: round;
  stroke-dasharray: 314;
  stroke-dashoffset: 314;
  transition: stroke-dashoffset 240ms ease;
}

.progress-ring div {
  display: grid;
  text-align: center;
}

.progress-ring strong {
  font-size: 2rem;
}

.progress-ring span {
  color: var(--muted);
  font-size: 0.9rem;
}

.progress-copy p:last-child {
  color: var(--muted);
}

.linear-progress {
  height: 12px;
  overflow: hidden;
  border-radius: 999px;
  background: #e5ebf1;
}

.linear-progress span {
  display: block;
  width: 0%;
  height: 100%;
  border-radius: inherit;
  background: linear-gradient(90deg, var(--accent), #32d74b);
  transition: width 240ms ease;
}

.plan-card {
  padding: 24px;
}

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

.card-head h3,
.task-panel h3,
.import-panel h3,
.empty-panel h3 {
  margin: 0;
  font-size: 1.3rem;
}

.number-input {
  margin-top: 16px;
}

.stats-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 14px;
  margin-top: 18px;
}

.stat-card {
  display: grid;
  gap: 10px;
  padding: 20px;
}

.stat-card span {
  color: var(--muted);
  font-size: 0.9rem;
  font-weight: 800;
}

.stat-card strong {
  font-size: 1.6rem;
}

.task-panel,
.import-panel,
.empty-panel {
  margin-top: 18px;
  padding: 24px;
}

.pill {
  display: inline-flex;
  align-items: center;
  min-height: 30px;
  padding: 0 10px;
  border-radius: 999px;
  color: var(--accent);
  background: rgba(15, 118, 110, 0.1);
  font-size: 0.86rem;
  font-weight: 800;
}

.task-list,
.lesson-list {
  display: grid;
  gap: 10px;
  margin-top: 18px;
}

.task-row,
.lesson-item {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.86);
  box-shadow: 0 1px 0 rgba(29, 29, 31, 0.03);
}

.task-row {
  display: grid;
  grid-template-columns: auto 1fr auto;
  gap: 12px;
  align-items: center;
  padding: 14px;
}

.toolbar {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 14px;
  align-items: center;
}

.segmented {
  display: flex;
  padding: 4px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.78);
  backdrop-filter: blur(18px);
}

.segmented button {
  min-height: 36px;
  padding: 0 12px;
  border-radius: 6px;
  color: var(--muted);
  background: transparent;
  font-weight: 800;
}

.segmented button.active {
  color: #fff;
  background: var(--accent);
}

.bulkbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  margin-top: 14px;
  padding: 14px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.78);
  backdrop-filter: blur(18px);
}

.bulkbar > div:first-child {
  display: grid;
  gap: 4px;
}

.bulkbar span {
  color: var(--muted);
  font-size: 0.9rem;
}

.bulk-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  justify-content: flex-end;
}

.secondary-button,
.bulk-actions .secondary-button {
  color: var(--text);
  background: rgba(29, 29, 31, 0.07);
  box-shadow: none;
}

.lesson-main {
  display: grid;
  grid-template-columns: auto minmax(0, 1fr);
  gap: 12px;
  align-items: center;
  padding: 14px;
}

.check-wrap {
  display: grid;
  place-items: center;
  width: 44px;
  height: 44px;
}

.check-wrap input {
  position: absolute;
  opacity: 0;
}

.check-wrap span {
  width: 24px;
  height: 24px;
  border: 2px solid var(--line);
  border-radius: 8px;
  background: #fff;
}

.check-wrap input:checked + span {
  border-color: var(--accent);
  background: var(--accent);
  box-shadow: inset 0 0 0 5px #fff;
}

.lesson-open {
  display: grid;
  grid-template-columns: 56px minmax(0, 1fr) auto;
  gap: 12px;
  align-items: center;
  width: 100%;
  min-height: 40px;
  color: var(--text);
  background: transparent;
  text-align: left;
}

.lesson-code {
  color: var(--accent-2);
  font-weight: 900;
}

.lesson-title {
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.lesson-meta {
  color: var(--muted);
  white-space: nowrap;
}

.lesson-detail {
  display: none;
  padding: 0 18px 18px 64px;
}

.lesson-item.open .lesson-detail {
  display: grid;
  gap: 18px;
}

.material-form {
  display: grid;
  gap: 12px;
  padding: 16px;
  border-radius: 8px;
  background: rgba(241, 244, 248, 0.82);
}

.dropzone {
  min-height: 112px;
  place-items: center;
  padding: 18px;
  border: 1.5px dashed rgba(0, 113, 227, 0.35);
  border-radius: 8px;
  color: var(--accent);
  background: rgba(0, 113, 227, 0.06);
  text-align: center;
  cursor: pointer;
}

.dropzone input {
  position: absolute;
  opacity: 0;
  pointer-events: none;
}

.dropzone span {
  font-weight: 800;
}

.dropzone small {
  color: var(--muted);
}

.dropzone.dragging {
  border-color: var(--accent);
  background: rgba(0, 113, 227, 0.13);
}

.material-form textarea {
  min-height: 96px;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  resize: vertical;
}

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

.material-card {
  display: grid;
  gap: 10px;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.92);
  box-shadow: 0 6px 18px rgba(29, 29, 31, 0.06);
}

.material-card img {
  width: 100%;
  aspect-ratio: 4 / 3;
  object-fit: cover;
  border-radius: 8px;
  background: var(--surface-2);
}

.note-card {
  grid-column: 1 / -1;
  white-space: pre-wrap;
  line-height: 1.8;
}

.material-title {
  font-weight: 800;
  overflow-wrap: anywhere;
}

.material-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.material-actions a,
.material-actions button {
  min-height: 32px;
  padding: 0 10px;
  border-radius: 7px;
  color: var(--accent);
  background: rgba(0, 113, 227, 0.1);
  font-size: 0.86rem;
  font-weight: 800;
  text-decoration: none;
}

.materials-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 22px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.82);
  backdrop-filter: blur(20px);
  box-shadow: var(--soft-shadow);
}

.materials-head h3 {
  margin: 0;
  font-size: 1.35rem;
}

.material-library {
  display: grid;
  gap: 14px;
  margin-top: 16px;
}

.library-item {
  display: grid;
  grid-template-columns: minmax(180px, 280px) minmax(0, 1fr);
  gap: 14px;
  padding: 14px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.82);
  box-shadow: var(--soft-shadow);
}

.library-meta {
  display: grid;
  align-content: start;
  gap: 8px;
}

.library-meta span {
  color: var(--muted);
}

.library-material .material-card {
  box-shadow: none;
}

.pdf-frame {
  width: 100%;
  height: 420px;
  border: 1px solid var(--line);
  border-radius: 8px;
}

.import-panel {
  display: grid;
  gap: 18px;
  max-width: 860px;
}

.empty-panel {
  text-align: center;
}

.preview-dialog {
  width: min(980px, calc(100vw - 32px));
  border: 0;
  border-radius: 8px;
  padding: 54px 18px 18px;
  background: #101828;
}

.preview-dialog::backdrop {
  background: rgba(10, 18, 28, 0.72);
}

.preview-stage {
  max-height: 82vh;
  overflow: auto;
  display: grid;
  place-items: center;
  touch-action: none;
}

.preview-dialog img {
  display: block;
  max-width: 100%;
  max-height: 78vh;
  margin: 0 auto;
  border-radius: 6px;
  transform-origin: center center;
  transition: transform 120ms ease;
}

.dialog-close {
  position: absolute;
  top: 10px;
  right: 10px;
  width: 32px;
  height: 32px;
  border-radius: 8px;
  color: #fff;
  background: rgba(255, 255, 255, 0.16);
  font-size: 1.2rem;
}

.preview-tools {
  position: absolute;
  top: 10px;
  left: 14px;
  display: flex;
  align-items: center;
  gap: 8px;
  color: #fff;
}

.preview-tools button {
  min-width: 38px;
  min-height: 32px;
  padding: 0 10px;
  color: #fff;
  background: rgba(255, 255, 255, 0.16);
  box-shadow: none;
}

.preview-tools span {
  min-width: 54px;
  text-align: center;
  font-weight: 800;
}

@media (max-width: 1040px) {
  .app-shell {
    grid-template-columns: 1fr;
  }

  .sidebar {
    position: static;
    height: auto;
    gap: 18px;
  }

  .hero-metrics {
    grid-template-columns: 1fr;
  }

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

  .library-item,
  .materials-head,
  .bulkbar {
    grid-template-columns: 1fr;
    align-items: stretch;
  }

  .materials-head,
  .bulkbar {
    flex-direction: column;
  }
}

@media (max-width: 720px) {
  .login-panel,
  .main-panel,
  .sidebar {
    padding: 20px;
  }

  .login-form,
  .progress-card,
  .topbar,
  .toolbar,
  .task-row,
  .lesson-open {
    grid-template-columns: 1fr;
  }

  .topbar {
    align-items: stretch;
  }

  .progress-ring {
    width: 132px;
    height: 132px;
  }

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

  .lesson-detail {
    padding-left: 18px;
  }
}
