:root {
  --bg: #f6f4ef; --surface: #ffffff; --text: #1d2129; --muted: #6b6f76; --line: #e5e1d8;
  --accent: #b7791f; --danger: #d1242f; --sel: #fbf1dd;
  color-scheme: light dark;
}
@media (prefers-color-scheme: dark) {
  :root { --bg: #121212; --surface: #1b1b1d; --text: #e8e6e3; --muted: #92908c; --line: #2a2a2d;
    --accent: #e0a43a; --sel: #2b2417; }
}
* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; background: var(--bg); color: var(--text);
  font: 16px/1.5 -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif; }
[hidden] { display: none !important; }
button { font: inherit; cursor: pointer; color: inherit; }
.hint { color: var(--muted); font-size: .85rem; margin: 0; }
.center { text-align: center; margin-top: 30vh; }
.error { color: var(--danger); margin: 0; }

/* Login */
#login { min-height: 100dvh; display: grid; place-items: center; padding: 24px; }
.login-box { width: 100%; max-width: 320px; display: grid; gap: 14px; text-align: center; }
.login-box img { margin: 0 auto; border-radius: 18px; }
.login-box h1 { margin: 0 0 8px; font-size: 1.4rem; }
.primary-btn { display: block; padding: 14px; border-radius: 12px; background: var(--accent);
  color: #fff; font-weight: 600; text-decoration: none; }

/* Estructura: dos columnas en escritorio, una vista cada vez en móvil */
#main { height: 100dvh; display: grid; grid-template-columns: 340px 1fr; }
#list-pane { position: relative; display: flex; flex-direction: column; min-height: 0;
  border-right: 1px solid var(--line); background: var(--bg); }
#editor-pane { display: flex; flex-direction: column; min-height: 0; background: var(--surface); }
#btn-back { display: none; }
@media (max-width: 760px) {
  #main { grid-template-columns: 1fr; }
  #list-pane { border-right: 0; }
  #main.editing #list-pane { display: none; }
  #main:not(.editing) #editor-pane { display: none; }
  #btn-back { display: inline-flex; }
}

.bar { display: flex; align-items: center; gap: 8px; min-height: 52px;
  padding: calc(env(safe-area-inset-top) + 6px) 10px 6px 14px; border-bottom: 1px solid var(--line); }
.bar h1 { margin: 0; font-size: 1.15rem; flex: 1; }
.bar .hint { flex: 1; }
.bar-actions { display: flex; gap: 2px; }
.icon-btn { display: inline-flex; align-items: center; justify-content: center; min-width: 40px; height: 40px;
  border: 0; border-radius: 10px; background: transparent; font-size: 1.15rem; }
.icon-btn:hover { background: var(--line); }
.icon-btn.on { background: var(--sel); }
#btn-back { font-size: 1.8rem; line-height: 1; }

.search-row { padding: 10px 12px 6px; }
#search { width: 100%; padding: 10px 12px; border-radius: 10px; border: 1px solid var(--line);
  background: var(--surface); color: var(--text); font-size: 1rem; }
#list-pane > .hint { padding: 6px 14px; }

.note-list { list-style: none; margin: 0; padding: 4px 8px 96px; overflow-y: auto; flex: 1; }
.note-list li { padding: 10px 12px; border-radius: 10px; cursor: pointer; }
.note-list li:hover { background: var(--line); }
.note-list li.active { background: var(--sel); }
.note-list .t { font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.note-list .s { color: var(--muted); font-size: .9rem; overflow: hidden; display: -webkit-box;
  -webkit-line-clamp: 2; -webkit-box-orient: vertical; white-space: pre-line; }
.note-list .d { color: var(--muted); font-size: .75rem; margin-top: 2px; }

.fab { position: absolute; right: 18px; bottom: calc(env(safe-area-inset-bottom) + 18px);
  width: 56px; height: 56px; border-radius: 50%; border: 0; background: var(--accent); color: #fff;
  font-size: 1.8rem; box-shadow: 0 4px 14px rgba(0,0,0,.25); }

#editor { flex: 1; display: flex; flex-direction: column; min-height: 0;
  padding: 16px 18px calc(env(safe-area-inset-bottom) + 12px); max-width: 860px; width: 100%; margin: 0 auto; }
#title { border: 0; outline: 0; background: transparent; color: var(--text);
  font-size: 1.5rem; font-weight: 700; padding: 4px 0 10px; }
#body { flex: 1; border: 0; outline: 0; resize: none; background: transparent; color: var(--text);
  font: inherit; font-size: 1.02rem; line-height: 1.6; min-height: 200px; }
#meta { padding-top: 8px; }
#btn-logout { font-size: .85rem; padding: 0 8px; }
