:root {
  /* Palette — deep slate base, single teal accent, restrained amber for status */
  --bg: #0d1117;
  --bg-2: #131920;
  --panel: #161b22;
  --panel-2: #1c222b;
  --border: #2a3340;
  --border-soft: rgba(88, 166, 255, 0.14);
  --text: #dbe2ec;
  --text-dim: #8b96a5;
  --text-mute: #5b6675;
  --accent: #58a6ff;
  --accent-2: #79c0ff;
  --amber: #f0b65c;
  --danger: #f47067;
  --ok: #7ee787;
  --mono: "JetBrains Mono", "SFMono-Regular", Consolas, monospace;
  --sans: "Inter", system-ui, -apple-system, sans-serif;
  --radius: 10px;
  --shadow: 0 18px 40px rgba(0, 0, 0, 0.5);
}

* { box-sizing: border-box; }

html, body {
  height: 100%;
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: var(--sans);
  font-size: 15px;
  line-height: 1.55;
  -webkit-font-smoothing: antialiased;
}

/* ================= LOCK SCREEN ================= */
.lock-screen {
  position: fixed;
  inset: 0;
  display: grid;
  place-items: center;
  background:
    radial-gradient(1200px 600px at 75% -10%, rgba(88, 166, 255, 0.12), transparent 60%),
    radial-gradient(900px 500px at 15% 110%, rgba(240, 182, 92, 0.06), transparent 55%),
    var(--bg);
  padding: 24px;
}
.lock-card {
  width: min(400px, 100%);
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 16px;
  padding: 40px 36px 34px;
  box-shadow: var(--shadow);
  text-align: center;
}
.lock-mark {
  width: 64px; height: 64px;
  margin: 0 auto 16px;
  display: grid; place-items: center;
  color: var(--accent);
  background: var(--border-soft);
  border: 1px solid rgba(88, 166, 255, 0.28);
  border-radius: 16px;
}
.lock-card h1 {
  margin: 0;
  font-family: var(--mono);
  font-size: 1.6rem;
  font-weight: 600;
  letter-spacing: -0.02em;
}
.lock-sub {
  color: var(--text-dim);
  font-size: 0.85rem;
  margin: 6px 0 26px;
}
.field, .verify-field { margin-bottom: 12px; }

.lock-card input {
  width: 100%;
  padding: 12px 14px;
  background: var(--bg-2);
  border: 1px solid var(--border);
  border-radius: 8px;
  color: var(--text);
  font-size: 1rem;
  font-family: var(--mono);
  outline: none;
  transition: border-color 0.15s, box-shadow 0.15s;
}
.lock-card input:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(88, 166, 255, 0.18);
}
.lock-card input::placeholder { color: var(--text-mute); }

.btn-primary {
  width: 100%;
  margin-top: 8px;
  padding: 12px;
  background: var(--accent);
  color: #06121f;
  font-weight: 600;
  font-size: 0.95rem;
  border: none;
  border-radius: 8px;
  cursor: pointer;
  transition: background 0.15s, transform 0.05s;
}
.btn-primary:hover { background: var(--accent-2); }
.btn-primary:active { transform: translateY(1px); }
.btn-primary:disabled { opacity: 0.6; cursor: default; }

.lock-error {
  min-height: 1.2em;
  color: var(--danger);
  font-size: 0.85rem;
  margin: 12px 0 0;
}
.lock-hint {
  color: var(--text-mute);
  font-size: 0.78rem;
  margin: 20px 0 0;
  line-height: 1.5;
}

/* ================= APP LAYOUT ================= */
.app {
  display: grid;
  grid-template-columns: 300px 1fr;
  height: 100vh;
  overflow: hidden;
}

/* ================= SIDEBAR ================= */
.sidebar {
  display: flex;
  flex-direction: column;
  background: var(--bg);
  border-right: 1px solid var(--border);
  min-height: 0;
}
.sidebar-head {
  padding: 16px 14px 12px;
  border-bottom: 1px solid var(--border);
}
.logo-row {
  display: flex; align-items: center; justify-content: space-between;
  margin-bottom: 12px;
}
.logo {
  font-family: var(--mono);
  font-weight: 600;
  font-size: 1.1rem;
  letter-spacing: -0.01em;
  color: var(--accent);
}

