/* Personal Notes – modern look, cool colours with gradient (light + automatic dark mode) */
:root {
	--accent: #2f6fe4; --accent-2: #0ea5e9; --accent-soft: #e6f0fe; --accent-ink: #1e3a8a;
	--grad: linear-gradient(135deg, #06b6d4 0%, #3b82f6 55%, #6366f1 100%);
	--glow-a: #06b6d4; --glow-b: #6366f1;
	--bg: #f3f6fa; --surface: #ffffff; --surface-2: #f7f9fc; --ink: #0f172a; --muted: #64748b; --line: #e2e8f0;
	--danger: #dc2f4f; --ok: #0f9f6e; --shadow: 0 1px 2px rgba(15,23,42,.05), 0 4px 16px rgba(15,23,42,.06);
	--radius: 14px; --side: 248px; --bar: 60px;
}
@media (prefers-color-scheme: dark) {
	:root {
		--accent: #6ea8ff; --accent-2: #38bdf8; --accent-soft: #16233b; --accent-ink: #bcd4ff;
		--bg: #0b1120; --surface: #111827; --surface-2: #162032; --ink: #e5edf7; --muted: #94a3b8; --line: #1f2b3e;
		--danger: #fb7185; --ok: #34d399; --shadow: 0 1px 2px rgba(0,0,0,.35), 0 6px 20px rgba(0,0,0,.3);
	}
}* { box-sizing: border-box; }
html, body { margin: 0; }
body { background: var(--bg); color: var(--ink); font: 15px/1.6 'Inter', system-ui, -apple-system, 'Segoe UI', sans-serif; -webkit-font-smoothing: antialiased; }
a { color: var(--accent); text-decoration: none; }
a:hover { color: var(--accent-2); }
h2 { font-size: 1.35rem; font-weight: 700; letter-spacing: -.01em; margin: 0 0 18px; display: flex; flex-wrap: wrap; align-items: center; gap: 10px 14px; }
h3 { margin: 0; font-size: 1.05rem; font-weight: 650; }
button { font: inherit; }

/* ---------- top bar ---------- */
.appbar::after { content: ""; position: absolute; left: 0; right: 0; bottom: -1px; height: 2px; background: var(--grad); opacity: .85; }
.appbar { position: sticky; top: 0; z-index: 30; height: var(--bar); display: flex; align-items: center; gap: 14px; padding: 0 18px;
	background: color-mix(in srgb, var(--surface) 85%, transparent); backdrop-filter: blur(12px); -webkit-backdrop-filter: blur(12px); border-bottom: 1px solid var(--line); }
.brand { display: flex; align-items: center; gap: 10px; color: var(--ink); font-weight: 700; font-size: 1.1rem; width: calc(var(--side) - 18px); flex: none; }
.brand:hover { color: var(--ink); }
.logo { width: 34px; height: 34px; border-radius: 10px; display: grid; place-items: center; color: #fff; background: var(--grad); }
.search { flex: 1; max-width: 560px; display: flex; align-items: center; gap: 10px; background: var(--surface-2); border: 1px solid var(--line); border-radius: 999px; padding: 0 14px; height: 40px; color: var(--muted); }
.search:focus-within { border-color: var(--accent); box-shadow: 0 0 0 4px var(--accent-soft); }
.search input { flex: 1; min-width: 0; border: 0; background: transparent; color: var(--ink); font: inherit; outline: none; }
.top-nav { margin-left: auto; display: flex; align-items: center; gap: 4px; }
.top-nav a { display: flex; align-items: center; gap: 8px; padding: 8px 12px; border-radius: 10px; color: var(--muted); font-weight: 500; }
.top-nav a:hover { background: var(--surface-2); color: var(--ink); }
.top-nav a.on { background: var(--accent-soft); color: var(--accent-ink); }
.user { width: 34px; height: 34px; border-radius: 50%; display: grid; place-items: center; margin-left: 6px; font-weight: 700; color: var(--accent-ink); background: var(--accent-soft); }
.icon-btn { width: 38px; height: 38px; border-radius: 10px; border: 0; background: transparent; color: var(--muted); cursor: pointer; display: grid; place-items: center; }
.icon-btn:hover { background: var(--surface-2); color: var(--ink); }
.menu-btn { display: none; }
form.inline { display: inline; margin: 0; }

/* ---------- layout ---------- */
.shell { display: flex; align-items: flex-start; }
.side { width: var(--side); flex: none; position: sticky; top: var(--bar); height: calc(100vh - var(--bar)); overflow-y: auto; padding: 18px 12px 24px;
	border-right: 1px solid var(--line); background: var(--surface); scrollbar-width: thin; }
.new-btn { display: flex; align-items: center; justify-content: center; gap: 8px; padding: 10px 14px; border-radius: 12px; font-weight: 600; color: #fff;
	background: var(--grad); box-shadow: 0 6px 16px color-mix(in srgb, var(--accent) 35%, transparent); }
.new-btn:hover { color: #fff; filter: brightness(1.06); }
.side-head { display: flex; align-items: center; gap: 8px; margin: 20px 4px 8px; font-size: .72rem; font-weight: 700; letter-spacing: .08em; text-transform: uppercase; color: var(--muted); }
.cat-filter { margin-left: auto; width: 100px; font: inherit; font-size: .8rem; letter-spacing: 0; text-transform: none; padding: 4px 8px; border: 1px solid var(--line); border-radius: 8px; background: var(--surface-2); color: var(--ink); }
.cats a { display: flex; align-items: center; justify-content: space-between; gap: 8px; padding: 4px 10px; border-radius: 8px; color: var(--ink); font-size: .9rem; line-height: 1.5; }
.cats a span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.cats a small { flex: none; font-size: .72rem; color: var(--muted); background: var(--surface-2); border-radius: 999px; padding: 0 7px; }
.cats a:hover { background: var(--surface-2); }
.cats a.on { background: var(--accent-soft); color: var(--accent-ink); font-weight: 600; }
.cats a.on small { background: transparent; color: var(--accent-ink); }
.cats .cat-all { margin-bottom: 4px; gap: 8px; justify-content: flex-start; color: var(--muted); }
.cats a[hidden] { display: none; }
.scrim { display: none; }
.content { flex: 1; min-width: 0; padding: 28px clamp(16px, 4vw, 48px) 60px; max-width: 980px; }

/* ---------- notes ---------- */
.note { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 18px 20px; margin: 0 0 14px; box-shadow: var(--shadow); transition: border-color .15s; }
.note:hover { border-color: color-mix(in srgb, var(--accent) 35%, var(--line)); }
.note h3 { display: flex; justify-content: space-between; align-items: flex-start; gap: 10px; margin-bottom: 8px; }
.note .text { overflow-wrap: anywhere; color: color-mix(in srgb, var(--ink) 88%, var(--muted)); }
.edit { flex: none; width: 32px; height: 32px; border-radius: 8px; display: grid; place-items: center; color: var(--muted); font-size: .85rem; }
.edit:hover { background: var(--accent-soft); color: var(--accent-ink); }
.meta { display: flex; justify-content: space-between; align-items: center; gap: 8px; margin-top: 14px; padding-top: 12px; border-top: 1px dashed var(--line); font-size: .8rem; color: var(--muted); }
.tag { background: var(--accent-soft); color: var(--accent-ink); border-radius: 999px; padding: 2px 10px; font-weight: 600; }
.muted { color: var(--muted); }
.toast { display: flex; align-items: center; gap: 8px; background: color-mix(in srgb, var(--ok) 12%, var(--surface)); color: var(--ok);
	border: 1px solid color-mix(in srgb, var(--ok) 30%, transparent); border-radius: 12px; padding: 10px 14px; margin-bottom: 18px; font-weight: 500; }
.notice { border-radius: 12px; padding: 10px 14px; margin-bottom: 14px; }
.notice.err { background: color-mix(in srgb, var(--danger) 12%, var(--surface)); color: var(--danger); border: 1px solid color-mix(in srgb, var(--danger) 30%, transparent); }

/* rename category (pencil next to the category title) */
.rename { font-size: .9rem; font-weight: 500; }
.rename summary { list-style: none; cursor: pointer; width: 32px; height: 32px; border-radius: 8px; display: grid; place-items: center; color: var(--muted); font-size: .85rem; }
.rename summary::-webkit-details-marker { display: none; }
.rename summary:hover, .rename[open] summary { background: var(--accent-soft); color: var(--accent-ink); }
.rename form { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; margin-top: 8px; }
.rename input { font: inherit; padding: 7px 10px; border: 1px solid var(--line); border-radius: 10px; background: var(--surface); color: var(--ink); min-width: 220px; }
.rename input:focus { outline: none; border-color: var(--accent); box-shadow: 0 0 0 4px var(--accent-soft); }
.rename .hint { font-size: .78rem; color: var(--muted); width: 100%; }
h2:has(.rename[open]) { align-items: flex-start; }

/* ---------- forms ---------- */
.card { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 22px 24px; box-shadow: var(--shadow); }
.form { max-width: 820px; }
.form label, .login label { display: block; font-size: .85rem; font-weight: 600; color: var(--muted); margin-bottom: 16px; }
.form input, .form textarea, .login input { display: block; width: 100%; margin-top: 6px; font: inherit; font-size: .95rem; color: var(--ink); padding: 10px 12px;
	border: 1px solid var(--line); border-radius: 10px; background: var(--surface-2); transition: border-color .15s, box-shadow .15s; }
.form textarea { resize: vertical; min-height: 260px; font-family: ui-monospace, 'Cascadia Code', Consolas, monospace; font-size: .9rem; line-height: 1.55; }
.form input:focus, .form textarea:focus, .login input:focus { outline: none; border-color: var(--accent); box-shadow: 0 0 0 4px var(--accent-soft); background: var(--surface); }
.actions { display: flex; gap: 16px; align-items: center; }
.btn { display: inline-flex; align-items: center; gap: 8px; border: 0; border-radius: 10px; padding: 10px 20px; font-weight: 600; cursor: pointer; color: #fff;
	background: var(--grad); }
.btn:hover { color: #fff; filter: brightness(1.06); }
.btn.small { padding: 6px 12px; font-size: .85rem; }
.btn.ghost { background: transparent; color: var(--danger); border: 1px solid color-mix(in srgb, var(--danger) 40%, transparent); }
.btn.ghost:hover { background: color-mix(in srgb, var(--danger) 10%, transparent); filter: none; }
.danger { margin-top: 16px; }

/* ---------- login ---------- */
.guest { min-height: 100vh; background: radial-gradient(1200px 600px at 10% -10%, color-mix(in srgb, var(--glow-a) 28%, transparent), transparent),
	radial-gradient(900px 500px at 110% 110%, color-mix(in srgb, var(--glow-b) 28%, transparent), transparent), var(--bg); }
.guest-main { min-height: 100vh; display: grid; place-items: center; padding: 20px; }
.login { width: min(380px, 100%); }
.login h1 { display: flex; align-items: center; gap: 12px; font-size: 1.35rem; margin: 0 0 22px; }
.login .btn { width: 100%; justify-content: center; padding: 12px; margin-top: 4px; }

/* ---------- links ---------- */
.group { margin: 22px 0 8px; font-size: .72rem; font-weight: 700; letter-spacing: .08em; text-transform: uppercase; color: var(--muted); }
.link { display: grid; grid-template-columns: minmax(0, 2fr) minmax(0, 3fr) auto; align-items: center; gap: 12px; padding: 10px 14px; margin-bottom: 6px;
	background: var(--surface); border: 1px solid var(--line); border-radius: 12px; }
.link:hover { border-color: color-mix(in srgb, var(--accent) 35%, var(--line)); }
.link .lt { font-weight: 600; color: var(--ink); }
.link .lt, .link .lu { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.link .lu { color: var(--muted); font-size: .88rem; }

/* ---------- files ---------- */
.tabs { display: inline-flex; gap: 4px; padding: 4px; background: var(--surface); border: 1px solid var(--line); border-radius: 12px; font-size: .85rem; font-weight: 500; }
.tabs a { padding: 5px 12px; border-radius: 8px; color: var(--muted); }
.tabs a.on { background: var(--accent-soft); color: var(--accent-ink); }
.dropzone { border: 2px dashed color-mix(in srgb, var(--accent) 45%, var(--line)) !important; border-radius: var(--radius) !important;
	background: var(--surface) !important; min-height: 130px !important; color: var(--muted); }
.dz-done { margin: 10px 0 20px; }
.files { display: grid; grid-template-columns: repeat(auto-fill, minmax(160px, 1fr)); gap: 12px; }
.file { position: relative; height: 160px; border: 1px solid var(--line); border-radius: var(--radius); background: var(--surface) center / cover no-repeat; overflow: hidden; box-shadow: var(--shadow); }
.file .open { position: absolute; inset: 0; display: flex; flex-direction: column; justify-content: flex-end; align-items: flex-start; padding: 10px; }
.file:not(.photo) .open { justify-content: center; align-items: center; text-align: center; gap: 10px; }
.file .open img { width: 38px; height: 38px; }
.fname { background: color-mix(in srgb, var(--surface) 88%, transparent); color: var(--ink); border-radius: 6px; padding: 2px 8px; font-size: .78rem; max-width: 100%; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.file form { position: absolute; top: 6px; right: 6px; margin: 0; opacity: 0; transition: opacity .15s; }
.file:hover form, .file:focus-within form { opacity: 1; }
.file .del { border: 0; width: 28px; height: 28px; border-radius: 8px; cursor: pointer; color: var(--danger); background: color-mix(in srgb, var(--surface) 92%, transparent); }

/* ---------- phones & tablets ---------- */
@media (max-width: 860px) {
	:root { --side: 280px; }
	.menu-btn { display: grid; }
	.brand { width: auto; }
	.brand-t, .top-nav a span, .user { display: none; }
	.appbar { gap: 6px; padding: 0 8px; }
	.search { min-width: 0; padding: 0 10px; gap: 6px; }
	.search input { width: 100%; }
	.top-nav { gap: 0; }
	.top-nav a { padding: 8px; }
	.side { position: fixed; left: 0; top: var(--bar); z-index: 40; height: calc(100vh - var(--bar)); transform: translateX(-100%); transition: transform .2s ease; box-shadow: var(--shadow); }
	body.side-open .side { transform: none; }
	body.side-open .scrim { display: block; position: fixed; inset: var(--bar) 0 0 0; z-index: 35; background: rgba(0,0,0,.35); }
	.content { padding: 18px 14px 50px; }
	.link { grid-template-columns: 1fr auto; }
	.link .edit { grid-column: 2; grid-row: 1; }
	.link .lu { grid-column: 1 / -1; grid-row: 2; }
	.file form { opacity: 1; }
}
@media (prefers-reduced-motion: reduce) { * { transition: none !important; } }
