:root {
  --dash-bg: #f3efe4;
  --dash-panel: #fffdf8;
  --dash-text: #10251f;
  --dash-muted: #64716b;
  --dash-border: rgba(16, 37, 31, 0.14);
  --dash-lime: #b6db45;
  --dash-lime-dark: #6d8b17;
  --dash-orange: #ff9b63;
  --dash-blue: #4569e8;
  --dash-shadow: 0 12px 34px rgba(16, 37, 31, 0.08);
}

* { box-sizing: border-box; }

body.dashboard-page {
  min-width: 320px;
  margin: 0;
  color: var(--dash-text);
  background: var(--dash-bg);
  overflow: hidden;
}

.dashboard-container {
  display: grid;
  grid-template-columns: 256px minmax(0, 1fr);
  min-height: 100vh;
  min-height: 100dvh;
}

.mobile-bar { display: none; }

.dashboard-sidebar {
  z-index: 20;
  min-height: 0;
  padding: 24px 18px;
  display: flex;
  flex-direction: column;
  background: var(--dash-panel);
  border-right: 1px solid var(--dash-border);
}

.sidebar-brand { margin: 0 6px 32px; }
.sidebar-brand-link {
  display: flex;
  align-items: center;
  gap: 11px;
  color: var(--dash-text);
  text-decoration: none;
}
.sidebar-brand-link .brand-mark {
  width: 38px;
  height: 38px;
  border-radius: 11px;
  display: grid;
  place-items: center;
  color: var(--dash-text);
  background: var(--dash-lime);
  font-weight: 900;
  box-shadow: 0 5px 14px rgba(109, 139, 23, 0.22);
}
.sidebar-brand-link .brand-name { font-size: 17px; }

.sidebar-nav {
  min-height: 0;
  flex: 1;
  overflow-y: auto;
  overscroll-behavior: contain;
  scrollbar-width: thin;
}
.sidebar-label {
  margin: 0 10px 8px;
  color: var(--dash-muted);
  font-size: 11px;
  font-weight: 850;
  letter-spacing: 0.12em;
  text-transform: uppercase;
}
.sidebar-label-spaced { margin-top: 28px; }

