/* ================================================================== */
/*  Design Tokens                                                      */
/* ================================================================== */

:root {
  /* Palette - cool dark theme with accent */
  --clr-bg:           #0e0f14;
  --clr-surface:      #15161d;
  --clr-surface-alt:  #1c1d27;
  --clr-border:       #2a2b38;
  --clr-border-focus: #5b5eff;
  --clr-text:         #e2e4ed;
  --clr-text-muted:   #7e8295;
  --clr-accent:       #6c63ff;
  --clr-accent-glow:  rgba(108, 99, 255, .25);
  --clr-danger:       #ff5c6c;
  --clr-danger-glow:  rgba(255, 92, 108, .18);
  --clr-success:      #3ddc84;
  --clr-success-glow: rgba(61, 220, 132, .18);

  /* Typography */
  --font-sans: 'Inter', system-ui, -apple-system, sans-serif;
  --font-mono: 'JetBrains Mono', 'Fira Code', monospace;

  /* Spacing */
  --space-xs: 4px;
  --space-sm: 8px;
  --space-md: 16px;
  --space-lg: 24px;
  --space-xl: 32px;

  /* Radius */
  --radius-sm: 6px;
  --radius-md: 10px;
  --radius-lg: 16px;

  /* Transitions */
  --ease-out: cubic-bezier(.22, 1, .36, 1);
  --dur-fast: 150ms;
  --dur-med:  250ms;

  /* Sidebar */
  --sidebar-w: 320px;
}

/* ================================================================== */
/*  Reset & Base                                                       */
/* ================================================================== */

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

[hidden] {
  display: none !important;
}

html, body {
  height: 100%;
  font-family: var(--font-sans);
  font-size: 15px;
  line-height: 1.6;
  color: var(--clr-text);
  background: var(--clr-bg);
  -webkit-font-smoothing: antialiased;
}

/* ================================================================== */
/*  Unsupported Banner                                                 */
/* ================================================================== */

.unsupported-banner {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  min-height: 100vh;
  text-align: center;
  padding: var(--space-xl);
  gap: var(--space-md);
}

.unsupported-banner svg {
  color: var(--clr-danger);
  opacity: .8;
}

.unsupported-banner h1 {
  font-size: 1.6rem;
  font-weight: 700;
}

.unsupported-banner p {
  color: var(--clr-text-muted);
  max-width: 460px;
}

.unsupported-banner code {
  font-family: var(--font-mono);
  background: var(--clr-surface-alt);
  padding: 2px 8px;
  border-radius: var(--radius-sm);
  font-size: .85em;
}

/* ================================================================== */
/*  Layout                                                             */
/* ================================================================== */

.app {
  display: flex;
  height: 100vh;
  overflow: hidden;
}

/* ================================================================== */
/*  Sidebar                                                            */
/* ================================================================== */

.sidebar {
  width: var(--sidebar-w);
  min-width: var(--sidebar-w);
  display: flex;
  flex-direction: column;
  background: var(--clr-surface);
  border-right: 1px solid var(--clr-border);
}

.sidebar__header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: var(--space-md) var(--space-lg);
  border-bottom: 1px solid var(--clr-border);
}

.sidebar__title {
  font-size: 1.1rem;
  font-weight: 700;
  display: flex;
  align-items: center;
  gap: var(--space-sm);
}

.sidebar__title svg {
  color: var(--clr-accent);
}

.sidebar__actions {
  display: flex;
  gap: var(--space-sm);
}

/* ================================================================== */
/*  Buttons                                                            */
/* ================================================================== */

.btn {
  display: inline-flex;
  align-items: center;
  gap: var(--space-xs);
  padding: var(--space-sm) var(--space-md);
  font-family: var(--font-sans);
  font-size: .85rem;
  font-weight: 600;
  color: var(--clr-text);
  background: var(--clr-surface-alt);
  border: 1px solid var(--clr-border);
  border-radius: var(--radius-sm);
  cursor: pointer;
  transition: all var(--dur-fast) var(--ease-out);
  white-space: nowrap;
}

