*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

:root {
  --bg: #1a1a2e;
  --surface: #16213e;
  --surface2: #0f3460;
  --accent: #e94560;
  --accent2: #533483;
  --text: #eaeaea;
  --muted: #888;
  --radius: 6px;
  --font: 'Segoe UI', system-ui, sans-serif;
}

body {
  background: var(--bg);
  color: var(--text);
  font-family: var(--font);
  min-height: 100vh;
}

/* Auth */
.screen {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 100vh;
}

.auth-box {
  background: var(--surface);
  padding: 2rem;
  border-radius: var(--radius);
  display: flex;
  flex-direction: column;
  gap: 1rem;
  width: 320px;
}

.auth-box h1 {
  text-align: center;
  font-size: 1.8rem;
  color: var(--accent);
  letter-spacing: 2px;
}

input[type="password"], textarea, input[type="text"] {
  background: var(--bg);
  border: 1px solid var(--surface2);
  color: var(--text);
  border-radius: var(--radius);
  padding: 0.6rem 0.8rem;
  font-size: 1rem;
  font-family: var(--font);
  width: 100%;
  outline: none;
  transition: border-color 0.2s;
}

input:focus, textarea:focus { border-color: var(--accent); }

button {
  background: var(--accent);
  color: #fff;
  border: none;
  border-radius: var(--radius);
  padding: 0.5rem 1rem;
  cursor: pointer;
  font-size: 0.95rem;
  transition: opacity 0.15s;
}

button:hover { opacity: 0.85; }

.error { color: var(--accent); font-size: 0.85rem; text-align: center; }
.hidden { display: none !important; }

/* App shell */
#app { display: flex; flex-direction: column; min-height: 100vh; }

header {
  background: var(--surface);
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0.5rem 1rem;
  border-bottom: 1px solid var(--surface2);
  position: sticky;
  top: 0;
  z-index: 10;
}

nav { display: flex; gap: 0.5rem; }

.tab {
  background: transparent;
  color: var(--muted);
  border: 1px solid transparent;
  padding: 0.4rem 1rem;
  font-size: 0.9rem;
}

.tab.active {
  background: var(--surface2);
  color: var(--text);
  border-color: var(--accent);
}

#btn-logout { background: transparent; color: var(--muted); font-size: 1.1rem; }

/* Capture view */
#capture-view { padding: 1.5rem; max-width: 700px; margin: 0 auto; width: 100%; }

.capture-area { display: flex; flex-direction: column; gap: 0.5rem; }

#capture-input {
  height: 120px;
  resize: vertical;
  font-size: 1.1rem;
  line-height: 1.5;
}

#capture-save { align-self: flex-end; }

#recent-list {
  list-style: none;
  margin-top: 1.5rem;
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}

.recent-item {
  background: var(--surface);
  border-radius: var(--radius);
  padding: 0.7rem 1rem;
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 1rem;
  animation: fadeIn 0.2s ease;
}

.recent-item .content { flex: 1; white-space: pre-wrap; word-break: break-word; }
.recent-item .meta { color: var(--muted); font-size: 0.75rem; flex-shrink: 0; }

@keyframes fadeIn { from { opacity: 0; transform: translateY(-4px); } to { opacity: 1; } }

/* Organize view */
#organize-view { padding: 1rem 1.5rem; }

.organize-toolbar {
  display: flex;
  gap: 0.5rem;
  margin-bottom: 1rem;
}

.organize-toolbar button {
  background: var(--surface2);
  color: var(--text);
  font-size: 0.8rem;
  padding: 0.3rem 0.7rem;
}

.tree { padding-left: 0; }

.tree-node {
  margin: 2px 0;
  user-select: none;
}

.node-row {
  display: flex;
  align-items: center;
  gap: 0.4rem;
  padding: 0.35rem 0.6rem;
  border-radius: var(--radius);
  cursor: pointer;
  transition: background 0.1s;
  position: relative;
}

.node-row:hover { background: var(--surface); }
.node-row.drag-over { background: var(--surface2); outline: 2px dashed var(--accent); }

.toggle-btn {
  background: transparent;
  color: var(--muted);
  padding: 0;
  width: 1.2rem;
  font-size: 0.7rem;
  flex-shrink: 0;
}

.toggle-btn:hover { color: var(--text); opacity: 1; }

.node-label {
  flex: 1;
  white-space: pre-wrap;
  word-break: break-word;
  font-size: 0.95rem;
}

.node-label-input {
  flex: 1;
  background: var(--bg);
  border: 1px solid var(--accent);
  color: var(--text);
  padding: 2px 6px;
  border-radius: 3px;
  font-size: 0.95rem;
}

.node-actions {
  display: none;
  gap: 0.3rem;
  flex-shrink: 0;
}

.node-row:hover .node-actions { display: flex; }

.node-actions button {
  background: var(--surface2);
  color: var(--muted);
  padding: 2px 6px;
  font-size: 0.75rem;
}

.node-actions button:hover { color: var(--text); }

.children { padding-left: 1.4rem; border-left: 1px solid var(--surface2); margin-left: 0.8rem; }

.dragging { opacity: 0.4; }

.node-add-child {
  background: transparent;
  color: var(--muted);
  font-size: 0.75rem;
  padding: 1px 5px;
}

.orphan-header {
  color: var(--muted);
  font-size: 0.8rem;
  padding: 0.5rem 0.6rem;
  border-top: 1px solid var(--surface2);
  margin-top: 1rem;
}

