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

html {
  font-size: 16px;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  scroll-behavior: smooth;
}

body {
  font-family: var(--font-sans);
  font-size: var(--text-base);
  line-height: var(--leading-normal);
  color: var(--text-primary);
  background: var(--bg-primary);
  min-height: 100vh;
  overflow-x: hidden;
}

a {
  color: var(--body);
  text-decoration: none;
  transition: color var(--transition-fast);
}

a:hover {
  color: var(--ink);
}

[data-theme="dark"] a {
  color: var(--color-teal);
}

[data-theme="dark"] a:hover {
  color: var(--color-teal-light);
}

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

input, textarea, select {
  font-family: inherit;
  font-size: inherit;
  color: inherit;
}

code {
  font-family: var(--font-mono);
  font-size: 0.9em;
  background: var(--bg-tertiary);
  padding: 0.15em 0.4em;
  border-radius: var(--radius-sm);
}

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

/* App layout */
.app {
  display: flex;
  flex-direction: column;
  min-height: 100vh;
}

.app-header {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  height: var(--header-height);
  background: rgba(255,255,255,0.95);
  border-bottom: 1px solid var(--border-primary);
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 var(--space-6);
  z-index: 100;
  backdrop-filter: blur(12px);
}

.app-body {
  display: flex;
  margin-top: var(--header-height);
  min-height: calc(100vh - var(--header-height));
}

.app-sidebar {
  position: fixed;
  top: var(--header-height);
  left: 0;
  bottom: 0;
  width: var(--sidebar-width);
  background: var(--bg-secondary);
  border-right: 1px solid var(--border-primary);
  overflow-y: auto;
  overflow-x: hidden;
  z-index: 50;
  transition: transform var(--transition-slow);
}

.app-main {
  margin-left: var(--sidebar-width);
  flex: 1;
  padding: var(--space-10) var(--space-8);
  display: flex;
  justify-content: center;
  overflow-x: hidden;
  min-width: 0;
}

.app-main-inner {
  width: 100%;
  max-width: var(--content-max-width);
}

/* Header elements */
.header-left {
  display: flex;
  align-items: center;
  gap: var(--space-3);
}

.header-logo {
  color: var(--text-primary);
  display: flex;
  align-items: center;
  gap: var(--space-2);
  text-decoration: none;
}

.header-logo:hover {
  color: var(--text-primary);
}

.header-pa-mark {
  flex-shrink: 0;
  display: flex;
  align-items: center;
}

.header-logo-text {
  display: flex;
  flex-direction: column;
  line-height: 1.1;
}

.header-logo-brand {
  font-size: var(--text-sm);
  font-weight: var(--weight-extrabold);
  color: var(--text-primary);
  letter-spacing: -0.01em;
  white-space: nowrap;
}

.header-logo-sub {
  font-size: var(--text-xs);
  color: var(--text-tertiary);
  font-weight: var(--weight-medium);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

@media (max-width: 480px) {
  .header-logo-sub {
    display: none;
  }
}

.header-right {
  display: flex;
  align-items: center;
  gap: var(--space-2);
}

.header-btn {
  width: 36px;
  height: 36px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: var(--radius-md);
  color: var(--text-secondary);
  transition: all var(--transition-fast);
}

.header-btn:hover {
  background: var(--bg-tertiary);
  color: var(--text-primary);
}

.header-search {
  display: flex;
  align-items: center;
  gap: var(--space-2);
  padding: var(--space-2) var(--space-3);
  background: var(--bg-tertiary);
  border-radius: var(--radius-md);
  color: var(--text-tertiary);
  font-size: var(--text-sm);
  cursor: pointer;
  transition: all var(--transition-fast);
  min-width: 200px;
}

.header-search:hover {
  background: var(--border-primary);
  color: var(--text-secondary);
}

.header-search kbd {
  font-family: var(--font-sans);
  font-size: var(--text-xs);
  background: var(--bg-elevated);
  padding: 2px 6px;
  border-radius: 4px;
  border: 1px solid var(--border-primary);
  margin-left: auto;
}

.mobile-menu-btn {
  display: none;
}

/* Responsive */
@media (max-width: 768px) {
  .app-sidebar {
    transform: translateX(-100%);
  }

  .app-sidebar.open {
    transform: translateX(0);
  }

  .app-main {
    margin-left: 0;
    padding: var(--space-6) var(--space-4);
  }

  .mobile-menu-btn {
    display: flex;
  }

  .header-search {
    min-width: auto;
  }

  .header-search span {
    display: none;
  }

  .header-search kbd {
    display: none;
  }
}

/* Scrollbar styling */
.app-sidebar::-webkit-scrollbar {
  width: 4px;
}

.app-sidebar::-webkit-scrollbar-track {
  background: transparent;
}

.app-sidebar::-webkit-scrollbar-thumb {
  background: var(--border-secondary);
  border-radius: var(--radius-full);
}

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

/* Utility classes */
.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}
