/* ---------- app shell ---------- */
.app {
  display: flex;
  height: 100dvh;
  overflow: hidden;
}

.sidebar {
  position: relative;
  z-index: 30;
  width: 272px;
  flex: 0 0 272px;
  height: 100%;
  background: var(--bg-2);
  border-right: 1px solid var(--line);
}

.sidebar-inner {
  display: flex;
  flex-direction: column;
  height: 100%;
  min-height: 0;
}

.main {
  position: relative;
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
  height: 100%;
  background:
    radial-gradient(1000px 420px at 78% -12%, var(--accent-faint), transparent 70%),
    var(--bg);
}

.main-scroll {
  flex: 1;
  min-height: 0;
  overflow-y: auto;
  overflow-x: hidden;
  scroll-behavior: smooth;
  overscroll-behavior: contain;
}

.view {
  min-height: 100%;
  animation: view-in 0.32s cubic-bezier(0.2, 0.7, 0.3, 1) both;
}

@keyframes view-in {
  from {
    opacity: 0;
    transform: translateY(6px);
  }
  to {
    opacity: 1;
    transform: none;
  }
}

.page {
  width: 100%;
  max-width: 1080px;
  margin: 0 auto;
  padding: 38px 42px 90px;
}

.page-narrow {
  max-width: 860px;
}

.page-wide {
  max-width: 1200px;
}

/* ---------- sidebar parts ---------- */
.side-top {
  padding: 22px 18px 12px;
}

.brand {
  display: flex;
  align-items: center;
  gap: 9px;
  padding: 4px 8px 18px;
  color: var(--ink);
  text-decoration: none;
}

.brand-mark {
  display: grid;
  place-items: center;
  width: 28px;
  height: 28px;
  color: var(--accent);
}

.brand-name {
  font-family: var(--font-display);
  font-style: italic;
  font-weight: 550;
  font-size: 26px;
  letter-spacing: -0.035em;
  line-height: 1;
  font-variation-settings: 'SOFT' 50, 'WONK' 1;
}

.brand-dot {
  color: var(--accent);
}

.side-search {
  position: relative;
  margin-top: 14px;
}

.side-search .icon {
  position: absolute;
  left: 11px;
  top: 50%;
  transform: translateY(-50%);
  color: var(--muted);
  pointer-events: none;
}

.side-search input {
  width: 100%;
  height: 36px;
  padding: 0 12px 0 34px;
  border: 1px solid transparent;
  border-radius: 10px;
  background: color-mix(in srgb, var(--bg) 55%, transparent);
  font-size: 13px;
  transition: background 0.18s, border-color 0.18s, box-shadow 0.18s;
}

.side-search input::placeholder {
  color: var(--muted);
}

.side-search input:focus {
  outline: none;
  background: var(--field);
  border-color: var(--line-strong);
  box-shadow: var(--ring);
}

.side-label {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 18px 26px 7px;
  font-size: 11.5px;
  font-weight: 600;
  color: var(--muted);
  letter-spacing: 0.02em;
}

.side-count {
  font-weight: 500;
  font-variant-numeric: tabular-nums;
}

.note-list {
  flex: 1;
  min-height: 0;
  overflow-y: auto;
  padding: 0 12px 18px;
}

.note-item {
  position: relative;
  display: flex;
  align-items: flex-start;
  gap: 10px;
  width: 100%;
  padding: 9px 10px;
  border-radius: 10px;
  text-align: left;
  color: var(--ink-2);
  transition: background 0.15s, color 0.15s;
}

.note-item:hover {
  background: var(--hover);
  color: var(--ink);
}

.note-item.is-active {
  background: var(--accent-soft);
  color: var(--accent-ink);
}

.note-item-icon {
  margin-top: 2px;
  color: var(--muted);
}

.note-item.is-active .note-item-icon {
  color: var(--accent-ink);
}

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

