:root {
  --bg: #fbf7f2;
  --card: #ffffff;
  --ink: #2b2320;
  --muted: #7a7068;
  --accent: #ff7a3d;
  --accent-ink: #ffffff;
  --border: #ece3d8;
  --teal: #1f8a70;
  --sidebar-bg: #241d1a;
  --sidebar-ink: #f1e9e2;
  --sidebar-muted: #a99c92;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  background: var(--bg);
  color: var(--ink);
}

.wrap { max-width: 960px; margin: 0 auto; padding: 32px 20px; }
.centered { min-height: 100vh; display: flex; align-items: center; justify-content: center; padding: 20px; }

.card {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 14px;
  padding: 24px;
  box-shadow: 0 2px 10px rgba(43,35,32,0.05);
}

.login-card { width: 100%; max-width: 380px; }

h1 { font-size: 1.4rem; margin: 0 0 4px; }
.subtitle { color: var(--muted); margin: 0 0 20px; }

label { display: block; font-size: 0.85rem; color: var(--muted); margin: 12px 0 4px; }

input[type="email"], input[type="password"], input[type="text"], input[type="file"], textarea {
  width: 100%;
  padding: 10px 12px;
  border: 1px solid var(--border);
  border-radius: 8px;
  font-size: 0.95rem;
  font-family: inherit;
  background: #fff;
}

textarea { resize: vertical; margin-top: 8px; }

button, .btn {
  display: inline-block;
  margin-top: 14px;
  background: var(--accent);
  color: var(--accent-ink);
  border: none;
  padding: 10px 18px;
  border-radius: 8px;
  font-size: 0.95rem;
  font-weight: 600;
  cursor: pointer;
  text-decoration: none;
}
button:hover, .btn:hover { opacity: 0.92; }

.link-btn {
  background: none;
  color: var(--sidebar-muted);
  text-decoration: underline;
  padding: 0;
  margin: 0;
  font-weight: 400;
  cursor: pointer;
}

.alert {
  background: #fdecea;
  color: #b3261e;
  border: 1px solid #f5c6c2;
  padding: 10px 12px;
  border-radius: 8px;
  margin-bottom: 12px;
  font-size: 0.9rem;
}

.hint { color: var(--muted); font-size: 0.78rem; margin-top: 8px; }

/* app shell */
.app { display: flex; min-height: 100vh; align-items: stretch; }

.sidebar {
  width: 260px;
  flex-shrink: 0;
  background: var(--sidebar-bg);
  color: var(--sidebar-ink);
  padding: 20px 16px;
  display: flex;
  flex-direction: column;
  gap: 14px;
}
.brand { font-weight: 700; font-size: 1.05rem; }
.search-box input {
  background: #362d29;
  border: 1px solid #4a3f39;
  color: var(--sidebar-ink);
}
.tree { list-style: none; margin: 0; padding: 0; flex: 1; overflow-y: auto; }
.tree ul { list-style: none; margin: 0; padding-left: 14px; }
.tree li { margin: 2px 0; }
.tree a {
  color: var(--sidebar-muted);
  text-decoration: none;
  font-size: 0.88rem;
  display: block;
  padding: 4px 6px;
  border-radius: 6px;
  word-break: break-word;
}
.tree a:hover { background: #362d29; color: var(--sidebar-ink); }
.tree a.active { background: var(--accent); color: var(--accent-ink); }
.logout-form { margin-top: auto; }

.content { flex: 1; padding: 28px 36px; max-width: 980px; }

.crumb { color: var(--muted); font-size: 0.9rem; margin-bottom: 18px; }
.crumb a { color: var(--teal); text-decoration: none; }
.crumb a:hover { text-decoration: underline; }

.file-list { list-style: none; padding: 0; margin: 0 0 28px; }
.file-list li {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 10px 4px;
  border-bottom: 1px solid var(--border);
}
.file-list li:last-child { border-bottom: none; }
.file-list .empty { color: var(--muted); justify-content: flex-start; }
.item-link { color: var(--ink); text-decoration: none; flex: 1; display: flex; align-items: baseline; gap: 10px; }
.item-link:hover { color: var(--teal); }
.item-link .size { color: var(--muted); font-size: 0.78rem; font-weight: 400; }
.inline-form { margin: 0; }
.del-btn {
  margin: 0;
  background: none;
  color: var(--muted);
  border: none;
  padding: 4px 8px;
  font-size: 0.9rem;
  cursor: pointer;
}
.del-btn:hover { color: #b3261e; }

.actions-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 16px; }
@media (max-width: 900px) { .actions-grid { grid-template-columns: 1fr; } .app { flex-direction: column; } .sidebar { width: 100%; } }
.action-card label { margin-top: 0; }

.note-toolbar { display: flex; gap: 10px; margin-bottom: 18px; }
.note-editor { width: 100%; font-family: ui-monospace, SFMono-Regular, Menlo, monospace; font-size: 0.9rem; line-height: 1.5; }

.note-content { background: var(--card); border: 1px solid var(--border); border-radius: 14px; padding: 28px 32px; line-height: 1.65; }
.note-content h1, .note-content h2, .note-content h3 { margin-top: 1.2em; }
.note-content pre { background: #f4ede4; padding: 12px; border-radius: 8px; overflow-x: auto; }
.note-content code { background: #f4ede4; padding: 2px 5px; border-radius: 4px; font-size: 0.88em; }
.note-content pre code { background: none; padding: 0; }
.note-content img { max-width: 100%; border-radius: 8px; }
.note-content .empty { color: var(--muted); }

.search-results .snippet { color: var(--muted); font-size: 0.82rem; margin-top: 2px; flex-basis: 100%; }
.search-results li { flex-direction: column; align-items: flex-start; }
