:root {
  --bg: #ffffff;
  --fg: #0f172a;
  --muted: #64748b;
  --accent: #111827;
  --ring: #e5e7eb;
  --card: #f8fafc;
  --shadow: 0 10px 30px rgba(15, 23, 42, .08);
  --radius: 18px;
  --success: #10b981;
  --danger: #e11d48;
}

* { box-sizing: border-box }
html, body { height: 100% }

body {
  margin: 0;
  background: var(--bg);
  color: var(--fg);
  font-family: Inter, system-ui, -apple-system, Segoe UI, Roboto, Helvetica, Arial, "Apple Color Emoji", "Segoe UI Emoji";
}

a { color: var(--fg); text-decoration: none }

/* ---- Header ---- */
.header {
  position: sticky;
  top: 0;
  z-index: 100;
  background: rgba(255, 255, 255, .85);
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
  border-bottom: 1px solid var(--ring);
}

.header-inner {
  max-width: 1200px;
  margin-inline: auto;
  padding: 14px clamp(16px, 3vw, 28px);
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.brand {
  display: flex;
  align-items: center;
  gap: 10px;
  text-decoration: none;
}

.logo { height: 32px }

.brand-name {
  font-weight: 700;
  font-size: 18px;
  color: var(--fg);
}

.nav-cta {
  display: flex;
  align-items: center;
  gap: 10px;
}

/* ---- Buttons ---- */
.btn {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  padding: 12px 16px;
  border-radius: 12px;
  border: 1px solid var(--ring);
  font-weight: 600;
  font-size: 14px;
  font-family: inherit;
  cursor: pointer;
  transition: .2s ease;
  text-decoration: none;
  background: #fff;
  color: var(--fg);
}

.btn:hover { transform: translateY(-1px) }

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

.btn.ghost {
  background: #fff;
  border: 1px solid var(--ring);
}

.btn.sm { padding: 8px 14px; font-size: 13px }

/* ---- Container ---- */
.container {
  max-width: 1200px;
  margin-inline: auto;
  padding: 24px clamp(16px, 3vw, 28px) 60px;
}

/* ---- Quick Capture ---- */
.capture-bar {
  display: flex;
  gap: 10px;
  margin-bottom: 12px;
}

.capture-input {
  flex: 1;
  padding: 14px 18px;
  border: 2px solid var(--ring);
  border-radius: 14px;
  font-size: 16px;
  font-family: inherit;
  outline: none;
  transition: border-color .2s;
  resize: none;
  overflow: hidden;
  min-height: 48px;
  max-height: 200px;
  line-height: 1.4;
}

.capture-input:focus { border-color: var(--fg) }

.capture-btn { white-space: nowrap }

.capture-options {
  display: flex;
  align-items: center;
  gap: 16px;
  flex-wrap: wrap;
  margin-bottom: 24px;
  padding: 0 4px;
}

/* Type pills */
.type-pills {
  display: flex;
  gap: 6px;
}

.type-pill {
  padding: 5px 12px;
  border-radius: 20px;
  border: 1px solid var(--ring);
  background: #fff;
  font-size: 12px;
  font-weight: 600;
  font-family: inherit;
  cursor: pointer;
  transition: all .2s;
  color: var(--muted);
}

.type-pill:hover { border-color: var(--fg); color: var(--fg) }
.type-pill.active { background: var(--fg); color: #fff; border-color: var(--fg) }

/* Color dots */
.color-dots {
  display: flex;
  gap: 6px;
  align-items: center;
}

.color-dot {
  width: 20px;
  height: 20px;
  border-radius: 50%;
  border: 2px solid transparent;
  cursor: pointer;
  transition: transform .15s, border-color .15s;
  padding: 0;
}

.color-dot:hover { transform: scale(1.2) }
.color-dot.active { border-color: var(--fg); transform: scale(1.2) }

/* Due date */
.due-date-wrap {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 13px;
  color: var(--muted);
}

.due-date-wrap label { font-weight: 600 }

.due-input {
  padding: 4px 8px;
  border: 1px solid var(--ring);
  border-radius: 8px;
  font-size: 13px;
  font-family: inherit;
  outline: none;
}

.due-input:focus { border-color: var(--fg) }

/* ---- Filter Bar ---- */
.filter-bar {
  display: flex;
  align-items: center;
  gap: 12px;
  flex-wrap: wrap;
  margin-bottom: 24px;
  padding-bottom: 20px;
  border-bottom: 1px solid var(--ring);
}

.search-input {
  flex: 0 1 260px;
  padding: 10px 14px;
  border: 1px solid var(--ring);
  border-radius: 10px;
  font-size: 14px;
  font-family: inherit;
  outline: none;
  transition: border-color .2s;
}

.search-input:focus { border-color: var(--fg) }

.filter-pills {
  display: flex;
  gap: 6px;
  flex-wrap: wrap;
}

.filter-pill {
  padding: 6px 14px;
  border-radius: 20px;
  border: 1px solid var(--ring);
  background: #fff;
  font-size: 12px;
  font-weight: 600;
  font-family: inherit;
  cursor: pointer;
  transition: all .2s;
  color: var(--muted);
}

.filter-pill:hover { border-color: var(--fg); color: var(--fg) }
.filter-pill.active { background: var(--fg); color: #fff; border-color: var(--fg) }

/* ---- Jots Grid ---- */
.jots-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
  gap: 16px;
}

/* ---- Jot Card ---- */
.jot-card {
  background: #fff;
  border: 1px solid var(--ring);
  border-radius: 16px;
  padding: 18px 20px;
  box-shadow: var(--shadow);
  position: relative;
  transition: transform .15s, box-shadow .15s;
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.jot-card:hover {
  transform: translateY(-2px);
  box-shadow: 0 12px 36px rgba(15, 23, 42, .12);
}

/* Color accent */
.jot-card[data-color="gray"]   { border-left: 4px solid #94a3b8 }
.jot-card[data-color="blue"]   { border-left: 4px solid #3b82f6 }
.jot-card[data-color="green"]  { border-left: 4px solid #10b981 }
.jot-card[data-color="yellow"] { border-left: 4px solid #f59e0b }
.jot-card[data-color="orange"] { border-left: 4px solid #f97316 }
.jot-card[data-color="red"]    { border-left: 4px solid #ef4444 }

/* Card header */
.jot-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.jot-type {
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: .8px;
  font-weight: 600;
  color: var(--muted);
}

.jot-actions {
  display: flex;
  gap: 4px;
  align-items: center;
}

.jot-action-btn {
  background: none;
  border: none;
  cursor: pointer;
  padding: 4px;
  font-size: 16px;
  line-height: 1;
  border-radius: 6px;
  transition: background .15s;
  color: var(--muted);
}

.jot-action-btn:hover { background: var(--card); color: var(--fg) }
.jot-action-btn.pinned { color: #e11d48; font-size: 18px }

/* Pinned card highlight */
.jot-card.pinned {
  background: #fffbeb;
  border-color: #f59e0b;
  box-shadow: 0 4px 16px rgba(245, 158, 11, .15);
}

/* Card content */
.jot-content {
  font-size: 15px;
  line-height: 1.5;
  color: var(--fg);
  white-space: pre-wrap;
  word-break: break-word;
  cursor: text;
  min-height: 20px;
}

.jot-content:empty::before {
  content: "Empty jot...";
  color: var(--muted);
  font-style: italic;
}

/* Inline edit */
.jot-edit-textarea {
  width: 100%;
  border: 1px solid var(--ring);
  border-radius: 8px;
  padding: 8px 10px;
  font-size: 15px;
  line-height: 1.5;
  font-family: inherit;
  resize: vertical;
  min-height: 60px;
  outline: none;
}

.jot-edit-textarea:focus { border-color: var(--fg) }

/* Card footer */
.jot-footer {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
}

.jot-due {
  font-size: 12px;
  font-weight: 600;
  padding: 3px 8px;
  border-radius: 6px;
  background: var(--card);
}

.jot-due.overdue {
  background: #fef2f2;
  color: var(--danger);
}

.jot-time {
  font-size: 12px;
  color: var(--muted);
  margin-left: auto;
}

/* Color picker popover */
.color-picker {
  position: absolute;
  top: 40px;
  right: 16px;
  background: #fff;
  border: 1px solid var(--ring);
  border-radius: 12px;
  padding: 8px;
  display: flex;
  gap: 6px;
  box-shadow: var(--shadow);
  z-index: 10;
}

/* Delete confirm */
.delete-confirm {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 13px;
  color: var(--danger);
  font-weight: 600;
}

.delete-confirm button {
  padding: 4px 10px;
  border-radius: 8px;
  border: 1px solid;
  font-size: 12px;
  font-weight: 600;
  font-family: inherit;
  cursor: pointer;
  transition: .15s;
}

.delete-confirm .confirm-yes {
  background: var(--danger);
  color: #fff;
  border-color: var(--danger);
}

.delete-confirm .confirm-no {
  background: #fff;
  color: var(--fg);
  border-color: var(--ring);
}

/* ---- Category Select (capture) ---- */
.category-select-wrap {
  display: flex;
  align-items: center;
  gap: 6px;
}

.category-select {
  padding: 5px 10px;
  border: 1px solid var(--ring);
  border-radius: 10px;
  font-size: 12px;
  font-weight: 600;
  font-family: inherit;
  color: var(--fg);
  background: #fff;
  cursor: pointer;
  outline: none;
  min-width: 120px;
}

.category-select:focus { border-color: var(--fg) }

.btn-icon {
  width: 28px;
  height: 28px;
  border-radius: 50%;
  border: 1px solid var(--ring);
  background: #fff;
  font-size: 16px;
  font-weight: 700;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--muted);
  transition: all .15s;
  padding: 0;
  line-height: 1;
}

.btn-icon:hover { border-color: var(--fg); color: var(--fg) }

.btn-icon-sm {
  background: none;
  border: none;
  font-size: 16px;
  cursor: pointer;
  color: var(--muted);
  padding: 2px 6px;
  border-radius: 6px;
  transition: all .15s;
}

.btn-icon-sm:hover { color: var(--fg); background: var(--card) }

/* ---- Category Filter Bar ---- */
.category-filter-bar {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 20px;
  flex-wrap: wrap;
}

.category-filter-pills {
  display: flex;
  gap: 6px;
  flex-wrap: wrap;
}

.category-pill {
  padding: 5px 12px;
  border-radius: 20px;
  border: 1px solid var(--ring);
  background: #fff;
  font-size: 11px;
  font-weight: 600;
  font-family: inherit;
  cursor: pointer;
  transition: all .2s;
  color: var(--muted);
}

.category-pill:hover { border-color: var(--fg); color: var(--fg) }
.category-pill.active { background: var(--accent); color: #fff; border-color: var(--accent) }

/* ---- Category Management ---- */
.category-manage {
  background: var(--card);
  border: 1px solid var(--ring);
  border-radius: 14px;
  padding: 16px 20px;
  margin-bottom: 20px;
}

.category-manage-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 12px;
}

.category-manage-title {
  font-size: 14px;
  font-weight: 700;
}

.category-add-row {
  display: flex;
  gap: 8px;
  margin-bottom: 12px;
}

.category-add-input {
  flex: 1;
  padding: 8px 12px;
  border: 1px solid var(--ring);
  border-radius: 10px;
  font-size: 14px;
  font-family: inherit;
  outline: none;
}

.category-add-input:focus { border-color: var(--fg) }

.category-list {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.category-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 8px 12px;
  background: #fff;
  border: 1px solid var(--ring);
  border-radius: 10px;
  font-size: 13px;
  font-weight: 500;
}

.category-item-delete {
  background: none;
  border: none;
  color: var(--danger);
  font-size: 14px;
  cursor: pointer;
  padding: 2px 6px;
  border-radius: 6px;
  transition: background .15s;
}

.category-item-delete:hover { background: #fef2f2 }

/* ---- Category Badge (on cards) ---- */
.category-badge {
  font-size: 11px;
  font-weight: 600;
  padding: 2px 8px;
  border-radius: 10px;
  background: #eef2ff;
  color: #4338ca;
  white-space: nowrap;
}

/* ---- Empty / Loading ---- */
.empty-state {
  text-align: center;
  padding: 60px 20px;
  color: var(--muted);
  font-size: 16px;
}

.loading {
  text-align: center;
  padding: 60px 20px;
  color: var(--muted);
  font-size: 14px;
}

/* ---- Notification Toast ---- */
.notification-toast {
  position: fixed;
  top: 20px;
  right: 20px;
  background: #333;
  color: #fff;
  padding: 14px 20px;
  border-radius: 12px;
  font-size: 14px;
  z-index: 2000;
  display: flex;
  align-items: center;
  gap: 8px;
  transform: translateX(120%);
  transition: transform .3s ease, opacity .3s ease;
  opacity: 0;
  pointer-events: none;
}

.notification-toast.show {
  transform: translateX(0);
  opacity: 1;
  pointer-events: auto;
}

.notification-toast.success { background: var(--success) }
.notification-toast.error { background: var(--danger) }

/* ---- Expiration ---- */
.expiration-box {
  max-width: 600px;
  margin: 60px auto 0;
  padding: 32px;
  background: #fef2f2;
  border: 1px solid #fecaca;
  border-radius: var(--radius);
  text-align: center;
}
.expiration-content .warning-msg {
  font-size: 18px;
  font-weight: 700;
  color: #991b1b;
  margin-bottom: 8px;
}
.expiration-content .detail-msg {
  font-size: 14px;
  color: #b91c1c;
}

/* ---- Utility ---- */
.hidden { display: none !important }

/* ---- Responsive ---- */
@media (max-width: 640px) {
  .jots-grid {
    grid-template-columns: 1fr;
  }

  .filter-bar {
    flex-direction: column;
    align-items: stretch;
  }

  .search-input { flex: 1 1 auto }

  .capture-options {
    gap: 10px;
  }
}

@media (max-width: 900px) {
  .brand-name { font-size: 16px }
}
