:root {
  --bg: #0b0f14;
  --panel: #131a22;
  --panel-2: #18212b;
  --line: #24303d;
  --text: #e6edf3;
  --muted: #8b98a5;
  --accent: #4f8cff;
  --accent-2: #2f6bdd;
  --danger: #ff6b6b;
  --ok: #3ddc97;
  --radius: 12px;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  background: radial-gradient(1200px 600px at 20% -10%, #16202b 0%, var(--bg) 55%) fixed;
  color: var(--text);
  font: 15px/1.55 -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC", "Microsoft YaHei", sans-serif;
  min-height: 100%;
}

.hidden { display: none !important; }
.muted { color: var(--muted); font-size: 13px; }

button {
  cursor: pointer;
  border-radius: 9px;
  border: 1px solid var(--line);
  background: var(--panel-2);
  color: var(--text);
  padding: 9px 14px;
  font-size: 14px;
  transition: filter .15s ease, background .15s ease;
}
button:hover { filter: brightness(1.15); }
button.primary { background: linear-gradient(180deg, var(--accent), var(--accent-2)); border-color: transparent; font-weight: 600; }
button.secondary { background: #1d2836; }
button.ghost { background: transparent; border-color: transparent; color: var(--muted); }
button.ghost:hover { color: var(--text); }
button.small { padding: 4px 8px; font-size: 12px; }

input {
  width: 100%;
  margin-top: 6px;
  padding: 11px 12px;
  border-radius: 9px;
  border: 1px solid var(--line);
  background: #0e151d;
  color: var(--text);
  font-size: 14px;
  outline: none;
}
input:focus { border-color: var(--accent); }

label { display: block; margin: 14px 0; font-size: 13px; color: var(--muted); }

/* auth */
.view.hidden { display: none; }
#auth-view {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 24px;
}
.auth-card {
  width: 100%;
  max-width: 400px;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 16px;
  padding: 28px;
  box-shadow: 0 20px 60px rgba(0,0,0,.45);
}
.brand { font-size: 24px; font-weight: 700; letter-spacing: .3px; margin: 0; }
.sub { color: var(--muted); font-size: 13px; margin: 8px 0 18px; }
.tabs { display: flex; gap: 6px; background: #0e151d; padding: 4px; border-radius: 10px; border: 1px solid var(--line); }
.tab { flex: 1; background: transparent; border: none; color: var(--muted); padding: 8px; border-radius: 8px; }
.tab.active { background: var(--panel-2); color: var(--text); font-weight: 600; }
.msg { color: var(--danger); font-size: 13px; min-height: 18px; margin: 10px 0 0; }
.msg.ok { color: var(--ok); }
#auth-form button[type="submit"] { width: 100%; margin-top: 10px; padding: 12px; }

/* main */
.topbar {
  display: flex; justify-content: space-between; align-items: center;
  padding: 16px 24px; border-bottom: 1px solid var(--line);
  background: rgba(11,15,20,.8); backdrop-filter: blur(8px);
  position: sticky; top: 0; z-index: 5;
}
.topbar .right { display: flex; align-items: center; gap: 12px; }
.container { max-width: 1080px; margin: 0 auto; padding: 28px 24px 60px; }
.row { display: flex; align-items: center; }
.row.between { justify-content: space-between; }
.row.end { justify-content: flex-end; }
.row.gap { gap: 10px; }
.row.center { align-items: center; }
h2 { margin: 0; font-size: 20px; }
h3 { margin: 0; font-size: 17px; }
.hint { color: var(--muted); font-size: 13px; margin: 10px 0 18px; }

.grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(300px, 1fr)); gap: 14px; }
.card {
  background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius);
  padding: 16px; display: flex; flex-direction: column; gap: 10px;
}
.card h4 { margin: 0; font-size: 16px; display: flex; justify-content: space-between; gap: 8px; }
.badge { font-size: 11px; color: var(--muted); border: 1px solid var(--line); padding: 2px 8px; border-radius: 999px; white-space: nowrap; }
.card .link { font-size: 12px; color: var(--muted); word-break: break-all; background: #0e151d; border: 1px solid var(--line); border-radius: 8px; padding: 8px; }
.card .actions { display: flex; gap: 8px; margin-top: auto; }
.empty { color: var(--muted); text-align: center; padding: 40px; border: 1px dashed var(--line); border-radius: var(--radius); }

/* modal */
.modal { position: fixed; inset: 0; background: rgba(0,0,0,.6); display: grid; place-items: center; padding: 20px; z-index: 20; }
.modal-card {
  width: 100%; max-width: 640px; max-height: 86vh; overflow: auto;
  background: var(--panel); border: 1px solid var(--line); border-radius: 16px; padding: 22px;
}
.nodes { max-height: 34vh; overflow: auto; border: 1px solid var(--line); border-radius: 10px; margin: 10px 0; }
.node { display: flex; align-items: center; gap: 10px; padding: 9px 12px; border-bottom: 1px solid #1b242f; font-size: 14px; }
.node:last-child { border-bottom: none; }
.node:hover { background: #16202b; }
.node input { width: 16px; margin: 0; }
.node .meta { margin-left: auto; color: var(--muted); font-size: 12px; }

.linkbox { display: flex; gap: 8px; margin: 14px 0; }
.linkbox input { margin: 0; font-family: ui-monospace, SFMono-Regular, Menlo, monospace; font-size: 13px; }

.toast {
  position: fixed; bottom: 24px; left: 50%; transform: translateX(-50%);
  background: #1d2836; border: 1px solid var(--line); color: var(--text);
  padding: 10px 16px; border-radius: 10px; z-index: 50; font-size: 14px;
  box-shadow: 0 10px 30px rgba(0,0,0,.4);
}
.toast.err { border-color: #5a2a2a; color: #ffb4b4; }
