/* =============================================
   NoteD Web — Global Base Styles
   ============================================= */
@import url('https://fonts.googleapis.com/css2?family=Inter:wght@300;400;500;600;700;800&family=JetBrains+Mono:wght@400;500&display=swap');

/* === Reset & Base === */
*, *::before, *::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

html {
  font-size: 16px;
  -webkit-text-size-adjust: 100%;
  scroll-behavior: smooth;
}

body {
  font-family: var(--font-sans);
  font-size: var(--text-base);
  font-weight: var(--weight-regular);
  color: var(--text-primary);
  background: var(--color-bg);
  line-height: 1.6;
  min-height: 100vh;
  overflow-x: hidden;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

/* === Scrollbar === */
::-webkit-scrollbar { width: 4px; height: 4px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb {
  background: rgba(255,255,255,0.12);
  border-radius: var(--radius-full);
}
::-webkit-scrollbar-thumb:hover { background: rgba(255,255,255,0.22); }

/* === Selection === */
::selection {
  background: rgba(var(--color-accent-rgb), 0.3);
  color: var(--text-primary);
}

/* === Focus === */
:focus-visible {
  outline: 2px solid var(--color-accent);
  outline-offset: 2px;
  border-radius: var(--radius-sm);
}

/* === Typography === */
h1,h2,h3,h4,h5,h6 { font-weight: var(--weight-semibold); line-height: 1.3; }
p { line-height: 1.7; }
a { color: var(--color-accent); text-decoration: none; transition: opacity var(--transition-fast); }
a:hover { opacity: 0.8; }
code { font-family: var(--font-mono); }
img, video { max-width: 100%; display: block; }
button { font-family: inherit; cursor: pointer; border: none; background: none; color: inherit; }
input, textarea, select { font-family: inherit; color: inherit; }

/* === App Layout === */
#app {
  display: flex;
  flex-direction: column;
  height: 100vh;
  overflow: hidden;
  position: relative;
}

/* Master layout: sidebar + main content */
.app-layout {
  display: flex;
  flex: 1;
  overflow: hidden;
}

/* === View Management === */
.view { display: none; flex: 1; overflow: hidden; flex-direction: column; }
.view.active { display: flex; }

/* === Sidebar (Home) === */
.sidebar {
  width: 380px;
  min-width: 320px;
  max-width: 420px;
  background: var(--color-bg);
  border-right: 1px solid var(--color-border);
  display: flex;
  flex-direction: column;
  overflow: hidden;
  position: relative;
  flex-shrink: 0;
}

/* === Main Panel === */
.main-panel {
  flex: 1;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  background: var(--color-bg);
}

/* === Mobile: stack layout === */
@media (max-width: 768px) {
  .app-layout { position: relative; }
  .sidebar {
    position: absolute; inset: 0;
    width: 100%; max-width: 100%;
    z-index: var(--z-base);
    transform: translateX(0);
    transition: transform var(--transition-base);
  }
  .sidebar.hidden { transform: translateX(-100%); }
  .main-panel {
    position: absolute; inset: 0;
    transform: translateX(100%);
    transition: transform var(--transition-base);
  }
  .main-panel.active { transform: translateX(0); }
}

/* === Overlay / Backdrop === */
.backdrop {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.7);
  backdrop-filter: blur(4px);
  z-index: var(--z-overlay);
  opacity: 0;
  pointer-events: none;
  transition: opacity var(--transition-base);
}
.backdrop.visible { opacity: 1; pointer-events: auto; }

/* === Modal === */
.modal {
  position: fixed;
  inset: 0;
  z-index: var(--z-modal);
  display: flex;
  align-items: flex-end;
  justify-content: center;
  opacity: 0;
  pointer-events: none;
  transition: opacity var(--transition-base);
  padding: var(--space-4);
}
.modal.visible { opacity: 1; pointer-events: auto; }
.modal--center { align-items: center; }

.modal__content {
  background: var(--color-surface);
  border-radius: var(--radius-2xl) var(--radius-2xl) var(--radius-lg) var(--radius-lg);
  width: 100%;
  max-width: 640px;
  max-height: 90vh;
  overflow: hidden;
  display: flex;
  flex-direction: column;
  border: 1px solid var(--color-border);
  box-shadow: var(--shadow-lg);
  transform: translateY(30px) scale(0.98);
  transition: transform var(--transition-base);
}
.modal.visible .modal__content { transform: translateY(0) scale(1); animation: slideInModal 0.35s cubic-bezier(0.16,1,0.3,1); }
.modal--center .modal__content {
  border-radius: var(--radius-2xl);
  max-width: 480px;
}

/* === Toast === */
.toast-container {
  position: fixed;
  bottom: 24px;
  left: 50%;
  transform: translateX(-50%);
  z-index: var(--z-toast);
  display: flex;
  flex-direction: column;
  gap: var(--space-2);
  align-items: center;
  pointer-events: none;
}

.toast {
  background: var(--color-surface2);
  color: var(--text-primary);
  padding: var(--space-3) var(--space-5);
  border-radius: var(--radius-full);
  font-size: var(--text-sm);
  font-weight: var(--weight-medium);
  border: 1px solid var(--color-border);
  box-shadow: var(--shadow-md);
  animation: toastIn 0.3s ease forwards;
  white-space: nowrap;
}
.toast--success { border-color: rgba(var(--color-green-rgb), 0.4); color: var(--color-green); }
.toast--error { border-color: rgba(var(--color-red-rgb), 0.4); color: var(--color-red); }

/* === Empty State === */
.empty-state {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  flex: 1;
  padding: var(--space-8);
  gap: var(--space-5);
  text-align: center;
}

.empty-state__icon {
  width: 96px;
  height: 96px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 44px;
  background: rgba(var(--color-accent-rgb), 0.1);
}

.empty-state__title {
  font-size: var(--text-xl);
  font-weight: var(--weight-semibold);
  color: var(--text-primary);
}

.empty-state__desc {
  font-size: var(--text-sm);
  color: var(--text-secondary);
  line-height: 1.7;
  max-width: 280px;
}

/* === Divider === */
.divider {
  height: 1px;
  background: var(--color-border);
  flex-shrink: 0;
}

/* === Gradient text === */
.gradient-text {
  background: var(--gradient-accent);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
}

/* === Utility === */
.flex { display: flex; }
.flex-col { flex-direction: column; }
.items-center { align-items: center; }
.justify-center { justify-content: center; }
.justify-between { justify-content: space-between; }
.gap-1 { gap: var(--space-1); }
.gap-2 { gap: var(--space-2); }
.gap-3 { gap: var(--space-3); }
.gap-4 { gap: var(--space-4); }
.gap-5 { gap: var(--space-5); }
.gap-6 { gap: var(--space-6); }
.flex-1 { flex: 1; }
.overflow-hidden { overflow: hidden; }
.overflow-y-auto { overflow-y: auto; }
.text-center { text-align: center; }
.w-full { width: 100%; }
.h-full { height: 100%; }
.hidden { display: none !important; }
.sr-only {
  position: absolute; width: 1px; height: 1px;
  padding: 0; margin: -1px; overflow: hidden;
  clip: rect(0,0,0,0); border: 0;
}

/* === Scrollable === */
.scroll-y {
  overflow-y: auto;
  overflow-x: hidden;
  -webkit-overflow-scrolling: touch;
}