.nav-item {
  width: 100%;
  min-height: 44px;
  margin: 2px 0;
  padding: 9px 11px;
  display: grid;
  grid-template-columns: 29px minmax(0, 1fr) auto;
  gap: 9px;
  align-items: center;
  border: 0;
  border-radius: 11px;
  color: var(--dash-text);
  background: transparent;
  text-align: left;
  text-decoration: none;
  font: inherit;
  font-size: 14px;
  font-weight: 720;
  cursor: pointer;
  transition: color 160ms ease, background 160ms ease, transform 160ms ease;
}
.nav-item:hover { background: rgba(182, 219, 69, 0.18); }
.nav-item.is-active { color: #fff; background: var(--dash-text); }
.nav-item:active { transform: scale(0.985); }
.nav-item:disabled { opacity: 0.38; cursor: not-allowed; }
.nav-item small { color: inherit; opacity: 0.58; font-size: 11px; }
.nav-icon {
  width: 29px;
  height: 29px;
  border-radius: 9px;
  display: grid;
  place-items: center;
  background: rgba(16, 37, 31, 0.07);
  font-size: 13px;
  font-weight: 900;
}
.nav-item.is-active .nav-icon { color: var(--dash-text); background: var(--dash-lime); }
.sidebar-footer { padding-top: 14px; border-top: 1px solid var(--dash-border); }
.sidebar-scrim { display: none; }

.dashboard-main {
  min-width: 0;
  height: 100vh;
  height: 100dvh;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

.dashboard-header {
  z-index: 8;
  min-height: 76px;
  padding: 13px clamp(20px, 3vw, 42px);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 24px;
  flex: 0 0 auto;
  background: rgba(255, 253, 248, 0.9);
  border-bottom: 1px solid var(--dash-border);
  backdrop-filter: blur(18px);
}

.search-wrap {
  width: min(580px, 70%);
  min-height: 48px;
  padding: 0 10px 0 15px;
  display: flex;
  align-items: center;
  gap: 10px;
  border: 1px solid transparent;
  border-radius: 15px;
  background: var(--dash-bg);
  transition: background 160ms ease, border-color 160ms ease, box-shadow 160ms ease;
}
.search-wrap:focus-within {
  background: #fff;
  border-color: rgba(69, 105, 232, 0.5);
  box-shadow: 0 0 0 4px rgba(69, 105, 232, 0.1);
}
.search-wrap svg {
  width: 20px;
  flex: 0 0 auto;
  fill: none;
  stroke: currentColor;
  stroke-linecap: round;
  stroke-width: 1.8;
  opacity: 0.58;
}
.search-wrap input {
  min-width: 0;
  flex: 1;
  border: 0;
  outline: 0;
  color: var(--dash-text);
  background: transparent;
  font-size: 15px;
}
.search-wrap input::placeholder { color: #7b8681; }
.search-wrap kbd {
  padding: 2px 8px;
  color: var(--dash-muted);
  border: 1px solid var(--dash-border);
  border-bottom-width: 2px;
  border-radius: 6px;
  background: var(--dash-panel);
  font: 12px/1.5 inherit;
}
.search-clear {
  width: 30px;
  height: 30px;
  padding: 0;
  border: 0;
  border-radius: 50%;
  background: rgba(16, 37, 31, 0.08);
  cursor: pointer;
  font-size: 20px;
  line-height: 1;
}
.home-link { color: var(--dash-text); font-size: 13px; font-weight: 850; text-underline-offset: 5px; }

.dashboard-content {
  flex: 1;
  min-height: 0;
  padding: clamp(24px, 4vw, 54px);
  overflow-y: auto;
  overscroll-behavior: contain;
  scrollbar-gutter: stable;
}
.content-header {
  margin-bottom: 24px;
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 24px;
}
.content-header .eyebrow { margin-bottom: 10px; color: var(--dash-lime-dark); }
.content-header h1 { margin: 0; font-size: clamp(35px, 4vw, 54px); line-height: 0.98; letter-spacing: -0.055em; }
.content-header > div > p:last-child { margin: 14px 0 0; color: var(--dash-muted); font-size: 14px; }
.button-quiet {
  min-height: 42px;
  padding: 9px 16px;
  border: 1px solid var(--dash-border);
  color: var(--dash-text);
  background: var(--dash-panel);
  cursor: pointer;
}

.studio-callout {
  position: relative;
  min-height: 112px;
  margin-bottom: 22px;
  padding: 23px clamp(24px, 4vw, 40px);
  display: grid;
  grid-template-columns: auto minmax(0, 1fr) auto;
  align-items: center;
  gap: 18px;
  overflow: hidden;
  border-radius: 20px;
  color: #fff;
  background: var(--dash-text);
}
.studio-callout-badge {
  padding: 6px 10px;
  border-radius: 999px;
  color: var(--dash-text);
  background: var(--dash-orange);
  font-size: 10px;
  font-weight: 950;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}
.studio-callout strong { display: block; font-size: 17px; }
.studio-callout p { max-width: 760px; margin: 3px 0 0; color: #c7d2cd; font-size: 13px; line-height: 1.5; }
.studio-callout-icon { color: var(--dash-lime); font: 62px/1 Georgia, serif; opacity: 0.85; }

.quick-stats {
  margin-bottom: 25px;
  display: flex;
  gap: 9px;
  overflow-x: auto;
  scrollbar-width: none;
}
.quick-stats::-webkit-scrollbar { display: none; }
.stat-pill {
  min-height: 42px;
  padding: 9px 13px;
  flex: 0 0 auto;
  border: 1px solid var(--dash-border);
  border-radius: 12px;
  color: var(--dash-muted);
  background: var(--dash-panel);
  box-shadow: 0 4px 14px rgba(16, 37, 31, 0.04);
  cursor: pointer;
  font: inherit;
  font-size: 13px;
  font-weight: 800;
}
.stat-pill span { margin-left: 5px; opacity: 0.66; font-size: 11px; }
.stat-pill:hover { border-color: rgba(109, 139, 23, 0.55); }
.stat-pill.is-active { color: var(--dash-text); border-color: var(--dash-lime); background: var(--dash-lime); }

.dashboard-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(min(100%, 285px), 1fr));
  gap: 16px;
}
.dash-card {
  min-height: 330px;
  padding: 22px;
  display: flex;
  flex-direction: column;
  border: 1px solid var(--dash-border);
  border-radius: 18px;
  background: var(--dash-panel);
  box-shadow: 0 5px 18px rgba(16, 37, 31, 0.045);
  content-visibility: auto;
  contain-intrinsic-size: 330px;
  transition: transform 180ms ease, box-shadow 180ms ease, border-color 180ms ease;
}
.dash-card:hover { transform: translateY(-3px); border-color: rgba(109, 139, 23, 0.42); box-shadow: var(--dash-shadow); }
.dash-card-top { display: flex; align-items: center; justify-content: space-between; gap: 12px; }
.dash-card-grade {
  padding: 5px 9px;
  border-radius: 99px;
  color: #536719;
  background: rgba(182, 219, 69, 0.22);
  font-size: 10px;
  font-weight: 900;
  letter-spacing: 0.07em;
  text-transform: uppercase;
}
.save-resource {
  width: 38px;
  height: 38px;
  padding: 0;
  display: grid;
  place-items: center;
  border: 1px solid var(--dash-border);
  border-radius: 50%;
  color: #87908b;
  background: transparent;
  cursor: pointer;
  font-size: 16px;
}
.save-resource:hover { color: var(--dash-text); background: rgba(255, 155, 99, 0.15); }
.save-resource.is-saved { color: var(--dash-text); border-color: var(--dash-orange); background: var(--dash-orange); }
.dash-card-topic {
  margin: 23px 0 6px;
  color: var(--dash-blue);
  font-size: 11px;
  font-weight: 900;
  letter-spacing: 0.07em;
  text-transform: uppercase;
}
.dash-card h2 { margin: 0; font-size: 21px; line-height: 1.12; letter-spacing: -0.035em; }
.dash-card-description { margin: 10px 0 0; color: var(--dash-muted); font-size: 13px; line-height: 1.52; }
.dash-card-meta { margin: 17px 0; display: flex; gap: 6px; flex-wrap: wrap; }
.dash-card-meta span { padding: 4px 7px; border-radius: 7px; color: var(--dash-muted); background: var(--dash-bg); font-size: 10px; font-weight: 750; }
.dash-card-actions { margin-top: auto; display: grid; gap: 7px; }
.dash-btn {
  min-height: 43px;
  padding: 9px 12px;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  border: 1px solid var(--dash-border);
  border-radius: 11px;
  color: var(--dash-text);
  background: var(--dash-bg);
  text-align: center;
  text-decoration: none;
  font-size: 12px;
  font-weight: 880;
}
.dash-btn > span { width: 21px; height: 21px; display: grid; place-items: center; border-radius: 6px; background: rgba(16, 37, 31, 0.09); font-size: 10px; }
.dash-btn:hover { border-color: var(--dash-lime); background: rgba(182, 219, 69, 0.22); }
.dash-btn-primary { color: #fff; border-color: var(--dash-text); background: var(--dash-text); }
.dash-btn-primary > span { color: var(--dash-text); background: var(--dash-lime); }
.dash-btn-primary:hover { color: var(--dash-text); background: var(--dash-lime); }

.skeleton-card { gap: 15px; pointer-events: none; }
.skeleton-card span { height: 14px; border-radius: 7px; background: linear-gradient(90deg, #e8e3d8 20%, #f8f5ed 50%, #e8e3d8 80%); background-size: 240% 100%; animation: shimmer 1.2s infinite linear; }
.skeleton-card span:nth-child(1) { width: 30%; height: 25px; }
.skeleton-card span:nth-child(2) { width: 68%; height: 28px; margin-top: 20px; }
.skeleton-card span:nth-child(3) { width: 95%; }
.skeleton-card span:nth-child(4) { width: 82%; }
@keyframes shimmer { to { background-position: -240% 0; } }

.load-more-wrap { min-height: 2px; padding: 28px 0 5px; text-align: center; }
.load-more-wrap.is-loading { min-height: 72px; }
.infinite-scroll-status {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  min-height: 44px;
  color: var(--dash-muted);
  font-size: 13px;
  font-weight: 800;
}
.infinite-scroll-status[hidden] { display: none; }
.infinite-scroll-spinner {
  width: 19px;
  height: 19px;
  border: 3px solid rgba(26, 25, 23, 0.16);
  border-top-color: var(--dash-orange);
  border-radius: 50%;
  animation: infinite-scroll-spin 700ms linear infinite;
}
.infinite-scroll-sentinel { height: 1px; }
@keyframes infinite-scroll-spin { to { transform: rotate(360deg); } }
.load-more,
.library-error button {
  min-height: 46px;
  padding: 10px 20px;
  border: 0;
  border-radius: 999px;
  color: #fff;
  background: var(--dash-text);
  cursor: pointer;
  font: inherit;
  font-size: 13px;
  font-weight: 850;
}
.load-more:hover,
.library-error button:hover { color: var(--dash-text); background: var(--dash-lime); }
.load-more:disabled { cursor: wait; opacity: 0.62; }

.empty-state { padding: clamp(50px, 10vw, 100px) 20px; text-align: center; color: var(--dash-muted); }
.empty-state > span { color: var(--dash-orange); font: 70px/1 Georgia, serif; }
.empty-state h2 { margin: 10px 0 4px; color: var(--dash-text); font-size: 26px; }
.empty-state p { margin: 0 0 20px; }
.library-error {
  margin-bottom: 20px;
  padding: 18px;
  display: flex;
  align-items: center;
  gap: 12px;
  border: 1px solid rgba(190, 62, 62, 0.24);
  border-radius: 14px;
  color: #7a2929;
  background: #fff0ed;
}
.library-error[hidden] { display: none; }
.library-error span { flex: 1; font-size: 13px; }

.toast {
  position: fixed;
  right: 20px;
  bottom: 20px;
  z-index: 60;
  max-width: min(340px, calc(100vw - 32px));
  padding: 12px 17px;
  border-radius: 12px;
  color: var(--dash-text);
  background: var(--dash-orange);
  box-shadow: 0 16px 40px rgba(16, 37, 31, 0.24);
  opacity: 0;
  transform: translateY(14px);
  pointer-events: none;
  font-size: 13px;
  font-weight: 850;
  transition: opacity 180ms ease, transform 180ms ease;
}
.toast.is-visible { opacity: 1; transform: none; }

button:focus-visible,
a:focus-visible,
input:focus-visible { outline: 3px solid var(--dash-blue); outline-offset: 3px; }

@media (max-width: 1100px) {
  .dashboard-container { grid-template-columns: 226px minmax(0, 1fr); }
  .dashboard-sidebar { padding-inline: 12px; }
  .dashboard-content { padding-inline: 26px; }
}

@media (max-width: 900px) {
  body.dashboard-page { padding-top: 66px; overflow: auto; }
  body.sidebar-open { overflow: hidden; }
  .mobile-bar {
    position: fixed;
    inset: 0 0 auto;
    z-index: 35;
    height: 66px;
    padding: 10px 15px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    background: rgba(255, 253, 248, 0.95);
    border-bottom: 1px solid var(--dash-border);
    backdrop-filter: blur(18px);
  }
  .mobile-bar .brand-mark { width: 36px; height: 36px; }
  .sidebar-toggle {
    width: 44px;
    height: 44px;
    padding: 0;
    display: grid;
    place-content: center;
    gap: 5px;
    border: 0;
    border-radius: 11px;
    background: var(--dash-bg);
    cursor: pointer;
  }
  .sidebar-toggle > span:not(.sr-only) { width: 21px; height: 2px; background: var(--dash-text); transition: transform 180ms ease, opacity 180ms ease; }
  .sidebar-toggle[aria-expanded="true"] > span:nth-child(1) { transform: translateY(7px) rotate(45deg); }
  .sidebar-toggle[aria-expanded="true"] > span:nth-child(2) { opacity: 0; }
  .sidebar-toggle[aria-expanded="true"] > span:nth-child(3) { transform: translateY(-7px) rotate(-45deg); }
  .dashboard-container { display: block; min-height: calc(100dvh - 66px); }
  .dashboard-sidebar {
    position: fixed;
    inset: 66px auto 0 0;
    width: min(310px, calc(100vw - 44px));
    transform: translateX(-105%);
    box-shadow: 20px 0 45px rgba(16, 37, 31, 0.18);
    transition: transform 220ms ease;
  }
  .sidebar-brand { display: none; }
  .sidebar-open .dashboard-sidebar { transform: none; }
  .sidebar-scrim {
    position: fixed;
    inset: 66px 0 0;
    z-index: 15;
    border: 0;
    display: block;
    visibility: hidden;
    opacity: 0;
    background: rgba(6, 18, 14, 0.52);
    transition: opacity 180ms ease, visibility 180ms ease;
  }
  .sidebar-open .sidebar-scrim { visibility: visible; opacity: 1; }
  .dashboard-main { height: calc(100vh - 66px); height: calc(100dvh - 66px); }
  .dashboard-header { min-height: 70px; padding-inline: 18px; }
  .search-wrap { width: 100%; }
  .home-link { display: none; }
}

@media (max-width: 620px) {
  .dashboard-header { min-height: 66px; padding: 9px 12px; }
  .search-wrap { min-height: 46px; }
  .search-wrap kbd { display: none; }
  .dashboard-content { padding: 24px 12px 40px; scrollbar-gutter: auto; }
  .content-header { align-items: flex-start; }
  .content-header h1 { font-size: 39px; }
  .content-header .button { flex: 0 0 auto; padding-inline: 12px; }
  .studio-callout { grid-template-columns: 1fr; min-height: 0; padding: 21px; gap: 9px; }
  .studio-callout-badge { width: max-content; }
  .studio-callout-icon { position: absolute; right: 14px; top: 12px; font-size: 46px; opacity: 0.3; }
  .dashboard-grid { grid-template-columns: 1fr; }
  .dash-card { min-height: 315px; }
  .library-error { align-items: flex-start; flex-wrap: wrap; }
  .library-error span { flex-basis: 100%; }
  .toast { right: 12px; bottom: 12px; }
}

@media (prefers-reduced-motion: reduce) {
  .dash-card,
  .dashboard-sidebar,
  .sidebar-scrim,
  .sidebar-toggle > span,
  .toast { transition: none; }
  .skeleton-card span { animation: none; }
  .infinite-scroll-spinner { animation: none; border-color: var(--dash-orange); }
}
