:where(.nav) {
  background: var(--memovia-surface, #fff);
  padding: 12px 14px 12px 40px;
  box-shadow: var(--memovia-shadow-header);
  margin-bottom: 0;
  position: sticky;
  top: 0;
  z-index: 1000;
}

:where(.nav .container.nav-content) {
  display: flex;
  justify-content: space-between;
  align-items: center;
  max-width: 100%;
  margin: 0 auto;
  gap: 12px;
  position: relative;
}

:where(.nav-left) {
  display: flex;
  align-items: center;
  gap: 12px;
  flex: 0 0 auto;
}

:where(.nav .logo) {
  margin-left: 12px;
}

:where(.nav-center) {
  display: none;
  flex: 1 1 auto;
  align-items: center;
  justify-content: center;
  min-width: 0;
}

:where(.nav-brand-mobile) {
  color: var(--memovia-text-strong, #0f172a);
  font-weight: 900;
  letter-spacing: -0.02em;
  text-decoration: none;
  font-size: 1.05rem;
  text-transform: uppercase;
}

:where(.nav-logo-link) {
  display: inline-flex;
}

:where(.nav #site-logo) {
  height: 35px;
  vertical-align: middle;
}

:where(.nav-links) {
  margin-left: auto;
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 16px;
  min-width: 0;
}

:where(.nav-links a) {
  text-decoration: none;
  color: var(--memovia-text-strong, #0f172a);
  font-weight: 500;
}

.nav .btn,
.nav button.btn,
.nav a.btn,
.nav .account-badge {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  flex: 0 0 auto;
}

.nav .btn-icon,
.nav button.btn-icon,
.nav a.btn-icon,
.nav #nav-upload-btn,
.nav .nav-mobile-bookmark,
.nav .nav-sidebar-toggle,
.nav .nav-actions-toggle {
  width: 40px;
  height: 40px;
  min-width: 40px;
  min-height: 40px;
  padding: 0 !important;
}

.nav #nav-upload-btn svg,
.nav .nav-mobile-bookmark svg {
  width: 18px;
  height: 18px;
  flex: 0 0 auto;
}

.nav #nav-upload-btn,
.nav button#nav-upload-btn,
.nav button#nav-upload-btn.btn,
.nav button#nav-upload-btn.btn-upload {
  border: 0 !important;
  background: linear-gradient(135deg, var(--memovia-ai, #10b981), var(--memovia-ai-dark, #059669)) !important;
  color: var(--memovia-on-primary, #fff) !important;
  box-shadow: var(--memovia-shadow-ai) !important;
}

.nav #nav-upload-btn:hover,
.nav button#nav-upload-btn:hover,
.nav button#nav-upload-btn.btn:hover,
.nav button#nav-upload-btn.btn-upload:hover {
  background: linear-gradient(135deg, var(--memovia-ai-dark, #059669), var(--memovia-success-dark, #047857)) !important;
  color: var(--memovia-on-primary, #fff) !important;
}

.nav #nav-upload-btn svg,
.nav #nav-upload-btn svg * {
  stroke: currentColor !important;
}

.nav .nav-mobile-bookmark,
.nav a.nav-mobile-bookmark,
.nav a.nav-mobile-bookmark.btn {
  border: 0 !important;
  background: transparent !important;
  color: var(--memovia-primary, #2563eb) !important;
  box-shadow: none !important;
}

:where(.nav-sidebar-toggle) {
  flex: 0 0 auto;
}

:where(button.nav-sidebar-toggle),
:where(button.nav-sidebar-toggle.btn),
:where(button.nav-sidebar-toggle.btn-outline) {
  color: var(--memovia-text-strong, #0f172a) !important;
  border: 0 !important;
  background: transparent !important;
  box-shadow: none !important;
}

:where(button.nav-sidebar-toggle:hover),
:where(button.nav-sidebar-toggle.btn:hover),
:where(button.nav-sidebar-toggle.btn-outline:hover),
:where(button.nav-sidebar-toggle:active),
:where(button.nav-sidebar-toggle.btn:active),
:where(button.nav-sidebar-toggle.btn-outline:active),
:where(button.nav-sidebar-toggle:focus-visible),
:where(button.nav-sidebar-toggle.btn:focus-visible),
:where(button.nav-sidebar-toggle.btn-outline:focus-visible),
:where(button.nav-sidebar-toggle.is-open),
:where(button.nav-sidebar-toggle.is-open:hover),
:where(button.nav-sidebar-toggle.is-open:active) {
  color: var(--memovia-text-strong, #0f172a) !important;
  border-color: transparent !important;
  background: transparent !important;
  box-shadow: none !important;
}

:where(.nav-toggle-icon),
:where(.nav-dots-icon) {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 3px;
  transition: transform 0.2s ease;
}

:where(.nav-toggle-icon) {
  flex-direction: column;
}

:where(.nav-toggle-icon span) {
  display: block;
  width: 16px;
  height: 2px;
  border-radius: 999px;
  background: currentColor;
  transition: width 0.2s ease, height 0.2s ease, transform 0.2s ease;
}

:where(.nav-sidebar-toggle.is-open .nav-toggle-icon) {
  flex-direction: row;
}

:where(.nav-sidebar-toggle.is-open .nav-toggle-icon span) {
  width: 2px;
  height: 16px;
}

:where(.nav-actions-group) {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 10px;
  min-width: 0;
}

:where(.nav-expandable-links) {
  display: flex;
  align-items: center;
  gap: 14px;
  min-width: 0;
  max-width: 0;
  opacity: 0;
  overflow: hidden;
  pointer-events: none;
  transform: translateX(8px);
  transition: max-width 0.25s ease, opacity 0.2s ease, transform 0.2s ease;
}

:where(.nav-actions-group.is-open .nav-expandable-links) {
  max-width: 420px;
  opacity: 1;
  pointer-events: auto;
  transform: translateX(0);
}

:where(.nav-action-link) {
  white-space: nowrap;
  font-weight: 700;
}

:where(button.nav-actions-toggle),
:where(button.nav-actions-toggle.btn),
:where(button.nav-actions-toggle.btn-outline) {
  flex: 0 0 auto;
  color: var(--memovia-text-strong, #0f172a) !important;
  border-radius: var(--memovia-radius-pill, 9999px);
  border: 0 !important;
  background: transparent !important;
  box-shadow: none !important;
}

:where(button.nav-actions-toggle:hover),
:where(button.nav-actions-toggle.btn:hover),
:where(button.nav-actions-toggle.btn-outline:hover),
:where(button.nav-actions-toggle:active),
:where(button.nav-actions-toggle.btn:active),
:where(button.nav-actions-toggle.btn-outline:active),
:where(button.nav-actions-toggle:focus),
:where(button.nav-actions-toggle:focus-visible),
:where(button.nav-actions-toggle.is-open),
:where(button.nav-actions-toggle.is-open:hover),
:where(button.nav-actions-toggle.is-open:active) {
  color: var(--memovia-text-strong, #0f172a) !important;
  border-color: transparent !important;
  background: transparent !important;
  box-shadow: none !important;
}

:where(.nav-dots-icon) {
  flex-direction: column;
}

:where(.nav-dots-icon span) {
  display: block;
  width: 4px;
  height: 4px;
  border-radius: 999px;
  background: currentColor;
  transition: width 0.2s ease, height 0.2s ease;
}

:where(.nav-actions-toggle.is-open .nav-dots-icon) {
  flex-direction: row;
}

:where(button.nav-sidebar-toggle .nav-toggle-icon span),
:where(button.nav-actions-toggle .nav-dots-icon span) {
  background: currentColor !important;
}

:where(.nav-mobile-bookmark) {
  display: none;
  color: var(--memovia-primary, #2563eb) !important;
  border: 0 !important;
  background: transparent !important;
  box-shadow: none !important;
}

:where(.nav-mobile-bookmark:hover),
:where(.nav-mobile-bookmark:focus-visible) {
  color: var(--memovia-primary-dark, #1d4ed8) !important;
  border-color: transparent !important;
  background: transparent !important;
  box-shadow: none !important;
}

@media (min-width: 769px) {
  :where(.nav-item-mobile) {
    display: none !important;
  }
}

:where(.btn) {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  min-height: 40px;
  padding: 10px 14px;
  border-radius: var(--memovia-radius-md, 10px);
  border: 1px solid transparent;
  text-decoration: none;
  font-weight: 600;
  cursor: pointer;
  transition: background-color 0.2s ease, border-color 0.2s ease, color 0.2s ease, box-shadow 0.2s ease, transform 0.05s ease;
}

:where(.btn:active) {
  transform: translateY(1px);
}

:where(.btn-outline) {
  background: var(--memovia-surface, #fff);
  border-color: var(--memovia-primary, #2563eb);
  color: var(--memovia-primary, #2563eb);
}

:where(.btn-outline:hover) {
  background: var(--memovia-primary, #2563eb);
  color: var(--memovia-on-primary, #fff);
}

:where(.btn-primary) {
  background: linear-gradient(135deg, var(--memovia-primary, #2563eb), var(--memovia-primary-dark, #1d4ed8));
  color: var(--memovia-on-primary, #fff);
  box-shadow: var(--memovia-shadow-primary);
  border-color: transparent;
}

:where(.btn-ghost) {
  background: transparent;
  color: var(--memovia-primary, #2563eb);
  border-color: transparent;
  padding: 8px 10px;
  border-radius: var(--memovia-radius-sm, 8px);
}

:where(.btn-ghost:hover) {
  background: var(--memovia-primary-soft, #eff6ff);
}

:where(.btn-icon) {
  width: 40px;
  height: 40px;
  padding: 0;
  border-radius: var(--memovia-radius-pill, 9999px);
}

:where(.btn-upload) {
  border: none;
  background: linear-gradient(135deg, var(--memovia-ai, #10b981), var(--memovia-ai-dark, #059669));
  box-shadow: var(--memovia-shadow-ai);
  color: var(--memovia-on-primary, #fff);
  transform: translateY(2px);
}

:where(.btn-upload:hover) {
  background: linear-gradient(135deg, var(--memovia-ai-dark, #059669), var(--memovia-success-dark, #047857));
}

:where(.btn-upload svg) {
  transform: translateY(1px);
}

:where(.btn-logout) {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 36px;
  height: 36px;
  padding: 0;
  border: none;
  background: transparent;
  border-radius: var(--memovia-radius-sm, 8px);
  cursor: pointer;
  transition: background-color 0.2s ease, transform 0.05s ease;
}

:where(.btn-logout:hover) {
  background-color: var(--memovia-interactive-hover);
}

:where(.btn-logout:active) {
  transform: translateY(1px);
}

:where(.btn-logout img) {
  display: block;
  height: 20px;
  width: auto;
}

:where(.account-menu-wrap) {
  position: relative;
  display: inline-block;
}

:where(.account-badge) {
  font-weight: 600;
  color: var(--memovia-on-primary, #fff);
  background: var(--memovia-primary, #2563eb);
  border: 1px solid var(--memovia-primary-dark, #1d4ed8);
  padding: 8px 14px;
  border-radius: var(--memovia-radius-pill, 9999px);
  display: inline-block;
  max-width: 180px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  line-height: 1;
  box-shadow: var(--memovia-shadow-primary);
  text-decoration: none;
  cursor: pointer;
}

:where(.account-menu) {
  position: absolute;
  right: 0;
  top: calc(100% + 10px);
  min-width: 200px;
  background: var(--memovia-surface-elevated, #fff);
  border: 1px solid var(--memovia-border, #e5e7eb);
  border-radius: var(--memovia-radius-lg, 12px);
  box-shadow: var(--memovia-shadow-popover, 0 16px 38px rgba(15, 23, 42, 0.12), 0 3px 10px rgba(15, 23, 42, 0.06));
  padding: 6px;
  z-index: 3000;
  transform-origin: top right;
  transform: scale(0.98);
  opacity: 0;
  transition: transform 0.12s ease, opacity 0.12s ease;
  backdrop-filter: saturate(180%) blur(6px);
}

:where(.account-menu.open) {
  transform: scale(1);
  opacity: 1;
}

:where(.account-menu::before) {
  content: "";
  position: absolute;
  right: 18px;
  top: -6px;
  width: 10px;
  height: 10px;
  background: var(--memovia-surface-elevated, #fff);
  border-left: 1px solid var(--memovia-border, #e5e7eb);
  border-top: 1px solid var(--memovia-border, #e5e7eb);
  transform: rotate(45deg);
}

:where(.account-menu .acc-item) {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 12px;
  border-radius: var(--memovia-radius-md, 10px);
  color: var(--memovia-text-strong, #0f172a);
  text-decoration: none;
  font-weight: 700;
  font-size: 14px;
  line-height: 1;
  transition: background 0.12s ease, color 0.12s ease;
  width: 100%;
  box-sizing: border-box;
}

:where(.account-menu .acc-item .icon) {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 18px;
  height: 18px;
}

:where(.account-menu .acc-item:hover) {
  background: var(--memovia-surface-muted, #f8fafc);
}

:where(.account-menu .acc-item.danger) {
  color: var(--memovia-text-strong, #0f172a);
}

:where(.account-menu .acc-item.danger:hover) {
  color: var(--memovia-error, #ef4444);
  background: var(--memovia-surface-muted, #f8fafc);
}

:where(.account-menu .acc-theme-toggle) {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 10px 12px;
  border-radius: var(--memovia-radius-md, 10px);
  color: var(--memovia-text-strong, #0f172a);
}

:where(.acc-theme-copy) {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  min-width: 0;
  font-weight: 700;
  font-size: 14px;
}

:where(.acc-theme-copy .icon) {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 18px;
  height: 18px;
}

:where(.theme-toggle-btn) {
  position: relative;
  width: 46px;
  height: 28px;
  border: 1px solid var(--memovia-border-strong, #cbd5e1);
  border-radius: var(--memovia-radius-pill, 9999px);
  background: var(--memovia-surface-muted, #f8fafc);
  cursor: pointer;
  transition: background-color 0.2s ease, border-color 0.2s ease, box-shadow 0.2s ease;
  flex: 0 0 auto;
}

:where(.theme-toggle-btn:hover),
:where(.theme-toggle-btn:focus-visible) {
  border-color: var(--memovia-primary, #2563eb);
  box-shadow: 0 0 0 3px var(--memovia-primary-soft, #eff6ff);
  outline: none;
}

:where(.theme-toggle-thumb) {
  position: absolute;
  top: 3px;
  left: 3px;
  width: 20px;
  height: 20px;
  border-radius: 50%;
  background: var(--memovia-surface-elevated, #fff);
  box-shadow: var(--memovia-shadow-card, 0 6px 16px rgba(15, 23, 42, 0.06));
  transition: transform 0.2s ease, background-color 0.2s ease;
}

:where(.theme-toggle-btn[aria-pressed="true"]) {
  background: var(--memovia-primary, #2563eb);
  border-color: var(--memovia-primary, #2563eb);
}

:where(.theme-toggle-btn[aria-pressed="true"] .theme-toggle-thumb) {
  transform: translateX(18px);
  background: var(--memovia-on-primary, #fff);
}

:where(.account-menu .acc-sep) {
  height: 1px;
  background: var(--memovia-border, #e5e7eb);
  margin: 6px 4px;
  border-radius: var(--memovia-radius-pill, 9999px);
}

:where(.ui-card) {
  background: var(--memovia-surface, #fff);
  padding: 16px;
  border-radius: var(--memovia-radius-lg, 12px);
  box-shadow: var(--memovia-shadow-card, 0 6px 16px rgba(15, 23, 42, 0.06));
  border: 1px solid var(--memovia-border, #e5e7eb);
}

:where(.ui-tabs) {
  display: flex;
  gap: 8px;
  margin-bottom: 12px;
  flex-wrap: wrap;
}

:where(.ui-tab) {
  flex: 1;
  border: 1px solid var(--memovia-border, #e5e7eb);
  background: var(--memovia-surface-muted, #f8fafc);
  color: var(--memovia-text-soft, #334155);
  padding: clamp(6px, 1.8vw, 8px) clamp(8px, 2.6vw, 10px);
  border-radius: var(--memovia-radius-sm, 8px);
  cursor: pointer;
  white-space: normal;
  word-break: keep-all;
  text-align: center;
  line-height: 1.25;
  font-size: clamp(0.85rem, 2.6vw, 1rem);
}

:where(.ui-tab.is-active) {
  background: var(--memovia-primary, #2563eb);
  color: var(--memovia-on-primary, #fff);
  border-color: var(--memovia-primary, #2563eb);
}

:where(.layout-shell) {
  display: flex;
  min-height: calc(100vh - 60px);
  align-items: flex-start;
}

:where(.sidebar-shell) {
  flex: 0 0 280px;
  width: 280px;
  background: var(--memovia-surface-elevated, #fff);
  box-shadow: var(--memovia-shadow-sidebar);
  padding: 20px;
  transition: width 0.3s ease, padding 0.3s ease;
  overflow-y: auto;
  overflow-x: hidden;
  position: sticky;
  top: 60px;
  height: calc(100vh - 60px);
  align-self: flex-start;
  -ms-overflow-style: none;
  scrollbar-width: none;
  transform: translateX(0);
  opacity: 1;
  pointer-events: auto;
  transition: transform 0.25s ease, opacity 0.2s ease, padding 0.3s ease, width 0.3s ease;
}

:where(.sidebar-shell::-webkit-scrollbar) {
  width: 0;
  height: 0;
}

:where(.sidebar-shell::after),
:where(.sidebar-shell::before) {
  content: none !important;
}

:where(.sidebar-shell *::after) {
  content: normal;
}

@media (min-width: 993px) {
  :where(.sidebar-shell) {
    border: 1px solid var(--memovia-border, #e5e7eb);
    border-radius: var(--memovia-radius-lg, 12px);
    box-shadow: var(--memovia-shadow-card, 0 6px 16px rgba(15, 23, 42, 0.06));
    position: fixed !important;
    left: 0 !important;
    top: 60px !important;
    height: calc(100vh - 60px) !important;
  }

  :where(.sidebar-shell.overlay-open) {
    position: fixed !important;
    z-index: 2000;
    overflow: auto;
    left: 0 !important;
    top: 60px !important;
  }
}

:where(.sidebar-shell.collapsed) {
  transform: translateX(calc(-100% - 24px));
  opacity: 0;
  pointer-events: none;
}

:where(.sidebar-shell.overlay-open) {
  transform: translateX(0);
  opacity: 1;
  pointer-events: auto;
}

:where(.layout-main) {
  flex: 1 1 auto;
  min-width: 0;
  padding: 20px;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 20px;
  margin-left: 0;
  transition: padding 0.3s ease;
}

:where(.sidebar-shell-top) {
  display: flex;
  flex-direction: column;
  gap: 12px;
  margin-bottom: 18px;
}

:where(.sidebar-shell-panel) {
  display: block;
  min-width: 0;
}

:where(.sidebar-shell-panel + .sidebar-shell-panel) {
  margin-top: 16px;
}

:where(.shared-sidebar-menu) {
  margin: 8px 0;
}

:where(.shared-sidebar-list) {
  list-style: none;
  margin: 0;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

:where(.shared-sidebar-link) {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 12px 14px;
  border-radius: var(--memovia-radius-lg, 12px);
  text-decoration: none;
  color: var(--memovia-text-strong, #0f172a);
  font-weight: 700;
  border: 1px solid transparent;
  transition: background-color 0.2s ease, border-color 0.2s ease, color 0.2s ease;
}

:where(.shared-sidebar-link:hover) {
  background: var(--memovia-surface-muted, #f8fafc);
  border-color: var(--memovia-border-strong, #cbd5e1);
  color: var(--memovia-primary-dark, #1d4ed8);
}

:where(.shared-sidebar-link.is-bookmark) {
  color: var(--memovia-primary, #2563eb);
}

:where(.shared-sidebar-link-icon) {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 18px;
  height: 18px;
  flex: 0 0 auto;
}

:where(.sidebar.collapsed .study-subject-panel),
:where(.sidebar.collapsed .study-sidebar-menu),
:where(.sidebar.collapsed .subject-card),
:where(.sidebar.collapsed .add-subject-btn) {
  display: none;
}

:where(.subject-list) {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

:where(.subject-card) {
  position: relative;
  background: linear-gradient(180deg, var(--memovia-surface-elevated, #ffffff) 0%, var(--memovia-surface-subtle, #f8fbff) 100%);
  border-radius: 16px;
  padding: 14px 14px 13px;
  margin-bottom: 0;
  box-shadow: var(--memovia-shadow-card, 0 10px 24px rgba(15,23,42,0.06));
  transition: transform 0.2s ease, box-shadow 0.2s ease, border-color 0.2s ease, background 0.2s ease;
  cursor: pointer;
  border: 1px solid var(--memovia-border, #e2e8f0);
  overflow: hidden;
}

:where(.subject-card::before) {
  content: "";
  position: absolute;
  inset: 0 auto 0 0;
  width: 4px;
  background: transparent;
  transition: background 0.2s ease;
}

:where(.subject-card:hover) {
  transform: translateY(-2px);
  box-shadow: var(--memovia-shadow-primary, 0 14px 30px rgba(37,99,235,0.10));
  border-color: var(--memovia-primary-soft-strong, #bfdbfe);
}

:where(.subject-card.active) {
  background: linear-gradient(180deg, var(--memovia-primary-soft, #eff6ff) 0%, var(--memovia-surface-subtle, #f8fbff) 100%);
  border-color: var(--memovia-primary-light, #93c5fd);
  box-shadow: var(--memovia-shadow-primary, 0 14px 32px rgba(37,99,235,0.14));
}

:where(.subject-card.active::before) {
  background: linear-gradient(180deg, var(--memovia-primary, #2563eb) 0%, var(--memovia-primary-light, #60a5fa) 100%);
}

:where(.subject-card-head) {
  display:flex;
  align-items:flex-start;
  justify-content:space-between;
  gap:10px;
  margin-bottom:10px;
}

:where(.subject-card-title-wrap) {
  min-width: 0;
  flex: 1;
}

:where(.subject-card h3),
:where(.subject-card-title) {
  color: var(--memovia-text-strong, #0f172a);
  font-size: 1rem;
  margin: 0;
  font-weight: 800;
  letter-spacing: -0.01em;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

:where(.subject-card-subcopy) {
  margin-top: 5px;
  color: var(--memovia-text-light, #64748b);
  font-size: 0.83rem;
  line-height: 1.35;
}

:where(.subject-card-actions) {
  display:flex;
  gap:6px;
  flex-shrink: 0;
}

:where(.subject-card-btn) {
  display:none;
  padding:5px 8px;
  font-size:0.78rem;
  border-radius:8px;
  background: var(--memovia-surface-elevated, #fff);
  cursor:pointer;
  border:1px solid var(--memovia-border, #dbe2ea);
  color: var(--memovia-text-soft, #334155);
}

:where(.subject-card-btn.delete) {
  border-color: var(--memovia-error, #fecaca);
  color: var(--memovia-error-dark, #dc2626);
}

:where(.subject-card.is-edit-mode:hover .subject-edit-btn),
:where(.subject-card.is-edit-mode:focus-within .subject-edit-btn),
:where(.subject-card.is-delete-mode:hover .subject-delete-btn),
:where(.subject-card.is-delete-mode:focus-within .subject-delete-btn) {
  display:inline-flex;
  align-items:center;
  justify-content:center;
}

:where(.subject-card-meta) {
  display:flex;
  align-items:center;
  gap:8px;
  flex-wrap:wrap;
}

:where(.subject-card .progress),
:where(.subject-badge) {
  display:inline-flex;
  align-items:center;
  gap:6px;
  min-height: 30px;
  padding: 0 10px;
  border-radius: 999px;
  border: 1px solid var(--memovia-primary-soft-strong, #dbeafe);
  background: var(--memovia-primary-soft, #eff6ff);
  color: var(--memovia-primary-dark, #1d4ed8);
  font-size: 0.82rem;
  font-weight: 700;
  line-height: 1;
}

:where(.subject-card .progress::before) {
  content: "자료";
  color: var(--memovia-text-light, #64748b);
  font-size: 0.76rem;
  font-weight: 700;
}

:where(.subject-badge) {
  border-color: var(--memovia-border, #e5e7eb);
  background: var(--memovia-surface-muted, #f8fafc);
  color: var(--memovia-text-soft, #475569);
}

:where(.subject-badge.subject-badge-uncategorized) {
  border-color: var(--memovia-warning, #fde68a);
  background: var(--memovia-warning-soft, #fffbeb);
  color: var(--memovia-accent-dark, #92400e);
}

:where(.subject-card.active .progress) {
  border-color: var(--memovia-primary-light, #bfdbfe);
  background: var(--memovia-primary-soft-strong, #dbeafe);
}

:where(.add-subject-btn) {
  width: 100%;
  padding: 12px;
  background-color: var(--memovia-surface-muted, #f8fafc);
  border: 1px dashed var(--memovia-border-strong, #cbd5e1);
  border-radius: 12px;
  color: var(--memovia-text-soft, #475569);
  font-size: 0.95rem;
  cursor: pointer;
  transition: all 0.3s ease;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
}

:where(.add-subject-btn:hover) {
  background-color: var(--memovia-primary-soft, #eff6ff);
  border-color: var(--memovia-primary-light, #93c5fd);
  color: var(--memovia-primary-dark, #1d4ed8);
}

:where(.subjects-section-head) {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  margin-bottom: 14px;
}

:where(.subjects-section-head h3) {
  margin: 0;
  flex: 1;
  color: var(--memovia-text-strong, #0f172a);
  font-size: 1.02rem;
  font-weight: 800;
  letter-spacing: -0.01em;
  padding-bottom: 10px;
  border-bottom: 1px solid var(--memovia-border, #e5e7eb);
}

:where(.subject-actions-controls) {
  margin-top: 10px;
  display: block;
}

:where(.subject-manage-wrap) {
  position: relative;
  flex: 0 0 auto;
  margin-top: -22px;
}

:where(.subject-manage-btn) {
  width: 34px;
  min-width: 34px;
  height: 34px;
  padding: 0;
  border-style: dashed;
  background: var(--memovia-surface-muted, #f8fafc);
  border-color: var(--memovia-border-strong, #cbd5e1);
  border-radius: 10px;
  justify-content: center;
  font-size: 1rem;
  font-weight: 800;
  line-height: 1;
  color: var(--memovia-text-soft, #334155);
}

:where(.subject-manage-btn::before),
:where(.subject-manage-btn::after) {
  content: none !important;
}

:where(.subject-manage-menu) {
  position: absolute;
  top: calc(100% + 6px);
  right: 0;
  left: auto;
  display: none;
  flex-direction: column;
  gap: 6px;
  padding: 6px;
  border: 1px solid var(--memovia-border, #dbe2ea);
  border-radius: 12px;
  background: var(--memovia-surface-elevated, #fff);
  box-shadow: var(--memovia-shadow-popover, 0 12px 28px rgba(15,23,42,0.12));
  z-index: 20;
  min-width: 108px;
}

:where(.subject-manage-wrap.open .subject-manage-menu) {
  display: flex;
}

:where(.subject-manage-menu .subject-toggle-btn) {
  margin-top: 0 !important;
  width: auto;
  min-width: 96px;
  padding: 8px 10px;
  justify-content: center;
  border-style: solid;
  border-radius: 10px;
  background: var(--memovia-surface-elevated, #fff);
  border-color: var(--memovia-border, #e5e7eb);
  font-size: 0.82rem;
}

:where(.add-subject-btn::before) {
  content: "+";
  font-size: 1.2rem;
  font-weight: bold;
}

:where(.subject-toggle-btn::before) {
  content: none !important;
}

:where(.subjects-section h3) {
  color: var(--memovia-text-strong, #0f172a);
  font-size: 1rem;
  font-weight: 800;
  letter-spacing: -0.01em;
  margin-bottom: 15px;
  padding-bottom: 8px;
  border-bottom: 1px solid var(--memovia-border, #eee);
}

:where(#sidebarExtraMenu a) {
  font-weight: 800;
  color: var(--memovia-text-strong, #0f172a) !important;
  letter-spacing: -0.01em;
}

:where(#sidebarExtraMenu a:hover) {
  color: var(--memovia-primary-dark, #1d4ed8) !important;
}

:where(#sidebarExtraMenu .sidebar-bookmark-link) {
  display: flex;
  align-items: center;
  justify-content: flex-start;
  gap: 10px;
  padding: 4px 0;
  border-radius: 0;
  background: transparent;
  border: none;
  color: var(--memovia-text-strong, #0f172a) !important;
  transition: color 0.15s ease;
}

:where(#sidebarExtraMenu .sidebar-bookmark-link:hover) {
  color: var(--memovia-primary-dark, #1d4ed8) !important;
}

:where(.sidebar-bookmark-copy) {
  display: inline-flex;
  align-items: center;
  justify-content: flex-start;
  gap: 10px;
  min-width: 0;
}

:where(.sidebar-bookmark-icon) {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 20px;
  height: 20px;
  border-radius: 0;
  flex: 0 0 auto;
}

:where(.sidebar-bookmark-title) {
  color: inherit;
  font-weight: 800;
}

:where(.study-inline-divider) {
  border-top: 1px solid var(--memovia-border, #e5e7eb);
  margin: 8px 0;
}

:where(.study-inline-list) {
  list-style: none;
  padding: 0;
  margin: 0;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

:where(.study-inline-link) {
  color: var(--memovia-text-soft, #334155);
  text-decoration: none;
  font-size: 1.1rem;
}

:where(.study-primary-icon) {
  color: var(--memovia-primary, #2563eb);
}

:where(.page-modal-body) {
  padding: 20px;
}

:where(.page-form-stack) {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

:where(.page-form-meta),
:where(.page-action-row) {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
}

:where(.page-field-label) {
  color: var(--memovia-text-soft, #475569);
  font-size: 0.9rem;
  font-weight: 700;
}

:where(.page-field-input),
:where(.page-field-select) {
  width: 100%;
  min-height: 44px;
  border-radius: 12px;
  border: 1px solid var(--memovia-border, #dbe2ea);
  background: var(--memovia-surface, #fff);
  color: var(--memovia-text-strong, #0f172a);
  padding: 0 14px;
}

:where(.page-field-error) {
  color: var(--memovia-error-dark, #dc2626);
  font-size: 0.82rem;
  min-height: 1.2em;
}

:where(.page-modal-text) {
  color: var(--memovia-text-soft, #334155);
  line-height: 1.65;
}

@media (max-width: 992px) {
  :where(.materials-list) {
    top: auto;
    bottom: calc(70px + env(safe-area-inset-bottom));
    width: 100%;
    height: min(60vh, 480px);
    border-left: 0;
    border-top: 1px solid var(--memovia-border, #e5e7eb);
    transform: translateY(100%);
  }

  :where(.materials-list.active) {
    transform: translateY(0);
  }
}

:where(.materials-list) {
  position: fixed;
  top: 60px;
  right: 0;
  display: block;
  visibility: hidden;
  width: 350px;
  height: calc(100vh - 60px);
  background-color: var(--memovia-surface-elevated, #fff);
  box-shadow: var(--memovia-shadow-sidebar, -2px 0 5px rgba(0,0,0,0.1));
  padding: 20px;
  overflow-y: auto;
  z-index: 1005;
  transform: translateX(100%);
  transition: transform 0.3s ease-in-out, visibility 0s 0.3s;
}

:where(.materials-list.active) {
  transform: translateX(0);
  visibility: visible;
  transition: transform 0.3s ease-in-out, visibility 0s 0s;
}

:where(.materials-list-content .material-item) {
  background-color: var(--memovia-surface-elevated, #fff);
  border: 1px solid var(--memovia-border, #e9e9e9);
  border-radius: 16px;
  padding: 16px;
  margin-bottom: 15px;
  cursor: pointer;
  transition: transform 0.24s ease, box-shadow 0.24s ease, border-color 0.24s ease, background-color 0.24s ease;
  box-shadow: 0 10px 30px rgba(15, 23, 42, 0.08);
}

:where(.materials-list-content .material-item:hover) {
  transform: translateY(-2px);
  box-shadow: 0 18px 34px rgba(37, 99, 235, 0.12);
  border-color: color-mix(in srgb, var(--memovia-primary, #3498db) 45%, white);
}

:where(.material-item-header) {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 10px;
}

:where(.material-item-header .date-badge) {
  font-size: 0.8rem;
  color: var(--memovia-text-light, #666);
  background-color: var(--memovia-surface-muted, #f8f9fa);
  padding: 4px 8px;
  border-radius: 4px;
  border: 1px solid var(--memovia-border, #e9ecef);
}

:where(.materials-list-content .text-preview) {
  font-size: 0.9rem;
  color: var(--memovia-text-soft, #555);
  line-height: 1.5;
  margin-bottom: 10px;
}

:where(.text-preview-inner) {
  padding: 0;
  border-radius: 0;
  background: transparent;
  border: 0;
  max-height: 4.5em;
  overflow: hidden;
  text-overflow: ellipsis;
  display: -webkit-box;
  -webkit-line-clamp: 3;
  line-clamp: 3;
  -webkit-box-orient: vertical;
}

:where(.material-actions-toggle-btn) {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 66px;
  height: 32px;
  padding: 0 12px;
  border-radius: 999px;
  border: 1px solid color-mix(in srgb, var(--memovia-primary, #3498db) 24%, var(--memovia-border, #e9ecef));
  background: color-mix(in srgb, var(--memovia-primary, #3498db) 8%, var(--memovia-surface-elevated, #fff));
  color: var(--memovia-primary-dark, #1d4ed8);
  font-size: 0.8rem;
  font-weight: 800;
  letter-spacing: -0.01em;
  cursor: pointer;
  transition: all 0.2s ease;
  gap: 8px;
}

:where(.material-actions-toggle-btn::after) {
  content: "";
  width: 7px;
  height: 7px;
  border-right: 1.8px solid currentColor;
  border-bottom: 1.8px solid currentColor;
  transform: rotate(45deg) translateY(-1px);
  transition: transform 0.2s ease;
}

:where(.material-actions-toggle-btn:hover),
:where(.material-item.is-actions-open .material-actions-toggle-btn) {
  background: color-mix(in srgb, var(--memovia-primary, #3498db) 14%, var(--memovia-surface-elevated, #fff));
  border-color: color-mix(in srgb, var(--memovia-primary, #3498db) 40%, var(--memovia-border, #e9ecef));
  box-shadow: 0 8px 18px rgba(37, 99, 235, 0.14);
}

:where(.material-item.is-actions-open .material-actions-toggle-btn::after) {
  transform: rotate(-135deg) translateY(-1px);
}

:where(.material-item-footer) {
  gap: 0;
}

:where(.material-actions) {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 0 10px;
  margin-top: 0;
  border-radius: 12px;
  border: 1px solid var(--memovia-border, #e9ecef);
  background: color-mix(in srgb, var(--memovia-surface-muted, #f8f9fa) 84%, white);
  overflow: hidden;
  max-height: 0;
  opacity: 0;
  transform: translateY(-6px);
  pointer-events: none;
  transition: max-height 0.24s ease, opacity 0.2s ease, transform 0.2s ease, padding 0.2s ease, margin-top 0.2s ease;
}

:where(.material-item.is-actions-open .material-actions) {
  max-height: 68px;
  opacity: 1;
  transform: translateY(0);
  pointer-events: auto;
  padding: 10px;
  margin-top: 10px;
}

:where(.material-action-btn) {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 78px;
  height: 36px;
  padding: 0 12px;
  border-radius: 10px;
  border: 1px solid var(--memovia-border, #dbe2ea);
  background: var(--memovia-surface-elevated, #fff);
  color: var(--memovia-text-soft, #334155);
  font-size: 0.82rem;
  font-weight: 700;
  cursor: pointer;
  transition: all 0.2s ease;
  gap: 8px;
}

:where(.material-action-btn:hover) {
  transform: translateY(-1px);
  box-shadow: 0 10px 18px rgba(15, 23, 42, 0.08);
}

:where(.material-action-icon) {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 18px;
  height: 18px;
  flex: 0 0 18px;
}

:where(.material-action-icon svg) {
  display: block;
}

:where(.material-action-label) {
  display: inline-flex;
  align-items: center;
  line-height: 1;
}

:where(.material-action-btn.is-primary) {
  border-color: color-mix(in srgb, var(--memovia-primary, #3498db) 30%, var(--memovia-border, #dbe2ea));
  background: color-mix(in srgb, var(--memovia-primary, #3498db) 10%, white);
  color: var(--memovia-primary-dark, #1d4ed8);
}

:where(.material-action-btn.is-danger) {
  border-color: color-mix(in srgb, var(--memovia-error, #ef4444) 30%, var(--memovia-border, #dbe2ea));
  background: color-mix(in srgb, var(--memovia-error, #ef4444) 8%, white);
  color: var(--memovia-error-dark, #b91c1c);
}

:where(.review-status) {
  margin-bottom: 5px;
  font-size: 0.8rem;
  color: var(--memovia-text-light, #666);
}

:where(.review-progress) {
  border-radius: 4px;
  height: 6px;
  background-color: var(--memovia-surface-strong, #e9ecef);
}

:where(.materials-list-close) {
  position: absolute;
  top: 15px;
  right: 15px;
  width: 30px;
  height: 30px;
  border-radius: 50%;
  background-color: var(--memovia-surface-muted, #f8f9fa);
  color: var(--memovia-text-light, #666);
  font-size: 1.2rem;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all 0.3s ease;
}

:where(.materials-list-close:hover) {
  background-color: var(--memovia-surface-strong, #e9ecef);
  color: var(--memovia-text, #333);
  transform: rotate(90deg);
}

:where(.material-modal) {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: rgba(15, 23, 42, 0.32);
  backdrop-filter: blur(8px);
  z-index: 1100;
  display: none;
  opacity: 0;
  transition: opacity 0.3s ease;
}

:where(.material-modal.active) {
  opacity: 1;
}

:where(.material-modal-content) {
  position: relative;
  margin: 5% auto;
  width: min(840px, calc(100vw - 32px));
  max-width: 840px;
  border-radius: 20px;
  border: 1px solid color-mix(in srgb, var(--memovia-border, #e5e7eb) 88%, white);
  background: color-mix(in srgb, var(--memovia-surface-elevated, #fff) 96%, white);
  box-shadow: 0 30px 80px rgba(15, 23, 42, 0.24);
  transform: translateY(-14px) scale(0.985);
  transition: transform 0.28s ease, box-shadow 0.28s ease;
  overflow: hidden;
}

:where(.material-modal.active .material-modal-content) {
  transform: translateY(0) scale(1);
}

:where(.material-modal-header) {
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 12px;
  padding: 20px 22px 18px;
  border-bottom: 1px solid color-mix(in srgb, var(--memovia-border, #e5e7eb) 85%, white);
  background: linear-gradient(180deg, color-mix(in srgb, var(--memovia-primary, #3498db) 6%, white), transparent);
}

:where(.material-modal-title) {
  font-size: 1.18rem;
  color: var(--memovia-text-strong, #2c3e50);
  font-weight: 800;
  letter-spacing: -0.02em;
  flex: 1 1 auto;
  min-width: 180px;
}

:where(.material-modal-close) {
  width: 32px;
  height: 32px;
  border-radius: 50%;
  background-color: var(--memovia-surface-muted, #f8f9fa);
  border: none;
  color: var(--memovia-text-light, #666);
  font-size: 1.5rem;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all 0.3s ease;
}

:where(.material-modal-close:hover) {
  background-color: var(--memovia-surface-strong, #e9ecef);
  color: var(--memovia-text, #333);
  transform: rotate(90deg);
}

:where(.material-modal-body) {
  padding: 22px;
  max-height: min(62vh, 680px);
  overflow-y: auto;
  line-height: 1.72;
  color: var(--memovia-text, #333);
  background: color-mix(in srgb, var(--memovia-surface-elevated, #fff) 98%, white);
}

:where(.material-modal-footer) {
  padding: 16px 22px 20px;
  display: flex;
  flex-direction: row;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
  border-top: 1px solid color-mix(in srgb, var(--memovia-border, #eee) 85%, white);
  background: linear-gradient(180deg, color-mix(in srgb, var(--memovia-surface-muted, #f8f9fa) 92%, white), var(--memovia-surface-muted, #f8f9fa));
  border-radius: 0 0 20px 20px;
}

:where(.material-modal-date),
:where(.material-modal-review) {
  font-size: 0.9rem;
  color: var(--memovia-text-soft, #475569);
}

:where(.text-modal) {
  display: none;
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: rgba(15, 23, 42, 0.38);
  backdrop-filter: blur(8px);
  z-index: 1200;
  opacity: 0;
  transition: opacity 0.3s ease;
}

:where(.text-modal.active) {
  opacity: 1;
}

:where(.text-modal-content) {
  position: relative;
  margin: 5% auto;
  width: min(840px, calc(100vw - 32px));
  max-width: 840px;
  border-radius: 20px;
  border: 1px solid color-mix(in srgb, var(--memovia-border, #e5e7eb) 88%, white);
  background: color-mix(in srgb, var(--memovia-surface-elevated, #fff) 98%, white);
  box-shadow: 0 30px 80px rgba(15, 23, 42, 0.26);
  transform: translateY(-14px) scale(0.985);
  transition: transform 0.28s ease, box-shadow 0.28s ease;
  overflow: hidden;
}

:where(.text-modal.active .text-modal-content) {
  transform: translateY(0) scale(1);
}

:where(.text-modal-header) {
  padding: 20px 22px 18px;
  border-bottom: 1px solid color-mix(in srgb, var(--memovia-border, #eee) 85%, white);
  display: flex;
  justify-content: space-between;
  align-items: center;
  flex-wrap: wrap;
  gap: 12px;
  background: linear-gradient(180deg, color-mix(in srgb, var(--memovia-primary, #3498db) 6%, white), transparent);
}

:where(.text-modal-title) {
  font-size: 1.18rem;
  color: var(--memovia-text-strong, #2c3e50);
  font-weight: 800;
  letter-spacing: -0.02em;
  flex: 1 1 auto;
  min-width: 180px;
}

:where(.text-modal-close) {
  width: 32px;
  height: 32px;
  border-radius: 50%;
  background-color: var(--memovia-surface-muted, #f8f9fa);
  border: none;
  color: var(--memovia-text-light, #666);
  font-size: 1.5rem;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all 0.3s ease;
}

:where(.text-modal-close:hover) {
  background-color: var(--memovia-surface-strong, #e9ecef);
  color: var(--memovia-text, #333);
  transform: rotate(90deg);
}

:where(.text-modal-body) {
  padding: 22px;
  max-height: min(62vh, 680px);
  overflow-y: auto;
  background: color-mix(in srgb, var(--memovia-surface-elevated, #fff) 98%, white);
}

:where(.text-content) {
  line-height: 1.72;
  color: var(--memovia-text, #333);
  white-space: pre-wrap;
  position: relative;
}

:where(.text-content .edit-btn) {
  position: absolute;
  top: 10px;
  right: 10px;
  padding: 8px 16px;
  background-color: var(--memovia-primary, #3498db);
  color: var(--memovia-on-primary, #fff);
  border: none;
  border-radius: 4px;
  cursor: pointer;
}

:where(.text-edit-area) {
  width: 100%;
  min-height: 200px;
  padding: 15px;
  border: 1px solid var(--memovia-border, #ddd);
  border-radius: 4px;
  font-size: 1rem;
  line-height: 1.6;
  margin-bottom: 15px;
  resize: vertical;
  background: var(--memovia-surface, #fff);
  color: var(--memovia-text, #333);
}

:where(.text-edit-buttons) {
  display: flex;
  justify-content: flex-end;
  gap: 10px;
}

:where(.save-btn),
:where(.cancel-btn),
:where(.edit-original-btn-header),
:where(.preview-original-btn-header) {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 38px;
  padding: 0 14px;
  font-size: 0.9em;
  border: 1px solid transparent;
  border-radius: 10px;
  cursor: pointer;
  margin-left: 10px;
  font-weight: 700;
  transition: all 0.2s ease;
}

:where(.save-btn),
:where(.edit-original-btn-header) {
  background: color-mix(in srgb, var(--memovia-primary, #3498db) 90%, white);
  border-color: color-mix(in srgb, var(--memovia-primary, #3498db) 28%, white);
  color: var(--memovia-on-primary, #fff);
}

:where(.cancel-btn),
:where(.preview-original-btn-header) {
  background: color-mix(in srgb, var(--memovia-surface-muted, #f3f4f6) 92%, white);
  border-color: var(--memovia-border, #e5e7eb);
  color: var(--memovia-text-soft, #334155);
}

:where(.save-btn:hover),
:where(.cancel-btn:hover),
:where(.edit-original-btn-header:hover),
:where(.preview-original-btn-header:hover) {
  transform: translateY(-1px);
  box-shadow: 0 12px 24px rgba(15, 23, 42, 0.12);
}

:where(.edit-original-btn-header:disabled),
:where(.preview-original-btn-header:disabled) {
  opacity: 0.55;
  cursor: not-allowed;
}

:where(.original-preview-modal) {
  width: min(920px, calc(100vw - 32px));
}

:where(.original-preview-modal-body) {
  padding: 0;
}

:where(.original-preview-body) {
  min-height: 420px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--memovia-surface-subtle, #f8fafc);
}

:where(.original-preview-body.is-light-bg) {
  background: #fff;
}

:where(.original-preview-body.is-dark-bg) {
  background: #0f172a;
}

:where(.original-preview-media) {
  max-width: 100%;
  max-height: 72vh;
  object-fit: contain;
  display: none;
}

:where(.original-preview-object) {
  width: 100%;
  height: 72vh;
  display: none;
}

:where(.original-preview-text) {
  width: 100%;
  max-height: 72vh;
  overflow: auto;
  padding: 24px;
  color: var(--memovia-text-strong, #0f172a);
  white-space: pre-wrap;
  line-height: 1.65;
  display: none;
}

:where(.original-preview-hint) {
  padding: 14px 18px 18px;
  color: var(--memovia-text-light, #64748b);
  font-size: 0.88rem;
}

@media (max-width: 992px) {
  :where(.materials-list) {
    width: 100%;
    height: min(60vh, 480px);
    top: auto;
    bottom: calc(70px + env(safe-area-inset-bottom));
    border-left: 0;
    border-top: 1px solid var(--memovia-border, #e5e7eb);
    transform: translateY(100%);
  }

  :where(.materials-list.active) {
    transform: translateY(0);
  }

  :where(.material-actions) {
    flex-wrap: wrap;
  }

  :where(.material-action-btn) {
    flex: 1 1 calc(50% - 4px);
  }

  :where(.material-modal-content),
  :where(.text-modal-content) {
    width: calc(100vw - 20px);
    margin: 18px auto;
    border-radius: 18px;
  }

  :where(.material-modal-body),
  :where(.text-modal-body) {
    max-height: calc(100vh - 180px);
    padding: 18px;
  }

  :where(.material-modal-footer) {
    flex-direction: column;
    align-items: flex-start;
  }
}

:where(.sidebar-shell .sidebar-toggle-btn) {
  display: flex;
  align-items: center;
  justify-content: flex-start;
  gap: 10px;
  background: var(--memovia-surface, #fff);
  color: var(--memovia-text-strong, #0f172a);
  border: 1px solid var(--memovia-border, #e5e7eb);
  padding: 10px 12px;
  border-radius: var(--memovia-radius-lg, 12px);
  cursor: pointer;
  margin-bottom: 12px;
  width: 100%;
  text-align: left;
  transition: background-color 0.2s ease, border-color 0.2s ease, color 0.2s ease;
}

:where(.sidebar-shell .sidebar-toggle-btn:hover) {
  background: var(--memovia-surface-muted, #f8fafc);
  border-color: var(--memovia-border-strong, #cbd5e1);
  color: var(--memovia-primary-dark, #1d4ed8);
}

:where(.sidebar-shell .sidebar-toggle-icon) {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 30px;
  height: 30px;
  border-radius: var(--memovia-radius-pill, 999px);
  background: var(--memovia-surface-muted, #f8fafc);
  border: 1px solid var(--memovia-border, #e5e7eb);
  flex: 0 0 auto;
}

:where(.sidebar-shell .sidebar-toggle-label) {
  font-size: 0.92rem;
  font-weight: 800;
  letter-spacing: -0.01em;
  line-height: 1;
}

:where(.sidebar-shell .sidebar-quick-links) {
  display: none;
}

:where(.sidebar-shell .sidebar-quick-icon-link) {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 40px;
  height: 40px;
  border-radius: var(--memovia-radius-pill, 999px);
  background: var(--memovia-surface, #fff);
  border: 1px solid var(--memovia-border, #e5e7eb);
  color: var(--memovia-primary, #2563eb);
  text-decoration: none;
  transition: background-color 0.2s ease, border-color 0.2s ease, color 0.2s ease;
}

:where(.sidebar-shell .sidebar-quick-icon-link:hover) {
  background: var(--memovia-surface-muted, #f8fafc);
  border-color: var(--memovia-border-strong, #cbd5e1);
  color: var(--memovia-primary-dark, #1d4ed8);
}

:where(.sidebar-shell .sidebar-double-divider) {
  display: flex;
  flex-direction: column;
  gap: 6px;
  padding: 0 2px;
}

:where(.sidebar-shell .sidebar-double-divider span),
:where(.sidebar-shell .sidebar-menu-divider) {
  display: block;
  height: 1px;
  background: var(--memovia-divider-fade);
}

:where(.overlay) {
  display: none;
  position: fixed;
  inset: 0;
  background: var(--memovia-overlay-bg, rgba(15, 23, 42, 0.45));
  z-index: 9900;
  align-items: center;
  justify-content: center;
}

:where(.overlay.active) {
  display: flex;
}

:where(.modal) {
  background: var(--memovia-surface-elevated, #fff);
  width: 92vw;
  max-width: 720px;
  border-radius: var(--memovia-radius-xl, 16px);
  overflow: hidden;
  box-shadow: var(--memovia-shadow-modal, 0 24px 48px rgba(15, 23, 42, 0.24));
  border: 1px solid var(--memovia-border, #e5e7eb);
}

:where(.modal-header) {
  padding: 16px;
  border-bottom: 1px solid var(--memovia-border, #e5e7eb);
  display: flex;
  align-items: center;
  justify-content: space-between;
}

:where(.modal-title) {
  font-weight: 800;
  color: var(--memovia-text-strong, #0f172a);
  letter-spacing: -0.01em;
}

:where(.modal-body) {
  padding: 20px;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
}

:where(.modal-footer) {
  padding: 12px 16px;
  border-top: 1px solid var(--memovia-border, #e5e7eb);
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 10px;
}

:where(.upload-zone) {
  border: 2px dashed var(--memovia-border-strong, #cbd5e1);
  border-radius: var(--memovia-radius-xl, 16px);
  padding: 36px 28px;
  text-align: center;
  color: var(--memovia-text-light, #475569);
  cursor: pointer;
  transition: border-color 0.2s ease, background-color 0.2s ease, box-shadow 0.2s ease;
  background: linear-gradient(0deg, var(--memovia-surface, #fff), var(--memovia-surface-subtle, #fafafa));
  display: block;
  max-width: 560px;
  width: 100%;
  margin: 8px auto;
}

:where(.upload-zone:hover) {
  border-color: var(--memovia-primary, #2563eb);
  background: linear-gradient(0deg, var(--memovia-primary-soft, #f8fbff), var(--memovia-surface, #fff));
  box-shadow: inset 0 1px 0 var(--memovia-primary-soft-strong, rgba(37, 99, 235, 0.08));
}

:where(.preview) {
  overflow: hidden;
  border-radius: var(--memovia-radius-lg, 12px);
  border: 1px solid var(--memovia-border, #e5e7eb);
  background: var(--memovia-surface-muted, #f8fafc);
}

:where(.preview img) {
  display: block;
  width: 100%;
  height: auto;
  max-height: 60vh;
  object-fit: contain;
  transition: transform 0.2s ease;
}

:where(.progress) {
  flex: 1;
  height: 10px;
  background: var(--memovia-surface-strong, #f1f5f9);
  border-radius: var(--memovia-radius-pill, 999px);
  overflow: hidden;
  display: none;
}

:where(.bar) {
  height: 100%;
  width: 0%;
  background: linear-gradient(90deg, var(--memovia-ai, #10b981), var(--memovia-ai-light, #34d399));
  transition: width 0.25s ease;
}

:where(.progress-bar-container) {
  height: 10px;
  background: var(--memovia-surface-strong, #f1f5f9);
  border-radius: var(--memovia-radius-pill, 9999px);
  overflow: hidden;
  margin-top: 12px;
  opacity: 0;
  max-width: 560px;
  transition: opacity 0.2s ease;
}

:where(.progress-bar-container.visible) {
  opacity: 1;
}

:where(.progress-bar) {
  height: 100%;
  width: 0%;
  background: linear-gradient(90deg, var(--memovia-ai, #10b981), var(--memovia-ai-light, #34d399));
  transition: width 0.25s ease;
  border-radius: var(--memovia-radius-pill, 9999px);
}

:where(.progress-bar.success) {
  background: linear-gradient(90deg, var(--memovia-success, #10b981), var(--memovia-success-dark, #059669));
}

:where(.progress-bar.error) {
  background: linear-gradient(90deg, var(--memovia-error, #ef4444), var(--memovia-error-dark, #dc2626));
}

:where(.mobile-bottom-bar) {
  display: none;
}

:where(.site-footer) {
  margin-top: 40px;
  background: var(--memovia-surface-muted, #f8fafc);
  border-top: 1px solid var(--memovia-border, #e5e7eb);
}

:where(.site-footer-inner) {
  max-width: 1200px;
  margin: 0 auto;
  padding: 24px 16px;
  color: var(--memovia-text-soft, #334155);
  text-align: center;
}

:where(.site-footer-stack) {
  display: flex;
  flex-direction: column;
  gap: 10px;
  font-size: 14px;
  line-height: 1.8;
  align-items: center;
}

:where(.site-footer-title) {
  font-weight: 800;
  color: var(--memovia-text-strong, #0f172a);
}

:where(.site-footer-note) {
  color: var(--memovia-text-soft, #475569);
}

:where(.site-footer-links) {
  display: flex;
  gap: 16px;
  flex-wrap: wrap;
  justify-content: center;
  margin-top: 6px;
}

:where(.site-footer-link) {
  color: var(--memovia-primary, #2563eb);
  text-decoration: none;
}

:where(.site-footer-link:hover) {
  color: var(--memovia-primary-dark, #1d4ed8);
}

:where(.site-footer-sep) {
  color: var(--memovia-border-strong, #cbd5e1);
}

:where(.site-footer-copy) {
  margin-top: 8px;
  color: var(--memovia-text-light, #64748b);
  font-size: 13px;
}

@media (max-width: 768px) {
  :where(.nav) {
    padding-left: 11px !important;
    padding-right: 12px !important;
  }

  :where(.nav .container.nav-content) {
    max-width: 100% !important;
    margin: 0 !important;
    padding-left: 0 !important;
    padding-right: 0 !important;
    display: grid;
    grid-template-columns: auto 1fr auto;
    align-items: center;
    gap: 8px;
  }

  :where(.nav-left) {
    margin-left: 0 !important;
    gap: 0;
    min-width: 40px;
    justify-self: start;
  }

  :where(button.nav-sidebar-toggle),
  :where(button.nav-sidebar-toggle.btn),
  :where(button.nav-sidebar-toggle.btn-outline) {
    color: var(--memovia-text-strong, #0f172a) !important;
    border: 0 !important;
    background: transparent !important;
    box-shadow: none !important;
  }

  :where(.nav .logo) {
    display: none;
  }

  :where(.nav-center) {
    display: flex;
    position: absolute;
    left: 50%;
    transform: translateX(-50%);
    justify-content: center;
    width: max-content;
    z-index: 0;
  }

  :where(.nav-links) {
    display: flex !important;
    gap: 8px;
    position: relative;
    z-index: 1;
    justify-self: end;
  }

  :where(.nav-actions-group),
  :where(.nav-expandable-links),
  :where(.nav-actions-toggle) {
    display: none !important;
  }

  :where(.nav-mobile-bookmark) {
    display: inline-flex !important;
  }

  :where(.account-badge) {
    display: inline-flex !important;
    align-items: center;
    justify-content: center;
    width: 36px;
    height: 36px;
    min-width: 36px;
    max-width: 36px;
    padding: 0;
    text-align: center;
    border-radius: 9999px;
    overflow: hidden;
  }

  :where(.mobile-bottom-bar) {
    display: flex;
    position: fixed;
    left: 0;
    right: 0;
    bottom: 0;
    height: 64px;
    background: color-mix(in srgb, var(--memovia-surface, #fff) 94%, transparent);
    backdrop-filter: var(--memovia-backdrop-blur);
    border-top: 1px solid var(--memovia-border, #e5e7eb);
    z-index: 2500;
    padding: 6px 12px calc(6px + env(safe-area-inset-bottom));
    box-shadow: var(--memovia-shadow-mobile-bar);
    align-items: center;
    justify-content: space-between;
    gap: 10px;
  }

  :where(.mobile-bottom-bar .mb-btn) {
    flex: 1;
    min-width: 0;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 4px;
    color: var(--memovia-text-soft, #334155);
    text-decoration: none;
  }

  :where(.mobile-bottom-bar .mb-btn.is-active) {
    color: var(--memovia-primary, #2563eb);
  }

  :where(.mobile-bottom-bar .mb-btn svg) {
    width: 22px;
    height: 22px;
    display: block;
  }

  :where(.mobile-bottom-bar .mb-btn span) {
    font-size: 11px;
    font-weight: 700;
    letter-spacing: 0.01em;
  }

  :where(.mobile-bottom-bar .mb-btn:is(:active)) {
    transform: translateY(1px);
  }

  :where(.layout-shell) {
    flex-direction: column;
    align-items: stretch;
  }

  :where(.sidebar-shell) {
    flex: none;
    width: 100%;
    position: static;
    left: auto !important;
    top: auto !important;
    height: 0;
    min-height: 0;
    padding: 0;
    margin: 0;
    border: 0;
    border-radius: 0;
    box-shadow: none;
    opacity: 0;
    overflow: hidden;
    pointer-events: none;
  }

  :where(.sidebar-shell.collapsed) {
    width: 100%;
  }

  :where(.sidebar-shell-top) {
    gap: 10px;
    margin-bottom: 12px;
  }

  :where(.sidebar-shell.mobile-open) {
    flex: none;
    width: 100%;
    height: auto;
    min-height: 0;
    padding: 10px 10px calc(84px + env(safe-area-inset-bottom));
    border-top: 1px solid var(--memovia-border, #e5e7eb);
    background: var(--memovia-surface-elevated, #fff);
    box-shadow: var(--memovia-shadow-header);
    opacity: 1;
    overflow: visible;
    pointer-events: auto;
  }

  :where(.sidebar-shell .sidebar-toggle-btn) {
    display: none !important;
  }

  :where(.layout-main) {
    margin-left: 0;
    padding: 15px;
    width: 100%;
    max-width: 100%;
    min-width: 0;
    align-self: stretch;
  }

  :where(.ui-tabs) {
    flex-wrap: nowrap;
    gap: 6px;
  }

  :where(.ui-tab) {
    flex: 1 1 0;
    min-width: 0;
    min-height: 40px;
  }
}
