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

:root {
  --bg: #f1f5f9;
  --surface: #ffffff;
  --surface-soft: #f8fafc;
  --text: #0f172a;
  --muted: #64748b;
  --line: #e2e8f0;
  --dark: #0f172a;
  --accent: #0d9488;
  --accent-soft: #ccfbf1;
  --amber: #b45309;
  --amber-bg: #fef3c7;
  --green: #047857;
  --green-bg: #d1fae5;
  --red: #b91c1c;
  --red-bg: #fee2e2;
  --shadow: 0 1px 2px rgba(0, 0, 0, .05), 0 8px 24px rgba(15, 23, 42, .08);
  --radius: 10px;
  --max-w: 880px;
  --sidebar-w: 220px;
}

html {
  scroll-behavior: smooth;
  height: 100%;
}

body {
  background: var(--bg);
  color: var(--text);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "Noto Sans SC", sans-serif;
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
  height: 100%;
}

button, input {
  font: inherit;
}

button {
  cursor: pointer;
}

#app {
  height: 100%;
}

.layout {
  display: flex;
  min-height: 100vh;
}

/* ─── Sidebar ─── */

.sidebar {
  flex-shrink: 0;
  width: var(--sidebar-w);
  background: var(--dark);
  color: #fff;
  display: flex;
  flex-direction: column;
  overflow-y: auto;
}

.sidebar-toggle,
.sidebar-backdrop,
.sidebar-close {
  display: none;
}

.sidebar-brand {
  padding: 1.6rem 1.2rem 1.2rem;
  border-bottom: 1px solid rgba(255, 255, 255, .12);
}

.sidebar-eyebrow {
  color: #5eead4;
  font-size: .72rem;
  font-weight: 800;
  letter-spacing: .08em;
  text-transform: uppercase;
}

.sidebar-title {
  margin-top: .15rem;
  font-size: 1.35rem;
  font-weight: 900;
  line-height: 1.15;
}

.sidebar-nav {
  flex: 1;
  padding: .6rem .6rem 1rem;
  display: flex;
  flex-direction: column;
  gap: .2rem;
}

.sidebar-item {
  display: flex;
  align-items: center;
  gap: .65rem;
  width: 100%;
  padding: .7rem .75rem;
  border: none;
  border-radius: 8px;
  background: transparent;
  color: rgba(255, 255, 255, .72);
  font-size: .9rem;
  font-weight: 700;
  cursor: pointer;
  text-align: left;
  transition: background .15s, color .15s;
}

.sidebar-item:hover {
  background: rgba(255, 255, 255, .08);
  color: #fff;
}

.sidebar-item.active {
  background: rgba(13, 148, 136, .22);
  color: #5eead4;
}

.sidebar-icon {
  font-size: 1.15rem;
  width: 1.4rem;
  text-align: center;
  flex-shrink: 0;
}

/* ─── Main ─── */

.main-area {
  flex: 1;
  display: flex;
  flex-direction: column;
  min-width: 0;
  overflow-y: auto;
}

.app-shell {
  max-width: var(--max-w);
  margin: 0 auto;
  padding: 1.4rem 1rem 3rem;
  width: 100%;
}

.view-title {
  font-size: 1.4rem;
  font-weight: 900;
  color: var(--text);
  letter-spacing: .03em;
  margin-bottom: .2rem;
}

.view-sub {
  color: var(--muted);
  font-size: .85rem;
  margin-bottom: 1.1rem;
}

/* ─── Filter bar ─── */

.filter-bar {
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--surface);
  box-shadow: var(--shadow);
  padding: .8rem 1rem;
  margin-bottom: 1.1rem;
}

.filter-row {
  display: flex;
  align-items: flex-start;
  gap: .6rem;
  padding: .35rem 0;
}

.filter-row + .filter-row {
  border-top: 1px dashed var(--line);
}

.filter-label {
  flex-shrink: 0;
  width: 3.4rem;
  font-size: .78rem;
  font-weight: 800;
  color: var(--muted);
  padding-top: .35rem;
}

