:root {
  --page-bg: linear-gradient(160deg, #f5f8fc 0%, #eef3f8 45%, #f9fbfd 100%);
  --surface: #ffffff;
  --text-primary: #1e2a39;
  --text-secondary: #4d627a;
  --highlight: #38506a;
  --highlight-strong: #2e4258;
  --highlight-soft: #e8eef5;
  --darkmode-text-primary: #d2dfed;
  --darkmode-text-secondary: #b8c8da;
  --darkmode-highlight: #d5e1ee;
  --darkmode-highlight-strong: #a7b7c8;
  --darkmode-highlight-soft: #93a1b0;
  --radius-lg: 24px;
  --radius-md: 18px;
  --radius-sm: 14px;
  --shadow-soft: 0 14px 28px rgba(43, 67, 89, 0.08);
  --shadow-card: 0 10px 22px rgba(35, 57, 77, 0.1);
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  font-family: "Manrope", "Segoe UI", Arial, sans-serif;
  background: var(--page-bg);
  color: var(--text-primary);
  min-height: 100dvh;
}

img {
  max-width: 100%;
  display: block;
}

a {
  color: inherit;
  text-decoration: none;
}

.app-shell {
  width: min(100%, 760px);
  margin: 0 auto;
  padding: 16px 14px 28px;
}

.category-page .app-shell-category {
  min-height: 100dvh;
  display: flex;
  flex-direction: column;
  justify-content: flex-start;
}

.back-link {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  color: var(--highlight);
  font-weight: 700;
  margin-bottom: 14px;
}

.back-link::before {
  content: "\2190";
  font-size: 1rem;
}

.hero-card {
  position: relative;
  aspect-ratio: 1 / 1;
  border-radius: var(--radius-lg);
  padding: 18px;
  background: radial-gradient(circle at 20% 15%, #133755 0%, #05182f 40%, #041121 100%);
  box-shadow: var(--shadow-soft);
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  overflow: hidden;
}

.hero-card::after {
  content: "";
  position: absolute;
  width: 210px;
  height: 210px;
  background: radial-gradient(circle, rgba(56, 80, 106, 0.13) 0%, rgba(56, 80, 106, 0) 65%);
  top: -54px;
  right: -72px;
  pointer-events: none;
}

.hero-main {
  position: relative;
  z-index: 1;
  display: grid;
  gap: 10px;
}

.hero-logo {
  width: 88px;
  height: 88px;
  border-radius: 24px;
  padding: 10px;
  object-fit: cover;
  border: 2px solid #fff;
  box-shadow: 0 10px 18px rgba(41, 57, 73, 0.18);
  background-color: #0a213d;
}

.hero-title {
  margin: 0;
  font-family: "Nunito", "Manrope", sans-serif;
  font-size: clamp(1.3rem, 3.9vw, 1.8rem);
  color: var(--darkmode-text-primary);
  line-height: 1.15;
}

.hero-subtitle {
  margin: 0;
  font-size: 0.95rem;
  color: var(--darkmode-text-secondary);
  line-height: 1.45;
}

.hero-metrics {
  position: relative;
  z-index: 1;
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 10px;
}

.metric {
  background: rgba(56, 80, 106, 0.12);
  border: 1px solid rgba(56, 80, 106, 0.2);
  border-radius: var(--radius-sm);
  padding: 12px;
  display: grid;
  gap: 2px;
}

.metric-label {
  font-size: 0.8rem;
  color: var(--darkmode-text-secondary);
}

.metric-value {
  font-size: 1.35rem;
  color: var(--darkmode-highlight-strong);
  font-family: "Nunito", "Manrope", sans-serif;
}

.section-block {
  margin-top: 18px;
}

.section-head h2 {
  margin: 0 0 12px;
  font-family: "Nunito", "Manrope", sans-serif;
  font-size: 1.1rem;
  color: var(--highlight-strong);
}

.categories-grid {
  display: grid;
  gap: 12px;
  grid-template-columns: minmax(0, 1fr);
}

.category-card {
  min-height: 0;
  border-radius: var(--radius-md);
  overflow: hidden;
  position: relative;
  box-shadow: var(--shadow-soft);
  display: grid;
  grid-template-columns: 90px minmax(0, 1fr);
  gap: 12px;
  align-items: start;
  padding: 10px;
  background: var(--surface);
  border: 1px solid rgba(56, 80, 106, 0.14);
}

.category-thumb {
  width: 90px;
  aspect-ratio: 1 / 1;
  border-radius: var(--radius-sm);
  overflow: hidden;
  background: #dfe8f2;
}

.category-thumb-image {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.category-content {
  width: 100%;
  position: relative;
  z-index: 1;
  padding: 0;
  display: grid;
  gap: 8px;
}

.category-title {
  margin: 0;
  color: var(--text-primary);
  font-size: 0.95rem;
  line-height: 1.3;
}

.category-button {
  justify-self: start;
  border: 0;
  border-radius: 12px;
  background: #14324f;
  color: #edf5ff;
  font-family: "Nunito", "Manrope", sans-serif;
  font-weight: 800;
  font-size: 0.8rem;
  padding: 8px 12px;
  box-shadow: 0 8px 14px rgba(16, 31, 46, 0.2);
}

.categories-grid .category-card:last-child:nth-child(odd) {
  grid-column: 1 / -1;
  min-height: 0;
}

.hero-card-category {
  color: #fff;
  background-size: cover;
  background-position: center;
}

.hero-card-category::before {
  content: "";
  position: absolute;
  inset: 0;
  background: linear-gradient(180deg, rgba(22, 34, 47, 0.35) 0%, rgba(17, 26, 36, 0.88) 84%);
}

.hero-main-category,
.hero-card-category .hero-metrics {
  position: relative;
  z-index: 1;
}

.hero-card-category .hero-title,
.hero-card-category .hero-subtitle,
.hero-card-category .metric-label,
.hero-card-category .metric-value {
  color: #f8fbff;
}

.hero-card-category .metric {
  width: min(220px, 100%);
  background: rgba(255, 255, 255, 0.14);
  border-color: rgba(255, 255, 255, 0.22);
}

.course-strip {
  display: grid;
  grid-auto-flow: column;
  grid-auto-columns: minmax(155px, 44vw);
  gap: 12px;
  overflow-x: auto;
  padding: 6px 4px 14px;
  margin: 0 -4px;
  scroll-snap-type: x mandatory;
}

.course-card {
  display: flex;
  flex-direction: column;
  gap: 10px;
  scroll-snap-align: start;
}

.course-cover-link {
  display: block;
  color: inherit;
}

.course-cover-frame {
  position: relative;
  border-radius: var(--radius-md);
  overflow: hidden;
  box-shadow: var(--shadow-card);
}

.course-cover {
  width: 100%;
  aspect-ratio: 9 / 16;
  object-fit: cover;
  border-radius: 0;
  background: #dae4ef;
}

.course-cover-frame::after {
  content: "";
  position: absolute;
  inset: auto 0 0 0;
  height: 56%;
  background: linear-gradient(180deg, rgba(7, 16, 28, 0) 0%, rgba(7, 16, 28, 0.86) 100%);
}

.course-name-overlay {
  margin: 0;
  position: absolute;
  left: 10px;
  right: 10px;
  bottom: 10px;
  z-index: 1;
  font-size: 0.88rem;
  color: #f4f8ff;
  line-height: 1.35;
}

.course-action {
  margin-top: auto;
  background: #14324f;
  border-radius: 999px;
  padding: 5px 8px;
  box-shadow: 0 8px 14px rgba(16, 31, 46, 0.2);
}

.course-link {
  display: block;
  text-align: center;
  color: #edf5ff;
  font-weight: 800;
  font-size: 0.84rem;
  letter-spacing: 0.01em;
}

.helper-text {
  margin: 10px 4px 0;
  color: var(--text-secondary);
  font-size: 0.83rem;
}

.empty-state {
  background: var(--surface);
  border: 1px dashed rgba(56, 80, 106, 0.3);
  border-radius: var(--radius-md);
  padding: 16px;
  color: var(--text-secondary);
}

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  margin-bottom: 12px;
}

.topbar-user {
  margin: 0;
  padding: 8px 12px;
  border-radius: 999px;
  background: rgba(20, 50, 79, 0.1);
  color: var(--highlight-strong);
  font-size: 0.82rem;
  font-weight: 700;
}

.topbar-logout {
  border: 0;
  border-radius: 999px;
  background: #14324f;
  color: #edf5ff;
  font-family: "Nunito", "Manrope", sans-serif;
  font-weight: 800;
  font-size: 0.8rem;
  padding: 8px 14px;
  cursor: pointer;
}

.app-shell-login {
  max-width: 520px;
  min-height: 100dvh;
  display: flex;
  flex-direction: column;
  justify-content: center;
}

.login-card {
  background: var(--surface);
  border: 1px solid rgba(56, 80, 106, 0.14);
  border-radius: var(--radius-md);
  padding: 14px;
  box-shadow: var(--shadow-soft);
  display: grid;
  gap: 12px;
}

.form-field {
  display: grid;
  gap: 6px;
}

.field-label {
  color: var(--highlight-strong);
  font-size: 0.82rem;
  font-weight: 700;
}

.field-input {
  width: 100%;
  border-radius: 12px;
  border: 1px solid rgba(56, 80, 106, 0.28);
  padding: 11px 12px;
  font-size: 0.92rem;
  color: var(--text-primary);
  background: #fbfdff;
}

.field-input:focus {
  border-color: #1f4f79;
  outline: 2px solid rgba(31, 79, 121, 0.18);
  outline-offset: 1px;
}

.primary-button {
  border: 0;
  border-radius: 12px;
  background: #14324f;
  color: #edf5ff;
  font-family: "Nunito", "Manrope", sans-serif;
  font-weight: 800;
  font-size: 0.92rem;
  padding: 12px 14px;
  box-shadow: 0 10px 18px rgba(16, 31, 46, 0.2);
  cursor: pointer;
}

.primary-button[disabled] {
  opacity: 0.7;
  cursor: wait;
}

.helper-text.is-error {
  color: #a02424;
  font-weight: 700;
}

.helper-text.is-success {
  color: #22693f;
  font-weight: 700;
}

@media (min-width: 680px) {
  .app-shell {
    padding: 24px 20px 38px;
  }

  .hero-card {
    padding: 24px;
  }

  .categories-grid {
    gap: 14px;
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .category-thumb {
    width: 100px;
  }

  .course-strip {
    grid-auto-columns: minmax(165px, 24vw);
  }
}