.note-item-title {
  font-size: 13.5px;
  font-weight: 500;
  line-height: 1.35;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.note-item-meta {
  display: flex;
  align-items: center;
  gap: 5px;
  margin-top: 2px;
  font-size: 11px;
  color: var(--muted);
  white-space: nowrap;
  overflow: hidden;
}

.note-item.is-active .note-item-meta {
  color: color-mix(in srgb, var(--accent-ink) 70%, var(--muted));
}

.note-item-badge {
  display: inline-flex;
  align-items: center;
  gap: 3px;
  font-variant-numeric: tabular-nums;
}

.note-item-badge::before {
  content: '';
  width: 2.5px;
  height: 2.5px;
  border-radius: 50%;
  background: currentColor;
  opacity: 0.5;
}

.side-empty {
  padding: 16px 14px;
  font-size: 12.5px;
  line-height: 1.55;
  color: var(--muted);
}

.side-foot {
  padding: 12px 18px 18px;
  border-top: 1px solid var(--line);
}

.theme-row {
  display: flex;
  align-items: center;
  gap: 7px;
  padding: 2px 4px 12px;
}

.theme-dot {
  width: 16px;
  height: 16px;
  border-radius: 50%;
  border: 1.5px solid transparent;
  background: var(--dot);
  box-shadow: inset 0 0 0 2px var(--bg-2);
  transition: transform 0.15s, border-color 0.15s;
}

.theme-dot:hover {
  transform: scale(1.16);
}

.theme-dot.is-active {
  border-color: var(--ink-2);
}

.theme-row-label {
  margin-right: auto;
  font-size: 11px;
  color: var(--muted);
}

.side-link {
  display: flex;
  align-items: center;
  gap: 9px;
  width: 100%;
  padding: 8px 8px;
  border-radius: 9px;
  color: var(--ink-2);
  font-size: 13px;
  text-align: left;
  transition: background 0.15s;
}

.side-link:hover {
  background: var(--hover);
  color: var(--ink);
}

.side-link.is-active {
  background: var(--accent-soft);
  color: var(--accent-ink);
}

.ai-chip {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 2px 7px;
  margin-left: auto;
  border-radius: 999px;
  background: var(--card-soft);
  color: var(--muted);
  font-size: 10px;
  font-weight: 500;
}

.ai-chip::before {
  content: '';
  width: 5px;
  height: 5px;
  border-radius: 50%;
  background: var(--muted);
}

.ai-chip.is-on {
  background: var(--ok-soft);
  color: var(--ok);
}

.ai-chip.is-on::before {
  background: var(--ok);
}

/* ---------- mobile ---------- */
.mobile-bar {
  display: none;
  flex: none;
  align-items: center;
  gap: 8px;
  height: 56px;
  padding: 0 12px;
  background: color-mix(in srgb, var(--bg) 88%, transparent);
  border-bottom: 1px solid var(--line);
  backdrop-filter: blur(10px);
  z-index: 20;
}

.mobile-bar .brand {
  padding: 0;
  flex: 1;
  justify-content: center;
}

.mobile-bar .brand-name {
  font-size: 23px;
}

.sidebar-scrim {
  position: fixed;
  inset: 0;
  z-index: 25;
  background: rgba(30, 20, 15, 0.32);
  backdrop-filter: blur(2px);
}

@media (max-width: 940px) {
  .mobile-bar {
    display: flex;
  }

  .sidebar {
    position: fixed;
    inset: 0 auto 0 0;
    width: min(310px, 86vw);
    flex-basis: auto;
    transform: translateX(-104%);
    transition: transform 0.26s cubic-bezier(0.2, 0.7, 0.3, 1);
    box-shadow: 0 0 60px rgba(40, 25, 15, 0.18);
  }

  body.sidebar-open .sidebar {
    transform: none;
  }

  .sidebar-scrim {
    display: block;
  }

  .page {
    padding: 26px 20px 72px;
  }

  .page-wide {
    padding-left: 16px;
    padding-right: 16px;
  }
}

@media (max-width: 600px) {
  .page {
    padding: 22px 15px 64px;
  }

  .side-top {
    padding-top: 16px;
  }
}