/* Link mode */
.link-banner {
  background: var(--accent2);
  color: var(--text);
  padding: 0.5rem 1rem;
  display: flex;
  align-items: center;
  gap: 1rem;
  font-size: 0.9rem;
}

.link-banner button {
  background: transparent;
  border: 1px solid var(--text);
  color: var(--text);
  padding: 2px 10px;
  font-size: 0.8rem;
}

.link-target .node-row { cursor: crosshair; outline: 1px dashed var(--accent2); border-radius: var(--radius); }
.link-target .node-row:hover { background: var(--accent2); }

/* Edge badges */
.edge-list {
  padding: 0.2rem 0.6rem 0.4rem 2.4rem;
  display: flex;
  flex-wrap: wrap;
  gap: 0.3rem;
}

.edge-badge {
  display: inline-flex;
  align-items: center;
  gap: 0.3rem;
  font-size: 0.72rem;
  padding: 2px 6px;
  border-radius: 20px;
  color: #fff;
}

.edge-inspireret_af  { background: #1a6b55; }
.edge-modsiger       { background: #7a2020; }
.edge-relaterer_til  { background: #2a4a7a; }

.edge-remove {
  background: transparent;
  color: rgba(255,255,255,0.6);
  padding: 0 2px;
  font-size: 0.65rem;
  line-height: 1;
}
.edge-remove:hover { color: #fff; opacity: 1; }

/* Kind modal */
.modal {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.6);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 100;
}

.modal-box {
  background: var(--surface);
  border-radius: var(--radius);
  padding: 1.5rem;
  display: flex;
  flex-direction: column;
  gap: 0.6rem;
  min-width: 220px;
}

.modal-box p { color: var(--muted); font-size: 0.85rem; margin-bottom: 0.3rem; }

.modal-box button { width: 100%; text-align: left; }

.cancel-btn { background: transparent; color: var(--muted); border: 1px solid var(--surface2); margin-top: 0.3rem; }

/* Auth tabs */
.auth-tabs { display: flex; gap: 0; border-radius: var(--radius); overflow: hidden; border: 1px solid var(--surface2); }
.auth-tab { flex: 1; background: transparent; color: var(--muted); border: none; border-radius: 0; padding: 0.5rem; font-size: 0.9rem; }
.auth-tab.active { background: var(--surface2); color: var(--text); }

/* Header right */
.header-right { display: flex; align-items: center; gap: 0.8rem; }
.user-label { color: var(--muted); font-size: 0.85rem; }
#btn-logout { background: transparent; color: var(--muted); font-size: 0.85rem; border: 1px solid var(--surface2); padding: 0.3rem 0.7rem; }

/* Groups view */
#groups-view { padding: 1.5rem; max-width: 700px; margin: 0 auto; width: 100%; }
.groups-toolbar { margin-bottom: 1rem; }
.no-groups { color: var(--muted); font-size: 0.9rem; }

.group-card {
  background: var(--surface);
  border-radius: var(--radius);
  margin-bottom: 0.8rem;
  overflow: hidden;
}

.group-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0.8rem 1rem;
}

.group-actions { display: flex; gap: 0.4rem; }
.group-actions button { font-size: 0.8rem; padding: 0.3rem 0.6rem; }
.group-del-btn { background: var(--accent) !important; }

.group-members-list { padding: 0 1rem 0.8rem; }

.member-list { list-style: none; display: flex; flex-direction: column; gap: 0.3rem; }
.member-list li { display: flex; align-items: center; gap: 0.5rem; font-size: 0.9rem; color: var(--muted); }
.member-del-btn { background: transparent; color: var(--accent); border: none; padding: 1px 4px; font-size: 0.75rem; }

.add-member-row { display: flex; gap: 0.5rem; margin-top: 0.6rem; }
.add-member-row select { flex: 1; background: var(--bg); border: 1px solid var(--surface2); color: var(--text); border-radius: var(--radius); padding: 0.4rem; font-size: 0.85rem; }
.add-member-btn { font-size: 0.8rem; padding: 0.3rem 0.7rem; }

/* Share modal */
.share-modal-box { min-width: 300px; max-width: 420px; }
.modal-title { color: var(--text); font-size: 1rem; margin-bottom: 0.5rem; }
.modal-subtitle { color: var(--muted); font-size: 0.8rem; margin-top: 0.3rem; }
.share-divider { border: none; border-top: 1px solid var(--surface2); margin: 0.6rem 0; }

.share-entry {
  display: flex;
  align-items: center;
  justify-content: space-between;
  font-size: 0.85rem;
  color: var(--muted);
  padding: 0.3rem 0;
}

.share-del-btn { background: transparent; color: var(--accent); border: none; padding: 2px 5px; font-size: 0.8rem; }
.no-shares { color: var(--muted); font-size: 0.85rem; }

.share-modal-box select {
  background: var(--bg);
  border: 1px solid var(--surface2);
  color: var(--text);
  border-radius: var(--radius);
  padding: 0.4rem;
  font-size: 0.9rem;
  width: 100%;
  margin-top: 0.4rem;
}

.share-edit-label { display: flex; align-items: center; gap: 0.4rem; font-size: 0.85rem; color: var(--muted); margin-top: 0.4rem; }
.share-edit-label input[type="checkbox"] { width: auto; }
.share-actions { display: flex; gap: 0.5rem; margin-top: 0.6rem; }
.share-actions button { flex: 1; }
