:root {
  --bg: #0f1115;
  --panel: #1a1d24;
  --panel-2: #20242c;
  --border: #2a2e38;
  --text: #eaeaea;
  --muted: #8b8f9a;
  --accent: #d97757;
  --accent-2: #7ea9d9;
  --green: #4caf7d;
  --amber: #e0b354;
  --red: #e0685a;
  --radius: 10px;
}

* { box-sizing: border-box; }

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

/* --- Login --- */
.login-body { display: flex; align-items: center; justify-content: center; height: 100vh; }
.login-card {
  background: var(--panel);
  padding: 2.5rem;
  border-radius: 14px;
  width: 340px;
  box-shadow: 0 20px 60px rgba(0,0,0,.5);
  border: 1px solid var(--border);
}
.brand { font-size: 1.3rem; font-weight: 700; margin-bottom: .25rem; }
.brand span { color: var(--text); }
.muted { color: var(--muted); font-size: .85rem; margin: 0 0 1.5rem; }
.err { color: var(--red); font-size: .8rem; margin-bottom: 1rem; }
label { display: block; font-size: .8rem; color: #bbb; margin-bottom: .3rem; margin-top: .8rem; }
input, select, textarea {
  width: 100%;
  padding: .6rem .7rem;
  border-radius: 7px;
  border: 1px solid var(--border);
  background: var(--bg);
  color: var(--text);
  font-family: inherit;
  font-size: .9rem;
}
button {
  padding: .65rem 1.1rem;
  border: none;
  border-radius: 7px;
  background: var(--accent);
  color: #fff;
  font-weight: 600;
  cursor: pointer;
  font-size: .9rem;
}
button:hover { background: #c86a4c; }
button.secondary { background: var(--panel-2); color: var(--text); border: 1px solid var(--border); }
button.secondary:hover { background: #262b34; }
button.danger { background: transparent; color: var(--red); border: 1px solid #4a2a28; }
.login-card form button { width: 100%; margin-top: 1.5rem; }

/* --- App shell --- */
.app { display: grid; grid-template-columns: 220px 1fr; min-height: 100vh; }
.sidebar {
  background: var(--panel);
  border-right: 1px solid var(--border);
  padding: 1.5rem 1rem;
  display: flex;
  flex-direction: column;
}
.sidebar .brand { font-size: 1.1rem; margin-bottom: 1.5rem; padding: 0 .5rem; }
.nav-item {
  padding: .6rem .8rem;
  border-radius: 8px;
  color: var(--muted);
  cursor: pointer;
  font-size: .9rem;
  margin-bottom: .2rem;
}
.nav-item.active, .nav-item:hover { background: var(--panel-2); color: var(--text); }
.sidebar-footer { margin-top: auto; padding-top: 1rem; border-top: 1px solid var(--border); }
.sidebar-footer form button { width: 100%; }

main { padding: 2rem 2.5rem; max-width: 1100px; }
h1 { font-size: 1.4rem; margin: 0 0 .3rem; }
h2 { font-size: 1rem; color: var(--muted); font-weight: 600; margin: 2rem 0 .8rem; text-transform: uppercase; letter-spacing: .04em; }
.subtitle { color: var(--muted); font-size: .9rem; margin-bottom: 2rem; }

.stat-grid { display: grid; grid-template-columns: repeat(4, 1fr); gap: 1rem; }
.stat-card {
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1.2rem;
}
.stat-card .num { font-size: 1.8rem; font-weight: 700; }
.stat-card .label { color: var(--muted); font-size: .8rem; margin-top: .2rem; }

.search-row { display: flex; gap: .6rem; margin-bottom: 1.2rem; }
.search-row input[type="text"] { flex: 1; }
.search-row select { width: 160px; }

.memory-list { display: flex; flex-direction: column; gap: .6rem; }
.memory-card {
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: .9rem 1.1rem;
}
.memory-card .top { display: flex; justify-content: space-between; align-items: center; gap: .5rem; margin-bottom: .35rem; }
.tag {
  font-size: .7rem;
  padding: .15rem .5rem;
  border-radius: 999px;
  background: var(--panel-2);
  color: var(--muted);
  border: 1px solid var(--border);
}
.tag.project { color: var(--accent-2); border-color: #2b3a4a; }
.tag.importance-3 { color: var(--amber); border-color: #4a3a20; }
.memory-card .content { font-size: .92rem; line-height: 1.4; }
.memory-card .meta { color: var(--muted); font-size: .75rem; margin-top: .4rem; }
.memory-card .actions { display: flex; gap: .4rem; }
.memory-card .actions button { padding: .25rem .5rem; font-size: .7rem; }

.bar-row { display: flex; align-items: center; gap: .6rem; margin-bottom: .5rem; }
.bar-label { width: 110px; font-size: .82rem; color: var(--muted); flex-shrink: 0; }
.bar-track { flex: 1; background: var(--panel-2); border-radius: 5px; height: 10px; overflow: hidden; }
.bar-fill { background: var(--accent); height: 100%; border-radius: 5px; }
.bar-count { width: 34px; text-align: right; font-size: .8rem; color: var(--muted); }

.add-form { background: var(--panel); border: 1px solid var(--border); border-radius: var(--radius); padding: 1.2rem; margin-bottom: 2rem; }
.add-form .row { display: flex; gap: .6rem; margin-top: .8rem; }
.add-form .row > * { flex: 1; }
.add-form button { margin-top: 1rem; }

.empty { color: var(--muted); font-size: .9rem; padding: 2rem 0; text-align: center; }

table { width: 100%; border-collapse: collapse; font-size: .85rem; }
th { text-align: left; color: var(--muted); font-weight: 600; padding: .5rem; border-bottom: 1px solid var(--border); }
td { padding: .6rem .5rem; border-bottom: 1px solid var(--border); }

code.mini {
  background: var(--panel-2);
  padding: .15rem .4rem;
  border-radius: 5px;
  font-size: .8rem;
  color: var(--accent-2);
}
