:root {
  --bg: #14181d;
  --panel: #1a1f26;
  --panel-alt: #20262e;
  --border: #2a323c;
  --text: #e8e3d6;
  --text-dim: #8f97a3;
  --accent: #c08a46;
  --accent-soft: rgba(192, 138, 70, 0.16);
  --danger: #c1554a;
  --radius: 3px;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: 'Inter', -apple-system, BlinkMacSystemFont, sans-serif;
  font-size: 15px;
}

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

/* ---------- Sidebar (the "drawer") ---------- */

.drawer {
  width: 220px;
  flex-shrink: 0;
  background: var(--panel);
  border-right: 1px solid var(--border);
  padding: 28px 16px;
  display: flex;
  flex-direction: column;
  gap: 20px;
}

.drawer-title {
  font-family: 'Lora', Georgia, serif;
  font-weight: 600;
  font-size: 20px;
  letter-spacing: 0.01em;
  color: var(--text);
  padding-left: 4px;
}

.folder-list {
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.folder-row {
  display: flex;
  align-items: center;
  position: relative;
}

.folder-row .folder-item {
  flex: 1;
}

.folder-item {
  display: block;
  width: 100%;
  text-align: left;
  background: none;
  border: none;
  color: var(--text-dim);
  font-size: 14px;
  padding: 7px 10px;
  border-radius: var(--radius);
  cursor: pointer;
  font-family: inherit;
}

.folder-item:hover {
  background: var(--panel-alt);
  color: var(--text);
}

.folder-item.active {
  background: var(--accent-soft);
  color: var(--accent);
  font-weight: 500;
}

.folder-remove {
  background: none;
  border: none;
  color: var(--text-dim);
  cursor: pointer;
  font-size: 15px;
  padding: 4px 8px;
  opacity: 0;
  border-radius: var(--radius);
}

.folder-row:hover .folder-remove {
  opacity: 1;
}

.folder-remove:hover {
  color: var(--danger);
}

.new-folder-form {
  display: flex;
  gap: 6px;
  margin-top: auto;
  padding-top: 16px;
  border-top: 1px solid var(--border);
}

.new-folder-form input {
  flex: 1;
  min-width: 0;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  color: var(--text);
  padding: 7px 9px;
  font-size: 13px;
  font-family: inherit;
}

.new-folder-form button {
  background: none;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  color: var(--text-dim);
  padding: 7px 10px;
  font-size: 13px;
  cursor: pointer;
  font-family: inherit;
}

.new-folder-form button:hover {
  color: var(--text);
  border-color: var(--accent);
}

/* ---------- Main area ---------- */

.main {
  flex: 1;
  padding: 28px 40px;
  max-width: 1000px;
}

.toolbar {
  display: flex;
  gap: 12px;
  margin-bottom: 24px;
}

#searchInput {
  flex: 1;
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  color: var(--text);
  padding: 10px 14px;
  font-size: 14px;
  font-family: inherit;
}

#searchInput:focus, .editor-title-input:focus, .editor-body:focus, .new-folder-form input:focus {
  outline: none;
  border-color: var(--accent);
}

.btn-primary {
  background: var(--accent);
  border: none;
  color: #14181d;
  padding: 10px 18px;
  border-radius: var(--radius);
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
  font-family: inherit;
}

.btn-primary:hover {
  filter: brightness(1.08);
}

.board {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(240px, 1fr));
  gap: 14px;
}

.note-card {
  background: var(--panel);
  border: 1px solid var(--border);
  border-top: 2px solid var(--border);
  border-radius: var(--radius);
  padding: 16px;
  cursor: pointer;
  display: flex;
  flex-direction: column;
  gap: 8px;
  min-height: 120px;
}

.note-card:hover {
  border-color: var(--accent);
}

.note-card.pinned {
  border-top-color: var(--accent);
}

.note-card-title {
  font-family: 'Lora', Georgia, serif;
  font-weight: 600;
  font-size: 16px;
  color: var(--text);
}

.note-card-excerpt {
  font-size: 13px;
  color: var(--text-dim);
  line-height: 1.5;
  flex: 1;
}

.note-card-meta {
  font-size: 12px;
  color: var(--text-dim);
  opacity: 0.7;
}

.empty {
  grid-column: 1 / -1;
  color: var(--text-dim);
  padding: 60px 0;
  text-align: center;
  font-size: 14px;
}

/* ---------- Editor overlay ---------- */

.editor-overlay {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(10, 12, 15, 0.6);
  align-items: flex-start;
  justify-content: center;
  padding: 6vh 20px;
  z-index: 10;
}

.editor-overlay.open {
  display: flex;
}

.editor {
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 4px;
  width: 100%;
  max-width: 680px;
  padding: 24px;
  display: flex;
  flex-direction: column;
  gap: 12px;
  max-height: 88vh;
}

.editor-head {
  display: flex;
  align-items: center;
  gap: 10px;
}

.editor-title-input {
  flex: 1;
  background: none;
  border: none;
  color: var(--text);
  font-family: 'Lora', Georgia, serif;
  font-size: 22px;
  font-weight: 600;
  padding: 4px 0;
}

.pin-toggle {
  background: none;
  border: none;
  color: var(--text-dim);
  font-size: 20px;
  cursor: pointer;
  line-height: 1;
  padding: 4px;
}

.pin-toggle.active {
  color: var(--accent);
}