.filter-tags {
  display: flex;
  flex-wrap: wrap;
  gap: .4rem;
}

.filter-tag {
  padding: .25rem .7rem;
  font-size: .78rem;
  font-weight: 700;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: var(--surface-soft);
  color: var(--text);
  transition: all .15s;
}

.filter-tag:hover {
  border-color: var(--accent);
}

.filter-tag.on {
  background: var(--accent);
  border-color: var(--accent);
  color: #fff;
}

.filter-clear {
  margin-left: auto;
  padding: .25rem .7rem;
  font-size: .76rem;
  font-weight: 700;
  border: none;
  background: transparent;
  color: var(--muted);
  text-decoration: underline;
}

.filter-clear:hover {
  color: var(--red);
}

/* ─── Note list ─── */

.note-list {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(260px, 1fr));
  gap: .7rem;
}

.note-card {
  display: flex;
  flex-direction: column;
  gap: .45rem;
  padding: .85rem .95rem;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--surface);
  box-shadow: var(--shadow);
  cursor: pointer;
  transition: border-color .15s, box-shadow .15s, transform .1s;
  text-align: left;
  width: 100%;
  font-family: inherit;
  color: inherit;
}

.note-card:hover {
  border-color: var(--accent);
  box-shadow: 0 4px 14px rgba(13, 148, 136, .14);
}

.note-card-title {
  font-size: .95rem;
  font-weight: 800;
  color: var(--text);
  line-height: 1.35;
}

.note-card-meta {
  font-size: .74rem;
  color: var(--muted);
}

.note-tags {
  display: flex;
  flex-wrap: wrap;
  gap: .3rem;
}

.note-tag {
  font-size: .7rem;
  font-weight: 700;
  padding: .12rem .5rem;
  border-radius: 999px;
  background: var(--accent-soft);
  color: #0f766e;
}

.note-tag.type {
  background: var(--amber-bg);
  color: var(--amber);
}

.empty-state {
  border: 1px dashed var(--line);
  border-radius: var(--radius);
  background: rgba(255, 255, 255, .6);
  padding: 2rem;
  text-align: center;
  color: var(--muted);
}

/* ─── Note detail ─── */

.note-detail {
  margin-top: 1rem;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--surface);
  box-shadow: var(--shadow);
  animation: fadeIn .2s ease;
  overflow: hidden;
}

.note-detail-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: .8rem 1rem;
  background: var(--dark);
}

.note-detail-title {
  font-size: .98rem;
  font-weight: 800;
  color: #fff;
}

.note-detail-close {
  width: 1.7rem;
  height: 1.7rem;
  border: none;
  border-radius: 50%;
  background: rgba(255, 255, 255, .12);
  color: rgba(255, 255, 255, .7);
  font-size: .8rem;
  cursor: pointer;
}

.note-detail-close:hover {
  background: rgba(255, 255, 255, .22);
  color: #fff;
}

.note-detail-meta {
  display: flex;
  flex-wrap: wrap;
  gap: .4rem;
  padding: .7rem 1rem 0;
}

.note-detail-body {
  padding: .6rem 1rem 1rem;
  font-size: .88rem;
  line-height: 1.65;
  color: var(--text);
}

.note-detail-body h2,
.note-detail-body h3 {
  margin: .9rem 0 .4rem;
  color: var(--text);
}

.note-detail-body h2 { font-size: .95rem; font-weight: 800; }
.note-detail-body h3 { font-size: .9rem; font-weight: 800; }
.note-detail-body p { margin: .4rem 0; }
.note-detail-body ul,
.note-detail-body ol { margin: .4rem 0; padding-left: 1.3rem; }
.note-detail-body li { margin: .2rem 0; }
.note-detail-body a { color: var(--accent); text-decoration: none; word-break: break-all; }
.note-detail-body a:hover { text-decoration: underline; }
.note-detail-body code {
  font-family: "SF Mono", Menlo, Consolas, monospace;
  font-size: .8rem;
  padding: .1rem .35rem;
  background: var(--surface-soft);
  border: 1px solid var(--line);
  border-radius: 4px;
}
.note-detail-body strong { font-weight: 800; }