.icon-btn, .tool-btn {
  display: inline-flex; align-items: center; gap: 6px;
  background: var(--panel);
  border: 1px solid var(--border);
  color: var(--text-dim);
  border-radius: 7px;
  cursor: pointer;
  padding: 6px 8px;
  transition: background 0.12s, color 0.12s, border-color 0.12s;
}
.icon-btn:hover { color: var(--text); border-color: var(--accent); }
.icon-btn.danger:hover { color: var(--danger); border-color: var(--danger); }

.btn-new {
  width: 100%;
  display: flex; align-items: center; justify-content: center; gap: 8px;
  padding: 10px;
  background: var(--accent);
  color: #06121f;
  border: none;
  border-radius: 8px;
  font-weight: 600;
  font-size: 0.9rem;
  cursor: pointer;
  transition: background 0.15s;
}
.btn-new:hover { background: var(--accent-2); }

.search-wrap {
  display: flex; align-items: center; gap: 8px;
  margin-top: 12px;
  padding: 8px 10px;
  background: var(--bg-2);
  border: 1px solid var(--border);
  border-radius: 8px;
  color: var(--text-mute);
}
.search-wrap:focus-within { border-color: var(--accent); }
.search-wrap input {
  flex: 1;
  background: none; border: none; outline: none;
  color: var(--text); font-size: 0.85rem;
}
.search-wrap input::placeholder { color: var(--text-mute); }

.folder-list {
  display: flex; flex-wrap: wrap; gap: 6px;
  padding: 10px 14px 6px;
  border-bottom: 1px solid var(--border);
}
.folder-chip {
  background: var(--panel-2);
  border: 1px solid var(--border);
  color: var(--text-dim);
  padding: 3px 10px;
  font-size: 0.75rem;
  border-radius: 20px;
  cursor: pointer;
  transition: all 0.12s;
}
.folder-chip:hover { color: var(--text); border-color: var(--accent); }
.folder-chip.active { background: rgba(88,166,255,0.14); color: var(--accent-2); border-color: var(--border-soft); }