.editor-folder-select {
  align-self: flex-start;
  background: var(--panel-alt);
  border: 1px solid var(--border);
  color: var(--text-dim);
  border-radius: var(--radius);
  padding: 6px 10px;
  font-size: 13px;
  font-family: inherit;
}

.editor-body {
  flex: 1;
  min-height: 320px;
  background: none;
  border: none;
  color: var(--text);
  font-family: 'Inter', sans-serif;
  font-size: 15px;
  line-height: 1.65;
  resize: vertical;
}

.editor-actions {
  display: flex;
  justify-content: space-between;
  align-items: center;
  border-top: 1px solid var(--border);
  padding-top: 14px;
}

.editor-actions-right {
  display: flex;
  align-items: center;
  gap: 14px;
}

.save-status {
  font-size: 12px;
  color: var(--text-dim);
}

.btn-quiet {
  background: none;
  border: 1px solid var(--border);
  color: var(--text-dim);
  padding: 8px 16px;
  border-radius: var(--radius);
  cursor: pointer;
  font-family: inherit;
  font-size: 13px;
}

.btn-quiet:hover {
  color: var(--text);
  border-color: var(--accent);
}

.btn-danger {
  background: none;
  border: 1px solid var(--border);
  color: var(--danger);
  padding: 8px 16px;
  border-radius: var(--radius);
  cursor: pointer;
  font-family: inherit;
  font-size: 13px;
}

.btn-danger:hover {
  background: rgba(193, 85, 74, 0.12);
}

/* ---------- View tabs ---------- */

.view-tabs {
  display: flex;
  gap: 2px;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 3px;
}

.view-tab {
  flex: 1;
  background: none;
  border: none;
  color: var(--text-dim);
  font-size: 13px;
  padding: 6px 0;
  border-radius: 2px;
  cursor: pointer;
  font-family: inherit;
}

.view-tab.active {
  background: var(--panel-alt);
  color: var(--text);
}

.webhooks-btn {
  background: none;
  border: 1px dashed var(--border);
  color: var(--text-dim);
  padding: 8px 10px;
  border-radius: var(--radius);
  cursor: pointer;
  font-family: inherit;
  font-size: 12px;
}

.webhooks-btn:hover {
  color: var(--accent);
  border-color: var(--accent);
}

/* ---------- Reminders ---------- */

.reminders-view {
  display: none;
  flex-direction: column;
  gap: 20px;
  max-width: 560px;
}

.reminder-form {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
}

.reminder-form input[type="text"] {
  flex: 1;
  min-width: 200px;
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  color: var(--text);
  padding: 10px 12px;
  font-size: 14px;
  font-family: inherit;
}

.reminder-form input[type="datetime-local"] {
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  color: var(--text-dim);
  padding: 9px 10px;
  font-size: 13px;
  font-family: inherit;
}

.reminder-list {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.reminder-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  background: var(--panel);
  border: 1px solid var(--border);
  border-left: 2px solid var(--accent);
  border-radius: var(--radius);
  padding: 12px 14px;
}

.reminder-text {
  font-size: 14px;
  color: var(--text);
}

.reminder-due {
  font-size: 12px;
  color: var(--accent);
  margin-top: 3px;
}

.reminder-remove {
  background: none;
  border: none;
  color: var(--text-dim);
  font-size: 16px;
  cursor: pointer;
  padding: 4px 8px;
}

.reminder-remove:hover {
  color: var(--danger);
}

/* ---------- Webhooks panel ---------- */

.webhooks-hint {
  font-size: 12px;
  color: var(--text-dim);
  margin: 0;
  line-height: 1.5;
}

.webhooks-hint code {
  background: var(--panel-alt);
  padding: 1px 5px;
  border-radius: 2px;
}

.webhook-list {
  display: flex;
  flex-direction: column;
  gap: 6px;
  max-height: 240px;
  overflow-y: auto;
}

.webhook-row {
  display: flex;
  align-items: center;
  gap: 10px;
  background: var(--panel-alt);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 10px 12px;
}

.webhook-info {
  flex: 1;
  min-width: 0;
}

.webhook-name {
  font-size: 13px;
  color: var(--text);
  font-weight: 500;
}

.webhook-url {
  font-size: 11px;
  color: var(--text-dim);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.webhook-test {
  font-size: 11px;
  padding: 5px 10px;
  flex-shrink: 0;
}

.webhook-remove {
  background: none;
  border: none;
  color: var(--text-dim);
  font-size: 15px;
  cursor: pointer;
  padding: 2px 6px;
  flex-shrink: 0;
}

.webhook-remove:hover {
  color: var(--danger);
}

.new-webhook-form {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  padding-top: 8px;
  border-top: 1px solid var(--border);
}

.new-webhook-form input, .new-webhook-form select {
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  color: var(--text);
  padding: 7px 9px;
  font-size: 12px;
  font-family: inherit;
}

.new-webhook-form input[type="text"]:first-of-type { flex: 0 0 100px; }
.new-webhook-form input#whUrl { flex: 1; min-width: 160px; }
.new-webhook-form input#whParams { flex: 1; min-width: 160px; }

/* ---------- Mobile ---------- */

@media (max-width: 720px) {
  .shell { flex-direction: column; }
  .drawer {
    width: 100%;
    border-right: none;
    border-bottom: 1px solid var(--border);
    flex-direction: row;
    flex-wrap: wrap;
    align-items: center;
    padding: 16px;
  }
  .drawer-title { width: 100%; }
  .new-folder-form { margin-top: 0; padding-top: 0; border-top: none; width: 100%; }
  .main { padding: 20px; }
}
