/* ==============================
   CATATAN — clean notes theme
   ============================== */
:root {
  --bg: #0e1015;
  --bg-2: #13161d;
  --card: #171b24;
  --card-2: #1c2129;
  --stroke: #242a36;
  --text: #e9ecef;
  --muted: #9aa3b2;
  --faint: #5f687a;
  --accent: #7c5cff;
  --accent-2: #3ddc97;
  --danger: #ff5c5c;
  --radius: 14px;
  --shadow: 0 12px 40px rgba(0, 0, 0, .45);
  --font: 'Inter', system-ui, -apple-system, sans-serif;
}
[data-theme="light"] {
  --bg: #f6f7fb;
  --bg-2: #eceef5;
  --card: #ffffff;
  --card-2: #f3f4f9;
  --stroke: #e1e5ef;
  --text: #191c24;
  --muted: #59606f;
  --faint: #8d94a3;
  --shadow: 0 12px 40px rgba(30, 40, 80, .1);
}

* { margin: 0; padding: 0; box-sizing: border-box; }
html { height: 100%; }
body {
  font-family: var(--font);
  background: var(--bg);
  color: var(--text);
  height: 100vh;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}
button, input, textarea { font-family: var(--font); }

/* ---------- TOP BAR ---------- */
.topbar {
  display: flex; align-items: center; justify-content: space-between;
  padding: 0 22px; height: 62px;
  background: var(--bg-2);
  border-bottom: 1px solid var(--stroke);
  flex-shrink: 0;
}
.brand { display: flex; align-items: center; gap: 10px; }
.logo {
  width: 36px; height: 36px; border-radius: 11px;
  background: linear-gradient(135deg, var(--accent), #a78bfa);
  display: grid; place-items: center; font-size: 18px;
  box-shadow: 0 4px 16px rgba(124, 92, 255, .4);
}
.brand-name { font-weight: 800; font-size: 19px; letter-spacing: .3px; }
.brand-name .dot { color: var(--accent); }
.top-actions { display: flex; gap: 10px; }

.ghost-btn {
  display: inline-flex; align-items: center; gap: 8px;
  background: transparent; color: var(--text);
  border: 1px solid var(--stroke); border-radius: 10px;
  padding: 9px 15px; font-size: 14px; font-weight: 600;
  cursor: pointer; transition: .2s;
}
.ghost-btn:hover { border-color: var(--faint); background: var(--card); }
.ghost-btn .plus { font-size: 16px; }
.ghost-btn.icon { padding: 9px 12px; font-size: 15px; }

/* ---------- LAYOUT ---------- */
.layout { flex: 1; display: flex; min-height: 0; }

/* ---------- SIDEBAR ---------- */
.sidebar {
  width: 300px; flex-shrink: 0;
  background: var(--bg-2);
  border-right: 1px solid var(--stroke);
  display: flex; flex-direction: column;
  padding: 14px;
  overflow: hidden;
}
.sidebar-head {
  display: flex; justify-content: space-between; align-items: center;
  font-size: 12.5px; text-transform: uppercase; letter-spacing: .5px;
  color: var(--faint); font-weight: 600; padding: 2px 6px 10px;
}
.count {
  background: var(--card-2); padding: 2px 9px; border-radius: 999px;
  font-size: 11.5px; color: var(--muted);
}
.search-box {
  display: flex; align-items: center; gap: 8px;
  background: var(--card); border: 1px solid var(--stroke);
  border-radius: 10px; padding: 8px 12px; margin-bottom: 10px;
}
.search-ico { font-size: 13px; opacity: .7; }
.search-box input {
  flex: 1; background: transparent; border: none; outline: none;
  color: var(--text); font-size: 13.5px;
}
.search-box input::placeholder { color: var(--faint); }

.note-list { flex: 1; overflow-y: auto; display: flex; flex-direction: column; gap: 6px; padding-right: 2px; }
.note-list::-webkit-scrollbar { width: 6px; }
.note-list::-webkit-scrollbar-thumb { background: var(--stroke); border-radius: 4px; }

.note-item {
  display: block; text-align: left; width: 100%;
  background: transparent; border: 1px solid transparent;
  border-radius: 11px; padding: 12px 14px; cursor: pointer;
  transition: .15s; color: var(--text);
}
.note-item:hover { background: var(--card); }
.note-item.active {
  background: var(--card);
  border-color: var(--accent);
  box-shadow: 0 4px 18px rgba(124, 92, 255, .18);
}
.note-item .ni-title {
  font-size: 14px; font-weight: 600; margin-bottom: 3px;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.note-item .ni-preview {
  font-size: 12.5px; color: var(--muted);
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.note-item .ni-date { font-size: 11px; color: var(--faint); margin-top: 4px; }

.sidebar-empty { text-align: center; padding: 30px 12px; }
.empty-emoji { font-size: 34px; margin-bottom: 8px; }
.empty-text { font-size: 13px; color: var(--muted); line-height: 1.5; }

/* ---------- EDITOR ---------- */
.editor { flex: 1; display: flex; flex-direction: column; min-width: 0; background: var(--bg); }

.editor-empty {
  flex: 1; display: flex; flex-direction: column; align-items: center; justify-content: center;
  gap: 8px; text-align: center; padding: 30px;
}
.empty-hero { font-size: 64px; margin-bottom: 6px; filter: drop-shadow(0 8px 24px rgba(124,92,255,.35)); }
.editor-empty h2 { font-size: 24px; }
.editor-empty p { color: var(--muted); font-size: 14.5px; max-width: 380px; line-height: 1.6; }
.primary-btn {
  margin-top: 16px; background: linear-gradient(135deg, var(--accent), #a78bfa);
  color: #fff; border: none; border-radius: 12px; padding: 13px 24px;
  font-size: 15px; font-weight: 700; cursor: pointer; box-shadow: 0 10px 30px rgba(124,92,255,.4);
  transition: .2s;
}
.primary-btn:hover { transform: translateY(-2px); }

.editor-main { flex: 1; display: flex; flex-direction: column; min-height: 0; }
.editor-toolbar {
  display: flex; justify-content: space-between; align-items: center; gap: 12px;
  padding: 16px 24px 8px; flex-wrap: wrap;
}
.title-input {
  background: transparent; border: none; outline: none;
  font-size: 22px; font-weight: 700; color: var(--text);
  flex: 1; min-width: 200px;
}
.title-input::placeholder { color: var(--faint); font-weight: 600; }
.toolbar-actions { display: flex; align-items: center; gap: 12px; }
.saved-state { font-size: 11.5px; color: var(--faint); white-space: nowrap; }
.saved-state.saving { color: var(--accent-2); }
.saved-state.error { color: var(--danger); }
.wordcount { font-size: 12px; color: var(--faint); }
.tool-btn {
  width: 36px; height: 36px; border-radius: 9px; border: 1px solid transparent;
  background: transparent; font-size: 16px; cursor: pointer; transition: .15s;
}
.tool-btn.danger:hover { background: rgba(255,92,92,.12); }
.tool-btn.danger { color: var(--faint); }
.tool-btn.danger:hover { color: var(--danger); border-color: var(--danger); }

.content-area {
  flex: 1; border: none; outline: none; resize: none;
  background: transparent; color: var(--text);
  font-size: 15.5px; line-height: 1.75;
  padding: 8px 24px 20px;
  scrollbar-width: thin;
}
.content-area::placeholder { color: var(--faint); }
.content-area::-webkit-scrollbar { width: 8px; }
.content-area::-webkit-scrollbar-thumb { background: var(--stroke); border-radius: 4px; }

.editor-footer {
  display: flex; justify-content: space-between; align-items: center; gap: 12px;
  padding: 10px 24px 14px; border-top: 1px solid var(--stroke);
  font-size: 12px; color: var(--faint); flex-wrap: wrap;
}
.footer-links { display: flex; gap: 16px; }
.share-link { color: var(--muted); text-decoration: none; font-weight: 600; font-size: 12.5px; }
.share-link:hover { color: var(--accent); }

/* ---------- TOAST ---------- */
.toast {
  position: fixed; left: 50%; bottom: 26px; transform: translateX(-50%);
  background: var(--card-2); border: 1px solid var(--stroke); color: var(--text);
  padding: 11px 20px; border-radius: 12px; font-size: 13.5px; z-index: 60;
  box-shadow: var(--shadow); animation: rise .25s ease;
}
.toast.ok { border-color: var(--accent-2); }
.toast.error { border-color: var(--danger); }
@keyframes rise { from { opacity: 0; transform: translate(-50%, 10px); } }

/* ---------- RESPONSIVE ---------- */
@media (max-width: 720px) {
  .sidebar { width: 250px; }
  .title-input { font-size: 19px; }
}
@media (max-width: 540px) {
  .sidebar { width: 100%; border-right: none; border-bottom: 1px solid var(--stroke); max-height: 40vh; }
  .layout { flex-direction: column; }
  .sidebar { display: none; }
  .layout.sidebar-open .sidebar { display: flex; }
  .wordcount { display: none; }
}