:root {
  --color-primary: #1A1F2E;
  --color-primary-light: #2D3548;
  --color-accent: #2563EB;
  --color-accent-light: #3B82F6;
  --color-accent-soft: rgba(37, 99, 235, 0.08);
  --color-bg: #F4F6F9;
  --color-surface: #FFFFFF;
  --color-surface-elevated: #FFFFFF;
  --color-border: #E2E8F0;
  --color-border-light: #F1F5F9;
  --color-success: #10B981;
  --color-success-soft: rgba(16, 185, 129, 0.08);
  --color-warning: #F59E0B;
  --color-warning-soft: rgba(245, 158, 11, 0.08);
  --color-danger: #EF4444;
  --color-danger-soft: rgba(239, 68, 68, 0.08);
  --color-gold: #D97706;
  --color-gold-soft: rgba(217, 119, 6, 0.08);
  --color-text: #0F172A;
  --color-text-secondary: #64748B;
  --color-text-tertiary: #94A3B8;
  --color-text-inverse: #FFFFFF;

  --font-base: 'Inter', 'Noto Sans SC', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
  --font-mono: 'SF Mono', Monaco, 'Cascadia Code', monospace;

  --radius-sm: 8px;
  --radius-md: 12px;
  --radius-lg: 16px;
  --radius-xl: 20px;
  --radius-full: 9999px;

  --shadow-sm: 0 1px 2px rgba(15, 23, 42, 0.04);
  --shadow-md: 0 4px 12px rgba(15, 23, 42, 0.06);
  --shadow-lg: 0 12px 32px rgba(15, 23, 42, 0.1);
  --shadow-xl: 0 24px 48px rgba(15, 23, 42, 0.12);

  --sidebar-width: 240px;
  --sidebar-collapsed: 72px;
  --header-height: 72px;
  --transition-base: 0.2s cubic-bezier(0.4, 0, 0.2, 1);
  --transition-bounce: 0.35s cubic-bezier(0.34, 1.56, 0.64, 1);
}

*, *::before, *::after {
  box-sizing: border-box;
}

* {
  margin: 0;
  padding: 0;
}

html, body {
  font-size: 16px;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  height: 100%;
  width: 100%;
  overflow: hidden;
}

body {
  font-family: var(--font-base);
  background-color: #0F172A;
  color: var(--color-text);
  line-height: 1.5;
}

button {
  font-family: inherit;
  cursor: pointer;
  border: none;
  background: none;
}

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

ul, ol {
  list-style: none;
}

svg {
  display: block;
  flex-shrink: 0;
}

