.profile-page {
  min-height: 100vh;
  height: auto;
  background: var(--stage);
}

.profile-topbar {
  justify-content: space-between;
  position: sticky;
  top: 0;
  z-index: 10;
}

.profile-brand {
  padding: 0;
  text-decoration: none;
}

.back-link {
  color: var(--heading);
  font-weight: 700;
  font-size: 14px;
  text-decoration: none;
  border: 1px solid var(--line);
  border-radius: 30px;
  padding: 9px 16px;
  background: var(--panel);
}

.back-link:hover {
  border-color: var(--accent);
  color: var(--accent);
}

.profile-main {
  width: min(1100px, 100%);
  margin: 0 auto;
  padding: 28px 22px 120px;
  display: flex;
  flex-direction: column;
  gap: 28px;
}

.profile-tabs {
  display: flex;
  gap: 8px;
}

.profile-tab {
  min-height: 40px;
  padding: 0 16px;
  border-radius: 30px;
  border: 1px solid var(--line);
  background: var(--panel);
  color: var(--heading);
  font-weight: 700;
}

.profile-tab.is-selected {
  background: var(--accent);
  border-color: var(--accent);
  color: var(--accent-ink);
}

#subjectsTab,
#examsTab {
  display: flex;
  flex-direction: column;
  gap: 28px;
}

#subjectsTab[hidden],
#examsTab[hidden] { display: none; }

.past-exam-list {
  list-style: none;
  margin: 0;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.past-exam {
  display: flex;
  gap: 8px;
  align-items: stretch;
}

.past-exam-open {
  flex: 1;
  min-width: 0;
  text-align: left;
  text-decoration: none;
  color: var(--text);
  border-radius: 14px;
  border: 1px solid var(--line);
  background: var(--panel-soft);
  padding: 12px;
}

.past-exam-open:hover { border-color: var(--accent); }

.past-exam-open strong { display: block; color: var(--heading); }

.past-exam-open span {
  display: block;
  margin-top: 3px;
  color: var(--muted);
  font-size: 12px;
}

.past-exam-share,
.past-exam-remove {
  flex: 0 0 auto;
  border-radius: 14px;
  border: 1px solid var(--line);
  background: var(--panel);
  font-weight: 700;
  padding: 0 14px;
}

.past-exam-remove {
  display: grid;
  place-items: center;
  color: var(--danger);
}

.past-exam-remove:hover:not(:disabled) {
  border-color: var(--danger);
  background: #fbe5e5;
}

.past-exam-share.is-code {
  letter-spacing: 0.08em;
  font-variant-numeric: tabular-nums;
}

.profile-card {
  display: flex;
  align-items: center;
  gap: 18px;
  flex-wrap: wrap;
  padding: 22px;
  background: var(--panel);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
}

.profile-avatar {
  width: 64px;
  height: 64px;
  color: #6135d2;
}

.profile-id { flex: 1; min-width: 180px; }

.profile-id h1 {
  margin: 2px 0;
  font-size: 1.5rem;
  color: var(--heading);
}

.profile-email {
  margin: 0;
  color: var(--muted);
  font-size: 14px;
}

.profile-email a {
  color: var(--accent);
  font-weight: 700;
}

.profile-stats {
  display: flex;
  gap: 10px;
  margin: 0;
}

.profile-stats div {
  min-width: 96px;
  padding: 10px 14px;
  border-radius: 12px;
  background: var(--panel-soft);
  text-align: center;
}

.profile-stats dt {
  font-size: 11px;
  font-weight: 800;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--muted);
}

.profile-stats dd {
  margin: 2px 0 0;
  font-size: 1.4rem;
  font-weight: 800;
  color: var(--heading);
}

.subject-panel {
  padding: 22px;
  background: var(--panel);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
}

.subject-panel[hidden],
.subject-grid[hidden] { display: none; }

.subject-panel .subject-card.is-active { box-shadow: 0 6px 16px rgba(25, 25, 25, 0.06); }

.panel-empty {
  margin: 0;
  padding: 28px 16px;
  text-align: center;
  color: var(--muted);
  font-size: 14px;
  border: 1px dashed var(--line-strong);
  border-radius: 12px;
}

.section-head { margin-bottom: 14px; }

.section-head h2 {
  margin: 0 0 4px;
  font-size: 1.15rem;
  color: var(--heading);
}

.subject-grid {
  list-style: none;
  margin: 0;
  padding: 0;
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(240px, 1fr));
  gap: 16px;
}

.subject-card {
  position: relative;
  display: flex;
  flex-direction: column;
  gap: 10px;
  min-height: 200px;
  padding: 20px;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  transition: transform 0.15s ease, box-shadow 0.15s ease;
}

.subject-card.is-active { border-color: rgba(var(--ok-rgb), 0.35); }

.subject-card.is-active:hover {
  transform: translateY(-2px);
  box-shadow: 0 14px 28px rgba(25, 25, 25, 0.12);
}

.subject-card.is-inactive {
  background: #f1f4f8;
  box-shadow: none;
}

.subject-card.is-inactive .subject-icon,
.subject-card.is-inactive .subject-name,
.subject-card.is-inactive .subject-meta {
  filter: grayscale(1);
  opacity: 0.55;
}