.btn:hover {
  background: var(--clr-border);
  border-color: var(--clr-border-focus);
  box-shadow: 0 0 0 3px var(--clr-accent-glow);
}

.btn:active {
  transform: scale(.96);
}

.btn--primary {
  background: var(--clr-accent);
  border-color: var(--clr-accent);
  color: #fff;
}

.btn--primary:hover {
  background: #7b73ff;
  border-color: #7b73ff;
}

.btn--danger {
  color: var(--clr-danger);
}

.btn--danger:hover {
  background: var(--clr-danger-glow);
  border-color: var(--clr-danger);
  box-shadow: 0 0 0 3px var(--clr-danger-glow);
}

.btn--icon {
  padding: var(--space-sm);
}

/* ================================================================== */
/*  Note List                                                          */
/* ================================================================== */

.note-list {
  flex: 1;
  overflow-y: auto;
  padding: var(--space-sm);
  scrollbar-width: thin;
  scrollbar-color: var(--clr-border) transparent;
}

.note-list-empty {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  height: 100%;
  color: var(--clr-text-muted);
  text-align: center;
  gap: var(--space-sm);
}

.note-list-empty svg {
  opacity: .4;
}

.note-list-empty-hint {
  font-size: .82rem;
  opacity: .6;
}

/* ------------------------------------------------------------------ */
/*  Note Card                                                          */
/* ------------------------------------------------------------------ */

.note-card {
  display: flex;
  align-items: flex-start;
  width: 100%;
  text-align: left;
  background: transparent;
  color: var(--clr-text);
  font-family: var(--font-sans);
  border: 1px solid transparent;
  border-radius: var(--radius-md);
  padding: var(--space-md);
  margin-bottom: var(--space-xs);
  cursor: pointer;
  transition: all var(--dur-fast) var(--ease-out);
}

.note-card:hover {
  background: var(--clr-surface-alt);
  border-color: var(--clr-border);
}

.note-card--active {
  background: var(--clr-surface-alt);
  border-color: var(--clr-accent);
  box-shadow: 0 0 0 2px var(--clr-accent-glow);
}

.note-card__content {
  flex: 1;
  min-width: 0;
}