/* ===== Desktop Canvas ===== */
.desktop-canvas {
  width: 100%;
  height: 100%;
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 40px;
  background:
    radial-gradient(ellipse at 20% 20%, rgba(59, 130, 246, 0.18) 0%, transparent 50%),
    radial-gradient(ellipse at 80% 80%, rgba(139, 92, 246, 0.14) 0%, transparent 50%),
    radial-gradient(ellipse at 50% 50%, rgba(14, 165, 233, 0.08) 0%, transparent 60%),
    linear-gradient(135deg, #0F172A 0%, #1E293B 50%, #0F172A 100%);
  background-attachment: fixed;
  position: relative;
}

.desktop-canvas::before {
  content: '';
  position: absolute;
  inset: 0;
  background-image:
    radial-gradient(circle at 25% 25%, rgba(255, 255, 255, 0.03) 1px, transparent 1px),
    radial-gradient(circle at 75% 75%, rgba(255, 255, 255, 0.03) 1px, transparent 1px);
  background-size: 60px 60px;
  pointer-events: none;
}

/* ===== Client Window ===== */
.client-window {
  position: relative;
  width: 100%;
  max-width: 1440px;
  height: calc(100vh - 80px);
  max-height: 1000px;
  display: flex;
  flex-direction: column;
  background: rgba(255, 255, 255, 0.96);
  border: 1px solid rgba(255, 255, 255, 0.2);
  border-radius: 18px;
  box-shadow:
    0 32px 96px rgba(0, 0, 0, 0.22),
    0 12px 32px rgba(0, 0, 0, 0.12),
    inset 0 1px 0 rgba(255, 255, 255, 0.4);
  backdrop-filter: blur(20px);
  -webkit-backdrop-filter: blur(20px);
  overflow: hidden;
  animation: windowAppear 0.5s cubic-bezier(0.34, 1.56, 0.64, 1) both;
}

@keyframes windowAppear {
  from {
    opacity: 0;
    transform: scale(0.96) translateY(20px);
  }
  to {
    opacity: 1;
    transform: scale(1) translateY(0);
  }
}

.window-titlebar {
  flex-shrink: 0;
  height: 42px;
  background: rgba(248, 250, 252, 0.85);
  border-bottom: 1px solid rgba(226, 232, 240, 0.8);
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 16px;
  position: relative;
  z-index: 60;
}

.window-titlebar__controls {
  display: flex;
  align-items: center;
  gap: 10px;
}

.window-titlebar__title {
  position: absolute;
  left: 50%;
  top: 50%;
  transform: translate(-50%, -50%);
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 13px;
  font-weight: 600;
  color: var(--color-text-secondary);
}

.window-titlebar__logo {
  width: 18px;
  height: 18px;
  color: var(--color-accent);
}

.window-titlebar__spacer {
  width: 66px;
}

.window-body {
  flex: 1;
  position: relative;
  overflow: hidden;
  display: flex;
}

.client-window__resize-handle {
  position: absolute;
  right: 4px;
  bottom: 4px;
  width: 12px;
  height: 12px;
  background: linear-gradient(
    135deg,
    transparent 45%,
    rgba(15, 23, 42, 0.2) 45%,
    rgba(15, 23, 42, 0.2) 55%,
    transparent 55%
  );
  pointer-events: none;
  z-index: 70;
}

.app {
  display: grid;
  grid-template-columns: var(--sidebar-width) 1fr;
  width: 100%;
  height: 100%;
  min-height: 0;
}

/* ===== Sidebar ===== */
.sidebar {
  position: relative;
  width: var(--sidebar-width);
  height: 100%;
  background: var(--color-primary);
  color: var(--color-text-inverse);
  display: flex;
  flex-direction: column;
  z-index: 50;
  transition: width var(--transition-base);
  overflow: hidden;
}

.sidebar__brand {
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 20px;
  border-bottom: 1px solid rgba(255, 255, 255, 0.08);
  flex-shrink: 0;
}

.brand__logo {
  width: 36px;
  height: 36px;
  color: var(--color-accent-light);
  flex-shrink: 0;
}

.logo-mark {
  width: 100%;
  height: 100%;
}

.brand__text {
  display: flex;
  flex-direction: column;
  gap: 2px;
  overflow: hidden;
}

.brand__title {
  font-size: 15px;
  font-weight: 700;
  white-space: nowrap;
}

.brand__subtitle {
  font-size: 10px;
  color: rgba(255, 255, 255, 0.55);
  white-space: nowrap;
}

.sidebar__nav {
  flex: 1;
  padding: 16px 12px;
  overflow-y: auto;
  min-height: 0;
}

.nav__list {
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.nav__divider {
  height: 1px;
  background: rgba(255, 255, 255, 0.08);
  margin: 16px 0;
}

.nav__link {
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 11px 14px;
  border-radius: var(--radius-md);
  color: rgba(255, 255, 255, 0.7);
  font-size: 14px;
  font-weight: 500;
  transition: all var(--transition-base);
  position: relative;
}

.nav__link:hover {
  background: rgba(255, 255, 255, 0.06);
  color: rgba(255, 255, 255, 0.9);
}

.nav__link--active {
  background: var(--color-accent);
  color: var(--color-text-inverse);
  box-shadow: 0 4px 14px rgba(37, 99, 235, 0.35);
}

.nav__link--active:hover {
  background: var(--color-accent-light);
  color: var(--color-text-inverse);
}

.nav__link--active::before {
  content: '';
  position: absolute;
  left: -12px;
  top: 50%;
  transform: translateY(-50%);
  width: 4px;
  height: 24px;
  background: var(--color-accent-light);
  border-radius: 0 4px 4px 0;
}

.nav__icon {
  width: 20px;
  height: 20px;
  flex-shrink: 0;
}

.sidebar__footer {
  padding: 16px 12px;
  border-top: 1px solid rgba(255, 255, 255, 0.08);
  flex-shrink: 0;
}

.membership-mini {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px;
  background: rgba(245, 158, 11, 0.12);
  border: 1px solid rgba(245, 158, 11, 0.2);
  border-radius: var(--radius-md);
  cursor: pointer;
  transition: all var(--transition-base);
}

.membership-mini:hover {
  background: rgba(245, 158, 11, 0.18);
  transform: translateY(-1px);
}

.membership-mini__icon {
  width: 22px;
  height: 22px;
  color: var(--color-gold);
}

.membership-mini__info {
  display: flex;
  flex-direction: column;
  gap: 2px;
  overflow: hidden;
}

.membership-mini__tier {
  font-size: 13px;
  font-weight: 600;
  color: #FCD34D;
}

.membership-mini__hint {
  font-size: 11px;
  color: rgba(255, 255, 255, 0.6);
  white-space: nowrap;
}

/* ===== Main Area ===== */
.main-area {
  grid-column: 2;
  display: flex;
  flex-direction: column;
  height: 100%;
  min-height: 0;
  overflow: hidden;
}

/* ===== Header ===== */
.header {
  flex-shrink: 0;
  height: var(--header-height);
  background: var(--color-surface);
  border-bottom: 1px solid var(--color-border);
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 32px;
  z-index: 40;
}

.header__menu-toggle {
  display: none;
  align-items: center;
  justify-content: center;
  width: 40px;
  height: 40px;
  border-radius: var(--radius-md);
  color: var(--color-text-secondary);
  transition: all var(--transition-base);
}

.header__menu-toggle:hover {
  background: var(--color-border-light);
  color: var(--color-text);
}

.header__brand {
  display: flex;
  align-items: center;
  gap: 16px;
}

.header__logo {
  display: none;
  width: 36px;
  height: 36px;
  color: var(--color-accent);
}

.header__greeting {
  font-size: 20px;
  font-weight: 700;
  color: var(--color-text);
}

.wave {
  display: inline-block;
  animation: wave 2s ease-in-out infinite;
  transform-origin: 70% 70%;
}

@keyframes wave {
  0%, 100% { transform: rotate(0deg); }
  25% { transform: rotate(14deg); }
  75% { transform: rotate(-8deg); }
}

.header__actions {
  display: flex;
  align-items: center;
  gap: 12px;
}

/* ===== Content ===== */
.content {
  flex: 1;
  padding: 32px;
  max-width: 1440px;
  width: 100%;
  margin: 0 auto;
  overflow-y: auto;
  min-height: 0;
}

/* ===== Dashboard ===== */
.dashboard {
  display: flex;
  flex-direction: column;
  gap: 28px;
}

.dashboard__header {
  animation: fadeInUp 0.5s ease-out both;
}

.dashboard__title {
  font-size: 26px;
  font-weight: 700;
  color: var(--color-text);
  margin-bottom: 6px;
}

.dashboard__subtitle {
  font-size: 15px;
  color: var(--color-text-secondary);
}

.dashboard__subtitle strong {
  color: var(--color-accent);
  font-weight: 600;
}

/* ===== Sections ===== */
.section {
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-lg);
  padding: 24px;
  box-shadow: var(--shadow-sm);
}

.section__header {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 20px;
}

.section__icon {
  font-size: 20px;
  line-height: 1;
}

.section__title {
  font-size: 17px;
  font-weight: 700;
  color: var(--color-text);
}

/* ===== Page View Placeholder ===== */
.page-view {
  display: block;
  min-height: 100%;
}

.page-view > * {
  width: 100%;
}

.page-view__content {
  margin: 0 auto;
  text-align: center;
  max-width: 400px;
  padding: 48px;
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-xl);
  box-shadow: var(--shadow-md);
  animation: fadeInUp 0.5s ease-out;
}