.subject-card.in-cart {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(var(--accent-rgb), 0.15);
}

.bundle-card {
  background:
    radial-gradient(circle at 100% 0%, rgba(255, 213, 107, 0.35), transparent 45%),
    linear-gradient(150deg, #d84646 0%, #a82e2e 55%, #7a1d1d 100%);
  border: 1px solid #7a1d1d;
  box-shadow: 0 14px 30px rgba(var(--accent-rgb), 0.35);
}

.bundle-card:hover {
  transform: translateY(-3px);
  box-shadow: 0 20px 38px rgba(var(--accent-rgb), 0.45);
}

.bundle-card.in-cart {
  border-color: #ffd56b;
  box-shadow: 0 0 0 3px rgba(255, 213, 107, 0.6), 0 14px 30px rgba(var(--accent-rgb), 0.35);
}

.bundle-card .subject-name,
.bundle-card .price { color: #fff; }

.bundle-card .subject-meta,
.bundle-card .price small { color: rgba(255, 255, 255, 0.85); }

.bundle-icon {
  background: rgba(255, 255, 255, 0.18);
  border: 1px solid rgba(255, 255, 255, 0.35);
  font-size: 0.85rem;
}

.status-bundle {
  background: linear-gradient(135deg, #ffe08a 0%, #f5b82e 100%);
  color: #4a2c00;
  box-shadow: 0 4px 12px rgba(245, 184, 46, 0.55);
}

.status-bundle::before { content: "\2605"; }

.bundle-card .primary {
  background: #fff;
  color: var(--accent);
  border-color: #fff;
  font-weight: 800;
}

.bundle-card .primary:hover:not(:disabled) {
  background: #ffd56b;
  color: #4a2c00;
  border-color: #ffd56b;
}

.bundle-card .ghost {
  background: transparent;
  color: #fff;
  border-color: rgba(255, 255, 255, 0.6);
}

.bundle-card .ghost:hover {
  background: #fff;
  color: var(--accent);
  border-color: #fff;
}

.in-bundle {
  font-size: 12px;
  font-weight: 700;
  color: var(--accent);
}

.subject-icon {
  width: 44px;
  height: 44px;
  border-radius: 12px;
  display: grid;
  place-items: center;
  font-weight: 800;
  font-size: 1.05rem;
  color: var(--accent-ink);
}

.subject-name {
  margin: 0;
  font-size: 1.1rem;
  font-weight: 700;
  color: var(--heading);
}

.subject-meta {
  margin: 0;
  color: var(--muted);
  font-size: 13px;
  line-height: 1.45;
}

.status {
  position: absolute;
  top: 16px;
  right: 16px;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 4px 10px;
  border-radius: 999px;
  font-size: 11px;
  font-weight: 800;
  letter-spacing: 0.06em;
  text-transform: uppercase;
}

.status-active {
  background: rgba(var(--ok-rgb), 0.12);
  color: var(--ok);
}

.status-active::before {
  content: "";
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--ok);
  box-shadow: 0 0 0 3px rgba(var(--ok-rgb), 0.2);
}

.status-inactive {
  background: var(--line);
  color: var(--muted);
}

.card-foot {
  margin-top: auto;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
}

.price {
  font-weight: 800;
  font-size: 1.15rem;
  color: var(--heading);
}

.price small {
  font-size: 12px;
  font-weight: 600;
  color: var(--muted);
}

.card-foot .primary,
.card-foot .ghost {
  min-height: 38px;
  padding: 0 16px;
  font-weight: 600;
  font-size: 13px;
  white-space: nowrap;
}

.subject-card.is-inactive .card-foot .primary {
  background: var(--panel);
  color: var(--heading);
}

.subject-card.is-inactive .card-foot .primary:hover:not(:disabled) {
  background: var(--accent);
  color: var(--accent-ink);
}

.ghost {
  border-radius: 30px;
  border: 1px solid var(--line-strong);
  background: var(--panel);
  color: var(--heading);
}

.ghost:hover {
  border-color: var(--accent);
  color: var(--accent);
}

.open-link {
  color: var(--accent);
  font-weight: 700;
  font-size: 14px;
  text-decoration: none;
}

.open-link:hover { text-decoration: underline; }

.cart-bar {
  position: fixed;
  left: 50%;
  bottom: 18px;
  transform: translateX(-50%);
  width: min(720px, calc(100% - 28px));
  display: flex;
  align-items: center;
  gap: 16px;
  padding: 12px 14px 12px 20px;
  background: var(--panel);
  border-radius: 999px;
  box-shadow: 0 16px 36px rgba(25, 25, 25, 0.18);
  z-index: 20;
}

.cart-bar[hidden] { display: none; }

.cart-summary {
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
}

.cart-summary span {
  color: var(--muted);
  font-size: 12px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.cart-total {
  font-weight: 800;
  color: var(--heading);
}

.cart-bar .primary { padding: 0 20px; font-weight: 700; }

@media (max-width: 560px) {
  .profile-stats { width: 100%; }
  .profile-stats div { flex: 1; }
  .cart-bar { border-radius: 18px; }
}

@media (prefers-reduced-motion: reduce) {
  .subject-card { transition: none; }
}