.note-links {
  display: flex;
  flex-wrap: wrap;
  gap: .5rem;
  padding: 0 1rem 1rem;
}

.note-link {
  display: inline-flex;
  align-items: center;
  gap: .3rem;
  padding: .3rem .7rem;
  font-size: .8rem;
  font-weight: 700;
  border: 1px solid var(--accent);
  border-radius: 999px;
  background: var(--accent-soft);
  color: #0f766e;
  text-decoration: none;
}

.note-link:hover {
  background: var(--accent);
  color: #fff;
}

/* ─── Pricing table ─── */

.pricing-meta {
  font-size: .8rem;
  color: var(--muted);
  background: var(--amber-bg);
  border: 1px solid #fde68a;
  border-radius: 8px;
  padding: .5rem .8rem;
  margin-bottom: 1.1rem;
}

.pricing-meta strong {
  color: var(--amber);
}

.price-section {
  margin-bottom: 1.2rem;
}

.price-section-title {
  font-size: .95rem;
  font-weight: 800;
  color: var(--text);
  padding: .3rem 0 .5rem;
  border-bottom: 2px solid var(--accent);
  margin-bottom: .6rem;
}

.table-wrap {
  overflow-x: auto;
}

.pricing-table {
  width: 100%;
  border-collapse: collapse;
  font-size: .85rem;
}

.pricing-table th,
.pricing-table td {
  padding: .55rem .7rem;
  border-bottom: 1px solid var(--line);
  text-align: left;
  vertical-align: top;
}

.pricing-table th {
  background: var(--surface-soft);
  font-weight: 700;
  color: var(--muted);
  font-size: .75rem;
  text-transform: uppercase;
  letter-spacing: .03em;
  white-space: nowrap;
}

.pt-name { font-weight: 800; color: var(--text); white-space: nowrap; }
.pt-note { color: var(--muted); font-size: .8rem; }
.pt-price { font-weight: 800; white-space: nowrap; }
.price-free { color: var(--green); }
.price-paid { color: var(--text); }
.price-unknown { color: var(--muted); font-style: italic; }

/* ─── Animations ─── */

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

.note-view, .pricing-view {
  animation: fadeIn .2s ease;
}

/* ─── Responsive ─── */

@media (max-width: 719px) {
  .sidebar-toggle {
    display: flex;
    align-items: center;
    justify-content: center;
    position: fixed;
    top: .5rem;
    left: .5rem;
    z-index: 15;
    width: 2.3rem;
    height: 2.3rem;
    border: none;
    border-radius: 8px;
    background: var(--dark);
    color: #fff;
    font-size: 1.2rem;
  }

  .sidebar-backdrop {
    display: none;
    position: fixed;
    inset: 0;
    z-index: 24;
    background: rgba(0, 0, 0, .45);
  }

  body.sidebar-open .sidebar-backdrop {
    display: block;
  }

  .sidebar {
    position: fixed;
    top: 0;
    left: 0;
    bottom: 0;
    z-index: 25;
    transform: translateX(-100%);
    transition: transform .25s ease;
  }

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

  .sidebar-close {
    display: flex;
    align-items: center;
    justify-content: center;
    position: absolute;
    top: .5rem;
    right: .5rem;
    width: 1.8rem;
    height: 1.8rem;
    border: none;
    border-radius: 6px;
    background: rgba(255, 255, 255, .1);
    color: rgba(255, 255, 255, .7);
    font-size: .9rem;
  }

  .sidebar-close:hover { background: rgba(255, 255, 255, .18); color: #fff; }
  .sidebar-brand { padding: 1.2rem .8rem .9rem; position: relative; }

  .note-list { grid-template-columns: 1fr; }
  .filter-label { width: auto; padding-top: 0; }
}