.page-view__icon {
  width: 80px;
  height: 80px;
  margin: 0 auto 24px;
  color: var(--color-text-tertiary);
}

.page-view__title {
  font-size: 24px;
  font-weight: 700;
  margin-bottom: 12px;
}

.page-view__desc {
  color: var(--color-text-secondary);
  margin-bottom: 24px;
}

/* ===== Toast ===== */
.toast {
  position: fixed;
  bottom: 28px;
  left: 50%;
  transform: translateX(-50%) translateY(100px);
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 14px 20px;
  background: var(--color-primary);
  color: var(--color-text-inverse);
  border-radius: var(--radius-full);
  box-shadow: var(--shadow-lg);
  opacity: 0;
  pointer-events: none;
  transition: all 0.3s cubic-bezier(0.34, 1.56, 0.64, 1);
  z-index: 200;
}

.toast--visible {
  transform: translateX(-50%) translateY(0);
  opacity: 1;
}

.toast__icon {
  width: 20px;
  height: 20px;
  color: var(--color-gold);
}

.toast__message {
  font-size: 14px;
  font-weight: 500;
}

/* ===== Animations ===== */
@keyframes fadeInUp {
  from {
    opacity: 0;
    transform: translateY(16px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

@keyframes pulse {
  0%, 100% { box-shadow: 0 0 0 0 rgba(37, 99, 235, 0.2); }
  50% { box-shadow: 0 0 0 8px rgba(37, 99, 235, 0); }
}

/* ===== Scrollbar ===== */
.sidebar__nav::-webkit-scrollbar,
.content::-webkit-scrollbar {
  width: 6px;
}

.sidebar__nav::-webkit-scrollbar-track,
.content::-webkit-scrollbar-track {
  background: transparent;
}

.sidebar__nav::-webkit-scrollbar-thumb {
  background: rgba(255, 255, 255, 0.15);
  border-radius: var(--radius-full);
}

.content::-webkit-scrollbar-thumb {
  background: var(--color-border);
  border-radius: var(--radius-full);
}

.content::-webkit-scrollbar-thumb:hover {
  background: var(--color-text-tertiary);
}

/* ===== Exam Focus Mode ===== */
body.exam-focus .sidebar,
body.exam-focus .header {
  display: none;
}

body.exam-focus .app {
  grid-template-columns: 1fr;
}

body.exam-focus .main-area {
  grid-column: 1 / -1;
}

body.exam-focus .content {
  padding: 0;
  max-width: none;
}

body.exam-focus .page-view#examTakingPage {
  max-width: none;
  padding: 0;
  margin: 0;
  text-align: left;
  background: transparent;
  border: none;
  border-radius: 0;
  box-shadow: none;
  height: 100%;
  min-height: 100%;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
  }
}
