:root {
  --bg: #0a0d11;
  --panel: #10151b;
  --panel2: #141a21;
  --line: #202a33;
  --txt: #dce4ea;
  --mut: #7d8b97;
  --mut2: #57636c;
  --accent: #5eead4;
  --accent-dim: #1f7566;
}
* { box-sizing: border-box; }
html, body {
  margin: 0; height: 100%;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC", "Microsoft YaHei", sans-serif;
  background: var(--bg); color: var(--txt);
  overflow: hidden;
}

/* ---------- login ---------- */
.login-wrap {
  height: 100vh; display: flex; align-items: center; justify-content: center;
  background: radial-gradient(circle at 30% 20%, #132029, var(--bg) 60%);
}
.login-box {
  width: 300px; background: var(--panel); border: 1px solid var(--line);
  border-radius: 14px; padding: 28px 24px; text-align: center;
}
.login-box .brand { font-size: 20px; font-weight: 800; margin-bottom: 4px; }
.login-box .brand span { color: var(--accent); }
.login-box p { color: var(--mut); font-size: 12.5px; margin: 0 0 20px; }
.login-box input {
  width: 100%; background: rgba(255,255,255,0.06); border: 1px solid var(--line);
  border-radius: 8px; color: var(--txt); padding: 10px 12px; font-size: 14px; margin-bottom: 12px;
}
.login-box button {
  width: 100%; border: none; border-radius: 8px; background: var(--accent); color: #05222b;
  font-weight: 700; padding: 10px; font-size: 14px; cursor: pointer;
}
.login-error { color: #f87171; font-size: 12px; margin-top: 10px; min-height: 14px; }

/* ---------- board ---------- */
#board { height: 100vh; display: flex; flex-direction: column; }
.toolbar {
  flex: 0 0 auto; display: flex; align-items: center; gap: 14px;
  padding: 10px 18px; border-bottom: 1px solid var(--line); background: var(--panel);
  -webkit-user-select: none; user-select: none;
}
.toolbar .brand { font-size: 15px; font-weight: 800; }
.toolbar .brand span { color: var(--accent); }
.toolbar .hint { color: var(--mut2); font-size: 12px; flex: 1; }
.toolbar .back-link { color: var(--mut); font-size: 12.5px; text-decoration: none; }
.toolbar .back-link:hover { color: var(--accent); }

#viewport {
  flex: 1; overflow: auto; position: relative;
  background-image: radial-gradient(circle, #1a2129 1px, transparent 1px);
  background-size: 26px 26px;
  background-color: var(--bg);
  cursor: grab;
}
#viewport.panning { cursor: grabbing; }
#canvas { position: relative; }

.note {
  position: absolute; width: 280px; min-height: 130px;
  border-radius: 10px; box-shadow: 0 6px 18px rgba(0,0,0,0.35);
  display: flex; flex-direction: column; overflow: hidden;
}
.note .note-head {
  height: 20px; flex: 0 0 auto; cursor: grab;
  display: flex; align-items: center; justify-content: flex-end; padding: 0 6px;
  opacity: 0; transition: opacity 0.15s;
}
.note:hover .note-head { opacity: 1; }
.note .note-head.dragging { cursor: grabbing; }
.note .note-del, .note .note-img-del {
  border: none; background: transparent; color: rgba(0,0,0,0.45); font-size: 15px;
  cursor: pointer; line-height: 1; padding: 2px 4px;
}
.note .note-img-del { font-size: 12px; }
.note .note-del:hover, .note .note-img-del:hover { color: rgba(0,0,0,0.8); }
.note .note-image {
  display: block; width: 100%; max-height: 260px; object-fit: cover;
  cursor: default; -webkit-user-select: none; user-select: none;
}
.note textarea {
  flex: 1; resize: none; border: none; outline: none; background: transparent;
  padding: 4px 12px 12px; font: inherit; font-size: 13.5px; line-height: 1.5;
  color: #292415; -webkit-user-select: text; user-select: text;
}
.note textarea::placeholder { color: rgba(0,0,0,0.35); }
.note.dragging { box-shadow: 0 14px 32px rgba(0,0,0,0.5); z-index: 9999 !important; }

/* ---------- rendered markdown (view mode) ---------- */
.note-view {
  flex: 1; padding: 4px 12px 12px; font-size: 13.5px; line-height: 1.5;
  color: #292415; cursor: text; overflow-x: hidden; overflow-y: auto;
}
.note-view .note-placeholder { color: rgba(0,0,0,0.35); margin: 0; }
.note-view p { margin: 0 0 8px; }
.note-view p:last-child { margin-bottom: 0; }
.note-view h1, .note-view h2, .note-view h3, .note-view h4, .note-view h5, .note-view h6 {
  margin: 10px 0 6px; line-height: 1.3;
}
.note-view h1 { font-size: 17px; }
.note-view h2 { font-size: 15.5px; }
.note-view h3, .note-view h4, .note-view h5, .note-view h6 { font-size: 14px; }
.note-view ul, .note-view ol { margin: 0 0 8px; padding-left: 20px; }
.note-view li { margin: 2px 0; }
.note-view code {
  background: rgba(0,0,0,0.08); border-radius: 3px; padding: 1px 4px;
  font-family: ui-monospace, "SF Mono", Menlo, Consolas, monospace; font-size: 12px;
}
.note-view pre {
  background: rgba(0,0,0,0.08); border-radius: 6px; padding: 8px 10px; margin: 0 0 8px;
  overflow-x: auto;
}
.note-view pre code { background: none; padding: 0; }
.note-view blockquote {
  margin: 0 0 8px; padding: 2px 10px; border-left: 3px solid rgba(0,0,0,0.2); color: rgba(41,36,21,0.75);
}
.note-view blockquote p { margin: 0; }
.note-view a { color: #1d4ed8; word-break: break-word; }
.note-view hr { border: none; border-top: 1px solid rgba(0,0,0,0.15); margin: 8px 0; }
.note-view .md-table-wrap { overflow-x: auto; margin: 0 0 8px; max-width: 100%; }
.note-view table { border-collapse: collapse; font-size: 12.5px; }
.note-view th, .note-view td {
  border: 1px solid rgba(0,0,0,0.15); padding: 3px 7px; text-align: left; white-space: nowrap;
}
.note-view th { background: rgba(0,0,0,0.06); font-weight: 700; }

.empty-hint {
  position: absolute; top: 40px; left: 40px; color: var(--mut2); font-size: 13px;
  pointer-events: none;
}
