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

:root {
  --bg: #1a1a2e;
  --surface: #16213e;
  --surface2: #0f3460;
  --primary: #e94560;
  --text: #eee;
  --text-dim: #999;
  --border: #333;
  --radius: 8px;
}

html, body { height: 100%; }

body {
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  background: var(--bg);
  color: var(--text);
  display: flex;
  flex-direction: column;
}

/* Navbar */
.navbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 10px 20px;
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  flex-shrink: 0;
}

.logo {
  font-size: 1.3rem;
  font-weight: 700;
  color: var(--primary);
  text-decoration: none;
}

.nav-links a {
  color: var(--text-dim);
  text-decoration: none;
  margin-left: 20px;
  font-size: 0.9rem;
}

.nav-links a:hover, .nav-links a.active { color: var(--text); }

/* Editor page - fills 95% of screen */
.editor-page {
  display: flex;
  flex-direction: column;
  height: 95vh;
  padding: 0;
}

.toolbar {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 20px;
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  flex-wrap: wrap;
}

.title-input {
  flex: 1;
  min-width: 150px;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 8px 12px;
  color: var(--text);
  font-size: 1rem;
}

.toolbar-right {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
}

.password-toggle {
  display: flex;
  align-items: center;
  gap: 5px;
  cursor: pointer;
  font-size: 0.85rem;
  color: var(--text-dim);
  user-select: none;
}

.password-toggle input[type="checkbox"] { accent-color: var(--primary); }

.password-input {
  width: 140px;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 6px 10px;
  color: var(--text);
  font-size: 0.85rem;
}

.toolbar-btn {
  background: none;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 6px 10px;
  color: var(--text);
  cursor: pointer;
  font-size: 1rem;
  transition: background 0.2s;
}

.toolbar-btn:hover { background: var(--surface2); }
.toolbar-btn.active { color: #f1c40f; }

.btn {
  display: inline-block;
  padding: 8px 18px;
  border-radius: var(--radius);
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--text);
  cursor: pointer;
  font-size: 0.9rem;
  text-decoration: none;
  transition: background 0.2s;
}

.btn:hover { background: var(--surface2); }

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

.btn-primary:hover { opacity: 0.9; }

.note-editor {
  flex: 1;
  width: 100%;
  padding: 20px;
  background: var(--bg);
  border: none;
  outline: none;
  color: var(--text);
  font-family: 'SF Mono', 'Fira Code', 'Consolas', monospace;
  font-size: 1rem;
  line-height: 1.6;
  resize: none;
  tab-size: 4;
}

.note-editor::placeholder { color: var(--text-dim); }

/* Toast */
.toast {
  position: fixed;
  bottom: 30px;
  left: 50%;
  transform: translateX(-50%);
  background: var(--surface2);
  color: var(--text);
  padding: 12px 24px;
  border-radius: var(--radius);
  font-size: 0.9rem;
  z-index: 1000;
  transition: opacity 0.3s;
  border: 1px solid var(--border);
}

.toast.hidden { opacity: 0; pointer-events: none; }

/* Modal */
.modal {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.7);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 999;
}

.modal.hidden { display: none; }

.modal-content {
  background: var(--surface);
  padding: 30px;
  border-radius: var(--radius);
  max-width: 450px;
  width: 90%;
  text-align: center;
}

.modal-content h2 { margin-bottom: 10px; }

.modal-content p { color: var(--text-dim); margin-bottom: 15px; }

.result-link {
  display: flex;
  gap: 8px;
  margin-bottom: 15px;
}

.result-link input {
  flex: 1;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 8px 12px;
  color: var(--text);
  font-size: 0.9rem;
}

.modal-content .btn { margin: 5px; }

/* Note view page */
.note-view-page {
  flex: 1;
  display: flex;
  flex-direction: column;
}

.unlock-prompt {
  flex: 1;
  display: flex;
  align-items: center;
  justify-content: center;
}

.unlock-box {
  background: var(--surface);
  padding: 30px;
  border-radius: var(--radius);
  text-align: center;
  max-width: 350px;
  width: 90%;
}

.unlock-box h2 { margin-bottom: 15px; font-size: 1.1rem; }

.unlock-box input {
  width: 100%;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 10px;
  color: var(--text);
  font-size: 1rem;
  margin-bottom: 10px;
}

.unlock-box .btn { width: 100%; }

.error { color: var(--primary); font-size: 0.85rem; margin-top: 8px; }
.hidden { display: none !important; }

#note-container {
  flex: 1;
  display: flex;
  flex-direction: column;
  padding: 20px;
}

.note-toolbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 15px;
  flex-wrap: wrap;
  gap: 10px;
}

.note-title {
  font-size: 1.4rem;
  color: var(--text);
  word-break: break-word;
}

.note-actions { display: flex; gap: 6px; }

.note-content {
  flex: 1;
  white-space: pre-wrap;
  word-wrap: break-word;
  font-family: 'SF Mono', 'Fira Code', 'Consolas', monospace;
  font-size: 0.95rem;
  line-height: 1.6;
  color: var(--text);
  padding: 15px;
  background: var(--surface);
  border-radius: var(--radius);
  overflow-y: auto;
}

.note-date {
  color: var(--text-dim);
  font-size: 0.8rem;
  margin-top: 10px;
  text-align: right;
}

/* Search page */
.page-center {
  flex: 1;
  max-width: 700px;
  width: 100%;
  margin: 0 auto;
  padding: 30px 20px;
}

.page-center h1 { margin-bottom: 20px; }

.search-bar {
  display: flex;
  gap: 10px;
  margin-bottom: 20px;
}

.search-bar input {
  flex: 1;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 10px 14px;
  color: var(--text);
  font-size: 1rem;
}

.notes-list { min-height: 200px; }

.hint, .loading { color: var(--text-dim); text-align: center; padding: 40px; }

.note-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 15px;
  margin-bottom: 10px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
}

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

.note-card-title {
  font-weight: 600;
  margin-bottom: 4px;
  word-break: break-word;
}

.note-card-title a { color: var(--primary); text-decoration: none; }
.note-card-title a:hover { text-decoration: underline; }

.note-card-meta {
  font-size: 0.8rem;
  color: var(--text-dim);
}

.note-card-actions {
  display: flex;
  gap: 4px;
  flex-shrink: 0;
}

.note-card .fav-star {
  cursor: pointer;
  font-size: 1.2rem;
  background: none;
  border: none;
  color: var(--text-dim);
  padding: 4px;
}

.note-card .fav-star.active { color: #f1c40f; }

/* Pagination */
.pagination {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  margin-top: 20px;
}

.pagination span { color: var(--text-dim); font-size: 0.85rem; }

/* Mic recording indicator */
.mic-recording {
  color: var(--primary) !important;
  animation: pulse 1s infinite;
  border-color: var(--primary) !important;
}

@keyframes pulse {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.5; }
}

/* Lock icon on protected notes */
.protected-badge { font-size: 0.8rem; color: var(--text-dim); margin-left: 8px; }

/* Scrollbar */
::-webkit-scrollbar { width: 8px; }
::-webkit-scrollbar-track { background: var(--bg); }
::-webkit-scrollbar-thumb { background: var(--border); border-radius: 4px; }
::-webkit-scrollbar-thumb:hover { background: var(--text-dim); }