.note-card__title {
  font-size: .92rem;
  font-weight: 600;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.note-card__preview {
  font-size: .8rem;
  color: var(--clr-text-muted);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  margin-top: 2px;
}

.note-card__time {
  font-size: .72rem;
  color: var(--clr-text-muted);
  opacity: .7;
  margin-top: var(--space-xs);
  display: block;
}

.note-card__delete {
  flex-shrink: 0;
  background: none;
  border: none;
  color: var(--clr-text-muted);
  cursor: pointer;
  padding: var(--space-xs);
  border-radius: var(--radius-sm);
  transition: all var(--dur-fast) var(--ease-out);
  opacity: 0;
  margin-left: var(--space-sm);
}

.note-card:hover .note-card__delete {
  opacity: 1;
}

.note-card__delete:hover {
  color: var(--clr-danger);
  background: var(--clr-danger-glow);
}

/* ================================================================== */
/*  Editor Panel                                                       */
/* ================================================================== */

.editor {
  flex: 1;
  display: flex;
  flex-direction: column;
  background: var(--clr-bg);
  overflow: hidden;
}

.editor__content {
  flex: 1;
  display: flex;
  flex-direction: column;
}

.editor__header {
  display: flex;
  align-items: center;
  padding: var(--space-md) var(--space-lg);
  border-bottom: 1px solid var(--clr-border);
  gap: var(--space-sm);
}

.editor__title-input {
  flex: 1;
  font-family: var(--font-sans);
  font-size: 1.15rem;
  font-weight: 700;
  color: var(--clr-text);
  background: transparent;
  border: none;
  outline: none;
  padding: var(--space-xs) 0;
}

.editor__title-input::placeholder {
  color: var(--clr-text-muted);
  opacity: .6;
}

.editor__title-input:disabled {
  opacity: .3;
}

.editor__body {
  flex: 1;
  padding: var(--space-lg);
  display: flex; /* Added to allow textarea to fill height */
  overflow: hidden;
}

.editor__textarea {
  width: 100%;
  flex: 1; /* Changed from height: 100% to flex: 1 for better behavior in flex container */
  font-family: var(--font-sans);
  font-size: .95rem;
  line-height: 1.75;
  color: var(--clr-text);
  background: transparent;
  border: none;
  outline: none;
  resize: none;
  scrollbar-width: thin;
  scrollbar-color: var(--clr-border) transparent;
}

.editor__textarea::placeholder {
  color: var(--clr-text-muted);
  opacity: .5;
}

.editor__textarea:disabled {
  opacity: .3;
}

/* placeholder state */
.editor__placeholder {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  color: var(--clr-text-muted);
  gap: var(--space-md);
  text-align: center;
}

.editor__placeholder svg {
  opacity: .25;
}

.editor__placeholder p {
  font-size: .9rem;
  opacity: .6;
}

.editor__placeholder kbd {
  font-family: var(--font-mono);
  font-size: .78rem;
  background: var(--clr-surface-alt);
  border: 1px solid var(--clr-border);
  border-radius: var(--radius-sm);
  padding: 2px 8px;
}

/* ================================================================== */
/*  Status Bar                                                         */
/* ================================================================== */

.status-bar {
  display: flex;
  align-items: center;
  gap: var(--space-lg);
  padding: var(--space-sm) var(--space-lg);
  font-size: .75rem;
  color: var(--clr-text-muted);
  border-top: 1px solid var(--clr-border);
  background: var(--clr-surface);
}

.status-item {
  display: flex;
  align-items: center;
  gap: var(--space-xs);
}

.status-dot {
  width: 7px;
  height: 7px;
  border-radius: 50%;
}

.status-dot--persisted {
  background: var(--clr-success);
  box-shadow: 0 0 6px var(--clr-success-glow);
}

.status-dot--volatile {
  background: var(--clr-danger);
  box-shadow: 0 0 6px var(--clr-danger-glow);
}

/* ================================================================== */
/*  Toast                                                              */
/* ================================================================== */

.toast {
  position: fixed;
  bottom: 60px;
  left: 50%;
  transform: translateX(-50%) translateY(20px);
  padding: var(--space-sm) var(--space-lg);
  font-size: .85rem;
  font-weight: 500;
  border-radius: var(--radius-md);
  pointer-events: none;
  opacity: 0;
  transition: all var(--dur-med) var(--ease-out);
  z-index: 1000;
}

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

.toast--info {
  background: var(--clr-surface-alt);
  border: 1px solid var(--clr-border);
  color: var(--clr-text);
}

.toast--success {
  background: #132a1e;
  border: 1px solid var(--clr-success);
  color: var(--clr-success);
}

.toast--error {
  background: #2a1318;
  border: 1px solid var(--clr-danger);
  color: var(--clr-danger);
}

/* ================================================================== */
/*  Responsive                                                         */
/* ================================================================== */

@media (max-width: 720px) {
  :root {
    --sidebar-w: 100%;
  }

  .app {
    flex-direction: column;
  }

  .sidebar {
    width: 100%;
    min-width: unset;
    max-height: 45vh;
    border-right: none;
    border-bottom: 1px solid var(--clr-border);
  }
}

/* ================================================================== */
/*  Animations                                                         */
/* ================================================================== */

@keyframes fadeIn {
  from { opacity: 0; transform: translateY(8px); }
  to   { opacity: 1; transform: translateY(0); }
}

.note-card {
  animation: fadeIn var(--dur-med) var(--ease-out) both;
}