.note-list {
  flex: 1;
  overflow-y: auto;
  padding: 8px;
  min-height: 0;
}
.note-item {
  width: 100%;
  display: block;
  text-align: left;
  padding: 10px 12px;
  margin-bottom: 2px;
  background: none;
  border: none;
  border-radius: 7px;
  color: var(--text);
  font-family: var(--sans);
  cursor: pointer;
  transition: background 0.12s;
}
.note-item:hover { background: var(--panel); }
.note-item.active { background: var(--panel-2); box-shadow: inset 2px 0 0 var(--accent); }
.note-item-meta {
  font-size: 0.88rem;
  font-weight: 500;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.note-item-lang {
  font-family: var(--mono);
  font-size: 0.66rem;
  color: var(--text-mute);
  text-transform: uppercase;
  letter-spacing: 0.04em;
  margin-top: 3px;
}
.pin-dot { color: var(--amber); margin-left: 6px; font-size: 0.6rem; }
.list-empty {
  color: var(--text-mute);
  text-align: center;
  padding: 30px 10px;
  font-size: 0.85rem;
}

.sidebar-foot {
  display: flex; align-items: center; justify-content: space-between;
  padding: 10px 14px;
  border-top: 1px solid var(--border);
  color: var(--text-mute);
  font-size: 0.75rem;
}
.enc-badge {
  display: inline-flex; align-items: center; gap: 5px;
  color: var(--ok);
}
.enc-badge::before {
  content: "";
  width: 7px; height: 7px;
  border-radius: 50%;
  background: var(--ok);
}

/* ================= EDITOR PANE ================= */
.editor-pane {
  position: relative;
  display: flex;
  flex-direction: column;
  background: var(--bg-2);
  min-width: 0;
  min-height: 0;
}
.editor-empty {
  flex: 1;
  display: grid;
  place-content: center;
  text-align: center;
  color: var(--text-dim);
  padding: 40px;
}
.empty-mark {
  font-family: var(--mono);
  font-size: 3rem;
  color: var(--border);
  margin-bottom: 8px;
}
.editor-empty h2 { margin: 0 0 6px; font-weight: 500; font-size: 1.2rem; color: var(--text); }
.editor-empty p { margin: 0; font-size: 0.88rem; max-width: 380px; }

.editor {
  flex: 1;
  display: flex;
  flex-direction: column;
  min-height: 0;
}

.editor-head {
  display: flex; align-items: center; justify-content: space-between; gap: 12px;
  padding: 14px 18px;
  border-bottom: 1px solid var(--border);
  background: var(--panel);
  flex-wrap: wrap;
}
.title-input {
  flex: 1;
  min-width: 160px;
  background: none;
  border: none;
  outline: none;
  color: var(--text);
  font-family: var(--mono);
  font-size: 1.05rem;
  font-weight: 500;
  padding: 4px 0;
}
.title-input::placeholder { color: var(--text-mute); }

.editor-actions { display: flex; align-items: center; gap: 8px; }
.lang-picker, .folder-picker select {
  background: var(--bg-2);
  border: 1px solid var(--border);
  color: var(--text-dim);
  border-radius: 7px;
  padding: 6px 8px;
  font-size: 0.8rem;
  font-family: var(--mono);
  outline: none;
  cursor: pointer;
}
.lang-picker:hover, .folder-picker select:hover { border-color: var(--accent); }
.folder-picker { display: inline-flex; align-items: center; gap: 5px; color: var(--text-mute); }

.pin-toggle { position: absolute; opacity: 0; width: 0; height: 0; }
.pin-label {
  display: inline-flex; align-items: center;
  color: var(--text-mute);
  cursor: pointer;
  padding: 4px;
  border-radius: 6px;
  transition: color 0.12s;
}
.pin-toggle:checked + .pin-label { color: var(--amber); }

/* ================= TOOLBAR ================= */
.toolbar {
  display: flex; align-items: center; justify-content: space-between;
  padding: 8px 18px;
  background: var(--bg-2);
  border-bottom: 1px solid var(--border);
}
.tool-btn {
  padding: 4px 10px;
  font-size: 0.78rem;
  background: var(--panel);
}
.tool-btn:hover { color: var(--accent); }
.save-state { color: var(--text-mute); font-size: 0.75rem; font-family: var(--mono); }

/* ================= CODE EDITOR ================= */
.code-wrap {
  position: relative;
  flex: 1;
  min-height: 0;
  overflow: hidden;
}
.code-editor, .code-highlight {
  position: absolute;
  inset: 0;
  margin: 0;
  padding: 20px 22px;
  font-family: var(--mono);
  font-size: 0.9rem;
  line-height: 1.65;
  tab-size: 2;
  white-space: pre-wrap;
  word-wrap: break-word;
  overflow-wrap: break-word;
  border: none;
  outline: none;
  overflow: auto;
  background: transparent;
  color: var(--text);
  box-sizing: border-box;
}
.code-editor {
  z-index: 1;
  resize: none;
  caret-color: var(--accent);
  color: transparent;
  background: transparent;
}
.code-editor::selection { color: transparent; background: rgba(88,166,255,0.25); }
.code-highlight {
  z-index: 0;
  pointer-events: none;
  color: var(--text);
}
.code-highlight code { font-family: var(--mono); background: none; }

/* Prism tweaks */
code[class*="language-"], pre[class*="language-"] {
  font-family: var(--mono) !important;
  font-size: 0.9rem !important;
  text-shadow: none !important;
  background: transparent !important;
}

/* ================= TOAST ================= */
.toast {
  position: fixed;
  bottom: 24px;
  left: 50%;
  transform: translateX(-50%) translateY(20px);
  background: var(--panel);
  color: var(--text);
  border: 1px solid var(--border);
  padding: 10px 18px;
  border-radius: 10px;
  font-size: 0.85rem;
  box-shadow: var(--shadow);
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.2s, transform 0.2s;
  z-index: 50;
}
.toast.show { opacity: 1; transform: translateX(-50%) translateY(0); }
.toast.ok { border-color: var(--ok); }
.toast.error { border-color: var(--danger); }

/* ================= SCROLLBARS ================= */
::-webkit-scrollbar { width: 10px; height: 10px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--border); border-radius: 5px; }
::-webkit-scrollbar-thumb:hover { background: var(--text-mute); }

/* ================= RESPONSIVE ================= */
@media (max-width: 720px) {
  .app { grid-template-columns: 1fr; grid-template-rows: auto 1fr; }
  .sidebar { border-right: none; border-bottom: 1px solid var(--border); max-height: 45vh; }
  .note-list { max-height: 30vh; }
}
@media (prefers-reduced-motion: reduce) {
  * { transition: none !important; }
}

/* ================= FOCUS ================= */
:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}
